From: Krzysztof KosiƄski Date: Sun, 4 Apr 2010 23:26:13 +0000 (+0200) Subject: Coords: fix guidelines X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7114757ca3ac2d2dc7e821c1034321031619de83;p=inkscape.git Coords: fix guidelines --- diff --git a/src/document.cpp b/src/document.cpp index f137ba60d..aeafaf1f9 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -327,7 +327,7 @@ sp_document_create(Inkscape::XML::Document *rdoc, document->base = NULL; document->name = g_strdup(name); - document->root = sp_object_repr_build_tree(document, rroot); + sp_object_repr_build_tree(document, rroot); /* fixme: Not sure about this, but lets assume ::build updates */ rroot->setAttribute("inkscape:version", Inkscape::version_string); diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index f5edf7d97..def039937 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -217,12 +217,14 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value) success += sp_svg_number_read_d(strarray[1], &newy); g_strfreev (strarray); if (success == 2) { - guide->point_on_line = Geom::Point(newx, newy); + // Desktop coords fix + guide->point_on_line = Geom::Point(newx, sp_document_height(guide->document) - newy); } else if (success == 1) { // before 0.46 style guideline definition. const gchar *attr = SP_OBJECT_REPR(object)->attribute("orientation"); if (attr && !strcmp(attr, "horizontal")) { - guide->point_on_line = Geom::Point(0, newx); + // Desktop coords fix + guide->point_on_line = Geom::Point(0, sp_document_height(guide->document) - newx); } else { guide->point_on_line = Geom::Point(newx, 0); } diff --git a/src/sp-object-repr.cpp b/src/sp-object-repr.cpp index 62143e3ab..e32819746 100644 --- a/src/sp-object-repr.cpp +++ b/src/sp-object-repr.cpp @@ -91,9 +91,9 @@ static unsigned const N_NAME_TYPES = SODIPODI_TYPE + 1; static GType name_to_gtype(NameType name_type, gchar const *name); /** - * Construct an SPRoot and all its descendents from the given repr. + * Construct an SPRoot and all its descendents from the given XML representation. */ -SPObject * +void sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) { g_assert(document != NULL); @@ -103,13 +103,14 @@ sp_object_repr_build_tree(SPDocument *document, Inkscape::XML::Node *repr) g_assert(name != NULL); GType const type = name_to_gtype(REPR_NAME, name); g_assert(g_type_is_a(type, SP_TYPE_ROOT)); - gpointer newobj = g_object_new(type, 0); - g_assert(newobj != NULL); - SPObject *const object = SP_OBJECT(newobj); - g_assert(object != NULL); - sp_object_invoke_build(object, document, repr, FALSE); - return object; + // create and assign root + SPObject *root = SP_OBJECT(g_object_new(type, 0)); + g_assert(root != NULL); + document->root = root; + + // recursively create SP tree elements + sp_object_invoke_build(root, document, repr, FALSE); } GType diff --git a/src/sp-object-repr.h b/src/sp-object-repr.h index f3a80f83c..43aead41e 100644 --- a/src/sp-object-repr.h +++ b/src/sp-object-repr.h @@ -21,7 +21,7 @@ class Node; } -SPObject *sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr); +void sp_object_repr_build_tree (SPDocument *document, Inkscape::XML::Node *repr); GType sp_repr_type_lookup (Inkscape::XML::Node *repr);