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 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/Models/Table.cpp') 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(""); -- cgit v1.3.1-23-gd82d