From 47aa8306a659760d5967944af42da27a703dfc63 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 5 Jun 2012 22:40:25 +0200 Subject: various (bzr r11461) --- src/document.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index cc139aae0..b2ee5103d 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -103,7 +103,8 @@ SPDocument::SPDocument() : router(new Avoid::Router(Avoid::PolyLineRouting|Avoid::OrthogonalRouting)), _collection_queue(0), oldSignalsConnected(false), - current_persp3d(0) + current_persp3d(NULL), + current_persp3d_impl(NULL) { // Penalise libavoid for choosing paths with needless extra segments. // This results in much better looking orthogonal connector paths. @@ -223,8 +224,7 @@ SPDefs *SPDocument::getDefs() return root->defs; } -Persp3D * -SPDocument::getCurrentPersp3D() { +Persp3D *SPDocument::getCurrentPersp3D() { // Check if current_persp3d is still valid std::vector plist; getPerspectivesInDefs(plist); @@ -239,13 +239,11 @@ SPDocument::getCurrentPersp3D() { return current_persp3d; } -Persp3DImpl * -SPDocument::getCurrentPersp3DImpl() { +Persp3DImpl *SPDocument::getCurrentPersp3DImpl() { return current_persp3d_impl; } -void -SPDocument::setCurrentPersp3D(Persp3D * const persp) { +void SPDocument::setCurrentPersp3D(Persp3D * const persp) { current_persp3d = persp; //current_persp3d_impl = persp->perspective_impl; } -- cgit v1.2.3 From 1764f9bee905bcc27c3e9bb88f22f6510807a23d Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 21 Jul 2012 11:20:15 -0400 Subject: refresh sodipodi:docname when saving (Bug 1024690) Fixed bugs: - https://launchpad.net/bugs/1024690 (bzr r11562) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index b2ee5103d..818558a94 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -714,7 +714,7 @@ void SPDocument::do_change_uri(gchar const *const filename, bool const rebase) Inkscape::XML::rebase_hrefs(this, new_base, true); } - repr->setAttribute("sodipodi:docname", this->name); + repr->setAttribute("sodipodi:docname", new_name); DocumentUndo::setUndoSensitive(this, saved); -- cgit v1.2.3 From 703af68b0aea10252a11e738b147054926b19f24 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 28 Jul 2012 08:15:34 -0400 Subject: do not allow sodipodi:docname to have a temporary filename (partial fix for Bug 243162) Fixed bugs: - https://launchpad.net/bugs/243162 (bzr r11574) --- src/document.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 818558a94..01c5481b0 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -354,9 +354,9 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, /* End of quick hack 2 */ /* Quick hack 3 - Set uri attributes */ - if (uri) { - rroot->setAttribute("sodipodi:docname", uri); - } +// if (uri) { // this is done in do_change_uri() +// rroot->setAttribute("sodipodi:docname", uri); +// } /* End of quick hack 3 */ /* Eliminate obsolete sodipodi:docbase, for privacy reasons */ @@ -714,7 +714,8 @@ void SPDocument::do_change_uri(gchar const *const filename, bool const rebase) Inkscape::XML::rebase_hrefs(this, new_base, true); } - repr->setAttribute("sodipodi:docname", new_name); + if (strncmp(new_name, "ink_ext_XXXXXX", 14)) // do not use temporary filenames + repr->setAttribute("sodipodi:docname", new_name); DocumentUndo::setUndoSensitive(this, saved); -- cgit v1.2.3 From 8d2e0c37027b55156c81a7733f35338409e37a00 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 4 Aug 2012 11:20:42 +0900 Subject: Fix for 1030239 : Custom markers only added to the list in Stroke Style after reloading the file (bzr r11588) --- src/document.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 01c5481b0..5eaab3eca 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -221,6 +221,9 @@ SPDocument::~SPDocument() { SPDefs *SPDocument::getDefs() { + if (!root) { + return NULL; + } return root->defs; } -- cgit v1.2.3 From fed4cf9a7438a2e0d6833618bd769b684397a483 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 18 Sep 2012 14:15:41 +0900 Subject: Fix for 1051434 : occasional crash when selecting disjoint path with markers (bzr r11673) --- src/document.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 5eaab3eca..9efd9d923 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -865,6 +865,9 @@ SPObject *SPDocument::getObjectById(Glib::ustring const &id) const SPObject *SPDocument::getObjectById(gchar const *id) const { g_return_val_if_fail(id != NULL, NULL); + if (!priv || !priv->iddef) { + return NULL; + } GQuark idq = g_quark_from_string(id); gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); -- cgit v1.2.3 From bf7c3e8d98b557cb64447804399797d93e1cedc0 Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 19 Sep 2012 10:52:19 +0900 Subject: Fix for 643150 : Auto-palette swatches duplicated on copy and paste (bzr r11677) --- src/document.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 9efd9d923..e28356969 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1453,10 +1453,33 @@ void SPDocument::importDefs(SPDocument *source) prevent_id_clashes(source, this); for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); - target_defs->appendChild(dup); - Inkscape::GC::release(dup); + + // Prevent duplicates of solid swatches by checking if equivalent swatch already exists + gboolean duplicate = false; + SPObject *src = source->getObjectByRepr(def); + if (src && SP_IS_GRADIENT(src)) { + SPGradient *gr = SP_GRADIENT(src); + if (gr->isSolid() || gr->getVector()->isSolid()) { + for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { + if (trg && SP_IS_GRADIENT(trg) && src != trg) { + if (gr->isEquivalent(SP_GRADIENT(trg))) { + // Change object references to the existing equivalent gradient + change_def_references(src, trg); + duplicate = true; + break; + } + } + } + } + } + + if (!duplicate) { + Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); + target_defs->appendChild(dup); + Inkscape::GC::release(dup); + } } + } /* -- cgit v1.2.3 From 370a3f5cc9e39352a081e5d5dd8c43676547a6e6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 4 Oct 2012 11:45:44 +1000 Subject: code cleanup: add own includes to cpp files or make the functions static if they are not used elsewhere. (bzr r11735) --- src/document.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e28356969..9d8291db0 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1107,7 +1107,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, /** Returns true if an item is among the descendants of group (recursively). */ -bool item_is_in_group(SPItem *item, SPGroup *group) +static bool item_is_in_group(SPItem *item, SPGroup *group) { bool inGroup = false; for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) { @@ -1158,7 +1158,7 @@ items. If upto != NULL, then if item upto is encountered (at any level), stops s upwards in z-order and returns what it has found so far (i.e. the found item is guaranteed to be lower than upto). */ -SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) +static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) { SPItem *seen = NULL; SPItem *newseen = NULL; @@ -1203,7 +1203,7 @@ SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const Returns the topmost non-layer group from the descendants of group which is at point p, or NULL if none. Recurses into layers but not into groups. */ -SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) +static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) { SPItem *seen = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1374,7 +1374,7 @@ sp_document_resource_list_free(gpointer /*key*/, gpointer value, gpointer /*data return TRUE; } -unsigned int count_objects_recursive(SPObject *obj, unsigned int count) +static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself @@ -1385,12 +1385,12 @@ unsigned int count_objects_recursive(SPObject *obj, unsigned int count) return count; } -unsigned int objects_in_document(SPDocument *document) +static unsigned int objects_in_document(SPDocument *document) { return count_objects_recursive(document->getRoot(), 0); } -void vacuum_document_recursive(SPObject *obj) +static void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) { -- cgit v1.2.3 From f304ab600788b02cb02a4413f68f466e35cf1539 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 11 Oct 2012 19:54:14 +0200 Subject: Add symbols dialog. See: http://wiki.inkscape.org/wiki/index.php/SymbolsDialog (bzr r11782) --- src/document.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 9d8291db0..172037518 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -7,10 +7,12 @@ * bulia byak * Jon A. Cruz * Abhishek Sharma + * Tavmjong Bah * * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. + * Copyright (C) 2012 Tavmjong Bah * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -59,6 +61,7 @@ #include "sp-item-group.h" #include "sp-namedview.h" #include "sp-object-repr.h" +#include "sp-symbol.h" #include "transf_mat_3x4.h" #include "unit-constants.h" #include "xml/repr.h" @@ -1454,9 +1457,10 @@ void SPDocument::importDefs(SPDocument *source) for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - // Prevent duplicates of solid swatches by checking if equivalent swatch already exists gboolean duplicate = false; SPObject *src = source->getObjectByRepr(def); + + // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *gr = SP_GRADIENT(src); if (gr->isSolid() || gr->getVector()->isSolid()) { @@ -1473,6 +1477,35 @@ void SPDocument::importDefs(SPDocument *source) } } + // Prevent duplication of symbols... could be more clever. + // The tag "_inkscape_duplicate" is added to "id" by ClipboardManagerImpl::copySymbol(). + // We assume that symbols are in defs section (not required by SVG spec). + if (src && SP_IS_SYMBOL(src)) { + + Glib::ustring id = src->getRepr()->attribute("id"); + size_t pos = id.find( "_inkscape_duplicate" ); + if( pos != Glib::ustring::npos ) { + + // This is our symbol, now get rid of tag + id.erase( pos ); + + // Check that it really is a duplicate + for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { + if( trg && SP_IS_SYMBOL(trg) && src != trg ) { + std::string id2 = trg->getRepr()->attribute("id"); + + if( !id.compare( id2 ) ) { + duplicate = true; + break; + } + } + } + if ( !duplicate ) { + src->getRepr()->setAttribute("id", id.c_str() ); + } + } + } + if (!duplicate) { Inkscape::XML::Node * dup = def->duplicate(this->getReprDoc()); target_defs->appendChild(dup); -- cgit v1.2.3 From c35fe9c8d780e447dd6e3a8263689ea661a630de Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 22 Jan 2013 19:46:36 +0100 Subject: direct use of Glib::ustring (bzr r12053) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 172037518..25ad735e1 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -862,7 +862,7 @@ SPDocument::removeUndoObserver(Inkscape::UndoStackObserver& observer) SPObject *SPDocument::getObjectById(Glib::ustring const &id) const { - return getObjectById( id.c_str() ); + return getObjectById( id ); } SPObject *SPDocument::getObjectById(gchar const *id) const -- cgit v1.2.3 From 70467baaabf4efc3f76297058a358c04212419c2 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Wed, 23 Jan 2013 22:21:28 +0100 Subject: revert my revision 12053 (Bug #1103248 ) (bzr r12058) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 25ad735e1..172037518 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -862,7 +862,7 @@ SPDocument::removeUndoObserver(Inkscape::UndoStackObserver& observer) SPObject *SPDocument::getObjectById(Glib::ustring const &id) const { - return getObjectById( id ); + return getObjectById( id.c_str() ); } SPObject *SPDocument::getObjectById(gchar const *id) const -- cgit v1.2.3 From 32ff8baed32f34bf6083d05fa27b8bb1b2d0d596 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 29 Jan 2013 18:12:40 +0100 Subject: Crash. Partial fix for Bug #1046068 (Inkscape (GTK+/Quartz) calls output extensions or crashes when quitting while clipboard not empty). (bzr r12071) --- src/document.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 172037518..97b3bf584 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1435,10 +1435,12 @@ bool SPDocument::isSeeking() const { void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; - Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); - g_assert(parent != NULL); - SPDesktopWidget *dtw = static_cast(parent->get_data("desktopwidget")); - dtw->updateTitle( this->getName() ); + if (SP_ACTIVE_DESKTOP) { + Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); + g_assert(parent != NULL); + SPDesktopWidget *dtw = static_cast(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } -- cgit v1.2.3 From 152c4d581e6dcb5185cbd9886a80cd7dc5e27c8e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 18 Mar 2013 12:42:20 +0000 Subject: Fix -Wcast-align issues with SPItemCtx (bzr r12222) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 97b3bf584..706710cfc 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -953,7 +953,7 @@ void SPDocument::requestModified() void SPDocument::setupViewport(SPItemCtx *ctx) { - ctx->ctx.flags = 0; + ctx->flags = 0; ctx->i2doc = Geom::identity(); // Set up viewport in case svg has it defined as percentages if (root->viewBox_set) { // if set, take from viewBox -- cgit v1.2.3 From 8de8047c5e30af8598646d7a66c62dbf290f7c51 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 10 Apr 2013 16:10:04 +0200 Subject: Removed old SPObject factory. (bzr r11608.1.91) --- src/document.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 706710cfc..0a8b2e674 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -58,9 +58,9 @@ #include "preferences.h" #include "profile-manager.h" #include "rdf.h" +#include "sp-factory.h" #include "sp-item-group.h" #include "sp-namedview.h" -#include "sp-object-repr.h" #include "sp-symbol.h" #include "transf_mat_3x4.h" #include "unit-constants.h" @@ -348,7 +348,20 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, } document->name = g_strdup(name); - document->root = sp_object_repr_build_tree(document, rroot); + // Create SPRoot element + SPObject* rootObj = SPFactory::instance().createObject(*rroot); + document->root = dynamic_cast(rootObj); + + if (document->root == nullptr) { + // Node is not a valid root element + delete rootObj; + + // fixme: what to do here? + throw; + } + + // Recursively build object tree + document->root->invoke_build(document, rroot, false); /* fixme: Not sure about this, but lets assume ::build updates */ rroot->setAttribute("inkscape:version", Inkscape::version_string); -- cgit v1.2.3 From fbb85064cfaaf03cc09bacedb16a8561f61f2b3d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 00:37:18 +0200 Subject: Added prefPaths to contexts; modified SPFactory (bzr r11608.1.94) --- src/document.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 0a8b2e674..e58f581b5 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -349,10 +349,11 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->name = g_strdup(name); // Create SPRoot element - SPObject* rootObj = SPFactory::instance().createObject(*rroot); + const std::string typeString = NodeTraits::getTypeString(*rroot); + SPObject* rootObj = SPFactory::instance().createObject(typeString); document->root = dynamic_cast(rootObj); - if (document->root == nullptr) { + if (document->root == 0) { // Node is not a valid root element delete rootObj; -- cgit v1.2.3 From 608843c38bc77cffe831c1d397de9f166831e0ab Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 21 May 2013 13:17:25 +0200 Subject: Fix for bug #1022543 (Ctrl+C increments the documents count) by Maggio. Fixed bugs: - https://launchpad.net/bugs/1022543 (bzr r12340) --- src/document.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 706710cfc..2fc6d3bc6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -84,6 +84,7 @@ static gint sp_document_rerouting_handler(gpointer data); gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); static gint doc_count = 0; +static gint doc_mem_count = 0; static unsigned long next_serial = 0; @@ -480,15 +481,16 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b base = NULL; name = g_strdup(uri); } + if (make_new) { + name = g_strdup_printf(_("New document %d"), ++doc_count); + } g_free(s); } else { - rdoc = sp_repr_document_new("svg:svg"); - } + if (make_new) { + name = g_strdup_printf(_("Memory document %d"), ++doc_mem_count); + } - if (make_new) { - base = NULL; - uri = NULL; - name = g_strdup_printf(_("New document %d"), ++doc_count); + rdoc = sp_repr_document_new("svg:svg"); } //# These should be set by now @@ -514,7 +516,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // If xml file is not svg, return NULL without warning // TODO fixme: destroy document } else { - Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count ); + Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); } } -- cgit v1.2.3 From a2a5d1f2446214af5457693e3a06cfc7aa132942 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 25 May 2013 08:38:34 +0200 Subject: Reverting fix for Bug #1022543. (bzr r12341) --- src/document.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 2fc6d3bc6..706710cfc 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -84,7 +84,6 @@ static gint sp_document_rerouting_handler(gpointer data); gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); static gint doc_count = 0; -static gint doc_mem_count = 0; static unsigned long next_serial = 0; @@ -481,18 +480,17 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b base = NULL; name = g_strdup(uri); } - if (make_new) { - name = g_strdup_printf(_("New document %d"), ++doc_count); - } g_free(s); } else { - if (make_new) { - name = g_strdup_printf(_("Memory document %d"), ++doc_mem_count); - } - rdoc = sp_repr_document_new("svg:svg"); } + if (make_new) { + base = NULL; + uri = NULL; + name = g_strdup_printf(_("New document %d"), ++doc_count); + } + //# These should be set by now g_assert(name); @@ -516,7 +514,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // If xml file is not svg, return NULL without warning // TODO fixme: destroy document } else { - Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); + Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count ); doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); } } -- cgit v1.2.3 From bd77ef25e9161acb007323f851ba77e106036939 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 1 Jul 2013 23:40:52 -0400 Subject: Ported "ui/widget/page-sizer.cpp" and "document.cpp" to "Util::Unit" class. (bzr r12380.1.4) --- src/document.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 706710cfc..cc1c519fc 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -49,7 +49,6 @@ #include "display/drawing-item.h" #include "document-private.h" #include "document-undo.h" -#include "helper/units.h" #include "id-clash.h" #include "inkscape-private.h" #include "inkscape-version.h" @@ -87,6 +86,8 @@ static gint doc_count = 0; static unsigned long next_serial = 0; +static Inkscape::Util::UnitTable unit_table; + SPDocument::SPDocument() : keepalive(FALSE), virgin(TRUE), @@ -546,21 +547,22 @@ gdouble SPDocument::getWidth() const return result; } -void SPDocument::setWidth(gdouble width, const SPUnit *unit) +void SPDocument::setWidth(gdouble width, const Inkscape::Util::Unit *unit) { + Inkscape::Util::Unit px = unit_table.getUnit("px"); if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.left() + sp_units_get_pixels (width, *unit), root->viewBox.bottom())); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + Inkscape::Util::Quantity::convert(width, unit, &px), root->viewBox.bottom())); } else { // set to width= gdouble old_computed = root->width.computed; - root->width.computed = sp_units_get_pixels (width, *unit); + root->width.computed = Inkscape::Util::Quantity::convert(width, unit, &px); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ - if (!strcmp(unit->abbr, "m")) { + if (*unit == unit_table.getUnit("m")) { root->width.value = 100*width; root->width.unit = SVGLength::CM; } else { root->width.value = width; - root->width.unit = (SVGLength::Unit) sp_unit_get_svg_unit(unit); + root->width.unit = (SVGLength::Unit) unit->svgUnit(); } if (root->viewBox_set) @@ -582,21 +584,22 @@ gdouble SPDocument::getHeight() const return result; } -void SPDocument::setHeight(gdouble height, const SPUnit *unit) +void SPDocument::setHeight(gdouble height, const Inkscape::Util::Unit *unit) { + Inkscape::Util::Unit px = unit_table.getUnit("px"); if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + sp_units_get_pixels (height, *unit))); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + Inkscape::Util::Quantity::convert(height, unit, &px))); } else { // set to height= gdouble old_computed = root->height.computed; - root->height.computed = sp_units_get_pixels (height, *unit); + root->height.computed = Inkscape::Util::Quantity::convert(height, unit, &px); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ - if (!strcmp(unit->abbr, "m")) { + if (*unit == unit_table.getUnit("m")) { root->height.value = 100*height; root->height.unit = SVGLength::CM; } else { root->height.value = height; - root->height.unit = (SVGLength::Unit) sp_unit_get_svg_unit(unit); + root->height.unit = (SVGLength::Unit) unit->svgUnit(); } if (root->viewBox_set) @@ -626,7 +629,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double const h = rect.height(); double const old_height = getHeight(); - SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX)); + Inkscape::Util::Unit const px = unit_table.getUnit("px"); /* in px */ double margin_top = 0.0; @@ -639,9 +642,10 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) if (with_margins && nv) { if (nv != NULL) { gchar const * const units_abbr = nv->getAttribute("units"); - SPUnit const *margin_units = NULL; + Inkscape::Util::Unit const *margin_units = NULL; if (units_abbr != NULL) { - margin_units = sp_unit_get_by_abbreviation(units_abbr); + Inkscape::Util::Unit mu = unit_table.getUnit(units_abbr); + margin_units = μ } if (margin_units == NULL) { margin_units = &px; -- cgit v1.2.3 From d04405f745da587b2a3ccca8d2ca7bf49edf2d4d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sat, 6 Jul 2013 11:01:59 -0400 Subject: Switch setWidth and setHeight to use Quantity and switch to forward declaration of Inkscape::Util::Quantity in document.h. (bzr r12380.1.7) --- src/document.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index cc1c519fc..ed3d8e21b 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -547,22 +547,23 @@ gdouble SPDocument::getWidth() const return result; } -void SPDocument::setWidth(gdouble width, const Inkscape::Util::Unit *unit) +void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { Inkscape::Util::Unit px = unit_table.getUnit("px"); if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.left() + Inkscape::Util::Quantity::convert(width, unit, &px), root->viewBox.bottom())); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + width.value(&px), root->viewBox.bottom())); } else { // set to width= gdouble old_computed = root->width.computed; - root->width.computed = Inkscape::Util::Quantity::convert(width, unit, &px); + root->width.computed = width.value(&px); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ - if (*unit == unit_table.getUnit("m")) { - root->width.value = 100*width; + if (*width.unit == unit_table.getUnit("m")) { + Inkscape::Util::Unit cm = unit_table.getUnit("cm"); + root->width.value = width.value(&cm); root->width.unit = SVGLength::CM; } else { - root->width.value = width; - root->width.unit = (SVGLength::Unit) unit->svgUnit(); + root->width.value = width.quantity; + root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); } if (root->viewBox_set) @@ -584,22 +585,23 @@ gdouble SPDocument::getHeight() const return result; } -void SPDocument::setHeight(gdouble height, const Inkscape::Util::Unit *unit) +void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { Inkscape::Util::Unit px = unit_table.getUnit("px"); if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + Inkscape::Util::Quantity::convert(height, unit, &px))); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + height.value(&px))); } else { // set to height= gdouble old_computed = root->height.computed; - root->height.computed = Inkscape::Util::Quantity::convert(height, unit, &px); + root->height.computed = height.value(&px); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ - if (*unit == unit_table.getUnit("m")) { - root->height.value = 100*height; + if (*height.unit == unit_table.getUnit("m")) { + Inkscape::Util::Unit cm = unit_table.getUnit("cm"); + root->height.value = height.value(&cm); root->height.unit = SVGLength::CM; } else { - root->height.value = height; - root->height.unit = (SVGLength::Unit) unit->svgUnit(); + root->height.value = height.quantity; + root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); } if (root->viewBox_set) @@ -662,8 +664,8 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) rect.max() + Geom::Point(margin_right, margin_top)); - setWidth(rect_with_margins.width(), &px); - setHeight(rect_with_margins.height(), &px); + setWidth(Inkscape::Util::Quantity(rect_with_margins.width(), &px)); + setHeight(Inkscape::Util::Quantity(rect_with_margins.height(), &px)); Geom::Translate const tr( Geom::Point(0, old_height - rect_with_margins.height()) -- cgit v1.2.3 From 4d232a223d1dcb7b2381615de1a64b20b2fb6165 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 9 Jul 2013 20:46:51 -0400 Subject: Small refactor of align and distribute to reduce complexity. (bzr r12411) --- src/document.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 706710cfc..0e9c43fe4 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -611,6 +611,11 @@ Geom::Point SPDocument::getDimensions() const return Geom::Point(getWidth(), getHeight()); } +Geom::OptRect SPDocument::preferredBounds() const +{ + return Geom::OptRect( Geom::Point(0, 0), getDimensions() ); +} + /** * Given a Geom::Rect that may, for example, correspond to the bbox of an object, * this function fits the canvas to that rect by resizing the canvas -- cgit v1.2.3 From 3772fc428950b2b946a1bd7c7c97e06219c3165f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Thu, 18 Jul 2013 17:21:24 -0400 Subject: Switch unit functions from using pointer arguements to reference arguements. (bzr r12380.1.28) --- src/document.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 78d7018bb..a024cc790 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -549,17 +549,15 @@ gdouble SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { - Inkscape::Util::Unit px = unit_table.getUnit("px"); if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.left() + width.value(&px), root->viewBox.bottom())); + root->viewBox.setMax(Geom::Point(root->viewBox.left() + width.value("px"), root->viewBox.bottom())); } else { // set to width= gdouble old_computed = root->width.computed; - root->width.computed = width.value(&px); + root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ if (*width.unit == unit_table.getUnit("m")) { - Inkscape::Util::Unit cm = unit_table.getUnit("cm"); - root->width.value = width.value(&cm); + root->width.value = width.value("cm"); root->width.unit = SVGLength::CM; } else { root->width.value = width.quantity; @@ -587,17 +585,15 @@ gdouble SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { - Inkscape::Util::Unit px = unit_table.getUnit("px"); if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + height.value(&px))); + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + height.value("px"))); } else { // set to height= gdouble old_computed = root->height.computed; - root->height.computed = height.value(&px); + root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ if (*height.unit == unit_table.getUnit("m")) { - Inkscape::Util::Unit cm = unit_table.getUnit("cm"); - root->height.value = height.value(&cm); + root->height.value = height.value("cm"); root->height.unit = SVGLength::CM; } else { root->height.value = height.quantity; @@ -669,8 +665,8 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) rect.max() + Geom::Point(margin_right, margin_top)); - setWidth(Inkscape::Util::Quantity(rect_with_margins.width(), &px)); - setHeight(Inkscape::Util::Quantity(rect_with_margins.height(), &px)); + setWidth(Inkscape::Util::Quantity(rect_with_margins.width(), "px")); + setHeight(Inkscape::Util::Quantity(rect_with_margins.height(), "px")); Geom::Translate const tr( Geom::Point(0, old_height - rect_with_margins.height()) -- cgit v1.2.3 From f1cdb3b3f47c7187d9325e8ddd8e630268dc8e8b Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 31 Jul 2013 18:33:03 -0400 Subject: Eliminate "unit-constants.h". (bzr r12380.1.54) --- src/document.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index a024cc790..afd0a6ddc 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -62,7 +62,7 @@ #include "sp-object-repr.h" #include "sp-symbol.h" #include "transf_mat_3x4.h" -#include "unit-constants.h" +#include "util/units.h" #include "xml/repr.h" #include "xml/rebase-hrefs.h" #include "libcroco/cr-cascade.h" @@ -966,7 +966,7 @@ void SPDocument::setupViewport(SPItemCtx *ctx) if (root->viewBox_set) { // if set, take from viewBox ctx->viewport = root->viewBox; } else { // as a last resort, set size to A4 - ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * PX_PER_MM, 297 * PX_PER_MM); + ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * Inkscape::Util::Quantity::convert(1, "mm", "px"), 297 * Inkscape::Util::Quantity::convert(1, "mm", "px")); } ctx->i2vp = Geom::identity(); } -- cgit v1.2.3 From 6ae6c0bea96eef09907091279e0678aa5f83102d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 4 Aug 2013 18:01:18 -0400 Subject: Switched to global UnitTable. (bzr r12380.1.62) --- src/document.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index afd0a6ddc..0b742e491 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -68,6 +68,7 @@ #include "libcroco/cr-cascade.h" using Inkscape::DocumentUndo; +using Inkscape::Util::unit_table; // Higher number means lower priority. #define SP_DOCUMENT_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE - 2) @@ -86,8 +87,6 @@ static gint doc_count = 0; static unsigned long next_serial = 0; -static Inkscape::Util::UnitTable unit_table; - SPDocument::SPDocument() : keepalive(FALSE), virgin(TRUE), -- cgit v1.2.3 From f10048be170a45921ae8fc65ccd2588a9ad2897d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 12:32:55 -0400 Subject: Added viewBox implement document unit support. (bzr r12475.1.2) --- src/document.cpp | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 0b742e491..20c6fe331 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -534,16 +534,20 @@ SPDocument *SPDocument::doUnref() return NULL; } -gdouble SPDocument::getWidth() const +Inkscape::Util::Quantity SPDocument::getWidth() const { - g_return_val_if_fail(this->priv != NULL, 0.0); - g_return_val_if_fail(this->root != NULL, 0.0); + g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); + g_return_val_if_fail(this->root != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); - gdouble result = root->width.computed; + gdouble result = root->width.value; + SVGLength::Unit u = root->width.unit; if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { result = root->viewBox.width(); } - return result; + if (u == SVGLength::NONE) { + u = SVGLength::PX; + } + return Inkscape::Util::Quantity(result, unit_table.getUnit(u)); } void SPDocument::setWidth(const Inkscape::Util::Quantity &width) @@ -570,16 +574,20 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->updateRepr(); } -gdouble SPDocument::getHeight() const +Inkscape::Util::Quantity SPDocument::getHeight() const { - g_return_val_if_fail(this->priv != NULL, 0.0); - g_return_val_if_fail(this->root != NULL, 0.0); + g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); + g_return_val_if_fail(this->root != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); - gdouble result = root->height.computed; + gdouble result = root->height.value; + SVGLength::Unit u = root->height.unit; if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { result = root->viewBox.height(); } - return result; + if (u == SVGLength::NONE) { + u = SVGLength::PX; + } + return Inkscape::Util::Quantity(result, unit_table.getUnit(u)); } void SPDocument::setHeight(const Inkscape::Util::Quantity &height) @@ -606,9 +614,16 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->updateRepr(); } +void SPDocument::setViewBox(const Geom::Rect &viewBox) +{ + root->viewBox_set = true; + root->viewBox = viewBox; + root->updateRepr(); +} + Geom::Point SPDocument::getDimensions() const { - return Geom::Point(getWidth(), getHeight()); + return Geom::Point(getWidth().value("px"), getHeight().value("px")); } Geom::OptRect SPDocument::preferredBounds() const @@ -630,7 +645,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double const w = rect.width(); double const h = rect.height(); - double const old_height = getHeight(); + double const old_height = getHeight().value("px"); Inkscape::Util::Unit const px = unit_table.getUnit("px"); /* in px */ -- cgit v1.2.3 From 3bfb610bb7719d49821fe5381ae449789c3cb968 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 27 Aug 2013 23:32:14 -0400 Subject: Improve code readability. (bzr r12475.1.9) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 20c6fe331..a544c60c9 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -980,7 +980,7 @@ void SPDocument::setupViewport(SPItemCtx *ctx) if (root->viewBox_set) { // if set, take from viewBox ctx->viewport = root->viewBox; } else { // as a last resort, set size to A4 - ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * Inkscape::Util::Quantity::convert(1, "mm", "px"), 297 * Inkscape::Util::Quantity::convert(1, "mm", "px")); + ctx->viewport = Geom::Rect::from_xywh(0, 0, Inkscape::Util::Quantity::convert(210, "mm", "px"), Inkscape::Util::Quantity::convert(297, "mm", "px")); } ctx->i2vp = Geom::identity(); } -- cgit v1.2.3 From abde5067bcfbb4c0e3ba61c6f69db7925f80600a Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Mon, 16 Sep 2013 19:32:58 +0200 Subject: Removed TypeInfo; adjusted Factory to meet code style conventions. (bzr r11608.1.124) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 65c4cb10a..ec831745c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -349,7 +349,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->name = g_strdup(name); // Create SPRoot element - const std::string typeString = NodeTraits::getTypeString(*rroot); + const std::string typeString = NodeTraits::get_type_string(*rroot); SPObject* rootObj = SPFactory::instance().createObject(typeString); document->root = dynamic_cast(rootObj); -- cgit v1.2.3 From 4e8b8beaf879c90d59ef84548b2299151dbfb697 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 20 Sep 2013 18:13:00 -0400 Subject: Use viewBox for new documents. Fixed bugs: - https://launchpad.net/bugs/171203 - https://launchpad.net/bugs/168261 (bzr r12557) --- src/document.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 967d049c2..5e59a0a0c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -450,6 +450,11 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->setCurrentPersp3DImpl(persp_impl); } + // Set viewBox if it doesn't exist + if (!document->root->viewBox_set) { + document->setViewBox(Geom::Rect::from_xywh(0, 0, document->getWidth().quantity, document->getHeight().quantity)); + } + DocumentUndo::setUndoSensitive(document, true); // reset undo key when selection changes, so that same-key actions on different objects are not coalesced -- cgit v1.2.3 From 2df0abfd438d90edb6056f0197ed9d27ce2cd1f1 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 22 Sep 2013 13:47:37 -0400 Subject: Fix adding viewBox to new documents. Fixed bugs: - https://launchpad.net/bugs/1228660 - https://launchpad.net/bugs/1228693 - https://launchpad.net/bugs/1228852 (bzr r12575) --- src/document.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 5e59a0a0c..967d049c2 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -450,11 +450,6 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->setCurrentPersp3DImpl(persp_impl); } - // Set viewBox if it doesn't exist - if (!document->root->viewBox_set) { - document->setViewBox(Geom::Rect::from_xywh(0, 0, document->getWidth().quantity, document->getHeight().quantity)); - } - DocumentUndo::setUndoSensitive(document, true); // reset undo key when selection changes, so that same-key actions on different objects are not coalesced -- cgit v1.2.3 From 37b7de3efa31c7aa3094aed7c849a08e7f7bedfd Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 22 Sep 2013 20:26:44 -0400 Subject: Fix percentage document size handling. Fixed bugs: - https://launchpad.net/bugs/1228852 (bzr r12577) --- src/document.cpp | 62 +++++++++++++++++++++++++------------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 967d049c2..800f2f33d 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -557,6 +557,7 @@ Inkscape::Util::Quantity SPDocument::getWidth() const SVGLength::Unit u = root->width.unit; if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { result = root->viewBox.width(); + u = SVGLength::PX; } if (u == SVGLength::NONE) { u = SVGLength::PX; @@ -566,25 +567,21 @@ Inkscape::Util::Quantity SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { - if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.left() + width.value("px"), root->viewBox.bottom())); - } else { // set to width= - gdouble old_computed = root->width.computed; - root->width.computed = width.value("px"); - /* SVG does not support meters as a unit, so we must translate meters to - * cm when writing */ - if (*width.unit == unit_table.getUnit("m")) { - root->width.value = width.value("cm"); - root->width.unit = SVGLength::CM; - } else { - root->width.value = width.quantity; - root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); - } - - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + gdouble old_computed = root->width.computed; + root->width.computed = width.value("px"); + /* SVG does not support meters as a unit, so we must translate meters to + * cm when writing */ + if (*width.unit == unit_table.getUnit("m")) { + root->width.value = width.value("cm"); + root->width.unit = SVGLength::CM; + } else { + root->width.value = width.quantity; + root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); } + if (root->viewBox_set) + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + root->updateRepr(); } @@ -597,6 +594,7 @@ Inkscape::Util::Quantity SPDocument::getHeight() const SVGLength::Unit u = root->height.unit; if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { result = root->viewBox.height(); + u = SVGLength::PX; } if (u == SVGLength::NONE) { u = SVGLength::PX; @@ -606,25 +604,21 @@ Inkscape::Util::Quantity SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { - if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + height.value("px"))); - } else { // set to height= - gdouble old_computed = root->height.computed; - root->height.computed = height.value("px"); - /* SVG does not support meters as a unit, so we must translate meters to - * cm when writing */ - if (*height.unit == unit_table.getUnit("m")) { - root->height.value = height.value("cm"); - root->height.unit = SVGLength::CM; - } else { - root->height.value = height.quantity; - root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); - } - - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + gdouble old_computed = root->height.computed; + root->height.computed = height.value("px"); + /* SVG does not support meters as a unit, so we must translate meters to + * cm when writing */ + if (*height.unit == unit_table.getUnit("m")) { + root->height.value = height.value("cm"); + root->height.unit = SVGLength::CM; + } else { + root->height.value = height.quantity; + root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); } + if (root->viewBox_set) + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + root->updateRepr(); } -- cgit v1.2.3 From ae4fb171df25c328e398d0cf1909a4cbad33a897 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 13:58:09 -0300 Subject: dying document needs to delete its perspective (bzr r12611) --- src/document.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 800f2f33d..dda072283 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -219,6 +219,11 @@ SPDocument::~SPDocument() { inkscape_unref(); keepalive = FALSE; } + + if (this->current_persp3d_impl) + delete this->current_persp3d_impl; + this->current_persp3d_impl = NULL; + //delete this->_whiteboard_session_manager; } -- cgit v1.2.3 From ee8f0667f84689466f68eecfb9498e7b092e168b Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Sat, 28 Sep 2013 23:09:39 -0300 Subject: collectOrphans moved to the end of destructor to prevent leaking of uncollected stuff (bzr r12625) --- src/document.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index dda072283..b94b72bda 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -139,8 +139,6 @@ SPDocument::SPDocument() : } SPDocument::~SPDocument() { - collectOrphans(); - // kill/unhook this first if ( profileManager ) { delete profileManager; @@ -224,6 +222,9 @@ SPDocument::~SPDocument() { delete this->current_persp3d_impl; this->current_persp3d_impl = NULL; + // This is at the end of the destructor, because preceding code adds new orphans to the queue + collectOrphans(); + //delete this->_whiteboard_session_manager; } -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/document.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index b94b72bda..4f57cf080 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -556,8 +556,8 @@ SPDocument *SPDocument::doUnref() Inkscape::Util::Quantity SPDocument::getWidth() const { - g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); - g_return_val_if_fail(this->root != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); + g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); + g_return_val_if_fail(this->root != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); gdouble result = root->width.value; SVGLength::Unit u = root->width.unit; @@ -577,7 +577,7 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ - if (*width.unit == unit_table.getUnit("m")) { + if (*width.unit == *unit_table.getUnit("m")) { root->width.value = width.value("cm"); root->width.unit = SVGLength::CM; } else { @@ -593,8 +593,8 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) Inkscape::Util::Quantity SPDocument::getHeight() const { - g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); - g_return_val_if_fail(this->root != NULL, Inkscape::Util::Quantity(0.0, Inkscape::Util::Unit())); + g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); + g_return_val_if_fail(this->root != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); gdouble result = root->height.value; SVGLength::Unit u = root->height.unit; @@ -614,7 +614,7 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ - if (*height.unit == unit_table.getUnit("m")) { + if (*height.unit == *unit_table.getUnit("m")) { root->height.value = height.value("cm"); root->height.unit = SVGLength::CM; } else { @@ -660,7 +660,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double const h = rect.height(); double const old_height = getHeight().value("px"); - Inkscape::Util::Unit const px = unit_table.getUnit("px"); + Inkscape::Util::Unit const *px = unit_table.getUnit("px"); /* in px */ double margin_top = 0.0; @@ -674,17 +674,16 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) if (nv != NULL) { gchar const * const units_abbr = nv->getAttribute("units"); Inkscape::Util::Unit const *margin_units = NULL; - if (units_abbr != NULL) { - Inkscape::Util::Unit mu = unit_table.getUnit(units_abbr); - margin_units = μ + if (units_abbr) { + margin_units = unit_table.getUnit(units_abbr); } - if (margin_units == NULL) { - margin_units = &px; + if (!margin_units) { + margin_units = px; } - margin_top = nv->getMarginLength("fit-margin-top",margin_units, &px, w, h, false); - margin_left = nv->getMarginLength("fit-margin-left",margin_units, &px, w, h, true); - margin_right = nv->getMarginLength("fit-margin-right",margin_units, &px, w, h, true); - margin_bottom = nv->getMarginLength("fit-margin-bottom",margin_units, &px, w, h, false); + margin_top = nv->getMarginLength("fit-margin-top",margin_units, px, w, h, false); + margin_left = nv->getMarginLength("fit-margin-left",margin_units, px, w, h, true); + margin_right = nv->getMarginLength("fit-margin-right",margin_units, px, w, h, true); + margin_bottom = nv->getMarginLength("fit-margin-bottom",margin_units, px, w, h, false); } } @@ -693,8 +692,8 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) rect.max() + Geom::Point(margin_right, margin_top)); - setWidth(Inkscape::Util::Quantity(rect_with_margins.width(), "px")); - setHeight(Inkscape::Util::Quantity(rect_with_margins.height(), "px")); + setWidth(Inkscape::Util::Quantity(rect_with_margins.width(), px)); + setHeight(Inkscape::Util::Quantity(rect_with_margins.height(), px)); Geom::Translate const tr( Geom::Point(0, old_height - rect_with_margins.height()) -- cgit v1.2.3 From 85288191bbf9afd5d91b2bd0b0ea5d0e5c270ce0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 22 Oct 2013 10:34:00 +0200 Subject: Fix for Bug #1022543 (Ctrl+C increments the documents count). Fixed bugs: - https://launchpad.net/bugs/1022543 (bzr r12712) --- src/document.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 4f57cf080..41defcc01 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -84,6 +84,7 @@ static gint sp_document_rerouting_handler(gpointer data); gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); static gint doc_count = 0; +static gint doc_mem_count = 0; static unsigned long next_serial = 0; @@ -500,15 +501,18 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b base = NULL; name = g_strdup(uri); } + if (make_new) { + base = NULL; + uri = NULL; + name = g_strdup_printf(_("New document %d"), ++doc_count); + } g_free(s); } else { - rdoc = sp_repr_document_new("svg:svg"); - } + if (make_new) { + name = g_strdup_printf(_("Memory document %d"), ++doc_mem_count); + } - if (make_new) { - base = NULL; - uri = NULL; - name = g_strdup_printf(_("New document %d"), ++doc_count); + rdoc = sp_repr_document_new("svg:svg"); } //# These should be set by now @@ -534,7 +538,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // If xml file is not svg, return NULL without warning // TODO fixme: destroy document } else { - Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_count ); + Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); } } -- cgit v1.2.3 From fadaf147c5add875593a8fbf4933e890c0d4ed83 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 16:21:44 +0200 Subject: fix crash bug 1237676 Fixed bugs: - https://launchpad.net/bugs/1237676 (bzr r12716) --- src/document.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 41defcc01..4a3d40308 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1475,9 +1475,10 @@ void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; if (SP_ACTIVE_DESKTOP) { Gtk::Window *parent = SP_ACTIVE_DESKTOP->getToplevel(); - g_assert(parent != NULL); - SPDesktopWidget *dtw = static_cast(parent->get_data("desktopwidget")); - dtw->updateTitle( this->getName() ); + if (parent) { // during load, SP_ACTIVE_DESKTOP may be !nullptr, but parent might still be nullptr + SPDesktopWidget *dtw = static_cast(parent->get_data("desktopwidget")); + dtw->updateTitle( this->getName() ); + } } } -- cgit v1.2.3 From 651b367a2e01f918435d829394baff45537f6b91 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 17:03:01 +0200 Subject: fix bug "some of the locale-based templates cause objects to be resized when default units are changed" #1236257 Fixed bugs: - https://launchpad.net/bugs/1236257 (bzr r12717) --- src/document.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 4a3d40308..782eb22f3 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -558,6 +558,13 @@ SPDocument *SPDocument::doUnref() return NULL; } +/// guaranteed not to return nullptr +Inkscape::Util::Unit const* SPDocument::getDefaultUnit() +{ + SPNamedView const* nv = sp_document_namedview(this, NULL); + return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt"); +} + Inkscape::Util::Quantity SPDocument::getWidth() const { g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); -- cgit v1.2.3 From 88ff8a79ec45f9591e764fce4244315b105f3cb6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 17:14:16 +0200 Subject: fix bad style (bzr r12718) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 782eb22f3..e1df38da1 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -679,7 +679,7 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins) double margin_right = 0.0; double margin_bottom = 0.0; - SPNamedView *nv = sp_document_namedview(this, 0); + SPNamedView *nv = sp_document_namedview(this, NULL); if (with_margins && nv) { if (nv != NULL) { -- cgit v1.2.3 From 9c27ef4d920ac6b05cd052cf48fa1d0b85b194b9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 24 Oct 2013 18:04:08 +0200 Subject: try to add some const-correctness (bzr r12719) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e1df38da1..3433e42ec 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -559,7 +559,7 @@ SPDocument *SPDocument::doUnref() } /// guaranteed not to return nullptr -Inkscape::Util::Unit const* SPDocument::getDefaultUnit() +Inkscape::Util::Unit const* SPDocument::getDefaultUnit() const { SPNamedView const* nv = sp_document_namedview(this, NULL); return nv ? nv->getDefaultUnit() : unit_table.getUnit("pt"); -- cgit v1.2.3 From 67e24fa688c6b9da489a22a6bd281bf1956f38eb Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 13 Nov 2013 19:03:07 +0100 Subject: Add command line support for EMF and WMF export, by David Mathog. Fixed bugs: - https://launchpad.net/bugs/1244749 (bzr r12809) --- src/document.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 3433e42ec..e6166ee82 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -968,7 +968,10 @@ Glib::ustring SPDocument::getLanguage() const if ( NULL == document_language || *document_language == 0 ) { document_language = getenv ("LANG"); } - + if ( NULL == document_language || *document_language == 0 ) { + document_language = getenv ("LANGUAGE"); + } + if ( NULL != document_language ) { const char *pos = strchr(document_language, '_'); if ( NULL != pos ) { -- cgit v1.2.3 From 8c982dba53fde33ed4ac47645049938259894a8e Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Sat, 11 Jan 2014 12:46:14 +0100 Subject: pass class variables by reference for performance (bzr r12916) --- src/document.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e6166ee82..e56adee68 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1173,7 +1173,7 @@ static bool item_is_in_group(SPItem *item, SPGroup *group) return inGroup; } -SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const p, bool take_insensitive) +SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive) { g_return_val_if_fail(group, NULL); SPItem *bottomMost = 0; @@ -1209,7 +1209,7 @@ items. If upto != NULL, then if item upto is encountered (at any level), stops s upwards in z-order and returns what it has found so far (i.e. the found item is guaranteed to be lower than upto). */ -static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) +static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const &p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) { SPItem *seen = NULL; SPItem *newseen = NULL; @@ -1254,7 +1254,7 @@ static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point Returns the topmost non-layer group from the descendants of group which is at point p, or NULL if none. Recurses into layers but not into groups. */ -static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) +static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const &p) { SPItem *seen = NULL; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1334,7 +1334,7 @@ GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vectorpriv != NULL, NULL); @@ -1342,7 +1342,7 @@ SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const p, return find_item_at_point(key, SP_GROUP(this->root), p, into_groups, false, upto); } -SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const p) const +SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const &p) const { g_return_val_if_fail(this->priv != NULL, NULL); -- cgit v1.2.3 From 77c9748e54f9170aac7c8b292377951f73da487f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 20 Jan 2014 20:11:09 -0500 Subject: Fix imprecise viewBox dimensions on page size change (bug #1235279). Fixed bugs: - https://launchpad.net/bugs/1235279 (bzr r12965) --- src/document.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e56adee68..8b956d5e7 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -585,6 +585,7 @@ Inkscape::Util::Quantity SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { gdouble old_computed = root->width.computed; + gdouble old_value = root->width.value; root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -596,8 +597,14 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); } - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + if (root->viewBox_set) { + if (abs(old_value - root->viewBox.width()) < 0.00001) { + root->viewBox.setMax(Geom::Point(root->viewBox.left() + root->width.value, root->viewBox.bottom())); + } + else { + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + } + } root->updateRepr(); } @@ -622,6 +629,7 @@ Inkscape::Util::Quantity SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { gdouble old_computed = root->height.computed; + gdouble old_value = root->height.value; root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -633,8 +641,14 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); } - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + if (root->viewBox_set) { + if (abs(old_value - root->viewBox.height()) < 0.00001) { + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + root->height.value)); + } + else { + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + } + } root->updateRepr(); } -- cgit v1.2.3 From d94a93e813b9e4a30f82925670b30de93fc63d38 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 20 Jan 2014 20:36:09 -0500 Subject: Revert last commit (breaks changing document units). (bzr r12966) --- src/document.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 8b956d5e7..e56adee68 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -585,7 +585,6 @@ Inkscape::Util::Quantity SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { gdouble old_computed = root->width.computed; - gdouble old_value = root->width.value; root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -597,14 +596,8 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); } - if (root->viewBox_set) { - if (abs(old_value - root->viewBox.width()) < 0.00001) { - root->viewBox.setMax(Geom::Point(root->viewBox.left() + root->width.value, root->viewBox.bottom())); - } - else { - root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); - } - } + if (root->viewBox_set) + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); root->updateRepr(); } @@ -629,7 +622,6 @@ Inkscape::Util::Quantity SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { gdouble old_computed = root->height.computed; - gdouble old_value = root->height.value; root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -641,14 +633,8 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); } - if (root->viewBox_set) { - if (abs(old_value - root->viewBox.height()) < 0.00001) { - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + root->height.value)); - } - else { - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); - } - } + if (root->viewBox_set) + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); root->updateRepr(); } -- cgit v1.2.3 From e01eb5907b04fdc194551741be6c6dbf5ee6f7e5 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 21 Jan 2014 22:20:23 -0500 Subject: Improve use tag logic by recording the loaded documents in a list. (bzr r12969) --- src/document.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e56adee68..32a025e87 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -106,6 +106,7 @@ SPDocument::SPDocument() : profileManager(0), // deferred until after other initialization router(new Avoid::Router(Avoid::PolyLineRouting|Avoid::OrthogonalRouting)), _collection_queue(0), + parent_document(NULL), oldSignalsConnected(false), current_persp3d(NULL), current_persp3d_impl(NULL) -- cgit v1.2.3 From 9a0c54cb8bc9b0bfc0c6af95f4b156fd717179a8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 14:58:15 -0500 Subject: Protect against infinate looping of new included hrefs (bzr r12970) --- src/document.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 32a025e87..90f35307d 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -315,7 +315,8 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, - unsigned int keepalive) + unsigned int keepalive, + SPDocument *parent) { SPDocument *document = new SPDocument(); @@ -326,6 +327,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->rdoc = rdoc; document->rroot = rroot; + document->parent_document = parent; if (document->uri){ g_free(document->uri); @@ -474,7 +476,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, * Fetches document from URI, or creates new, if NULL; public document * appears in document list. */ -SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new) +SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new, SPDocument *parent) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -519,7 +521,7 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b //# These should be set by now g_assert(name); - doc = createDoc(rdoc, uri, base, name, keepalive); + doc = createDoc(rdoc, uri, base, name, keepalive, parent); g_free(base); g_free(name); @@ -540,7 +542,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // TODO fixme: destroy document } else { Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); - doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); + doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive, NULL); } } -- cgit v1.2.3 From 423ea7c0373e77a83c8a9ef62df9a786b4feb7ac Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 17:58:40 -0500 Subject: Move sub-document reference creation code from uri-reference to document.cpp as createChildDoc(path) (bzr r12971) --- src/document.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 90f35307d..f5c799575 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -106,10 +106,10 @@ SPDocument::SPDocument() : profileManager(0), // deferred until after other initialization router(new Avoid::Router(Avoid::PolyLineRouting|Avoid::OrthogonalRouting)), _collection_queue(0), - parent_document(NULL), oldSignalsConnected(false), current_persp3d(NULL), - current_persp3d_impl(NULL) + current_persp3d_impl(NULL), + _parent_document(NULL) { // Penalise libavoid for choosing paths with needless extra segments. // This results in much better looking orthogonal connector paths. @@ -327,7 +327,10 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->rdoc = rdoc; document->rroot = rroot; - document->parent_document = parent; + if (parent) { + document->_parent_document = parent; + parent->_child_documents.push_back(document); + } if (document->uri){ g_free(document->uri); @@ -472,6 +475,43 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, return document; } +/** + * Fetches a document and attaches it to the current document as a child href + */ +SPDocument *SPDocument::createChildDoc(gchar const *uri) { + + // Calculate the absolute path from an available document + std::string basePath = std::string( this->getBase() ); + std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); + const char *path = absPath.c_str(); + + SPDocument *parent = this; + SPDocument *document = NULL; + + while(parent != NULL && document == NULL) { + // Check myself and any parents int he chain + if(strcmp(parent->getURI(), path)==0) { + document = parent; + break; + } + // Then check children of those. + boost::ptr_list::iterator iter; + for (iter = parent->_child_documents.begin(); + iter != parent->_child_documents.end(); ++iter) { + if(strcmp(iter->getURI(), path)==0) { + document = &*iter; + break; + } + } + parent = parent->_parent_document; + } + + // Load a fresh document from the svg source. + if(!document) { + document = createNewDoc(path, false, false, this); + } + return document; +} /** * Fetches document from URI, or creates new, if NULL; public document * appears in document list. @@ -605,6 +645,7 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->updateRepr(); } + Inkscape::Util::Quantity SPDocument::getHeight() const { g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); -- cgit v1.2.3 From f30005bef81c2e1c5e04fe583935269c5b209749 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 21:17:48 -0500 Subject: Don't throw away an existing full path. (bzr r12973) --- src/document.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index f5c799575..499601259 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -481,16 +481,19 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, SPDocument *SPDocument::createChildDoc(gchar const *uri) { // Calculate the absolute path from an available document - std::string basePath = std::string( this->getBase() ); - std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); - const char *path = absPath.c_str(); + if(strncmp(uri, "/", 1)!=0) { + std::string basePath = std::string( this->getBase() ); + std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); + // free uri first? + uri = absPath.c_str(); + } SPDocument *parent = this; SPDocument *document = NULL; while(parent != NULL && document == NULL) { // Check myself and any parents int he chain - if(strcmp(parent->getURI(), path)==0) { + if(strcmp(parent->getURI(), uri)==0) { document = parent; break; } @@ -498,7 +501,7 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { boost::ptr_list::iterator iter; for (iter = parent->_child_documents.begin(); iter != parent->_child_documents.end(); ++iter) { - if(strcmp(iter->getURI(), path)==0) { + if(strcmp(iter->getURI(), uri)==0) { document = &*iter; break; } @@ -508,7 +511,7 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { // Load a fresh document from the svg source. if(!document) { - document = createNewDoc(path, false, false, this); + document = createNewDoc(uri, false, false, this); } return document; } -- cgit v1.2.3 From d9fbd1a23235bc8725574f61e156e0992ecc83bf Mon Sep 17 00:00:00 2001 From: su_v Date: Thu, 23 Jan 2014 22:12:22 +0100 Subject: Fix GTK3 build failure (follow-up to r12971) Fixed bugs: - https://launchpad.net/bugs/1271802 (bzr r12975) --- src/document.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 499601259..b7f5cb097 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -67,6 +67,8 @@ #include "xml/rebase-hrefs.h" #include "libcroco/cr-cascade.h" +#include + using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; -- cgit v1.2.3 From ddb8af8009f151c7107daf0c2127f0ba2d882649 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 24 Jan 2014 20:05:26 -0500 Subject: Move absolute path generator to URI and use std::strings (bzr r12977) --- src/document.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index b7f5cb097..e456f2b81 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -67,8 +67,6 @@ #include "xml/rebase-hrefs.h" #include "libcroco/cr-cascade.h" -#include - using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; @@ -480,22 +478,14 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, /** * Fetches a document and attaches it to the current document as a child href */ -SPDocument *SPDocument::createChildDoc(gchar const *uri) { - - // Calculate the absolute path from an available document - if(strncmp(uri, "/", 1)!=0) { - std::string basePath = std::string( this->getBase() ); - std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); - // free uri first? - uri = absPath.c_str(); - } - +SPDocument *SPDocument::createChildDoc(std::string const uri) +{ SPDocument *parent = this; SPDocument *document = NULL; while(parent != NULL && document == NULL) { // Check myself and any parents int he chain - if(strcmp(parent->getURI(), uri)==0) { + if(uri.compare(parent->getURI())==0) { document = parent; break; } @@ -503,7 +493,7 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { boost::ptr_list::iterator iter; for (iter = parent->_child_documents.begin(); iter != parent->_child_documents.end(); ++iter) { - if(strcmp(iter->getURI(), uri)==0) { + if(uri.compare(iter->getURI())==0) { document = &*iter; break; } @@ -513,7 +503,8 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { // Load a fresh document from the svg source. if(!document) { - document = createNewDoc(uri, false, false, this); + const char *path = g_strdup(uri.c_str()); + document = createNewDoc(path, false, false, this); } return document; } -- cgit v1.2.3 From 7455f1a259ce28ee56866b5cde06e79be4cfaf97 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 26 Jan 2014 12:19:47 -0500 Subject: Check file existance and clean up memory issues thanks to KK and Johan (bzr r12979) --- src/document.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index e456f2b81..634462001 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -478,22 +478,22 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, /** * Fetches a document and attaches it to the current document as a child href */ -SPDocument *SPDocument::createChildDoc(std::string const uri) +SPDocument *SPDocument::createChildDoc(std::string const &uri) { SPDocument *parent = this; SPDocument *document = NULL; while(parent != NULL && document == NULL) { // Check myself and any parents int he chain - if(uri.compare(parent->getURI())==0) { + if(uri == parent->getURI()) { document = parent; break; } // Then check children of those. boost::ptr_list::iterator iter; for (iter = parent->_child_documents.begin(); - iter != parent->_child_documents.end(); ++iter) { - if(uri.compare(iter->getURI())==0) { + iter != parent->_child_documents.end(); ++iter) { + if(uri == iter->getURI()) { document = &*iter; break; } @@ -503,7 +503,7 @@ SPDocument *SPDocument::createChildDoc(std::string const uri) // Load a fresh document from the svg source. if(!document) { - const char *path = g_strdup(uri.c_str()); + const char *path = uri.c_str(); document = createNewDoc(path, false, false, this); } return document; -- cgit v1.2.3 From 7dd239eed97761b22ef635b6896a8f65c4939462 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 6 Feb 2014 15:29:15 +0100 Subject: Added new base class to handle viewBox and preserveAspectRatio. Updated sp-root, sp-symbol, sp-image, sp-pattern, marker to use new class. Fixed some viewport issues when % used. (bzr r13002) --- src/document.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 634462001..6f957cace 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -381,16 +381,6 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, rroot->setAttribute("inkscape:version", Inkscape::version_string); /* fixme: Again, I moved these here to allow version determining in ::build (Lauris) */ - /* Quick hack 2 - get default image size into document */ - if (!rroot->attribute("width")) rroot->setAttribute("width", "100%"); - if (!rroot->attribute("height")) rroot->setAttribute("height", "100%"); - /* End of quick hack 2 */ - - /* Quick hack 3 - Set uri attributes */ -// if (uri) { // this is done in do_change_uri() -// rroot->setAttribute("sodipodi:docname", uri); -// } - /* End of quick hack 3 */ /* Eliminate obsolete sodipodi:docbase, for privacy reasons */ rroot->setAttribute("sodipodi:docbase", NULL); -- cgit v1.2.3 From 9dc9db77232e264edcfec1e6ba6437130ac4c0eb Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 7 Feb 2014 13:27:42 +0100 Subject: Prevent attempt to initialize/compare std::string with/to null pointer. (bzr r13004) --- src/document.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 6f957cace..470d0cc5a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -473,7 +473,7 @@ SPDocument *SPDocument::createChildDoc(std::string const &uri) SPDocument *parent = this; SPDocument *document = NULL; - while(parent != NULL && document == NULL) { + while(parent != NULL && parent->getURI() != NULL && document == NULL) { // Check myself and any parents int he chain if(uri == parent->getURI()) { document = parent; -- cgit v1.2.3 From 8a6810210b3b1ce2cb82055063eee635174be637 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Thu, 20 Feb 2014 14:22:58 -0500 Subject: crash on cut n paste, or alt+scroll.. Fixed bugs: - https://launchpad.net/bugs/1171109 (bzr r13047) --- src/document.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 470d0cc5a..112503320 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1544,15 +1544,13 @@ void SPDocument::importDefs(SPDocument *source) // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *gr = SP_GRADIENT(src); - if (gr->isSolid() || gr->getVector()->isSolid()) { - for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { - if (trg && SP_IS_GRADIENT(trg) && src != trg) { - if (gr->isEquivalent(SP_GRADIENT(trg))) { - // Change object references to the existing equivalent gradient - change_def_references(src, trg); - duplicate = true; - break; - } + for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { + if (trg && SP_IS_GRADIENT(trg) && src != trg) { + if (gr->isEquivalent(SP_GRADIENT(trg))) { + // Change object references to the existing equivalent gradient + change_def_references(src, trg); + duplicate = true; + break; } } } -- cgit v1.2.3 From c8d15c18dcb8d089f8103d74015f6651d9b9b27c Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 2 Mar 2014 12:31:12 -0800 Subject: Adding destroy signal do document to allow proper cleanup. (bzr r13094) --- src/document.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 112503320..18e626b5b 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -141,6 +141,8 @@ SPDocument::SPDocument() : } SPDocument::~SPDocument() { + priv->destroySignal.emit(); + // kill/unhook this first if ( profileManager ) { delete profileManager; @@ -230,6 +232,11 @@ SPDocument::~SPDocument() { //delete this->_whiteboard_session_manager; } +sigc::connection SPDocument::connectDestroy(sigc::signal::slot_type slot) +{ + return priv->destroySignal.connect(slot); +} + SPDefs *SPDocument::getDefs() { if (!root) { -- cgit v1.2.3 From f1cc639a41e953136e1015a11ccca36483cff2e6 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 3 Mar 2014 22:34:34 +0100 Subject: code cleanup (bzr r13104) --- src/document.cpp | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 18e626b5b..d71fd97df 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -92,20 +92,20 @@ SPDocument::SPDocument() : keepalive(FALSE), virgin(TRUE), modified_since_save(FALSE), - rdoc(0), - rroot(0), - root(0), + rdoc(NULL), + rroot(NULL), + root(NULL), style_cascade(cr_cascade_new(NULL, NULL, NULL)), - uri(0), - base(0), - name(0), - priv(0), // reset in ctor + uri(NULL), + base(NULL), + name(NULL), + priv(NULL), // reset in ctor actionkey(), modified_id(0), rerouting_handler_id(0), - profileManager(0), // deferred until after other initialization + profileManager(NULL), // deferred until after other initialization router(new Avoid::Router(Avoid::PolyLineRouting|Avoid::OrthogonalRouting)), - _collection_queue(0), + _collection_queue(NULL), oldSignalsConnected(false), current_persp3d(NULL), current_persp3d_impl(NULL), @@ -124,7 +124,7 @@ SPDocument::SPDocument() : p->resources = g_hash_table_new(g_str_hash, g_str_equal); - p->sensitive = FALSE; + p->sensitive = false; p->partial = NULL; p->history_size = 0; p->undo = NULL; @@ -511,8 +511,7 @@ SPDocument *SPDocument::createChildDoc(std::string const &uri) */ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new, SPDocument *parent) { - SPDocument *doc; - Inkscape::XML::Document *rdoc; + Inkscape::XML::Document *rdoc = NULL; gchar *base = NULL; gchar *name = NULL; @@ -554,7 +553,7 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b //# These should be set by now g_assert(name); - doc = createDoc(rdoc, uri, base, name, keepalive, parent); + SPDocument *doc = createDoc(rdoc, uri, base, name, keepalive, parent); g_free(base); g_free(name); @@ -564,7 +563,7 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, unsigned int keepalive) { - SPDocument *doc = 0; + SPDocument *doc = NULL; Inkscape::XML::Document *rdoc = sp_repr_read_mem(buffer, length, SP_SVG_NS_URI); if ( rdoc ) { @@ -762,7 +761,7 @@ void SPDocument::setBase( gchar const* base ) { if (this->base) { g_free(this->base); - this->base = 0; + this->base = NULL; } if (base) { this->base = g_strdup(base); @@ -771,9 +770,9 @@ void SPDocument::setBase( gchar const* base ) void SPDocument::do_change_uri(gchar const *const filename, bool const rebase) { - gchar *new_base = 0; - gchar *new_name = 0; - gchar *new_uri = 0; + gchar *new_base = NULL; + gchar *new_name = NULL; + gchar *new_uri = NULL; if (filename) { #ifndef WIN32 -- cgit v1.2.3 From 76be008fcda64acffe569af78f77a07b0d4ea593 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Wed, 12 Mar 2014 14:34:51 -0400 Subject: incorrect gradient transform on copy&paste.. committing for mathog Fixed bugs: - https://launchpad.net/bugs/1283193 (bzr r13139) --- src/document.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index d71fd97df..4756110f6 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1552,7 +1552,8 @@ void SPDocument::importDefs(SPDocument *source) SPGradient *gr = SP_GRADIENT(src); for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { if (trg && SP_IS_GRADIENT(trg) && src != trg) { - if (gr->isEquivalent(SP_GRADIENT(trg))) { + if (gr->isEquivalent(SP_GRADIENT(trg)) && + gr->isAligned(SP_GRADIENT(trg))) { // Change object references to the existing equivalent gradient change_def_references(src, trg); duplicate = true; -- cgit v1.2.3 From 5ece992a297ec8fb400a32f4c8dbb34c592236a8 Mon Sep 17 00:00:00 2001 From: David Mathog Date: Thu, 13 Mar 2014 21:55:24 +0100 Subject: Fix gradient position on document import (bug #1283193) Fixed bugs: - https://launchpad.net/bugs/1283193 (bzr r13145) --- src/document.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 4756110f6..dc7ed254c 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1133,12 +1133,11 @@ static gint sp_document_idle_handler(gpointer data) { SPDocument *doc = static_cast(data); - if (doc->_updateDocument()) { + bool status = !doc->_updateDocument(); // method TRUE if it does NOT need further modification, so invert + if (!status) { doc->modified_id = 0; - return false; - } else { - return true; } + return status; } /** -- cgit v1.2.3