diff options
| author | Martin Owens <doctormo@gmail.com> | 2017-06-04 22:12:50 +0000 |
|---|---|---|
| committer | Martin Owens <doctormo@gmail.com> | 2017-06-04 22:12:50 +0000 |
| commit | a6162e760c7eab68fc65a4ccc879e73ab0c20c1b (patch) | |
| tree | 2c588631313ac6078c1a047eea4e0fbcc2df3fd4 /src | |
| parent | Merge bugfixes for xverbs (diff) | |
| download | inkscape-a6162e760c7eab68fc65a4ccc879e73ab0c20c1b.tar.gz inkscape-a6162e760c7eab68fc65a4ccc879e73ab0c20c1b.zip | |
Add very raw page loading using links
(bzr r15727)
Diffstat (limited to 'src')
| -rw-r--r-- | src/document.cpp | 12 | ||||
| -rw-r--r-- | src/sp-anchor.cpp | 42 | ||||
| -rw-r--r-- | src/sp-anchor.h | 4 |
3 files changed, 52 insertions, 6 deletions
diff --git a/src/document.cpp b/src/document.cpp index c7115f906..4fcc2b098 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -481,7 +481,7 @@ SPDocument *SPDocument::createChildDoc(std::string const &uri) SPDocument *document = NULL; while(parent != NULL && parent->getURI() != NULL && document == NULL) { - // Check myself and any parents int he chain + // Check myself and any parents in the chain if(uri == parent->getURI()) { document = parent; break; @@ -500,8 +500,14 @@ SPDocument *SPDocument::createChildDoc(std::string const &uri) // Load a fresh document from the svg source. if(!document) { - const char *path = uri.c_str(); - document = createNewDoc(path, false, false, this); + std::string path; + if(uri.find('/') == -1) { + path = this->getBase() + uri; + } else { + path = uri; + } + std::cout << "Added base: '" << path << "'\n"; + document = createNewDoc(path.c_str(), false, false, this); } return document; } diff --git a/src/sp-anchor.cpp b/src/sp-anchor.cpp index 78ba10c13..b40f53ee1 100644 --- a/src/sp-anchor.cpp +++ b/src/sp-anchor.cpp @@ -5,6 +5,7 @@ * Lauris Kaplinski <lauris@kaplinski.com> * Abhishek Sharma * + * Copyright (C) 2017 Martin Owens * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. * @@ -23,6 +24,9 @@ SPAnchor::SPAnchor() : SPGroup() { this->href = NULL; + this->type = NULL; + this->title = NULL; + this->page = NULL; } SPAnchor::~SPAnchor() { @@ -46,6 +50,18 @@ void SPAnchor::release() { g_free(this->href); this->href = NULL; } + if (this->type) { + g_free(this->type); + this->type = NULL; + } + if (this->title) { + g_free(this->title); + this->title = NULL; + } + if (this->page) { + g_free(this->page); + this->page = NULL; + } SPGroup::release(); } @@ -56,12 +72,21 @@ void SPAnchor::set(unsigned int key, const gchar* value) { g_free(this->href); this->href = g_strdup(value); this->requestModified(SP_OBJECT_MODIFIED_FLAG); + this->updatePageAnchor(); break; - case SP_ATTR_XLINK_TYPE: + g_free(this->type); + this->type = g_strdup(value); + this->updatePageAnchor(); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_XLINK_ROLE: case SP_ATTR_XLINK_ARCROLE: case SP_ATTR_XLINK_TITLE: + g_free(this->title); + this->title = g_strdup(value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_XLINK_SHOW: case SP_ATTR_XLINK_ACTUATE: case SP_ATTR_TARGET: @@ -74,6 +99,17 @@ void SPAnchor::set(unsigned int key, const gchar* value) { } } +/* + * Detect if this anchor qualifies as a page link and append + * the new page document to this document. + */ +void SPAnchor::updatePageAnchor() { + if (this->type && !strcmp(this->type, "page")) { + if (this->href && !this->page) { + this->page = this->document->createChildDoc(this->href); + } + } +} #define COPY_ATTR(rd,rs,key) (rd)->setAttribute((key), rs->attribute(key)); @@ -83,14 +119,14 @@ Inkscape::XML::Node* SPAnchor::write(Inkscape::XML::Document *xml_doc, Inkscape: } repr->setAttribute("xlink:href", this->href); + if (this->type) repr->setAttribute("xlink:type", this->type); + if (this->title) repr->setAttribute("xlink:title", this->title); if (repr != this->getRepr()) { // XML Tree being directly used while it shouldn't be in the // below COPY_ATTR lines - COPY_ATTR(repr, this->getRepr(), "xlink:type"); COPY_ATTR(repr, this->getRepr(), "xlink:role"); COPY_ATTR(repr, this->getRepr(), "xlink:arcrole"); - COPY_ATTR(repr, this->getRepr(), "xlink:title"); COPY_ATTR(repr, this->getRepr(), "xlink:show"); COPY_ATTR(repr, this->getRepr(), "xlink:actuate"); COPY_ATTR(repr, this->getRepr(), "target"); diff --git a/src/sp-anchor.h b/src/sp-anchor.h index d17718344..2dd81f74c 100644 --- a/src/sp-anchor.h +++ b/src/sp-anchor.h @@ -24,10 +24,14 @@ public: virtual ~SPAnchor(); char *href; + char *type; + char *title; + SPDocument *page; virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); virtual void set(unsigned int key, char const* value); + virtual void updatePageAnchor(); virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); virtual const char* displayName() const; |
