From 7a6a1baa2b891c16edd7fbb86be3179f92adaee2 Mon Sep 17 00:00:00 2001 From: Joseph Da Silva Date: Wed, 20 Mar 2019 21:22:46 +0530 Subject: Fixed: circles and ellipses had wrong element names in XML editor (Issue #116) --- src/xml/event.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/xml/event.cpp') diff --git a/src/xml/event.cpp b/src/xml/event.cpp index 481c12bb6..b0c163784 100644 --- a/src/xml/event.cpp +++ b/src/xml/event.cpp @@ -120,6 +120,11 @@ public: { node.setContent(new_value); } + + void notifyElementNameChanged(Node& node, GQuark /*old_value*/, GQuark new_value) + { + node.setCodeUnsafe(new_value); + } }; } @@ -180,6 +185,12 @@ void Inkscape::XML::EventChgOrder::_undoOne( observer.notifyChildOrderChanged(*this->repr, *this->child, this->newref, this->oldref); } +void Inkscape::XML::EventChgElementName::_undoOne( + Inkscape::XML::NodeObserver& observer +) const { + observer.notifyElementNameChanged(*this->repr, this->new_name, this->old_name); +} + void Inkscape::XML::replay_log_to_observer( Inkscape::XML::Event const *log, Inkscape::XML::NodeObserver &observer @@ -239,6 +250,12 @@ void Inkscape::XML::EventChgOrder::_replayOne( observer.notifyChildOrderChanged(*this->repr, *this->child, this->oldref, this->newref); } +void Inkscape::XML::EventChgElementName::_replayOne( + Inkscape::XML::NodeObserver &observer +) const { + observer.notifyElementNameChanged(*this->repr, this->new_name, this->old_name); +} + Inkscape::XML::Event * sp_repr_coalesce_log (Inkscape::XML::Event *a, Inkscape::XML::Event *b) { @@ -398,6 +415,17 @@ Inkscape::XML::Event *Inkscape::XML::EventChgOrder::_optimizeOne() { } } +Inkscape::XML::Event* Inkscape::XML::EventChgElementName::_optimizeOne() { + auto next_chg_element_name = dynamic_cast(this->next); + if (next_chg_element_name && next_chg_element_name->repr == this->repr) { + // Combine name changes to the same element. + this->old_name = next_chg_element_name->old_name; + this->next = next_chg_element_name->next; + delete next_chg_element_name; + } + return this; +} + namespace { class LogPrinter : public Inkscape::XML::NodeObserver { @@ -482,6 +510,12 @@ public: g_warning("Event: Unset content of %s", node_to_string(node).c_str()); } } + + void notifyElementNameChanged(Node& node, GQuark old_value, GQuark new_value) override + { + g_warning("Event: Changed name of %s from %s to %s\n", + node_to_string(node).c_str(), g_quark_to_string(old_value), g_quark_to_string(new_value)); + } }; } -- cgit v1.2.3