Code

Added missing (and very important) file.
[inkscape.git] / src / extension / implementation / script.cpp
index 9475b479623ed6e98865d48cd5baf03c8bf5a6e2..eabf147f64980afa2acbb18027dc682c961da6a3 100644 (file)
@@ -37,6 +37,8 @@
 #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"
 
@@ -120,7 +122,7 @@ Script::resolveInterpreterExecutable(const Glib::ustring &interpNameArg)
 
     // 1.  Check preferences
     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-    Glib::ustring prefInterp = prefs->getString("extensions", interp->prefstring);
+    Glib::ustring prefInterp = prefs->getString("/extensions/" + Glib::ustring(interp->prefstring));
 
     if (!prefInterp.empty()) {
         interpName = prefInterp;
@@ -579,7 +581,9 @@ Script::open(Inkscape::Extension::Input *module,
     } // 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 */