From c2d8810625892a8bedcaa192df9b4165e46609ee Mon Sep 17 00:00:00 2001 From: Peter Moulder Date: Tue, 7 Apr 2009 05:31:32 +0000 Subject: Move Inkscape::IO::fixupHrefs to Inkscape::XML::rebase_hrefs in new file xml/rebase-hrefs.*. Give it the old and new base directory, so that it can change hrefs without relying on sodipodi:absref. Also create a new function sp_repr_save_rebased_file that changes all xlink:href attributes as it writes them, so that we don't need to modify the owning document. (Especially useful for "Save a copy" or exporting.) extension/system.cpp: (Inkscape::Extension::save): Don't call sp_document_set_uri even temporarily other than at the same time as calling rebase_hrefs. (Otherwise, existing relative hrefs will point nowhere.) When exporting plain SVG, change the relative hrefs according to the destination filename. (bzr r7643) --- src/extension/implementation/xslt.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/extension/implementation/xslt.cpp') diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index c331cac60..f34fea64a 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -184,16 +184,14 @@ XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename) void XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const *filename) { + /* TODO: Should we assume filename to be in utf8 or to be a raw filename? + * See JavaFXOutput::save for discussion. */ g_return_if_fail(doc != NULL); g_return_if_fail(filename != NULL); Inkscape::XML::Node *repr = NULL; repr = sp_document_repr_root (doc); - gchar *save_path = g_path_get_dirname (filename); - Inkscape::IO::fixupHrefs( doc, save_path, true ); - g_free(save_path); - std::string tempfilename_out; int tempfd_out = 0; try { @@ -203,8 +201,8 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const return; } - gboolean const s = sp_repr_save_file (repr->document(), tempfilename_out.c_str(), SP_SVG_NS_URI); - if (s == FALSE) { + if (!sp_repr_save_rebased_file(repr->document(), tempfilename_out.c_str(), SP_SVG_NS_URI, + doc->base, filename)) { throw Inkscape::Extension::Output::save_failed(); } -- cgit v1.2.3