From 2c961228ea05472cb86eab289f5f7859f492190b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 14 Jun 2022 07:23:27 +0300 Subject: Autocommit at 14.06.2022 @ 07:23 --- src/Models/Table.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/Models/Table.cpp') diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 68908fd..787652a 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -124,6 +124,14 @@ unsigned Table::get_cols() const { void Table::putCell(unsigned row, unsigned col, const char* rawValue) { Cell* newCell; + while (*rawValue == ' ') rawValue++; + + if (*rawValue == '"') { + rawValue++; + newCell = (*rawValue == '=') + ? (Cell*)new CellFormula(rawValue, &cells) + : (Cell*)new CellString(rawValue); + } if (containsNumber(rawValue)) { double doubleParse = atof(rawValue); unsigned intPart = abs(doubleParse); @@ -131,11 +139,7 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { newCell = (abs(doubleParse) - intPart > FLOATING_POINT_PRECISION) ? (Cell*)new CellDouble(doubleParse) : (Cell*)new CellInt(intPart); } - else if (*rawValue == '"') { - rawValue++; - newCell = (*rawValue == '=') - ? (Cell*)new CellFormula(rawValue, &cells) : (Cell*)new CellString(rawValue); - } + else throw std::logic_error("Error: Could not determine data type."); -- cgit v1.3.1-23-gd82d