diff --git a/src/document.cpp b/src/document.cpp
index 92aad942d7687e7f8d24cad35a25712962774d8b..356fba577055c7cab0d165401117f68c68fcadc6 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
#include "inkscape-private.h"
#include "inkscape_version.h"
#include "sp-object-repr.h"
+#include "sp-namedview.h"
+#include "desktop.h"
#include "document-private.h"
#include "dir-util.h"
#include "unit-constants.h"
static unsigned long next_serial = 0;
-SPDocument::SPDocument() {
- SPDocumentPrivate *p;
-
- keepalive = FALSE;
- virgin = TRUE;
-
- modified_id = 0;
-
- rdoc = NULL;
- rroot = NULL;
- root = NULL;
- style_cascade = cr_cascade_new(NULL, NULL, NULL);
-
- uri = NULL;
- base = NULL;
- name = NULL;
-
- _collection_queue = NULL;
-
- // Initialise instance of connector router.
- router = new Avoid::Router();
+SPDocument::SPDocument() :
+ keepalive(FALSE),
+ virgin(TRUE),
+ modified_since_save(FALSE),
+ rdoc(0),
+ rroot(0),
+ root(0),
+ style_cascade(cr_cascade_new(NULL, NULL, NULL)),
+ uri(0),
+ base(0),
+ name(0),
+ priv(0), // reset in ctor
+ actionkey(0),
+ modified_id(0),
+ profileManager(0), // deferred until after other initialization
+ router(new Avoid::Router()),
+ perspectives(0),
+ current_persp3d(0),
+ _collection_queue(0)
+{
// Don't use the Consolidate moves optimisation.
router->ConsolidateMoves = false;
- perspectives = NULL;
-
- p = new SPDocumentPrivate();
+ SPDocumentPrivate *p = new SPDocumentPrivate();
p->serial = next_serial++;
}
/* End of quick hack 3 */
+ /* Eliminate obsolete sodipodi:docbase, for privacy reasons */
+ rroot->setAttribute("sodipodi:docbase", NULL);
+
+ /* Eliminate any claim to adhere to a profile, as we don't try to */
+ rroot->setAttribute("baseProfile", NULL);
+
// creating namedview
if (!sp_item_group_get_child_by_name((SPGroup *) document->root, NULL, "sodipodi:namedview")) {
// if there's none in the document already,
g_return_val_if_fail(document->priv != NULL, 0.0);
g_return_val_if_fail(document->root != NULL, 0.0);
- return SP_ROOT(document->root)->width.computed;
+ SPRoot *root = SP_ROOT(document->root);
+
+ if (root->width.unit == SVGLength::PERCENT && root->viewBox_set)
+ return root->viewBox.x1 - root->viewBox.x0;
+ return root->width.computed;
}
void
g_return_val_if_fail(document->priv != NULL, 0.0);
g_return_val_if_fail(document->root != NULL, 0.0);
- return SP_ROOT(document->root)->height.computed;
+ SPRoot *root = SP_ROOT(document->root);
+
+ if (root->height.unit == SVGLength::PERCENT && root->viewBox_set)
+ return root->viewBox.y1 - root->viewBox.y0;
+ return root->height.computed;
}
/**
NR::translate const tr(NR::Point(0, (old_height - h))
- rect.min());
SP_GROUP(root)->translateChildItems(tr);
+ SPNamedView *nv = sp_document_namedview(this, 0);
+ if(nv) {
+ NR::translate tr2(-rect.min());
+ nv->translateGuides(tr2);
+
+ // update the viewport so the drawing appears to stay where it was
+ nv->scrollAllDesktops(-tr2[0], tr2[1], false);
+ }
}
void sp_document_set_uri(SPDocument *document, gchar const *uri)