Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / CellFormula.cpp
diff options
context:
space:
mode:
Commitdf1d4f096d676be8faaf4f1183fdef09ff301706 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-28 19:29:45 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-28 19:29:45 +0300
Filesdc0e39b80918c89fc4486598b0a1c91b1e6da1bd /src/Models/CellFormula.cpp
FMI-OOP-P2_Tables-df1d4f096d676be8faaf4f1183fdef09ff301706.tar
FMI-OOP-P2_Tables-df1d4f096d676be8faaf4f1183fdef09ff301706.tar.gz
FMI-OOP-P2_Tables-df1d4f096d676be8faaf4f1183fdef09ff301706.zip
Parentfcb095cdbdee891365054a978533a9a0480ff03b (diff)
Autocommit at 28.05.2022 @ 19:29
1 files changed, 7 insertions, 2 deletions
-rw-r--r--src/Models/CellFormula.cpp9
diff --git a/src/Models/CellFormula.cpp b/src/Models/CellFormula.cpp
index 395e31c..631621d 100644
--- a/src/Models/CellFormula.cpp
+++ b/src/Models/CellFormula.cpp
@@ -10,8 +10,8 @@ CellFormula::CellFormula(const char* str, const List<List<Cell*>>* tableCells) :
double CellFormula::calculate(unsigned index) {
double lval = formula[index].left->getNumeralValue();
- if (formula[index].right & branch) {
- switch (formula[index++].right & !branch) {
+ if (formula[index].right < 0) {
+ switch (-formula[index++].right) {
case plus : lval += formula[index].left->getNumeralValue(); break;
case minus : lval -= formula[index].left->getNumeralValue(); break;
case mult : lval *= formula[index].left->getNumeralValue(); break;
@@ -42,6 +42,11 @@ void CellFormula::parseAndSetValue(const char* str) {
while (*str == ' ') str++;
if (*str == 'R') {
unsigned row = atoi(++str);
+ while (*str != 'C') str++;
+ unsigned col = atoi(++str);
+ while (*str != ' ') str++;
+
+ formula.add({(*tableCells)[row][col], (Op)*str});
}
}