summaryrefslogtreecommitdiffstats
path: root/src/uri-references.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-01-22 03:20:23 +0000
committerMartin Owens <doctormo@gmail.com>2014-01-22 03:20:23 +0000
commite01eb5907b04fdc194551741be6c6dbf5ee6f7e5 (patch)
tree5b0051ad37589ddaa109f88cf9cf8ce1d1687945 /src/uri-references.cpp
parentEMF export: fix handling of transformed rectangular gradients (bug #1263242) (diff)
downloadinkscape-e01eb5907b04fdc194551741be6c6dbf5ee6f7e5.tar.gz
inkscape-e01eb5907b04fdc194551741be6c6dbf5ee6f7e5.zip
Improve use tag logic by recording the loaded documents in a list.
(bzr r12969)
Diffstat (limited to 'src/uri-references.cpp')
-rw-r--r--src/uri-references.cpp39
1 files changed, 29 insertions, 10 deletions
diff --git a/src/uri-references.cpp b/src/uri-references.cpp
index 718b2d451..adf948c7b 100644
--- a/src/uri-references.cpp
+++ b/src/uri-references.cpp
@@ -58,17 +58,36 @@ void URIReference::attach(const URI &uri) throw(BadURIException)
// 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();
+ if(path && 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();
+
+ // We look at existing children and parents
+ SPDocument *parent = document;
+ SPDocument *original = document;
+ document = NULL;
+
+ while(parent != NULL) {
+ boost::ptr_list<SPDocument>::iterator iter;
+ for (iter = parent->child_documents.begin();
+ iter != parent->child_documents.end(); ++iter) {
+ if(strcmp(iter->getURI(), path)==0)
+ document = &*iter;
+ }
+ parent = parent->parent_document;
+ }
+ // Load a fresh document from the svg source.
+ if(!document) {
+ document = SPDocument::createNewDoc(path, FALSE);
+ if(document) {
+ document->parent_document = original;
+ original->child_documents.push_back(document);
+ } else {
+ g_warning("Could not load svg file: %s", path);
+ }
}
- // 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);