diff --git a/src/App/PropertyExpressionEngine.cpp b/src/App/PropertyExpressionEngine.cpp index 4b77e84364..41986f1806 100644 --- a/src/App/PropertyExpressionEngine.cpp +++ b/src/App/PropertyExpressionEngine.cpp @@ -53,6 +53,8 @@ PropertyExpressionContainer::PropertyExpressionContainer() inited = true; GetApplication().signalRelabelDocument.connect( PropertyExpressionContainer::slotRelabelDocument); + GetApplication().signalRenameDynamicProperty.connect( + PropertyExpressionContainer::slotRenameDynamicProperty); } _ExprContainers.insert(this); } @@ -75,6 +77,13 @@ void PropertyExpressionContainer::slotRelabelDocument(const App::Document& doc) } } +void PropertyExpressionContainer::slotRenameDynamicProperty(const App::Property& prop, const char* oldName) +{ + for (auto container : _ExprContainers) { + container->onRenameDynamicProperty(prop, oldName); + } +} + /////////////////////////////////////////////////////////////////////////////////////// struct PropertyExpressionEngine::Private @@ -1208,6 +1217,17 @@ void PropertyExpressionEngine::onRelabeledDocument(const App::Document& doc) } } +void PropertyExpressionEngine::onRenameDynamicProperty(const App::Property& prop, const char* oldName) +{ + ObjectIdentifier oldNameId = ObjectIdentifier(prop.getContainer(), std::string(oldName)); + ObjectIdentifier newNameId = ObjectIdentifier(prop); + const std::map paths = { + {oldNameId, newNameId}, + }; + + renameObjectIdentifiers(paths); +} + void PropertyExpressionEngine::getLinksTo(std::vector& identifiers, App::DocumentObject* obj, const char* subname, diff --git a/src/App/PropertyExpressionEngine.h b/src/App/PropertyExpressionEngine.h index 655b5f52e3..266aea4160 100644 --- a/src/App/PropertyExpressionEngine.h +++ b/src/App/PropertyExpressionEngine.h @@ -59,9 +59,11 @@ public: protected: virtual void onRelabeledDocument(const App::Document& doc) = 0; + virtual void onRenameDynamicProperty(const App::Property& prop, const char* oldName) = 0; private: static void slotRelabelDocument(const App::Document& doc); + static void slotRenameDynamicProperty(const App::Property& prop, const char* oldName); }; class AppExport PropertyExpressionEngine @@ -117,6 +119,7 @@ public: std::map getExpressions() const override; void setExpressions(std::map&& exprs) override; void onRelabeledDocument(const App::Document& doc) override; + void onRenameDynamicProperty(const App::Property& prop, const char* oldName) override; void setValue() {} // Dummy diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 932e2360d8..66fda50643 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -1577,6 +1577,17 @@ void PropertySheet::onRelabeledDocument(const App::Document& doc) } } +void PropertySheet::onRenameDynamicProperty(const App::Property& prop, const char* oldName) +{ + ObjectIdentifier oldNameId = ObjectIdentifier(prop.getContainer(), std::string(oldName)); + ObjectIdentifier newNameId = ObjectIdentifier(prop); + const std::map paths = { + {oldNameId, newNameId}, + }; + + renameObjectIdentifiers(paths); +} + void PropertySheet::renameObjectIdentifiers( const std::map& paths) { diff --git a/src/Mod/Spreadsheet/App/PropertySheet.h b/src/Mod/Spreadsheet/App/PropertySheet.h index 3123ec99c5..236b180baf 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.h +++ b/src/Mod/Spreadsheet/App/PropertySheet.h @@ -51,6 +51,7 @@ public: std::map getExpressions() const override; void setExpressions(std::map&& exprs) override; void onRelabeledDocument(const App::Document& doc) override; + void onRenameDynamicProperty(const App::Property& prop, const char* oldName) override; void updateElementReference(App::DocumentObject* feature, bool reverse = false,