Commit a6162e76 authored by Martin Owens's avatar Martin Owens

Add very raw page loading using links

(bzr r15727)
parent dd8b63d5
......@@ -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;
}
......
......@@ -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");
......
......@@ -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;
......
  • What does this actually do? Is there a well specified plan?

  • It would be nice if JessyInk were integrated into multi-page support.

  • When I was looking at it yesterday I tried something like

    <a xlink:href="another.svg" xlink:type="page"><text>test</text></a>

    which crashed Inkscape...

    (I'm not sure if this is even how it's supposed to be used, though)

    Edited by Patrick Storz
  • I've documented the plan, but I can't find it right now (must have hidden it good).

    The brief grand idea is:

    1. Add page links so that a first page can reference other pages
    2. Allow zip files to be opened, which unpacks multiple svg files (and png and css files if needed)
    3. Add navigation to user interface so one can move from previous the next page
    4. Add page add and remove to interface, allowing page settings to inherit from previous page.
    5. Add pdf export and import for multiple pages.

    This is a part of the 'odf' style document zip file solution. It's not the only way of doing multi-pages though.

  • Why not use a much more "safe" approach? For example:

    1. A page is just fixed rectangle ( <svg:rect id="rect001" inkscape:page="page001"> ) with the "inkscape:page", position fixed but selectable, and with size equal to the page.
    2. A multi page document is just another rectangle to the right of the first one. Etc.
    3. Export to PDF could work just calling --export-pdf adding the support --export-area that of the rectangle "page"; and then use some kind of opensource pdf merger as dependency to merge the created PDFs.

    The benefit of this approach is that you can move objects around between pages, with the groups/layers you want, etc. without having any problem with compatibility and without any need to learn anything new but just to keep the items you want in a page inside a rectangle...

Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment