From 49cb6b81084d814d13a3e794667e66add5745541 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 31 Oct 2008 10:13:48 -0500 Subject: [PATCH] Patch from Hannes Hochreiner to make it so that attributes on the root node copy correctly. --- src/extension/implementation/script.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index fc94205b6..964eb85d8 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -37,6 +37,7 @@ #include "script.h" #include "dialogs/dialog-events.h" #include "application/application.h" +#include "xml/node.h" #include "util/glib-list-iterators.h" @@ -834,8 +835,26 @@ Script::copy_doc (Inkscape::XML::Node * oldroot, Inkscape::XML::Node * newroot) } } - oldroot->setAttribute("width", newroot->attribute("width")); - oldroot->setAttribute("height", newroot->attribute("height")); + { + using Inkscape::Util::List; + using Inkscape::XML::AttributeRecord; + std::vector attribs; + + // Make a list of all attributes of the old root node. + for (List iter = oldroot->attributeList(); iter; ++iter) { + attribs.push_back(g_quark_to_string(iter->key)); + } + + // Delete the attributes of the old root nodes. + for (std::vector::const_iterator it = attribs.begin(); it != attribs.end(); it++) + oldroot->setAttribute(*it, NULL); + + // Set the new attributes. + for (List iter = newroot->attributeList(); iter; ++iter) { + gchar const *name = g_quark_to_string(iter->key); + oldroot->setAttribute(name, newroot->attribute(name)); + } + } /** \todo Restore correct layer */ /** \todo Restore correct selection */ -- 2.30.2