Code

Added missing (and very important) file.
[inkscape.git] / src / extension / system.cpp
index 390206f302141edef110c1fc1edc4213caeb8ede..a7828d3fc115e0bcb291b6e2fea29603c46b68d7 100644 (file)
@@ -29,6 +29,7 @@
 #include "print.h"
 #include "implementation/script.h"
 #include "implementation/xslt.h"
+#include "xml/rebase-hrefs.h"
 /* #include "implementation/plugin.h" */
 
 namespace Inkscape {
@@ -92,7 +93,7 @@ open(Extension *key, gchar const *filename)
 
     SPDocument *doc = imod->open(filename);
     if (!doc) {
-        return NULL;
+        throw Input::open_failed();
     }
 
     if (last_chance_svg) {
@@ -250,12 +251,13 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
     bool saved_modified = false;
     gchar *saved_output_extension = NULL;
     gchar *saved_dataloss = NULL;
-    gchar *saved_uri = NULL;
     if (!official) {
         saved_modified = doc->isModifiedSinceSave();
         saved_output_extension = g_strdup(repr->attribute("inkscape:output_extension"));
         saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss"));
-        saved_uri = g_strdup(doc->uri);
+    } else {
+        /* The document is changing name/uri. */
+        sp_document_change_uri_and_hrefs(doc, fileName);
     }
 
     // Update attributes:
@@ -263,8 +265,6 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
         bool const saved = sp_document_get_undo_sensitive(doc);
         sp_document_set_undo_sensitive(doc, false);
         {
-            // save the filename for next use
-            sp_document_set_uri(doc, fileName);
             // also save the extension for next use
             repr->setAttribute("inkscape:output_extension", omod->get_id());
             // set the "dataloss" attribute if the chosen extension is lossy
@@ -286,14 +286,12 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
         {
             repr->setAttribute("inkscape:output_extension", saved_output_extension);
             repr->setAttribute("inkscape:dataloss", saved_dataloss);
-            sp_document_set_uri(doc, saved_uri);
         }
         sp_document_set_undo_sensitive(doc, saved);
         doc->setModifiedSinceSave(saved_modified);
 
         g_free(saved_output_extension);
         g_free(saved_dataloss);
-        g_free(saved_uri);
     }
 
     g_free(fileName);
@@ -390,8 +388,6 @@ build_from_reprdoc(Inkscape::XML::Document *doc, Implementation::Implementation
 
     Inkscape::XML::Node *repr = doc->root();
 
-    /* sp_repr_print(repr); */
-
     if (strcmp(repr->name(), INKSCAPE_EXTENSION_NS "inkscape-extension")) {
         g_warning("Extension definition started with <%s> instead of <" INKSCAPE_EXTENSION_NS "inkscape-extension>.  Extension will not be created. See http://wiki.inkscape.org/wiki/index.php/Extensions for reference.\n", repr->name());
         return NULL;