Simplify logic using freecad_dynamic_cast

This commit is contained in:
Benjamin Nauck
2025-01-17 18:45:34 +01:00
parent 45c997f40a
commit cb4ee4737d
5 changed files with 56 additions and 63 deletions

View File

@@ -186,14 +186,14 @@ App::DocumentObjectExecReturn* FeatureViewSpreadsheet::execute(void)
App::Property* prop = sheet->getPropertyByName(address.toString().c_str());
std::stringstream field;
if (prop) {
if (prop->isDerivedFrom((App::PropertyQuantity::getClassTypeId()))) {
field << static_cast<App::PropertyQuantity*>(prop)->getValue();
if (auto* p = Base::freecad_dynamic_cast<App::PropertyQuantity>(prop)) {
field << p->getValue();
}
else if (prop->isDerivedFrom((App::PropertyFloat::getClassTypeId()))) {
field << static_cast<App::PropertyFloat*>(prop)->getValue();
else if (auto p = Base::freecad_dynamic_cast<App::PropertyFloat>(prop)) {
field << p->getValue();
}
else if (prop->isDerivedFrom((App::PropertyString::getClassTypeId()))) {
field << static_cast<App::PropertyString*>(prop)->getValue();
else if (auto p = Base::freecad_dynamic_cast<App::PropertyString>(prop)) {
field << p->getValue();
}
else {
assert(0);