summaryrefslogtreecommitdiffstats
path: root/src/uri-references.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-01-16 17:20:34 +0000
committerMartin Owens <doctormo@gmail.com>2014-01-16 17:20:34 +0000
commitb31224a81f04f0ff9b412983f2f35fa63c0e7e41 (patch)
tree376cbcc47d96f261eb61cd15d9b7571f30991b3a /src/uri-references.cpp
parentbzrignore: update ignore list to include new i18n file (follow-up to r12937) (diff)
downloadinkscape-b31224a81f04f0ff9b412983f2f35fa63c0e7e41.tar.gz
inkscape-b31224a81f04f0ff9b412983f2f35fa63c0e7e41.zip
Add the ability to load external documents in xlink:hrefs such as the use element. See bug #1269880
Fixed bugs: - https://launchpad.net/bugs/1269880 (bzr r12939)
Diffstat (limited to 'src/uri-references.cpp')
-rw-r--r--src/uri-references.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/uri-references.cpp b/src/uri-references.cpp
index 2c09695d4..718b2d451 100644
--- a/src/uri-references.cpp
+++ b/src/uri-references.cpp
@@ -12,6 +12,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <iostream>
#include <cstring>
#include <string>
@@ -21,6 +22,7 @@
#include "uri-references.h"
#include "extract-uri.h"
+#include <glibmm/miscutils.h>
#include <sigc++/functors/mem_fun.h>
namespace Inkscape {
@@ -45,15 +47,31 @@ URIReference::~URIReference()
void URIReference::attach(const URI &uri) throw(BadURIException)
{
- SPDocument *document;
+ SPDocument *document = NULL;
+
+ // Attempt to get the document that contains the URI
if (_owner) {
document = _owner->document;
} else if (_owner_document) {
document = _owner_document;
- } else {
- g_assert_not_reached();
}
+ // The path contains references to seperate document files to load.
+ const char *path = uri.getPath();
+ if(path) {
+ if(document != NULL) {
+ // Calculate the absolute path from an available document
+ std::string basePath = std::string( document->getBase() );
+ std::string absPath = Glib::build_filename(basePath, std::string( path ) );
+ path = absPath.c_str();
+ }
+ // TODO: This is inefficient because it will load the same svg file
+ // many times if it's used many times. A global list of documents would
+ // be useful for tracking linked items.
+ document = SPDocument::createNewDoc(path, FALSE);
+ }
+ g_return_if_fail(document != NULL);
+
gchar const *fragment = uri.getFragment();
if ( !uri.isRelative() || uri.getQuery() || !fragment ) {
throw UnsupportedURIException();