index fc94205b64007c70d4061f0345b4c8820f24a2f3..eabf147f64980afa2acbb18027dc682c961da6a3 100644 (file)
#include "script.h"
#include "dialogs/dialog-events.h"
#include "application/application.h"
+#include "xml/node.h"
+#include "xml/attribute-record.h"
#include "util/glib-list-iterators.h"
} // data_read
if (mydoc != NULL) {
- sp_document_set_uri(mydoc, filenameArg);
+ g_free(mydoc->base);
+ mydoc->base = NULL;
+ sp_document_change_uri_and_hrefs(mydoc, filenameArg);
}
// make sure we don't leak file descriptors from g_file_open_tmp
@@ -834,8 +838,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<gchar const *> attribs;
+
+ // Make a list of all attributes of the old root node.
+ for (List<AttributeRecord const> 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<gchar const *>::const_iterator it = attribs.begin(); it != attribs.end(); it++)
+ oldroot->setAttribute(*it, NULL);
+
+ // Set the new attributes.
+ for (List<AttributeRecord const> 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 */