From bf7c3e8d98b557cb64447804399797d93e1cedc0 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 19 Sep 2012 10:52:19 +0900 Subject: Fix for 643150 : Auto-palette swatches duplicated on copy and paste (bzr r11677) --- src/id-clash.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/id-clash.cpp') diff --git a/src/id-clash.cpp b/src/id-clash.cpp index d8299652b..05a3149fc 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -26,6 +26,7 @@ #include "xml/node.h" #include "xml/repr.h" #include "sp-root.h" +#include "sp-gradient.h" typedef enum { REF_HREF, REF_STYLE, REF_URL, REF_CLIPBOARD } ID_REF_TYPE; @@ -291,6 +292,33 @@ prevent_id_clashes(SPDocument *imported_doc, SPDocument *current_doc) delete refmap; } +/* + * Change any references of svg:def from_obj into to_obj + */ +void +change_def_references(SPObject *from_obj, SPObject *to_obj) +{ + refmap_type *refmap = new refmap_type; + id_changelist_type id_changes; + SPDocument *current_doc = from_obj->document; + std::string old_id(from_obj->getId()); + + find_references(current_doc->getRoot(), refmap); + + refmap_type::const_iterator pos = refmap->find(old_id); + if (pos != refmap->end()) { + std::list::const_iterator it; + const std::list::const_iterator it_end = pos->second.end(); + for (it = pos->second.begin(); it != it_end; ++it) { + if (it->type == REF_STYLE) { + sp_style_set_property_url(it->elem, it->attr, to_obj, false); + } + } + } + + delete refmap; +} + /* * Change the id of a SPObject to new_name * If there is an id clash then rename to something similar -- cgit v1.2.3