diff options
| author | Nicolas Dufour <nicoduf@yahoo.fr> | 2014-08-10 13:29:46 +0000 |
|---|---|---|
| committer | JazzyNico <nicoduf@yahoo.fr> | 2014-08-10 13:29:46 +0000 |
| commit | 4436eae1a6810e3630679898f91fe1995d1fae7e (patch) | |
| tree | 9e218022e7968af9df92c6b3cbb225e3279058cf | |
| parent | Fix related to bug #1327267 -- don't bother to update gradient toolbar when n... (diff) | |
| download | inkscape-4436eae1a6810e3630679898f91fe1995d1fae7e.tar.gz inkscape-4436eae1a6810e3630679898f91fe1995d1fae7e.zip | |
Export. Fix for Bug #1166184 (XAML export not compatible with Silverlight).
Fixed bugs:
- https://launchpad.net/bugs/1166184
(bzr r13505)
| -rw-r--r-- | share/extensions/svg2xaml.inx | 1 | ||||
| -rwxr-xr-x | share/extensions/svg2xaml.xsl | 14 | ||||
| -rw-r--r-- | src/extension/implementation/xslt.cpp | 40 |
3 files changed, 36 insertions, 19 deletions
diff --git a/share/extensions/svg2xaml.inx b/share/extensions/svg2xaml.inx index da621b8f7..74b8f731a 100644 --- a/share/extensions/svg2xaml.inx +++ b/share/extensions/svg2xaml.inx @@ -2,6 +2,7 @@ <inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension"> <_name>XAML Output</_name> <id>org.inkscape.output.xaml</id> + <param name="silverlight" type="boolean" _gui-text="Silverlight compatible XAML">false</param> <output> <extension>.xaml</extension> <mimetype>text/xml+xaml</mimetype> diff --git a/share/extensions/svg2xaml.xsl b/share/extensions/svg2xaml.xsl index 40b1f400b..516f68b76 100755 --- a/share/extensions/svg2xaml.xsl +++ b/share/extensions/svg2xaml.xsl @@ -3,7 +3,7 @@ <!-- Copyright (c) 2005-2007 authors: Original version: Toine de Greef (a.degreef@chello.nl) -Modified (2010-2011) by Nicolas Dufour (nicoduf@yahoo.fr) (blur support, units +Modified (2010-2014) by Nicolas Dufour (nicoduf@yahoo.fr) (blur support, units convertion, comments, and some other fixes) Permission is hereby granted, free of charge, to any person obtaining a copy @@ -39,7 +39,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt"> <xsl:strip-space elements="*" /> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> -<xsl:param name="silverlight_compatible" select="2" /> +<xsl:param name="silverlight_compatible" select="$silverlight" /> <!-- // Containers // @@ -53,10 +53,16 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt"> --> <xsl:template match="/"> <xsl:choose> - <xsl:when test="$silverlight_compatible = 1"> + <xsl:when test="$silverlight_compatible = 'true'"> + <xsl:comment> + <xsl:value-of select="'This file is compatible with Silverlight'" /> + </xsl:comment> <xsl:apply-templates mode="forward" /> </xsl:when> <xsl:otherwise> + <xsl:comment> + <xsl:value-of select="'This file is NOT compatible with Silverlight'" /> + </xsl:comment> <Viewbox Stretch="Uniform"> <xsl:apply-templates mode="forward" /> </Viewbox> @@ -2650,7 +2656,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt"> <xsl:if test="@d"> <xsl:choose> - <xsl:when test="$silverlight_compatible = 1"> + <xsl:when test="$silverlight_compatible = 'true'"> <xsl:attribute name="Data"> <xsl:value-of select="translate(@d , ',', ' ')" /> </xsl:attribute> diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index bcea06cb5..85ae9efde 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -20,6 +20,7 @@ #include "xslt.h" #include "../extension.h" #include "../output.h" +#include "extension/input.h" #include "xml/repr.h" #include "io/sys.h" @@ -53,8 +54,7 @@ XSLT::XSLT(void) : { } -Glib::ustring -XSLT::solve_reldir(Inkscape::XML::Node *reprin) { +Glib::ustring XSLT::solve_reldir(Inkscape::XML::Node *reprin) { gchar const *s = reprin->attribute("reldir"); @@ -90,8 +90,7 @@ XSLT::solve_reldir(Inkscape::XML::Node *reprin) { return ""; } -bool -XSLT::check(Inkscape::Extension::Extension *module) +bool XSLT::check(Inkscape::Extension::Extension *module) { if (load(module)) { unload(module); @@ -101,8 +100,7 @@ XSLT::check(Inkscape::Extension::Extension *module) } } -bool -XSLT::load(Inkscape::Extension::Extension *module) +bool XSLT::load(Inkscape::Extension::Extension *module) { if (module->loaded()) { return true; } @@ -130,8 +128,7 @@ XSLT::load(Inkscape::Extension::Extension *module) return true; } -void -XSLT::unload(Inkscape::Extension::Extension *module) +void XSLT::unload(Inkscape::Extension::Extension *module) { if (!module->loaded()) { return; } xsltFreeStylesheet(_stylesheet); @@ -139,8 +136,8 @@ XSLT::unload(Inkscape::Extension::Extension *module) return; } -SPDocument * -XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename) +SPDocument * XSLT::open(Inkscape::Extension::Input */*module*/, + gchar const *filename) { xmlDocPtr filein = xmlParseFile(filename); if (filein == NULL) { return NULL; } @@ -184,8 +181,7 @@ XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename) return doc; } -void -XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, 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. */ @@ -214,10 +210,24 @@ XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const return; } - const char * params[1]; - params[0] = NULL; + std::list<std::string> params; + module->paramListString(params); + const int max_parameters = params.size() * 2; + const char * xslt_params[max_parameters+1] ; + + int count = 0; + for(std::list<std::string>::iterator t=params.begin(); t != params.end(); ++t) { + std::size_t pos = t->find("="); + std::ostringstream parameter; + std::ostringstream value; + parameter << t->substr(2,pos-2); + value << t->substr(pos+1); + xslt_params[count++] = g_strdup_printf("%s", parameter.str().c_str()); + xslt_params[count++] = g_strdup_printf("'%s'", value.str().c_str()); + } + xslt_params[count] = NULL; - xmlDocPtr newdoc = xsltApplyStylesheet(_stylesheet, svgdoc, params); + xmlDocPtr newdoc = xsltApplyStylesheet(_stylesheet, svgdoc, xslt_params); //xmlSaveFile(filename, newdoc); int success = xsltSaveResultToFilename(filename, newdoc, _stylesheet, 0); |
