diff --git a/src/Mod/Spreadsheet/App/Cell.cpp b/src/Mod/Spreadsheet/App/Cell.cpp index 031cf0fba..4daa1068e 100644 --- a/src/Mod/Spreadsheet/App/Cell.cpp +++ b/src/Mod/Spreadsheet/App/Cell.cpp @@ -235,7 +235,7 @@ void Cell::setContent(const char * value) if (expr) delete expr->eval(); } - catch (Base::Exception & e) { + catch (Base::Exception &) { expr = new StringExpression(owner->sheet(), value); } } diff --git a/src/Mod/Spreadsheet/App/Expression.cpp b/src/Mod/Spreadsheet/App/Expression.cpp index bdd590f9c..19960bb11 100644 --- a/src/Mod/Spreadsheet/App/Expression.cpp +++ b/src/Mod/Spreadsheet/App/Expression.cpp @@ -60,6 +60,10 @@ # define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/ #endif +#if defined(_MSC_VER) +#define strtoll _strtoi64 +#endif + using namespace Base; using namespace App; using namespace Spreadsheet; diff --git a/src/Mod/Spreadsheet/App/PreCompiled.h b/src/Mod/Spreadsheet/App/PreCompiled.h index bae4d0bfe..767e0fca1 100644 --- a/src/Mod/Spreadsheet/App/PreCompiled.h +++ b/src/Mod/Spreadsheet/App/PreCompiled.h @@ -33,14 +33,16 @@ # define SpreadsheetExport #endif -#ifdef _PreComp_ /// here get the warnings of to long specifieres disabled (needed for VC6) #ifdef _MSC_VER -# pragma warning( disable : 4251 ) -# pragma warning( disable : 4503 ) -# pragma warning( disable : 4786 ) // specifier longer then 255 chars +# pragma warning( disable : 4251 ) +# pragma warning( disable : 4275 ) +# pragma warning( disable : 4503 ) +# pragma warning( disable : 4786 ) // specifier longer then 255 chars #endif +#ifdef _PreComp_ + // standard #include #include diff --git a/src/Mod/Spreadsheet/App/PropertyColumnWidths.h b/src/Mod/Spreadsheet/App/PropertyColumnWidths.h index 8f3bbcbd2..9adfe17c0 100644 --- a/src/Mod/Spreadsheet/App/PropertyColumnWidths.h +++ b/src/Mod/Spreadsheet/App/PropertyColumnWidths.h @@ -45,7 +45,10 @@ public: return *this; } - int getValue(int column) const { return find(column) != end() ? at(column) : defaultWidth; } + int getValue(int column) const { + std::map::const_iterator i = find(column); + return i != end() ? i->second : defaultWidth; + } virtual Property *Copy(void) const; diff --git a/src/Mod/Spreadsheet/App/PropertyRowHeights.h b/src/Mod/Spreadsheet/App/PropertyRowHeights.h index 3ec58ff4a..3042c16b2 100644 --- a/src/Mod/Spreadsheet/App/PropertyRowHeights.h +++ b/src/Mod/Spreadsheet/App/PropertyRowHeights.h @@ -41,7 +41,10 @@ public: void setValue(int row, int height); - int getValue(int row) const { return find(row) != end() ? at(row) : 20; } + int getValue(int row) const { + std::map::const_iterator i = find(row); + return i != end() ? i->second : defaultHeight; + } std::map getValues() const { return *this; diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 9c3e8645c..75e34d759 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -147,8 +147,9 @@ void PropertySheet::setDirty(CellAddress address) { /* Merged cells will automatically force an update of the top left cell to be consistent. */ - if (mergedCells.find(address) != mergedCells.end()) - address = mergedCells[address]; + std::map::const_iterator i = mergedCells.find(address); + if (i != mergedCells.end()) + address = i->second; dirty.insert(address); } @@ -287,7 +288,7 @@ void PropertySheet::Restore(Base::XMLReader &reader) mergeCells(address, CellAddress(address.row() + rows - 1, address.col() + cols - 1)); } } - catch (const Base::Exception & e) { + catch (const Base::Exception &) { // Something is wrong, skip this cell } catch (...) { @@ -298,66 +299,61 @@ void PropertySheet::Restore(Base::XMLReader &reader) Cell * PropertySheet::cellAt(CellAddress address) { - std::map::iterator i = data.find(address); + std::map::const_iterator j = mergedCells.find(address); - if (i == data.end()) { - if (mergedCells.find(address) != mergedCells.end()) { - std::map::iterator j = mergedCells.find(address); + // address actually inside a merged cell + if (j != mergedCells.end()) { + std::map::const_iterator i = data.find(j->second); + assert(i != data.end()); - assert(j != mergedCells.end()); - - i = data.find(j->second); - assert(i != data.end()); - - return i->second; - } - return 0; + return i->second; } + + std::map::const_iterator i = data.find(address); + + if (i == data.end()) + return 0; else return i->second; } const Cell * PropertySheet::cellAt(CellAddress address) const { + std::map::const_iterator j = mergedCells.find(address); + + // address actually inside a merged cell + if (j != mergedCells.end()) { + std::map::const_iterator i = data.find(j->second); + assert(i != data.end()); + + return i->second; + } + std::map::const_iterator i = data.find(address); - if (i == data.end()) { - if (mergedCells.find(address) != mergedCells.end()) { - std::map::const_iterator j = mergedCells.find(address); - - assert(j != mergedCells.end()); - - i = data.find(j->second); - assert(i != data.end()); - - return i->second; - } - + if (i == data.end()) return 0; - } else return i->second; } Cell * PropertySheet::nonNullCellAt(CellAddress address) { + std::map::const_iterator j = mergedCells.find(address); + + if (j != mergedCells.end()) { + std::map::const_iterator i = data.find(j->second); + + if (i == data.end()) + return createCell(address); + else + return i->second; + } + std::map::const_iterator i = data.find(address); - if (i == data.end()) { - if (mergedCells.find(address) != mergedCells.end()) { - std::map::const_iterator j = mergedCells.find(address); - - assert(j != mergedCells.end()); - - i = data.find(j->second); - if (i == data.end()) - return createCell(address); - else - return i->second; - } - + if (i == data.end()) return createCell(address); - } else return i->second; } @@ -453,8 +449,7 @@ void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos) clear(newPos); if (i != data.end()) { - int row, col; - Cell * cell = data.at(currPos); + Cell * cell = i->second; // Remove from old removeDependencies(currPos); @@ -540,7 +535,11 @@ void PropertySheet::insertRows(int row, int count) Signaller signaller(*this); for (std::vector::const_reverse_iterator i = keys.rbegin(); i != keys.rend(); ++i) { - Cell * cell = data.at(*i); + std::map::iterator j = data.find(*i); + + assert(j != data.end()); + + Cell * cell = j->second; // Visit each cell to make changes to expressions if necessary visitor.reset(); @@ -581,7 +580,11 @@ void PropertySheet::removeRows(int row, int count) Signaller signaller(*this); for (std::vector::const_iterator i = keys.begin(); i != keys.end(); ++i) { - Cell * cell = data.at(*i); + std::map::iterator j = data.find(*i); + + assert(j != data.end()); + + Cell * cell = j->second; // Visit each cell to make changes to expressions if necessary visitor.reset(); @@ -613,7 +616,11 @@ void PropertySheet::insertColumns(int col, int count) Signaller signaller(*this); for (std::vector::const_reverse_iterator i = keys.rbegin(); i != keys.rend(); ++i) { - Cell * cell = data.at(*i); + std::map::iterator j = data.find(*i); + + assert(j != data.end()); + + Cell * cell = j->second; // Visit each cell to make changes to expressions if necessary visitor.reset(); @@ -654,7 +661,11 @@ void PropertySheet::removeColumns(int col, int count) Signaller signaller(*this); for (std::vector::const_iterator i = keys.begin(); i != keys.end(); ++i) { - Cell * cell = data.at(*i); + std::map::iterator j = data.find(*i); + + assert(j != data.end()); + + Cell * cell = j->second; // Visit each cell to make changes to expressions if necessary visitor.reset(); @@ -692,7 +703,7 @@ bool PropertySheet::mergeCells(CellAddress from, CellAddress to) // Clear cells that will be hidden by the merge for (int r = from.row(); r <= to.row(); ++r) for (int c = from.col(); c <= to.col(); ++c) - if ( !(r == from.row() && c == to.row()) ) + if ( !(r == from.row() && c == from.col()) ) clear(CellAddress(r, c)); // Update internal structure to track merged cells @@ -710,14 +721,14 @@ bool PropertySheet::mergeCells(CellAddress from, CellAddress to) void PropertySheet::splitCell(CellAddress address) { int rows, cols; + std::map::const_iterator i = mergedCells.find(address); - if (mergedCells.find(address) == mergedCells.end()) + if (i == mergedCells.end()) return; - cellAt(address)->getSpans(rows, cols); - - CellAddress anchor = mergedCells.at(address); + CellAddress anchor = i->second; Signaller signaller(*this); + cellAt(anchor)->getSpans(rows, cols); for (int r = anchor.row(); r <= anchor.row() + rows; ++r) for (int c = anchor.col(); c <= anchor.col() + cols; ++c) { @@ -730,8 +741,10 @@ void PropertySheet::splitCell(CellAddress address) void PropertySheet::getSpans(CellAddress address, int & rows, int & cols) const { - if (mergedCells.find(address) != mergedCells.end()) { - CellAddress anchor = mergedCells.at(address); + std::map::const_iterator i = mergedCells.find(address); + + if (i != mergedCells.end()) { + CellAddress anchor = i->second; cellAt(anchor)->getSpans(rows, cols); } @@ -747,7 +760,9 @@ bool PropertySheet::isMergedCell(CellAddress address) const bool PropertySheet::isHidden(CellAddress address) const { - return mergedCells.find(address) != mergedCells.end() && mergedCells.at(address) != address; + std::map::const_iterator i = mergedCells.find(address); + + return i != mergedCells.end() && i->second != address; } /** @@ -839,7 +854,11 @@ void PropertySheet::removeDependencies(CellAddress key) j = i1->second.begin(); while (j != i1->second.end()) { - propertyNameToCellMap.at(*j).erase(key); + std::map >::iterator k = propertyNameToCellMap.find(*j); + + assert(k != propertyNameToCellMap.end()); + + k->second.erase(key); ++j; } @@ -855,7 +874,11 @@ void PropertySheet::removeDependencies(CellAddress key) j = i2->second.begin(); while (j != i2->second.end()) { - documentObjectToCellMap.at(*j).erase(key); + std::map >::iterator k = documentObjectToCellMap.find(*j); + + assert(k != documentObjectToCellMap.end()); + + k->second.erase(key); ++j; } @@ -997,9 +1020,10 @@ void PropertySheet::recomputeDependants(const DocumentObject *docObj) const std::set &PropertySheet::getDeps(const std::string &name) const { static std::set empty; + std::map >::const_iterator i = propertyNameToCellMap.find(name); - if (propertyNameToCellMap.find(name) != propertyNameToCellMap.end()) - return propertyNameToCellMap.at(name); + if (i != propertyNameToCellMap.end()) + return i->second; else return empty; } @@ -1007,9 +1031,10 @@ const std::set &PropertySheet::getDeps(const std::string &name) con const std::set &PropertySheet::getDeps(CellAddress pos) const { static std::set empty; + std::map >::const_iterator i = cellToPropertyNameMap.find(pos); - if (cellToPropertyNameMap.find(pos) != cellToPropertyNameMap.end()) - return cellToPropertyNameMap.at(pos); + if (i != cellToPropertyNameMap.end()) + return i->second; else return empty; } diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index 586ddd7f0..637357820 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -212,7 +212,7 @@ static void writeEscaped(std::string const& s, char quoteChar, char escapeChar, bool Sheet::exportToFile(const std::string &filename, char delimiter, char quoteChar, char escapeChar) const { std::ofstream file; - int row, col, prevRow = -1, prevCol = -1; + int prevRow = -1, prevCol = -1; file.open(filename.c_str(), std::ios::out | std::ios::ate | std::ios::binary); @@ -493,7 +493,6 @@ Property * Sheet::setFloatProperty(CellAddress key, double value) Property * Sheet::setQuantityProperty(CellAddress key, double value, const Base::Unit & unit) { - int row, col; Property * prop = props.getPropertyByName(toAddress(key).c_str()); PropertyQuantity * quantityProp; diff --git a/src/Mod/Spreadsheet/App/Sheet.h b/src/Mod/Spreadsheet/App/Sheet.h index d39d06d86..aacecf015 100644 --- a/src/Mod/Spreadsheet/App/Sheet.h +++ b/src/Mod/Spreadsheet/App/Sheet.h @@ -193,7 +193,7 @@ public: } short getPropertyType(const App::Property *prop) const { - props.getPropertyType(prop); + return props.getPropertyType(prop); } /// get the name of a property diff --git a/src/Mod/Spreadsheet/App/SheetPyImp.cpp b/src/Mod/Spreadsheet/App/SheetPyImp.cpp index 7b81d573a..54c311084 100644 --- a/src/Mod/Spreadsheet/App/SheetPyImp.cpp +++ b/src/Mod/Spreadsheet/App/SheetPyImp.cpp @@ -416,7 +416,6 @@ PyObject* SheetPy::getStyle(PyObject *args) PyObject* SheetPy::setDisplayUnit(PyObject *args) { - int row, col; const char * cell; const char * value; @@ -842,7 +841,6 @@ PyObject* SheetPy::setRowHeight(PyObject *args) PyObject* SheetPy::getRowHeight(PyObject *args) { const char * rowStr; - int row, col; if (!PyArg_ParseTuple(args, "s:getRowHeight", &rowStr)) return 0; diff --git a/src/Mod/Spreadsheet/Gui/SheetModel.cpp b/src/Mod/Spreadsheet/Gui/SheetModel.cpp index edd9b91c5..f3a85abd1 100644 --- a/src/Mod/Spreadsheet/Gui/SheetModel.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetModel.cpp @@ -355,6 +355,8 @@ QVariant SheetModel::data(const QModelIndex &index, int role) const return QVariant(); } } + + return QVariant(); } QVariant SheetModel::headerData(int section, Qt::Orientation orientation, int role) const