From 272f317bb0817ec46ecfae9696457ec84b8ec55c Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 30 May 2022 17:57:35 +0300 Subject: Autocommit at 30.05.2022 @ 17:57 --- src/Models/CellFormula.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/Models/CellFormula.cpp') diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp index 4990ee4..915c38d 100644 --- a/src/Models/CellFormula.cpp +++ b/src/Models/CellFormula.cpp @@ -3,6 +3,11 @@ #include #include #include + +const Cell* CellFormula::ptrByInd(int firstInd, int secondInd) const { + return (firstInd < 0) ? &localCells[secondInd] : (*tableCells)[firstInd][secondInd]; +} + double pow(double x, unsigned y) { if (y == 0) return 1; @@ -13,7 +18,7 @@ double pow(double x, unsigned y) { } double CellFormula::calculate(unsigned index) { - CellLoc& c = formula[index].left; + Cell* currCell = ptrByInd(formula[index].left); double lval = (c.firstInd == -1) ? localCells[c.secondInd].getNumeralValue() : (*tableCells)[c.firstInd][c.secondInd]->getNumeralValue(); while (formula[index].right < 0) { @@ -47,7 +52,7 @@ CellFormula::CellFormula(const char* str, const List>* tableCells) : #include -double CellFormula::getNumeralValue() { +double CellFormula::getNumeralValue() const { try { return calculate(); } @@ -56,7 +61,7 @@ double CellFormula::getNumeralValue() { } } -String CellFormula::getValueForPrint() { +String CellFormula::getValueForPrint() const { try { return String() += calculate(); } -- cgit v1.3.1-23-gd82d