summaryrefslogtreecommitdiffstats
path: root/src/uri-references.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-01-18 09:11:04 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-01-18 09:11:04 +0000
commitf12d6a57fe5cc18be5afd164061578d8e00d75ce (patch)
tree7fd1a501a8a545fbf2326ead48cd041928699c5e /src/uri-references.cpp
parentupdate to trunk (diff)
parentFix missing embeded image condition, kindly caught by suv in bug #1270334 (diff)
downloadinkscape-f12d6a57fe5cc18be5afd164061578d8e00d75ce.tar.gz
inkscape-f12d6a57fe5cc18be5afd164061578d8e00d75ce.zip
update to trunk
(bzr r11950.1.235)
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();