summaryrefslogtreecommitdiffstats
path: root/src/id-clash.cpp
diff options
context:
space:
mode:
authorJohn Smith <john.smith7545@yahoo.com>2012-09-19 01:52:19 +0000
committerJohn Smith <john.smith7545@yahoo.com>2012-09-19 01:52:19 +0000
commitbf7c3e8d98b557cb64447804399797d93e1cedc0 (patch)
tree80848f225cad4c163c32ce4d2ec963982558adba /src/id-clash.cpp
parentFix for 900602 : Enter key returns focus to canvas for Font family selector (diff)
downloadinkscape-bf7c3e8d98b557cb64447804399797d93e1cedc0.tar.gz
inkscape-bf7c3e8d98b557cb64447804399797d93e1cedc0.zip
Fix for 643150 : Auto-palette swatches duplicated on copy and paste
(bzr r11677)
Diffstat (limited to 'src/id-clash.cpp')
-rw-r--r--src/id-clash.cpp28
1 files changed, 28 insertions, 0 deletions
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;
@@ -292,6 +293,33 @@ prevent_id_clashes(SPDocument *imported_doc, SPDocument *current_doc)
}
/*
+ * 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<IdReference>::const_iterator it;
+ const std::list<IdReference>::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
*/