Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellFormula.cpp
diff options
context:
space:
mode:
Commit447009b8afc88e9be55780fa87083fe78c125d6f (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 14:04:24 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 14:04:24 +0300
Files305526c84abdc7e74769e8a82e3524e63d0092a8 /src/Models/CellFormula.cpp
FMI-OOP-P2_Tables-447009b8afc88e9be55780fa87083fe78c125d6f.tar
FMI-OOP-P2_Tables-447009b8afc88e9be55780fa87083fe78c125d6f.tar.gz
FMI-OOP-P2_Tables-447009b8afc88e9be55780fa87083fe78c125d6f.zip
Parentcb59aafe3b87daf2a736abba261928697fba714d (diff)
Autocommit at 14.06.2022 @ 14:04
1 files changed, 6 insertions, 4 deletions
-rw-r--r--src/Models/CellFormula.cpp10
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 6233921..9609238 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -6,12 +6,14 @@
const Cell* CellFormula::ptrByInd(Pair<int, int> loc) const {
if (loc.left < 0) {
- if (loc.right < 0 || &localCells.get_count() - 1 < loc.right) return nullptr;
+ if (loc.right < 0 || localCells.get_count() - 1 < loc.right) return nullptr;
return &localCells[loc.right];
}
+
if (loc.right < 0
- || )
- return (loc.left < 0) ? &localCells[loc.right] : (*tableCells)[loc.left][loc.right];
+ || (*tableCells).get_count() - 1 < loc.left || (*tableCells)[loc.left].get_count() - 1 < loc.right)
+ return nullptr;
+ return (*tableCells)[loc.left][loc.right];
}
double pow(double x, int y) {
@@ -25,7 +27,7 @@ double pow(double x, int y) {
double CellFormula::calculate(unsigned index) const {
const Cell* currCell = ptrByInd(formula[index].left);
- double numVal = currCell->getNumeralValue();
+ double numVal = (currCell == nullptr) ? 0 : currCell->getNumeralValue();
while (formula[index].right < 0) {
switch (-formula[index++].right) {