From cb7ed2e2af57c98bbe22080ed5529777b8019b74 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 13:39:17 +0300 Subject: Autocommit at 14.06.2022 @ 13:39 --- src/Models/Table.cpp | 17 +++++++++-------- src/test.table | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 163926b..a3c03fe 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -72,9 +72,8 @@ void Table::readFromFile(std::ifstream& inFile) { W(inFile); if (inFile.peek() == ',') inFile.get(); - else if (inFile.peek() != '\n' || inFile.peek() != EOF) + else if (inFile.peek() != '\n' && inFile.peek() != EOF) throwException(inFile, row); - inFile.get(); cells[row].add((buffer[0] == '=') ? (Cell*)new CellFormula(buffer.raw_data(), &cells) @@ -93,16 +92,18 @@ void Table::readFromFile(std::ifstream& inFile) { buffer.add('\0'); W(inFile); - if (inFile.peek() != ',') throwException(inFile, row); - inFile.get(); + if (inFile.peek() == ',') inFile.get(); + else if (inFile.peek() != '\n' && inFile.peek() != EOF) + throwException(inFile, row); cells[row].add((Cell*)new CellDouble(buffer.raw_data())); } else { buffer.add('\0'); W(inFile); - if (inFile.peek() != ',') throwException(inFile, row); - inFile.get(); + if (inFile.peek() == ',') inFile.get(); + else if (inFile.peek() != '\n' && inFile.peek() != EOF) + throwException(inFile, row); cells[row].add((Cell*)new CellInt(buffer.raw_data())); } @@ -182,8 +183,8 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { List Table::getAllCells() const { List toRet; for (unsigned i = 0; i < cells.get_count(); i++) { - for (unsigned j = 0; j < cells[i].get_count(); j++) { - if (cells[i][j] != nullptr) + for (unsigned j = 0; j < get_cols(); j++) { + if (cells[i].get_count() - 1 >= j && cells[i][j] != nullptr) toRet.add(cells[i][j]->getValueForPrint()); else toRet.add(""); diff --git a/src/test.table b/src/test.table index 9570992..ca7c7b8 100644 --- a/src/test.table +++ b/src/test.table @@ -1,2 +1,2 @@ 8.6,3,"String","= 3 * R1C2 + R1C1 ^ R1C2 * 27 / R1C2 - 2 * 2.5 * 2 * 2 + R1C3 ^ R1C3","", -"HELLL YEAH BROTHER","Bruh","=R1C0 + R1C1",,,,,,,,,,"Wow", +"HELLL YEAH BROTHER","Bruh","=R1C0 + R1C1",,,,,,,,,,"Wow" -- cgit v1.3.1-26-gb76a