summaryrefslogtreecommitdiffstats
path: root/src/sp-anchor.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2017-06-04 22:12:50 +0000
committerMartin Owens <doctormo@gmail.com>2017-06-04 22:12:50 +0000
commit33f79b9653a737c534acd45eff6da806b68c276d (patch)
tree2c588631313ac6078c1a047eea4e0fbcc2df3fd4 /src/sp-anchor.cpp
parentMerge bugfixes for xverbs (diff)
downloadinkscape-33f79b9653a737c534acd45eff6da806b68c276d.tar.gz
inkscape-33f79b9653a737c534acd45eff6da806b68c276d.zip
Add very raw page loading using links
(bzr r15703.1.24)
Diffstat (limited to 'src/sp-anchor.cpp')
-rw-r--r--src/sp-anchor.cpp42
1 files changed, 39 insertions, 3 deletions
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");