index fb7d6a6f91bbcb1fa8f9f296f309e28498df9118..762051339429aab6349614b16519779317462b0e 100644 (file)
/*
* Authors:
* Ted Gould <ted@gould.cx>
+ * Jon A. Cruz <jon@joncruz.org>
+ * Abhishek Sharma
*
* Copyright (C) 2006-2007 Authors
*
#include "io/sys.h"
#include "file.h"
#include <unistd.h>
+#include <cstring>
+#include "document.h"
#include <libxml/parser.h>
#include <libxslt/transform.h>
+#include <libxslt/xsltutils.h>
Inkscape::XML::Document * sp_repr_do_read (xmlDocPtr doc, const gchar * default_ns);
Inkscape::XML::Node *child_repr = sp_repr_children(module->get_repr());
while (child_repr != NULL) {
- if (!strcmp(child_repr->name(), "xslt")) {
+ if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "xslt")) {
child_repr = sp_repr_children(child_repr);
while (child_repr != NULL) {
- if (!strcmp(child_repr->name(), "file")) {
+ if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "file")) {
_filename = solve_reldir(child_repr);
}
child_repr = sp_repr_next(child_repr);
{
if (!module->loaded()) { return; }
xsltFreeStylesheet(_stylesheet);
- xmlFreeDoc(_parsedDoc);
+ // No need to use xmlfreedoc(_parsedDoc), it's handled by xsltFreeStylesheet(_stylesheet);
return;
}
}
g_free(s);
- SPDocument * doc = sp_document_create(rdoc, filename, base, name, true);
+ SPDocument * doc = SPDocument::createDoc(rdoc, filename, base, name, true);
g_free(base); g_free(name);
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);
+ Inkscape::XML::Node *repr = doc->getReprRoot();
std::string tempfilename_out;
int tempfd_out = 0;
try {
- tempfd_out = Glib::file_open_tmp(tempfilename_out, "ink_ext_XXXXXX");
+ tempfd_out = Inkscape::IO::file_open_tmp(tempfilename_out, "ink_ext_XXXXXX");
} catch (...) {
/// \todo Popup dialog here
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->getBase(), filename)) {
throw Inkscape::Extension::Output::save_failed();
}
@@ -216,11 +218,16 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const
params[0] = NULL;
xmlDocPtr newdoc = xsltApplyStylesheet(_stylesheet, svgdoc, params);
- xmlSaveFile(filename, newdoc);
+ //xmlSaveFile(filename, newdoc);
+ xsltSaveResultToFilename(filename, newdoc, _stylesheet, 0);
+
xmlFreeDoc(newdoc);
xmlFreeDoc(svgdoc);
+ xsltCleanupGlobals();
+ xmlCleanupParser();
+
return;
}
@@ -239,4 +246,4 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :