summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-10-14 18:58:58 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-10-14 18:58:58 +0000
commit19463b12ec3527406825b9d2e092d6e78688f2a4 (patch)
tree59008ee44a4138ff35c218bed89a2ad38748376a /src
parentExtensions: Improve logic to lookup script extensions (diff)
downloadinkscape-19463b12ec3527406825b9d2e092d6e78688f2a4.tar.gz
inkscape-19463b12ec3527406825b9d2e092d6e78688f2a4.zip
Extensions: Switch .xslt file look-up to dependency logic as well
Diffstat (limited to 'src')
-rw-r--r--src/extension/extension.cpp9
-rw-r--r--src/extension/implementation/xslt.cpp24
-rw-r--r--src/extension/implementation/xslt.h1
3 files changed, 12 insertions, 22 deletions
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 771a2105e..e0f4ed3fe 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -122,7 +122,14 @@ Extension::Extension(Inkscape::XML::Node *in_repr, Implementation::Implementatio
}
} else if (!strcmp(chname, "dependency")) {
_deps.push_back(new Dependency(child_repr, this));
- } else if (!strcmp(chname, "script")) { // check command as a dependency (see LP #505920)
+ } else if (!strcmp(chname, "script")) { // TODO: should these be parsed in their respective Implementation?
+ for (Inkscape::XML::Node *child = child_repr->firstChild(); child != nullptr; child = child->next()) {
+ if (child->type() == Inkscape::XML::ELEMENT_NODE) { // skip non-element nodes (see LP #1372200)
+ _deps.push_back(new Dependency(child, this));
+ break;
+ }
+ }
+ } else if (!strcmp(chname, "xslt")) { // TODO: should these be parsed in their respective Implementation?
for (Inkscape::XML::Node *child = child_repr->firstChild(); child != nullptr; child = child->next()) {
if (child->type() == Inkscape::XML::ELEMENT_NODE) { // skip non-element nodes (see LP #1372200)
_deps.push_back(new Dependency(child, this));
diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp
index 69e876be4..81ce90dd0 100644
--- a/src/extension/implementation/xslt.cpp
+++ b/src/extension/implementation/xslt.cpp
@@ -57,25 +57,6 @@ XSLT::XSLT() :
{
}
-Glib::ustring XSLT::solve_reldir(Inkscape::XML::Node *reprin) {
-
- gchar const *s = reprin->attribute("reldir");
-
- if (!s) {
- Glib::ustring str = reprin->firstChild()->content();
- return str;
- }
-
- Glib::ustring reldir = s;
- if (reldir == "extensions") {
- using namespace Inkscape::IO::Resource;
- return get_filename(EXTENSIONS, reprin->firstChild()->content());
- } else {
- Glib::ustring str = reprin->firstChild()->content();
- return str;
- }
-}
-
bool XSLT::check(Inkscape::Extension::Extension *module)
{
if (load(module)) {
@@ -96,7 +77,10 @@ bool XSLT::load(Inkscape::Extension::Extension *module)
child_repr = child_repr->firstChild();
while (child_repr != nullptr) {
if (!strcmp(child_repr->name(), INKSCAPE_EXTENSION_NS "file")) {
- _filename = solve_reldir(child_repr);
+ // TODO: we already parse xslt files as dependencies in extension.cpp
+ // can can we optimize this to be less indirect?
+ const char *filename = child_repr->firstChild()->content();
+ _filename = module->get_dependency_location(filename);
}
child_repr = child_repr->next();
}
diff --git a/src/extension/implementation/xslt.h b/src/extension/implementation/xslt.h
index f4fc871a9..745d7f57a 100644
--- a/src/extension/implementation/xslt.h
+++ b/src/extension/implementation/xslt.h
@@ -36,7 +36,6 @@ private:
xmlDocPtr _parsedDoc;
xsltStylesheetPtr _stylesheet;
- Glib::ustring solve_reldir(Inkscape::XML::Node *reprin);
public:
XSLT ();