Code

Use the new sp_document_change_uri_and_hrefs function.
authorpjrm <pjrm@users.sourceforge.net>
Tue, 7 Apr 2009 08:25:43 +0000 (08:25 +0000)
committerpjrm <pjrm@users.sourceforge.net>
Tue, 7 Apr 2009 08:25:43 +0000 (08:25 +0000)
 The change to extension/system.cpp is a functional noop.
 The change to extension/implementation/script.cpp should fix importing of .ai files that contain images (or whatever ill2svg.pl creates png files for).  The effect on any other scripts that create SVG files with relative hrefs is unknown.

src/extension/implementation/script.cpp
src/extension/system.cpp

index 70b006d310265ba5afd69fd274e2b0a69bc0e7a2..eabf147f64980afa2acbb18027dc682c961da6a3 100644 (file)
@@ -581,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
index 37b70fec8325269104d58eb95541f77fa40b5b22..fdebd7b227ded8eaa9c1a5714e521aafbc05b1ef 100644 (file)
@@ -257,14 +257,7 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
         saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss"));
     } else {
         /* The document is changing name/uri. */
-
-        /* TODO: Don't treat URIs and filenames interchangeably.
-         * So call g_filename_to_uri when passing to sp_document_set_uri,
-         * and change rebase_hrefs to accept a base URI/LEIRI instead of dir name. */
-        gchar *const new_base = g_path_get_dirname(fileName);
-        Inkscape::XML::rebase_hrefs(doc, new_base, true);
-        sp_document_set_uri(doc, fileName);
-        g_free(new_base);
+        sp_document_change_uri_and_hrefs(doc, fileName);
     }
 
     // Update attributes: