From 3e173aedbe72ba21d33eaec804bf4c9f8e9fa158 Mon Sep 17 00:00:00 2001 From: brock-alexander Date: Tue, 14 Jun 2016 12:26:58 +0200 Subject: Merging lp:~inkscape+alexander/inkscape/comments into lp:inkscape. (bzr r14986) --- src/document.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index d8c3f1269..902dabbc3 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1602,11 +1602,22 @@ static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) return count; } +/** + * Count the number of objects in a given document recursively using the count_objects_recursive helper function + * + * @param[in] document Pointer to the document for counting objects + * @return Numer of objects in the document + */ static unsigned int objects_in_document(SPDocument *document) { return count_objects_recursive(document->getRoot(), 0); } +/** + * Remove unused definitions etc. recursively from an object and its siblings + * + * @param[inout] obj Object which shall be "cleaned" + */ static void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { @@ -1621,6 +1632,11 @@ static void vacuum_document_recursive(SPObject *obj) } } +/** + * Remove unused definitions etc. recursively from an entire document. + * + * @return Number of removed objects + */ unsigned int SPDocument::vacuumDocument() { unsigned int start = objects_in_document(this); @@ -1639,6 +1655,7 @@ unsigned int SPDocument::vacuumDocument() newend = objects_in_document(this); } while (iterations < 100 && newend < end); + // We stop if vacuum_document_recursive doesn't remove any more objects or after 100 iterations, whichever occurs first. return start - newend; } @@ -1647,6 +1664,11 @@ bool SPDocument::isSeeking() const { return priv->seeking; } +/** + * Indicate to the user if the document has been modified since the last save by displaying a "*" in front of the name of the file in the window title. + * + * @param[in] modified True if the document has been modified. + */ void SPDocument::setModifiedSinceSave(bool modified) { this->modified_since_save = modified; if (SP_ACTIVE_DESKTOP) { -- cgit v1.2.3 From d1947e768272c703674129d5c583204ff2b59251 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 13 Jul 2016 13:36:19 +0200 Subject: Second part of new SPObject children list (bzr r14954.1.19) --- src/document.cpp | 96 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 47 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 902dabbc3..3dcec4795 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -257,9 +257,9 @@ void SPDocument::setCurrentPersp3D(Persp3D * const persp) { void SPDocument::getPerspectivesInDefs(std::vector &list) const { - for (SPObject *i = root->defs->firstChild(); i; i = i->getNext() ) { - if (SP_IS_PERSP3D(i)) { - list.push_back(SP_PERSP3D(i)); + for (auto& i: root->defs->_children) { + if (SP_IS_PERSP3D(&i)) { + list.push_back(SP_PERSP3D(&i)); } } } @@ -1256,12 +1256,12 @@ static std::vector &find_items_in_area(std::vector &s, SPGroup { g_return_val_if_fail(SP_IS_GROUP(group), s); - for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { - s = find_items_in_area(s, SP_GROUP(o), dkey, area, test, take_insensitive, into_groups); + for (auto& o: group->_children) { + if ( SP_IS_ITEM(&o) ) { + if (SP_IS_GROUP(&o) && (SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { + s = find_items_in_area(s, SP_GROUP(&o), dkey, area, test, take_insensitive, into_groups); } else { - SPItem *child = SP_ITEM(o); + SPItem *child = SP_ITEM(&o); Geom::OptRect box = child->desktopVisualBounds(); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { s.push_back(child); @@ -1278,17 +1278,16 @@ Returns true if an item is among the descendants of group (recursively). */ static bool item_is_in_group(SPItem *item, SPGroup *group) { - bool inGroup = false; - for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - if (SP_ITEM(o) == item) { - inGroup = true; - } else if ( SP_IS_GROUP(o) ) { - inGroup = item_is_in_group(item, SP_GROUP(o)); + for (auto& o: group->_children) { + if ( SP_IS_ITEM(&o) ) { + if (SP_ITEM(&o) == item) { + return true; + } else if (SP_IS_GROUP(&o) && item_is_in_group(item, SP_GROUP(&o))) { + return true; } } } - return inGroup; + return false; } SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector const &list,Geom::Point const &p, bool take_insensitive) @@ -1299,21 +1298,24 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for ( SPObject *o = group->firstChild() ; o && !bottomMost; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - SPItem *item = SP_ITEM(o); + for (auto& o: group->_children) { + if (bottomMost) { + break; + } + if (SP_IS_ITEM(&o)) { + SPItem *item = SP_ITEM(&o); Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); arenaitem->drawing().update(); if (arenaitem && arenaitem->pick(p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { - if (find(list.begin(),list.end(),item)!=list.end() ) { + if (find(list.begin(), list.end(), item) != list.end()) { bottomMost = item; } } - if ( !bottomMost && SP_IS_GROUP(o) ) { + if (!bottomMost && SP_IS_GROUP(&o)) { // return null if not found: - bottomMost = getItemFromListAtPointBottom(dkey, SP_GROUP(o), list, p, take_insensitive); + bottomMost = getItemFromListAtPointBottom(dkey, SP_GROUP(&o), list, p, take_insensitive); } } } @@ -1326,15 +1328,15 @@ The list can be persisted, which improves "find at multiple points" speed. */ void SPDocument::build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups) const { - for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if (!SP_IS_ITEM(o)) { + for (auto& o: group->_children) { + if (!SP_IS_ITEM(&o)) { continue; } - if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { - build_flat_item_list(dkey, SP_GROUP(o), into_groups); + if (SP_IS_GROUP(&o) && (SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { + build_flat_item_list(dkey, SP_GROUP(&o), into_groups); } else { - SPItem *child = SP_ITEM(o); + SPItem *child = SP_ITEM(&o); if (child->isVisibleAndUnlocked(dkey)) { _node_cache.push_front(child); @@ -1390,18 +1392,18 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if (!SP_IS_ITEM(o)) { + for (auto& o: group->_children) { + if (!SP_IS_ITEM(&o)) { continue; } - if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER) { - SPItem *newseen = find_group_at_point(dkey, SP_GROUP(o), p); + if (SP_IS_GROUP(&o) && SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER) { + SPItem *newseen = find_group_at_point(dkey, SP_GROUP(&o), p); if (newseen) { seen = newseen; } } - if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { - SPItem *child = SP_ITEM(o); + if (SP_IS_GROUP(&o) && SP_GROUP(&o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { + SPItem *child = SP_ITEM(&o); Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey); arenaitem->drawing().update(); @@ -1595,8 +1597,8 @@ static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself - for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) { - count = count_objects_recursive(i, count); + for (auto& i: obj->_children) { + count = count_objects_recursive(&i, count); } return count; @@ -1621,13 +1623,13 @@ static unsigned int objects_in_document(SPDocument *document) static void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { - for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) { + for (auto& def: obj->_children) { // fixme: some inkscape-internal nodes in the future might not be collectable - def->requestOrphanCollection(); + def.requestOrphanCollection(); } } else { - for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) { - vacuum_document_recursive(i); + for (auto& i: obj->_children) { + vacuum_document_recursive(&i); } } } @@ -1755,14 +1757,14 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *s_gr = SP_GRADIENT(src); - for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { - if (trg && (src != trg) && SP_IS_GRADIENT(trg)) { - SPGradient *t_gr = SP_GRADIENT(trg); + for (auto& trg: getDefs()->_children) { + if (&trg && (src != &trg) && SP_IS_GRADIENT(&trg)) { + SPGradient *t_gr = SP_GRADIENT(&trg); if (t_gr && s_gr->isEquivalent(t_gr)) { // Change object references to the existing equivalent gradient - Glib::ustring newid = trg->getId(); + Glib::ustring newid = trg.getId(); if(newid != defid){ // id could be the same if it is a second paste into the same document - change_def_references(src, trg); + change_def_references(src, &trg); } gchar *longid = g_strdup_printf("%s_%9.9d", DuplicateDefString.c_str(), stagger++); def->setAttribute("id", longid ); @@ -1826,9 +1828,9 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I 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"); + for (auto& trg: getDefs()->_children) { + if(&trg && SP_IS_SYMBOL(&trg) && src != &trg ) { + std::string id2 = trg.getRepr()->attribute("id"); if( !id.compare( id2 ) ) { duplicate = true; -- cgit v1.2.3 From 24d3f50003ca3cec6a03a7f5267cc4fe5588c69f Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 13:17:21 +0200 Subject: Renamed children list in SPObject (bzr r14954.1.21) --- src/document.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 3dcec4795..aebb7829f 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -257,7 +257,7 @@ void SPDocument::setCurrentPersp3D(Persp3D * const persp) { void SPDocument::getPerspectivesInDefs(std::vector &list) const { - for (auto& i: root->defs->_children) { + for (auto& i: root->defs->children) { if (SP_IS_PERSP3D(&i)) { list.push_back(SP_PERSP3D(&i)); } @@ -1256,7 +1256,7 @@ static std::vector &find_items_in_area(std::vector &s, SPGroup { g_return_val_if_fail(SP_IS_GROUP(group), s); - for (auto& o: group->_children) { + for (auto& o: group->children) { if ( SP_IS_ITEM(&o) ) { if (SP_IS_GROUP(&o) && (SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { s = find_items_in_area(s, SP_GROUP(&o), dkey, area, test, take_insensitive, into_groups); @@ -1278,7 +1278,7 @@ Returns true if an item is among the descendants of group (recursively). */ static bool item_is_in_group(SPItem *item, SPGroup *group) { - for (auto& o: group->_children) { + for (auto& o: group->children) { if ( SP_IS_ITEM(&o) ) { if (SP_ITEM(&o) == item) { return true; @@ -1298,7 +1298,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (auto& o: group->_children) { + for (auto& o: group->children) { if (bottomMost) { break; } @@ -1328,7 +1328,7 @@ The list can be persisted, which improves "find at multiple points" speed. */ void SPDocument::build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups) const { - for (auto& o: group->_children) { + for (auto& o: group->children) { if (!SP_IS_ITEM(&o)) { continue; } @@ -1392,7 +1392,7 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for (auto& o: group->_children) { + for (auto& o: group->children) { if (!SP_IS_ITEM(&o)) { continue; } @@ -1597,7 +1597,7 @@ static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself - for (auto& i: obj->_children) { + for (auto& i: obj->children) { count = count_objects_recursive(&i, count); } @@ -1623,12 +1623,12 @@ static unsigned int objects_in_document(SPDocument *document) static void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { - for (auto& def: obj->_children) { + for (auto& def: obj->children) { // fixme: some inkscape-internal nodes in the future might not be collectable def.requestOrphanCollection(); } } else { - for (auto& i: obj->_children) { + for (auto& i: obj->children) { vacuum_document_recursive(&i); } } @@ -1757,7 +1757,7 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *s_gr = SP_GRADIENT(src); - for (auto& trg: getDefs()->_children) { + for (auto& trg: getDefs()->children) { if (&trg && (src != &trg) && SP_IS_GRADIENT(&trg)) { SPGradient *t_gr = SP_GRADIENT(&trg); if (t_gr && s_gr->isEquivalent(t_gr)) { @@ -1828,7 +1828,7 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I id.erase( pos ); // Check that it really is a duplicate - for (auto& trg: getDefs()->_children) { + for (auto& trg: getDefs()->children) { if(&trg && SP_IS_SYMBOL(&trg) && src != &trg ) { std::string id2 = trg.getRepr()->attribute("id"); -- cgit v1.2.3 From 1dd869116719a20f503e05f3b01cddb8b0c97ed6 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sat, 23 Jul 2016 11:30:20 +0200 Subject: Fix auto palette when using extensions (bzr r15019) --- 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 902dabbc3..9f408788b 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -955,6 +955,9 @@ SPDocument::emitReconstructionFinish(void) { // printf("Finishing Reconstruction\n"); priv->_reconstruction_finish_signal.emit(); + // indicates that gradients are reloaded (to rebuild the Auto palette) + priv->resources_changed_signals[g_quark_from_string("gradient")].emit(); + /** // Reference to the old persp3d object is invalid after reconstruction. -- cgit v1.2.3 From 6641c2e8c586612aad47e1296584ca6447e11b15 Mon Sep 17 00:00:00 2001 From: "Tavmjong Bah, Kamalpreet Grewal" <> Date: Mon, 25 Jul 2016 19:10:59 +0530 Subject: Add robust implementation of _getSelectorVec() (bzr r14949.1.60) --- src/document.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 9f408788b..834d54132 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1053,6 +1053,60 @@ sigc::connection SPDocument::connectIdChanged(gchar const *id, return priv->id_changed_signals[g_quark_from_string(id)].connect(slot); } +void _getObjectsByClassRecursive(Glib::ustring const &klass, SPObject *parent, std::vector &objects) +{ + if (parent) { + Glib::ustring class_attribute; + char const *temp = parent->getAttribute("class"); + if (temp) { + class_attribute = temp; + } + + if (class_attribute.find( klass ) != std::string::npos) { + objects.push_back( parent ); + } + + // Check children + for (SPObject *child = parent->children; child; child = child->next) { + _getObjectsByClassRecursive( klass, child, objects ); + } + } +} + +std::vector SPDocument::getObjectsByClass(Glib::ustring const &klass) const +{ + std::vector objects; + g_return_val_if_fail(!klass.empty(), objects); + + _getObjectsByClassRecursive(klass, root, objects); + return objects; +} + +void _getObjectsByElementRecursive(Glib::ustring const &element, SPObject *parent, + std::vector &objects) +{ + if (parent) { + Glib::ustring prefixed = "svg:" + element; + if (parent->getRepr()->name() == prefixed) { + objects.push_back(parent); + } + + // Check children + for (SPObject *child = parent->children; child; child = child->next) { + _getObjectsByElementRecursive(element, child, objects); + } + } +} + +std::vector SPDocument::getObjectsByElement(Glib::ustring const &element) const +{ + std::vector objects; + g_return_val_if_fail(!element.empty(), objects); + + _getObjectsByElementRecursive(element, root, objects); + return objects; +} + void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) { if (object) { -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/document.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 9f408788b..181029cd0 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -37,17 +37,17 @@ #define noSP_DOCUMENT_DEBUG_UNDO #ifdef HAVE_CONFIG_H -# include "config.h" +#include #endif #include #include #include <2geom/transforms.h> +#include #include "widgets/desktop-widget.h" #include "desktop.h" #include "dir-util.h" #include "display/drawing.h" -#include "display/drawing-item.h" #include "document-private.h" #include "document-undo.h" #include "id-clash.h" @@ -55,18 +55,12 @@ #include "inkscape-version.h" #include "libavoid/router.h" #include "persp3d.h" -#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-symbol.h" -#include "transf_mat_3x4.h" -#include "util/units.h" -#include "xml/repr.h" #include "xml/rebase-hrefs.h" -#include "libcroco/cr-cascade.h" using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/document.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 181029cd0..9f408788b 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -37,17 +37,17 @@ #define noSP_DOCUMENT_DEBUG_UNDO #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif #include #include #include <2geom/transforms.h> -#include #include "widgets/desktop-widget.h" #include "desktop.h" #include "dir-util.h" #include "display/drawing.h" +#include "display/drawing-item.h" #include "document-private.h" #include "document-undo.h" #include "id-clash.h" @@ -55,12 +55,18 @@ #include "inkscape-version.h" #include "libavoid/router.h" #include "persp3d.h" +#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-symbol.h" +#include "transf_mat_3x4.h" +#include "util/units.h" +#include "xml/repr.h" #include "xml/rebase-hrefs.h" +#include "libcroco/cr-cascade.h" using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/document.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 9f408788b..0ff01b587 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -37,7 +37,7 @@ #define noSP_DOCUMENT_DEBUG_UNDO #ifdef HAVE_CONFIG_H -# include "config.h" +#include #endif #include #include @@ -47,7 +47,6 @@ #include "desktop.h" #include "dir-util.h" #include "display/drawing.h" -#include "display/drawing-item.h" #include "document-private.h" #include "document-undo.h" #include "id-clash.h" @@ -55,18 +54,12 @@ #include "inkscape-version.h" #include "libavoid/router.h" #include "persp3d.h" -#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-symbol.h" -#include "transf_mat_3x4.h" -#include "util/units.h" -#include "xml/repr.h" #include "xml/rebase-hrefs.h" -#include "libcroco/cr-cascade.h" using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; -- cgit v1.2.3 From 11e0546b1c039fc84c1a0f86a4681df34642916b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah & Kamalpreet Grewal <> Date: Mon, 15 Aug 2016 10:45:09 +0530 Subject: Add changes for compilation with trunk (bzr r14949.1.65) --- src/document.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 27fbaf8d8..bd59da501 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1060,8 +1060,8 @@ void _getObjectsByClassRecursive(Glib::ustring const &klass, SPObject *parent, s } // Check children - for (SPObject *child = parent->children; child; child = child->next) { - _getObjectsByClassRecursive( klass, child, objects ); + for (auto& child : parent->children) { + _getObjectsByClassRecursive( klass, &child, objects ); } } } @@ -1085,8 +1085,8 @@ void _getObjectsByElementRecursive(Glib::ustring const &element, SPObject *paren } // Check children - for (SPObject *child = parent->children; child; child = child->next) { - _getObjectsByElementRecursive(element, child, objects); + for (auto& child : parent->children) { + _getObjectsByElementRecursive(element, &child, objects); } } } -- cgit v1.2.3 From b1fd9e5520ba0578f3b1dbfa53a806bfdb74f3a3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 3 Oct 2016 00:48:49 +0200 Subject: Doc rotate start (bzr r15142.1.1) --- src/document.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 920e47cb8..a371fe1e5 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -386,6 +386,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, if (!bordercolor.empty()) { rnew->setAttribute("bordercolor", bordercolor.data()); } + sp_repr_set_svg_double(rnew, "inkscape:document-rotation", 0.); sp_repr_set_svg_double(rnew, "borderopacity", prefs->getDouble("/template/base/borderopacity", 1.0)); sp_repr_set_svg_double(rnew, "objecttolerance", @@ -407,6 +408,11 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, rroot->addChild(rnew, NULL); // clean up Inkscape::GC::release(rnew); + } else { + Inkscape::XML::Node *nv_repr = sp_item_group_get_child_by_name(document->root, NULL, "sodipodi:namedview")->getRepr(); + if (!nv_repr->attribute("inkscape:document-rotation")) { + sp_repr_set_svg_double(nv_repr, "inkscape:document-rotation", 0.); + } } // Defs -- cgit v1.2.3 From 5113c265f595b8497e1c340e01177d425155ff3d Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 28 Nov 2016 23:07:00 +0100 Subject: update filter list when pasting and on import (bzr r15283) --- 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 920e47cb8..0c77a8f48 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -950,6 +950,7 @@ SPDocument::emitReconstructionFinish(void) priv->_reconstruction_finish_signal.emit(); // indicates that gradients are reloaded (to rebuild the Auto palette) priv->resources_changed_signals[g_quark_from_string("gradient")].emit(); + priv->resources_changed_signals[g_quark_from_string("filter")].emit(); /** -- cgit v1.2.3 From 6947ff531840b67cafd4c7931e6b7bb9ceaf7d70 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 5 Feb 2017 20:24:08 +0100 Subject: forward-port from 0.92.x the line height conversion from <.92 to >=.92 Code written by su_v in python as an extension, ported to c++ by Mc, some fixes added by bryce. http://bazaar.launchpad.net/~inkscape.dev/inkscape/0.92.x/revision/15338 http://bazaar.launchpad.net/~inkscape.dev/inkscape/0.92.x/revision/15339 http://bazaar.launchpad.net/~inkscape.dev/inkscape/0.92.x/revision/15350 http://bazaar.launchpad.net/~inkscape.dev/inkscape/0.92.x/revision/15351 Option to disable it is called --no-convert-text-baseline-spacing The terminology "convert" is chosen as a jargon word to be used for all such legacy file conversions. The "--no-XXX" naming style is adopted from the convention used by other software such as GIMP. (bzr r15481) --- src/document.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index 57208582a..b69508751 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -49,6 +49,7 @@ #include "display/drawing.h" #include "document-private.h" #include "document-undo.h" +#include "file.h" #include "id-clash.h" #include "inkscape.h" #include "inkscape-version.h" @@ -71,7 +72,7 @@ using Inkscape::Util::unit_table; // since we want it to happen when there are no more updates. #define SP_DOCUMENT_REROUTING_PRIORITY (G_PRIORITY_HIGH_IDLE - 1) - +bool sp_no_convert_text_baseline_spacing = false; static gint sp_document_idle_handler(gpointer data); static gint sp_document_rerouting_handler(gpointer data); @@ -452,6 +453,17 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, )); document->oldSignalsConnected = true; + /** Fix baseline spacing (pre-92 files) **/ + if ( (!sp_no_convert_text_baseline_spacing) + && sp_version_inside_range( document->root->version.inkscape, 0, 1, 0, 92 ) ) { + sp_file_convert_text_baseline_spacing(document); + } + + /** Fix font names in legacy documents (pre-92 files) **/ + if ( sp_version_inside_range( document->root->version.inkscape, 0, 1, 0, 92 ) ) { + sp_file_convert_font_name(document); + } + return document; } -- cgit v1.2.3 From 646ef9c0269e7cf99f07d2a2896c35cf151a68a5 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 9 Feb 2017 14:51:53 +0100 Subject: [Bug #1662439] Instant crash when trying to move svg symbol. Fixed bugs: - https://launchpad.net/bugs/1662439 (bzr r15498) --- src/document.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index b69508751..b1f16fece 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1474,7 +1474,9 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin if (SP_IS_GROUP(&o) && SP_GROUP(&o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { SPItem *child = SP_ITEM(&o); Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey); - arenaitem->drawing().update(); + if (arenaitem) { + arenaitem->drawing().update(); + } // seen remembers the last (topmost) of groups pickable at this point if (arenaitem && arenaitem->pick(p, delta, 1) != NULL) { -- cgit v1.2.3 From 1510fb894b45a78aaa2ac9f1dca81357c010544a Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 22 Feb 2017 13:21:03 +0100 Subject: Allow any valid CSS selector. (bzr r15539) --- src/document.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index b1f16fece..c7115f906 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -62,6 +62,11 @@ #include "sp-symbol.h" #include "xml/rebase-hrefs.h" +#include "libcroco/cr-sel-eng.h" +#include "libcroco/cr-selector.h" +#include "libcroco/cr-parser.h" +#include "src/xml/croco-node-iface.h" + using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; @@ -1119,6 +1124,50 @@ std::vector SPDocument::getObjectsByElement(Glib::ustring const &ele return objects; } +void _getObjectsBySelectorRecursive(SPObject *parent, + CRSelEng *sel_eng, CRSimpleSel *simple_sel, + std::vector &objects) +{ + if (parent) { + gboolean result = false; + cr_sel_eng_matches_node( sel_eng, simple_sel, parent->getRepr(), &result ); + if (result) { + objects.push_back(parent); + } + + // Check children + for (auto& child : parent->children) { + _getObjectsBySelectorRecursive(&child, sel_eng, simple_sel, objects); + } + } +} + +std::vector SPDocument::getObjectsBySelector(Glib::ustring const &selector) const +{ + // std::cout << "\nSPDocument::getObjectsBySelector: " << selector << std::endl; + + std::vector objects; + g_return_val_if_fail(!selector.empty(), objects); + + static CRSelEng *sel_eng = NULL; + if (!sel_eng) { + sel_eng = cr_sel_eng_new(); + cr_sel_eng_set_node_iface(sel_eng, &Inkscape::XML::croco_node_iface); + } + + Glib::ustring my_selector = selector + " {"; // Parsing fails sometimes without '{'. Fix me + CRSelector *cr_selector = cr_selector_parse_from_buf ((guchar*)my_selector.c_str(), CR_UTF_8); + // char * cr_string = (char*)cr_selector_to_string( cr_selector ); + // std::cout << " selector: |" << (cr_string?cr_string:"Empty") << "|" << std::endl; + CRSelector const *cur = NULL; + for (cur = cr_selector; cur; cur = cur->next) { + if (cur->simple_sel ) { + _getObjectsBySelectorRecursive(root, sel_eng, cur->simple_sel, objects); + } + } + return objects; +} + void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) { if (object) { -- cgit v1.2.3 From a6162e760c7eab68fc65a4ccc879e73ab0c20c1b Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 4 Jun 2017 18:12:50 -0400 Subject: Add very raw page loading using links (bzr r15727) --- src/document.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/document.cpp') diff --git a/src/document.cpp b/src/document.cpp index c7115f906..4fcc2b098 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -481,7 +481,7 @@ SPDocument *SPDocument::createChildDoc(std::string const &uri) SPDocument *document = NULL; while(parent != NULL && parent->getURI() != NULL && document == NULL) { - // Check myself and any parents int he chain + // Check myself and any parents in the chain if(uri == parent->getURI()) { document = parent; break; @@ -500,8 +500,14 @@ SPDocument *SPDocument::createChildDoc(std::string const &uri) // Load a fresh document from the svg source. if(!document) { - const char *path = uri.c_str(); - document = createNewDoc(path, false, false, this); + std::string path; + if(uri.find('/') == -1) { + path = this->getBase() + uri; + } else { + path = uri; + } + std::cout << "Added base: '" << path << "'\n"; + document = createNewDoc(path.c_str(), false, false, this); } return document; } -- cgit v1.2.3 From 99cc870e2202dd3bd4c63be34bb45ba09aa0bd0e Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 5 Jun 2017 00:58:45 +0200 Subject: Porting the pre-92 file update message from 0.92.x to trunk: New dialog when opening pre-0.92 files (with 90 dpi). I implemented it mostly based on mizmo's UI proposal (thanks!), with additional inputs from su_v with a few bugfixes from jabiertxof Also adds a commandline option --convert-dpi-method=[none|scale-viewbox|scale-document] to be able to batch convert files. Fixed bugs: - https://launchpad.net/bugs/1659229 (bzr r15729) --- 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 4fcc2b098..2141f65e9 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -469,6 +469,11 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, sp_file_convert_font_name(document); } + /** Fix dpi (pre-92 files) **/ + if ( !(INKSCAPE.use_gui()) && sp_version_inside_range( document->root->version.inkscape, 0, 1, 0, 92 ) ) { + sp_file_convert_dpi(document); + } + return document; } -- cgit v1.2.3