diff --git a/src/Mod/Assembly/App/BomObject.cpp b/src/Mod/Assembly/App/BomObject.cpp index 83761e0f5c..54fcb4b14f 100644 --- a/src/Mod/Assembly/App/BomObject.cpp +++ b/src/Mod/Assembly/App/BomObject.cpp @@ -24,7 +24,6 @@ #include #include - #include #include #include @@ -43,7 +42,6 @@ #include #include - #include "AssemblyObject.h" #include "AssemblyLink.h" #include "BomObject.h" @@ -291,19 +289,19 @@ std::string BomObject::getBomPropertyValue(App::DocumentObject* obj, const std:: if (auto propStr = freecad_cast(prop)) { return propStr->getValue(); } - else if (auto propQuantity = freecad_cast(prop)) { + if (auto propQuantity = freecad_cast(prop)) { return propQuantity->getQuantityValue().getUserString(); } - else if (auto propEnum = freecad_cast(prop)) { + if (auto propEnum = freecad_cast(prop)) { return propEnum->getValueAsString(); } - else if (auto propFloat = freecad_cast(prop)) { + if (auto propFloat = freecad_cast(prop)) { return std::to_string(propFloat->getValue()); } - else if (auto propInt = freecad_cast(prop)) { + if (auto propInt = freecad_cast(prop)) { return std::to_string(propInt->getValue()); } - else if (auto propBool = freecad_cast(prop)) { + if (auto propBool = freecad_cast(prop)) { return propBool->getValue() ? "True" : "False"; } @@ -311,7 +309,7 @@ std::string BomObject::getBomPropertyValue(App::DocumentObject* obj, const std:: return QObject::tr("Not supported").toStdString(); } -AssemblyObject* BomObject::getAssembly() +AssemblyObject* BomObject::getAssembly() const { for (auto& obj : getInList()) { if (obj->isDerivedFrom()) { @@ -321,7 +319,7 @@ AssemblyObject* BomObject::getAssembly() return nullptr; } -bool BomObject::hasQuantityColumn() +bool BomObject::hasQuantityColumn() const { for (auto& columnName : columnsNames.getValues()) { if (columnName == "Quantity") { @@ -331,9 +329,9 @@ bool BomObject::hasQuantityColumn() return false; } -std::string Assembly::BomObject::getText(size_t row, size_t col) +std::string Assembly::BomObject::getText(size_t row, size_t col) const { - Spreadsheet::Cell* cell = getCell(App::CellAddress(row, col)); + const Spreadsheet::Cell* cell = getCell(App::CellAddress(row, col)); std::string cellName; if (cell) { cell->getStringContent(cellName); @@ -347,7 +345,7 @@ std::string Assembly::BomObject::getText(size_t row, size_t col) return cellName; } -int BomObject::getColumnIndex(std::string name) +int BomObject::getColumnIndex(std::string name) const { int col = 0; for (auto& columnName : columnsNames.getValues()) { diff --git a/src/Mod/Assembly/App/BomObject.h b/src/Mod/Assembly/App/BomObject.h index c1e4954323..2ea18d81b7 100644 --- a/src/Mod/Assembly/App/BomObject.h +++ b/src/Mod/Assembly/App/BomObject.h @@ -80,11 +80,11 @@ public: void addObjectChildrenToBom(std::vector objs, size_t& row, std::string index); void saveCustomColumnData(); - AssemblyObject* getAssembly(); + AssemblyObject* getAssembly() const; - bool hasQuantityColumn(); - int getColumnIndex(std::string name); - std::string getText(size_t row, size_t col); + bool hasQuantityColumn() const; + int getColumnIndex(std::string name) const; + std::string getText(size_t row, size_t col) const; App::PropertyStringList columnsNames; App::PropertyBool detailSubAssemblies; diff --git a/src/Mod/Spreadsheet/App/Sheet.cpp b/src/Mod/Spreadsheet/App/Sheet.cpp index e0fb337f07..df27045ea7 100644 --- a/src/Mod/Spreadsheet/App/Sheet.cpp +++ b/src/Mod/Spreadsheet/App/Sheet.cpp @@ -411,6 +411,17 @@ Cell* Sheet::getCell(CellAddress address) return cells.getValue(address); } +/** + * Get contents of the cell specified by \a address, or 0 if it is not defined + * + * @returns A CellContent object or 0. + */ + +const Cell* Sheet::getCell(CellAddress address) const +{ + return cells.getValue(address); +} + /** * Get cell contents specified by \a address. * diff --git a/src/Mod/Spreadsheet/App/Sheet.h b/src/Mod/Spreadsheet/App/Sheet.h index 6b347db8e7..74ff2c11cc 100644 --- a/src/Mod/Spreadsheet/App/Sheet.h +++ b/src/Mod/Spreadsheet/App/Sheet.h @@ -110,6 +110,7 @@ public: void splitCell(App::CellAddress address); Cell* getCell(App::CellAddress address); + const Cell* getCell(App::CellAddress address) const; Cell* getNewCell(App::CellAddress address);