summaryrefslogtreecommitdiffstats
path: root/src/ui/clipboard.cpp
diff options
context:
space:
mode:
authorStephen Silver <sasilver@yahoo.com>2008-06-24 10:49:28 +0000
committersasilver <sasilver@users.sourceforge.net>2008-06-24 10:49:28 +0000
commit48d54d31775d7822ac5ab65614cd71f9a088b65f (patch)
tree60597f523326e0d5777ad033ffc7a6baf7436276 /src/ui/clipboard.cpp
parentCmake: Add GSL to LIBS and Includes (diff)
downloadinkscape-48d54d31775d7822ac5ab65614cd71f9a088b65f.tar.gz
inkscape-48d54d31775d7822ac5ab65614cd71f9a088b65f.zip
Resolve ID clashes when pasting (fixes bug 165936).
(bzr r6048)
Diffstat (limited to 'src/ui/clipboard.cpp')
-rw-r--r--src/ui/clipboard.cpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index f7967bd40..28dc7d937 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -72,6 +72,7 @@
#include "tools-switch.h"
#include "libnr/n-art-bpath-2geom.h"
#include "path-chemistry.h"
+#include "id-clash.h"
/// @brief Made up mimetype to represent Gdk::Pixbuf clipboard contents
#define CLIPBOARD_GDK_PIXBUF_TARGET "image/x-gdk-pixbuf"
@@ -787,29 +788,9 @@ void ClipboardManagerImpl::_pasteDefs(SPDocument *clipdoc)
*target_defs = SP_OBJECT_REPR(SP_DOCUMENT_DEFS(target_document));
Inkscape::XML::Document *target_xmldoc = sp_document_repr_doc(target_document);
+ prevent_id_clashes(clipdoc, target_document);
+
for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) {
- /// @todo TODO: implement def id collision resolution in ClipboardManagerImpl::_pasteDefs()
-
- /*
- // simplistic solution: when a collision occurs, add "a" to id until it's unique
- Glib::ustring pasted_id = def->attribute("id");
- if ( pasted_id.empty() ) continue; // defs without id are useless
- Glib::ustring pasted_id_original = pasted_id;
-
- while(sp_repr_lookup_child(target_defs, "id", pasted_id.data())) {
- pasted_id.append("a");
- }
-
- if ( pasted_id != pasted_id_original ) {
- def->setAttribute("id", pasted_id.data());
- // Update the id in the rest of the document so there are no dangling references
- // How to do that?
- _changeIdReferences(clipdoc, pasted_id_original, pasted_id);
- }
- */
- if (sp_repr_lookup_child(target_defs, "id", def->attribute("id")))
- continue; // skip duplicate defs - temporary non-solution
-
_copyNode(def, target_xmldoc, target_defs);
}
}