From b7e61b7ae335cccd83b22cce8840848c2c7d80ef Mon Sep 17 00:00:00 2001 From: sasilver Date: Mon, 30 Jun 2008 12:22:10 +0000 Subject: [PATCH] Prevent 'title', 'desc' and 'metadata' elements being moved to 'defs' when ungrouping (fixes bug 243720). --- src/sp-item-group.cpp | 6 ++++-- src/xml/repr-util.cpp | 16 ++++++++++++++++ src/xml/repr.h | 2 ++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 556a349ed..9e6333f97 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -457,8 +457,10 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) if (objects) { Inkscape::XML::Node *last_def = SP_OBJECT_REPR(defs)->lastChild(); while (objects) { - SP_OBJECT_REPR(defs)->addChild((Inkscape::XML::Node *) objects->data, last_def); - Inkscape::GC::release((Inkscape::XML::Node *) objects->data); + Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data; + if (!sp_repr_is_meta_element(repr)) + SP_OBJECT_REPR(defs)->addChild(repr, last_def); + Inkscape::GC::release(repr); objects = g_slist_remove (objects, objects->data); } } diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 97676bebe..193c1125c 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -445,6 +445,22 @@ sp_repr_lookup_name( Inkscape::XML::Node *repr, gchar const *name, gint maxdepth return found; } +/** + * Determine if the node is a 'title', 'desc' or 'metadata' element. + */ +bool +sp_repr_is_meta_element(const Inkscape::XML::Node *node) +{ + if (node == NULL) return false; + if (node->type() != Inkscape::XML::ELEMENT_NODE) return false; + gchar const *name = node->name(); + if (name == NULL) return false; + if (!std::strcmp(name, "svg:title")) return true; + if (!std::strcmp(name, "svg:desc")) return true; + if (!std::strcmp(name, "svg:metadata")) return true; + return false; +} + /** * Parses the boolean value of an attribute "key" in repr and sets val accordingly, or to FALSE if * the attr is not set. diff --git a/src/xml/repr.h b/src/xml/repr.h index 162451a0f..f0a1dbeb6 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -211,6 +211,8 @@ inline void sp_repr_unparent(Inkscape::XML::Node *repr) { } } +bool sp_repr_is_meta_element(const Inkscape::XML::Node *node); + /* Convenience */ unsigned sp_repr_get_boolean(Inkscape::XML::Node *repr, gchar const *key, unsigned *val); unsigned sp_repr_get_int(Inkscape::XML::Node *repr, gchar const *key, int *val); -- 2.30.2