From 9abb5e658d005b3ac82afeec13fd59384a8e65eb Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sun, 5 Jun 2016 23:20:55 +0200 Subject: Added object set (bzr r14954.1.1) --- src/CMakeLists.txt | 4 ++ src/object-set.cpp | 133 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/object-set.h | 58 +++++++++++++++++++++++ src/object.cpp | 50 ++++++++++++++++++++ src/object.h | 76 ++++++++++++++++++++++++++++++ 5 files changed, 321 insertions(+) create mode 100644 src/object-set.cpp create mode 100644 src/object-set.h create mode 100644 src/object.cpp create mode 100644 src/object.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df25728f4..802a79c4f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -229,7 +229,9 @@ set(inkscape_SRC message-context.cpp message-stack.cpp mod360.cpp + object.cpp object-hierarchy.cpp + object-set.cpp object-snapper.cpp path-chemistry.cpp persp3d-reference.cpp @@ -353,7 +355,9 @@ set(inkscape_SRC mod360-test.h mod360.h number-opt-number.h + object.h object-hierarchy.h + object-set.h object-snapper.h object-test.h path-chemistry.h diff --git a/src/object-set.cpp b/src/object-set.cpp new file mode 100644 index 000000000..f071aa4d6 --- /dev/null +++ b/src/object-set.cpp @@ -0,0 +1,133 @@ +/* + * Multiindex container for selection + * + * Authors: + * Adrian Boguszewski + * + * Copyright (C) 2016 Adrian Boguszewski + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "object-set.h" + +bool ObjectSet::add(Object* object) { + // any ancestor is in the set - do nothing + if (_anyAncestorIsInSet(object)) { + return false; + } + + // check if there is mutual ancestor for some elements, which can replace all of them in the set + Object* o = _getMutualAncestor(object); + + // remove all descendants from the set + _removeDescendantsFromSet(o); + + _add(o); + return true; +} + +bool ObjectSet::remove(Object* object) { + // object is the top of subtree + if (contains(object)) { + _remove(object); + return true; + } + + // any ancestor of object is in the set + if (_anyAncestorIsInSet(object)) { + _removeAncestorsFromSet(object); + return true; + } + + // no object nor any parent in the set + return false; +} + +bool ObjectSet::contains(Object* object) { + return container.get().find(object) != container.get().end(); +} + +void ObjectSet::clear() { + for (auto object: container) { + _remove(object); + } +} + +int ObjectSet::size() { + return container.size(); +} + +bool ObjectSet::_anyAncestorIsInSet(Object *object) { + Object* o = object; + while (o != nullptr) { + if (contains(o)) { + return true; + } + o = o->getParent(); + } + + return false; +} + +void ObjectSet::_removeDescendantsFromSet(Object *object) { + for (auto& child: object->getChildren()) { + if (contains(&child)) { + _remove(&child); + // there is certainly no children of this child in the set + continue; + } + + _removeDescendantsFromSet(&child); + } +} + +void ObjectSet::_remove(Object *object) { + releaseConnections[object].disconnect(); + releaseConnections.erase(object); + container.get().erase(object); +} + +void ObjectSet::_add(Object *object) { + releaseConnections[object] = object->connectRelease(sigc::mem_fun(*this, &ObjectSet::remove)); + container.push_back(object); +} + +Object *ObjectSet::_getMutualAncestor(Object *object) { + Object *o = object; + + bool flag = true; + while (o->getParent() != nullptr) { + for (auto &child: o->getParent()->getChildren()) { + if(&child != o && !contains(&child)) { + flag = false; + break; + } + } + if (!flag) { + break; + } + o = o->getParent(); + } + return o; +} + +void ObjectSet::_removeAncestorsFromSet(Object *object) { + Object* o = object; + while (o->getParent() != nullptr) { + for (auto &child: o->getParent()->getChildren()) { + if (&child != o) { + _add(&child); + } + } + if (contains(o->getParent())) { + _remove(o->getParent()); + break; + } + o = o->getParent(); + } +} + +ObjectSet::~ObjectSet() { + clear(); +} diff --git a/src/object-set.h b/src/object-set.h new file mode 100644 index 000000000..a3962356b --- /dev/null +++ b/src/object-set.h @@ -0,0 +1,58 @@ +/* + * Multiindex container for selection + * + * Authors: + * Adrian Boguszewski + * + * Copyright (C) 2016 Adrian Boguszewski + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_PROTOTYPE_OBJECTSET_H +#define INKSCAPE_PROTOTYPE_OBJECTSET_H + +#include "object.h" +#include +#include +#include +#include +#include +#include +#include + +struct hashed{}; + +typedef boost::multi_index_container< + Object*, + boost::multi_index::indexed_by< + boost::multi_index::sequenced<>, + boost::multi_index::hashed_unique< + boost::multi_index::tag, + boost::multi_index::identity> + >> multi_index_container; + +class ObjectSet { +public: + ObjectSet() {}; + ~ObjectSet(); + bool add(Object* object); + bool remove(Object* object); + bool contains(Object* object); + void clear(); + int size(); + +private: + void _add(Object* object); + void _remove(Object* object); + bool _anyAncestorIsInSet(Object *object); + void _removeDescendantsFromSet(Object *object); + void _removeAncestorsFromSet(Object *object); + Object *_getMutualAncestor(Object *object); + + multi_index_container container; + std::unordered_map releaseConnections; +}; + + +#endif //INKSCAPE_PROTOTYPE_OBJECTSET_H diff --git a/src/object.cpp b/src/object.cpp new file mode 100644 index 000000000..c05d50b3a --- /dev/null +++ b/src/object.cpp @@ -0,0 +1,50 @@ +/* + * Temporary file + * + * Authors: + * Adrian Boguszewski + * + * Copyright (C) 2016 Adrian Boguszewski + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "object.h" + +Object::Object(std::string name) : name(name), parent(NULL) { } + +Object::~Object() { + // only for this prototype + // call destructor on every child + children.clear_and_dispose(delete_disposer()); + release_signal.emit(this); +} + +const std::string& Object::getName() const { + return name; +} + +Object *Object::getParent() { + return parent; +} + +bool Object::isDescendantOf(Object *o) { + Object* p = parent; + while(p != NULL) { + if (p == o) { + return true; + } + p = p->parent; + } + return false; +} + +void Object::addChild(Object* o) { + o->parent = this; + children.push_back(*o); +} + +sigc::connection Object::connectRelease(sigc::slot slot) { + return release_signal.connect(slot); +} + diff --git a/src/object.h b/src/object.h new file mode 100644 index 000000000..a5ad5692e --- /dev/null +++ b/src/object.h @@ -0,0 +1,76 @@ +/* + * Temporary file + * + * Authors: + * Adrian Boguszewski + * + * Copyright (C) 2016 Adrian Boguszewski + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_PROTOTYPE_OBJECT_H +#define INKSCAPE_PROTOTYPE_OBJECT_H + +#include +#include +#include +#include + +// this causes some warning, but it's only for this prototype +class Object; +struct delete_disposer +{ + void operator()(Object *delete_this) { + delete delete_this; + } +}; + +class Object { +private: + std::string name; + Object* parent; + + typedef boost::intrusive::list_member_hook< + boost::intrusive::link_mode< + boost::intrusive::auto_unlink + >> list_hook; + list_hook child_hook; + + typedef boost::intrusive::list< + Object, + boost::intrusive::constant_time_size, + boost::intrusive::member_hook< + Object, + list_hook, + &Object::child_hook + >> list; + list children; + + sigc::signal release_signal; + +public: + Object(std::string name); + virtual ~Object(); + + list &getChildren() { + return children; + } + + const std::string &getName() const; + Object * getParent() ; + + sigc::connection connectRelease(sigc::slot slot); + void addChild(Object* o); + bool isDescendantOf(Object* o); + + bool operator==(Object o) { + return name == o.name; + } + + bool operator!=(Object o) { + return name != o.name; + } +}; + +#endif //INKSCAPE_PROTOTYPE_OBJECT_H -- cgit v1.2.3 From 5633812ca77f35e52db62e7b432761e0e59253fe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 9 Jun 2016 17:19:23 +0200 Subject: Removed Object class and temporary test dependencies (bzr r14954.1.4) --- src/CMakeLists.txt | 2 -- src/object.cpp | 50 ----------------------------------- src/object.h | 76 ------------------------------------------------------ src/sp-flowtext.h | 1 + 4 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 src/object.cpp delete mode 100644 src/object.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 802a79c4f..92436ea9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -229,7 +229,6 @@ set(inkscape_SRC message-context.cpp message-stack.cpp mod360.cpp - object.cpp object-hierarchy.cpp object-set.cpp object-snapper.cpp @@ -355,7 +354,6 @@ set(inkscape_SRC mod360-test.h mod360.h number-opt-number.h - object.h object-hierarchy.h object-set.h object-snapper.h diff --git a/src/object.cpp b/src/object.cpp deleted file mode 100644 index c05d50b3a..000000000 --- a/src/object.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Temporary file - * - * Authors: - * Adrian Boguszewski - * - * Copyright (C) 2016 Adrian Boguszewski - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "object.h" - -Object::Object(std::string name) : name(name), parent(NULL) { } - -Object::~Object() { - // only for this prototype - // call destructor on every child - children.clear_and_dispose(delete_disposer()); - release_signal.emit(this); -} - -const std::string& Object::getName() const { - return name; -} - -Object *Object::getParent() { - return parent; -} - -bool Object::isDescendantOf(Object *o) { - Object* p = parent; - while(p != NULL) { - if (p == o) { - return true; - } - p = p->parent; - } - return false; -} - -void Object::addChild(Object* o) { - o->parent = this; - children.push_back(*o); -} - -sigc::connection Object::connectRelease(sigc::slot slot) { - return release_signal.connect(slot); -} - diff --git a/src/object.h b/src/object.h deleted file mode 100644 index a5ad5692e..000000000 --- a/src/object.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Temporary file - * - * Authors: - * Adrian Boguszewski - * - * Copyright (C) 2016 Adrian Boguszewski - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef INKSCAPE_PROTOTYPE_OBJECT_H -#define INKSCAPE_PROTOTYPE_OBJECT_H - -#include -#include -#include -#include - -// this causes some warning, but it's only for this prototype -class Object; -struct delete_disposer -{ - void operator()(Object *delete_this) { - delete delete_this; - } -}; - -class Object { -private: - std::string name; - Object* parent; - - typedef boost::intrusive::list_member_hook< - boost::intrusive::link_mode< - boost::intrusive::auto_unlink - >> list_hook; - list_hook child_hook; - - typedef boost::intrusive::list< - Object, - boost::intrusive::constant_time_size, - boost::intrusive::member_hook< - Object, - list_hook, - &Object::child_hook - >> list; - list children; - - sigc::signal release_signal; - -public: - Object(std::string name); - virtual ~Object(); - - list &getChildren() { - return children; - } - - const std::string &getName() const; - Object * getParent() ; - - sigc::connection connectRelease(sigc::slot slot); - void addChild(Object* o); - bool isDescendantOf(Object* o); - - bool operator==(Object o) { - return name == o.name; - } - - bool operator!=(Object o) { - return name != o.name; - } -}; - -#endif //INKSCAPE_PROTOTYPE_OBJECT_H diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index 9ee676893..d0b0a19a4 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -8,6 +8,7 @@ #include "libnrtype/Layout-TNG.h" #include "sp-item.h" +#include "desktop.h" #define SP_FLOWTEXT(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_FLOWTEXT(obj) (dynamic_cast((SPObject*)obj) != NULL) -- cgit v1.2.3 From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/desktop-style.cpp | 6 +- src/extension/execution-env.cpp | 2 +- src/extension/implementation/implementation.cpp | 2 +- src/extension/implementation/script.cpp | 2 +- src/extension/internal/bitmap/imagemagick.cpp | 4 +- src/extension/internal/bluredge.cpp | 2 +- src/extension/internal/filter/filter.cpp | 2 +- src/extension/internal/grid.cpp | 2 +- src/extension/plugins/grid2/grid.cpp | 2 +- src/gradient-chemistry.cpp | 4 +- src/gradient-drag.cpp | 6 +- src/object-set.cpp | 31 +++++++--- src/object-set.h | 27 +++++++- src/path-chemistry.cpp | 10 +-- src/selcue.cpp | 8 +-- src/selection-chemistry.cpp | 82 ++++++++++++------------- src/selection-describer.cpp | 2 +- src/selection.cpp | 18 +----- src/selection.h | 16 ----- src/seltrans.cpp | 14 ++--- src/snap.cpp | 2 +- src/splivarot.cpp | 10 +-- src/text-chemistry.cpp | 24 ++++---- src/trace/trace.cpp | 2 +- src/ui/clipboard.cpp | 6 +- src/ui/dialog/align-and-distribute.cpp | 16 ++--- src/ui/dialog/clonetiler.cpp | 8 +-- src/ui/dialog/export.cpp | 14 ++--- src/ui/dialog/filter-effects-dialog.cpp | 6 +- src/ui/dialog/find.cpp | 2 +- src/ui/dialog/glyphs.cpp | 4 +- src/ui/dialog/grid-arrange-tab.cpp | 12 ++-- src/ui/dialog/icon-preview.cpp | 2 +- src/ui/dialog/objects.cpp | 2 +- src/ui/dialog/pixelartdialog.cpp | 2 +- src/ui/dialog/polar-arrange-tab.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.cpp | 4 +- src/ui/dialog/swatches.cpp | 2 +- src/ui/dialog/tags.cpp | 4 +- src/ui/dialog/text-edit.cpp | 6 +- src/ui/dialog/transformation.cpp | 14 ++--- src/ui/interface.cpp | 2 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 4 +- src/ui/tools/gradient-tool.cpp | 14 ++--- src/ui/tools/lpe-tool.cpp | 2 +- src/ui/tools/mesh-tool.cpp | 12 ++-- src/ui/tools/node-tool.cpp | 4 +- src/ui/tools/select-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 10 +-- src/ui/tools/tool-base.cpp | 2 +- src/ui/tools/tweak-tool.cpp | 6 +- src/ui/widget/style-subject.cpp | 2 +- src/vanishing-point.cpp | 10 +-- src/widgets/arc-toolbar.cpp | 8 +-- src/widgets/connector-toolbar.cpp | 6 +- src/widgets/fill-style.cpp | 2 +- src/widgets/gradient-toolbar.cpp | 6 +- src/widgets/mesh-toolbar.cpp | 4 +- src/widgets/pencil-toolbar.cpp | 4 +- src/widgets/rect-toolbar.cpp | 4 +- src/widgets/spiral-toolbar.cpp | 4 +- src/widgets/star-toolbar.cpp | 12 ++-- src/widgets/stroke-style.cpp | 6 +- src/widgets/text-toolbar.cpp | 8 +-- 65 files changed, 266 insertions(+), 256 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 7f9b46c7d..6fab01f16 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -194,7 +194,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_write, css); sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); - std::vector const itemlist = desktop->selection->itemList(); + std::vector const itemlist = desktop->selection->items(); for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { /* last used styles for 3D box faces are stored separately */ SPObject *obj = *i; @@ -234,7 +234,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_no_text, css); css_no_text = sp_css_attr_unset_text(css_no_text); - std::vector const itemlist = desktop->selection->itemList(); + std::vector const itemlist = desktop->selection->items(); for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { SPItem *item = *i; @@ -1917,7 +1917,7 @@ sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property) // otherwise, do querying and averaging over selection if (desktop->selection != NULL) { - return sp_desktop_query_style_from_list (desktop->selection->itemList(), style, property); + return sp_desktop_query_style_from_list (desktop->selection->items(), style, property); } return QUERY_STYLE_NOTHING; diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index d5c80f26e..2b0183d4b 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -58,7 +58,7 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - std::vector selected = desktop->getSelection()->itemList(); + std::vector selected = desktop->getSelection()->items(); for(std::vector::const_iterator x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id = (*x)->getId(); diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 92a8a2833..eb1213a84 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -46,7 +46,7 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); - std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { const SPItem * item = selected[0]; diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 01323bee2..0acc99aed 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -690,7 +690,7 @@ void Script::effect(Inkscape::Extension::Effect *module, } std::vector selected = - desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer + desktop->getSelection()->items(); //desktop should not be NULL since doc was checked and desktop is a casted pointer for(std::vector::const_iterator x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id += "--id="; diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index a235dcb0f..707cd763d 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -65,7 +65,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const std::vector selectedItemList = desktop->selection->itemList(); + const std::vector selectedItemList = desktop->selection->items(); int selectCount = selectedItemList.size(); // Init the data-holders @@ -235,7 +235,7 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie { SPDocument * current_document = view->doc(); - std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = (selected.front())->getRepr(); diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 4a04e3c33..6dc788f17 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -62,7 +62,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); // TODO need to properly refcount the items, at least - std::vector items(selection->itemList()); + std::vector items(selection->items()); selection->clear(); for(std::vector::iterator item = items.begin(); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 25e89bbf3..acfcaed0e 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -125,7 +125,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::Selection * selection = ((SPDesktop *)document)->selection; // TODO need to properly refcount the items, at least - std::vector items(selection->itemList()); + std::vector items(selection->items()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index c766bd828..fd1b311a8 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -180,7 +180,7 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = selected[0]->getRepr(); diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp index 6880c574d..c938d1ec4 100644 --- a/src/extension/plugins/grid2/grid.cpp +++ b/src/extension/plugins/grid2/grid.cpp @@ -186,7 +186,7 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = selected[0]->getRepr(); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index edeb523d7..698cf5012 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1570,7 +1570,7 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa { Inkscape::Selection *selection = desktop->getSelection(); - const std::vector list=selection->itemList(); + const std::vector list= selection->items(); for (std::vector::const_iterator i = list.begin(); i != list.end(); ++i) { sp_item_gradient_invert_vector_color(*i, fill_or_stroke); } @@ -1595,7 +1595,7 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) if (drag && !drag->selected.empty()) { drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - const std::vector list=selection->itemList(); + const std::vector list= selection->items(); for (std::vector::const_iterator i = list.begin(); i != list.end(); ++i) { sp_item_gradient_reverse_vector(*i, Inkscape::FOR_FILL); sp_item_gradient_reverse_vector(*i, Inkscape::FOR_STROKE); diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 613dc2fc1..3d1cefd4f 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2070,7 +2070,7 @@ void GrDrag::updateDraggers() this->draggers.clear(); g_return_if_fail(this->selection != NULL); - std::vector list = this->selection->itemList(); + std::vector list = this->selection->items(); for (std::vector::const_iterator i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; SPStyle *style = item->style; @@ -2138,7 +2138,7 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); - std::vector list = this->selection->itemList(); + std::vector list = this->selection->items(); for (std::vector::const_iterator i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; @@ -2282,7 +2282,7 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); - std::vector list = this->selection->itemList(); + std::vector list = this->selection->items(); for (std::vector::const_iterator i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; Geom::OptRect rect = item->desktopVisualBounds(); diff --git a/src/object-set.cpp b/src/object-set.cpp index d282e7894..627544a21 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -16,6 +16,7 @@ #include "persp3d.h" #include "preferences.h" +namespace Inkscape { bool ObjectSet::add(SPObject* object) { g_return_val_if_fail(object != NULL, false); @@ -202,7 +203,7 @@ SPItem *ObjectSet::largestItem(CompareSize compare) { } SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { - std::vector const items = itemList(); + std::vector const items = const_cast(this)->items(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; @@ -226,10 +227,10 @@ SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { return ist; } -SPObjectRange ObjectSet::range() { +SPObjectRange ObjectSet::objects() { return SPObjectRange(container.get().begin(), container.get().end()); } -std::vector ObjectSet::itemList() { +std::vector ObjectSet::items() { std::vector tmp = std::vector(container.begin(), container.end()); std::vector result; std::remove_if(tmp.begin(), tmp.end(), [](SPObject* o){return !SP_IS_ITEM(o);}); @@ -237,6 +238,18 @@ std::vector ObjectSet::itemList() { return result; } +std::vector ObjectSet::xmlNodes() { + std::vector list = items(); + std::vector result; + std::transform(list.begin(), list.end(), std::back_inserter(result), [](SPItem* item) { return item->getRepr(); }); + return result; +} + +Inkscape::XML::Node *ObjectSet::singleRepr() { + SPObject *obj = single(); + return obj ? obj->getRepr() : nullptr; +} + void ObjectSet::set(SPObject *object) { _clear(); _add(object); @@ -273,7 +286,7 @@ Geom::OptRect ObjectSet::bounds(SPItem::BBoxType type) const Geom::OptRect ObjectSet::geometricBounds() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); Geom::OptRect bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { @@ -284,7 +297,7 @@ Geom::OptRect ObjectSet::geometricBounds() const Geom::OptRect ObjectSet::visualBounds() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); Geom::OptRect bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { @@ -305,7 +318,7 @@ Geom::OptRect ObjectSet::preferredBounds() const Geom::OptRect ObjectSet::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); if (items.empty()) return bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { @@ -319,7 +332,7 @@ Geom::OptRect ObjectSet::documentBounds(SPItem::BBoxType type) const // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() boost::optional ObjectSet::center() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); if (!items.empty()) { SPItem *first = items.back(); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly @@ -381,4 +394,6 @@ void ObjectSet::_remove_3D_boxes_recursively(SPObject *obj) { } _3dboxes.erase(b); } -} \ No newline at end of file +} + +} // namespace Inkscape diff --git a/src/object-set.h b/src/object-set.h index 05264a3ea..49a875562 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -28,6 +28,12 @@ class SPBox3D; class Persp3D; +namespace Inkscape { + +namespace XML { +class Node; +} + struct hashed{}; struct random_access{}; @@ -54,6 +60,12 @@ typedef boost::any_range< SPItem* const&, std::ptrdiff_t> SPItemRange; +typedef boost::any_range< + XML::Node*, + boost::random_access_traversal_tag, + XML::Node* const&, + std::ptrdiff_t> XMLNodeRange; + class ObjectSet { public: enum CompareSize {HORIZONTAL, VERTICAL, AREA}; @@ -144,10 +156,20 @@ public: SPItem *largestItem(CompareSize compare); /** Returns the list of selected objects. */ - SPObjectRange range(); + SPObjectRange objects(); /** Returns the list of selected SPItems. */ - std::vector itemList(); + std::vector items(); + + /** Returns a list of the xml nodes of all selected objects. */ + std::vector xmlNodes(); + + /** + * Returns a single selected object's xml node. + * + * @return NULL unless exactly one object is selected + */ + XML::Node *singleRepr(); /** * Selects exactly the specified objects. @@ -213,5 +235,6 @@ protected: }; +} // namespace Inkscape #endif //INKSCAPE_PROTOTYPE_OBJECTSET_H diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 1a345b565..37d242b6b 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -57,7 +57,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) Inkscape::Selection *selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); - std::vector items(selection->itemList()); + std::vector items(selection->items()); if (items.size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to combine.")); @@ -203,7 +203,7 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo) bool did = false; - std::vector itemlist(selection->itemList()); + std::vector itemlist(selection->items()); for (std::vector::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){ SPItem *item = *i; @@ -303,7 +303,7 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b desktop->setWaitingCursor(); } - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); std::vector to_select; selection->clear(); std::vector items(selected); @@ -334,7 +334,7 @@ void sp_selected_to_lpeitems(SPDesktop *desktop) return; } - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); std::vector to_select; selection->clear(); std::vector items(selected); @@ -603,7 +603,7 @@ void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector items = selection->itemList(); + std::vector items = selection->items(); if (items.empty()) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to reverse.")); diff --git a/src/selcue.cpp b/src/selcue.cpp index 297b9fffc..13248a553 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -96,14 +96,14 @@ void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs) void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) { - const std::vector items = _selection->itemList(); + const std::vector items = _selection->items(); if (_item_bboxes.size() != items.size()) { _newItemBboxes(); return; } int bcount = 0; - std::vector ll=_selection->itemList(); + std::vector ll= _selection->items(); for (std::vector::const_iterator l = ll.begin(); l != ll.end(); ++l) { SPItem *item = *l; SPCanvasItem* box = _item_bboxes[bcount ++]; @@ -146,7 +146,7 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); - std::vector ll=_selection->itemList(); + std::vector ll= _selection->items(); for (std::vector::const_iterator l = ll.begin(); l != ll.end(); ++l) { SPItem *item = *l; @@ -201,7 +201,7 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - std::vector ll = _selection->itemList(); + std::vector ll = _selection->items(); for (std::vector::const_iterator l=ll.begin();l!=ll.end();++l) { SPItem *item = *l; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index a13f3e64d..ded776fea 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -282,7 +282,7 @@ void SelectionHelper::fixSelection(SPDesktop *dt) std::vector items ; - std::vector const selList = selection->itemList(); + std::vector const selList = selection->items(); for( std::vector::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); ++i ) { SPItem *item = *i; @@ -409,7 +409,7 @@ void sp_selection_delete(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing was deleted.")); return; } - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); selection->clear(); sp_selection_delete_impl(selected); desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -454,7 +454,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to duplicate.")); return; } - std::vector reprs(selection->reprList()); + std::vector reprs(selection->xmlNodes()); if(duplicateLayer){ reprs.clear(); @@ -624,7 +624,7 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i std::vector exclude; if (invert) { - exclude = selection->itemList(); + exclude = selection->items(); } if (force_all_layers) @@ -763,7 +763,7 @@ void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) return; } - std::vector p (selection->reprList()); + std::vector p (selection->xmlNodes()); selection->clear(); @@ -798,7 +798,7 @@ void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDeskto selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("No objects selected to pop out of group.")); return; } - std::vector selection_list = selection->itemList(); + std::vector selection_list = selection->items(); std::vector::const_iterator item = selection_list.begin(); // leaving this because it will be useful for // future implementation of complex pop ungrouping @@ -831,7 +831,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } // first check whether there is anything to ungroup - std::vector old_select = selection->itemList(); + std::vector old_select = selection->items(); std::vector new_select; GSList *groups = NULL; for (std::vector::const_iterator item = old_select.begin(); item!=old_select.end(); ++item) { @@ -983,7 +983,7 @@ bool sp_item_repr_compare_position_bool(SPObject const *first, SPObject const *s void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { - std::vector items= selection->itemList(); + std::vector items= selection->items(); if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise.")); return; @@ -1040,7 +1040,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - std::vector items = selection->itemList(); + std::vector items = selection->items(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1048,7 +1048,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - std::vector rl(selection->reprList()); + std::vector rl(selection->xmlNodes()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector::const_iterator l=rl.begin(); l!=rl.end();++l) { @@ -1062,7 +1062,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { - std::vector items = selection->itemList(); + std::vector items = selection->items(); if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower.")); return; @@ -1124,7 +1124,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - std::vector items =selection->itemList(); + std::vector items = selection->items(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1132,7 +1132,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - std::vector rl(selection->reprList()); + std::vector rl(selection->xmlNodes()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector::const_reverse_iterator l=rl.rbegin();l!=rl.rend();++l) { @@ -1287,7 +1287,7 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to remove live path effects from.")); return; } - std::vector list=selection->itemList(); + std::vector list= selection->items(); for ( std::vector::const_iterator itemlist=list.begin();itemlist!=list.end();++itemlist) { SPItem *item = *itemlist; @@ -1368,7 +1368,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) return; } - std::vector items(selection->itemList()); + std::vector items(selection->items()); bool no_more = false; // Set to true, if no more layers above SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); @@ -1412,7 +1412,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) return; } - const std::vector items(selection->itemList()); + const std::vector items(selection->items()); bool no_more = false; // Set to true, if no more layers below SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); @@ -1455,7 +1455,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) return; } - std::vector items(selection->itemList()); + std::vector items(selection->items()); if (moveto) { selection->clear(); @@ -1506,7 +1506,7 @@ static bool selection_contains_both_clone_and_original(Inkscape::Selection *selection) { bool clone_with_original = false; - std::vector items = selection->itemList(); + std::vector items = selection->items(); for (std::vector::const_iterator l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if (item) { @@ -1551,7 +1551,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons persp3d_apply_affine_transformation(transf_persp, affine); } - std::vector items = selection->itemList(); + std::vector items = selection->items(); for (std::vector::const_iterator l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; @@ -1722,7 +1722,7 @@ void sp_selection_remove_transform(SPDesktop *desktop) Inkscape::Selection *selection = desktop->getSelection(); - std::vector items = selection->reprList(); + std::vector items = selection->xmlNodes(); for (std::vector::const_iterator l=items.begin();l!=items.end() ;++l) { (*l)->setAttribute("transform", NULL, false); } @@ -1822,7 +1822,7 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) if (selection->isEmpty()) return; - std::vector items = selection->itemList(); + std::vector items = selection->items(); Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw for (std::vector::const_iterator l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; @@ -1886,7 +1886,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea std::vector all_matches; Inkscape::Selection *selection = desktop->getSelection(); - std::vector items = selection->itemList(); + std::vector items = selection->items(); std::vector tmp; for (std::vector::const_iterator iter=all_list.begin();iter!=all_list.end();++iter) { @@ -1943,7 +1943,7 @@ void sp_select_same_object_type(SPDesktop *desktop) Inkscape::Selection *selection = desktop->getSelection(); - std::vector items=selection->itemList(); + std::vector items= selection->items(); for (std::vector::const_iterator sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { SPItem *sel = *sel_iter; if (sel) { @@ -2456,7 +2456,7 @@ sp_selection_item_next(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + SPItem *item=next_item_from_list(desktop, selection->items(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); @@ -2486,7 +2486,7 @@ sp_selection_item_prev(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + SPItem *item=next_item_from_list(desktop, selection->items(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); @@ -2603,7 +2603,7 @@ void sp_selection_clone(SPDesktop *desktop) return; } - std::vector reprs (selection->reprList()); + std::vector reprs (selection->xmlNodes()); selection->clear(); @@ -2662,7 +2662,7 @@ sp_selection_relink(SPDesktop *desktop) // Get a copy of current selection. bool relinked = false; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for (std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; @@ -2700,7 +2700,7 @@ sp_selection_unlink(SPDesktop *desktop) // Get a copy of current selection. std::vector new_select; bool unlinked = false; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){ SPItem *item = *i; @@ -2767,7 +2767,7 @@ sp_select_clone_original(SPDesktop *desktop) // Check if other than two objects are selected - std::vector items=selection->itemList(); + std::vector items= selection->items(); if (items.size() != 1 || !item) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); return; @@ -2865,7 +2865,7 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) Inkscape::SVGOStringStream os; SPObject * firstItem = NULL; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for (std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { if (firstItem) { @@ -2950,7 +2950,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) Geom::Point center( *c - corner ); // As defined by rotation center center[Geom::Y] = -center[Geom::Y]; - std::vector items(selection->itemList()); + std::vector items(selection->items()); //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? @@ -3024,7 +3024,7 @@ void sp_selection_to_guides(SPDesktop *desktop) SPDocument *doc = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); // we need to copy the list because it gets reset when objects are deleted - std::vector items(selection->itemList()); + std::vector items(selection->items()); if (items.empty()) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to convert to guides.")); @@ -3090,7 +3090,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) doc->ensureUpToDate(); - std::vector items(selection->range().begin(), selection->range().end()); + std::vector items(selection->objects().begin(), selection->objects().end()); sort(items.begin(),items.end(),sp_object_compare_position_bool); // Keep track of parent, this is where will be inserted. @@ -3302,7 +3302,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); - std::vector items (selection->itemList()); + std::vector items (selection->items()); sort(items.begin(),items.end(),sp_object_compare_position_bool); @@ -3407,7 +3407,7 @@ void sp_selection_untile(SPDesktop *desktop) bool did = false; - std::vector items(selection->itemList()); + std::vector items(selection->items()); for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){ SPItem *item = *i; @@ -3472,7 +3472,7 @@ void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring return; } - std::vector const reprlst = selection->reprList(); + std::vector const reprlst = selection->xmlNodes(); bool filename_search = TRUE; bool xdpi_search = TRUE; bool ydpi_search = TRUE; @@ -3564,7 +3564,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // List of the items to show; all others will be hidden - std::vector items(selection->itemList()); + std::vector items(selection->items()); // Sort items so that the topmost comes last sort(items.begin(),items.end(),sp_item_repr_compare_position_bool); @@ -3765,7 +3765,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) return; } - std::vector p(selection->reprList()); + std::vector p(selection->xmlNodes()); sort(p.begin(),p.end(),sp_repr_compare_position_bool); @@ -3875,7 +3875,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ if ( apply_to_layer && is_empty) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to create clippath or mask from.")); return; - } else if (!apply_to_layer && ( is_empty || selection->itemList().size()==1 )) { + } else if (!apply_to_layer && ( is_empty || selection->items().size()==1 )) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and object(s) to apply clippath or mask to.")); return; } @@ -3890,7 +3890,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ doc->ensureUpToDate(); - std::vector items(selection->itemList()); + std::vector items(selection->items()); sort(items.begin(),items.end(),sp_object_compare_position_bool); @@ -4052,7 +4052,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map referenced_objects; - std::vector items(selection->itemList()); + std::vector items(selection->items()); selection->clear(); GSList *items_to_ungroup = NULL; diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index ddc7a0d10..93808ed54 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -122,7 +122,7 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin } void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { - std::vector const items = selection->itemList(); + std::vector const items = selection->items(); if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); diff --git a/src/selection.cpp b/src/selection.cpp index 32e27f2d4..94b64a7bc 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -130,25 +130,13 @@ void Selection::setReprList(std::vector const &list) { _emitChanged(); } -std::vector Selection::reprList() { - std::vector list = itemList(); - std::vector result; - std::transform(list.begin(), list.end(), std::back_inserter(result), [](SPItem* item) { return item->getRepr(); }); - return result; -} - -Inkscape::XML::Node *Selection::singleRepr() { - SPObject *obj = single(); - return obj ? obj->getRepr() : nullptr; -} - std::vector Selection::getSnapPoints(SnapPreferences const *snapprefs) const { std::vector p; if (snapprefs != NULL){ SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { SPItem *this_item = *iter; this_item->getSnappoints(p, &snapprefs_dummy); @@ -174,7 +162,7 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { } size_t Selection::numberOfLayers() { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); std::set layers; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { SPObject *layer = _layers->layerForObject(*iter); @@ -185,7 +173,7 @@ size_t Selection::numberOfLayers() { } size_t Selection::numberOfParents() { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->items(); std::set parents; for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { SPObject *parent = (*iter)->parent; diff --git a/src/selection.h b/src/selection.h index 8b1bb25fa..7027a388f 100644 --- a/src/selection.h +++ b/src/selection.h @@ -39,12 +39,6 @@ class Node; namespace Inkscape { -typedef boost::any_range< - XML::Node*, - boost::random_access_traversal_tag, - XML::Node* const&, - std::ptrdiff_t> XMLNodeRange; - /** * The set of selected SPObjects for a given document and layer model. * @@ -156,16 +150,6 @@ public: return includes(_objectForXMLNode(repr)); } - /** - * Returns a single selected object's xml node. - * - * @return NULL unless exactly one object is selected - */ - XML::Node *singleRepr(); - - /** Returns a list of the xml nodes of all selected objects. */ - std::vector reprList(); - /** Returns the number of layers in which there are selected objects. */ size_t numberOfLayers(); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index b54525610..9fa6172ed 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -240,7 +240,7 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - std::vector items=_desktop->selection->itemList(); + std::vector items= _desktop->selection->items(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = SP_ITEM(*iter); it->setCenter(p); @@ -270,7 +270,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - std::vector items=_desktop->selection->itemList(); + std::vector items= _desktop->selection->items(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = static_cast(sp_object_ref(*iter, NULL)); _items.push_back(it); @@ -492,7 +492,7 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - std::vector items=_desktop->selection->itemList(); + std::vector items= _desktop->selection->items(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = *iter; it->updateRepr(); @@ -529,7 +529,7 @@ void Inkscape::SelTrans::stamp() l = _stamp_cache; } else { /* Build cache */ - l = selection->itemList(); + l = selection->items(); sort(l.begin(),l.end(),sp_object_compare_position_bool); _stamp_cache = l; } @@ -621,7 +621,7 @@ void Inkscape::SelTrans::_updateVolatileState() return; } - _strokewidth = stroke_average_width (selection->itemList()); + _strokewidth = stroke_average_width (selection->items()); } void Inkscape::SelTrans::_showHandles(SPSelTransType type) @@ -711,7 +711,7 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa case HANDLE_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items - std::vector items=_desktop->selection->itemList(); + std::vector items= _desktop->selection->items(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = *iter; it->unsetCenter(); @@ -1287,7 +1287,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center - std::vector items = const_cast(_selection)->itemList(); + std::vector items = const_cast(_selection)->items(); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); diff --git a/src/snap.cpp b/src/snap.cpp index 7f0e8d9dc..d1d15ca0c 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -708,7 +708,7 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, _items_to_ignore.clear(); Inkscape::Selection *sel = _desktop->selection; - std::vector const items = sel->itemList(); + std::vector const items = sel->items(); for (std::vector::const_iterator i=items.begin();i!=items.end();++i) { _items_to_ignore.push_back(*i); } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 1bc6da3e1..d4ef3f9c2 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -335,7 +335,7 @@ void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) { SPDocument *doc = selection->layers()->getDocument(); - std::vector il= selection->itemList(); + std::vector il= selection->items(); // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) if ( (il.size() < 2) && (bop != bool_op_union)) { @@ -689,7 +689,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } } else { // find out the bottom object - std::vector sorted(selection->reprList()); + std::vector sorted(selection->xmlNodes()); sort(sorted.begin(),sorted.end(),sp_repr_compare_position_bool); @@ -1157,7 +1157,7 @@ sp_selected_path_outline(SPDesktop *desktop) bool scale_stroke = prefs->getBool("/options/transform/stroke", true); prefs->setBool("/options/transform/stroke", true); bool did = false; - std::vector il(selection->itemList()); + std::vector il(selection->items()); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; @@ -1771,7 +1771,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } bool did = false; - std::vector il(selection->itemList()); + std::vector il(selection->items()); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; SPCurve *curve = NULL; @@ -2196,7 +2196,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju return; } - std::vector items(selection->itemList()); + std::vector items(selection->items()); bool didSomething = sp_selected_path_simplify_items(desktop, selection, items, threshold, diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index fbbbe5807..5565464a1 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -43,7 +43,7 @@ using Inkscape::DocumentUndo; static SPItem * flowtext_in_selection(Inkscape::Selection *selection) { - std::vector items = selection->itemList(); + std::vector items = selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (SP_IS_FLOWTEXT(*i)) return *i; @@ -54,7 +54,7 @@ flowtext_in_selection(Inkscape::Selection *selection) static SPItem * text_or_flowtext_in_selection(Inkscape::Selection *selection) { - std::vector items = selection->itemList(); + std::vector items = selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return *i; @@ -65,7 +65,7 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) static SPItem * shape_in_selection(Inkscape::Selection *selection) { - std::vector items = selection->itemList(); + std::vector items = selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (SP_IS_SHAPE(*i)) return *i; @@ -87,7 +87,7 @@ text_put_on_path() Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - if (!text || !shape || selection->itemList().size() != 2) { + if (!text || !shape || selection->items().size() != 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a text and a path to put text on path.")); return; } @@ -196,7 +196,7 @@ text_remove_from_path() } bool did = false; - std::vector items(selection->itemList()); + std::vector items(selection->items()); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPObject *obj = *i; @@ -214,7 +214,7 @@ text_remove_from_path() } else { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Remove text from path")); - selection->setList(selection->itemList()); // reselect to update statusbar description + selection->setList(selection->items()); // reselect to update statusbar description } } @@ -260,7 +260,7 @@ text_remove_all_kerns() bool did = false; - std::vector items = selection->itemList(); + std::vector items = selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPObject *obj = *i; @@ -296,7 +296,7 @@ text_flow_into_shape() SPItem *text = text_or_flowtext_in_selection(selection); SPItem *shape = shape_in_selection(selection); - if (!text || !shape || selection->itemList().size() < 2) { + if (!text || !shape || selection->items().size() < 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a text and one or more paths or shapes to flow text into frame.")); return; } @@ -320,7 +320,7 @@ text_flow_into_shape() g_return_if_fail(SP_IS_FLOWREGION(object)); /* Add clones */ - std::vector items = selection->itemList(); + std::vector items = selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; if (SP_IS_SHAPE(item)){ @@ -387,7 +387,7 @@ text_unflow () Inkscape::Selection *selection = desktop->getSelection(); - if (!flowtext_in_selection(selection) || selection->itemList().size() < 1) { + if (!flowtext_in_selection(selection) || selection->items().size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a flowed text to unflow it.")); return; } @@ -395,7 +395,7 @@ text_unflow () std::vector new_objs; GSList *old_objs = NULL; - std::vector items = selection->itemList(); + std::vector items = selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (!SP_IS_FLOWTEXT(*i)) { @@ -480,7 +480,7 @@ flowtext_to_text() bool did = false; std::vector reprs; - std::vector items(selection->itemList()); + std::vector items(selection->items()); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 379682668..f0fa61b89 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -65,7 +65,7 @@ SPImage *Tracer::getSelectedSPImage() if (sioxEnabled) { SPImage *img = NULL; - std::vector const list = sel->itemList(); + std::vector const list = sel->items(); std::vector items; sioxShapes.clear(); diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index d581dbf7e..b1a946db2 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -522,7 +522,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (item) { @@ -578,7 +578,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) desktop->doc()->importDefs(tempdoc); // make sure all selected items are converted to paths first (i.e. rectangles) sp_selected_to_lpeitems(desktop); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; _applyPathEffect(item, effectstack); @@ -661,7 +661,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { // copy the defs used by all items - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); cloned_elements.clear(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 8f87932b8..b7b5b96cd 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -133,7 +133,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; const Coeffs &a = _allCoeffs[index]; @@ -293,7 +293,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; //Check 2 or more selected objects @@ -499,7 +499,7 @@ private : // xGap and yGap are the minimum space required between bounding rectangles. double const xGap = removeOverlapXGap.get_value(); double const yGap = removeOverlapYGap.get_value(); - removeoverlap(_dialog.getDesktop()->getSelection()->itemList(), xGap, yGap); + removeoverlap(_dialog.getDesktop()->getSelection()->items(), xGap, yGap); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -530,7 +530,7 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(_dialog.getDesktop()->getSelection()->itemList()); + graphlayout(_dialog.getDesktop()->getSelection()->items()); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -590,7 +590,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; //Check 2 or more selected objects @@ -656,7 +656,7 @@ private : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - std::vector x(_dialog.getDesktop()->getSelection()->itemList()); + std::vector x(_dialog.getDesktop()->getSelection()->items()); unclump (x); // restore compensation setting @@ -687,7 +687,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; //Check 2 or more selected objects @@ -785,7 +785,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); //Check 2 or more selected objects if (selected.size() < 2) return; diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b727c87ee..7ce937de7 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1376,7 +1376,7 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, Gtk return; } - if (selection->itemList().size() > 1) { + if (selection->items().size() > 1) { gtk_widget_set_sensitive (buttons, FALSE); gtk_label_set_markup (GTK_LABEL(status), _("More than one object selected.")); return; @@ -2113,7 +2113,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to unclump.")); return; } @@ -2162,7 +2162,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to remove.")); return; } @@ -2240,7 +2240,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) } // Check if more than one object is selected. - if (selection->itemList().size() > 1) { + if (selection->items().size() > 1) { desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, group them and clone the group.")); return; } diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2fb5f9e3b..6d2842511 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -608,7 +608,7 @@ void Export::onBatchClicked () void Export::updateCheckbuttons () { - gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size(); + gint num = SP_ACTIVE_DESKTOP->getSelection()->items().size(); if (num >= 2) { batch_export.set_sensitive(true); batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num)); @@ -820,7 +820,7 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); + const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes(); for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { @@ -1015,7 +1015,7 @@ void Export::onExport () if (batch_export.get_active ()) { // Batch export of selected objects - gint num = (desktop->getSelection()->itemList()).size(); + gint num = (desktop->getSelection()->items()).size(); gint n = 0; if (num < 1) { @@ -1029,7 +1029,7 @@ void Export::onExport () gint export_count = 0; - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){ SPItem *item = *i; @@ -1075,7 +1075,7 @@ void Export::onExport () nv->pagecolor, onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking - hide ? (desktop->getSelection()->itemList()) : x + hide ? (desktop->getSelection()->items()) : x )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1165,7 +1165,7 @@ void Export::onExport () nv->pagecolor, onProgressCallback, (void*)prog_dlg, FALSE, - hide ? (desktop->getSelection()->itemList()) : x + hide ? (desktop->getSelection()->items()) : x ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); @@ -1237,7 +1237,7 @@ void Export::onExport () bool saved = DocumentUndo::getUndoSensitive(doc); DocumentUndo::setUndoSensitive(doc, false); - reprlst = desktop->getSelection()->reprList(); + reprlst = desktop->getSelection()->xmlNodes(); for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index d3ad5d1da..dfc19f3cc 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -691,7 +691,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = sel->reprList()[0]; + Inkscape::XML::Node* node = sel->xmlNodes()[0]; if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; @@ -1474,7 +1474,7 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } std::set used; - std::vector itemlist=sel->itemList(); + std::vector itemlist= sel->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { SPObject *obj = *i; SPStyle *style = obj->style; @@ -1555,7 +1555,7 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri if((*iter)[_columns.sel] == 1) filter = 0; - std::vector itemlist=sel->itemList(); + std::vector itemlist= sel->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { SPItem * item = *i; SPStyle *style = item->style; diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 0f368c5ac..8424dd7f5 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -761,7 +761,7 @@ std::vector &Find::all_items (SPObject *r, std::vector &l, boo std::vector &Find::all_selection_items (Inkscape::Selection *s, std::vector &l, SPObject *ancestor, bool hidden, bool locked) { - std::vector itemlist=s->itemList(); + std::vector itemlist= s->items(); for(std::vector::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; ++i) { SPObject *obj = *i; SPItem *item = dynamic_cast(obj); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 56b001291..30b0f8df7 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -578,7 +578,7 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) void GlyphsPanel::insertText() { SPItem *textItem = 0; - std::vector itemlist=targetDesktop->selection->itemList(); + std::vector itemlist= targetDesktop->selection->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { textItem = *i; @@ -688,7 +688,7 @@ void GlyphsPanel::selectionModifiedCB(guint flags) void GlyphsPanel::calcCanInsert() { int items = 0; - std::vector itemlist=targetDesktop->selection->itemList(); + std::vector itemlist= targetDesktop->selection->items(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { ++items; diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 639e463ea..ddcc20cb7 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -163,7 +163,7 @@ void GridArrangeTab::arrange() desktop->getDocument()->ensureUpToDate(); Inkscape::Selection *selection = desktop->getSelection(); - const std::vector items = selection ? selection->itemList() : std::vector(); + const std::vector items = selection ? selection->items() : std::vector(); for(std::vector::const_iterator i = items.begin();i!=items.end(); ++i){ SPItem *item = *i; Geom::OptRect b = item->documentVisualBounds(); @@ -192,7 +192,7 @@ void GridArrangeTab::arrange() // require the sorting done before we can calculate row heights etc. g_return_if_fail(selection); - std::vector sorted(selection->itemList()); + std::vector sorted(selection->items()); sort(sorted.begin(),sorted.end(),sp_compare_y_position); sort(sorted.begin(),sorted.end(),sp_compare_x_position); @@ -368,7 +368,7 @@ void GridArrangeTab::on_row_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); - std::vector const items = selection->itemList(); + std::vector const items = selection->items(); int selcount = items.size(); double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); @@ -394,7 +394,7 @@ void GridArrangeTab::on_col_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail(selection); - int selcount = selection->itemList().size(); + int selcount = selection->items().size(); double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); NoOfColsSpinner.set_value(PerRow); @@ -531,7 +531,7 @@ void GridArrangeTab::updateSelection() updating = true; SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; - std::vector const items = selection ? selection->itemList() : std::vector(); + std::vector const items = selection ? selection->items() : std::vector(); if (!items.empty()) { int selcount = items.size(); @@ -602,7 +602,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) g_return_if_fail( selection ); int selcount = 1; if (!selection->isEmpty()) { - selcount = selection->itemList().size(); + selcount = selection->items().size(); } diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 83656a1f2..173a964e9 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -362,7 +362,7 @@ void IconPreviewPanel::refreshPreview() if ( sel ) { //g_message("found a selection to play with"); - std::vector const items = sel->itemList(); + std::vector const items = sel->items(); for(std::vector::const_iterator i=items.begin();!target && i!=items.end();++i){ SPItem* item = *i; gchar const *id = item->getId(); diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 27694a9ac..df32f73cf 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -478,7 +478,7 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); SPItem *item = NULL; - std::vector const items = sel->itemList(); + std::vector const items = sel->items(); for(std::vector::const_iterator i=items.begin(); i!=items.end(); ++i){ item = *i; if (setOpacity) diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index f557ff0fc..ed62e26b0 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -372,7 +372,7 @@ void PixelArtDialogImpl::vectorize() return; } - std::vector const items = desktop->selection->itemList(); + std::vector const items = desktop->selection->items(); for(std::vector::const_iterator i=items.begin(); i!=items.end();++i){ if ( !SP_IS_IMAGE(*i) ) continue; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 5ec1285c1..c160c269f 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -297,7 +297,7 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { Inkscape::Selection *selection = parent->getDesktop()->getSelection(); - const std::vector tmp(selection->itemList()); + const std::vector tmp(selection->items()); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 790c0e5fb..100a620fa 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -524,7 +524,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ return; } - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node) return;//TODO: should this be an assert? if (!node->matchAttributeName("d") || !node->attribute("d")){ char *msg = _("The selected object does not have a path description."); @@ -566,7 +566,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ return; } - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node) return;//TODO: should this be an assert? if (!node->matchAttributeName("d") || !node->attribute("d")){ char *msg = _("The selected object does not have a path description."); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 6577c8d4e..2573719ac 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -123,7 +123,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) bool shown = false; if ( desktop && desktop->doc() ) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector const items = selection->itemList(); + std::vector const items = selection->items(); if (!items.empty()) { SPStyle query( desktop->doc() ); int result = objects_query_fillstroke((items), &query, true); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index affbe0a3b..98b0f9502 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -348,7 +348,7 @@ void TagsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); - auto tmp = sel->range(); + auto tmp = sel->objects(); for(auto i = tmp.begin(); i != tmp.end(); ++i) { SPObject *obj = *i; @@ -646,7 +646,7 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) if (col == _tree.get_column(COL_ADD - 1) && down_at_add) { if (SP_IS_TAG(obj)) { bool wasadded = false; - std::vector items=_desktop->selection->itemList(); + std::vector items= _desktop->selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index c01da8864..355bd16d1 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -443,7 +443,7 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - std::vector tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + std::vector tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) @@ -461,7 +461,7 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - std::vector tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + std::vector tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) @@ -568,7 +568,7 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const std::vector item_list = desktop->getSelection()->itemList(); + const std::vector item_list = desktop->getSelection()->items(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index b7638e8c1..f11ac1ebe 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -650,7 +650,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - Geom::Affine current (selection->itemList()[0]->transform); // take from the first item in selection + Geom::Affine current (selection->items()[0]->transform); // take from the first item in selection Geom::Affine new_displayed = current; @@ -735,7 +735,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { // shift each object relatively to the previous one - std::vector selected(selection->itemList()); + std::vector selected(selection->items()); if (selected.empty()) return; if (fabs(x) > 1e-6) { @@ -810,7 +810,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) bool transform_stroke = prefs->getBool("/options/transform/stroke", true); bool preserve = prefs->getBool("/options/preservetransform/value", false); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector tmp=selection->itemList(); + std::vector tmp= selection->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; Geom::OptRect bbox_pref = item->desktopPreferredBounds(); @@ -874,7 +874,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector tmp=selection->itemList(); + std::vector tmp= selection->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); @@ -894,7 +894,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i = items.begin();i!=items.end();++i){ SPItem *item = *i; @@ -996,7 +996,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) } if (_check_replace_matrix.get_active()) { - std::vector tmp=selection->itemList(); + std::vector tmp= selection->items(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; item->set_item_transform(displayed); @@ -1149,7 +1149,7 @@ void Transformation::onReplaceMatrixToggled() double f = _scalar_transform_f.getValue(); Geom::Affine displayed (a, b, c, d, e, f); - Geom::Affine current = selection->itemList()[0]->transform; // take from the first item in selection + Geom::Affine current = selection->items()[0]->transform; // take from the first item in selection Geom::Affine new_displayed; if (_check_replace_matrix.get_active()) { diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index ab29471ed..7bbf588a7 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -2096,7 +2096,7 @@ void ContextMenu::ImageEdit(void) } #endif - std::vector itemlist=_desktop->selection->itemList(); + std::vector itemlist= _desktop->selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ Inkscape::XML::Node *ir = (*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 74f2664fe..52ddd589c 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1306,7 +1306,7 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - std::vector l = selection->itemList(); + std::vector l = selection->items(); for(std::vector::const_iterator i=l.begin();i!=l.end(); ++i) { SPItem *item = *i; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index cb7747b2b..a81161ea9 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,7 +692,7 @@ void EraserTool::set_to_accumulated() { } } } else { - toWorkOn = selection->itemList(); + toWorkOn = selection->items(); } wasSelection = true; } @@ -744,7 +744,7 @@ void EraserTool::set_to_accumulated() { } if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - std::vector nowSel(selection->itemList()); + std::vector nowSel(selection->items()); for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { remainingItems.push_back(*i2); } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 9d8101cc4..e2bb0dc07 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -106,7 +106,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) { if (selection == NULL) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = selection->items().size(); if (!drag->isNonEmpty() || selection->isEmpty()) return; @@ -492,9 +492,9 @@ bool GradientTool::root_handler(GdkEvent* event) { if (over_line) { // we take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); + sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->items().front()), this->mousepoint_doc, event->button.time); } else { - std::vector items=selection->itemList(); + std::vector items= selection->items(); for (std::vector::const_iterator i = items.begin();i!=items.end();++i) { SPItem *item = *i; SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); @@ -897,7 +897,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector items(selection->itemList()); + std::vector items(selection->items()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -907,7 +907,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector itemlist = selection->itemList(); + std::vector itemlist = selection->items(); for (std::vector::const_iterator i = itemlist.begin();i!=itemlist.end();++i) { //FIXME: see above @@ -931,7 +931,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta ec->_grdrag->local_change = true; // give the grab out-of-bounds values of xp/yp because we're already dragging // and therefore are already out of tolerance - ec->_grdrag->grabKnot (selection->itemList()[0], + ec->_grdrag->grabKnot (selection->items()[0], type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1, -1, // ignore number (though it is always 1) fill_or_stroke, 99999, 99999, etime); @@ -940,7 +940,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->itemList().size(); + int n_objects = selection->items().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 9bbc1ac20..ebcac2279 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -396,7 +396,7 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 47927667c..9aaa0c14e 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -103,7 +103,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = selection->items().size(); if (!drag->isNonEmpty() || selection->isEmpty()) { return; @@ -467,10 +467,10 @@ bool MeshTool::root_handler(GdkEvent* event) { if (over_line) { // We take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->items()[0], this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; SPGradientType new_type = SP_GRADIENT_TYPE_MESH; @@ -945,7 +945,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector items(selection->itemList()); + std::vector items(selection->items()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -955,7 +955,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ //FIXME: see above @@ -972,7 +972,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->itemList().size(); + int n_objects = selection->items().size(); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Gradient for %d object; with Ctrl to snap angle", "Gradient for %d objects; with Ctrl to snap angle", n_objects), diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 23aaf6bb1..f7a725794 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -407,7 +407,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set shapes; - std::vector items=sel->itemList(); + std::vector items= sel->items(); for(std::vector::const_iterator i=items.begin();i!=items.end();++i){ SPObject *obj = *i; @@ -444,7 +444,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { } _previous_selection = _current_selection; - _current_selection = sel->itemList(); + _current_selection = sel->items(); this->_multipath->setItems(shapes); this->update_tip(NULL); diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index b5ec3d88e..676a41eaa 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -477,7 +477,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = selection->itemList()[0]; + SPItem *clicked_item = selection->items()[0]; if (dynamic_cast(clicked_item) && !dynamic_cast(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 9adaf3879..4f36a827f 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -210,7 +210,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -591,7 +591,7 @@ static bool fit_item(SPDesktop *desktop, if (selection->isEmpty()) { return false; } - std::vector const items_selected(selection->itemList()); + std::vector const items_selected(selection->items()); std::vector items_down_erased; for (std::vector::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) { SPItem *item_down = *i; @@ -1002,7 +1002,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator it=items.begin();it!=items.end(); ++it){ SPItem *item1 = *it; if (i == 1) { @@ -1170,7 +1170,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - std::vector const items(selection->itemList()); + std::vector const items(selection->items()); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1299,7 +1299,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 36fe26e76..6da6526bc 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1158,7 +1158,7 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, if (select_under) { SPItem *selected_at_point = desktop->getItemFromListAtPointBottom( - desktop->selection->itemList(), p); + desktop->selection->items(), p); item = desktop->getItemAtPoint(p, into_groups, selected_at_point); if (item == NULL) { // we may have reached bottom, flip over to the top item = desktop->getItemAtPoint(p, into_groups, NULL); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 39a7a3f0b..4da8060e2 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -153,7 +153,7 @@ void TweakTool::update_cursor (bool with_shift) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -1076,7 +1076,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point double move_force = get_move_force(tc); double color_force = MIN(sqrt(path_force)/20.0, 1); - std::vector items=selection->itemList(); + std::vector items= selection->items(); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1185,7 +1185,7 @@ bool TweakTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = desktop->selection->items().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to tweak.")); diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index 5f697e420..059d1a4e3 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -58,7 +58,7 @@ Inkscape::Selection *StyleSubject::Selection::_getSelection() const { std::vector StyleSubject::Selection::list() { Inkscape::Selection *selection = _getSelection(); if(selection) { - return std::vector(selection->range().begin(), selection->range().end()); + return std::vector(selection->objects().begin(), selection->objects().end()); } return std::vector(); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 32ccbad93..a6be353f8 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -258,7 +258,7 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list sel_boxes; - std::vector itemlist=sel->itemList(); + std::vector itemlist= sel->items(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast(item); @@ -397,7 +397,7 @@ VPDragger::VPsOfSelectedBoxes() { VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); - std::vector itemlist=sel->itemList(); + std::vector itemlist= sel->items(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast(item); @@ -575,7 +575,7 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - std::vector itemlist=this->selection->itemList(); + std::vector itemlist= this->selection->items(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast(item); @@ -607,7 +607,7 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - std::vector itemlist=this->selection->itemList(); + std::vector itemlist= this->selection->items(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast(item); @@ -625,7 +625,7 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - std::vector sel = selection->itemList(); + std::vector sel = selection->items(); if (sel.empty()) return; // no selection diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 7b872e8b1..5db714f85 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -97,7 +97,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL); bool modmade = false; - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { @@ -163,7 +163,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) bool modmade = false; if ( ege_select_one_action_get_active(act) != 0 ) { - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { @@ -174,7 +174,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } } } else { - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { @@ -264,7 +264,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb purge_repr_listener( tbl, tbl ); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 733fb34e8..54b4be547 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -97,7 +97,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl gchar *value = is_orthog ? orthog_str : polyline_str ; bool modmade = false; - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; @@ -144,7 +144,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) g_ascii_dtostr(value, G_ASCII_DTOSTR_BUF_SIZE, newValue); bool modmade = false; - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; @@ -227,7 +227,7 @@ static void sp_connector_graph_layout(void) int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(SP_ACTIVE_DESKTOP->getSelection()->itemList()); + graphlayout(SP_ACTIVE_DESKTOP->getSelection()->items()); prefs->setInt("/options/clonecompensation/value", saved_compensation); diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index a96776894..8c3a0a0a8 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -476,7 +476,7 @@ void FillNStroke::updateFromPaint() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - std::vector const items = selection->itemList(); + std::vector const items = selection->items(); switch (psel->mode) { case SPPaintSelector::MODE_EMPTY: diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index a44e9962e..ab345b73f 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -116,7 +116,7 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient } // If no drag or no dragger selected, act on selection - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ gr_apply_gradient_to_item(*i, gr, initialType, initialMode, initialMode); } @@ -216,7 +216,7 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr { SPGradient *gradient = 0; - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; @@ -284,7 +284,7 @@ void gr_read_selection( Inkscape::Selection *selection, } // If no selected dragger, read desktop selection - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; SPStyle *style = item->style; diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 3643ce00c..5d326253c 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -89,7 +89,7 @@ void ms_read_selection( Inkscape::Selection *selection, bool first = true; ms_type = SP_MESH_TYPE_COONS; - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; SPStyle *style = item->style; @@ -216,7 +216,7 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_sel { SPMesh *gradient = 0; - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 55127206c..34cebbe1b 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -240,7 +240,7 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GObject *obj) static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj) { SPDesktop *desktop = static_cast(g_object_get_data(obj, "desktop")); - std::vector selected = desktop->getSelection()->itemList(); + std::vector selected = desktop->getSelection()->items(); for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast(*it); if (lpeitem && lpeitem->hasPathEffect()){ @@ -285,7 +285,7 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb gtk_adjustment_get_value(adj)); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop")); - std::vector selected = desktop->getSelection()->itemList(); + std::vector selected = desktop->getSelection()->items(); for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast(*it); if (lpeitem && lpeitem->hasPathEffect()){ diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index bc27d003c..2ee38608b 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -106,7 +106,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ if (SP_IS_RECT(*i)) { if (gtk_adjustment_get_value(adj) != 0) { @@ -243,7 +243,7 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO } purge_repr_listener( tbl, tbl ); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ if (SP_IS_RECT(*i)) { n_selected++; diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 7e7398091..8f5f10bf8 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -79,7 +79,7 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL); bool modmade = false; - std::vector itemlist=desktop->getSelection()->itemList(); + std::vector itemlist= desktop->getSelection()->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ SPItem *item = *i; if (SP_IS_SPIRAL(item)) { @@ -195,7 +195,7 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, purge_repr_listener( tbl, tbl ); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ SPItem *item = *i; if (SP_IS_SPIRAL(item)) { diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 982a3c854..fc8757162 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -83,7 +83,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { @@ -128,7 +128,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { @@ -185,7 +185,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d gtk_action_set_visible( prop_action, !flat ); } - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { @@ -224,7 +224,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { @@ -264,7 +264,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { @@ -367,7 +367,7 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) purge_repr_listener( tbl, tbl ); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 84a6e77ad..7ed2c3180 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -515,7 +515,7 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using @@ -988,7 +988,7 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - std::vector const objects = sel->itemList(); + std::vector const objects = sel->items(); SPObject * const object = objects[0]; SPStyle * const style = object->style; @@ -1044,7 +1044,7 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - std::vector items=selection->itemList(); + std::vector items= selection->items(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 23acb74af..3d08b04f1 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -378,7 +378,7 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) // move the x of all texts to preserve the same bbox Inkscape::Selection *selection = desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT(*i)) { SPItem *item = *i; @@ -560,7 +560,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Only need to save for undo if a text item has been changed. Inkscape::Selection *selection = desktop->getSelection(); bool modmade = false; - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { modmade = true; @@ -625,7 +625,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Selection *selection = desktop->getSelection(); - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); // Convert between units if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_EX) { @@ -1120,7 +1120,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Only flowed text can be justified, only normal text can be kerned... // Find out if we have flowed text now so we can use it several places gboolean isFlow = false; - std::vector itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + std::vector itemlist= SP_ACTIVE_DESKTOP->getSelection()->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ // const gchar* id = reinterpret_cast(items->data)->getId(); // std::cout << " " << id << std::endl; -- cgit v1.2.3 From a51df2ab1eb079b2588ccb9398440f403d11c34d Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Mon, 27 Jun 2016 16:59:48 +0200 Subject: Added more tests (bzr r14954.1.11) --- src/object-set.cpp | 28 +--------------------------- src/object-set.h | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/object-set.cpp b/src/object-set.cpp index 627544a21..518ce15a3 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -174,13 +174,8 @@ bool ObjectSet::isEmpty() { return container.size() == 0; } - SPObject *ObjectSet::single() { - if (container.size() == 1) { - return *container.begin(); - } - - return nullptr; + return container.size() == 1 ? *container.begin() : nullptr; } SPItem *ObjectSet::singleItem() { @@ -257,27 +252,6 @@ void ObjectSet::set(SPObject *object) { // _emitSignals(); } -void ObjectSet::setList(const std::vector &objs) { - _clear(); - addList(objs); -} - -void ObjectSet::addList(const std::vector &objs) { - for (std::vector::const_iterator iter = objs.begin(); iter != objs.end(); ++iter) { - SPObject *obj = *iter; - if (!includes(obj)) { - add(obj); - } - } -} - -void ObjectSet::add(const std::vector::iterator& from, const std::vector::iterator& to) { - for(auto it = from; it != to; ++it) { - _add(*it); - } -} - - Geom::OptRect ObjectSet::bounds(SPItem::BBoxType type) const { return (type == SPItem::GEOMETRIC_BBOX) ? diff --git a/src/object-set.h b/src/object-set.h index 49a875562..29083863b 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #include "sp-object.h" #include "sp-item.h" @@ -84,7 +86,12 @@ public: * \param from the begin iterator * \param to the end iterator */ - void add(const std::vector::iterator& from, const std::vector::iterator& to); + template + void add(InputIterator from, InputIterator to) { + for(auto it = from; it != to; ++it) { + _add(*it); + } + } /** * Removes an item from the set of selected objects. @@ -176,14 +183,27 @@ public: * * @param objs the objects to select */ - void setList(const std::vector &objs); + template + typename boost::enable_if, void>::type + setList(const std::vector &objs) { + _clear(); + addList(objs); + } /** * Adds the specified objects to selection, without deselecting first. * * @param objs the objects to select */ - void addList(std::vector const &objs); + template + typename boost::enable_if, void>::type + addList(const std::vector &objs) { + for (auto obj: objs) { + if (!includes(obj)) { + add(obj); + } + } + } /** Returns the bounding rectangle of the selection. */ Geom::OptRect bounds(SPItem::BBoxType type) const; -- cgit v1.2.3 From 22262f2db6747eb516283b92abcfd348c700911a Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Fri, 1 Jul 2016 20:57:32 +0200 Subject: Added xmlNodes as range function (bzr r14954.1.12) --- src/object-set.cpp | 9 ++----- src/object-set.h | 45 +++++++++++++++++++++++---------- src/selection-chemistry.cpp | 20 +++++++-------- src/splivarot.cpp | 2 +- src/ui/dialog/export.cpp | 9 +++---- src/ui/dialog/filter-effects-dialog.cpp | 2 +- 6 files changed, 50 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/object-set.cpp b/src/object-set.cpp index 518ce15a3..1240e5198 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -15,6 +15,8 @@ #include "box3d.h" #include "persp3d.h" #include "preferences.h" +#include +#include namespace Inkscape { @@ -233,13 +235,6 @@ std::vector ObjectSet::items() { return result; } -std::vector ObjectSet::xmlNodes() { - std::vector list = items(); - std::vector result; - std::transform(list.begin(), list.end(), std::back_inserter(result), [](SPItem* item) { return item->getRepr(); }); - return result; -} - Inkscape::XML::Node *ObjectSet::singleRepr() { SPObject *obj = single(); return obj ? obj->getRepr() : nullptr; diff --git a/src/object-set.h b/src/object-set.h index 29083863b..ea6534350 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include #include @@ -39,6 +41,26 @@ class Node; struct hashed{}; struct random_access{}; +struct is_item { + bool operator()(SPObject* obj) { + return SP_IS_ITEM(obj); + } +}; + +struct object_to_item { + typedef SPItem* result_type; + SPItem* operator()(SPObject* obj) const { + return SP_ITEM(obj); + } +}; + +struct object_to_node { + typedef XML::Node* result_type; + XML::Node* operator()(SPObject* obj) const { + return obj->getRepr(); + } +}; + typedef boost::multi_index_container< SPObject*, boost::multi_index::indexed_by< @@ -56,21 +78,11 @@ typedef boost::any_range< SPObject* const&, std::ptrdiff_t> SPObjectRange; -typedef boost::any_range< - SPItem*, - boost::random_access_traversal_tag, - SPItem* const&, - std::ptrdiff_t> SPItemRange; - -typedef boost::any_range< - XML::Node*, - boost::random_access_traversal_tag, - XML::Node* const&, - std::ptrdiff_t> XMLNodeRange; - class ObjectSet { public: enum CompareSize {HORIZONTAL, VERTICAL, AREA}; + typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_item())) SPItemRange; + typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())) XMLNodeRange; ObjectSet() {}; virtual ~ObjectSet(); @@ -169,7 +181,11 @@ public: std::vector items(); /** Returns a list of the xml nodes of all selected objects. */ - std::vector xmlNodes(); + XMLNodeRange xmlNodes() { + return XMLNodeRange(container.get() + | boost::adaptors::filtered(is_item()) + | boost::adaptors::transformed(object_to_node())); + } /** * Returns a single selected object's xml node. @@ -255,6 +271,9 @@ protected: }; +typedef ObjectSet::SPItemRange SPItemRange; +typedef ObjectSet::XMLNodeRange XMLNodeRange; + } // namespace Inkscape #endif //INKSCAPE_PROTOTYPE_OBJECTSET_H diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index ded776fea..82f89c03a 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -454,7 +454,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to duplicate.")); return; } - std::vector reprs(selection->xmlNodes()); + std::vector reprs(selection->xmlNodes().begin(), selection->xmlNodes().end()); if(duplicateLayer){ reprs.clear(); @@ -763,7 +763,7 @@ void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) return; } - std::vector p (selection->xmlNodes()); + std::vector p (selection->xmlNodes().begin(), selection->xmlNodes().end()); selection->clear(); @@ -1048,7 +1048,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - std::vector rl(selection->xmlNodes()); + std::vector rl(selection->xmlNodes().begin(), selection->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector::const_iterator l=rl.begin(); l!=rl.end();++l) { @@ -1132,7 +1132,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - std::vector rl(selection->xmlNodes()); + std::vector rl(selection->xmlNodes().begin(), selection->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector::const_reverse_iterator l=rl.rbegin();l!=rl.rend();++l) { @@ -1722,8 +1722,8 @@ void sp_selection_remove_transform(SPDesktop *desktop) Inkscape::Selection *selection = desktop->getSelection(); - std::vector items = selection->xmlNodes(); - for (std::vector::const_iterator l=items.begin();l!=items.end() ;++l) { + auto items = selection->xmlNodes(); + for (auto l=items.begin();l!=items.end() ;++l) { (*l)->setAttribute("transform", NULL, false); } @@ -2603,7 +2603,7 @@ void sp_selection_clone(SPDesktop *desktop) return; } - std::vector reprs (selection->xmlNodes()); + std::vector reprs(selection->xmlNodes().begin(), selection->xmlNodes().end()); selection->clear(); @@ -3472,12 +3472,12 @@ void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring return; } - std::vector const reprlst = selection->xmlNodes(); + auto reprlst = selection->xmlNodes(); bool filename_search = TRUE; bool xdpi_search = TRUE; bool ydpi_search = TRUE; - for (std::vector::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();++i){ + for (auto i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();++i){ gchar const *dpi_string; Inkscape::XML::Node *repr = *i; @@ -3765,7 +3765,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) return; } - std::vector p(selection->xmlNodes()); + std::vector p(selection->xmlNodes().begin(), selection->xmlNodes().end()); sort(p.begin(),p.end(),sp_repr_compare_position_bool); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index d4ef3f9c2..09d74a010 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -689,7 +689,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } } else { // find out the bottom object - std::vector sorted(selection->xmlNodes()); + std::vector sorted(selection->xmlNodes().begin(), selection->xmlNodes().end()); sort(sorted.begin(),sorted.end(),sp_repr_compare_position_bool); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 6d2842511..dbee80af9 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -820,8 +820,8 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes(); - for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { + auto reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes(); + for(auto i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { id = repr->attribute("id"); @@ -1231,15 +1231,14 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - std::vector reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; bool saved = DocumentUndo::getUndoSensitive(doc); DocumentUndo::setUndoSensitive(doc, false); - reprlst = desktop->getSelection()->xmlNodes(); + auto reprlst = desktop->getSelection()->xmlNodes(); - for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { + for(auto i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; const gchar * temp_string; Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index dfc19f3cc..ccba5a278 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -691,7 +691,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = sel->xmlNodes()[0]; + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; -- cgit v1.2.3 From 058e95a59ccb2ab1748392acdfdbbffd516c9c81 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Mon, 11 Jul 2016 14:24:52 +0200 Subject: First part of new SPObject children list (bzr r14954.1.17) --- src/layer-fns.cpp | 36 +++++------- src/object-set.cpp | 18 +++--- src/selection-chemistry.cpp | 6 +- src/sp-item-group.cpp | 5 +- src/sp-item.cpp | 41 ++++--------- src/sp-mask.cpp | 15 ++--- src/sp-object.cpp | 124 ++++++++++++++++++++++----------------- src/sp-object.h | 29 +++++---- src/ui/widget/layer-selector.cpp | 20 ++----- src/uri-references.cpp | 2 +- 10 files changed, 139 insertions(+), 157 deletions(-) (limited to 'src') diff --git a/src/layer-fns.cpp b/src/layer-fns.cpp index 3e794a0a4..d149089db 100644 --- a/src/layer-fns.cpp +++ b/src/layer-fns.cpp @@ -36,11 +36,9 @@ bool is_layer(SPObject &object) { * @returns NULL if there are no further layers under a parent */ SPObject *next_sibling_layer(SPObject *layer) { - using std::find_if; - - return find_if( - layer->getNext(), NULL, &is_layer - ); + SPObject::ChildrenList &list = layer->parent->_children; + auto l = std::find_if(++list.iterator_to(*layer), list.end(), &is_layer); + return l != list.end() ? &*l : nullptr; } /** Finds the previous sibling layer for a \a layer @@ -50,11 +48,9 @@ SPObject *next_sibling_layer(SPObject *layer) { SPObject *previous_sibling_layer(SPObject *layer) { using Inkscape::Algorithms::find_last_if; - SPObject *sibling(find_last_if( - layer->parent->firstChild(), layer, &is_layer - )); - - return ( sibling != layer ) ? sibling : NULL; + SPObject::ChildrenList &list = layer->parent->_children; + auto l = find_last_if(list.begin(), list.iterator_to(*layer), &is_layer); + return l != list.iterator_to(*layer) ? &*(l) : nullptr; } /** Finds the first child of a \a layer @@ -62,16 +58,15 @@ SPObject *previous_sibling_layer(SPObject *layer) { * @returns NULL if layer has no sublayers */ SPObject *first_descendant_layer(SPObject *layer) { - using std::find_if; - - SPObject *first_descendant=NULL; - while (layer) { - layer = find_if( - layer->firstChild(), NULL, &is_layer - ); - if (layer) { + SPObject *first_descendant = nullptr; + while (true) { + auto tmp = std::find_if(layer->_children.begin(), layer->_children.end(), &is_layer); + if (tmp != layer->_children.end()) { first_descendant = layer; + } else { + break; } + layer = &*tmp; } return first_descendant; @@ -84,9 +79,8 @@ SPObject *first_descendant_layer(SPObject *layer) { SPObject *last_child_layer(SPObject *layer) { using Inkscape::Algorithms::find_last_if; - return find_last_if( - layer->firstChild(), NULL, &is_layer - ); + auto l = find_last_if(layer->_children.begin(), layer->_children.end(), &is_layer); + return l != layer->_children.end() ? &*l : nullptr; } SPObject *last_elder_layer(SPObject *root, SPObject *layer) { diff --git a/src/object-set.cpp b/src/object-set.cpp index 07f9ea0c8..b7b84e163 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -93,14 +93,14 @@ bool ObjectSet::_anyAncestorIsInSet(SPObject *object) { } void ObjectSet::_removeDescendantsFromSet(SPObject *object) { - for (auto& child: object->childList(false)) { - if (includes(child)) { - _remove(child); + for (auto& child: object->_children) { + if (includes(&child)) { + _remove(&child); // there is certainly no children of this child in the set continue; } - _removeDescendantsFromSet(child); + _removeDescendantsFromSet(&child); } } @@ -130,8 +130,8 @@ SPObject *ObjectSet::_getMutualAncestor(SPObject *object) { bool flag = true; while (o->parent != nullptr) { - for (auto &child: o->parent->childList(false)) { - if(child != o && !includes(child)) { + for (auto &child: o->parent->_children) { + if(&child != o && !includes(&child)) { flag = false; break; } @@ -147,9 +147,9 @@ SPObject *ObjectSet::_getMutualAncestor(SPObject *object) { void ObjectSet::_removeAncestorsFromSet(SPObject *object) { SPObject* o = object; while (o->parent != nullptr) { - for (auto &child: o->parent->childList(false)) { - if (child != o) { - _add(child); + for (auto &child: o->parent->_children) { + if (&child != o) { + _add(&child); } } if (includes(o->parent)) { diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 4b5c3f921..1f34f798d 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -4261,11 +4261,11 @@ static void itemtree_map(void (*f)(SPItem *, SPDesktop *), SPObject *root, SPDes f(item, desktop); } } - for ( SPObject::SiblingIterator iter = root->firstChild() ; iter ; ++iter ) { + for (auto& child: root->_children) { //don't recurse into locked layers - SPItem *item = dynamic_cast(&*iter); + SPItem *item = dynamic_cast(&child); if (!(item && desktop->isLayer(item) && item->isLocked())) { - itemtree_map(f, iter, desktop); + itemtree_map(f, &child, desktop); } } } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 70d2bc732..d775e306f 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -297,9 +297,8 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } void SPGroup::print(SPPrintContext *ctx) { - std::vector l=this->childList(false); - for(std::vector::const_iterator i=l.begin();i!=l.end();++i){ - SPObject *o = *i; + for(auto& child: _children){ + SPObject *o = &child; SPItem *item = dynamic_cast(o); if (item) { item->invoke_print(ctx); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 9fd6e8ecc..258a5cd14 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -308,50 +308,35 @@ bool is_item(SPObject const &object) { void SPItem::raiseToTop() { using Inkscape::Algorithms::find_last_if; - SPObject *topmost=find_last_if( - next, NULL, &is_item - ); - if (topmost) { + auto topmost = find_last_if(++parent->_children.iterator_to(*this), parent->_children.end(), &is_item); + if (topmost != parent->_children.end()) { getRepr()->parent()->changeOrder( getRepr(), topmost->getRepr() ); } } void SPItem::raiseOne() { - SPObject *next_higher=std::find_if( - next, NULL, &is_item - ); - if (next_higher) { + auto next_higher = std::find_if(++parent->_children.iterator_to(*this), parent->_children.end(), &is_item); + if (next_higher != parent->_children.end()) { Inkscape::XML::Node *ref = next_higher->getRepr(); getRepr()->parent()->changeOrder(getRepr(), ref); } } void SPItem::lowerOne() { - using Inkscape::Util::MutableList; - using Inkscape::Util::reverse_list; - - MutableList next_lower=std::find_if( - reverse_list( - parent->firstChild(), this - ), - MutableList(), - &is_item - ); - if (next_lower) { - ++next_lower; - Inkscape::XML::Node *ref = ( next_lower ? next_lower->getRepr() : NULL ); + using Inkscape::Algorithms::find_last_if; + + auto next_lower = find_last_if(parent->_children.begin(), parent->_children.iterator_to(*this), &is_item); + if (next_lower != parent->_children.iterator_to(*this)) { + next_lower--; + Inkscape::XML::Node *ref = next_lower->getRepr(); getRepr()->parent()->changeOrder(getRepr(), ref); } } void SPItem::lowerToBottom() { - using Inkscape::Algorithms::find_last_if; - using Inkscape::Util::MutableList; - using Inkscape::Util::reverse_list; - - SPObject * bottom=parent->firstChild(); - while(dynamic_cast(bottom) && dynamic_cast(bottom->next) && bottom!=this && !is_item(*(bottom->next))) bottom=bottom->next; - if (bottom && bottom != this) { + auto bottom = std::find_if(parent->_children.begin(), parent->_children.iterator_to(*this), &is_item); + if (bottom != parent->_children.iterator_to(*this)) { + bottom--; Inkscape::XML::Node *ref = bottom->getRepr() ; parent->getRepr()->changeOrder(getRepr(), ref); } diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 3537c7bac..a36d8ef29 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -138,12 +138,8 @@ void SPMask::update(SPCtx* ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - std::vector children = this->childList(false); - for (std::vector::const_iterator child = children.begin();child != children.end();++child) { - sp_object_ref(*child); - } - - + std::vector children = this->childList(true); + for (std::vector::const_iterator child = children.begin();child != children.end();++child) { if (flags || ((*child)->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { (*child)->updateDisplay(ctx, flags); @@ -172,11 +168,8 @@ void SPMask::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - std::vector children = this->childList(false); - for (std::vector::const_iterator child = children.begin();child != children.end();++child) { - sp_object_ref(*child); - } - + std::vector children = this->childList(true); + for (std::vector::const_iterator child = children.begin();child != children.end();++child) { if (flags || ((*child)->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { (*child)->emitModified(flags); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index d1659eedc..36957ab49 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -7,8 +7,9 @@ * Stephen Silver * Jon A. Cruz * Abhishek Sharma + * Adrian Boguszewski * - * Copyright (C) 1999-2008 authors + * Copyright (C) 1999-2016 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -16,6 +17,7 @@ #include #include +#include #include "helper/sp-marshal.h" #include "xml/node-event-vector.h" @@ -398,13 +400,12 @@ void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr) } std::vector SPObject::childList(bool add_ref, Action) { - std::vector l; - for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { + std::vector l; + for (auto& child: _children) { if (add_ref) { - sp_object_ref (child); + sp_object_ref(&child); } - - l.push_back(child); + l.push_back(&child); } return l; @@ -467,9 +468,9 @@ void SPObject::requestOrphanCollection() { } void SPObject::_sendDeleteSignalRecursive() { - for (SPObject *child = firstChild(); child; child = child->getNext()) { - child->_delete_signal.emit(child); - child->_sendDeleteSignalRecursive(); + for (auto& child: _children) { + child._delete_signal.emit(&child); + child._sendDeleteSignalRecursive(); } } @@ -497,12 +498,12 @@ void SPObject::deleteObject(bool propagate, bool propagate_descendants) void SPObject::cropToObject(SPObject *except) { std::vector toDelete; - for ( SPObject *child = this->firstChild(); child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - if (child->isAncestorOf(except)) { - child->cropToObject(except); - } else if(child != except) { - toDelete.push_back(child); + for (auto& child: _children) { + if (SP_IS_ITEM(&child)) { + if (child.isAncestorOf(except)) { + child.cropToObject(except); + } else if(&child != except) { + toDelete.push_back(&child); } } } @@ -525,6 +526,12 @@ void SPObject::attach(SPObject *object, SPObject *prev) object->parent = this; this->_updateTotalHRefCount(object->_total_hrefcount); + auto it = _children.begin(); + if (prev != nullptr) { + it = ++_children.iterator_to(*prev); + } + _children.insert(it, *object); + SPObject *next; if (prev) { next = prev->next; @@ -541,43 +548,47 @@ void SPObject::attach(SPObject *object, SPObject *prev) object->xml_space.value = this->xml_space.value; } -void SPObject::reorder(SPObject *prev) -{ - //g_return_if_fail(object != NULL); - //g_return_if_fail(SP_IS_OBJECT(object)); - g_return_if_fail(this->parent != NULL); - g_return_if_fail(this != prev); - g_return_if_fail(!prev || SP_IS_OBJECT(prev)); - g_return_if_fail(!prev || prev->parent == this->parent); +void SPObject::reorder(SPObject* obj, SPObject* prev) { + g_return_if_fail(obj != nullptr); + g_return_if_fail(obj->parent); + g_return_if_fail(obj->parent == this); + g_return_if_fail(obj != prev); + g_return_if_fail(!prev || prev->parent == obj->parent); + + auto it = _children.begin(); + if (prev != nullptr) { + it = ++_children.iterator_to(*prev); + } + + _children.splice(it, _children, _children.iterator_to(*obj)); - SPObject *const parent=this->parent; SPObject *old_prev=NULL; - for ( SPObject *child = parent->children ; child && child != this ; + for ( SPObject *child = children ; child && child != obj ; child = child->next ) { old_prev = child; } - SPObject *next=this->next; + SPObject *next=obj->next; if (old_prev) { old_prev->next = next; } else { - parent->children = next; + children = next; } if (!next) { - parent->_last_child = old_prev; + _last_child = old_prev; } if (prev) { next = prev->next; - prev->next = this; + prev->next = obj; } else { - next = parent->children; - parent->children = this; + next = children; + children = obj; } - this->next = next; + obj->next = next; if (!next) { - parent->_last_child = this; + _last_child = obj; } } @@ -589,6 +600,7 @@ void SPObject::detach(SPObject *object) g_return_if_fail(SP_IS_OBJECT(object)); g_return_if_fail(object->parent == this); + _children.erase(_children.iterator_to(*object)); object->releaseReferences(); SPObject *prev=NULL; @@ -618,14 +630,14 @@ void SPObject::detach(SPObject *object) SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) { g_return_val_if_fail(repr != NULL, NULL); - SPObject *result = 0; + SPObject *result = nullptr; - if ( _last_child && (_last_child->getRepr() == repr) ) { - result = _last_child; // optimization for common scenario + if (_children.size() > 0 && _children.back().getRepr() == repr) { + result = &_children.back(); // optimization for common scenario } else { - for ( SPObject *child = children ; child ; child = child->next ) { - if ( child->getRepr() == repr ) { - result = child; + for (auto& child: _children) { + if (child.getRepr() == repr) { + result = &child; break; } } @@ -656,10 +668,12 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) void SPObject::release() { SPObject* object = this; - debug("id=%p, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); - while (object->children) { - object->detach(object->children); + auto tmp = _children | boost::adaptors::transformed([](SPObject& obj){return &obj;}); + std::vector toRelease(tmp.begin(), tmp.end()); + + for (auto& p: toRelease) { + object->detach(p); } } @@ -680,7 +694,7 @@ void SPObject::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node * / SPObject *ochild = object->get_child_by_repr(child); g_return_if_fail(ochild != NULL); SPObject *prev = new_ref ? object->get_child_by_repr(new_ref) : NULL; - ochild->reorder(prev); + object->reorder(ochild, prev); ochild->_position_changed_signal.emit(ochild); } @@ -1523,33 +1537,33 @@ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool return true; } -SPObject * SPObject::findFirstChild(gchar const *tagname) const +SPObject* SPObject::findFirstChild(gchar const *tagname) const { - for (SPObject *child = children; child; child = child->next) + for (auto& child: const_cast(this)->_children) { - if (child->repr->type() == Inkscape::XML::ELEMENT_NODE && - !strcmp(child->repr->name(), tagname)) { - return child; + if (child.repr->type() == Inkscape::XML::ELEMENT_NODE && + !strcmp(child.repr->name(), tagname)) { + return &child; } } - return NULL; + return nullptr; } char* SPObject::textualContent() const { GString* text = g_string_new(""); - for (const SPObject *child = firstChild(); child; child = child->next) + for (auto& child: _children) { - Inkscape::XML::NodeType child_type = child->repr->type(); + Inkscape::XML::NodeType child_type = child.repr->type(); if (child_type == Inkscape::XML::ELEMENT_NODE) { - char* new_string = child->textualContent(); + char* new_string = child.textualContent(); g_string_append(text, new_string); g_free(new_string); } else if (child_type == Inkscape::XML::TEXT_NODE) { - g_string_append(text, child->repr->content()); + g_string_append(text, child.repr->content()); } } return g_string_free(text, FALSE); @@ -1566,8 +1580,8 @@ void SPObject::recursivePrintTree( unsigned level ) std::cout << " "; } std::cout << (getId()?getId():"No object id") << std::endl; - for (SPObject *child = children; child; child = child->next) { - child->recursivePrintTree( level+1 ); + for (auto& child: _children) { + child.recursivePrintTree(level + 1); } } diff --git a/src/sp-object.h b/src/sp-object.h index 70d3e5df5..6aa006283 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -6,8 +6,9 @@ * Lauris Kaplinski * Jon A. Cruz * Abhishek Sharma + * Adrian Boguszewski * - * Copyright (C) 1999-2002 authors + * Copyright (C) 1999-2016 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -53,6 +54,7 @@ class SPObject; #include #include #include +#include #include "version.h" #include "util/forward-pointer-iterator.h" @@ -216,6 +218,7 @@ private: char *id; /* Our very own unique id */ Inkscape::XML::Node *repr; /* Our xml representation */ + public: int refCount; std::list hrefList; @@ -279,17 +282,9 @@ public: return object->parent; } }; - /// Switch containing next() method. - struct SiblingIteratorStrategy { - static SPObject const *next(SPObject const *object) { - return object->next; - } - }; typedef Inkscape::Util::ForwardPointerIterator ParentIterator; typedef Inkscape::Util::ForwardPointerIterator ConstParentIterator; - typedef Inkscape::Util::ForwardPointerIterator SiblingIterator; - typedef Inkscape::Util::ForwardPointerIterator ConstSiblingIterator; bool isSiblingOf(SPObject const *object) const { if (object == NULL) return false; @@ -317,7 +312,7 @@ public: */ SPObject *getPrev(); - bool hasChildren() const { return ( children != NULL ); } + bool hasChildren() const { return ( _children.size() > 0 ); } SPObject *firstChild() { return children; } SPObject const *firstChild() const { return children; } @@ -681,9 +676,9 @@ public: void attach(SPObject *object, SPObject *prev); /** - * In list of object's siblings, move object behind prev. + * In list of object's children, move object behind prev. */ - void reorder(SPObject *prev); + void reorder(SPObject* obj, SPObject *prev); /** * Remove object from parent's children, release and unref it. @@ -858,7 +853,17 @@ protected: virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); + typedef boost::intrusive::list_member_hook<> ListHook; + ListHook _child_hook; public: + typedef boost::intrusive::list< + SPObject, + boost::intrusive::member_hook< + SPObject, + ListHook, + &SPObject::_child_hook + >> ChildrenList; + ChildrenList _children; virtual void read_content(); void recursivePrintTree(unsigned level = 0); // For debugging diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 1a9ce617f..46a0b3547 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -19,6 +19,8 @@ #include "ui/dialog/layer-properties.h" #include +#include +#include #include "desktop.h" @@ -348,27 +350,17 @@ void LayerSelector::_buildSiblingEntries( unsigned depth, SPObject &parent, Inkscape::Util::List hierarchy ) { - using Inkscape::Util::List; using Inkscape::Util::rest; - using Inkscape::Util::reverse_list_in_place; - using Inkscape::Util::filter_list; - Inkscape::Util::List siblings( - reverse_list_in_place( - filter_list( - is_layer(_desktop), parent.firstChild(), NULL - ) - ) - ); + auto siblings = parent._children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed; SPObject *layer( hierarchy ? &*hierarchy : NULL ); - while (siblings) { - _buildEntry(depth, *siblings); - if ( &*siblings == layer ) { + for (auto& sib: siblings) { + _buildEntry(depth, sib); + if ( &sib == layer ) { _buildSiblingEntries(depth+1, *layer, rest(hierarchy)); } - ++siblings; } } diff --git a/src/uri-references.cpp b/src/uri-references.cpp index db46a156f..078834131 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -92,7 +92,7 @@ bool URIReference::_acceptObject(SPObject *obj) const g_warning("cloned object with no known type\n"); return false; } - for (int i = positions.size() - 2; i >= 0; i--) + for (int i = (int) (positions.size() - 2); i >= 0; i--) owner = owner->childList(false)[positions[i]]; } // once we have the "original" object (hopefully) we look at who is referencing it -- 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/box3d.cpp | 20 ++-- src/conn-avoid-ref.cpp | 18 ++-- src/desktop-style.cpp | 25 ++--- src/document.cpp | 96 +++++++++---------- src/extension/internal/cairo-render-context.cpp | 23 +++-- src/extension/internal/cairo-renderer.cpp | 8 +- src/extension/internal/emf-print.cpp | 14 ++- src/extension/internal/javafx-out.cpp | 8 +- src/extension/internal/pov-out.cpp | 4 +- src/file.cpp | 16 ++-- src/filter-chemistry.cpp | 14 ++- src/gradient-chemistry.cpp | 20 ++-- src/gradient-drag.cpp | 4 +- src/helper/pixbuf-ops.cpp | 4 +- src/helper/png-write.cpp | 4 +- src/helper/stock-items.cpp | 30 +++--- src/id-clash.cpp | 8 +- src/libnrtype/font-lister.cpp | 4 +- src/live_effects/lpe-perspective_path.cpp | 10 +- src/main.cpp | 4 +- src/object-snapper.cpp | 8 +- src/object-test.h | 1 - src/persp3d.cpp | 13 +-- src/selection-chemistry.cpp | 43 +++++---- src/sp-clippath.cpp | 30 +++--- src/sp-defs.cpp | 14 +-- src/sp-filter.cpp | 8 +- src/sp-flowdiv.cpp | 120 ++++++++++++------------ src/sp-flowregion.cpp | 53 +++++------ src/sp-flowtext.cpp | 54 +++++------ src/sp-gradient.cpp | 41 ++++---- src/sp-hatch.cpp | 17 ++-- src/sp-item-group.cpp | 61 ++++++------ src/sp-item.cpp | 22 ++--- src/sp-mask.cpp | 12 +-- src/sp-mesh-array.cpp | 34 +++---- src/sp-namedview.cpp | 12 +-- src/sp-object-group.cpp | 8 +- src/sp-object.cpp | 22 +---- src/sp-object.h | 9 +- src/sp-pattern.cpp | 30 +++--- src/sp-root.cpp | 15 +-- src/sp-switch.cpp | 7 +- src/sp-text.cpp | 54 +++++------ src/sp-tref.cpp | 6 +- src/sp-tspan.cpp | 80 ++++++++-------- src/splivarot.cpp | 6 +- src/text-chemistry.cpp | 6 +- src/text-editing.cpp | 53 ++++++----- src/ui/clipboard.cpp | 4 +- src/ui/dialog/clonetiler.cpp | 24 ++--- src/ui/dialog/filter-effects-dialog.cpp | 23 ++--- src/ui/dialog/find.cpp | 10 +- src/ui/dialog/font-substitution.cpp | 2 +- src/ui/dialog/objects.cpp | 6 +- src/ui/dialog/spellcheck.cpp | 12 +-- src/ui/dialog/symbols.cpp | 8 +- src/ui/tools/box3d-tool.cpp | 4 +- src/ui/tools/connector-tool.cpp | 6 +- src/ui/tools/tweak-tool.cpp | 16 ++-- src/widgets/gradient-toolbar.cpp | 12 +-- src/widgets/gradient-vector.cpp | 28 +++--- src/widgets/stroke-marker-selector.cpp | 6 +- 63 files changed, 669 insertions(+), 665 deletions(-) (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index c4c2728e4..0a33ee306 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -259,8 +259,8 @@ void box3d_position_set(SPBox3D *box) { /* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in box3d_side_position_set() to avoid update conflicts with the parent box) */ - for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) { - Box3DSide *side = dynamic_cast(obj); + for (auto& obj: box->_children) { + Box3DSide *side = dynamic_cast(&obj); if (side) { box3d_side_position_set(side); } @@ -275,8 +275,8 @@ Geom::Affine SPBox3D::set_transform(Geom::Affine const &xform) { gdouble const sw = hypot(ret[0], ret[1]); gdouble const sh = hypot(ret[2], ret[3]); - for ( SPObject *child = firstChild(); child; child = child->getNext() ) { - SPItem *childitem = dynamic_cast(child); + for (auto& child: _children) { + SPItem *childitem = dynamic_cast(&child); if (childitem) { // Adjust stroke width childitem->adjust_stroke(sqrt(fabs(sw * sh))); @@ -1074,8 +1074,8 @@ box3d_recompute_z_orders (SPBox3D *box) { static std::map box3d_get_sides(SPBox3D *box) { std::map sides; - for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) { - Box3DSide *side = dynamic_cast(obj); + for (auto& obj: box->_children) { + Box3DSide *side = dynamic_cast(&obj); if (side) { sides[Box3D::face_to_int(side->getFaceId())] = side; } @@ -1217,8 +1217,8 @@ static void box3d_extract_boxes_rec(SPObject *obj, std::list &boxes) if (box) { boxes.push_back(box); } else if (dynamic_cast(obj)) { - for ( SPObject *child = obj->firstChild(); child; child = child->getNext() ) { - box3d_extract_boxes_rec(child, boxes); + for (auto& child: obj->_children) { + box3d_extract_boxes_rec(&child, boxes); } } } @@ -1276,8 +1276,8 @@ SPGroup *box3d_convert_to_group(SPBox3D *box) // create a new group and add the sides (converted to ordinary paths) as its children Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); - for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) { - Box3DSide *side = dynamic_cast(obj); + for (auto& obj: box->_children) { + Box3DSide *side = dynamic_cast(&obj); if (side) { Inkscape::XML::Node *repr = box3d_side_convert_to_path(side); grepr->appendChild(repr); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 9190fe633..638ba48e3 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -334,19 +334,19 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) std::vector get_avoided_items(std::vector &list, SPObject *from, SPDesktop *desktop, bool initialised) { - for (SPObject *child = from->firstChild() ; child != NULL; child = child->next ) { - if (SP_IS_ITEM(child) && - !desktop->isLayer(SP_ITEM(child)) && - !SP_ITEM(child)->isLocked() && - !desktop->itemIsHidden(SP_ITEM(child)) && - (!initialised || SP_ITEM(child)->avoidRef->shapeRef) + for (auto& child: from->_children) { + if (SP_IS_ITEM(&child) && + !desktop->isLayer(SP_ITEM(&child)) && + !SP_ITEM(&child)->isLocked() && + !desktop->itemIsHidden(SP_ITEM(&child)) && + (!initialised || SP_ITEM(&child)->avoidRef->shapeRef) ) { - list.push_back(SP_ITEM(child)); + list.push_back(SP_ITEM(&child)); } - if (SP_IS_ITEM(child) && desktop->isLayer(SP_ITEM(child))) { - list = get_avoided_items(list, child, desktop, initialised); + if (SP_IS_ITEM(&child) && desktop->isLayer(SP_ITEM(&child))) { + list = get_avoided_items(list, &child, desktop, initialised); } } diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 885d17c21..a52ab3d76 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -163,17 +163,17 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines) return; } - for ( SPObject *child = o->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: o->_children) { if (sp_repr_css_property(css, "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. SPCSSAttr *css_recurse = sp_repr_css_attr_new(); sp_repr_css_merge(css_recurse, css); sp_repr_css_set_property(css_recurse, "opacity", NULL); - sp_desktop_apply_css_recursive(child, css_recurse, skip_lines); + sp_desktop_apply_css_recursive(&child, css_recurse, skip_lines); sp_repr_css_attr_unref(css_recurse); } else { - sp_desktop_apply_css_recursive(child, css, skip_lines); + sp_desktop_apply_css_recursive(&child, css, skip_lines); } } } @@ -1714,10 +1714,11 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) int blendcount = 0; // determine whether filter is simple (blend and/or blur) or complex - for(SPObject *primitive_obj = style->getFilter()->children; - primitive_obj && dynamic_cast(primitive_obj); - primitive_obj = primitive_obj->next) { - SPFilterPrimitive *primitive = dynamic_cast(primitive_obj); + for(auto& primitive_obj: style->getFilter()->_children) { + SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); + if (!primitive) { + break; + } if (dynamic_cast(primitive)) { ++blendcount; } else if (dynamic_cast(primitive)) { @@ -1730,10 +1731,12 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) // simple filter if(blurcount == 1 || blendcount == 1) { - for(SPObject *primitive_obj = style->getFilter()->children; - primitive_obj && dynamic_cast(primitive_obj); - primitive_obj = primitive_obj->next) { - SPFeBlend *spblend = dynamic_cast(primitive_obj); + for(auto& primitive_obj: style->getFilter()->_children) { + SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); + if (!primitive) { + break; + } + SPFeBlend *spblend = dynamic_cast(&primitive_obj); if (spblend) { blend = spblend->blend_mode; } 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; diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 5d8b0e076..bedf2fa7f 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -986,13 +986,12 @@ void CairoRenderContext::popState(void) static bool pattern_hasItemChildren(SPPattern *pat) { - bool hasItems = false; - for ( SPObject *child = pat->firstChild() ; child && !hasItems; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - hasItems = true; + for (auto& child: pat->_children) { + if (SP_IS_ITEM (&child)) { + return true; } } - return hasItems; + return false; } cairo_pattern_t* @@ -1087,10 +1086,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); - _renderer->renderItem(pattern_ctx, SP_ITEM(child)); + for (auto& child: pat_i->_children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); + _renderer->renderItem(pattern_ctx, SP_ITEM(&child)); } } break; // do not go further up the chain if children are found @@ -1116,9 +1115,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // hide all items for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(dkey); + for (auto& child: pat_i->_children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(dkey); } } break; // do not go further up the chain if children are found diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 5dc20ab06..088eaf11d 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -741,8 +741,8 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) TRACE(("BEGIN clip\n")); SPObject const *co = cp; - for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { - SPItem const *item = dynamic_cast(child); + for (auto& child: co->_children) { + SPItem const *item = dynamic_cast(&child); if (item) { // combine transform of the item in clippath and the item using clippath: @@ -800,8 +800,8 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) TRACE(("BEGIN mask\n")); SPObject const *co = mask; - for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { - SPItem const *item = dynamic_cast(child); + for (auto& child: co->_children) { + SPItem const *item = dynamic_cast(&child); if (item) { // TODO fix const correctness: renderItem(ctx, const_cast(item)); diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 9f3b5475f..c0c086c7a 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -1042,8 +1042,12 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ /* find the clipping path */ Geom::PathVector combined_pathvector; Geom::Affine tfc; // clipping transform, generally not the same as item transform - for(item = SP_ITEM(scp->firstChild()); item; item=SP_ITEM(item->getNext())){ - if (SP_IS_GROUP(item)) { // not implemented + for (auto& child: scp->_children) { + item = SP_ITEM(&child); + if (!item) { + break; + } + if (SP_IS_GROUP(item)) { // not implemented // return sp_group_render(item); combined_pathvector = merge_PathVector_with_group(combined_pathvector, item, tfc); } else if (SP_IS_SHAPE(item)) { @@ -1081,7 +1085,11 @@ Geom::PathVector PrintEmf::merge_PathVector_with_group(Geom::PathVector const &c new_combined_pathvector = combined_pathvector; SPGroup *group = SP_GROUP(item); Geom::Affine tfc = item->transform * transform; - for(SPItem *item = SP_ITEM(group->firstChild()); item; item=SP_ITEM(item->getNext())){ + for (auto& child: group->_children) { + item = SP_ITEM(&child); + if (!item) { + break; + } if (SP_IS_GROUP(item)) { new_combined_pathvector = merge_PathVector_with_group(new_combined_pathvector, item, tfc); // could be endlessly recursive on a badly formed SVG } else if (SP_IS_SHAPE(item)) { diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 386bde1d6..51608e4fa 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -732,9 +732,9 @@ bool JavaFXOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->_children) { - if (!doTreeRecursive(doc, child)) { + if (!doTreeRecursive(doc, &child)) { return false; } } @@ -804,9 +804,9 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->_children) { - if (!doBody(doc, child)) { + if (!doBody(doc, &child)) { return false; } } diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index bd2168b68..08f533010 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -479,9 +479,9 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->_children) { - if (!doTreeRecursive(doc, child)) + if (!doTreeRecursive(doc, &child)) return false; } diff --git a/src/file.cpp b/src/file.cpp index 650ce5d0f..11e5f0a42 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1204,8 +1204,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; - for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext()) { - if (SP_IS_ITEM(child)) { + for (auto& child: doc->getRoot()->_children) { + if (SP_IS_ITEM(&child)) { items_count++; } } @@ -1234,9 +1234,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - Inkscape::XML::Node *newitem = child->getRepr()->duplicate(xml_in_doc); + for (auto& child: doc->getRoot()->_children) { + if (SP_IS_ITEM(&child)) { + Inkscape::XML::Node *newitem = child.getRepr()->duplicate(xml_in_doc); // convert layers to groups, and make sure they are unlocked // FIXME: add "preserve layers" mode where each layer from @@ -1249,10 +1249,10 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } // don't lose top-level defs or style elements - else if (child->getRepr()->type() == Inkscape::XML::ELEMENT_NODE) { - const gchar *tag = child->getRepr()->name(); + else if (child.getRepr()->type() == Inkscape::XML::ELEMENT_NODE) { + const gchar *tag = child.getRepr()->name(); if (!strcmp(tag, "svg:style")) { - in_doc->getRoot()->appendChildRepr(child->getRepr()->duplicate(xml_in_doc)); + in_doc->getRoot()->appendChildRepr(child.getRepr()->duplicate(xml_in_doc)); } } } diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 9298a1ffc..2e99842ec 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -51,8 +51,8 @@ static guint count_filter_hrefs(SPObject *o, SPFilter *filter) i ++; } - for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) { - i += count_filter_hrefs(child, filter); + for (auto& child: o->_children) { + i += count_filter_hrefs(&child, filter); } return i; @@ -491,16 +491,14 @@ void remove_filter_gaussian_blur (SPObject *item) bool filter_is_single_gaussian_blur(SPFilter *filter) { - return (filter->firstChild() && - (filter->firstChild() == filter->lastChild()) && - SP_IS_GAUSSIANBLUR(filter->firstChild())); + return (filter->_children.size() == 1 && + SP_IS_GAUSSIANBLUR(&filter->_children.front())); } double get_single_gaussian_blur_radius(SPFilter *filter) { - if (filter->firstChild() && - (filter->firstChild() == filter->lastChild()) && - SP_IS_GAUSSIANBLUR(filter->firstChild())) { + if (filter->_children.size() == 1 && + SP_IS_GAUSSIANBLUR(&filter->_children.front())) { SPGaussianBlur *gb = SP_GAUSSIANBLUR(filter->firstChild()); double x = gb->stdDeviation.getNumber(); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 59d715149..9c46a2efb 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -199,8 +199,8 @@ static guint count_gradient_hrefs(SPObject *o, SPGradient *gr) i ++; } - for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) { - i += count_gradient_hrefs(child, gr); + for (auto& child: o->_children) { + i += count_gradient_hrefs(&child, gr); } return i; @@ -926,11 +926,11 @@ void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or GSList *child_objects = NULL; std::vector offsets; double offset; - for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) { - child_reprs = g_slist_prepend (child_reprs, child->getRepr()); - child_objects = g_slist_prepend (child_objects, child); + for (auto& child: vector->_children) { + child_reprs = g_slist_prepend (child_reprs, child.getRepr()); + child_objects = g_slist_prepend (child_objects, &child); offset=0; - sp_repr_get_double(child->getRepr(), "offset", &offset); + sp_repr_get_double(child.getRepr(), "offset", &offset); offsets.push_back(offset); } @@ -979,9 +979,9 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi sp_gradient_repr_set_link(gradient->getRepr(), vector); } - for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) { - if (SP_IS_STOP(child)) { - guint32 color = SP_STOP(child)->get_rgba32(); + for (auto& child: vector->_children) { + if (SP_IS_STOP(&child)) { + guint32 color = SP_STOP(&child)->get_rgba32(); //g_message("Stop color %d", color); gchar c[64]; sp_svg_write_color (c, sizeof(c), @@ -994,7 +994,7 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi ); SPCSSAttr *css = sp_repr_css_attr_new (); sp_repr_css_set_property (css, "stop-color", c); - sp_repr_css_change(child->getRepr(), css, "style"); + sp_repr_css_change(child.getRepr(), css, "style"); sp_repr_css_attr_unref (css); } } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 555bde786..b9d1fe109 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2539,9 +2539,9 @@ void GrDrag::deleteSelected(bool just_one) // cannot use vector->vector.stops.size() because the vector might be invalidated by deletion of a midstop // manually count the children, don't know if there already exists a function for this... int len = 0; - for ( SPObject *child = (stopinfo->vector)->firstChild() ; child ; child = child->getNext() ) + for (auto& child: stopinfo->vector->_children) { - if ( SP_IS_STOP(child) ) { + if ( SP_IS_STOP(&child) ) { len ++; } } diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 9639096fb..fb1740fc5 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -53,8 +53,8 @@ static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dke // recurse if (!g_slist_find(list, o)) { - for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { - hide_other_items_recursively(child, list, dkey); + for (auto& child: o->_children) { + hide_other_items_recursively(&child, list, dkey); } } } diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 9430feeff..c59db9df6 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -374,8 +374,8 @@ static void hide_other_items_recursively(SPObject *o, const std::vector // recurse if (list.end()==find(list.begin(),list.end(),o)) { - for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { - hide_other_items_recursively(child, list, dkey); + for (auto& child: o->_children) { + hide_other_items_recursively(&child, list, dkey); } } } diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 5a56b89ff..cf10a6c4d 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -204,37 +204,37 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) } SPObject *object = NULL; if (!strcmp(base, "marker") && !stock) { - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) + for (auto& child: defs->_children) { - if (child->getRepr()->attribute("inkscape:stockid") && - !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) && - SP_IS_MARKER(child)) + if (child.getRepr()->attribute("inkscape:stockid") && + !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && + SP_IS_MARKER(&child)) { - object = child; + object = &child; } } } else if (!strcmp(base,"pattern") && !stock) { - for ( SPObject *child = defs->firstChild() ; child; child = child->getNext() ) + for (auto& child: defs->_children) { - if (child->getRepr()->attribute("inkscape:stockid") && - !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) && - SP_IS_PATTERN(child)) + if (child.getRepr()->attribute("inkscape:stockid") && + !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && + SP_IS_PATTERN(&child)) { - object = child; + object = &child; } } } else if (!strcmp(base,"gradient") && !stock) { - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) + for (auto& child: defs->_children) { - if (child->getRepr()->attribute("inkscape:stockid") && - !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) && - SP_IS_GRADIENT(child)) + if (child.getRepr()->attribute("inkscape:stockid") && + !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && + SP_IS_GRADIENT(&child)) { - object = child; + object = &child; } } diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 4bd66e858..fecad9eee 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -187,9 +187,9 @@ find_references(SPObject *elem, refmap_type &refmap) } // recurse - for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) + for (auto& child: elem->_children) { - find_references(child, refmap); + find_references(&child, refmap); } } @@ -242,9 +242,9 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, // recurse - for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) + for (auto& child: elem->_children) { - change_clashing_ids(imported_doc, current_doc, child, refmap, id_changes); + change_clashing_ids(imported_doc, current_doc, &child, refmap, id_changes); } } diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 568a7c8cc..937d67895 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -298,8 +298,8 @@ void FontLister::update_font_list_recursive(SPObject *r, std::listpush_back(Glib::ustring(font_family)); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - update_font_list_recursive(child, l); + for (auto& child: r->_children) { + update_font_list_recursive(&child, l); } } diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index c8cdd7912..c62ead2b3 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -107,12 +107,12 @@ void LPEPerspectivePath::refresh(Gtk::Entry* perspective) { perspectiveID = perspective->get_text(); Persp3D *first = 0; Persp3D *persp = 0; - for ( SPObject *child = this->lpeobj->document->getDefs()->firstChild(); child && !persp; child = child->getNext() ) { - if (SP_IS_PERSP3D(child) && first == 0) { - first = SP_PERSP3D(child); + for (auto& child: lpeobj->document->getDefs()->_children) { + if (SP_IS_PERSP3D(&child) && first == 0) { + first = SP_PERSP3D(&child); } - if (SP_IS_PERSP3D(child) && strcmp(child->getId(), const_cast(perspectiveID.c_str())) == 0) { - persp = SP_PERSP3D(child); + if (SP_IS_PERSP3D(&child) && strcmp(child.getId(), const_cast(perspectiveID.c_str())) == 0) { + persp = SP_PERSP3D(&child); break; } } diff --git a/src/main.cpp b/src/main.cpp index 8cf52127b..db908f640 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1228,8 +1228,8 @@ static int sp_process_file_list(GSList *fl) std::vector items; SPRoot *root = doc->getRoot(); doc->ensureUpToDate(); - for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { - SPItem* item = (SPItem*) iter; + for (auto& iter: root->_children) { + SPItem* item = (SPItem*) &iter; if (! (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item) || SP_IS_GROUP(item))) { continue; } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 3e559ee7a..580fb5fc7 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -90,9 +90,9 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, Geom::Rect bbox_to_snap_incl = bbox_to_snap; // _incl means: will include the snapper tolerance bbox_to_snap_incl.expandBy(getSnapperTolerance()); // see? - for ( SPObject *o = parent->firstChild(); o; o = o->getNext() ) { + for (auto& o: parent->_children) { g_assert(dt != NULL); - SPItem *item = dynamic_cast(o); + SPItem *item = dynamic_cast(&o); if (item && !(dt->itemIsHidden(item) && !clip_or_mask)) { // Snapping to items in a locked layer is allowed // Don't snap to hidden objects, unless they're a clipped path or a mask @@ -100,7 +100,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, std::vector::const_iterator i; if (it != NULL) { i = it->begin(); - while (i != it->end() && *i != o) { + while (i != it->end() && *i != &o) { ++i; } } @@ -122,7 +122,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, } if (dynamic_cast(item)) { - _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine); + _findCandidates(&o, it, false, bbox_to_snap, clip_or_mask, additional_affine); } else { Geom::OptRect bbox_of_item; Preferences *prefs = Preferences::get(); diff --git a/src/object-test.h b/src/object-test.h index 4f0be3251..0af823684 100644 --- a/src/object-test.h +++ b/src/object-test.h @@ -115,7 +115,6 @@ public: prev = next; next = next->getNext(); } - TS_ASSERT(child->lastChild() == next); // Test hrefcount TS_ASSERT(path->isReferenced()); diff --git a/src/persp3d.cpp b/src/persp3d.cpp index a48481145..849e332bf 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -215,9 +215,10 @@ Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// Persp3D *persp3d_document_first_persp(SPDocument *document) { Persp3D *first = 0; - for ( SPObject *child = document->getDefs()->firstChild(); child && !first; child = child->getNext() ) { - if (SP_IS_PERSP3D(child)) { - first = SP_PERSP3D(child); + for (auto& child: document->getDefs()->_children) { + if (SP_IS_PERSP3D(&child)) { + first = SP_PERSP3D(&child); + break; } } return first; @@ -533,9 +534,9 @@ persp3d_print_debugging_info (Persp3D *persp) { void persp3d_print_debugging_info_all(SPDocument *document) { - for ( SPObject *child = document->getDefs()->firstChild(); child; child = child->getNext() ) { - if (SP_IS_PERSP3D(child)) { - persp3d_print_debugging_info(SP_PERSP3D(child)); + for (auto& child: document->getDefs()->_children) { + if (SP_IS_PERSP3D(&child)) { + persp3d_print_debugging_info(SP_PERSP3D(&child)); } } persp3d_print_all_selected(); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 1f34f798d..55f4118b0 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -88,6 +88,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include #include #include +#include #include "sp-item.h" #include "box3d.h" #include "persp3d.h" @@ -432,8 +433,8 @@ static void add_ids_recursive(std::vector &ids, SPObject *obj) ids.push_back(obj->getId()); if (dynamic_cast(obj)) { - for (SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { - add_ids_recursive(ids, child); + for (auto& child: obj->_children) { + add_ids_recursive(ids, &child); } } } @@ -586,20 +587,20 @@ void sp_edit_clear_all(Inkscape::Selection *selection) */ std::vector &get_all_items(std::vector &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector const &exclude) { - for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { - SPItem *item = dynamic_cast(child); + for (auto& child: from->_children) { + SPItem *item = dynamic_cast(&child); if (item && !desktop->isLayer(item) && (!onlysensitive || !item->isLocked()) && (!onlyvisible || !desktop->itemIsHidden(item)) && - (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child)) + (exclude.empty() || exclude.end() == std::find(exclude.begin(), exclude.end(), &child)) ) { list.insert(list.begin(),item); } if (ingroups || (item && desktop->isLayer(item))) { - list = get_all_items(list, child, desktop, onlyvisible, onlysensitive, ingroups, exclude); + list = get_all_items(list, &child, desktop, onlyvisible, onlysensitive, ingroups, exclude); } } @@ -1200,9 +1201,10 @@ take_style_from_item(SPObject *object) (dynamic_cast(object) && object->children && object->children->next == NULL)) { // if this is a text with exactly one tspan child, merge the style of that tspan as well // If this is a group, merge the style of its topmost (last) child with style - for (SPObject *last_element = object->lastChild(); last_element != NULL; last_element = last_element->getPrev()) { - if ( last_element->style ) { - SPCSSAttr *temp = sp_css_attr_from_object(last_element, SP_STYLE_FLAG_IFSET); + auto list = object->_children | boost::adaptors::reversed; + for (auto& element: list) { + if (element.style ) { + SPCSSAttr *temp = sp_css_attr_from_object(&element, SP_STYLE_FLAG_IFSET); if (temp) { sp_repr_css_merge(css, temp); sp_repr_css_attr_unref(temp); @@ -1621,10 +1623,10 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } else if (transform_flowtext_with_frame) { // apply the inverse of the region's transform to the so that the flow remains // the same (even though the output itself gets transformed) - for ( SPObject *region = item->firstChild() ; region ; region = region->getNext() ) { - if (dynamic_cast(region) || dynamic_cast(region)) { - for ( SPObject *item = region->firstChild() ; item ; item = item->getNext() ) { - SPUse *use = dynamic_cast(item); + for (auto& region: item->_children) { + if (dynamic_cast(®ion) || dynamic_cast(®ion)) { + for (auto& itm: region._children) { + SPUse *use = dynamic_cast(&itm); if ( use ) { use->doWriteTransform(use->getRepr(), use->transform.inverse(), NULL, compensate); } @@ -2702,8 +2704,9 @@ sp_selection_unlink(SPDesktop *desktop) // Get a copy of current selection. std::vector new_select; bool unlinked = false; - auto items= selection->items(); - for (auto i=boost::rbegin(items);i!=boost::rend(items);++i){ + std::vector items(selection->items().begin(), selection->items().end()); + + for (auto i=items.rbegin();i!=items.rend();++i){ SPItem *item = *i; if (dynamic_cast(item)) { @@ -3432,9 +3435,9 @@ void sp_selection_untile(SPDesktop *desktop) Geom::Affine pat_transform = basePat->getTransform(); pat_transform *= item->transform; - for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) { - if (dynamic_cast(child)) { - Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc); + for (auto& child: pattern->_children) { + if (dynamic_cast(&child)) { + Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc); SPItem *i = dynamic_cast(desktop->currentLayer()->appendChildRepr(copy)); // FIXME: relink clones to the new canvas objects @@ -4100,9 +4103,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for ( std::map::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { SPObject *obj = (*it).first; // Group containing the clipped paths or masks GSList *items_to_move = NULL; - for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { + for (auto& child: obj->_children) { // Collect all clipped paths and masks within a single group - Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc); if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect")) { copy->setAttribute("d", copy->attribute("inkscape:original-d")); diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 0c07d1b3d..25bf77f00 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -128,9 +128,9 @@ void SPClipPath::update(SPCtx* ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild(); child; child = child->getNext()) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -167,9 +167,9 @@ void SPClipPath::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (SPObject *child = this->firstChild(); child; child = child->getNext()) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -200,9 +200,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); display = sp_clippath_view_new_prepend(display, key, ai); - for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS); + for (auto& child: _children) { + if (SP_IS_ITEM(&child)) { + Inkscape::DrawingItem *ac = SP_ITEM(&child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in clippath */ @@ -223,9 +223,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int } void SPClipPath::hide(unsigned int key) { - for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(key); + for (auto& child: _children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(key); } } @@ -252,9 +252,9 @@ void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) { Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) { Geom::OptRect bbox; - for (SPObject *i = firstChild(); i; i = i->getNext()) { - if (SP_IS_ITEM(i)) { - Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform); + for (auto& i: _children) { + if (SP_IS_ITEM(&i)) { + Geom::OptRect tmp = SP_ITEM(&i)->geometricBounds(Geom::Affine(SP_ITEM(&i)->transform) * transform); bbox.unionWith(tmp); } } diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index dd779c0da..af4ea96d7 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -54,9 +54,9 @@ void SPDefs::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -79,8 +79,8 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X } GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: _children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); } @@ -93,8 +93,8 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X } } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: _children) { + child.updateRepr(flags); } } diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index c17c67fc5..da3f12f5f 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -268,8 +268,8 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML } GSList *l = NULL; - for ( SPObject *child = this->firstChild(); child; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(doc, NULL, flags); + for (auto& child: _children) { + Inkscape::XML::Node *crepr = child.updateRepr(doc, NULL, flags); if (crepr) { l = g_slist_prepend (l, crepr); @@ -282,8 +282,8 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML l = g_slist_remove (l, l->data); } } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: _children) { + child.updateRepr(flags); } } diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index 8d9c51ab8..ad04f0d78 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -27,9 +27,9 @@ void SPFlowdiv::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -65,9 +65,9 @@ void SPFlowdiv::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -104,15 +104,15 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape GSList *l = NULL; - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: _children) { Inkscape::XML::Node* c_repr = NULL; - if ( SP_IS_FLOWTSPAN (child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_FLOWPARA(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_FLOWTSPAN (&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -126,13 +126,13 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape l = g_slist_remove(l, l->data); } } else { - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_FLOWTSPAN (child) ) { - child->updateRepr(flags); - } else if ( SP_IS_FLOWPARA(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: _children) { + if ( SP_IS_FLOWTSPAN (&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -168,9 +168,9 @@ void SPFlowtspan::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -206,9 +206,9 @@ void SPFlowtspan::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -242,15 +242,15 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca GSList *l = NULL; - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: _children) { Inkscape::XML::Node* c_repr = NULL; - if ( SP_IS_FLOWTSPAN(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_FLOWPARA(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_FLOWTSPAN(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -264,13 +264,13 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca l = g_slist_remove(l, l->data); } } else { - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_FLOWTSPAN(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_FLOWPARA(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: _children) { + if ( SP_IS_FLOWTSPAN(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -307,9 +307,9 @@ void SPFlowpara::update(SPCtx *ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -343,9 +343,9 @@ void SPFlowpara::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -379,15 +379,15 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap GSList *l = NULL; - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: _children) { Inkscape::XML::Node* c_repr = NULL; - if ( SP_IS_FLOWTSPAN(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_FLOWPARA(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_FLOWTSPAN(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -401,13 +401,13 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap l = g_slist_remove(l, l->data); } } else { - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_FLOWTSPAN(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_FLOWPARA(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: _children) { + if ( SP_IS_FLOWTSPAN(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 5715e5eb1..71e029072 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -63,9 +63,9 @@ void SPFlowregion::update(SPCtx *ctx, unsigned int flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -102,9 +102,9 @@ void SPFlowregion::UpdateComputed(void) } computed.clear(); - for (SPObject* child = firstChild() ; child ; child = child->getNext() ) { + for (auto& child: _children) { Shape *shape = 0; - GetDest(child, &shape); + GetDest(&child, &shape); computed.push_back(shape); } } @@ -118,9 +118,9 @@ void SPFlowregion::modified(guint flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -145,9 +145,9 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc } GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - if ( !dynamic_cast(child) && !dynamic_cast(child) ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: _children) { + if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -161,10 +161,9 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc l = g_slist_remove(l, l->data); } - } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - if ( !dynamic_cast(child) && !dynamic_cast(child) ) { - child->updateRepr(flags); + for (auto& child: _children) { + if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { + child.updateRepr(flags); } } } @@ -221,9 +220,9 @@ void SPFlowregionExclude::update(SPCtx *ctx, unsigned int flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -259,8 +258,8 @@ void SPFlowregionExclude::UpdateComputed(void) computed = NULL; } - for ( SPObject* child = firstChild() ; child ; child = child->getNext() ) { - GetDest(child, &computed); + for (auto& child: _children) { + GetDest(&child, &computed); } } @@ -273,9 +272,9 @@ void SPFlowregionExclude::modified(guint flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -301,8 +300,8 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: _children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -316,8 +315,8 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc } } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: _children) { + child.updateRepr(flags); } } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 51fb3ae89..eed882800 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -72,9 +72,9 @@ void SPFlowtext::update(SPCtx* ctx, unsigned int flags) { GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -135,9 +135,9 @@ void SPFlowtext::modified(unsigned int flags) { } } - for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast(o)) { - region = o; + for (auto& o: _children) { + if (dynamic_cast(&o)) { + region = &o; break; } } @@ -223,11 +223,11 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: _children) { Inkscape::XML::Node *c_repr = NULL; - if ( dynamic_cast(child) || dynamic_cast(child) || dynamic_cast(child) || dynamic_cast(child)) { - c_repr = child->updateRepr(doc, NULL, flags); + if ( dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child)) { + c_repr = child.updateRepr(doc, NULL, flags); } if ( c_repr ) { @@ -241,9 +241,9 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X l = g_slist_remove(l, l->data); } } else { - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if ( dynamic_cast(child) || dynamic_cast(child) || dynamic_cast(child) || dynamic_cast(child)) { - child->updateRepr(flags); + for (auto& child: _children) { + if ( dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child)) { + child.updateRepr(flags); } } } @@ -390,8 +390,8 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, *pending_line_break_object = NULL; } - for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) { - SPString *str = dynamic_cast(child); + for (auto& child: root->_children) { + SPString *str = dynamic_cast(&child); if (str) { if (*pending_line_break_object) { if (dynamic_cast(*pending_line_break_object)) @@ -402,12 +402,12 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, *pending_line_break_object = NULL; } if (with_indent) { - layout.appendText(str->string, root->style, child, &pi); + layout.appendText(str->string, root->style, &child, &pi); } else { - layout.appendText(str->string, root->style, child); + layout.appendText(str->string, root->style, &child); } } else { - SPFlowregion *region = dynamic_cast(child); + SPFlowregion *region = dynamic_cast(&child); if (region) { std::vector const &computed = region->computed; for (std::vector::const_iterator it = computed.begin() ; it != computed.end() ; ++it) { @@ -421,8 +421,8 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, } } //Xml Tree is being directly used while it shouldn't be. - else if (!dynamic_cast(child) && !sp_repr_is_meta_element(child->getRepr())) { - _buildLayoutInput(child, exclusion_shape, shapes, pending_line_break_object); + else if (!dynamic_cast(&child) && !sp_repr_is_meta_element(child.getRepr())) { + _buildLayoutInput(&child, exclusion_shape, shapes, pending_line_break_object); } } } @@ -593,9 +593,9 @@ SPItem *SPFlowtext::get_frame(SPItem const *after) SPItem *frame = 0; SPObject *region = 0; - for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast(o)) { - region = o; + for (auto& o: _children) { + if (dynamic_cast(&o)) { + region = &o; break; } } @@ -603,8 +603,8 @@ SPItem *SPFlowtext::get_frame(SPItem const *after) if (region) { bool past = false; - for (SPObject *o = region->firstChild() ; o ; o = o->getNext() ) { - SPItem *item = dynamic_cast(o); + for (auto& o: region->_children) { + SPItem *item = dynamic_cast(&o); if (item) { if ( (after == NULL) || past ) { frame = item; @@ -707,9 +707,9 @@ Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) } SPObject *region = NULL; - for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast(o)) { - region = o; + for (auto& o: _children) { + if (dynamic_cast(&o)) { + region = &o; break; } } diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 854d53dc4..abfae1a1f 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -276,8 +276,8 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr) SPPaintServer::build(document, repr); - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: _children) { + if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } @@ -481,8 +481,8 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) SPPaintServer::remove_child(child); this->has_stops = FALSE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: _children) { + if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } @@ -536,9 +536,9 @@ void SPGradient::modified(guint flags) // FIXME: climb up the ladder of hrefs GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: _children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -557,10 +557,11 @@ void SPGradient::modified(guint flags) SPStop* SPGradient::getFirstStop() { - SPStop* first = 0; - for (SPObject *ochild = firstChild(); ochild && !first; ochild = ochild->getNext()) { - if (SP_IS_STOP(ochild)) { - first = SP_STOP(ochild); + SPStop* first = nullptr; + for (auto& ochild: _children) { + if (SP_IS_STOP(&ochild)) { + first = SP_STOP(&ochild); + break; } } return first; @@ -587,8 +588,8 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (SPObject *child = this->firstChild(); child; child = child->getNext()) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: _children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -915,8 +916,8 @@ bool SPGradient::invalidateArray() void SPGradient::rebuildVector() { gint len = 0; - for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_STOP(child)) { + for (auto& child: _children) { + if (SP_IS_STOP(&child)) { len ++; } } @@ -937,9 +938,9 @@ void SPGradient::rebuildVector() } } - for ( SPObject *child = firstChild(); child; child = child->getNext() ) { - if (SP_IS_STOP(child)) { - SPStop *stop = SP_STOP(child); + for (auto& child: _children) { + if (SP_IS_STOP(&child)) { + SPStop *stop = SP_STOP(&child); SPGradientStop gstop; if (!vector.stops.empty()) { @@ -1022,8 +1023,8 @@ void SPGradient::rebuildArray() array.read( SP_MESH( this ) ); has_patches = false; - for ( SPObject *ro = firstChild() ; ro ; ro = ro->getNext() ) { - if (SP_IS_MESHROW(ro)) { + for (auto& ro: _children) { + if (SP_IS_MESHROW(&ro)) { has_patches = true; // std::cout << " Has Patches" << std::endl; break; diff --git a/src/sp-hatch.cpp b/src/sp-hatch.cpp index 2d938618c..c06045e8f 100644 --- a/src/sp-hatch.cpp +++ b/src/sp-hatch.cpp @@ -233,14 +233,13 @@ void SPHatch::set(unsigned int key, const gchar* value) bool SPHatch::_hasHatchPatchChildren(SPHatch const *hatch) { - bool matched = false; - for (SPObject const *child = hatch->firstChild(); child && !matched; child = child->getNext() ) { - SPHatchPath const *hatchPath = dynamic_cast(child); + for (auto& child: hatch->_children) { + SPHatchPath const *hatchPath = dynamic_cast(&child); if (hatchPath) { - matched = true; + return true; } } - return matched; + return false; } std::vector SPHatch::hatchPaths() @@ -249,8 +248,8 @@ std::vector SPHatch::hatchPaths() SPHatch *src = chase_hrefs(this, sigc::ptr_fun(&_hasHatchPatchChildren)); if (src) { - for (SPObject *child = src->firstChild(); child; child = child->getNext()) { - SPHatchPath *hatchPath = dynamic_cast(child); + for (auto& child: src->_children) { + SPHatchPath *hatchPath = dynamic_cast(&child); if (hatchPath) { list.push_back(hatchPath); } @@ -265,8 +264,8 @@ std::vector SPHatch::hatchPaths() const SPHatch const *src = chase_hrefs(this, sigc::ptr_fun(&_hasHatchPatchChildren)); if (src) { - for (SPObject const *child = src->firstChild(); child; child = child->getNext()) { - SPHatchPath const *hatchPath = dynamic_cast(child); + for (auto& child: src->_children) { + SPHatchPath const *hatchPath = dynamic_cast(&child); if (hatchPath) { list.push_back(hatchPath); } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index d775e306f..7915b0453 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -235,9 +235,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = NULL; - for (SPObject *child = firstChild(); child; child = child->getNext() ) { - if ( !dynamic_cast(child) && !dynamic_cast(child) ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: _children) { + if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend (l, crepr); @@ -251,9 +251,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if ( !dynamic_cast(child) && !dynamic_cast(child) ) { - child->updateRepr(flags); + for (auto& child: _children) { + if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { + child.updateRepr(flags); } } } @@ -365,9 +365,9 @@ void SPGroup::hide (unsigned int key) { void SPGroup::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { - for ( SPObject const *o = this->firstChild(); o; o = o->getNext() ) + for (auto& o: _children) { - SPItem const *item = dynamic_cast(o); + SPItem const *item = dynamic_cast(&o); if (item) { item->getSnappoints(p, snapprefs); } @@ -511,20 +511,21 @@ sp_item_group_ungroup (SPGroup *group, std::vector &children, bool do_d GSList *objects = NULL; Geom::Affine const g(group->transform); - for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) - if (SPItem *citem = dynamic_cast(child)) - sp_item_group_ungroup_handle_clones(citem,g); - + for (auto& child: group->_children) { + if (SPItem *citem = dynamic_cast(&child)) { + sp_item_group_ungroup_handle_clones(citem, g); + } + } - for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) { - SPItem *citem = dynamic_cast(child); + for (auto& child: group->_children) { + SPItem *citem = dynamic_cast(&child); if (citem) { /* Merging of style */ // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do // it here _before_ the new transform is set, so as to use the pre-transform bbox citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); - child->style->merge( group->style ); + child.style->merge( group->style ); /* * fixme: We currently make no allowance for the case where child is cloned * and the group has any style settings. @@ -546,9 +547,9 @@ sp_item_group_ungroup (SPGroup *group, std::vector &children, bool do_d * extra complication & maintenance burden and this case is rare. */ - child->updateRepr(); + child.updateRepr(); - Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); + Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document()); // Merging transform Geom::Affine ctrans = citem->transform * g; @@ -599,7 +600,7 @@ sp_item_group_ungroup (SPGroup *group, std::vector &children, bool do_d items = g_slist_prepend (items, nrepr); } else { - Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); + Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document()); objects = g_slist_prepend (objects, nrepr); } } @@ -661,9 +662,9 @@ std::vector sp_item_group_item_list(SPGroup * group) std::vector s; g_return_val_if_fail(group != NULL, s); - for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if ( dynamic_cast(o) ) { - s.push_back((SPItem*)o); + for (auto& o: group->_children) { + if ( dynamic_cast(&o) ) { + s.push_back((SPItem*)&o); } } return s; @@ -734,8 +735,8 @@ void SPGroup::_updateLayerMode(unsigned int display_key) { void SPGroup::translateChildItems(Geom::Translate const &tr) { if ( hasChildren() ) { - for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - SPItem *item = dynamic_cast(o); + for (auto& o: _children) { + SPItem *item = dynamic_cast(&o); if ( item ) { sp_item_move_rel(item, tr); } @@ -747,14 +748,14 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse) { if ( hasChildren() ) { - for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - if ( SPDefs *defs = dynamic_cast(o) ) { // select symbols from defs, ignore clips, masks, patterns - for (SPObject *defschild = defs->firstChild() ; defschild ; defschild = defschild->getNext() ) { - SPGroup *defsgroup = dynamic_cast(defschild); + for (auto& o: _children) { + if ( SPDefs *defs = dynamic_cast(&o) ) { // select symbols from defs, ignore clips, masks, patterns + for (auto& defschild: defs->_children) { + SPGroup *defsgroup = dynamic_cast(&defschild); if (defsgroup) defsgroup->scaleChildItemsRec(sc, p, false); } - } else if ( SPItem *item = dynamic_cast(o) ) { + } else if ( SPItem *item = dynamic_cast(&o) ) { SPGroup *group = dynamic_cast(item); if (group && !dynamic_cast(item)) { /* Using recursion breaks clipping because transforms are applied @@ -870,8 +871,8 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo gint SPGroup::getItemCount() const { gint len = 0; - for (SPObject const *o = this->firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast(o)) { + for (auto& child: _children) { + if (dynamic_cast(&child)) { len++; } } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 258a5cd14..ba57cec8b 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -705,9 +705,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X // so we need to add any children from the underlying object to the new repr if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (SPObject *child = object->firstChild(); child != NULL; child = child->next ) { - if (dynamic_cast(child) || dynamic_cast(child)) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: object->_children) { + if (dynamic_cast(&child) || dynamic_cast(&child)) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend (l, crepr); } @@ -719,9 +719,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = object->firstChild() ; child != NULL; child = child->next ) { - if (dynamic_cast(child) || dynamic_cast(child)) { - child->updateRepr(flags); + for (auto& child: object->_children) { + if (dynamic_cast(&child) || dynamic_cast(&child)) { + child.updateRepr(flags); } } } @@ -928,12 +928,12 @@ unsigned int SPItem::pos_in_parent() const { unsigned int pos = 0; - for ( SPObject *iter = parent->firstChild() ; iter ; iter = iter->next) { - if (iter == this) { + for (auto& iter: parent->_children) { + if (&iter == this) { return pos; } - if (dynamic_cast(iter)) { + if (dynamic_cast(&iter)) { pos++; } } @@ -1666,8 +1666,8 @@ SPItem const *sp_item_first_item_child(SPObject const *obj) SPItem *sp_item_first_item_child(SPObject *obj) { SPItem *child = 0; - for ( SPObject *iter = obj->firstChild() ; iter ; iter = iter->next ) { - SPItem *tmp = dynamic_cast(iter); + for (auto& iter: obj->_children) { + SPItem *tmp = dynamic_cast(&iter); if ( tmp ) { child = tmp; break; diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index a36d8ef29..e643cc9bd 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -227,9 +227,9 @@ Inkscape::DrawingItem *SPMask::sp_mask_show(Inkscape::Drawing &drawing, unsigned Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); this->display = sp_mask_view_new_prepend (this->display, key, ai); - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - Inkscape::DrawingItem *ac = SP_ITEM (child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS); + for (auto& child: _children) { + if (SP_IS_ITEM (&child)) { + Inkscape::DrawingItem *ac = SP_ITEM (&child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { ai->prependChild(ac); @@ -250,9 +250,9 @@ void SPMask::sp_mask_hide(unsigned int key) { g_return_if_fail (this != NULL); g_return_if_fail (SP_IS_MASK (this)); - for ( SPObject *child = this->firstChild(); child; child = child->getNext()) { - if (SP_IS_ITEM (child)) { - SP_ITEM(child)->invoke_hide (key); + for (auto& child: _children) { + if (SP_IS_ITEM (&child)) { + SP_ITEM(&child)->invoke_hide (key); } } diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index 355150893..20d6d0d85 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -632,16 +632,16 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { guint max_column = 0; guint irow = 0; // Corresponds to top of patch being read in. - for ( SPObject *ro = mg->firstChild() ; ro ; ro = ro->getNext() ) { + for (auto& ro: mg->_children) { - if (SP_IS_MESHROW(ro)) { + if (SP_IS_MESHROW(&ro)) { guint icolumn = 0; // Corresponds to left of patch being read in. - for ( SPObject *po = ro->firstChild() ; po ; po = po->getNext() ) { + for (auto& po: ro._children) { - if (SP_IS_MESHPATCH(po)) { + if (SP_IS_MESHPATCH(&po)) { - SPMeshpatch *patch = SP_MESHPATCH(po); + SPMeshpatch *patch = SP_MESHPATCH(&po); // std::cout << "SPMeshNodeArray::read: row size: " << nodes.size() << std::endl; SPMeshPatchI new_patch( &nodes, irow, icolumn ); // Adds new nodes. @@ -652,15 +652,15 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { // Only 'top' side defined for first row. if( irow != 0 ) ++istop; - for ( SPObject *so = po->firstChild() ; so ; so = so->getNext() ) { - if (SP_IS_STOP(so)) { + for (auto& so: po._children) { + if (SP_IS_STOP(&so)) { if( istop > 3 ) { // std::cout << " Mesh Gradient: Too many stops: " << istop << std::endl; break; } - SPStop *stop = SP_STOP(so); + SPStop *stop = SP_STOP(&so); // Handle top of first row. if( istop == 0 && icolumn == 0 ) { @@ -848,15 +848,15 @@ void SPMeshNodeArray::write( SPMesh *mg ) { // First we must delete reprs for old mesh rows and patches. GSList *descendant_reprs = NULL; GSList *descendant_objects = NULL; - for ( SPObject *row = mg->firstChild(); row; row = row->getNext() ) { - descendant_reprs = g_slist_prepend (descendant_reprs, row->getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, row ); - for ( SPObject *patch = row->firstChild(); patch; patch = patch->getNext() ) { - descendant_reprs = g_slist_prepend (descendant_reprs, patch->getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, patch ); - for ( SPObject *stop = patch->firstChild(); stop; stop = stop->getNext() ) { - descendant_reprs = g_slist_prepend (descendant_reprs, stop->getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, stop ); + for (auto& row: mg->_children) { + descendant_reprs = g_slist_prepend (descendant_reprs, row.getRepr()); + descendant_objects = g_slist_prepend (descendant_objects, &row); + for (auto& patch: row._children) { + descendant_reprs = g_slist_prepend (descendant_reprs, patch.getRepr()); + descendant_objects = g_slist_prepend (descendant_objects, &patch); + for (auto& stop: patch._children) { + descendant_reprs = g_slist_prepend (descendant_reprs, stop.getRepr()); + descendant_objects = g_slist_prepend (descendant_objects, &stop); } } } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 616ec3921..173055dbd 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -248,9 +248,9 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "inkscape:lockguides" ); /* Construct guideline list */ - for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { - if (SP_IS_GUIDE(o)) { - SPGuide * g = SP_GUIDE(o); + for (auto& o: _children) { + if (SP_IS_GUIDE(&o)) { + SPGuide * g = SP_GUIDE(&o); this->guides.push_back(g); //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); g->setColor(this->guidecolor); @@ -858,9 +858,9 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop) } // if that didn't work out, look for the topmost layer if (!layer) { - for ( SPObject *iter = document->getRoot()->firstChild(); iter ; iter = iter->getNext() ) { - if (desktop->isLayer(iter)) { - layer = iter; + for (auto& iter: document->getRoot()->_children) { + if (desktop->isLayer(&iter)) { + layer = &iter; } } } diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index c3967461e..bfed08218 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -50,8 +50,8 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks } GSList *l = 0; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: _children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -64,8 +64,8 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks l = g_slist_remove(l, l->data); } } else { - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: _children) { + child.updateRepr(flags); } } diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 36957ab49..2babf0441 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -118,7 +118,7 @@ static gchar *sp_object_get_unique_id(SPObject *object, */ SPObject::SPObject() : cloned(0), uflags(0), mflags(0), hrefcount(0), _total_hrefcount(0), - document(NULL), parent(NULL), children(NULL), _last_child(NULL), + document(NULL), parent(NULL), children(NULL), next(NULL), id(NULL), repr(NULL), refCount(1),hrefList(std::list()), _successor(NULL), _collection_policy(SPObject::COLLECT_WITH_PARENT), _label(NULL), _default_label(NULL) @@ -541,9 +541,6 @@ void SPObject::attach(SPObject *object, SPObject *prev) this->children = object; } object->next = next; - if (!next) { - this->_last_child = object; - } if (!object->xml_space.set) object->xml_space.value = this->xml_space.value; } @@ -576,9 +573,6 @@ void SPObject::reorder(SPObject* obj, SPObject* prev) { } else { children = next; } - if (!next) { - _last_child = old_prev; - } if (prev) { next = prev->next; prev->next = obj; @@ -587,9 +581,6 @@ void SPObject::reorder(SPObject* obj, SPObject* prev) { children = obj; } obj->next = next; - if (!next) { - _last_child = obj; - } } void SPObject::detach(SPObject *object) @@ -616,9 +607,6 @@ void SPObject::detach(SPObject *object) } else { this->children = next; } - if (!next) { - this->_last_child = prev; - } object->next = NULL; object->parent = NULL; @@ -856,11 +844,9 @@ void SPObject::releaseReferences() { SPObject *SPObject::getPrev() { - SPObject *prev = 0; - for ( SPObject *obj = parent->firstChild(); obj && !prev; obj = obj->getNext() ) { - if (obj->getNext() == this) { - prev = obj; - } + SPObject *prev = nullptr; + if (parent && !parent->_children.empty() && &parent->_children.front() != this) { + prev = &*(--parent->_children.iterator_to(*this)); } return prev; } diff --git a/src/sp-object.h b/src/sp-object.h index 6aa006283..2534b2268 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -209,7 +209,6 @@ public: SPDocument *document; /* Document we are part of */ SPObject *parent; /* Our parent (only one allowed) */ SPObject *children; /* Our children */ - SPObject *_last_child; /* Remembered last child */ SPObject *next; /* Next object in linked list */ private: @@ -314,11 +313,11 @@ public: bool hasChildren() const { return ( _children.size() > 0 ); } - SPObject *firstChild() { return children; } - SPObject const *firstChild() const { return children; } + SPObject *firstChild() { return _children.empty() ? nullptr : &_children.front(); } + SPObject const *firstChild() const { return _children.empty() ? nullptr : &_children.front(); } - SPObject *lastChild() { return _last_child; } - SPObject const *lastChild() const { return _last_child; } + SPObject *lastChild() { return _children.empty() ? nullptr : &_children.back(); } + SPObject const *lastChild() const { return _children.empty() ? nullptr : &_children.back(); } enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 55110f3c5..fde9f90f1 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -223,8 +223,8 @@ void SPPattern::_getChildren(std::list &l) { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children - for (SPObject *child = pat_i->firstChild(); child; child = child->getNext()) { - l.push_back(child); + for (auto& child: pat_i->_children) { + l.push_back(&child); } break; // do not go further up the chain if children are found } @@ -319,8 +319,8 @@ guint SPPattern::_countHrefs(SPObject *o) const i++; } - for (SPObject *child = o->firstChild(); child != NULL; child = child->next) { - i += _countHrefs(child); + for (auto& child: o->_children) { + i += _countHrefs(&child); } return i; @@ -508,13 +508,13 @@ Geom::OptRect SPPattern::viewbox() const bool SPPattern::_hasItemChildren() const { - bool hasChildren = false; - for (SPObject const *child = firstChild(); child && !hasChildren; child = child->getNext()) { - if (SP_IS_ITEM(child)) { - hasChildren = true; + for (auto& child: _children) { + if (SP_IS_ITEM(&child)) { + return true; } } - return hasChildren; + + return false; } bool SPPattern::isValid() const @@ -558,12 +558,12 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); drawing.setRoot(root); - for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { - if (SP_IS_ITEM(child)) { + for (auto& child: shown->_children) { + if (SP_IS_ITEM(&child)) { // for each item in pattern, show it on our drawing, add to the group, // and connect to the release signal in case the item gets deleted Inkscape::DrawingItem *cai; - cai = SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); + cai = SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); root->appendChild(cai); } } @@ -654,9 +654,9 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Render drawing to pattern_surface via drawing context, this calls root->render // which is really DrawingItem->render(). drawing.render(dc, one_tile); - for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(dkey); + for (auto& child: shown->_children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(dkey); } } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 98eae2159..cfd0ced10 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -73,9 +73,9 @@ void SPRoot::build(SPDocument *document, Inkscape::XML::Node *repr) SPGroup::build(document, repr); // Search for first node - for (SPObject *o = this->firstChild() ; o ; o = o->getNext()) { - if (SP_IS_DEFS(o)) { - this->defs = SP_DEFS(o); + for (auto& o: _children) { + if (SP_IS_DEFS(&o)) { + this->defs = SP_DEFS(&o); break; } } @@ -174,9 +174,9 @@ void SPRoot::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) if (co && SP_IS_DEFS(co)) { // We search for first node - it is not beautiful, but works - for (SPObject *c = this->firstChild() ; c ; c = c->getNext()) { - if (SP_IS_DEFS(c)) { - this->defs = SP_DEFS(c); + for (auto& c: _children) { + if (SP_IS_DEFS(&c)) { + this->defs = SP_DEFS(&c); break; } } @@ -189,7 +189,8 @@ void SPRoot::remove_child(Inkscape::XML::Node *child) SPObject *iter = 0; // We search for first remaining node - it is not beautiful, but works - for (iter = this->firstChild() ; iter ; iter = iter->getNext()) { + for (auto& child: _children) { + iter = &child; if (SP_IS_DEFS(iter) && (SPDefs *)iter != this->defs) { this->defs = (SPDefs *)iter; break; diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index d2dcde15d..7679cc31e 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -32,9 +32,10 @@ SPSwitch::~SPSwitch() { SPObject *SPSwitch::_evaluateFirst() { SPObject *first = 0; - for (SPObject *child = this->firstChild() ; child && !first ; child = child->getNext() ) { - if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) { - first = child; + for (auto& child: _children) { + if (SP_IS_ITEM(&child) && sp_item_evaluate(SP_ITEM(&child))) { + first = &child; + break; } } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 4afc38524..5126ae094 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -155,9 +155,9 @@ void SPText::update(SPCtx *ctx, guint flags) { // Create temporary list of children GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, this); - l = g_slist_prepend (l, child); + for (auto& child: _children) { + sp_object_ref(&child, this); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); @@ -235,9 +235,9 @@ void SPText::modified(guint flags) { // Create temporary list of children GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, this); - l = g_slist_prepend (l, child); + for (auto& child: _children) { + sp_object_ref(&child, this); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); @@ -262,17 +262,17 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + for (auto& child: _children) { + if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } Inkscape::XML::Node *crepr = NULL; - if (SP_IS_STRING(child)) { - crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if (SP_IS_STRING(&child)) { + crepr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } else { - crepr = child->updateRepr(xml_doc, NULL, flags); + crepr = child.updateRepr(xml_doc, NULL, flags); } if (crepr) { @@ -286,15 +286,15 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + for (auto& child: _children) { + if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } - if (SP_IS_STRING(child)) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + if (SP_IS_STRING(&child)) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } else { - child->updateRepr(flags); + child.updateRepr(flags); } } } @@ -606,16 +606,16 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio } } - for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) { - SPString *str = dynamic_cast(child); + for (auto& child: root->_children) { + SPString *str = dynamic_cast(&child); if (str) { Glib::ustring const &string = str->string; // std::cout << " Appending: >" << string << "<" << std::endl; - layout.appendText(string, root->style, child, &optional_attrs, child_attrs_offset + length); + layout.appendText(string, root->style, &child, &optional_attrs, child_attrs_offset + length); length += string.length(); - } else if (!sp_repr_is_meta_element(child->getRepr())) { + } else if (!sp_repr_is_meta_element(child.getRepr())) { /* ^^^^ XML Tree being directly used here while it shouldn't be.*/ - length += _buildLayoutInput(child, optional_attrs, child_attrs_offset + length, in_textpath); + length += _buildLayoutInput(&child, optional_attrs, child_attrs_offset + length, in_textpath); } } @@ -628,9 +628,9 @@ void SPText::rebuildLayout() Inkscape::Text::Layout::OptionalTextTagAttrs optional_attrs; _buildLayoutInput(this, optional_attrs, 0, false); layout.calculateFlow(); - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TEXTPATH(child)) { - SPTextPath const *textpath = SP_TEXTPATH(child); + for (auto& child: _children) { + if (SP_IS_TEXTPATH(&child)) { + SPTextPath const *textpath = SP_TEXTPATH(&child); if (textpath->originalPath != NULL) { //g_print("%s", layout.dumpAsText().c_str()); layout.fitToPathAlign(textpath->startOffset, *textpath->originalPath); @@ -640,9 +640,9 @@ void SPText::rebuildLayout() //g_print("%s", layout.dumpAsText().c_str()); // set the x,y attributes on role:line spans - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TSPAN(child)) { - SPTSpan *tspan = SP_TSPAN(child); + for (auto& child: _children) { + if (SP_IS_TSPAN(&child)) { + SPTSpan *tspan = SP_TSPAN(&child); if ( (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED) && tspan->attributes.singleXYCoordinates() ) { Inkscape::Text::Layout::iterator iter = layout.sourceToIterator(tspan); diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index ba592058b..66866c9f7 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -506,9 +506,9 @@ sp_tref_convert_to_tspan(SPObject *obj) //////////////////// else { GSList *l = NULL; - for (SPObject *child = obj->firstChild() ; child != NULL ; child = child->getNext() ) { - sp_object_ref(child, obj); - l = g_slist_prepend (l, child); + for (auto& child: obj->_children) { + sp_object_ref(&child, obj); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); while (l) { diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 05f8430ba..23df18503 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -96,9 +96,9 @@ void SPTSpan::update(SPCtx *ctx, guint flags) { } childflags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { - ochild->updateDisplay(ctx, childflags); + for (auto& ochild: _children) { + if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) { + ochild.updateDisplay(ctx, childflags); } } @@ -128,9 +128,9 @@ void SPTSpan::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { - ochild->emitModified(flags); + for (auto& ochild: _children) { + if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) { + ochild.emitModified(flags); } } } @@ -175,15 +175,15 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: _children) { Inkscape::XML::Node* c_repr=NULL; - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_TEXTPATH(child) ) { - //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_TEXTPATH(&child) ) { + //c_repr = child.updateRepr(xml_doc, NULL, flags); // shouldn't happen + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -197,13 +197,13 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_TEXTPATH(child) ) { + for (auto& child: _children) { + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_TEXTPATH(&child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -313,9 +313,9 @@ void SPTextPath::update(SPCtx *ctx, guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { - ochild->updateDisplay(ctx, flags); + for (auto& ochild: _children) { + if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) { + ochild.updateDisplay(ctx, flags); } } @@ -367,9 +367,9 @@ void SPTextPath::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { - ochild->emitModified(flags); + for (auto& ochild: _children) { + if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) { + ochild.emitModified(flags); } } } @@ -399,15 +399,15 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap if ( flags & SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: _children) { Inkscape::XML::Node* c_repr=NULL; - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_TEXTPATH(child) ) { + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_TEXTPATH(&child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -421,13 +421,13 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_TEXTPATH(child) ) { - //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: _children) { + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_TEXTPATH(&child) ) { + //c_repr = child.updateRepr(xml_doc, NULL, flags); // shouldn't happen + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -466,8 +466,8 @@ void sp_textpath_to_text(SPObject *tp) // make a list of textpath children GSList *tp_reprs = NULL; - for (SPObject *o = tp->firstChild() ; o != NULL; o = o->next) { - tp_reprs = g_slist_prepend(tp_reprs, o->getRepr()); + for (auto& o: tp->_children) { + tp_reprs = g_slist_prepend(tp_reprs, o.getRepr()); } for ( GSList *i = tp_reprs ; i ; i = i->next ) { diff --git a/src/splivarot.cpp b/src/splivarot.cpp index b1f324be2..4ac9143f0 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -883,9 +883,9 @@ void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_tran // note: a marker child item can be an item group! if (SP_IS_GROUP(item)) { // recurse through all childs: - for (SPObject const *o = item->firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - item_outline_add_marker_child(SP_ITEM(o), tr, pathv_in); + for (auto& o: item->_children) { + if ( SP_IS_ITEM(&o) ) { + item_outline_add_marker_child(SP_ITEM(&o), tr, pathv_in); } } } else { diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 86aee1831..f539652c0 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -240,9 +240,9 @@ text_remove_all_kerns_recursively(SPObject *o) g_strfreev(xa_comma); } - for (SPObject *i = o->firstChild(); i != NULL; i = i->getNext()) { - text_remove_all_kerns_recursively(i); - i->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + for (auto& i: o->_children) { + text_remove_all_kerns_recursively(&i); + i.requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } } diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 057523b1e..b03be792b 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -91,8 +91,8 @@ bool sp_te_input_is_empty(SPObject const *item) if (SP_IS_STRING(item)) { empty = SP_STRING(item)->string.empty(); } else { - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (!sp_te_input_is_empty(child)) { + for (auto& child: item->_children) { + if (!sp_te_input_is_empty(&child)) { empty = false; break; } @@ -237,11 +237,11 @@ unsigned sp_text_get_length(SPObject const *item) length++; } - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (SP_IS_STRING(child)) { - length += SP_STRING(child)->string.length(); + for (auto& child: item->_children) { + if (SP_IS_STRING(&child)) { + length += SP_STRING(&child)->string.length(); } else { - length += sp_text_get_length(child); + length += sp_text_get_length(&child); } } } @@ -267,22 +267,22 @@ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto) } // Count the length of the children - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (upto && child == upto) { + for (auto& child: item->_children) { + if (upto && &child == upto) { // hit upto, return immediately return length; } - if (SP_IS_STRING(child)) { - length += SP_STRING(child)->string.length(); + if (SP_IS_STRING(&child)) { + length += SP_STRING(&child)->string.length(); } else { - if (upto && child->isAncestorOf(upto)) { + if (upto && child.isAncestorOf(upto)) { // upto is below us, recurse and break loop - length += sp_text_get_length_upto(child, upto); + length += sp_text_get_length_upto(&child, upto); return length; } else { // recurse and go to the next sibling - length += sp_text_get_length_upto(child, upto); + length += sp_text_get_length_upto(&child, upto); } } } @@ -323,8 +323,11 @@ to \a item at the same level. */ static unsigned sum_sibling_text_lengths_before(SPObject const *item) { unsigned char_index = 0; - for (SPObject *sibling = item->parent->firstChild() ; sibling && sibling != item ; sibling = sibling->getNext()) { - char_index += sp_text_get_length(sibling); + for (auto& sibling: item->parent->_children) { + if (&sibling == item) { + break; + } + char_index += sp_text_get_length(&sibling); } return char_index; } @@ -857,11 +860,11 @@ static void sp_te_get_ustring_multiline(SPObject const *root, Glib::ustring *str if (*pending_line_break) { *string += '\n'; } - for (SPObject const *child = root->firstChild() ; child ; child = child->getNext()) { - if (SP_IS_STRING(child)) { - *string += SP_STRING(child)->string; + for (auto& child: root->_children) { + if (SP_IS_STRING(&child)) { + *string += SP_STRING(&child)->string; } else { - sp_te_get_ustring_multiline(child, string, pending_line_break); + sp_te_get_ustring_multiline(&child, string, pending_line_break); } } if (!SP_IS_TEXT(root) && !SP_IS_TEXTPATH(root) && is_line_break_object(root)) { @@ -1405,17 +1408,17 @@ static void apply_css_recursive(SPObject *o, SPCSSAttr const *css) { sp_repr_css_change(o->getRepr(), const_cast(css), "style"); - for (SPObject *child = o->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: o->_children) { if (sp_repr_css_property(const_cast(css), "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. SPCSSAttr *css_recurse = sp_repr_css_attr_new(); sp_repr_css_merge(css_recurse, const_cast(css)); sp_repr_css_set_property(css_recurse, "opacity", NULL); - apply_css_recursive(child, css_recurse); + apply_css_recursive(&child, css_recurse); sp_repr_css_attr_unref(css_recurse); } else { - apply_css_recursive(child, const_cast(css)); + apply_css_recursive(&child, const_cast(css)); } } } @@ -1429,7 +1432,7 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const * { bool passed_start = start_item == NULL ? true : false; Inkscape::XML::Document *xml_doc = common_ancestor->document->getReprDoc(); - + for (SPObject *child = common_ancestor->firstChild() ; child ; child = child->getNext()) { if (start_item == child) { passed_start = true; @@ -2073,8 +2076,8 @@ bool has_visible_text(SPObject *obj) if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) { hasVisible = true; // maybe we should also check that it's not all whitespace? } else { - for (SPObject const *child = obj->firstChild() ; child ; child = child->getNext()) { - if (has_visible_text(const_cast(child))) { + for (auto& child: obj->_children) { + if (has_visible_text(const_cast(&child))) { hasVisible = true; break; } diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 9871804f5..75c6c5bcc 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -894,8 +894,8 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) _copyNode(pattern->getRepr(), _doc, _defs); // items in the pattern may also use gradients and other patterns, so recurse - for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) { - SPItem *childItem = dynamic_cast(child); + for (auto& child: pattern->_children) { + SPItem *childItem = dynamic_cast(&child); if (childItem) { _copyUsedDefs(childItem); } diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 87c90c460..11af02e3c 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2042,12 +2042,12 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) if (!trace_drawing) return; - for (SPObject *o = from->firstChild(); o != NULL; o = o->next) { - SPItem *item = dynamic_cast(o); - if (item && clonetiler_is_a_clone_of(o, NULL)) { + for (auto& o: from->_children) { + SPItem *item = dynamic_cast(&o); + if (item && clonetiler_is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! } - clonetiler_trace_hide_tiled_clones_recursively (o); + clonetiler_trace_hide_tiled_clones_recursively (&o); } } @@ -2123,9 +2123,9 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_unclump.push_back((SPItem*)child); + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { + to_unclump.push_back((SPItem*)&child); } } @@ -2143,8 +2143,8 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) guint n = 0; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { n ++; } } @@ -2172,9 +2172,9 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d // remove old tiling GSList *to_delete = NULL; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_delete = g_slist_prepend (to_delete, child); + for (auto& child: parent->_children) { + if (clonetiler_is_a_clone_of (&child, obj)) { + to_delete = g_slist_prepend (to_delete, &child); } } for (GSList *i = to_delete; i; i = i->next) { diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 78e03e2a0..a60d1ddff 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -103,9 +103,7 @@ static int input_count(const SPFilterPrimitive* prim) return 2; else if(SP_IS_FEMERGE(prim)) { // Return the number of feMergeNode connections plus an extra - int count = 1; - for(const SPObject* o = prim->firstChild(); o; o = o->next, ++count){}; - return count; + return (int) (prim->_children.size() + 1); } else return 1; @@ -2343,11 +2341,12 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T if(SP_IS_FEMERGE(prim)) { int c = 0; bool found = false; - for(const SPObject* o = prim->firstChild(); o; o = o->next, ++c) { - if(c == attr && SP_IS_FEMERGENODE(o)) { - image = SP_FEMERGENODE(o)->input; + for (auto& o: prim->_children) { + if(c == attr && SP_IS_FEMERGENODE(&o)) { + image = SP_FEMERGENODE(&o)->input; found = true; } + ++c; } if(!found) return target; @@ -2534,21 +2533,23 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* if(SP_IS_FEMERGE(prim)) { int c = 1; bool handled = false; - for(SPObject* o = prim->firstChild(); o && !handled; o = o->next, ++c) { - if(c == _in_drag && SP_IS_FEMERGENODE(o)) { + for (auto& o: prim->_children) { + if(c == _in_drag && SP_IS_FEMERGENODE(&o)) { // If input is null, delete it if(!in_val) { //XML Tree being used directly here while it shouldn't be. - sp_repr_unparent(o->getRepr()); + sp_repr_unparent(o.getRepr()); DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove merge node")); (*get_selection()->get_selected())[_columns.primitive] = prim; + } else { + _dialog.set_attr(&o, SP_ATTR_IN, in_val); } - else - _dialog.set_attr(o, SP_ATTR_IN, in_val); handled = true; + break; } + ++c; } // Add new input? if(!handled && c == _in_drag && in_val) { diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 013a0ae6a..e156dfa13 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -747,14 +747,14 @@ std::vector &Find::all_items (SPObject *r, std::vector &l, boo return l; // we're not interested in metadata } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - SPItem *item = dynamic_cast(child); - if (item && !child->cloned && !desktop->isLayer(item)) { + for (auto& child: r->_children) { + SPItem *item = dynamic_cast(&child); + if (item && !child.cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { - l.insert(l.begin(),(SPItem*)child); + l.insert(l.begin(),(SPItem*)&child); } } - l = all_items (child, l, hidden, locked); + l = all_items (&child, l, hidden, locked); } return l; } diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index f219f3db6..eafe5566a 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -182,7 +182,7 @@ std::vector FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli family = SP_TEXT(parent_text)->layout.getFontFamily(0); // Add all the spans fonts to the set gint ii = 0; - for (SPObject *child = parent_text->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: parent_text->_children) { family = SP_TEXT(parent_text)->layout.getFontFamily(ii); setFontSpans.insert(family); ii++; diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 9d05c73bc..00482c573 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -1292,9 +1292,9 @@ bool ObjectsPanel::_executeAction() break; case BUTTON_COLLAPSE_ALL: { - for (SPObject* obj = _document->getRoot()->firstChild(); obj != NULL; obj = obj->next) { - if (SP_IS_GROUP(obj)) { - _setCollapsed(SP_GROUP(obj)); + for (auto& obj: _document->getRoot()->_children) { + if (SP_IS_GROUP(&obj)) { + _setCollapsed(SP_GROUP(&obj)); } } _objectsChanged(_document->getRoot()); diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 6da8acb20..9338a4e8c 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -234,14 +234,14 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock return l; // we're not interested in metadata } - for (SPObject *child = r->firstChild(); child; child = child->next) { - if (SP_IS_ITEM (child) && !child->cloned && !desktop->isLayer(SP_ITEM(child))) { - if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { - if (SP_IS_TEXT(child) || SP_IS_FLOWTEXT(child)) - l = g_slist_prepend (l, child); + for (auto& child: r->_children) { + if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) { + if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) { + if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child)) + l = g_slist_prepend (l, &child); } } - l = allTextItems (child, l, hidden, locked); + l = allTextItems (&child, l, hidden, locked); } return l; } diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 51d81022f..1fdce34a5 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -658,8 +658,8 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - l = symbols_in_doc_recursive( child, l ); + for (auto& child: r->_children) { + l = symbols_in_doc_recursive( &child, l ); } return l; @@ -680,8 +680,8 @@ GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - l = use_in_doc_recursive( child, l ); + for (auto& child: r->_children) { + l = use_in_doc_recursive( &child, l ); } return l; diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 27e755add..2adba38c5 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -118,8 +118,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { SPDefs *defs = document->getDefs(); bool has_persp = false; - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { - if (SP_IS_PERSP3D(child)) { + for (auto& child: defs->_children) { + if (SP_IS_PERSP3D(&child)) { has_persp = true; break; } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index b81a630e2..be8ce6d0c 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1114,9 +1114,9 @@ void ConnectorTool::_setActiveShape(SPItem *item) { // The idea here is to try and add a group's children to solidify // connection handling. We react to path objects with only one node. - for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) { - this->_activeShapeAddKnot((SPItem *) child); + for (auto& child: item->_children) { + if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) { + this->_activeShapeAddKnot((SPItem *) &child); } } this->_activeShapeAddKnot(item); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 658cf4617..d048c318b 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -385,9 +385,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (dynamic_cast(item) && !dynamic_cast(item)) { GSList *children = NULL; - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - if (dynamic_cast(static_cast(child))) { - children = g_slist_prepend(children, child); + for (auto& child: item->_children) { + if (dynamic_cast(static_cast(&child))) { + children = g_slist_prepend(children, &child); } } @@ -832,8 +832,8 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or double offset_l = 0; double offset_h = 0; SPObject *child_prev = NULL; - for (SPObject *child = vector->firstChild(); child; child = child->getNext()) { - SPStop *stop = dynamic_cast(child); + for (auto& child: vector->_children) { + SPStop *stop = dynamic_cast(&child); if (!stop) { continue; } @@ -878,7 +878,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or } offset_l = offset_h; - child_prev = child; + child_prev = &child; } } @@ -894,8 +894,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, bool did = false; if (dynamic_cast(item)) { - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - SPItem *childItem = dynamic_cast(child); + for (auto& child: item->_children) { + SPItem *childItem = dynamic_cast(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, fill_goal, do_fill, diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index a395d1954..c4b2ed59a 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -720,9 +720,9 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPStop *new_stop, GtkWidget *data, gboolean block) { int i = 0; - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - if (ochild == new_stop) { + for (auto& ochild: gradient->_children) { + if (SP_IS_STOP(&ochild)) { + if (&ochild == new_stop) { blocked = block; gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , i); gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data); @@ -765,9 +765,9 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S /* Populate the combobox store */ std::vector sl; if ( gradient->hasStops() ) { - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - sl.push_back(ochild); + for (auto& ochild: gradient->_children) { + if (SP_IS_STOP(&ochild)) { + sl.push_back(&ochild); } } } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 97e65141f..813a2d28e 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -363,13 +363,13 @@ unsigned long sp_gradient_to_hhssll(SPGradient *gr) static GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) { - for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - list = g_slist_prepend(list, SP_ITEM(child)); + for (auto& child: from->_children) { + if (SP_IS_ITEM(&child)) { + list = g_slist_prepend(list, SP_ITEM(&child)); } - if (ingroups || SP_IS_ITEM(child)) { - list = get_all_doc_items(list, child, onlyvisible, onlysensitive, ingroups, exclude); + if (ingroups || SP_IS_ITEM(&child)) { + list = get_all_doc_items(list, &child, onlyvisible, onlysensitive, ingroups, exclude); } } @@ -525,10 +525,10 @@ static void verify_grad(SPGradient *gradient) int i = 0; SPStop *stop = NULL; /* count stops */ - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: gradient->_children) { + if (SP_IS_STOP(&ochild)) { i++; - stop = SP_STOP(ochild); + stop = SP_STOP(&ochild); } } @@ -568,9 +568,9 @@ static void select_stop_in_list( GtkWidget *vb, SPGradient *gradient, SPStop *ne GtkWidget *combo_box = static_cast(g_object_get_data(G_OBJECT(vb), "combo_box")); int i = 0; - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - if (ochild == new_stop) { + for (auto& ochild: gradient->_children) { + if (SP_IS_STOP(&ochild)) { + if (&ochild == new_stop) { gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , i); break; } @@ -603,9 +603,9 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s /* Populate the combobox store */ GSList *sl = NULL; if ( gradient->hasStops() ) { - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - sl = g_slist_append(sl, ochild); + for (auto& ochild: gradient->_children) { + if (SP_IS_STOP(&ochild)) { + sl = g_slist_append(sl, &ochild); } } } diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index e273faad7..fd7b5f6cd 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -335,10 +335,10 @@ GSList *MarkerComboBox::get_marker_list (SPDocument *source) return NULL; } - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) + for (auto& child: defs->_children) { - if (SP_IS_MARKER(child)) { - ml = g_slist_prepend (ml, child); + if (SP_IS_MARKER(&child)) { + ml = g_slist_prepend (ml, &child); } } return ml; -- cgit v1.2.3 From 9e210a6d1333c3366681547e3e81593ef69ff73e Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 14 Jul 2016 12:56:49 +0200 Subject: Last part of new SPObject children list (bzr r14954.1.20) --- src/desktop-style.cpp | 6 +-- src/display/nr-svgfonts.cpp | 35 +++++++------ src/extension/internal/metafile-print.cpp | 18 ++++--- src/filters/blend.cpp | 6 +-- src/filters/componenttransfer.cpp | 19 ++++--- src/filters/composite.cpp | 6 +-- src/filters/diffuselighting.cpp | 24 ++++----- src/filters/displacementmap.cpp | 6 +-- src/filters/merge.cpp | 9 ++-- src/filters/specularlighting.cpp | 24 ++++----- src/main.cpp | 6 +-- src/selection-chemistry.cpp | 28 +++++------ src/sp-filter-primitive.cpp | 6 ++- src/sp-filter.cpp | 25 ++++----- src/sp-flowtext.cpp | 4 +- src/sp-item-group.cpp | 2 +- src/sp-item.cpp | 28 +++++------ src/sp-object.cpp | 66 ++++++------------------ src/sp-object.h | 9 +--- src/sp-text.cpp | 12 ++--- src/sp-use.cpp | 32 +++++------- src/text-chemistry.cpp | 10 ++-- src/text-editing.cpp | 9 ++-- src/ui/clipboard.cpp | 8 +-- src/ui/dialog/document-properties.cpp | 14 +++--- src/ui/dialog/filter-effects-dialog.cpp | 54 ++++++++++---------- src/ui/dialog/objects.cpp | 83 +++++++++++++++++------------- src/ui/dialog/svg-fonts-dialog.cpp | 84 ++++++++++++++----------------- src/ui/dialog/tags.cpp | 45 ++++++++--------- src/ui/tools/node-tool.cpp | 4 +- src/ui/tools/tweak-tool.cpp | 6 +-- src/uri-references.cpp | 7 +-- 32 files changed, 320 insertions(+), 375 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index a52ab3d76..e4b7c6a83 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1810,9 +1810,8 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) //if object has a filter if (style->filter.set && style->getFilter()) { //cycle through filter primitives - SPObject *primitive_obj = style->getFilter()->children; - while (primitive_obj) { - SPFilterPrimitive *primitive = dynamic_cast(primitive_obj); + for(auto& primitive_obj: style->getFilter()->_children) { + SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { //if primitive is gaussianblur @@ -1830,7 +1829,6 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) } } } - primitive_obj = primitive_obj->next; } } } diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 011f51977..927093ef4 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -203,14 +203,19 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, //check whether is there a glyph declared on the SVG document // that matches with the text string in its current position if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){ - for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){ + for(auto& node: font->_children) { + if (!previous_unicode) { + break; + } //apply glyph kerning if appropriate - SPHkern *hkern = dynamic_cast(node); - if (hkern && is_horizontal_text && MatchHKerningRule(hkern, this->glyphs[i], previous_unicode, previous_glyph_name) ){ + SPHkern *hkern = dynamic_cast(&node); + if (hkern && is_horizontal_text && + MatchHKerningRule(hkern, this->glyphs[i], previous_unicode, previous_glyph_name)) { x -= (hkern->k / 1000.0);//TODO: use here the height of the font } - SPVkern *vkern = dynamic_cast(node); - if (vkern && !is_horizontal_text && MatchVKerningRule(vkern, this->glyphs[i], previous_unicode, previous_glyph_name) ){ + SPVkern *vkern = dynamic_cast(&node); + if (vkern && !is_horizontal_text && + MatchVKerningRule(vkern, this->glyphs[i], previous_unicode, previous_glyph_name)) { y -= (vkern->k / 1000.0);//TODO: use here the "height" of the font } } @@ -271,10 +276,10 @@ SvgFont::glyph_modified(SPObject* /* blah */, unsigned int /* bleh */){ Geom::PathVector SvgFont::flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv){ double units_per_em = 1000; - for (SPObject *obj = spfont->children; obj; obj = obj->next){ - if (dynamic_cast(obj)) { + for(auto& obj: spfont->_children) { + if (dynamic_cast(&obj)) { //XML Tree being directly used here while it shouldn't be. - sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em); + sp_repr_get_double(obj.getRepr(), "units_per_em", &units_per_em); } } @@ -339,19 +344,19 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, if (node->hasChildren()){ //render the SVG described on this glyph's child nodes. - for(node = node->children; node; node=node->next){ + for(auto& child: node->_children) { { - SPPath *path = dynamic_cast(node); + SPPath *path = dynamic_cast(&child); if (path) { pathv = path->_curve->get_pathvector(); pathv = flip_coordinate_system(spfont, pathv); render_glyph_path(cr, &pathv); } } - if (dynamic_cast(node)) { + if (dynamic_cast(&child)) { g_warning("TODO: svgfonts: render OBJECTGROUP"); } - SPUse *use = dynamic_cast(node); + SPUse *use = dynamic_cast(&child); if (use) { SPItem* item = use->ref->getObject(); SPPath *path = dynamic_cast(item); @@ -374,12 +379,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, cairo_font_face_t* SvgFont::get_font_face(){ if (!this->userfont) { - for(SPObject* node = this->font->children;node;node=node->next){ - SPGlyph *glyph = dynamic_cast(node); + for(auto& node: font->_children) { + SPGlyph *glyph = dynamic_cast(&node); if (glyph) { glyphs.push_back(glyph); } - SPMissingGlyph *missing = dynamic_cast(node); + SPMissingGlyph *missing = dynamic_cast(&node); if (missing) { missingglyph = missing; } diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 47ba5971c..5c10f7dd9 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -293,20 +293,22 @@ void PrintMetafile::brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf } // still looking? Look at this pattern's children, if there are any - SPObject *child = pat_i->firstChild(); - while (child && !(*epixbuf) && (*hatchType == -1)) { - brush_classify(child, depth, epixbuf, hatchType, hatchColor, bkColor); - child = child->getNext(); + for (auto& child: pat_i->_children) { + if (*epixbuf || *hatchType != -1) { + break; + } + brush_classify(&child, depth, epixbuf, hatchType, hatchColor, bkColor); } } } else if (SP_IS_IMAGE(parent)) { *epixbuf = ((SPImage *)parent)->pixbuf; return; } else { // some inkscape rearrangements pass through nodes between pattern and image which are not classified as either. - SPObject *child = parent->firstChild(); - while (child && !(*epixbuf) && (*hatchType == -1)) { - brush_classify(child, depth, epixbuf, hatchType, hatchColor, bkColor); - child = child->getNext(); + for (auto& child: parent->_children) { + if (*epixbuf || *hatchType != -1) { + break; + } + brush_classify(&child, depth, epixbuf, hatchType, hatchColor, bkColor); } } } diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 6e92ef50f..d3f031257 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -199,11 +199,11 @@ Inkscape::XML::Node* SPFeBlend::write(Inkscape::XML::Document *doc, Inkscape::XM if( !in2_name ) { // This code is very similar to sp_filter_primtive_name_previous_out() - SPObject *i = parent->children; + SPObject *i = parent->firstChild(); // Find previous filter primitive - while (i && i->next != this) { - i = i->next; + while (i && i->getNext() != this) { + i = i->getNext(); } if( i ) { diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 3d0264390..e52f6d478 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -49,11 +49,10 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c { if (sp_componenttransfer->renderer) { bool set[4] = {false, false, false, false}; - SPObject* node = sp_componenttransfer->children; - for(;node;node=node->next){ + for(auto& node: sp_componenttransfer->_children) { int i = 4; - SPFeFuncNode *funcNode = SP_FEFUNCNODE(node); + SPFeFuncNode *funcNode = SP_FEFUNCNODE(&node); switch (funcNode->channel) { case SPFeFuncNode::R: @@ -74,13 +73,13 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c g_warning("Unrecognized channel for component transfer."); break; } - sp_componenttransfer->renderer->type[i] = ((SPFeFuncNode *) node)->type; - sp_componenttransfer->renderer->tableValues[i] = ((SPFeFuncNode *) node)->tableValues; - sp_componenttransfer->renderer->slope[i] = ((SPFeFuncNode *) node)->slope; - sp_componenttransfer->renderer->intercept[i] = ((SPFeFuncNode *) node)->intercept; - sp_componenttransfer->renderer->amplitude[i] = ((SPFeFuncNode *) node)->amplitude; - sp_componenttransfer->renderer->exponent[i] = ((SPFeFuncNode *) node)->exponent; - sp_componenttransfer->renderer->offset[i] = ((SPFeFuncNode *) node)->offset; + sp_componenttransfer->renderer->type[i] = ((SPFeFuncNode *) &node)->type; + sp_componenttransfer->renderer->tableValues[i] = ((SPFeFuncNode *) &node)->tableValues; + sp_componenttransfer->renderer->slope[i] = ((SPFeFuncNode *) &node)->slope; + sp_componenttransfer->renderer->intercept[i] = ((SPFeFuncNode *) &node)->intercept; + sp_componenttransfer->renderer->amplitude[i] = ((SPFeFuncNode *) &node)->amplitude; + sp_componenttransfer->renderer->exponent[i] = ((SPFeFuncNode *) &node)->exponent; + sp_componenttransfer->renderer->offset[i] = ((SPFeFuncNode *) &node)->offset; set[i] = true; } // Set any types not explicitly set to the identity transform diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 3e651a778..42f06915f 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -221,11 +221,11 @@ Inkscape::XML::Node* SPFeComposite::write(Inkscape::XML::Document *doc, Inkscape if( !in2_name ) { // This code is very similar to sp_filter_primitive_name_previous_out() - SPObject *i = parent->children; + SPObject *i = parent->firstChild(); // Find previous filter primitive - while (i && i->next != this) { - i = i->next; + while (i && i->getNext() != this) { + i = i->getNext(); } if( i ) { diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index 120c058d2..a46b367ec 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -258,17 +258,17 @@ static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffu { if (sp_diffuselighting->renderer) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(sp_diffuselighting->children)) { + if (SP_IS_FEDISTANTLIGHT(sp_diffuselighting->firstChild())) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::DISTANT_LIGHT; - sp_diffuselighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_diffuselighting->children); + sp_diffuselighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_diffuselighting->firstChild()); } - if (SP_IS_FEPOINTLIGHT(sp_diffuselighting->children)) { + if (SP_IS_FEPOINTLIGHT(sp_diffuselighting->firstChild())) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::POINT_LIGHT; - sp_diffuselighting->renderer->light.point = SP_FEPOINTLIGHT(sp_diffuselighting->children); + sp_diffuselighting->renderer->light.point = SP_FEPOINTLIGHT(sp_diffuselighting->firstChild()); } - if (SP_IS_FESPOTLIGHT(sp_diffuselighting->children)) { + if (SP_IS_FESPOTLIGHT(sp_diffuselighting->firstChild())) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::SPOT_LIGHT; - sp_diffuselighting->renderer->light.spot = SP_FESPOTLIGHT(sp_diffuselighting->children); + sp_diffuselighting->renderer->light.spot = SP_FESPOTLIGHT(sp_diffuselighting->firstChild()); } } } @@ -293,19 +293,19 @@ void SPFeDiffuseLighting::build_renderer(Inkscape::Filters::Filter* filter) { //We assume there is at most one child nr_diffuselighting->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(this->children)) { + if (SP_IS_FEDISTANTLIGHT(this->firstChild())) { nr_diffuselighting->light_type = Inkscape::Filters::DISTANT_LIGHT; - nr_diffuselighting->light.distant = SP_FEDISTANTLIGHT(this->children); + nr_diffuselighting->light.distant = SP_FEDISTANTLIGHT(this->firstChild()); } - if (SP_IS_FEPOINTLIGHT(this->children)) { + if (SP_IS_FEPOINTLIGHT(this->firstChild())) { nr_diffuselighting->light_type = Inkscape::Filters::POINT_LIGHT; - nr_diffuselighting->light.point = SP_FEPOINTLIGHT(this->children); + nr_diffuselighting->light.point = SP_FEPOINTLIGHT(this->firstChild()); } - if (SP_IS_FESPOTLIGHT(this->children)) { + if (SP_IS_FESPOTLIGHT(this->firstChild())) { nr_diffuselighting->light_type = Inkscape::Filters::SPOT_LIGHT; - nr_diffuselighting->light.spot = SP_FESPOTLIGHT(this->children); + nr_diffuselighting->light.spot = SP_FESPOTLIGHT(this->firstChild()); } //nr_offset->set_dx(sp_offset->dx); diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index 1dbea67ff..f0ca36079 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -193,11 +193,11 @@ Inkscape::XML::Node* SPFeDisplacementMap::write(Inkscape::XML::Document *doc, In if( !in2_name ) { // This code is very similar to sp_filter_primtive_name_previous_out() - SPObject *i = parent->children; + SPObject *i = parent->firstChild(); // Find previous filter primitive - while (i && i->next != this) { - i = i->next; + while (i && i->getNext() != this) { + i = i->getNext(); } if( i ) { diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index 68f671b11..6af1e8115 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -92,17 +92,14 @@ void SPFeMerge::build_renderer(Inkscape::Filters::Filter* filter) { sp_filter_primitive_renderer_common(this, nr_primitive); - SPObject *input = this->children; int in_nr = 0; - while (input) { - if (SP_IS_FEMERGENODE(input)) { - SPFeMergeNode *node = SP_FEMERGENODE(input); + for(auto& input: _children) { + if (SP_IS_FEMERGENODE(&input)) { + SPFeMergeNode *node = SP_FEMERGENODE(&input); nr_merge->set_input(in_nr, node->input); in_nr++; } - - input = input->next; } } diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index bda1a0f30..ac7253ad9 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -266,19 +266,19 @@ static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_spe if (sp_specularlighting->renderer) { sp_specularlighting->renderer->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(sp_specularlighting->children)) { + if (SP_IS_FEDISTANTLIGHT(sp_specularlighting->firstChild())) { sp_specularlighting->renderer->light_type = Inkscape::Filters::DISTANT_LIGHT; - sp_specularlighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_specularlighting->children); + sp_specularlighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_specularlighting->firstChild()); } - if (SP_IS_FEPOINTLIGHT(sp_specularlighting->children)) { + if (SP_IS_FEPOINTLIGHT(sp_specularlighting->firstChild())) { sp_specularlighting->renderer->light_type = Inkscape::Filters::POINT_LIGHT; - sp_specularlighting->renderer->light.point = SP_FEPOINTLIGHT(sp_specularlighting->children); + sp_specularlighting->renderer->light.point = SP_FEPOINTLIGHT(sp_specularlighting->firstChild()); } - if (SP_IS_FESPOTLIGHT(sp_specularlighting->children)) { + if (SP_IS_FESPOTLIGHT(sp_specularlighting->firstChild())) { sp_specularlighting->renderer->light_type = Inkscape::Filters::SPOT_LIGHT; - sp_specularlighting->renderer->light.spot = SP_FESPOTLIGHT(sp_specularlighting->children); + sp_specularlighting->renderer->light.spot = SP_FESPOTLIGHT(sp_specularlighting->firstChild()); } } } @@ -304,19 +304,19 @@ void SPFeSpecularLighting::build_renderer(Inkscape::Filters::Filter* filter) { //We assume there is at most one child nr_specularlighting->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(this->children)) { + if (SP_IS_FEDISTANTLIGHT(this->firstChild())) { nr_specularlighting->light_type = Inkscape::Filters::DISTANT_LIGHT; - nr_specularlighting->light.distant = SP_FEDISTANTLIGHT(this->children); + nr_specularlighting->light.distant = SP_FEDISTANTLIGHT(this->firstChild()); } - if (SP_IS_FEPOINTLIGHT(this->children)) { + if (SP_IS_FEPOINTLIGHT(this->firstChild())) { nr_specularlighting->light_type = Inkscape::Filters::POINT_LIGHT; - nr_specularlighting->light.point = SP_FEPOINTLIGHT(this->children); + nr_specularlighting->light.point = SP_FEPOINTLIGHT(this->firstChild()); } - if (SP_IS_FESPOTLIGHT(this->children)) { + if (SP_IS_FESPOTLIGHT(this->firstChild())) { nr_specularlighting->light_type = Inkscape::Filters::SPOT_LIGHT; - nr_specularlighting->light.spot = SP_FESPOTLIGHT(this->children); + nr_specularlighting->light.spot = SP_FESPOTLIGHT(this->firstChild()); } //nr_offset->set_dx(sp_offset->dx); diff --git a/src/main.cpp b/src/main.cpp index db908f640..7ab27dcb2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1483,10 +1483,8 @@ do_query_all_recurse (SPObject *o) } } - SPObject *child = o->children; - while (child) { - do_query_all_recurse (child); - child = child->next; + for(auto& child: o->_children) { + do_query_all_recurse (&child); } } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 55f4118b0..28bcadef5 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1010,7 +1010,7 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) for (std::vector::const_iterator item=rev.begin();item!=rev.end();++item) { SPObject *child = *item; // for each selected object, find the next sibling - for (SPObject *newref = child->next; newref; newref = newref->next) { + for (SPObject *newref = child->getNext(); newref; newref = newref->getNext()) { // if the sibling is an item AND overlaps our selection, SPItem *newItem = dynamic_cast(newref); if (newItem) { @@ -1138,15 +1138,16 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des for (std::vector::const_reverse_iterator l=rl.rbegin();l!=rl.rend();++l) { gint minpos; - SPObject *pp, *pc; + SPObject *pp; Inkscape::XML::Node *repr = (*l); pp = document->getObjectByRepr(repr->parent()); minpos = 0; g_assert(dynamic_cast(pp)); - pc = pp->firstChild(); - while (!dynamic_cast(pc)) { + for (auto& pc: pp->_children) { + if(dynamic_cast(&pc)) { + break; + } minpos += 1; - pc = pc->next; } repr->setPosition(minpos); } @@ -1197,8 +1198,8 @@ take_style_from_item(SPObject *object) if (css == NULL) return NULL; - if ((dynamic_cast(object) && object->children) || - (dynamic_cast(object) && object->children && object->children->next == NULL)) { + if ((dynamic_cast(object) && object->firstChild()) || + (dynamic_cast(object) && object->firstChild() && object->firstChild()->getNext() == NULL)) { // if this is a text with exactly one tspan child, merge the style of that tspan as well // If this is a group, merge the style of its topmost (last) child with style auto list = object->_children | boost::adaptors::reversed; @@ -2330,10 +2331,10 @@ typedef struct ListReverse { typedef GSList *Iterator; static Iterator children(SPObject *o) { - return make_list(o->firstChild(), NULL); + return make_list(o, NULL); } static Iterator siblings_after(SPObject *o) { - return make_list(o->parent->firstChild(), o); + return make_list(o->parent, o); } static void dispose(Iterator i) { g_slist_free(i); @@ -2347,13 +2348,12 @@ typedef struct ListReverse { private: static GSList *make_list(SPObject *object, SPObject *limit) { GSList *list = NULL; - while ( object != limit ) { - if (!object) { // TODO check if this happens in practice - g_warning("Unexpected list overrun"); + for (auto &child: object->_children) { + if (&child == limit) { break; } - list = g_slist_prepend(list, object); - object = object->getNext(); + list = g_slist_prepend(list, &child); + } return list; } diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index b18850914..09df234cc 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -246,8 +246,10 @@ int sp_filter_primitive_read_result(SPFilterPrimitive *prim, gchar const *name) */ int sp_filter_primitive_name_previous_out(SPFilterPrimitive *prim) { SPFilter *parent = SP_FILTER(prim->parent); - SPObject *i = parent->children; - while (i && i->next != prim) i = i->next; + SPObject *i = parent->firstChild(); + while (i && i->getNext() != prim) { + i = i->getNext(); + } if (i) { SPFilterPrimitive *i_prim = SP_FILTER_PRIMITIVE(i); if (i_prim->image_out < 0) { diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index da3f12f5f..170847c0b 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -420,10 +420,9 @@ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr } nr_filter->clear_primitives(); - SPObject *primitive_obj = sp_filter->children; - while (primitive_obj) { - if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) { - SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj); + for(auto& primitive_obj: sp_filter->_children) { + if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(&primitive_obj); g_assert(primitive != NULL); // if (((SPFilterPrimitiveClass*) G_OBJECT_GET_CLASS(primitive))->build_renderer) { @@ -433,7 +432,6 @@ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr // } // CPPIFY: => FilterPrimitive should be abstract. primitive->build_renderer(nr_filter); } - primitive_obj = primitive_obj->next; } } @@ -441,11 +439,12 @@ int sp_filter_primitive_count(SPFilter *filter) { g_assert(filter != NULL); int count = 0; - SPObject *primitive_obj = filter->children; - while (primitive_obj) { - if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) count++; - primitive_obj = primitive_obj->next; + for(auto& primitive_obj: filter->_children) { + if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + count++; + } } + return count; } @@ -513,10 +512,9 @@ Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) { g_assert(filter != NULL); int largest = 0; - SPObject *primitive_obj = filter->children; - while (primitive_obj) { - if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) { - Inkscape::XML::Node *repr = primitive_obj->getRepr(); + for(auto& primitive_obj: filter->_children) { + if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + Inkscape::XML::Node *repr = primitive_obj.getRepr(); char const *result = repr->attribute("result"); int index; if (result) @@ -530,7 +528,6 @@ Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) { } } } - primitive_obj = primitive_obj->next; } return "result" + Glib::Ascii::dtostr(largest + 1); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index eed882800..83fa5a1b4 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -440,9 +440,9 @@ Shape* SPFlowtext::_buildExclusionShape() const Shape *shape = new Shape(); Shape *shape_temp = new Shape(); - for (SPObject *child = children ; child ; child = child->getNext() ) { + for (auto& child: _children) { // RH: is it right that this shouldn't be recursive? - SPFlowregionExclude *c_child = dynamic_cast(child); + SPFlowregionExclude *c_child = dynamic_cast(const_cast(&child)); if ( c_child && c_child->computed && c_child->computed->hasEdges() ) { if (shape->hasEdges()) { shape_temp->Booleen(shape, c_child->computed, bool_op_union); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 7915b0453..8d482d9b1 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -583,7 +583,7 @@ sp_item_group_ungroup (SPGroup *group, std::vector &children, bool do_d if (text) { //this causes a change in text-on-path appearance when there is a non-conformal transform, see bug #1594565 double scale = (ctrans.expansionX() + ctrans.expansionY()) / 2.0; - SPTextPath * text_path = dynamic_cast(text->children); + SPTextPath * text_path = dynamic_cast(text->firstChild()); if (!text_path) { nrepr->setAttribute("transform", affinestr); } else { diff --git a/src/sp-item.cpp b/src/sp-item.cpp index ba57cec8b..53b4c0879 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -351,8 +351,8 @@ void SPItem::moveTo(SPItem *target, bool intoafter) { // Assume move to the "first" in the top node, find the top node intoafter = false; SPObject* bottom = this->document->getObjectByRepr(our_ref->root())->firstChild(); - while(!dynamic_cast(bottom->next)){ - bottom=bottom->next; + while(!dynamic_cast(bottom->getNext())){ + bottom = bottom->getNext(); } target_ref = bottom->getRepr(); } @@ -974,8 +974,8 @@ void SPItem::getSnappoints(std::vector &p, Inkscap for (std::list::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); ++o) { if (*o) { // obj is a group object, the children are the actual clippers - for (SPObject *child = (*o)->children ; child ; child = child->next) { - SPItem *item = dynamic_cast(child); + for(auto& child: (*o)->_children) { + SPItem *item = dynamic_cast(const_cast(&child)); if (item) { std::vector p_clip_or_mask; // Please note the recursive call here! @@ -1302,8 +1302,8 @@ void SPItem::adjust_stroke_width_recursive(double expansion) // A clone's child is the ghost of its original - we must not touch it, skip recursion if ( !dynamic_cast(this) ) { - for ( SPObject *o = children; o; o = o->getNext() ) { - SPItem *item = dynamic_cast(o); + for (auto& o: _children) { + SPItem *item = dynamic_cast(&o); if (item) { item->adjust_stroke_width_recursive(expansion); } @@ -1317,8 +1317,8 @@ void SPItem::freeze_stroke_width_recursive(bool freeze) // A clone's child is the ghost of its original - we must not touch it, skip recursion if ( !dynamic_cast(this) ) { - for ( SPObject *o = children; o; o = o->getNext() ) { - SPItem *item = dynamic_cast(o); + for (auto& o: _children) { + SPItem *item = dynamic_cast(&o); if (item) { item->freeze_stroke_width_recursive(freeze); } @@ -1337,10 +1337,10 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) rect->compensateRxRy(advertized_transform); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - SPItem *item = dynamic_cast(o); - if (item) { - sp_item_adjust_rects_recursive(item, advertized_transform); + for(auto& o: item->_children) { + SPItem *itm = dynamic_cast(&o); + if (itm) { + sp_item_adjust_rects_recursive(itm, advertized_transform); } } } @@ -1357,8 +1357,8 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af // also we do not recurse into clones, because a clone's child is the ghost of its original - // we must not touch it if (!(this && (dynamic_cast(this) || dynamic_cast(this)))) { - for (SPObject *o = children; o != NULL; o = o->next) { - SPItem *item = dynamic_cast(o); + for (auto& o: _children) { + SPItem *item = dynamic_cast(&o); if (item) { // At the level of the transformed item, t_ancestors is identity; // below it, it is the accmmulated chain of transforms from this level to the top level diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 2babf0441..587efd4f6 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -118,8 +118,7 @@ static gchar *sp_object_get_unique_id(SPObject *object, */ SPObject::SPObject() : cloned(0), uflags(0), mflags(0), hrefcount(0), _total_hrefcount(0), - document(NULL), parent(NULL), children(NULL), - next(NULL), id(NULL), repr(NULL), refCount(1),hrefList(std::list()), + document(NULL), parent(NULL), id(NULL), repr(NULL), refCount(1), hrefList(std::list()), _successor(NULL), _collection_policy(SPObject::COLLECT_WITH_PARENT), _label(NULL), _default_label(NULL) { @@ -532,15 +531,6 @@ void SPObject::attach(SPObject *object, SPObject *prev) } _children.insert(it, *object); - SPObject *next; - if (prev) { - next = prev->next; - prev->next = object; - } else { - next = this->children; - this->children = object; - } - object->next = next; if (!object->xml_space.set) object->xml_space.value = this->xml_space.value; } @@ -558,29 +548,6 @@ void SPObject::reorder(SPObject* obj, SPObject* prev) { } _children.splice(it, _children, _children.iterator_to(*obj)); - - - SPObject *old_prev=NULL; - for ( SPObject *child = children ; child && child != obj ; - child = child->next ) - { - old_prev = child; - } - - SPObject *next=obj->next; - if (old_prev) { - old_prev->next = next; - } else { - children = next; - } - if (prev) { - next = prev->next; - prev->next = obj; - } else { - next = children; - children = obj; - } - obj->next = next; } void SPObject::detach(SPObject *object) @@ -594,21 +561,6 @@ void SPObject::detach(SPObject *object) _children.erase(_children.iterator_to(*object)); object->releaseReferences(); - SPObject *prev=NULL; - for ( SPObject *child = this->children ; child && child != object ; - child = child->next ) - { - prev = child; - } - - SPObject *next=object->next; - if (prev) { - prev->next = next; - } else { - this->children = next; - } - - object->next = NULL; object->parent = NULL; this->_updateTotalHRefCount(-object->_total_hrefcount); @@ -851,6 +803,15 @@ SPObject *SPObject::getPrev() return prev; } +SPObject* SPObject::getNext() +{ + SPObject *next = nullptr; + if (parent && !parent->_children.empty() && &parent->_children.back() != this) { + next = &*(++parent->_children.iterator_to(*this)); + } + return next; +} + void SPObject::repr_child_added(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -1514,8 +1475,11 @@ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool } else { // remove the current content of the 'text' or 'desc' element - SPObject *child; - while (NULL != (child = elem->firstChild())) child->deleteObject(); + auto tmp = elem->_children | boost::adaptors::transformed([](SPObject& obj) { return &obj; }); + std::vector vec(tmp.begin(), tmp.end()); + for (auto &child: vec) { + child->deleteObject(); + } } // add the new content diff --git a/src/sp-object.h b/src/sp-object.h index 2534b2268..94c9d5629 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -208,8 +208,6 @@ public: unsigned int _total_hrefcount; /* our hrefcount + total descendants */ SPDocument *document; /* Document we are part of */ SPObject *parent; /* Our parent (only one allowed) */ - SPObject *children; /* Our children */ - SPObject *next; /* Next object in linked list */ private: SPObject(const SPObject&); @@ -300,11 +298,8 @@ public: */ SPObject const *nearestCommonAncestor(SPObject const *object) const; - /* A non-const version can be similarly constructed if you want one. - * (Don't just cast away the constness, which would be ill-formed.) */ - SPObject *getNext() {return next;} - - SPObject const *getNext() const {return next;} + /* Returns next object in sibling list or NULL. */ + SPObject *getNext(); /** * Returns previous object in sibling list or NULL. diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 5126ae094..193289c2b 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -676,9 +676,9 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root) item->updateRepr(); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) - _adjustFontsizeRecursive(SP_ITEM(o), ex, false); + for(auto& o: item->_children) { + if (SP_IS_ITEM(&o)) + _adjustFontsizeRecursive(SP_ITEM(&o), ex, false); } } @@ -695,9 +695,9 @@ void SPText::_adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double SP_TREF(item)->attributes.transform(m, ex, ex, is_root); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) - _adjustCoordsRecursive(SP_ITEM(o), m, ex, false); + for(auto& o: item->_children) { + if (SP_IS_ITEM(&o)) + _adjustCoordsRecursive(SP_ITEM(&o), m, ex, false); } } diff --git a/src/sp-use.cpp b/src/sp-use.cpp index c8a0830c1..cef967c90 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -436,27 +436,23 @@ void SPUse::move_compensate(Geom::Affine const *mp) { //BUT move clippaths accordingly. //if clone has a clippath, move it accordingly if(clip_ref->getObject()){ - SPObject *clip = clip_ref->getObject()->firstChild() ; - while(clip){ - SPItem *item = (SPItem*) clip; + for(auto& clip: clip_ref->getObject()->_children){ + SPItem *item = (SPItem*) &clip; if(item){ item->transform *= m; Geom::Affine identity; - item->doWriteTransform(clip->getRepr(),item->transform, &identity); + item->doWriteTransform(clip.getRepr(),item->transform, &identity); } - clip = clip->getNext(); } } if(mask_ref->getObject()){ - SPObject *mask = mask_ref->getObject()->firstChild() ; - while(mask){ - SPItem *item = (SPItem*) mask; + for(auto& mask: mask_ref->getObject()->_children){ + SPItem *item = (SPItem*) &mask; if(item){ item->transform *= m; Geom::Affine identity; - item->doWriteTransform(mask->getRepr(),item->transform, &identity); + item->doWriteTransform(mask.getRepr(),item->transform, &identity); } - mask = mask->getNext(); } } return; @@ -480,27 +476,23 @@ void SPUse::move_compensate(Geom::Affine const *mp) { //if clone has a clippath, move it accordingly if(clip_ref->getObject()){ - SPObject *clip = clip_ref->getObject()->firstChild() ; - while(clip){ - SPItem *item = (SPItem*) clip; + for(auto& clip: clip_ref->getObject()->_children){ + SPItem *item = (SPItem*) &clip; if(item){ item->transform *= clone_move.inverse(); Geom::Affine identity; - item->doWriteTransform(clip->getRepr(),item->transform, &identity); + item->doWriteTransform(clip.getRepr(),item->transform, &identity); } - clip = clip->getNext(); } } if(mask_ref->getObject()){ - SPObject *mask = mask_ref->getObject()->firstChild() ; - while(mask){ - SPItem *item = (SPItem*) mask; + for(auto& mask: mask_ref->getObject()->_children){ + SPItem *item = (SPItem*) &mask; if(item){ item->transform *= clone_move.inverse(); Geom::Affine identity; - item->doWriteTransform(mask->getRepr(),item->transform, &identity); + item->doWriteTransform(mask.getRepr(),item->transform, &identity); } - mask = mask->getNext(); } } diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index f539652c0..56048d1f7 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -142,8 +142,8 @@ text_put_on_path() // make a list of text children GSList *text_reprs = NULL; - for (SPObject *o = text->children; o != NULL; o = o->next) { - text_reprs = g_slist_prepend(text_reprs, o->getRepr()); + for(auto& o: text->_children) { + text_reprs = g_slist_prepend(text_reprs, o.getRepr()); } // create textPath and put it into the text @@ -353,9 +353,9 @@ text_flow_into_shape() Inkscape::GC::release(text_repr); } else { // reflow an already flowed text, preserving paras - for (SPObject *o = text->children; o != NULL; o = o->next) { - if (SP_IS_FLOWPARA(o)) { - Inkscape::XML::Node *para_repr = o->getRepr()->duplicate(xml_doc); + for(auto& o: text->_children) { + if (SP_IS_FLOWPARA(&o)) { + Inkscape::XML::Node *para_repr = o.getRepr()->duplicate(xml_doc); root_repr->appendChild(para_repr); object = doc->getObjectByRepr(para_repr); g_return_if_fail(SP_IS_FLOWPARA(object)); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index b03be792b..6ca2fe948 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -944,13 +944,10 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str) gchar *content = g_strdup (str); repr->setContent(""); - SPObject *child = object->firstChild(); - while (child) { - SPObject *next = child->getNext(); - if (!SP_IS_FLOWREGION(child) && !SP_IS_FLOWREGIONEXCLUDE(child)) { - repr->removeChild(child->getRepr()); + for (auto& child: object->_children) { + if (!SP_IS_FLOWREGION(&child) && !SP_IS_FLOWREGIONEXCLUDE(&child)) { + repr->removeChild(child.getRepr()); } - child = next; } gchar *p = content; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 75c6c5bcc..48d53857b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -839,8 +839,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) SPObject *mask = item->mask_ref->getObject(); _copyNode(mask->getRepr(), _doc, _defs); // recurse into the mask for its gradients etc. - for (SPObject *o = mask->children ; o != NULL ; o = o->next) { - SPItem *childItem = dynamic_cast(o); + for(auto& o: mask->_children) { + SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); } @@ -857,8 +857,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } // recurse - for (SPObject *o = item->children ; o != NULL ; o = o->next) { - SPItem *childItem = dynamic_cast(o); + for(auto& o: item->_children) { + SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 589973162..df37eb005 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1315,12 +1315,7 @@ void DocumentProperties::changeEmbeddedScript(){ for (std::vector::const_iterator it = current.begin(); it != current.end(); ++it) { SPObject* obj = *it; if (id == obj->getId()){ - - int count=0; - for ( SPObject *child = obj->children ; child; child = child->next ) - { - count++; - } + int count = (int) obj->_children.size(); if (count>1) g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); @@ -1364,8 +1359,11 @@ void DocumentProperties::editEmbeddedScript(){ //XML Tree being used directly here while it shouldn't be. Inkscape::XML::Node *repr = obj->getRepr(); if (repr){ - SPObject *child; - while (NULL != (child = obj->firstChild())) child->deleteObject(); + auto tmp = obj->_children | boost::adaptors::transformed([](SPObject& o) { return &o; }); + std::vector vec(tmp.begin(), tmp.end()); + for (auto &child: vec) { + child->deleteObject(); + } obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str())); //TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text()); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index a60d1ddff..1be5d540a 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1058,11 +1058,10 @@ public: // FuncNode can be in any order so we must search to find correct one. SPFeFuncNode* find_node(SPFeComponentTransfer* ct) { - SPObject* node = ct->children; SPFeFuncNode* funcNode = NULL; bool found = false; - for(;node;node=node->next){ - funcNode = SP_FEFUNCNODE(node); + for(auto& node: ct->_children) { + funcNode = SP_FEFUNCNODE(&node); if( funcNode->channel == _channel ) { found = true; break; @@ -1226,7 +1225,7 @@ protected: _locked = true; - SPObject* child = o->children; + SPObject* child = o->firstChild(); if(SP_IS_FEDISTANTLIGHT(child)) _light_source.set_active(0); @@ -1251,7 +1250,7 @@ private: if(prim) { _locked = true; - SPObject* child = prim->children; + SPObject* child = prim->firstChild(); const int ls = _light_source.get_active_row_number(); // Check if the light source type has changed if(!(ls == -1 && !child) && @@ -1285,8 +1284,8 @@ private: _light_box.show_all(); SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); - if(prim && prim->children) - _settings.show_and_update(_light_source.get_active_data()->id, prim->children); + if(prim && prim->firstChild()) + _settings.show_and_update(_light_source.get_active_data()->id, prim->firstChild()); } FilterEffectsDialog& _dialog; @@ -1869,26 +1868,25 @@ void FilterEffectsDialog::PrimitiveList::update() bool active_found = false; _dialog._primitive_box->set_sensitive(true); _dialog.update_filter_general_settings_view(); - for(SPObject *prim_obj = f->children; - prim_obj && SP_IS_FILTER_PRIMITIVE(prim_obj); - prim_obj = prim_obj->next) { - SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(prim_obj); - if(prim) { - Gtk::TreeModel::Row row = *_model->append(); - row[_columns.primitive] = prim; - - //XML Tree being used directly here while it shouldn't be. - row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); - row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); - - if (prim->getId()) { - row[_columns.id] = Glib::ustring(prim->getId()); - } - - if(prim == active_prim) { - get_selection()->select(row); - active_found = true; - } + for(auto& prim_obj: f->_children) { + SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(&prim_obj); + if(!prim) { + break; + } + Gtk::TreeModel::Row row = *_model->append(); + row[_columns.primitive] = prim; + + //XML Tree being used directly here while it shouldn't be. + row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); + row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); + + if (prim->getId()) { + row[_columns.id] = Glib::ustring(prim->getId()); + } + + if(prim == active_prim) { + get_selection()->select(row); + active_found = true; } } @@ -3098,7 +3096,7 @@ void FilterEffectsDialog::set_filternode_attr(const AttrWidget* input) void FilterEffectsDialog::set_child_attr_direct(const AttrWidget* input) { - set_attr(_primitive_list.get_selected()->children, input->get_attribute(), input->get_as_attribute().c_str()); + set_attr(_primitive_list.get_selected()->firstChild(), input->get_attribute(), input->get_as_attribute().c_str()); } void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, const gchar* val) diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 00482c573..e4639745f 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -340,12 +340,11 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/) void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) { if ( _desktop && obj ) { - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - - if (SP_IS_ITEM(child)) + for(auto& child: obj->_children) { + if (SP_IS_ITEM(&child)) { - SPItem * item = SP_ITEM(child); - SPGroup * group = SP_IS_GROUP(child) ? SP_GROUP(child) : 0; + SPItem * item = SP_ITEM(&child); + SPGroup * group = SP_IS_GROUP(&child) ? SP_GROUP(&child) : 0; //Add the item to the tree and set the column information Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); @@ -372,14 +371,14 @@ void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) } //Add an object watcher to the item - ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, child); - child->getRepr()->addObserver(*w); + ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, &child); + child.getRepr()->addObserver(*w); _objectWatchers.push_back(w); //If the item is a group, recursively add its children if (group) { - _addObject( child, &row ); + _addObject( &child, &row ); } } } @@ -399,9 +398,8 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) { //end mark if (recurse) { - for (SPObject * iter = obj->children; iter != NULL; iter = iter->next) - { - _updateObject(iter, recurse); + for (auto& iter: obj->_children) { + _updateObject(&iter, recurse); } } } @@ -520,19 +518,22 @@ void ObjectsPanel::_setCompositingValues(SPItem *item) SPGaussianBlur *spblur = NULL; if (item->style->getFilter()) { - for(SPObject *primitive_obj = item->style->getFilter()->children; primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj); primitive_obj = primitive_obj->next) { - if(SP_IS_FEBLEND(primitive_obj) && !spblend) { - //Get the blend mode - spblend = SP_FEBLEND(primitive_obj); - } - - if(SP_IS_GAUSSIANBLUR(primitive_obj) && !spblur) { - //Get the blur value - spblur = SP_GAUSSIANBLUR(primitive_obj); - } + for (auto& primitive_obj: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + break; } + if(SP_IS_FEBLEND(&primitive_obj) && !spblend) { + //Get the blend mode + spblend = SP_FEBLEND(&primitive_obj); + } + + if(SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) { + //Get the blur value + spblur = SP_GAUSSIANBLUR(&primitive_obj); + } + } } - + //Set the blend mode _fe_cb.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL); @@ -1404,9 +1405,10 @@ void ObjectsPanel::_setCollapsed(SPGroup * group) { group->setExpanded(false); group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); - for (SPObject *iter = group->children; iter != NULL; iter = iter->next) - { - if (SP_IS_GROUP(iter)) _setCollapsed(SP_GROUP(iter)); + for (auto& iter: group->_children) { + if (SP_IS_GROUP(&iter)) { + _setCollapsed(SP_GROUP(&iter)); + } } } @@ -1521,11 +1523,14 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl if (blendmode != "normal") { gdouble radius = 0; if (item->style->getFilter()) { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_GAUSSIANBLUR(primitive)) { + for (auto& primitive: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_GAUSSIANBLUR(&primitive)) { Geom::OptRect bbox = item->bounds(SPItem::GEOMETRIC_BBOX); if (bbox) { - radius = SP_GAUSSIANBLUR(primitive)->stdDeviation.getNumber(); + radius = SP_GAUSSIANBLUR(&primitive)->stdDeviation.getNumber(); } } } @@ -1533,13 +1538,16 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius); sp_style_set_property_url(item, "filter", filter, false); } else { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_FEBLEND(primitive)) { - primitive->deleteObject(); + for (auto& primitive: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_FEBLEND(&primitive)) { + primitive.deleteObject(); break; } } - if (!item->style->getFilter()->children) { + if (!item->style->getFilter()->firstChild()) { remove_filter(item, false); } } @@ -1590,13 +1598,16 @@ void ObjectsPanel::_blurChangedIter(const Gtk::TreeIter& iter, double blur) SPFilter *filter = modify_filter_gaussian_blur_from_item(_document, item, radius); sp_style_set_property_url(item, "filter", filter, false); } else if (item->style->filter.set && item->style->getFilter()) { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_GAUSSIANBLUR(primitive)) { - primitive->deleteObject(); + for (auto& primitive: item->style->getFilter()->_children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_GAUSSIANBLUR(&primitive)) { + primitive.deleteObject(); break; } } - if (!item->style->getFilter()->children) { + if (!item->style->getFilter()->firstChild()) { remove_filter(item, false); } } diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 7b256fc8f..93bd67a3d 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -115,11 +115,11 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){ void SvgFontsDialog::AttrEntry::on_attr_changed(){ SPObject* o = NULL; - for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){ + for (auto& node: dialog->get_selected_spfont()->_children) { switch(this->attr){ case SP_PROP_FONT_FAMILY: - if (SP_IS_FONTFACE(node)){ - o = node; + if (SP_IS_FONTFACE(&node)){ + o = &node; continue; } break; @@ -170,9 +170,9 @@ void GlyphComboBox::update(SPFont* spfont){ this->append(""); //Gtk is refusing to clear the combobox when I comment out this line this->remove_all(); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_GLYPH(node)){ - this->append((static_cast(node))->unicode); + for (auto& node: spfont->_children) { + if (SP_IS_GLYPH(&node)){ + this->append((static_cast(&node))->unicode); } } } @@ -308,10 +308,9 @@ void SvgFontsDialog::update_global_settings_tab(){ SPFont* font = get_selected_spfont(); if (!font) return; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ - _familyname_entry->set_text((SP_FONTFACE(obj))->font_family); + for (auto& obj: font->_children) { + if (SP_IS_FONTFACE(&obj)){ + _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family); } } } @@ -414,12 +413,12 @@ SvgFontsDialog::populate_glyphs_box() SPFont* spfont = this->get_selected_spfont(); _glyphs_observer.set(spfont); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_GLYPH(node)){ + for (auto& node: spfont->_children) { + if (SP_IS_GLYPH(&node)){ Gtk::TreeModel::Row row = *(_GlyphsListStore->append()); - row[_GlyphsListColumns.glyph_node] = static_cast(node); - row[_GlyphsListColumns.glyph_name] = (static_cast(node))->glyph_name; - row[_GlyphsListColumns.unicode] = (static_cast(node))->unicode; + row[_GlyphsListColumns.glyph_node] = static_cast(&node); + row[_GlyphsListColumns.glyph_name] = (static_cast(&node))->glyph_name; + row[_GlyphsListColumns.unicode] = (static_cast(&node))->unicode; } } } @@ -432,13 +431,13 @@ SvgFontsDialog::populate_kerning_pairs_box() SPFont* spfont = this->get_selected_spfont(); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_HKERN(node)){ + for (auto& node: spfont->_children) { + if (SP_IS_HKERN(&node)){ Gtk::TreeModel::Row row = *(_KerningPairsListStore->append()); - row[_KerningPairsListColumns.first_glyph] = (static_cast(node))->u1->attribute_string().c_str(); - row[_KerningPairsListColumns.second_glyph] = (static_cast(node))->u2->attribute_string().c_str(); - row[_KerningPairsListColumns.kerning_value] = (static_cast(node))->k; - row[_KerningPairsListColumns.spnode] = static_cast(node); + row[_KerningPairsListColumns.first_glyph] = (static_cast(&node))->u1->attribute_string().c_str(); + row[_KerningPairsListColumns.second_glyph] = (static_cast(&node))->u2->attribute_string().c_str(); + row[_KerningPairsListColumns.kerning_value] = (static_cast(&node))->k; + row[_KerningPairsListColumns.spnode] = static_cast(&node); } } } @@ -493,11 +492,10 @@ void SvgFontsDialog::add_glyph(){ Geom::PathVector SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ double units_per_em = 1000; - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: get_selected_spfont()->_children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - sp_repr_get_double(obj->getRepr(), "units-per-em", &units_per_em); + sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em); } } @@ -576,13 +574,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_MISSING_GLYPH(obj)){ + for (auto& obj: get_selected_spfont()->_children) { + if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. gchar *str = sp_svg_write_path (flip_coordinate_system(pathv)); - obj->getRepr()->setAttribute("d", str); + obj.getRepr()->setAttribute("d", str); g_free(str); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } @@ -599,11 +596,10 @@ void SvgFontsDialog::reset_missing_glyph_description(){ } SPDocument* doc = desktop->getDocument(); - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_MISSING_GLYPH(obj)){ + for (auto& obj: get_selected_spfont()->_children) { + if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); + obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); } } @@ -738,12 +734,12 @@ void SvgFontsDialog::add_kerning_pair(){ //look for this kerning pair on the currently selected font this->kerning_pair = NULL; - for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){ + for (auto& node: get_selected_spfont()->_children) { //TODO: It is not really correct to get only the first byte of each string. //TODO: We should also support vertical kerning - if (SP_IS_HKERN(node) && (static_cast(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) - && (static_cast(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ - this->kerning_pair = static_cast(node); + if (SP_IS_HKERN(&node) && (static_cast(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) + && (static_cast(&node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ + this->kerning_pair = static_cast(&node); continue; } } @@ -852,11 +848,10 @@ SPFont *new_font(SPDocument *document) void set_font_family(SPFont* font, char* str){ if (!font) return; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: font->_children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("font-family", str); + obj.getRepr()->setAttribute("font-family", str); } } @@ -873,11 +868,10 @@ void SvgFontsDialog::add_font(){ font->setLabel(os.str().c_str()); os2 << "SVGFont " << count; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: font->_children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("font-family", os2.str().c_str()); + obj.getRepr()->setAttribute("font-family", os2.str().c_str()); } } diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 53641c0de..61c8b5d37 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -399,26 +399,26 @@ void TagsPanel::_objectsChanged(SPObject* root) void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* parentRow ) { if ( _desktop && obj ) { - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG(child)) + for (auto& child: obj->_children) { + if (SP_IS_TAG(&child)) { Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); Gtk::TreeModel::Row row = *iter; - row[_model->_colObject] = child; + row[_model->_colObject] = &child; row[_model->_colParentObject] = NULL; - row[_model->_colLabel] = child->label() ? child->label() : child->getId(); + row[_model->_colLabel] = child.label() ? child.label() : child.getId(); row[_model->_colAddRemove] = true; row[_model->_colAllowAddRemove] = true; _tree.expand_to_path( _store->get_path(iter) ); - TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child); - child->getRepr()->addObserver(*w); + TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child); + child.getRepr()->addObserver(*w); _objectWatchers.push_back(w); - _addObject( doc, child, &row ); + _addObject( doc, &child, &row ); } } - if (SP_IS_TAG(obj) && obj->children) + if (SP_IS_TAG(obj) && obj->firstChild()) { Gtk::TreeModel::iterator iteritems = parentRow ? _store->append(parentRow->children()) : _store->prepend(); Gtk::TreeModel::Row rowitems = *iteritems; @@ -429,16 +429,16 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* rowitems[_model->_colAllowAddRemove] = false; _tree.expand_to_path( _store->get_path(iteritems) ); - - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG_USE(child)) + + for (auto& child: obj->_children) { + if (SP_IS_TAG_USE(&child)) { - SPItem *item = SP_TAG_USE(child)->ref->getObject(); + SPItem *item = SP_TAG_USE(&child)->ref->getObject(); Gtk::TreeModel::iterator iter = _store->prepend(rowitems->children()); Gtk::TreeModel::Row row = *iter; - row[_model->_colObject] = child; + row[_model->_colObject] = &child; row[_model->_colParentObject] = NULL; - row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(child)->href; + row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(&child)->href; row[_model->_colAddRemove] = false; row[_model->_colAllowAddRemove] = true; @@ -447,7 +447,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* } if (item) { - TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child, item->getRepr()); + TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child, item->getRepr()); item->getRepr()->addObserver(*w); _objectWatchers.push_back(w); } @@ -459,12 +459,11 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* void TagsPanel::_select_tag( SPTag * tag ) { - for (SPObject * child = tag->children; child != NULL; child = child->next) - { - if (SP_IS_TAG(child)) { - _select_tag(SP_TAG(child)); - } else if (SP_IS_TAG_USE(child)) { - SPObject * obj = SP_TAG_USE(child)->ref->getObject(); + for (auto& child: tag->_children) { + if (SP_IS_TAG(&child)) { + _select_tag(SP_TAG(&child)); + } else if (SP_IS_TAG_USE(&child)) { + SPObject * obj = SP_TAG_USE(&child)->ref->getObject(); if (obj) { if (_desktop->selection->isEmpty()) _desktop->setCurrentLayer(obj->parent); _desktop->selection->add(obj); @@ -650,8 +649,8 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) for(auto i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG_USE(child) && SP_TAG_USE(child)->ref->getObject() == newobj) { + for (auto& child: obj->_children) { + if (SP_IS_TAG_USE(&child) && SP_TAG_USE(&child)->ref->getObject() == newobj) { addchild = false; } } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 736dafa50..3dfac5e3d 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -378,8 +378,8 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape r.role = role; s.insert(r); } else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) { - for (SPObject *c = obj->children; c; c = c->next) { - gather_items(nt, base, c, role, s); + for (auto& c: obj->_children) { + gather_items(nt, base, &c, role, s); } } else if (SP_IS_ITEM(obj)) { SPItem *item = static_cast(obj); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index d048c318b..7da0973d5 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -951,9 +951,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, Geom::Affine i2dt = item->i2dt_affine (); if (style->filter.set && style->getFilter()) { //cycle through filter primitives - SPObject *primitive_obj = style->getFilter()->children; - while (primitive_obj) { - SPFilterPrimitive *primitive = dynamic_cast(primitive_obj); + for (auto& primitive_obj: style->getFilter()->_children) { + SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { //if primitive is gaussianblur SPGaussianBlur * spblur = dynamic_cast(primitive); @@ -962,7 +961,6 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, blur_now += num * i2dt.descrim(); // sum all blurs in the filter } } - primitive_obj = primitive_obj->next; } } double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 078834131..23802ae65 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -76,10 +76,11 @@ bool URIReference::_acceptObject(SPObject *obj) const std::vector positions; while (owner->cloned) { int position = 0; - SPObject *c = owner->parent->firstChild(); - while (c != owner && dynamic_cast(c)) { + for (auto &child: owner->parent->_children) { + if(&child == owner) { + break; + } position++; - c = c->next; } positions.push_back(position); owner = owner->parent; -- 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/box3d.cpp | 10 +++--- src/conn-avoid-ref.cpp | 2 +- src/desktop-style.cpp | 8 ++--- src/display/nr-svgfonts.cpp | 8 ++--- src/document.cpp | 22 ++++++------- src/extension/internal/cairo-render-context.cpp | 6 ++-- src/extension/internal/cairo-renderer.cpp | 4 +-- src/extension/internal/emf-print.cpp | 4 +-- src/extension/internal/javafx-out.cpp | 4 +-- src/extension/internal/metafile-print.cpp | 4 +-- src/extension/internal/pov-out.cpp | 2 +- src/file.cpp | 4 +-- src/filter-chemistry.cpp | 10 +++--- src/filters/componenttransfer.cpp | 2 +- src/filters/merge.cpp | 2 +- src/gradient-chemistry.cpp | 6 ++-- src/gradient-drag.cpp | 2 +- src/helper/pixbuf-ops.cpp | 2 +- src/helper/png-write.cpp | 2 +- src/helper/stock-items.cpp | 6 ++-- src/id-clash.cpp | 4 +-- src/layer-fns.cpp | 12 +++---- src/libnrtype/font-lister.cpp | 2 +- src/live_effects/lpe-perspective_path.cpp | 2 +- src/main.cpp | 4 +-- src/object-set.cpp | 6 ++-- src/object-snapper.cpp | 2 +- src/persp3d.cpp | 4 +-- src/selection-chemistry.cpp | 20 +++++------ src/sp-clippath.cpp | 10 +++--- src/sp-defs.cpp | 6 ++-- src/sp-filter.cpp | 10 +++--- src/sp-flowdiv.cpp | 24 +++++++------- src/sp-flowregion.cpp | 20 +++++------ src/sp-flowtext.cpp | 18 +++++----- src/sp-gradient.cpp | 16 ++++----- src/sp-hatch.cpp | 6 ++-- src/sp-item-group.cpp | 22 ++++++------- src/sp-item.cpp | 34 +++++++++---------- src/sp-mask.cpp | 4 +-- src/sp-mesh-array.cpp | 12 +++---- src/sp-namedview.cpp | 4 +-- src/sp-object-group.cpp | 4 +-- src/sp-object.cpp | 44 ++++++++++++------------- src/sp-object.h | 12 +++---- src/sp-pattern.cpp | 10 +++--- src/sp-root.cpp | 6 ++-- src/sp-switch.cpp | 2 +- src/sp-text.cpp | 18 +++++----- src/sp-tref.cpp | 2 +- src/sp-tspan.cpp | 18 +++++----- src/sp-use.cpp | 8 ++--- src/splivarot.cpp | 2 +- src/text-chemistry.cpp | 6 ++-- src/text-editing.cpp | 16 ++++----- src/ui/clipboard.cpp | 6 ++-- src/ui/dialog/clonetiler.cpp | 8 ++--- src/ui/dialog/document-properties.cpp | 4 +-- src/ui/dialog/filter-effects-dialog.cpp | 10 +++--- src/ui/dialog/find.cpp | 2 +- src/ui/dialog/font-substitution.cpp | 2 +- src/ui/dialog/objects.cpp | 16 ++++----- src/ui/dialog/spellcheck.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.cpp | 22 ++++++------- src/ui/dialog/symbols.cpp | 4 +-- src/ui/dialog/tags.cpp | 8 ++--- src/ui/tools/box3d-tool.cpp | 2 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/node-tool.cpp | 2 +- src/ui/tools/tweak-tool.cpp | 8 ++--- src/ui/widget/layer-selector.cpp | 2 +- src/uri-references.cpp | 2 +- src/widgets/gradient-toolbar.cpp | 4 +-- src/widgets/gradient-vector.cpp | 8 ++--- src/widgets/stroke-marker-selector.cpp | 2 +- 75 files changed, 308 insertions(+), 308 deletions(-) (limited to 'src') diff --git a/src/box3d.cpp b/src/box3d.cpp index 0a33ee306..f8ef158b2 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -259,7 +259,7 @@ void box3d_position_set(SPBox3D *box) { /* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in box3d_side_position_set() to avoid update conflicts with the parent box) */ - for (auto& obj: box->_children) { + for (auto& obj: box->children) { Box3DSide *side = dynamic_cast(&obj); if (side) { box3d_side_position_set(side); @@ -275,7 +275,7 @@ Geom::Affine SPBox3D::set_transform(Geom::Affine const &xform) { gdouble const sw = hypot(ret[0], ret[1]); gdouble const sh = hypot(ret[2], ret[3]); - for (auto& child: _children) { + for (auto& child: children) { SPItem *childitem = dynamic_cast(&child); if (childitem) { // Adjust stroke width @@ -1074,7 +1074,7 @@ box3d_recompute_z_orders (SPBox3D *box) { static std::map box3d_get_sides(SPBox3D *box) { std::map sides; - for (auto& obj: box->_children) { + for (auto& obj: box->children) { Box3DSide *side = dynamic_cast(&obj); if (side) { sides[Box3D::face_to_int(side->getFaceId())] = side; @@ -1217,7 +1217,7 @@ static void box3d_extract_boxes_rec(SPObject *obj, std::list &boxes) if (box) { boxes.push_back(box); } else if (dynamic_cast(obj)) { - for (auto& child: obj->_children) { + for (auto& child: obj->children) { box3d_extract_boxes_rec(&child, boxes); } } @@ -1276,7 +1276,7 @@ SPGroup *box3d_convert_to_group(SPBox3D *box) // create a new group and add the sides (converted to ordinary paths) as its children Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); - for (auto& obj: box->_children) { + for (auto& obj: box->children) { Box3DSide *side = dynamic_cast(&obj); if (side) { Inkscape::XML::Node *repr = box3d_side_convert_to_path(side); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 638ba48e3..560f660b2 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -334,7 +334,7 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) std::vector get_avoided_items(std::vector &list, SPObject *from, SPDesktop *desktop, bool initialised) { - for (auto& child: from->_children) { + for (auto& child: from->children) { if (SP_IS_ITEM(&child) && !desktop->isLayer(SP_ITEM(&child)) && !SP_ITEM(&child)->isLocked() && diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index e4b7c6a83..01586096c 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -163,7 +163,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines) return; } - for (auto& child: o->_children) { + for (auto& child: o->children) { if (sp_repr_css_property(css, "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. @@ -1714,7 +1714,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) int blendcount = 0; // determine whether filter is simple (blend and/or blur) or complex - for(auto& primitive_obj: style->getFilter()->_children) { + for(auto& primitive_obj: style->getFilter()->children) { SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (!primitive) { break; @@ -1731,7 +1731,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) // simple filter if(blurcount == 1 || blendcount == 1) { - for(auto& primitive_obj: style->getFilter()->_children) { + for(auto& primitive_obj: style->getFilter()->children) { SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (!primitive) { break; @@ -1810,7 +1810,7 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) //if object has a filter if (style->filter.set && style->getFilter()) { //cycle through filter primitives - for(auto& primitive_obj: style->getFilter()->_children) { + for(auto& primitive_obj: style->getFilter()->children) { SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 927093ef4..53a5cba49 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -203,7 +203,7 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, //check whether is there a glyph declared on the SVG document // that matches with the text string in its current position if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){ - for(auto& node: font->_children) { + for(auto& node: font->children) { if (!previous_unicode) { break; } @@ -276,7 +276,7 @@ SvgFont::glyph_modified(SPObject* /* blah */, unsigned int /* bleh */){ Geom::PathVector SvgFont::flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv){ double units_per_em = 1000; - for(auto& obj: spfont->_children) { + for(auto& obj: spfont->children) { if (dynamic_cast(&obj)) { //XML Tree being directly used here while it shouldn't be. sp_repr_get_double(obj.getRepr(), "units_per_em", &units_per_em); @@ -344,7 +344,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, if (node->hasChildren()){ //render the SVG described on this glyph's child nodes. - for(auto& child: node->_children) { + for(auto& child: node->children) { { SPPath *path = dynamic_cast(&child); if (path) { @@ -379,7 +379,7 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, cairo_font_face_t* SvgFont::get_font_face(){ if (!this->userfont) { - for(auto& node: font->_children) { + for(auto& node: font->children) { SPGlyph *glyph = dynamic_cast(&node); if (glyph) { glyphs.push_back(glyph); 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"); diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index bedf2fa7f..1310bb343 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -986,7 +986,7 @@ void CairoRenderContext::popState(void) static bool pattern_hasItemChildren(SPPattern *pat) { - for (auto& child: pat->_children) { + for (auto& child: pat->children) { if (SP_IS_ITEM (&child)) { return true; } @@ -1086,7 +1086,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (auto& child: pat_i->_children) { + for (auto& child: pat_i->children) { if (SP_IS_ITEM(&child)) { SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); _renderer->renderItem(pattern_ctx, SP_ITEM(&child)); @@ -1115,7 +1115,7 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // hide all items for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for (auto& child: pat_i->_children) { + for (auto& child: pat_i->children) { if (SP_IS_ITEM(&child)) { SP_ITEM(&child)->invoke_hide(dkey); } diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 088eaf11d..cd96a7f58 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -741,7 +741,7 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) TRACE(("BEGIN clip\n")); SPObject const *co = cp; - for (auto& child: co->_children) { + for (auto& child: co->children) { SPItem const *item = dynamic_cast(&child); if (item) { @@ -800,7 +800,7 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) TRACE(("BEGIN mask\n")); SPObject const *co = mask; - for (auto& child: co->_children) { + for (auto& child: co->children) { SPItem const *item = dynamic_cast(&child); if (item) { // TODO fix const correctness: diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index c0c086c7a..d4c5d95a3 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -1042,7 +1042,7 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ /* find the clipping path */ Geom::PathVector combined_pathvector; Geom::Affine tfc; // clipping transform, generally not the same as item transform - for (auto& child: scp->_children) { + for (auto& child: scp->children) { item = SP_ITEM(&child); if (!item) { break; @@ -1085,7 +1085,7 @@ Geom::PathVector PrintEmf::merge_PathVector_with_group(Geom::PathVector const &c new_combined_pathvector = combined_pathvector; SPGroup *group = SP_GROUP(item); Geom::Affine tfc = item->transform * transform; - for (auto& child: group->_children) { + for (auto& child: group->children) { item = SP_ITEM(&child); if (!item) { break; diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 51608e4fa..d7ad7e6f7 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -732,7 +732,7 @@ bool JavaFXOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (auto &child: obj->_children) + for (auto &child: obj->children) { if (!doTreeRecursive(doc, &child)) { return false; @@ -804,7 +804,7 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (auto &child: obj->_children) + for (auto &child: obj->children) { if (!doBody(doc, &child)) { return false; diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 5c10f7dd9..061eb634d 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -293,7 +293,7 @@ void PrintMetafile::brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf } // still looking? Look at this pattern's children, if there are any - for (auto& child: pat_i->_children) { + for (auto& child: pat_i->children) { if (*epixbuf || *hatchType != -1) { break; } @@ -304,7 +304,7 @@ void PrintMetafile::brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf *epixbuf = ((SPImage *)parent)->pixbuf; return; } else { // some inkscape rearrangements pass through nodes between pattern and image which are not classified as either. - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (*epixbuf || *hatchType != -1) { break; } diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 08f533010..8df883069 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -479,7 +479,7 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (auto &child: obj->_children) + for (auto &child: obj->children) { if (!doTreeRecursive(doc, &child)) return false; diff --git a/src/file.cpp b/src/file.cpp index 11e5f0a42..9ba180cb4 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1204,7 +1204,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; - for (auto& child: doc->getRoot()->_children) { + for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { items_count++; } @@ -1234,7 +1234,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for (auto& child: doc->getRoot()->_children) { + for (auto& child: doc->getRoot()->children) { if (SP_IS_ITEM(&child)) { Inkscape::XML::Node *newitem = child.getRepr()->duplicate(xml_in_doc); diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 2e99842ec..3255bfb70 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -51,7 +51,7 @@ static guint count_filter_hrefs(SPObject *o, SPFilter *filter) i ++; } - for (auto& child: o->_children) { + for (auto& child: o->children) { i += count_filter_hrefs(&child, filter); } @@ -491,14 +491,14 @@ void remove_filter_gaussian_blur (SPObject *item) bool filter_is_single_gaussian_blur(SPFilter *filter) { - return (filter->_children.size() == 1 && - SP_IS_GAUSSIANBLUR(&filter->_children.front())); + return (filter->children.size() == 1 && + SP_IS_GAUSSIANBLUR(&filter->children.front())); } double get_single_gaussian_blur_radius(SPFilter *filter) { - if (filter->_children.size() == 1 && - SP_IS_GAUSSIANBLUR(&filter->_children.front())) { + if (filter->children.size() == 1 && + SP_IS_GAUSSIANBLUR(&filter->children.front())) { SPGaussianBlur *gb = SP_GAUSSIANBLUR(filter->firstChild()); double x = gb->stdDeviation.getNumber(); diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index e52f6d478..bc91e58a7 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -49,7 +49,7 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c { if (sp_componenttransfer->renderer) { bool set[4] = {false, false, false, false}; - for(auto& node: sp_componenttransfer->_children) { + for(auto& node: sp_componenttransfer->children) { int i = 4; SPFeFuncNode *funcNode = SP_FEFUNCNODE(&node); diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index 6af1e8115..8ec40cb46 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -94,7 +94,7 @@ void SPFeMerge::build_renderer(Inkscape::Filters::Filter* filter) { int in_nr = 0; - for(auto& input: _children) { + for(auto& input: children) { if (SP_IS_FEMERGENODE(&input)) { SPFeMergeNode *node = SP_FEMERGENODE(&input); nr_merge->set_input(in_nr, node->input); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 9c46a2efb..b6ea0d8c1 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -199,7 +199,7 @@ static guint count_gradient_hrefs(SPObject *o, SPGradient *gr) i ++; } - for (auto& child: o->_children) { + for (auto& child: o->children) { i += count_gradient_hrefs(&child, gr); } @@ -926,7 +926,7 @@ void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or GSList *child_objects = NULL; std::vector offsets; double offset; - for (auto& child: vector->_children) { + for (auto& child: vector->children) { child_reprs = g_slist_prepend (child_reprs, child.getRepr()); child_objects = g_slist_prepend (child_objects, &child); offset=0; @@ -979,7 +979,7 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi sp_gradient_repr_set_link(gradient->getRepr(), vector); } - for (auto& child: vector->_children) { + for (auto& child: vector->children) { if (SP_IS_STOP(&child)) { guint32 color = SP_STOP(&child)->get_rgba32(); //g_message("Stop color %d", color); diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index b9d1fe109..fd2f4b33b 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2539,7 +2539,7 @@ void GrDrag::deleteSelected(bool just_one) // cannot use vector->vector.stops.size() because the vector might be invalidated by deletion of a midstop // manually count the children, don't know if there already exists a function for this... int len = 0; - for (auto& child: stopinfo->vector->_children) + for (auto& child: stopinfo->vector->children) { if ( SP_IS_STOP(&child) ) { len ++; diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index fb1740fc5..24d2d7f1e 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -53,7 +53,7 @@ static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dke // recurse if (!g_slist_find(list, o)) { - for (auto& child: o->_children) { + for (auto& child: o->children) { hide_other_items_recursively(&child, list, dkey); } } diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index c59db9df6..2255157e2 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -374,7 +374,7 @@ static void hide_other_items_recursively(SPObject *o, const std::vector // recurse if (list.end()==find(list.begin(),list.end(),o)) { - for (auto& child: o->_children) { + for (auto& child: o->children) { hide_other_items_recursively(&child, list, dkey); } } diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index cf10a6c4d..647e42916 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -204,7 +204,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) } SPObject *object = NULL; if (!strcmp(base, "marker") && !stock) { - for (auto& child: defs->_children) + for (auto& child: defs->children) { if (child.getRepr()->attribute("inkscape:stockid") && !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && @@ -216,7 +216,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) } else if (!strcmp(base,"pattern") && !stock) { - for (auto& child: defs->_children) + for (auto& child: defs->children) { if (child.getRepr()->attribute("inkscape:stockid") && !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && @@ -228,7 +228,7 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) } else if (!strcmp(base,"gradient") && !stock) { - for (auto& child: defs->_children) + for (auto& child: defs->children) { if (child.getRepr()->attribute("inkscape:stockid") && !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && diff --git a/src/id-clash.cpp b/src/id-clash.cpp index fecad9eee..cb5893133 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -187,7 +187,7 @@ find_references(SPObject *elem, refmap_type &refmap) } // recurse - for (auto& child: elem->_children) + for (auto& child: elem->children) { find_references(&child, refmap); } @@ -242,7 +242,7 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, // recurse - for (auto& child: elem->_children) + for (auto& child: elem->children) { change_clashing_ids(imported_doc, current_doc, &child, refmap, id_changes); } diff --git a/src/layer-fns.cpp b/src/layer-fns.cpp index d149089db..030ebc07e 100644 --- a/src/layer-fns.cpp +++ b/src/layer-fns.cpp @@ -36,7 +36,7 @@ bool is_layer(SPObject &object) { * @returns NULL if there are no further layers under a parent */ SPObject *next_sibling_layer(SPObject *layer) { - SPObject::ChildrenList &list = layer->parent->_children; + SPObject::ChildrenList &list = layer->parent->children; auto l = std::find_if(++list.iterator_to(*layer), list.end(), &is_layer); return l != list.end() ? &*l : nullptr; } @@ -48,7 +48,7 @@ SPObject *next_sibling_layer(SPObject *layer) { SPObject *previous_sibling_layer(SPObject *layer) { using Inkscape::Algorithms::find_last_if; - SPObject::ChildrenList &list = layer->parent->_children; + SPObject::ChildrenList &list = layer->parent->children; auto l = find_last_if(list.begin(), list.iterator_to(*layer), &is_layer); return l != list.iterator_to(*layer) ? &*(l) : nullptr; } @@ -60,8 +60,8 @@ SPObject *previous_sibling_layer(SPObject *layer) { SPObject *first_descendant_layer(SPObject *layer) { SPObject *first_descendant = nullptr; while (true) { - auto tmp = std::find_if(layer->_children.begin(), layer->_children.end(), &is_layer); - if (tmp != layer->_children.end()) { + auto tmp = std::find_if(layer->children.begin(), layer->children.end(), &is_layer); + if (tmp != layer->children.end()) { first_descendant = layer; } else { break; @@ -79,8 +79,8 @@ SPObject *first_descendant_layer(SPObject *layer) { SPObject *last_child_layer(SPObject *layer) { using Inkscape::Algorithms::find_last_if; - auto l = find_last_if(layer->_children.begin(), layer->_children.end(), &is_layer); - return l != layer->_children.end() ? &*l : nullptr; + auto l = find_last_if(layer->children.begin(), layer->children.end(), &is_layer); + return l != layer->children.end() ? &*l : nullptr; } SPObject *last_elder_layer(SPObject *root, SPObject *layer) { diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 937d67895..4deae821a 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -298,7 +298,7 @@ void FontLister::update_font_list_recursive(SPObject *r, std::listpush_back(Glib::ustring(font_family)); } - for (auto& child: r->_children) { + for (auto& child: r->children) { update_font_list_recursive(&child, l); } } diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index c62ead2b3..049e10f0f 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -107,7 +107,7 @@ void LPEPerspectivePath::refresh(Gtk::Entry* perspective) { perspectiveID = perspective->get_text(); Persp3D *first = 0; Persp3D *persp = 0; - for (auto& child: lpeobj->document->getDefs()->_children) { + for (auto& child: lpeobj->document->getDefs()->children) { if (SP_IS_PERSP3D(&child) && first == 0) { first = SP_PERSP3D(&child); } diff --git a/src/main.cpp b/src/main.cpp index 7ab27dcb2..c01c4ee46 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1228,7 +1228,7 @@ static int sp_process_file_list(GSList *fl) std::vector items; SPRoot *root = doc->getRoot(); doc->ensureUpToDate(); - for (auto& iter: root->_children) { + for (auto& iter: root->children) { SPItem* item = (SPItem*) &iter; if (! (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item) || SP_IS_GROUP(item))) { continue; @@ -1483,7 +1483,7 @@ do_query_all_recurse (SPObject *o) } } - for(auto& child: o->_children) { + for(auto& child: o->children) { do_query_all_recurse (&child); } } diff --git a/src/object-set.cpp b/src/object-set.cpp index b7b84e163..1b994106a 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -93,7 +93,7 @@ bool ObjectSet::_anyAncestorIsInSet(SPObject *object) { } void ObjectSet::_removeDescendantsFromSet(SPObject *object) { - for (auto& child: object->_children) { + for (auto& child: object->children) { if (includes(&child)) { _remove(&child); // there is certainly no children of this child in the set @@ -130,7 +130,7 @@ SPObject *ObjectSet::_getMutualAncestor(SPObject *object) { bool flag = true; while (o->parent != nullptr) { - for (auto &child: o->parent->_children) { + for (auto &child: o->parent->children) { if(&child != o && !includes(&child)) { flag = false; break; @@ -147,7 +147,7 @@ SPObject *ObjectSet::_getMutualAncestor(SPObject *object) { void ObjectSet::_removeAncestorsFromSet(SPObject *object) { SPObject* o = object; while (o->parent != nullptr) { - for (auto &child: o->parent->_children) { + for (auto &child: o->parent->children) { if (&child != o) { _add(&child); } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 580fb5fc7..307dcf062 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -90,7 +90,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, Geom::Rect bbox_to_snap_incl = bbox_to_snap; // _incl means: will include the snapper tolerance bbox_to_snap_incl.expandBy(getSnapperTolerance()); // see? - for (auto& o: parent->_children) { + for (auto& o: parent->children) { g_assert(dt != NULL); SPItem *item = dynamic_cast(&o); if (item && !(dt->itemIsHidden(item) && !clip_or_mask)) { diff --git a/src/persp3d.cpp b/src/persp3d.cpp index 849e332bf..e260af8e5 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -215,7 +215,7 @@ Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// Persp3D *persp3d_document_first_persp(SPDocument *document) { Persp3D *first = 0; - for (auto& child: document->getDefs()->_children) { + for (auto& child: document->getDefs()->children) { if (SP_IS_PERSP3D(&child)) { first = SP_PERSP3D(&child); break; @@ -534,7 +534,7 @@ persp3d_print_debugging_info (Persp3D *persp) { void persp3d_print_debugging_info_all(SPDocument *document) { - for (auto& child: document->getDefs()->_children) { + for (auto& child: document->getDefs()->children) { if (SP_IS_PERSP3D(&child)) { persp3d_print_debugging_info(SP_PERSP3D(&child)); } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 28bcadef5..81d711e77 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -433,7 +433,7 @@ static void add_ids_recursive(std::vector &ids, SPObject *obj) ids.push_back(obj->getId()); if (dynamic_cast(obj)) { - for (auto& child: obj->_children) { + for (auto& child: obj->children) { add_ids_recursive(ids, &child); } } @@ -587,7 +587,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) */ std::vector &get_all_items(std::vector &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector const &exclude) { - for (auto& child: from->_children) { + for (auto& child: from->children) { SPItem *item = dynamic_cast(&child); if (item && !desktop->isLayer(item) && @@ -1143,7 +1143,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des pp = document->getObjectByRepr(repr->parent()); minpos = 0; g_assert(dynamic_cast(pp)); - for (auto& pc: pp->_children) { + for (auto& pc: pp->children) { if(dynamic_cast(&pc)) { break; } @@ -1202,7 +1202,7 @@ take_style_from_item(SPObject *object) (dynamic_cast(object) && object->firstChild() && object->firstChild()->getNext() == NULL)) { // if this is a text with exactly one tspan child, merge the style of that tspan as well // If this is a group, merge the style of its topmost (last) child with style - auto list = object->_children | boost::adaptors::reversed; + auto list = object->children | boost::adaptors::reversed; for (auto& element: list) { if (element.style ) { SPCSSAttr *temp = sp_css_attr_from_object(&element, SP_STYLE_FLAG_IFSET); @@ -1624,9 +1624,9 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } else if (transform_flowtext_with_frame) { // apply the inverse of the region's transform to the so that the flow remains // the same (even though the output itself gets transformed) - for (auto& region: item->_children) { + for (auto& region: item->children) { if (dynamic_cast(®ion) || dynamic_cast(®ion)) { - for (auto& itm: region._children) { + for (auto& itm: region.children) { SPUse *use = dynamic_cast(&itm); if ( use ) { use->doWriteTransform(use->getRepr(), use->transform.inverse(), NULL, compensate); @@ -2348,7 +2348,7 @@ typedef struct ListReverse { private: static GSList *make_list(SPObject *object, SPObject *limit) { GSList *list = NULL; - for (auto &child: object->_children) { + for (auto &child: object->children) { if (&child == limit) { break; } @@ -3435,7 +3435,7 @@ void sp_selection_untile(SPDesktop *desktop) Geom::Affine pat_transform = basePat->getTransform(); pat_transform *= item->transform; - for (auto& child: pattern->_children) { + for (auto& child: pattern->children) { if (dynamic_cast(&child)) { Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc); SPItem *i = dynamic_cast(desktop->currentLayer()->appendChildRepr(copy)); @@ -4103,7 +4103,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for ( std::map::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { SPObject *obj = (*it).first; // Group containing the clipped paths or masks GSList *items_to_move = NULL; - for (auto& child: obj->_children) { + for (auto& child: obj->children) { // Collect all clipped paths and masks within a single group Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc); if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect")) @@ -4264,7 +4264,7 @@ static void itemtree_map(void (*f)(SPItem *, SPDesktop *), SPObject *root, SPDes f(item, desktop); } } - for (auto& child: root->_children) { + for (auto& child: root->children) { //don't recurse into locked layers SPItem *item = dynamic_cast(&child); if (!(item && desktop->isLayer(item) && item->isLocked())) { diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 25bf77f00..c0c848bbd 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -128,7 +128,7 @@ void SPClipPath::update(SPCtx* ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -167,7 +167,7 @@ void SPClipPath::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -200,7 +200,7 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); display = sp_clippath_view_new_prepend(display, key, ai); - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM(&child)) { Inkscape::DrawingItem *ac = SP_ITEM(&child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS); @@ -223,7 +223,7 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int } void SPClipPath::hide(unsigned int key) { - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM(&child)) { SP_ITEM(&child)->invoke_hide(key); } @@ -252,7 +252,7 @@ void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) { Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) { Geom::OptRect bbox; - for (auto& i: _children) { + for (auto& i: children) { if (SP_IS_ITEM(&i)) { Geom::OptRect tmp = SP_ITEM(&i)->geometricBounds(Geom::Affine(SP_ITEM(&i)->transform) * transform); bbox.unionWith(tmp); diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index af4ea96d7..865c6891e 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -54,7 +54,7 @@ void SPDefs::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -79,7 +79,7 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X } GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -93,7 +93,7 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X } } else { - for (auto& child: _children) { + for (auto& child: children) { child.updateRepr(flags); } } diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 170847c0b..9ecee6a5f 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -268,7 +268,7 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML } GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node *crepr = child.updateRepr(doc, NULL, flags); if (crepr) { @@ -282,7 +282,7 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML l = g_slist_remove (l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { child.updateRepr(flags); } } @@ -420,7 +420,7 @@ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr } nr_filter->clear_primitives(); - for(auto& primitive_obj: sp_filter->_children) { + for(auto& primitive_obj: sp_filter->children) { if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(&primitive_obj); g_assert(primitive != NULL); @@ -439,7 +439,7 @@ int sp_filter_primitive_count(SPFilter *filter) { g_assert(filter != NULL); int count = 0; - for(auto& primitive_obj: filter->_children) { + for(auto& primitive_obj: filter->children) { if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { count++; } @@ -512,7 +512,7 @@ Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) { g_assert(filter != NULL); int largest = 0; - for(auto& primitive_obj: filter->_children) { + for(auto& primitive_obj: filter->children) { if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { Inkscape::XML::Node *repr = primitive_obj.getRepr(); char const *result = repr->attribute("result"); diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index ad04f0d78..17b841e37 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -27,7 +27,7 @@ void SPFlowdiv::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -65,7 +65,7 @@ void SPFlowdiv::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -104,7 +104,7 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node* c_repr = NULL; if ( SP_IS_FLOWTSPAN (&child) ) { @@ -126,7 +126,7 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape l = g_slist_remove(l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if ( SP_IS_FLOWTSPAN (&child) ) { child.updateRepr(flags); } else if ( SP_IS_FLOWPARA(&child) ) { @@ -168,7 +168,7 @@ void SPFlowtspan::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -206,7 +206,7 @@ void SPFlowtspan::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -242,7 +242,7 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node* c_repr = NULL; if ( SP_IS_FLOWTSPAN(&child) ) { @@ -264,7 +264,7 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca l = g_slist_remove(l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if ( SP_IS_FLOWTSPAN(&child) ) { child.updateRepr(flags); } else if ( SP_IS_FLOWPARA(&child) ) { @@ -307,7 +307,7 @@ void SPFlowpara::update(SPCtx *ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -343,7 +343,7 @@ void SPFlowpara::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -379,7 +379,7 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node* c_repr = NULL; if ( SP_IS_FLOWTSPAN(&child) ) { @@ -401,7 +401,7 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap l = g_slist_remove(l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if ( SP_IS_FLOWTSPAN(&child) ) { child.updateRepr(flags); } else if ( SP_IS_FLOWPARA(&child) ) { diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 71e029072..716a09914 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -63,7 +63,7 @@ void SPFlowregion::update(SPCtx *ctx, unsigned int flags) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -102,7 +102,7 @@ void SPFlowregion::UpdateComputed(void) } computed.clear(); - for (auto& child: _children) { + for (auto& child: children) { Shape *shape = 0; GetDest(&child, &shape); computed.push_back(shape); @@ -118,7 +118,7 @@ void SPFlowregion::modified(guint flags) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -145,7 +145,7 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc } GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); @@ -161,7 +161,7 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc l = g_slist_remove(l, l->data); } - for (auto& child: _children) { + for (auto& child: children) { if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { child.updateRepr(flags); } @@ -220,7 +220,7 @@ void SPFlowregionExclude::update(SPCtx *ctx, unsigned int flags) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -258,7 +258,7 @@ void SPFlowregionExclude::UpdateComputed(void) computed = NULL; } - for (auto& child: _children) { + for (auto& child: children) { GetDest(&child, &computed); } } @@ -272,7 +272,7 @@ void SPFlowregionExclude::modified(guint flags) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -300,7 +300,7 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { @@ -315,7 +315,7 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc } } else { - for (auto& child: _children) { + for (auto& child: children) { child.updateRepr(flags); } } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 83fa5a1b4..79988bdc2 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -72,7 +72,7 @@ void SPFlowtext::update(SPCtx* ctx, unsigned int flags) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -135,7 +135,7 @@ void SPFlowtext::modified(unsigned int flags) { } } - for (auto& o: _children) { + for (auto& o: children) { if (dynamic_cast(&o)) { region = &o; break; @@ -223,7 +223,7 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node *c_repr = NULL; if ( dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child)) { @@ -241,7 +241,7 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X l = g_slist_remove(l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if ( dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child) || dynamic_cast(&child)) { child.updateRepr(flags); } @@ -390,7 +390,7 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, *pending_line_break_object = NULL; } - for (auto& child: root->_children) { + for (auto& child: root->children) { SPString *str = dynamic_cast(&child); if (str) { if (*pending_line_break_object) { @@ -440,7 +440,7 @@ Shape* SPFlowtext::_buildExclusionShape() const Shape *shape = new Shape(); Shape *shape_temp = new Shape(); - for (auto& child: _children) { + for (auto& child: children) { // RH: is it right that this shouldn't be recursive? SPFlowregionExclude *c_child = dynamic_cast(const_cast(&child)); if ( c_child && c_child->computed && c_child->computed->hasEdges() ) { @@ -593,7 +593,7 @@ SPItem *SPFlowtext::get_frame(SPItem const *after) SPItem *frame = 0; SPObject *region = 0; - for (auto& o: _children) { + for (auto& o: children) { if (dynamic_cast(&o)) { region = &o; break; @@ -603,7 +603,7 @@ SPItem *SPFlowtext::get_frame(SPItem const *after) if (region) { bool past = false; - for (auto& o: region->_children) { + for (auto& o: region->children) { SPItem *item = dynamic_cast(&o); if (item) { if ( (after == NULL) || past ) { @@ -707,7 +707,7 @@ Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) } SPObject *region = NULL; - for (auto& o: _children) { + for (auto& o: children) { if (dynamic_cast(&o)) { region = &o; break; diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index abfae1a1f..afa209dbe 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -276,7 +276,7 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr) SPPaintServer::build(document, repr); - for (auto& ochild: _children) { + for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; @@ -481,7 +481,7 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) SPPaintServer::remove_child(child); this->has_stops = FALSE; - for (auto& ochild: _children) { + for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; @@ -536,7 +536,7 @@ void SPGradient::modified(guint flags) // FIXME: climb up the ladder of hrefs GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child); l = g_slist_prepend(l, &child); } @@ -558,7 +558,7 @@ void SPGradient::modified(guint flags) SPStop* SPGradient::getFirstStop() { SPStop* first = nullptr; - for (auto& ochild: _children) { + for (auto& ochild: children) { if (SP_IS_STOP(&ochild)) { first = SP_STOP(&ochild); break; @@ -588,7 +588,7 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { @@ -916,7 +916,7 @@ bool SPGradient::invalidateArray() void SPGradient::rebuildVector() { gint len = 0; - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_STOP(&child)) { len ++; } @@ -938,7 +938,7 @@ void SPGradient::rebuildVector() } } - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_STOP(&child)) { SPStop *stop = SP_STOP(&child); @@ -1023,7 +1023,7 @@ void SPGradient::rebuildArray() array.read( SP_MESH( this ) ); has_patches = false; - for (auto& ro: _children) { + for (auto& ro: children) { if (SP_IS_MESHROW(&ro)) { has_patches = true; // std::cout << " Has Patches" << std::endl; diff --git a/src/sp-hatch.cpp b/src/sp-hatch.cpp index c06045e8f..f667017fa 100644 --- a/src/sp-hatch.cpp +++ b/src/sp-hatch.cpp @@ -233,7 +233,7 @@ void SPHatch::set(unsigned int key, const gchar* value) bool SPHatch::_hasHatchPatchChildren(SPHatch const *hatch) { - for (auto& child: hatch->_children) { + for (auto& child: hatch->children) { SPHatchPath const *hatchPath = dynamic_cast(&child); if (hatchPath) { return true; @@ -248,7 +248,7 @@ std::vector SPHatch::hatchPaths() SPHatch *src = chase_hrefs(this, sigc::ptr_fun(&_hasHatchPatchChildren)); if (src) { - for (auto& child: src->_children) { + for (auto& child: src->children) { SPHatchPath *hatchPath = dynamic_cast(&child); if (hatchPath) { list.push_back(hatchPath); @@ -264,7 +264,7 @@ std::vector SPHatch::hatchPaths() const SPHatch const *src = chase_hrefs(this, sigc::ptr_fun(&_hasHatchPatchChildren)); if (src) { - for (auto& child: src->_children) { + for (auto& child: src->children) { SPHatchPath const *hatchPath = dynamic_cast(&child); if (hatchPath) { list.push_back(hatchPath); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 8d482d9b1..63edb3c84 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -235,7 +235,7 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = NULL; - for (auto& child: _children) { + for (auto& child: children) { if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); @@ -251,7 +251,7 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = g_slist_remove (l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if ( !dynamic_cast(&child) && !dynamic_cast(&child) ) { child.updateRepr(flags); } @@ -297,7 +297,7 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } void SPGroup::print(SPPrintContext *ctx) { - for(auto& child: _children){ + for(auto& child: children){ SPObject *o = &child; SPItem *item = dynamic_cast(o); if (item) { @@ -365,7 +365,7 @@ void SPGroup::hide (unsigned int key) { void SPGroup::snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const { - for (auto& o: _children) + for (auto& o: children) { SPItem const *item = dynamic_cast(&o); if (item) { @@ -511,13 +511,13 @@ sp_item_group_ungroup (SPGroup *group, std::vector &children, bool do_d GSList *objects = NULL; Geom::Affine const g(group->transform); - for (auto& child: group->_children) { + for (auto& child: group->children) { if (SPItem *citem = dynamic_cast(&child)) { sp_item_group_ungroup_handle_clones(citem, g); } } - for (auto& child: group->_children) { + for (auto& child: group->children) { SPItem *citem = dynamic_cast(&child); if (citem) { /* Merging of style */ @@ -662,7 +662,7 @@ std::vector sp_item_group_item_list(SPGroup * group) std::vector s; g_return_val_if_fail(group != NULL, s); - for (auto& o: group->_children) { + for (auto& o: group->children) { if ( dynamic_cast(&o) ) { s.push_back((SPItem*)&o); } @@ -735,7 +735,7 @@ void SPGroup::_updateLayerMode(unsigned int display_key) { void SPGroup::translateChildItems(Geom::Translate const &tr) { if ( hasChildren() ) { - for (auto& o: _children) { + for (auto& o: children) { SPItem *item = dynamic_cast(&o); if ( item ) { sp_item_move_rel(item, tr); @@ -748,9 +748,9 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse) { if ( hasChildren() ) { - for (auto& o: _children) { + for (auto& o: children) { if ( SPDefs *defs = dynamic_cast(&o) ) { // select symbols from defs, ignore clips, masks, patterns - for (auto& defschild: defs->_children) { + for (auto& defschild: defs->children) { SPGroup *defsgroup = dynamic_cast(&defschild); if (defsgroup) defsgroup->scaleChildItemsRec(sc, p, false); @@ -871,7 +871,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo gint SPGroup::getItemCount() const { gint len = 0; - for (auto& child: _children) { + for (auto& child: children) { if (dynamic_cast(&child)) { len++; } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 53b4c0879..69da28c66 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -308,15 +308,15 @@ bool is_item(SPObject const &object) { void SPItem::raiseToTop() { using Inkscape::Algorithms::find_last_if; - auto topmost = find_last_if(++parent->_children.iterator_to(*this), parent->_children.end(), &is_item); - if (topmost != parent->_children.end()) { + auto topmost = find_last_if(++parent->children.iterator_to(*this), parent->children.end(), &is_item); + if (topmost != parent->children.end()) { getRepr()->parent()->changeOrder( getRepr(), topmost->getRepr() ); } } void SPItem::raiseOne() { - auto next_higher = std::find_if(++parent->_children.iterator_to(*this), parent->_children.end(), &is_item); - if (next_higher != parent->_children.end()) { + auto next_higher = std::find_if(++parent->children.iterator_to(*this), parent->children.end(), &is_item); + if (next_higher != parent->children.end()) { Inkscape::XML::Node *ref = next_higher->getRepr(); getRepr()->parent()->changeOrder(getRepr(), ref); } @@ -325,8 +325,8 @@ void SPItem::raiseOne() { void SPItem::lowerOne() { using Inkscape::Algorithms::find_last_if; - auto next_lower = find_last_if(parent->_children.begin(), parent->_children.iterator_to(*this), &is_item); - if (next_lower != parent->_children.iterator_to(*this)) { + auto next_lower = find_last_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item); + if (next_lower != parent->children.iterator_to(*this)) { next_lower--; Inkscape::XML::Node *ref = next_lower->getRepr(); getRepr()->parent()->changeOrder(getRepr(), ref); @@ -334,8 +334,8 @@ void SPItem::lowerOne() { } void SPItem::lowerToBottom() { - auto bottom = std::find_if(parent->_children.begin(), parent->_children.iterator_to(*this), &is_item); - if (bottom != parent->_children.iterator_to(*this)) { + auto bottom = std::find_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item); + if (bottom != parent->children.iterator_to(*this)) { bottom--; Inkscape::XML::Node *ref = bottom->getRepr() ; parent->getRepr()->changeOrder(getRepr(), ref); @@ -705,7 +705,7 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X // so we need to add any children from the underlying object to the new repr if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (auto& child: object->_children) { + for (auto& child: object->children) { if (dynamic_cast(&child) || dynamic_cast(&child)) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { @@ -719,7 +719,7 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (auto& child: object->_children) { + for (auto& child: object->children) { if (dynamic_cast(&child) || dynamic_cast(&child)) { child.updateRepr(flags); } @@ -928,7 +928,7 @@ unsigned int SPItem::pos_in_parent() const { unsigned int pos = 0; - for (auto& iter: parent->_children) { + for (auto& iter: parent->children) { if (&iter == this) { return pos; } @@ -974,7 +974,7 @@ void SPItem::getSnappoints(std::vector &p, Inkscap for (std::list::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); ++o) { if (*o) { // obj is a group object, the children are the actual clippers - for(auto& child: (*o)->_children) { + for(auto& child: (*o)->children) { SPItem *item = dynamic_cast(const_cast(&child)); if (item) { std::vector p_clip_or_mask; @@ -1302,7 +1302,7 @@ void SPItem::adjust_stroke_width_recursive(double expansion) // A clone's child is the ghost of its original - we must not touch it, skip recursion if ( !dynamic_cast(this) ) { - for (auto& o: _children) { + for (auto& o: children) { SPItem *item = dynamic_cast(&o); if (item) { item->adjust_stroke_width_recursive(expansion); @@ -1317,7 +1317,7 @@ void SPItem::freeze_stroke_width_recursive(bool freeze) // A clone's child is the ghost of its original - we must not touch it, skip recursion if ( !dynamic_cast(this) ) { - for (auto& o: _children) { + for (auto& o: children) { SPItem *item = dynamic_cast(&o); if (item) { item->freeze_stroke_width_recursive(freeze); @@ -1337,7 +1337,7 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) rect->compensateRxRy(advertized_transform); } - for(auto& o: item->_children) { + for(auto& o: item->children) { SPItem *itm = dynamic_cast(&o); if (itm) { sp_item_adjust_rects_recursive(itm, advertized_transform); @@ -1357,7 +1357,7 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af // also we do not recurse into clones, because a clone's child is the ghost of its original - // we must not touch it if (!(this && (dynamic_cast(this) || dynamic_cast(this)))) { - for (auto& o: _children) { + for (auto& o: children) { SPItem *item = dynamic_cast(&o); if (item) { // At the level of the transformed item, t_ancestors is identity; @@ -1666,7 +1666,7 @@ SPItem const *sp_item_first_item_child(SPObject const *obj) SPItem *sp_item_first_item_child(SPObject *obj) { SPItem *child = 0; - for (auto& iter: obj->_children) { + for (auto& iter: obj->children) { SPItem *tmp = dynamic_cast(&iter); if ( tmp ) { child = tmp; diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index e643cc9bd..1b44c26ff 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -227,7 +227,7 @@ Inkscape::DrawingItem *SPMask::sp_mask_show(Inkscape::Drawing &drawing, unsigned Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); this->display = sp_mask_view_new_prepend (this->display, key, ai); - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM (&child)) { Inkscape::DrawingItem *ac = SP_ITEM (&child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS); @@ -250,7 +250,7 @@ void SPMask::sp_mask_hide(unsigned int key) { g_return_if_fail (this != NULL); g_return_if_fail (SP_IS_MASK (this)); - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM (&child)) { SP_ITEM(&child)->invoke_hide (key); } diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index 20d6d0d85..6bd5c85d7 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -632,12 +632,12 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { guint max_column = 0; guint irow = 0; // Corresponds to top of patch being read in. - for (auto& ro: mg->_children) { + for (auto& ro: mg->children) { if (SP_IS_MESHROW(&ro)) { guint icolumn = 0; // Corresponds to left of patch being read in. - for (auto& po: ro._children) { + for (auto& po: ro.children) { if (SP_IS_MESHPATCH(&po)) { @@ -652,7 +652,7 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { // Only 'top' side defined for first row. if( irow != 0 ) ++istop; - for (auto& so: po._children) { + for (auto& so: po.children) { if (SP_IS_STOP(&so)) { if( istop > 3 ) { @@ -848,13 +848,13 @@ void SPMeshNodeArray::write( SPMesh *mg ) { // First we must delete reprs for old mesh rows and patches. GSList *descendant_reprs = NULL; GSList *descendant_objects = NULL; - for (auto& row: mg->_children) { + for (auto& row: mg->children) { descendant_reprs = g_slist_prepend (descendant_reprs, row.getRepr()); descendant_objects = g_slist_prepend (descendant_objects, &row); - for (auto& patch: row._children) { + for (auto& patch: row.children) { descendant_reprs = g_slist_prepend (descendant_reprs, patch.getRepr()); descendant_objects = g_slist_prepend (descendant_objects, &patch); - for (auto& stop: patch._children) { + for (auto& stop: patch.children) { descendant_reprs = g_slist_prepend (descendant_reprs, stop.getRepr()); descendant_objects = g_slist_prepend (descendant_objects, &stop); } diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 173055dbd..e1d69e297 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -248,7 +248,7 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "inkscape:lockguides" ); /* Construct guideline list */ - for (auto& o: _children) { + for (auto& o: children) { if (SP_IS_GUIDE(&o)) { SPGuide * g = SP_GUIDE(&o); this->guides.push_back(g); @@ -858,7 +858,7 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop) } // if that didn't work out, look for the topmost layer if (!layer) { - for (auto& iter: document->getRoot()->_children) { + for (auto& iter: document->getRoot()->children) { if (desktop->isLayer(&iter)) { layer = &iter; } diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index bfed08218..62c6f7a87 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -50,7 +50,7 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks } GSList *l = 0; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { @@ -64,7 +64,7 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks l = g_slist_remove(l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { child.updateRepr(flags); } } diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 587efd4f6..ccd70f4cb 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -400,7 +400,7 @@ void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr) std::vector SPObject::childList(bool add_ref, Action) { std::vector l; - for (auto& child: _children) { + for (auto& child: children) { if (add_ref) { sp_object_ref(&child); } @@ -467,7 +467,7 @@ void SPObject::requestOrphanCollection() { } void SPObject::_sendDeleteSignalRecursive() { - for (auto& child: _children) { + for (auto& child: children) { child._delete_signal.emit(&child); child._sendDeleteSignalRecursive(); } @@ -497,7 +497,7 @@ void SPObject::deleteObject(bool propagate, bool propagate_descendants) void SPObject::cropToObject(SPObject *except) { std::vector toDelete; - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM(&child)) { if (child.isAncestorOf(except)) { child.cropToObject(except); @@ -525,11 +525,11 @@ void SPObject::attach(SPObject *object, SPObject *prev) object->parent = this; this->_updateTotalHRefCount(object->_total_hrefcount); - auto it = _children.begin(); + auto it = children.begin(); if (prev != nullptr) { - it = ++_children.iterator_to(*prev); + it = ++children.iterator_to(*prev); } - _children.insert(it, *object); + children.insert(it, *object); if (!object->xml_space.set) object->xml_space.value = this->xml_space.value; @@ -542,12 +542,12 @@ void SPObject::reorder(SPObject* obj, SPObject* prev) { g_return_if_fail(obj != prev); g_return_if_fail(!prev || prev->parent == obj->parent); - auto it = _children.begin(); + auto it = children.begin(); if (prev != nullptr) { - it = ++_children.iterator_to(*prev); + it = ++children.iterator_to(*prev); } - _children.splice(it, _children, _children.iterator_to(*obj)); + children.splice(it, children, children.iterator_to(*obj)); } void SPObject::detach(SPObject *object) @@ -558,7 +558,7 @@ void SPObject::detach(SPObject *object) g_return_if_fail(SP_IS_OBJECT(object)); g_return_if_fail(object->parent == this); - _children.erase(_children.iterator_to(*object)); + children.erase(children.iterator_to(*object)); object->releaseReferences(); object->parent = NULL; @@ -572,10 +572,10 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) g_return_val_if_fail(repr != NULL, NULL); SPObject *result = nullptr; - if (_children.size() > 0 && _children.back().getRepr() == repr) { - result = &_children.back(); // optimization for common scenario + if (children.size() > 0 && children.back().getRepr() == repr) { + result = &children.back(); // optimization for common scenario } else { - for (auto& child: _children) { + for (auto& child: children) { if (child.getRepr() == repr) { result = &child; break; @@ -609,7 +609,7 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) void SPObject::release() { SPObject* object = this; debug("id=%p, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); - auto tmp = _children | boost::adaptors::transformed([](SPObject& obj){return &obj;}); + auto tmp = children | boost::adaptors::transformed([](SPObject& obj){return &obj;}); std::vector toRelease(tmp.begin(), tmp.end()); for (auto& p: toRelease) { @@ -797,8 +797,8 @@ void SPObject::releaseReferences() { SPObject *SPObject::getPrev() { SPObject *prev = nullptr; - if (parent && !parent->_children.empty() && &parent->_children.front() != this) { - prev = &*(--parent->_children.iterator_to(*this)); + if (parent && !parent->children.empty() && &parent->children.front() != this) { + prev = &*(--parent->children.iterator_to(*this)); } return prev; } @@ -806,8 +806,8 @@ SPObject *SPObject::getPrev() SPObject* SPObject::getNext() { SPObject *next = nullptr; - if (parent && !parent->_children.empty() && &parent->_children.back() != this) { - next = &*(++parent->_children.iterator_to(*this)); + if (parent && !parent->children.empty() && &parent->children.back() != this) { + next = &*(++parent->children.iterator_to(*this)); } return next; } @@ -1475,7 +1475,7 @@ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool } else { // remove the current content of the 'text' or 'desc' element - auto tmp = elem->_children | boost::adaptors::transformed([](SPObject& obj) { return &obj; }); + auto tmp = elem->children | boost::adaptors::transformed([](SPObject& obj) { return &obj; }); std::vector vec(tmp.begin(), tmp.end()); for (auto &child: vec) { child->deleteObject(); @@ -1489,7 +1489,7 @@ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool SPObject* SPObject::findFirstChild(gchar const *tagname) const { - for (auto& child: const_cast(this)->_children) + for (auto& child: const_cast(this)->children) { if (child.repr->type() == Inkscape::XML::ELEMENT_NODE && !strcmp(child.repr->name(), tagname)) { @@ -1503,7 +1503,7 @@ char* SPObject::textualContent() const { GString* text = g_string_new(""); - for (auto& child: _children) + for (auto& child: children) { Inkscape::XML::NodeType child_type = child.repr->type(); @@ -1530,7 +1530,7 @@ void SPObject::recursivePrintTree( unsigned level ) std::cout << " "; } std::cout << (getId()?getId():"No object id") << std::endl; - for (auto& child: _children) { + for (auto& child: children) { child.recursivePrintTree(level + 1); } } diff --git a/src/sp-object.h b/src/sp-object.h index 94c9d5629..1c6212664 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -306,13 +306,13 @@ public: */ SPObject *getPrev(); - bool hasChildren() const { return ( _children.size() > 0 ); } + bool hasChildren() const { return ( children.size() > 0 ); } - SPObject *firstChild() { return _children.empty() ? nullptr : &_children.front(); } - SPObject const *firstChild() const { return _children.empty() ? nullptr : &_children.front(); } + SPObject *firstChild() { return children.empty() ? nullptr : &children.front(); } + SPObject const *firstChild() const { return children.empty() ? nullptr : &children.front(); } - SPObject *lastChild() { return _children.empty() ? nullptr : &_children.back(); } - SPObject const *lastChild() const { return _children.empty() ? nullptr : &_children.back(); } + SPObject *lastChild() { return children.empty() ? nullptr : &children.back(); } + SPObject const *lastChild() const { return children.empty() ? nullptr : &children.back(); } enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; @@ -857,7 +857,7 @@ public: ListHook, &SPObject::_child_hook >> ChildrenList; - ChildrenList _children; + ChildrenList children; virtual void read_content(); void recursivePrintTree(unsigned level = 0); // For debugging diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index fde9f90f1..3b1ae3f0b 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -223,7 +223,7 @@ void SPPattern::_getChildren(std::list &l) { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children - for (auto& child: pat_i->_children) { + for (auto& child: pat_i->children) { l.push_back(&child); } break; // do not go further up the chain if children are found @@ -319,7 +319,7 @@ guint SPPattern::_countHrefs(SPObject *o) const i++; } - for (auto& child: o->_children) { + for (auto& child: o->children) { i += _countHrefs(&child); } @@ -508,7 +508,7 @@ Geom::OptRect SPPattern::viewbox() const bool SPPattern::_hasItemChildren() const { - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM(&child)) { return true; } @@ -558,7 +558,7 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); drawing.setRoot(root); - for (auto& child: shown->_children) { + for (auto& child: shown->children) { if (SP_IS_ITEM(&child)) { // for each item in pattern, show it on our drawing, add to the group, // and connect to the release signal in case the item gets deleted @@ -654,7 +654,7 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Render drawing to pattern_surface via drawing context, this calls root->render // which is really DrawingItem->render(). drawing.render(dc, one_tile); - for (auto& child: shown->_children) { + for (auto& child: shown->children) { if (SP_IS_ITEM(&child)) { SP_ITEM(&child)->invoke_hide(dkey); } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index cfd0ced10..34047054a 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -73,7 +73,7 @@ void SPRoot::build(SPDocument *document, Inkscape::XML::Node *repr) SPGroup::build(document, repr); // Search for first node - for (auto& o: _children) { + for (auto& o: children) { if (SP_IS_DEFS(&o)) { this->defs = SP_DEFS(&o); break; @@ -174,7 +174,7 @@ void SPRoot::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) if (co && SP_IS_DEFS(co)) { // We search for first node - it is not beautiful, but works - for (auto& c: _children) { + for (auto& c: children) { if (SP_IS_DEFS(&c)) { this->defs = SP_DEFS(&c); break; @@ -189,7 +189,7 @@ void SPRoot::remove_child(Inkscape::XML::Node *child) SPObject *iter = 0; // We search for first remaining node - it is not beautiful, but works - for (auto& child: _children) { + for (auto& child: children) { iter = &child; if (SP_IS_DEFS(iter) && (SPDefs *)iter != this->defs) { this->defs = (SPDefs *)iter; diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 7679cc31e..971583a9a 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -32,7 +32,7 @@ SPSwitch::~SPSwitch() { SPObject *SPSwitch::_evaluateFirst() { SPObject *first = 0; - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_ITEM(&child) && sp_item_evaluate(SP_ITEM(&child))) { first = &child; break; diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 193289c2b..e52869942 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -155,7 +155,7 @@ void SPText::update(SPCtx *ctx, guint flags) { // Create temporary list of children GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child, this); l = g_slist_prepend (l, &child); } @@ -235,7 +235,7 @@ void SPText::modified(guint flags) { // Create temporary list of children GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { sp_object_ref(&child, this); l = g_slist_prepend (l, &child); } @@ -262,7 +262,7 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } @@ -286,7 +286,7 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } @@ -606,7 +606,7 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio } } - for (auto& child: root->_children) { + for (auto& child: root->children) { SPString *str = dynamic_cast(&child); if (str) { Glib::ustring const &string = str->string; @@ -628,7 +628,7 @@ void SPText::rebuildLayout() Inkscape::Text::Layout::OptionalTextTagAttrs optional_attrs; _buildLayoutInput(this, optional_attrs, 0, false); layout.calculateFlow(); - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TEXTPATH(&child)) { SPTextPath const *textpath = SP_TEXTPATH(&child); if (textpath->originalPath != NULL) { @@ -640,7 +640,7 @@ void SPText::rebuildLayout() //g_print("%s", layout.dumpAsText().c_str()); // set the x,y attributes on role:line spans - for (auto& child: _children) { + for (auto& child: children) { if (SP_IS_TSPAN(&child)) { SPTSpan *tspan = SP_TSPAN(&child); if ( (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED) @@ -676,7 +676,7 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root) item->updateRepr(); } - for(auto& o: item->_children) { + for(auto& o: item->children) { if (SP_IS_ITEM(&o)) _adjustFontsizeRecursive(SP_ITEM(&o), ex, false); } @@ -695,7 +695,7 @@ void SPText::_adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double SP_TREF(item)->attributes.transform(m, ex, ex, is_root); } - for(auto& o: item->_children) { + for(auto& o: item->children) { if (SP_IS_ITEM(&o)) _adjustCoordsRecursive(SP_ITEM(&o), m, ex, false); } diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index 66866c9f7..48e2b41f6 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -506,7 +506,7 @@ sp_tref_convert_to_tspan(SPObject *obj) //////////////////// else { GSList *l = NULL; - for (auto& child: obj->_children) { + for (auto& child: obj->children) { sp_object_ref(&child, obj); l = g_slist_prepend (l, &child); } diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 23df18503..5a82f2c05 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -96,7 +96,7 @@ void SPTSpan::update(SPCtx *ctx, guint flags) { } childflags &= SP_OBJECT_MODIFIED_CASCADE; - for (auto& ochild: _children) { + for (auto& ochild: children) { if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) { ochild.updateDisplay(ctx, childflags); } @@ -128,7 +128,7 @@ void SPTSpan::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for (auto& ochild: _children) { + for (auto& ochild: children) { if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild.emitModified(flags); } @@ -175,7 +175,7 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { @@ -197,7 +197,7 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = g_slist_remove(l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { child.updateRepr(flags); } else if ( SP_IS_TEXTPATH(&child) ) { @@ -313,7 +313,7 @@ void SPTextPath::update(SPCtx *ctx, guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for (auto& ochild: _children) { + for (auto& ochild: children) { if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) { ochild.updateDisplay(ctx, flags); } @@ -367,7 +367,7 @@ void SPTextPath::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for (auto& ochild: _children) { + for (auto& ochild: children) { if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) { ochild.emitModified(flags); } @@ -399,7 +399,7 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap if ( flags & SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (auto& child: _children) { + for (auto& child: children) { Inkscape::XML::Node* c_repr=NULL; if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { @@ -421,7 +421,7 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap l = g_slist_remove(l, l->data); } } else { - for (auto& child: _children) { + for (auto& child: children) { if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { child.updateRepr(flags); } else if ( SP_IS_TEXTPATH(&child) ) { @@ -466,7 +466,7 @@ void sp_textpath_to_text(SPObject *tp) // make a list of textpath children GSList *tp_reprs = NULL; - for (auto& o: tp->_children) { + for (auto& o: tp->children) { tp_reprs = g_slist_prepend(tp_reprs, o.getRepr()); } diff --git a/src/sp-use.cpp b/src/sp-use.cpp index cef967c90..b24363278 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -436,7 +436,7 @@ void SPUse::move_compensate(Geom::Affine const *mp) { //BUT move clippaths accordingly. //if clone has a clippath, move it accordingly if(clip_ref->getObject()){ - for(auto& clip: clip_ref->getObject()->_children){ + for(auto& clip: clip_ref->getObject()->children){ SPItem *item = (SPItem*) &clip; if(item){ item->transform *= m; @@ -446,7 +446,7 @@ void SPUse::move_compensate(Geom::Affine const *mp) { } } if(mask_ref->getObject()){ - for(auto& mask: mask_ref->getObject()->_children){ + for(auto& mask: mask_ref->getObject()->children){ SPItem *item = (SPItem*) &mask; if(item){ item->transform *= m; @@ -476,7 +476,7 @@ void SPUse::move_compensate(Geom::Affine const *mp) { //if clone has a clippath, move it accordingly if(clip_ref->getObject()){ - for(auto& clip: clip_ref->getObject()->_children){ + for(auto& clip: clip_ref->getObject()->children){ SPItem *item = (SPItem*) &clip; if(item){ item->transform *= clone_move.inverse(); @@ -486,7 +486,7 @@ void SPUse::move_compensate(Geom::Affine const *mp) { } } if(mask_ref->getObject()){ - for(auto& mask: mask_ref->getObject()->_children){ + for(auto& mask: mask_ref->getObject()->children){ SPItem *item = (SPItem*) &mask; if(item){ item->transform *= clone_move.inverse(); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 4ac9143f0..a4c4ac6cd 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -883,7 +883,7 @@ void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_tran // note: a marker child item can be an item group! if (SP_IS_GROUP(item)) { // recurse through all childs: - for (auto& o: item->_children) { + for (auto& o: item->children) { if ( SP_IS_ITEM(&o) ) { item_outline_add_marker_child(SP_ITEM(&o), tr, pathv_in); } diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 56048d1f7..a950dfebe 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -142,7 +142,7 @@ text_put_on_path() // make a list of text children GSList *text_reprs = NULL; - for(auto& o: text->_children) { + for(auto& o: text->children) { text_reprs = g_slist_prepend(text_reprs, o.getRepr()); } @@ -240,7 +240,7 @@ text_remove_all_kerns_recursively(SPObject *o) g_strfreev(xa_comma); } - for (auto& i: o->_children) { + for (auto& i: o->children) { text_remove_all_kerns_recursively(&i); i.requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } @@ -353,7 +353,7 @@ text_flow_into_shape() Inkscape::GC::release(text_repr); } else { // reflow an already flowed text, preserving paras - for(auto& o: text->_children) { + for(auto& o: text->children) { if (SP_IS_FLOWPARA(&o)) { Inkscape::XML::Node *para_repr = o.getRepr()->duplicate(xml_doc); root_repr->appendChild(para_repr); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 6ca2fe948..658cdf816 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -91,7 +91,7 @@ bool sp_te_input_is_empty(SPObject const *item) if (SP_IS_STRING(item)) { empty = SP_STRING(item)->string.empty(); } else { - for (auto& child: item->_children) { + for (auto& child: item->children) { if (!sp_te_input_is_empty(&child)) { empty = false; break; @@ -237,7 +237,7 @@ unsigned sp_text_get_length(SPObject const *item) length++; } - for (auto& child: item->_children) { + for (auto& child: item->children) { if (SP_IS_STRING(&child)) { length += SP_STRING(&child)->string.length(); } else { @@ -267,7 +267,7 @@ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto) } // Count the length of the children - for (auto& child: item->_children) { + for (auto& child: item->children) { if (upto && &child == upto) { // hit upto, return immediately return length; @@ -323,7 +323,7 @@ to \a item at the same level. */ static unsigned sum_sibling_text_lengths_before(SPObject const *item) { unsigned char_index = 0; - for (auto& sibling: item->parent->_children) { + for (auto& sibling: item->parent->children) { if (&sibling == item) { break; } @@ -860,7 +860,7 @@ static void sp_te_get_ustring_multiline(SPObject const *root, Glib::ustring *str if (*pending_line_break) { *string += '\n'; } - for (auto& child: root->_children) { + for (auto& child: root->children) { if (SP_IS_STRING(&child)) { *string += SP_STRING(&child)->string; } else { @@ -944,7 +944,7 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str) gchar *content = g_strdup (str); repr->setContent(""); - for (auto& child: object->_children) { + for (auto& child: object->children) { if (!SP_IS_FLOWREGION(&child) && !SP_IS_FLOWREGIONEXCLUDE(&child)) { repr->removeChild(child.getRepr()); } @@ -1405,7 +1405,7 @@ static void apply_css_recursive(SPObject *o, SPCSSAttr const *css) { sp_repr_css_change(o->getRepr(), const_cast(css), "style"); - for (auto& child: o->_children) { + for (auto& child: o->children) { if (sp_repr_css_property(const_cast(css), "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. @@ -2073,7 +2073,7 @@ bool has_visible_text(SPObject *obj) if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) { hasVisible = true; // maybe we should also check that it's not all whitespace? } else { - for (auto& child: obj->_children) { + for (auto& child: obj->children) { if (has_visible_text(const_cast(&child))) { hasVisible = true; break; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 48d53857b..b25a70b15 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -839,7 +839,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) SPObject *mask = item->mask_ref->getObject(); _copyNode(mask->getRepr(), _doc, _defs); // recurse into the mask for its gradients etc. - for(auto& o: mask->_children) { + for(auto& o: mask->children) { SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); @@ -857,7 +857,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } // recurse - for(auto& o: item->_children) { + for(auto& o: item->children) { SPItem *childItem = dynamic_cast(&o); if (childItem) { _copyUsedDefs(childItem); @@ -894,7 +894,7 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) _copyNode(pattern->getRepr(), _doc, _defs); // items in the pattern may also use gradients and other patterns, so recurse - for (auto& child: pattern->_children) { + for (auto& child: pattern->children) { SPItem *childItem = dynamic_cast(&child); if (childItem) { _copyUsedDefs(childItem); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 11af02e3c..1e8ca4405 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2042,7 +2042,7 @@ void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) if (!trace_drawing) return; - for (auto& o: from->_children) { + for (auto& o: from->children) { SPItem *item = dynamic_cast(&o); if (item && clonetiler_is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! @@ -2123,7 +2123,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) std::vector to_unclump; // not including the original - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { to_unclump.push_back((SPItem*)&child); } @@ -2143,7 +2143,7 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) guint n = 0; - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { n ++; } @@ -2172,7 +2172,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d // remove old tiling GSList *to_delete = NULL; - for (auto& child: parent->_children) { + for (auto& child: parent->children) { if (clonetiler_is_a_clone_of (&child, obj)) { to_delete = g_slist_prepend (to_delete, &child); } diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index df37eb005..6f5f14d80 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1315,7 +1315,7 @@ void DocumentProperties::changeEmbeddedScript(){ for (std::vector::const_iterator it = current.begin(); it != current.end(); ++it) { SPObject* obj = *it; if (id == obj->getId()){ - int count = (int) obj->_children.size(); + int count = (int) obj->children.size(); if (count>1) g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); @@ -1359,7 +1359,7 @@ void DocumentProperties::editEmbeddedScript(){ //XML Tree being used directly here while it shouldn't be. Inkscape::XML::Node *repr = obj->getRepr(); if (repr){ - auto tmp = obj->_children | boost::adaptors::transformed([](SPObject& o) { return &o; }); + auto tmp = obj->children | boost::adaptors::transformed([](SPObject& o) { return &o; }); std::vector vec(tmp.begin(), tmp.end()); for (auto &child: vec) { child->deleteObject(); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 1be5d540a..3e3ede019 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -103,7 +103,7 @@ static int input_count(const SPFilterPrimitive* prim) return 2; else if(SP_IS_FEMERGE(prim)) { // Return the number of feMergeNode connections plus an extra - return (int) (prim->_children.size() + 1); + return (int) (prim->children.size() + 1); } else return 1; @@ -1060,7 +1060,7 @@ public: { SPFeFuncNode* funcNode = NULL; bool found = false; - for(auto& node: ct->_children) { + for(auto& node: ct->children) { funcNode = SP_FEFUNCNODE(&node); if( funcNode->channel == _channel ) { found = true; @@ -1868,7 +1868,7 @@ void FilterEffectsDialog::PrimitiveList::update() bool active_found = false; _dialog._primitive_box->set_sensitive(true); _dialog.update_filter_general_settings_view(); - for(auto& prim_obj: f->_children) { + for(auto& prim_obj: f->children) { SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(&prim_obj); if(!prim) { break; @@ -2339,7 +2339,7 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T if(SP_IS_FEMERGE(prim)) { int c = 0; bool found = false; - for (auto& o: prim->_children) { + for (auto& o: prim->children) { if(c == attr && SP_IS_FEMERGENODE(&o)) { image = SP_FEMERGENODE(&o)->input; found = true; @@ -2531,7 +2531,7 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* if(SP_IS_FEMERGE(prim)) { int c = 1; bool handled = false; - for (auto& o: prim->_children) { + for (auto& o: prim->children) { if(c == _in_drag && SP_IS_FEMERGENODE(&o)) { // If input is null, delete it if(!in_val) { diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index e156dfa13..b09ce6078 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -747,7 +747,7 @@ std::vector &Find::all_items (SPObject *r, std::vector &l, boo return l; // we're not interested in metadata } - for (auto& child: r->_children) { + for (auto& child: r->children) { SPItem *item = dynamic_cast(&child); if (item && !child.cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index eafe5566a..b927096ab 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -182,7 +182,7 @@ std::vector FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli family = SP_TEXT(parent_text)->layout.getFontFamily(0); // Add all the spans fonts to the set gint ii = 0; - for (auto& child: parent_text->_children) { + for (auto& child: parent_text->children) { family = SP_TEXT(parent_text)->layout.getFontFamily(ii); setFontSpans.insert(family); ii++; diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index e4639745f..f4d3a3f70 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -340,7 +340,7 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/) void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) { if ( _desktop && obj ) { - for(auto& child: obj->_children) { + for(auto& child: obj->children) { if (SP_IS_ITEM(&child)) { SPItem * item = SP_ITEM(&child); @@ -398,7 +398,7 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) { //end mark if (recurse) { - for (auto& iter: obj->_children) { + for (auto& iter: obj->children) { _updateObject(&iter, recurse); } } @@ -518,7 +518,7 @@ void ObjectsPanel::_setCompositingValues(SPItem *item) SPGaussianBlur *spblur = NULL; if (item->style->getFilter()) { - for (auto& primitive_obj: item->style->getFilter()->_children) { + for (auto& primitive_obj: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { break; } @@ -1293,7 +1293,7 @@ bool ObjectsPanel::_executeAction() break; case BUTTON_COLLAPSE_ALL: { - for (auto& obj: _document->getRoot()->_children) { + for (auto& obj: _document->getRoot()->children) { if (SP_IS_GROUP(&obj)) { _setCollapsed(SP_GROUP(&obj)); } @@ -1405,7 +1405,7 @@ void ObjectsPanel::_setCollapsed(SPGroup * group) { group->setExpanded(false); group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); - for (auto& iter: group->_children) { + for (auto& iter: group->children) { if (SP_IS_GROUP(&iter)) { _setCollapsed(SP_GROUP(&iter)); } @@ -1523,7 +1523,7 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl if (blendmode != "normal") { gdouble radius = 0; if (item->style->getFilter()) { - for (auto& primitive: item->style->getFilter()->_children) { + for (auto& primitive: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { break; } @@ -1538,7 +1538,7 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius); sp_style_set_property_url(item, "filter", filter, false); } else { - for (auto& primitive: item->style->getFilter()->_children) { + for (auto& primitive: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { break; } @@ -1598,7 +1598,7 @@ void ObjectsPanel::_blurChangedIter(const Gtk::TreeIter& iter, double blur) SPFilter *filter = modify_filter_gaussian_blur_from_item(_document, item, radius); sp_style_set_property_url(item, "filter", filter, false); } else if (item->style->filter.set && item->style->getFilter()) { - for (auto& primitive: item->style->getFilter()->_children) { + for (auto& primitive: item->style->getFilter()->children) { if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { break; } diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 9338a4e8c..ac8ef5c15 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -234,7 +234,7 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock return l; // we're not interested in metadata } - for (auto& child: r->_children) { + for (auto& child: r->children) { if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) { if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) { if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child)) diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 93bd67a3d..a723c86d8 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -115,7 +115,7 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){ void SvgFontsDialog::AttrEntry::on_attr_changed(){ SPObject* o = NULL; - for (auto& node: dialog->get_selected_spfont()->_children) { + for (auto& node: dialog->get_selected_spfont()->children) { switch(this->attr){ case SP_PROP_FONT_FAMILY: if (SP_IS_FONTFACE(&node)){ @@ -170,7 +170,7 @@ void GlyphComboBox::update(SPFont* spfont){ this->append(""); //Gtk is refusing to clear the combobox when I comment out this line this->remove_all(); - for (auto& node: spfont->_children) { + for (auto& node: spfont->children) { if (SP_IS_GLYPH(&node)){ this->append((static_cast(&node))->unicode); } @@ -308,7 +308,7 @@ void SvgFontsDialog::update_global_settings_tab(){ SPFont* font = get_selected_spfont(); if (!font) return; - for (auto& obj: font->_children) { + for (auto& obj: font->children) { if (SP_IS_FONTFACE(&obj)){ _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family); } @@ -413,7 +413,7 @@ SvgFontsDialog::populate_glyphs_box() SPFont* spfont = this->get_selected_spfont(); _glyphs_observer.set(spfont); - for (auto& node: spfont->_children) { + for (auto& node: spfont->children) { if (SP_IS_GLYPH(&node)){ Gtk::TreeModel::Row row = *(_GlyphsListStore->append()); row[_GlyphsListColumns.glyph_node] = static_cast(&node); @@ -431,7 +431,7 @@ SvgFontsDialog::populate_kerning_pairs_box() SPFont* spfont = this->get_selected_spfont(); - for (auto& node: spfont->_children) { + for (auto& node: spfont->children) { if (SP_IS_HKERN(&node)){ Gtk::TreeModel::Row row = *(_KerningPairsListStore->append()); row[_KerningPairsListColumns.first_glyph] = (static_cast(&node))->u1->attribute_string().c_str(); @@ -492,7 +492,7 @@ void SvgFontsDialog::add_glyph(){ Geom::PathVector SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ double units_per_em = 1000; - for (auto& obj: get_selected_spfont()->_children) { + for (auto& obj: get_selected_spfont()->children) { if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em); @@ -574,7 +574,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - for (auto& obj: get_selected_spfont()->_children) { + for (auto& obj: get_selected_spfont()->children) { if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. @@ -596,7 +596,7 @@ void SvgFontsDialog::reset_missing_glyph_description(){ } SPDocument* doc = desktop->getDocument(); - for (auto& obj: get_selected_spfont()->_children) { + for (auto& obj: get_selected_spfont()->children) { if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); @@ -734,7 +734,7 @@ void SvgFontsDialog::add_kerning_pair(){ //look for this kerning pair on the currently selected font this->kerning_pair = NULL; - for (auto& node: get_selected_spfont()->_children) { + for (auto& node: get_selected_spfont()->children) { //TODO: It is not really correct to get only the first byte of each string. //TODO: We should also support vertical kerning if (SP_IS_HKERN(&node) && (static_cast(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) @@ -848,7 +848,7 @@ SPFont *new_font(SPDocument *document) void set_font_family(SPFont* font, char* str){ if (!font) return; - for (auto& obj: font->_children) { + for (auto& obj: font->children) { if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. obj.getRepr()->setAttribute("font-family", str); @@ -868,7 +868,7 @@ void SvgFontsDialog::add_font(){ font->setLabel(os.str().c_str()); os2 << "SVGFont " << count; - for (auto& obj: font->_children) { + for (auto& obj: font->children) { if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. obj.getRepr()->setAttribute("font-family", os2.str().c_str()); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 1fdce34a5..84088052e 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -658,7 +658,7 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (auto& child: r->_children) { + for (auto& child: r->children) { l = symbols_in_doc_recursive( &child, l ); } @@ -680,7 +680,7 @@ GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (auto& child: r->_children) { + for (auto& child: r->children) { l = use_in_doc_recursive( &child, l ); } diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 61c8b5d37..fcc9b804c 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -399,7 +399,7 @@ void TagsPanel::_objectsChanged(SPObject* root) void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* parentRow ) { if ( _desktop && obj ) { - for (auto& child: obj->_children) { + for (auto& child: obj->children) { if (SP_IS_TAG(&child)) { Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); @@ -430,7 +430,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* _tree.expand_to_path( _store->get_path(iteritems) ); - for (auto& child: obj->_children) { + for (auto& child: obj->children) { if (SP_IS_TAG_USE(&child)) { SPItem *item = SP_TAG_USE(&child)->ref->getObject(); @@ -459,7 +459,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* void TagsPanel::_select_tag( SPTag * tag ) { - for (auto& child: tag->_children) { + for (auto& child: tag->children) { if (SP_IS_TAG(&child)) { _select_tag(SP_TAG(&child)); } else if (SP_IS_TAG_USE(&child)) { @@ -649,7 +649,7 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) for(auto i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; - for (auto& child: obj->_children) { + for (auto& child: obj->children) { if (SP_IS_TAG_USE(&child) && SP_TAG_USE(&child)->ref->getObject() == newobj) { addchild = false; } diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 2adba38c5..9a0b37913 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -118,7 +118,7 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { SPDefs *defs = document->getDefs(); bool has_persp = false; - for (auto& child: defs->_children) { + for (auto& child: defs->children) { if (SP_IS_PERSP3D(&child)) { has_persp = true; break; diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index be8ce6d0c..11752726b 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1114,7 +1114,7 @@ void ConnectorTool::_setActiveShape(SPItem *item) { // The idea here is to try and add a group's children to solidify // connection handling. We react to path objects with only one node. - for (auto& child: item->_children) { + for (auto& child: item->children) { if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) { this->_activeShapeAddKnot((SPItem *) &child); } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 3dfac5e3d..87b7bf7e3 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -378,7 +378,7 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape r.role = role; s.insert(r); } else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) { - for (auto& c: obj->_children) { + for (auto& c: obj->children) { gather_items(nt, base, &c, role, s); } } else if (SP_IS_ITEM(obj)) { diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 7da0973d5..361986d0c 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -385,7 +385,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (dynamic_cast(item) && !dynamic_cast(item)) { GSList *children = NULL; - for (auto& child: item->_children) { + for (auto& child: item->children) { if (dynamic_cast(static_cast(&child))) { children = g_slist_prepend(children, &child); } @@ -832,7 +832,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or double offset_l = 0; double offset_h = 0; SPObject *child_prev = NULL; - for (auto& child: vector->_children) { + for (auto& child: vector->children) { SPStop *stop = dynamic_cast(&child); if (!stop) { continue; @@ -894,7 +894,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, bool did = false; if (dynamic_cast(item)) { - for (auto& child: item->_children) { + for (auto& child: item->children) { SPItem *childItem = dynamic_cast(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, @@ -951,7 +951,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, Geom::Affine i2dt = item->i2dt_affine (); if (style->filter.set && style->getFilter()) { //cycle through filter primitives - for (auto& primitive_obj: style->getFilter()->_children) { + for (auto& primitive_obj: style->getFilter()->children) { SPFilterPrimitive *primitive = dynamic_cast(&primitive_obj); if (primitive) { //if primitive is gaussianblur diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 46a0b3547..c080579f1 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -352,7 +352,7 @@ void LayerSelector::_buildSiblingEntries( ) { using Inkscape::Util::rest; - auto siblings = parent._children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed; + auto siblings = parent.children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed; SPObject *layer( hierarchy ? &*hierarchy : NULL ); diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 23802ae65..6ef933982 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -76,7 +76,7 @@ bool URIReference::_acceptObject(SPObject *obj) const std::vector positions; while (owner->cloned) { int position = 0; - for (auto &child: owner->parent->_children) { + for (auto &child: owner->parent->children) { if(&child == owner) { break; } diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index c4b2ed59a..1565e16f3 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -720,7 +720,7 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPStop *new_stop, GtkWidget *data, gboolean block) { int i = 0; - for (auto& ochild: gradient->_children) { + for (auto& ochild: gradient->children) { if (SP_IS_STOP(&ochild)) { if (&ochild == new_stop) { blocked = block; @@ -765,7 +765,7 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S /* Populate the combobox store */ std::vector sl; if ( gradient->hasStops() ) { - for (auto& ochild: gradient->_children) { + for (auto& ochild: gradient->children) { if (SP_IS_STOP(&ochild)) { sl.push_back(&ochild); } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 813a2d28e..5f549a77c 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -363,7 +363,7 @@ unsigned long sp_gradient_to_hhssll(SPGradient *gr) static GSList *get_all_doc_items(GSList *list, SPObject *from, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) { - for (auto& child: from->_children) { + for (auto& child: from->children) { if (SP_IS_ITEM(&child)) { list = g_slist_prepend(list, SP_ITEM(&child)); } @@ -525,7 +525,7 @@ static void verify_grad(SPGradient *gradient) int i = 0; SPStop *stop = NULL; /* count stops */ - for (auto& ochild: gradient->_children) { + for (auto& ochild: gradient->children) { if (SP_IS_STOP(&ochild)) { i++; stop = SP_STOP(&ochild); @@ -568,7 +568,7 @@ static void select_stop_in_list( GtkWidget *vb, SPGradient *gradient, SPStop *ne GtkWidget *combo_box = static_cast(g_object_get_data(G_OBJECT(vb), "combo_box")); int i = 0; - for (auto& ochild: gradient->_children) { + for (auto& ochild: gradient->children) { if (SP_IS_STOP(&ochild)) { if (&ochild == new_stop) { gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , i); @@ -603,7 +603,7 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s /* Populate the combobox store */ GSList *sl = NULL; if ( gradient->hasStops() ) { - for (auto& ochild: gradient->_children) { + for (auto& ochild: gradient->children) { if (SP_IS_STOP(&ochild)) { sl = g_slist_append(sl, &ochild); } diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index fd7b5f6cd..af3f03420 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -335,7 +335,7 @@ GSList *MarkerComboBox::get_marker_list (SPDocument *source) return NULL; } - for (auto& child: defs->_children) + for (auto& child: defs->children) { if (SP_IS_MARKER(&child)) { ml = g_slist_prepend (ml, &child); -- cgit v1.2.3 From 3c593bb8da3357514ff5b4f3154d08c4508ad47e Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 20 Jul 2016 11:01:17 +0200 Subject: Changed arguments and names of selection chemistry functions (bzr r14954.1.22) --- src/object-set.h | 43 ++++++- src/persp3d.cpp | 4 +- src/persp3d.h | 2 +- src/selection-chemistry.cpp | 289 ++++++++++++++++++++++---------------------- src/selection-chemistry.h | 34 +++--- src/selection.cpp | 5 +- src/selection.h | 10 +- src/ui/interface.cpp | 2 +- src/verbs.cpp | 12 +- 9 files changed, 217 insertions(+), 184 deletions(-) (limited to 'src') diff --git a/src/object-set.h b/src/object-set.h index 0f06e373b..a0bca7889 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -26,11 +26,14 @@ #include #include #include +#include #include "sp-object.h" #include "sp-item.h" +#include "sp-item-group.h" class SPBox3D; class Persp3D; +class SPDesktop; namespace Inkscape { @@ -47,6 +50,12 @@ struct is_item { } }; +struct is_group { + bool operator()(SPObject* obj) { + return SP_IS_GROUP(obj); + } +}; + struct object_to_item { typedef SPItem* result_type; SPItem* operator()(SPObject* obj) const { @@ -61,6 +70,13 @@ struct object_to_node { } }; +struct object_to_group { + typedef SPGroup* result_type; + SPGroup* operator()(SPObject* obj) const { + return SP_GROUP(obj); + } +}; + typedef boost::multi_index_container< SPObject*, boost::multi_index::indexed_by< @@ -82,9 +98,10 @@ class ObjectSet { public: enum CompareSize {HORIZONTAL, VERTICAL, AREA}; typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_item())) SPItemRange; + typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_group()) | boost::adaptors::transformed(object_to_group())) SPGroupRange; typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())) XMLNodeRange; - ObjectSet() {}; + ObjectSet(SPDesktop* desktop): _desktop(desktop) {}; virtual ~ObjectSet(); /** @@ -177,18 +194,25 @@ public: /** Returns the list of selected objects. */ SPObjectRange objects(); - /** Returns the list of selected SPItems. */ + /** Returns a range of selected SPItems. */ SPItemRange items() { return SPItemRange(container.get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_item())); }; - /** Returns a list of the xml nodes of all selected objects. */ + /** Returns a range of selected groups. */ + SPGroupRange groups() { + return SPGroupRange (container.get() + | boost::adaptors::filtered(is_group()) + | boost::adaptors::transformed(object_to_group())); + } + + /** Returns a range of the xml nodes of all selected objects. */ XMLNodeRange xmlNodes() { return XMLNodeRange(container.get() - | boost::adaptors::filtered(is_item()) - | boost::adaptors::transformed(object_to_node())); + | boost::adaptors::filtered(is_item()) + | boost::adaptors::transformed(object_to_node())); } /** @@ -254,6 +278,13 @@ public: */ std::list const box3DList(Persp3D *persp = NULL); + /** + * Returns the desktop the selection is bound to + * + * @return the desktop the selection is bound to, or NULL if in console mode + */ + SPDesktop *desktop() { return _desktop; } + protected: virtual void _connectSignals(SPObject* object) {}; virtual void _releaseSignals(SPObject* object) {}; @@ -270,12 +301,14 @@ protected: virtual void _remove_3D_boxes_recursively(SPObject *obj); multi_index_container container; + GC::soft_ptr _desktop; std::list _3dboxes; std::unordered_map releaseConnections; }; typedef ObjectSet::SPItemRange SPItemRange; +typedef ObjectSet::SPGroupRange SPGroupRange; typedef ObjectSet::XMLNodeRange XMLNodeRange; } // namespace Inkscape diff --git a/src/persp3d.cpp b/src/persp3d.cpp index e260af8e5..7d79d3ab5 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -494,10 +494,10 @@ persp3d_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/, /* checks whether all boxes linked to this perspective are currently selected */ bool -persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::Selection *selection) { +persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::ObjectSet *set) { Persp3DImpl *persp_impl = persp->perspective_impl; - std::list selboxes = selection->box3DList(); + std::list selboxes = set->box3DList(); for (std::vector::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { if (std::find(selboxes.begin(), selboxes.end(), *i) == selboxes.end()) { diff --git a/src/persp3d.h b/src/persp3d.h index be5680bcb..ce0e3c120 100644 --- a/src/persp3d.h +++ b/src/persp3d.h @@ -107,7 +107,7 @@ void persp3d_absorb(Persp3D *persp1, Persp3D *persp2); Persp3D * persp3d_create_xml_element (SPDocument *document, Persp3DImpl *dup = NULL); Persp3D * persp3d_document_first_persp (SPDocument *document); -bool persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::Selection *selection); +bool persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::ObjectSet *set); void persp3d_print_debugging_info (Persp3D *persp); void persp3d_print_debugging_info_all(SPDocument *doc); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 81d711e77..e8c408ed8 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -12,8 +12,9 @@ * Abhishek Sharma * Kris De Gussem * Tavmjong Bah (Symbol additions) + * Adrian Boguszewski * - * Copyright (C) 1999-2010,2012 authors + * Copyright (C) 1999-2016 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -109,6 +110,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "live_effects/effect-enum.h" #include "live_effects/parameter/originalpath.h" #include "layer-manager.h" +#include "object-set.h" #include "enums.h" #include "sp-item-group.h" @@ -124,6 +126,7 @@ using Inkscape::DocumentUndo; using Geom::X; using Geom::Y; using Inkscape::UI::Tools::NodeTool; +using namespace Inkscape; /* The clipboard handling is in ui/clipboard.cpp now. There are some legacy functions left here, because the layer manipulation code uses them. It should be rewritten specifically @@ -691,9 +694,13 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop) sp_edit_select_all_full(desktop, true, true); } -static void sp_selection_group_impl(std::vector p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { +static Inkscape::XML::Node* sp_selection_group(ObjectSet *set) { + SPDocument *doc = set->desktop()->getDocument(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - sort(p.begin(),p.end(),sp_repr_compare_position_bool); + std::vector p(set->xmlNodes().begin(), set->xmlNodes().end()); + std::sort(p.begin(), p.end(), sp_repr_compare_position_bool); // Remember the position and parent of the topmost object. gint topmost = p.back()->position(); @@ -751,31 +758,24 @@ static void sp_selection_group_impl(std::vector p, Inkscap // Move to the position of the topmost, reduced by the number of items deleted from topmost_parent group->setPosition(topmost + 1); + + set->set(doc->getObjectByRepr(group)); + + return group; } -void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_group_ui(Inkscape::Selection *selection, SPDesktop *desktop) { - SPDocument *doc = selection->layers()->getDocument(); - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - // Check if something is selected. if (selection->isEmpty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select some objects to group.")); return; } + Inkscape::XML::Node* group = sp_selection_group(selection); - std::vector p (selection->xmlNodes().begin(), selection->xmlNodes().end()); - - selection->clear(); - - Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - - sp_selection_group_impl(p, group, xml_doc, doc); - - DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP, + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_GROUP, C_("Verb", "Group")); - selection->set(group); Inkscape::GC::release(group); } @@ -823,32 +823,16 @@ void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDeskto } - -void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) +static void sp_selection_ungroup(ObjectSet *set) { - if (selection->isEmpty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a group to ungroup.")); - } - - // first check whether there is anything to ungroup - auto old_select = selection->items(); - std::vector new_select; GSList *groups = NULL; - for (auto item = old_select.begin(); item!=old_select.end(); ++item) { - SPItem *obj = *item; - if (dynamic_cast(obj)) { - groups = g_slist_prepend(groups, obj); - } - } - - if (groups == NULL) { - selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("No groups to ungroup in the selection.")); - g_slist_free(groups); - return; + for (auto g: set->groups()) { + groups = g_slist_prepend(groups, g); } + std::vector new_select; + auto old_select = set->items(); std::vector items(old_select.begin(), old_select.end()); - selection->clear(); // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. @@ -895,7 +879,21 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } } - selection->addList(new_select); + set->setList(new_select); +} + +void sp_selection_ungroup_ui(Inkscape::Selection *selection, SPDesktop *desktop) +{ + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a group to ungroup.")); + } + + if (boost::distance(selection->groups()) == 0) { + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("No groups to ungroup in the selection.")); + return; + } + + sp_selection_ungroup(selection); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); @@ -931,18 +929,18 @@ sp_degroup_list(std::vector &items) /** If items in the list have a common parent, return it, otherwise return NULL */ static SPGroup * -sp_item_list_common_parent_group(std::vector const &items) +sp_item_list_common_parent_group(const SPItemRange &items) { if (items.empty()) { return NULL; } - SPObject *parent = items[0]->parent; + SPObject *parent = items.front()->parent; // Strictly speaking this CAN happen, if user selects from Inkscape::XML editor if (!dynamic_cast(parent)) { return NULL; } - for (std::vector::const_iterator item=items.begin();item!=items.end();++item) { - if((*item)==items[0])continue; + for (auto item=items.begin();item!=items.end();++item) { + if((*item)==items.front())continue; if ((*item)->parent != parent) { return NULL; } @@ -980,23 +978,9 @@ bool sp_item_repr_compare_position_bool(SPObject const *first, SPObject const *s ((SPItem*)second)->getRepr())<0; } -void -sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) -{ - std::vector items(selection->items().begin(), selection->items().end()); - - if (items.empty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise.")); - return; - } - - SPGroup const *group = sp_item_list_common_parent_group(items); - if (!group) { - selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from different groups or layers.")); - return; - } - - Inkscape::XML::Node *grepr = const_cast(group->getRepr()); +void sp_selection_raise(ObjectSet* set) { + std::vector items(set->items().begin(), set->items().end()); + Inkscape::XML::Node *grepr = const_cast(items.front()->parent->getRepr()); /* Construct reverse-ordered list of selected children. */ std::vector rev(items); @@ -1027,55 +1011,61 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) } } } - DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, - //TRANSLATORS: "Raise" means "to raise an object" in the undo history - C_("Undo action", "Raise")); } -void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_raise_ui(Inkscape::Selection *selection, SPDesktop *desktop) { - SPDocument *document = selection->layers()->getDocument(); - - if (selection->isEmpty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise to top.")); + if (selection->items().empty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise.")); return; } - std::vector items(selection->items().begin(), selection->items().end()); - - SPGroup const *group = sp_item_list_common_parent_group(items); + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); if (!group) { selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from different groups or layers.")); return; } + sp_selection_raise(selection); + + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, + //TRANSLATORS: "Raise" means "to raise an object" in the undo history + C_("Undo action", "Raise")); +} - std::vector rl(selection->xmlNodes().begin(), selection->xmlNodes().end()); +void sp_selection_raise_to_top(ObjectSet* set) { + std::vector rl(set->xmlNodes().begin(), set->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector::const_iterator l=rl.begin(); l!=rl.end();++l) { Inkscape::XML::Node *repr =(*l); repr->setPosition(-1); } - - DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, - _("Raise to top")); } -void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_raise_to_top_ui(Inkscape::Selection *selection, SPDesktop *desktop) { - std::vector items(selection->items().begin(), selection->items().end()); - if (items.empty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower.")); + SPDocument *document = selection->layers()->getDocument(); + + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise to top.")); return; } - SPGroup const *group = sp_item_list_common_parent_group(items); + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); if (!group) { selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from different groups or layers.")); return; } - Inkscape::XML::Node *grepr = const_cast(group->getRepr()); + sp_selection_raise_to_top(selection); + + DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, + _("Raise to top")); +} + +void sp_selection_lower(ObjectSet *set) { + std::vector items(set->items().begin(), set->items().end()); + Inkscape::XML::Node *grepr = const_cast(items.front()->parent->getRepr()); // Determine the common bbox of the selected items. Geom::OptRect selected = enclose_items(items); @@ -1110,37 +1100,37 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) } } } - - DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, - //TRANSLATORS: "Lower" means "to lower an object" in the undo history - C_("Undo action", "Lower")); } -void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_lower_ui(Inkscape::Selection *selection, SPDesktop *desktop) { - SPDocument *document = selection->layers()->getDocument(); - - if (selection->isEmpty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower to bottom.")); + if (selection->items().empty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower.")); return; } - std::vector items(selection->items().begin(), selection->items().end()); - - SPGroup const *group = sp_item_list_common_parent_group(items); + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); if (!group) { selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from different groups or layers.")); return; } - std::vector rl(selection->xmlNodes().begin(), selection->xmlNodes().end()); + sp_selection_lower(selection); + + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, + //TRANSLATORS: "Lower" means "to lower an object" in the undo history + C_("Undo action", "Lower")); +} + +void sp_selection_lower_to_bottom(ObjectSet *set) { + std::vector rl(set->xmlNodes().begin(), set->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector::const_reverse_iterator l=rl.rbegin();l!=rl.rend();++l) { gint minpos; SPObject *pp; Inkscape::XML::Node *repr = (*l); - pp = document->getObjectByRepr(repr->parent()); + pp = set->desktop()->getDocument()->getObjectByRepr(repr->parent()); minpos = 0; g_assert(dynamic_cast(pp)); for (auto& pc: pp->children) { @@ -1151,8 +1141,24 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des } repr->setPosition(minpos); } +} + +void sp_selection_lower_to_bottom_ui(Inkscape::Selection *selection, SPDesktop *desktop) +{ + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower to bottom.")); + return; + } + + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); + if (!group) { + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from different groups or layers.")); + return; + } + + sp_selection_lower_to_bottom(selection); - DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_TO_BACK, _("Lower to bottom")); } @@ -1478,7 +1484,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) } static bool -selection_contains_original(SPItem *item, Inkscape::Selection *selection) +selection_contains_original(SPItem *item, ObjectSet* set) { bool contains_original = false; @@ -1489,7 +1495,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) { item_use = use->get_original(); use = dynamic_cast(item_use); - contains_original |= selection->includes(item_use); + contains_original |= set->includes(item_use); if (item_use == item_use_first) break; } @@ -1498,7 +1504,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) // data is part of the selection SPTRef *tref = dynamic_cast(item); if (!contains_original && tref) { - contains_original = selection->includes(tref->getObjectReferredTo()); + contains_original = set->includes(tref->getObjectReferredTo()); } return contains_original; @@ -1506,14 +1512,14 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) static bool -selection_contains_both_clone_and_original(Inkscape::Selection *selection) +selection_contains_both_clone_and_original(ObjectSet *set) { bool clone_with_original = false; - auto items = selection->items(); + auto items = set->items(); for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if (item) { - clone_with_original |= selection_contains_original(item, selection); + clone_with_original |= selection_contains_original(item, set); if (clone_with_original) break; } @@ -1527,21 +1533,21 @@ value of set_i2d==false is only used by seltrans when it's dragging objects live that case, items are already in the new position, but the repr is in the old, and this function then simply updates the repr from item->transform. */ -void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d, bool compensate, bool adjust_transf_center) +void sp_selection_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool set_i2d, bool compensate, bool adjust_transf_center) { - if (selection->isEmpty()) + if (set->isEmpty()) return; // For each perspective with a box in selection, check whether all boxes are selected and // unlink all non-selected boxes. Persp3D *persp; Persp3D *transf_persp; - std::list plist = selection->perspList(); + std::list plist = set->perspList(); for (std::list::iterator i = plist.begin(); i != plist.end(); ++i) { persp = (Persp3D *) (*i); - if (!persp3d_has_all_boxes_in_selection (persp, selection)) { - std::list selboxes = selection->box3DList(persp); + if (!persp3d_has_all_boxes_in_selection (persp, set)) { + std::list selboxes = set->box3DList(persp); // create a new perspective as a copy of the current one and link the selected boxes to it transf_persp = persp3d_create_xml_element (persp->document, persp->perspective_impl); @@ -1554,14 +1560,14 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons persp3d_apply_affine_transformation(transf_persp, affine); } - auto items = selection->items(); + auto items = set->items(); for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if( dynamic_cast(item) ) { // An SVG element cannot have a transform. We could change 'x' and 'y' in response // to a translation... but leave that for another day. - selection->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG.")); + set->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG.")); break; } @@ -1575,17 +1581,17 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons #endif // we're moving both a clone and its original or any ancestor in clone chain? - bool transform_clone_with_original = selection_contains_original(item, selection); + bool transform_clone_with_original = selection_contains_original(item, set); // ...both a text-on-path and its path? bool transform_textpath_with_path = ((dynamic_cast(item) && item->firstChild() && dynamic_cast(item->firstChild())) - && selection->includes( sp_textpath_get_path_item(dynamic_cast(item->firstChild())) )); + && set->includes( sp_textpath_get_path_item(dynamic_cast(item->firstChild())) )); // ...both a flowtext and its frame? - bool transform_flowtext_with_frame = (dynamic_cast(item) && selection->includes( dynamic_cast(item)->get_frame(NULL))); // (only the first frame is checked so far) + bool transform_flowtext_with_frame = (dynamic_cast(item) && set->includes( dynamic_cast(item)->get_frame(NULL))); // (only the first frame is checked so far) // ...both an offset and its source? - bool transform_offset_with_source = (dynamic_cast(item) && dynamic_cast(item)->sourceHref) && selection->includes( sp_offset_get_source(dynamic_cast(item)) ); + bool transform_offset_with_source = (dynamic_cast(item) && dynamic_cast(item)->sourceHref) && set->includes( sp_offset_get_source(dynamic_cast(item)) ); // If we're moving a connector, we want to detach it // from shapes that aren't part of the selection, but @@ -1596,7 +1602,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons SPItem *attItem[2] = {0, 0}; path->connEndPair.getAttachedItems(attItem); for (int n = 0; n < 2; ++n) { - if (!selection->includes(attItem[n])) { + if (!set->includes(attItem[n])) { sp_conn_end_detach(item, n); } } @@ -1735,14 +1741,14 @@ void sp_selection_remove_transform(SPDesktop *desktop) } void -sp_selection_scale_absolute(Inkscape::Selection *selection, +sp_selection_scale_absolute(ObjectSet *set, double const x0, double const x1, double const y0, double const y1) { - if (selection->isEmpty()) + if (set->isEmpty()) return; - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = set->visualBounds(); if ( !bbox ) { return; } @@ -1755,16 +1761,16 @@ sp_selection_scale_absolute(Inkscape::Selection *selection, Geom::Translate const o2n(x0, y0); Geom::Affine const final( p2o * scale * o2n ); - sp_selection_apply_affine(selection, final); + sp_selection_apply_affine(set, final); } -void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale) +void sp_selection_scale_relative(ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale) { - if (selection->isEmpty()) + if (set->isEmpty()) return; - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = set->visualBounds(); if ( !bbox ) { return; @@ -1780,21 +1786,21 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point con Geom::Translate const n2d(-align); Geom::Translate const d2n(align); Geom::Affine const final( n2d * scale * d2n ); - sp_selection_apply_affine(selection, final); + sp_selection_apply_affine(set, final); } void -sp_selection_rotate_relative(Inkscape::Selection *selection, Geom::Point const ¢er, gdouble const angle_degrees) +sp_selection_rotate_relative(ObjectSet *set, Geom::Point const ¢er, gdouble const angle_degrees) { Geom::Translate const d2n(center); Geom::Translate const n2d(-center); Geom::Rotate const rotate(Geom::Rotate::from_degrees(angle_degrees)); Geom::Affine const final( Geom::Affine(n2d) * rotate * d2n ); - sp_selection_apply_affine(selection, final); + sp_selection_apply_affine(set, final); } void -sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy) +sp_selection_skew_relative(ObjectSet *set, Geom::Point const &align, double dx, double dy) { Geom::Translate const d2n(align); Geom::Translate const n2d(-align); @@ -1802,17 +1808,17 @@ sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &al dx, 1, 0, 0); Geom::Affine const final( n2d * skew * d2n ); - sp_selection_apply_affine(selection, final); + sp_selection_apply_affine(set, final); } -void sp_selection_move_relative(Inkscape::Selection *selection, Geom::Point const &move, bool compensate) +void sp_selection_move_relative(ObjectSet *set, Geom::Point const &move, bool compensate) { - sp_selection_apply_affine(selection, Geom::Affine(Geom::Translate(move)), true, compensate); + sp_selection_apply_affine(set, Geom::Affine(Geom::Translate(move)), true, compensate); } -void sp_selection_move_relative(Inkscape::Selection *selection, double dx, double dy) +void sp_selection_move_relative(ObjectSet *set, double dx, double dy) { - sp_selection_apply_affine(selection, Geom::Affine(Geom::Translate(dx, dy))); + sp_selection_apply_affine(set, Geom::Affine(Geom::Translate(dx, dy))); } /** @@ -2244,8 +2250,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow) void sp_selection_scale_screen(Inkscape::Selection *selection, gdouble grow_pixels) { - sp_selection_scale(selection, - grow_pixels / selection->desktop()->current_zoom()); + sp_selection_scale(selection, grow_pixels / selection->desktop()->current_zoom()); } void @@ -3471,13 +3476,13 @@ void sp_selection_untile(SPDesktop *desktop) } } -void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring &filename, float *xdpi, float *ydpi) +void sp_selection_get_export_hints(ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi) { - if (selection->isEmpty()) { + if (set->isEmpty()) { return; } - auto reprlst = selection->xmlNodes(); + auto reprlst = set->xmlNodes(); bool filename_search = TRUE; bool xdpi_search = TRUE; bool ydpi_search = TRUE; @@ -3947,18 +3952,13 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ if (grouping == PREFS_MASKOBJECT_GROUPING_ALL) { // group all those objects into one group // and apply mask to that - Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); + ObjectSet* set = new ObjectSet(selection->desktop()); + set->add(apply_to_items.begin(), apply_to_items.end()); - // make a note we should ungroup this when unsetting mask - group->setAttribute("inkscape:groupmode", "maskhelper"); - - std::vector reprs_to_group; - for (std::vector::const_iterator i = apply_to_items.begin(); i != apply_to_items.end(); ++i) { - reprs_to_group.push_back(static_cast(*i)->getRepr()); - } items_to_select.clear(); - sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); + Inkscape::XML::Node *group = sp_selection_group(set); + group->setAttribute("inkscape:groupmode", "maskhelper"); // apply clip/mask only to newly created group apply_to_items.clear(); @@ -3966,6 +3966,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); + delete set; Inkscape::GC::release(group); } if (grouping == PREFS_MASKOBJECT_GROUPING_SEPARATE) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 82b91c617..cfae84eef 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -26,6 +26,7 @@ class SPDesktop; namespace Inkscape { class Selection; +class ObjectSet; namespace LivePathEffect { class PathParam; @@ -74,14 +75,19 @@ void sp_selection_unsymbol(SPDesktop *desktop); void sp_selection_tile(SPDesktop *desktop, bool apply = true); void sp_selection_untile(SPDesktop *desktop); -void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_group_ui(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_ungroup_ui(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_raise(Inkscape::ObjectSet* set); +void sp_selection_raise_to_top(Inkscape::ObjectSet* set); +void sp_selection_lower(Inkscape::ObjectSet *set); +void sp_selection_lower_to_bottom(Inkscape::ObjectSet *set); + +void sp_selection_raise_ui(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_raise_to_top_ui(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower_ui(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower_to_bottom_ui(Inkscape::Selection *selection, SPDesktop *desktop); SPCSSAttr *take_style_from_item (SPObject *object); @@ -103,14 +109,14 @@ void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false ) void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false ); void sp_selection_to_layer( SPDesktop *desktop, SPObject *layer, bool suppressDone = false ); -void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true, bool adjust_transf_center = true); +void sp_selection_apply_affine(Inkscape::ObjectSet *selection, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true, bool adjust_transf_center = true); void sp_selection_remove_transform (SPDesktop *desktop); -void sp_selection_scale_absolute (Inkscape::Selection *selection, double x0, double x1, double y0, double y1); -void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale); -void sp_selection_rotate_relative (Inkscape::Selection *selection, Geom::Point const ¢er, double angle); -void sp_selection_skew_relative (Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy); -void sp_selection_move_relative (Inkscape::Selection *selection, Geom::Point const &move, bool compensate = true); -void sp_selection_move_relative (Inkscape::Selection *selection, double dx, double dy); +void sp_selection_scale_absolute (Inkscape::ObjectSet *set, double x0, double x1, double y0, double y1); +void sp_selection_scale_relative(Inkscape::ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale); +void sp_selection_rotate_relative (Inkscape::ObjectSet *set, Geom::Point const ¢er, double angle); +void sp_selection_skew_relative (Inkscape::ObjectSet *set, Geom::Point const &align, double dx, double dy); +void sp_selection_move_relative (Inkscape::ObjectSet *set, Geom::Point const &move, bool compensate = true); +void sp_selection_move_relative (Inkscape::ObjectSet *set, double dx, double dy); void sp_selection_rotate_90 (SPDesktop *desktop, bool ccw); void sp_selection_rotate (Inkscape::Selection *selection, double angle); @@ -151,7 +157,7 @@ void scroll_to_show_item(SPDesktop *desktop, SPItem *item); void sp_undo (SPDesktop *desktop, SPDocument *doc); void sp_redo (SPDesktop *desktop, SPDocument *doc); -void sp_selection_get_export_hints (Inkscape::Selection *selection, Glib::ustring &filename, float *xdpi, float *ydpi); +void sp_selection_get_export_hints (Inkscape::ObjectSet* set, Glib::ustring &filename, float *xdpi, float *ydpi); void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, float *xdpi, float *ydpi); void sp_selection_create_bitmap_copy (SPDesktop *desktop); diff --git a/src/selection.cpp b/src/selection.cpp index 09eaf6c0e..bdd4f0dc7 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -27,15 +27,16 @@ #include "sp-shape.h" #include "sp-path.h" +#include "desktop.h" #include "document.h" #define SP_SELECTION_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE + 1) namespace Inkscape { -Selection::Selection(LayerModel *layers, SPDesktop *desktop) : +Selection::Selection(LayerModel *layers, SPDesktop *desktop): + ObjectSet(desktop), _layers(layers), - _desktop(desktop), _selection_context(NULL), _flags(0), _idle(0) diff --git a/src/selection.h b/src/selection.h index 7027a388f..4ea70c38d 100644 --- a/src/selection.h +++ b/src/selection.h @@ -23,11 +23,9 @@ #include "inkgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" -#include "inkgc/gc-soft-ptr.h" #include "sp-item.h" #include "object-set.h" -class SPDesktop; class SPItem; namespace Inkscape { @@ -80,12 +78,7 @@ public: */ LayerModel *layers() { return _layers; } - /** - * Returns the desktop the selection is bound to - * - * @return the desktop the selection is bound to, or NULL if in console mode - */ - SPDesktop *desktop() { return _desktop; } + /** * Returns active layer for selection (currentLayer or its parent). @@ -228,7 +221,6 @@ private: void _releaseContext(SPObject *obj); LayerModel *_layers; - GC::soft_ptr _desktop; SPObject* _selection_context; unsigned int _flags; unsigned int _idle; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index bcf055654..d19526105 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1916,7 +1916,7 @@ void ContextMenu::MakeGroupMenu(void) void ContextMenu::ActivateGroup(void) { - sp_selection_group(_desktop->selection, _desktop); + sp_selection_group_ui(_desktop->selection, _desktop); } void ContextMenu::ActivateUngroup(void) diff --git a/src/verbs.cpp b/src/verbs.cpp index 299cfe8e7..8255ea1ea 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1133,22 +1133,22 @@ void SelectionVerb::perform(SPAction *action, void *data) sp_selected_path_slice(selection, dt); break; case SP_VERB_SELECTION_TO_FRONT: - sp_selection_raise_to_top(selection, dt); + sp_selection_raise_to_top_ui(selection, dt); break; case SP_VERB_SELECTION_TO_BACK: - sp_selection_lower_to_bottom(selection, dt); + sp_selection_lower_to_bottom_ui(selection, dt); break; case SP_VERB_SELECTION_RAISE: - sp_selection_raise(selection, dt); + sp_selection_raise_ui(selection, dt); break; case SP_VERB_SELECTION_LOWER: - sp_selection_lower(selection, dt); + sp_selection_lower_ui(selection, dt); break; case SP_VERB_SELECTION_GROUP: - sp_selection_group(selection, dt); + sp_selection_group_ui(selection, dt); break; case SP_VERB_SELECTION_UNGROUP: - sp_selection_ungroup(selection, dt); + sp_selection_ungroup_ui(selection, dt); break; case SP_VERB_SELECTION_UNGROUP_POP_SELECTION: sp_selection_ungroup_pop_selection(selection, dt); -- cgit v1.2.3 From a227e8d45e7eaa6bf25d8ab65fbd404bc4597306 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 20 Jul 2016 13:45:05 +0200 Subject: Changed signatures of boolean functions (bzr r14954.1.24) --- src/object-set.h | 1 + src/splivarot.cpp | 170 +++++++++++++++++++++++-------------- src/splivarot.h | 10 ++- src/ui/tools/calligraphic-tool.cpp | 4 +- src/ui/tools/eraser-tool.cpp | 6 +- src/ui/tools/flood-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 2 +- 7 files changed, 121 insertions(+), 74 deletions(-) (limited to 'src') diff --git a/src/object-set.h b/src/object-set.h index a0bca7889..c7f1921cf 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -102,6 +102,7 @@ public: typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())) XMLNodeRange; ObjectSet(SPDesktop* desktop): _desktop(desktop) {}; + ObjectSet(): _desktop(nullptr) {}; virtual ~ObjectSet(); /** diff --git a/src/splivarot.cpp b/src/splivarot.cpp index a4c4ac6cd..54b9bff2c 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -13,7 +13,6 @@ */ #ifdef HAVE_CONFIG_H -# include #endif #include @@ -23,14 +22,11 @@ #include "xml/repr.h" #include "svg/svg.h" #include "sp-path.h" -#include "sp-shape.h" #include "sp-image.h" #include "sp-marker.h" -#include "enums.h" #include "sp-text.h" #include "sp-flowtext.h" #include "text-editing.h" -#include "sp-item-group.h" #include "style.h" #include "document.h" #include "document-undo.h" @@ -38,15 +34,9 @@ #include "message-stack.h" #include "selection.h" -#include "desktop.h" -#include "display/canvas-bpath.h" -#include "display/curve.h" #include -#include "preferences.h" -#include "xml/repr.h" #include "xml/repr-sorting.h" -#include <2geom/pathvector.h> #include <2geom/svg-path-writer.h> #include "helper/geom.h" @@ -57,65 +47,96 @@ #include "verbs.h" #include "2geom/svg-path-parser.h" // to get from SVG on boolean to Geom::Path +enum BoolOpErrors { + DONE, + DONE_NO_PATH, + DONE_NO_ACTION, + ERR_TOO_LESS_PATHS_1, + ERR_TOO_LESS_PATHS_2, + ERR_NO_PATHS, + ERR_Z_ORDER +}; + using Inkscape::DocumentUndo; bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); -void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description=""); +void sp_selected_path_boolop_ui(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, + const unsigned int verb = SP_VERB_NONE, const Glib::ustring description = ""); +BoolOpErrors sp_selected_path_boolop(Inkscape::ObjectSet *set, bool_op bop); void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset); void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating); void sp_selected_path_union(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); } void -sp_selected_path_union_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_union_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_NONE, _("Union")); + sp_selected_path_boolop(set, bool_op_union); } void sp_selected_path_intersect(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); +} + +void +sp_selected_path_intersect_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_inters); } void sp_selected_path_diff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); } void -sp_selected_path_diff_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_diff_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_NONE, _("Difference")); + sp_selected_path_boolop(set, bool_op_diff); } void sp_selected_path_symdiff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); } + +void +sp_selected_path_symdiff_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_symdiff); +} + void sp_selected_path_cut(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); } void -sp_selected_path_cut_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_cut_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_NONE, _("Division")); + sp_selected_path_boolop(set, bool_op_cut); } void sp_selected_path_slice(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); +} + +void +sp_selected_path_slice_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_slice); } // helper for printing error messages, regardless of whether we have a GUI or not @@ -331,20 +352,17 @@ Geom::PathVector pathliv_to_pathvector(Path *pathliv){ // boolean operations on the desktop // take the source paths from the file, do the operation, delete the originals and add the results -void -sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) +BoolOpErrors sp_selected_path_boolop(Inkscape::ObjectSet * set, bool_op bop) { - SPDocument *doc = selection->layers()->getDocument(); - std::vector il(selection->items().begin(), selection->items().end()); - + SPDocument *doc = set->desktop()->getDocument(); + std::vector il(set->items().begin(), set->items().end()); + // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) - if ( (il.size() < 2) && (bop != bool_op_union)) { - boolop_display_error_message(desktop, _("Select at least 2 paths to perform a boolean operation.")); - return; + if (il.size() < 2 && bop != bool_op_union) { + return ERR_TOO_LESS_PATHS_2; } - else if ( il.size() < 1 ) { - boolop_display_error_message(desktop, _("Select at least 1 path to perform a boolean union.")); - return; + else if (il.size() < 1) { + return ERR_TOO_LESS_PATHS_1; } g_assert(!il.empty()); @@ -360,8 +378,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool Inkscape::XML::Node *b = il.back()->getRepr(); if (a == NULL || b == NULL) { - boolop_display_error_message(desktop, _("Unable to determine the z-order of the objects selected for difference, XOR, division, or path cut.")); - return; + return ERR_Z_ORDER; } if (Ancetre(a, b)) { @@ -375,8 +392,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // find their lowest common ancestor Inkscape::XML::Node *parent = LCA(a, b); if (parent == NULL) { - boolop_display_error_message(desktop, _("Unable to determine the z-order of the objects selected for difference, XOR, division, or path cut.")); - return; + return ERR_Z_ORDER; } // find the children of the LCA that lead from it to the a and b @@ -405,8 +421,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SPItem *item = *l; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item)) { - boolop_display_error_message(desktop, _("One of the objects is not a path, cannot perform boolean operation.")); - return; + return ERR_NO_PATHS; } } @@ -439,7 +454,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (originaux[curOrig] == NULL || originaux[curOrig]->descr_cmd.size() <= 1) { for (int i = curOrig; i >= 0; i--) delete originaux[i]; - return; + return DONE_NO_ACTION; } curOrig++; } @@ -500,18 +515,18 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool bool zeroA = theShapeA->numberOfEdges() == 0; bool zeroB = theShapeB->numberOfEdges() == 0; if (zeroA || zeroB) { - // We might need to do a swap. Apply the above rules depending on operation type. - bool resultIsB = ((bop == bool_op_union || bop == bool_op_symdiff) && zeroA) - || ((bop == bool_op_inters) && zeroB) - || (bop == bool_op_diff); + // We might need to do a swap. Apply the above rules depending on operation type. + bool resultIsB = ((bop == bool_op_union || bop == bool_op_symdiff) && zeroA) + || ((bop == bool_op_inters) && zeroB) + || (bop == bool_op_diff); if (resultIsB) { - // Swap A and B to use B as the result + // Swap A and B to use B as the result Shape *swap = theShapeB; theShapeB = theShapeA; theShapeA = swap; } } else { - // Just do the Boolean operation as usual + // Just do the Boolean operation as usual // les elements arrivent en ordre inverse dans la liste theShape->Booleen(theShapeB, theShapeA, bop); Shape *swap = theShape; @@ -672,24 +687,23 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ (*l)->deleteObject(); } - DocumentUndo::done(doc, SP_VERB_NONE, description); - selection->clear(); + set->clear(); delete res; - return; + return DONE_NO_PATH; } // get the source path object SPObject *source; if ( bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { if (reverseOrderForOp) { - source = il[0]; + source = il[0]; } else { - source = il.back(); + source = il.back(); } } else { // find out the bottom object - std::vector sorted(selection->xmlNodes().begin(), selection->xmlNodes().end()); + std::vector sorted(set->xmlNodes().begin(), set->xmlNodes().end()); sort(sorted.begin(),sorted.end(),sp_repr_compare_position_bool); @@ -717,7 +731,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool gchar *title = source->title(); gchar *desc = source->desc(); // remove source paths - selection->clear(); + set->clear(); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ // if this is the bottommost object, if (!strcmp(reinterpret_cast(*l)->getRepr()->attribute("id"), id)) { @@ -796,7 +810,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // move to the saved position repr->setPosition(pos > 0 ? pos : 0); - selection->add(repr); + set->add(doc->getObjectByRepr(repr)); Inkscape::GC::release(repr); delete resPath[i]; @@ -824,14 +838,14 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool repr->setAttribute("id", id); parent->appendChild(repr); if (title) { - doc->getObjectByRepr(repr)->setTitle(title); - } + doc->getObjectByRepr(repr)->setTitle(title); + } if (desc) { - doc->getObjectByRepr(repr)->setDesc(desc); + doc->getObjectByRepr(repr)->setDesc(desc); } - repr->setPosition(pos > 0 ? pos : 0); + repr->setPosition(pos > 0 ? pos : 0); - selection->add(repr); + set->add(doc->getObjectByRepr(repr)); Inkscape::GC::release(repr); } @@ -839,11 +853,39 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (title) g_free(title); if (desc) g_free(desc); - if (verb != SP_VERB_NONE) { - DocumentUndo::done(doc, verb, description); - } - delete res; + + return DONE; +} + +void sp_selected_path_boolop_ui(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, + const Glib::ustring description) +{ + SPDocument *doc = selection->desktop()->getDocument(); + BoolOpErrors returnCode = sp_selected_path_boolop(selection, bop); + switch(returnCode) { + case ERR_TOO_LESS_PATHS_1: + boolop_display_error_message(desktop, _("Select at least 1 path to perform a boolean union.")); + return; + case ERR_TOO_LESS_PATHS_2: + boolop_display_error_message(desktop, _("Select at least 2 paths to perform a boolean operation.")); + return; + case ERR_NO_PATHS: + boolop_display_error_message(desktop, _("One of the objects is not a path, cannot perform boolean operation.")); + return; + case ERR_Z_ORDER: + boolop_display_error_message(desktop, _("Unable to determine the z-order of the objects selected for difference, XOR, division, or path cut.")); + return; + case DONE_NO_PATH: + DocumentUndo::done(doc, SP_VERB_NONE, description); + return; + case DONE: + DocumentUndo::done(doc, verb, description); + return; + case DONE_NO_ACTION: + default: + return; + } } static diff --git a/src/splivarot.h b/src/splivarot.h index 421c9c4b8..9b07a5a71 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -17,6 +17,7 @@ class SPItem; namespace Inkscape { class Selection; + class ObjectSet; } // boolean operations @@ -27,14 +28,17 @@ namespace Inkscape { // command-line mode, i.e. without a desktop. If a desktop is not // provided (desktop == NULL), error messages will be shown on stderr. void sp_selected_path_union (Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selected_path_union_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_union_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_intersect (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_intersect_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_diff (Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selected_path_diff_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_diff_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_symdiff (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_symdiff_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_cut (Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selected_path_cut_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_cut_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_slice (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_slice_skip_undo (Inkscape::ObjectSet *set); // offset/inset of a curve // takes the fill-rule in consideration diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 28195eb75..12dcedd21 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -930,10 +930,10 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) { if (unionize) { desktop->getSelection()->add(this->repr); - sp_selected_path_union_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_union_skip_undo(desktop->getSelection()); } else if (subtract) { desktop->getSelection()->add(this->repr); - sp_selected_path_diff_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_diff_skip_undo(desktop->getSelection()); } else { if (this->keep_selected) { desktop->getSelection()->set(this->repr); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 534123e90..8ed75fbdb 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -718,7 +718,7 @@ void EraserTool::set_to_accumulated() { Inkscape::GC::release(dup); // parent takes over selection->set(dup); if (!this->nowidth) { - sp_selected_path_union_skip_undo(selection, desktop); + sp_selected_path_union_skip_undo(selection); } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ @@ -729,9 +729,9 @@ void EraserTool::set_to_accumulated() { css = 0; } if (this->nowidth) { - sp_selected_path_cut_skip_undo(selection, desktop); + sp_selected_path_cut_skip_undo(selection); } else { - sp_selected_path_diff_skip_undo(selection, desktop); + sp_selected_path_diff_skip_undo(selection); } workDone = true; // TODO set this only if something was cut. bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 748c82717..b5a2fd871 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -456,7 +456,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto ngettext("Area filled, path with %d node created and unioned with selection.","Area filled, path with %d nodes created and unioned with selection.", SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() ); selection->add(reprobj); - sp_selected_path_union_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_union_skip_undo(desktop->getSelection()); } else { desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with %d node created.","Area filled, path with %d nodes created.", diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 5d804a9bd..a95e5aa96 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -1050,7 +1050,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, if (unionResult) { // No need to add the very first item (initialized with NULL). selection->add(unionResult); } - sp_selected_path_union_skip_undo(selection, selection->desktop()); + sp_selected_path_union_skip_undo(selection); selection->add(parent_item); Inkscape::GC::release(copy); did = true; -- cgit v1.2.3 From d31923a399f3c7cde85aae8406191e37ad877eb7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Fri, 22 Jul 2016 11:32:35 +0200 Subject: Improved spray tool, changed selection to object set (bzr r14954.1.25) --- src/object-set.h | 1 + src/ui/tools/spray-tool.cpp | 54 +++++++++++++++++++++------------------------ src/ui/tools/spray-tool.h | 9 +++++++- 3 files changed, 34 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/object-set.h b/src/object-set.h index c7f1921cf..b4178bd37 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -121,6 +121,7 @@ public: for(auto it = from; it != to; ++it) { _add(*it); } + _emitSignals(); } /** diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index a95e5aa96..49ff50428 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -13,6 +13,7 @@ * Jon A. Cruz * Abhishek Sharma * Jabiertxo Arraiza + * Adrian Boguszewski * * Copyright (C) 2009 authors * @@ -196,6 +197,7 @@ SprayTool::SprayTool() } SprayTool::~SprayTool() { + object_set.clear(); this->enableGrDrag(false); this->style_set_connection.disconnect(); @@ -862,7 +864,7 @@ static bool fit_item(SPDesktop *desktop, } static bool sp_spray_recursive(SPDesktop *desktop, - Inkscape::Selection *selection, + Inkscape::ObjectSet *set, SPItem *item, Geom::Point p, Geom::Point /*vector*/, @@ -907,7 +909,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, if (box) { // convert 3D boxes to ordinary groups before spraying their shapes item = box3d_convert_to_group(box); - selection->add(item); + set->add(item); } } @@ -996,23 +998,11 @@ static bool sp_spray_recursive(SPDesktop *desktop, } #ifdef ENABLE_SPRAY_MODE_SINGLE_PATH } else if (mode == SPRAY_MODE_SINGLE_PATH) { + long setSize = boost::distance(set->items()); + SPItem *parent_item = setSize > 0 ? set->items().front() : nullptr; // Initial object + SPItem *unionResult = setSize > 1 ? *(++set->items().begin()) : nullptr; // Previous union + SPItem *item_copied = nullptr; // Projected object - SPItem *parent_item = NULL; // Initial object - SPItem *item_copied = NULL; // Projected object - SPItem *unionResult = NULL; // Previous union - - int i=1; - auto items= selection->items(); - for(auto it=items.begin();it!=items.end(); ++it){ - SPItem *item1 = *it; - if (i == 1) { - parent_item = item1; - } - if (i == 2) { - unionResult = item1; - } - i++; - } if (parent_item) { SPDocument *doc = parent_item->document; Inkscape::XML::Document* xml_doc = doc->getReprDoc(); @@ -1045,13 +1035,13 @@ static bool sp_spray_recursive(SPDesktop *desktop, sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); // Union and duplication - selection->clear(); - selection->add(item_copied); + set->clear(); + set->add(item_copied); if (unionResult) { // No need to add the very first item (initialized with NULL). - selection->add(unionResult); + set->add(unionResult); } - sp_selected_path_union_skip_undo(selection); - selection->add(parent_item); + sp_selected_path_union_skip_undo(set); + set->add(parent_item); Inkscape::GC::release(copy); did = true; } @@ -1146,9 +1136,8 @@ static bool sp_spray_recursive(SPDesktop *desktop, static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) { SPDesktop *desktop = tc->desktop; - Inkscape::Selection *selection = desktop->getSelection(); - - if (selection->isEmpty()) { + Inkscape::ObjectSet *set = tc->objectSet(); + if (set->isEmpty()) { return false; } @@ -1170,7 +1159,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - std::vector const items(selection->items().begin(), selection->items().end()); + std::vector const items(set->items().begin(), set->items().end()); for(std::vector::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1182,7 +1171,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point SPItem *item = *i; g_assert(item != NULL); if (sp_spray_recursive(desktop - , selection + , set , item , p, vector , tc->mode @@ -1276,6 +1265,11 @@ bool SprayTool::root_handler(GdkEvent* event) { this->is_dilating = true; this->has_dilated = false; + object_set = *desktop->getSelection(); + if (mode == SPRAY_MODE_SINGLE_PATH) { + desktop->getSelection()->clear(); + } + if(this->is_dilating && event->button.button == 1 && !this->space_panning) { sp_spray_dilate(this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } @@ -1299,7 +1293,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = boost::distance(desktop->selection->items() ); + num = (guint) boost::distance(desktop->selection->items()); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); @@ -1384,6 +1378,8 @@ bool SprayTool::root_handler(GdkEvent* event) { SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); break; case SPRAY_MODE_SINGLE_PATH: + sp_selected_path_union_skip_undo(objectSet()); + desktop->getSelection()->add(object_set.objects().begin(), object_set.objects().end()); DocumentUndo::done(this->desktop->getDocument(), SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); break; diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h index c81110b37..d5504d565 100644 --- a/src/ui/tools/spray-tool.h +++ b/src/ui/tools/spray-tool.h @@ -13,6 +13,7 @@ * Vincent MONTAGNE * Pierre BARBRY-BLOT * Jabiertxo ARRAIZA + * Adrian Boguszewski * * Copyright (C) 2009 authors * @@ -120,8 +121,14 @@ public: virtual const std::string& getPrefsPath(); - void update_cursor(bool /*with_shift*/); + + ObjectSet* objectSet() { + return &object_set; + } + +private: + ObjectSet object_set; }; } -- cgit v1.2.3 From 300d24dedddefb2f68ebd680fcd2234bfca53ad7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Mon, 25 Jul 2016 22:16:54 +0200 Subject: Changed coding style (bzr r14954.1.27) --- src/object-set.cpp | 47 ++++++++++++++++++++++++++++------------------- src/object-set.h | 25 ++++++++++++++++++------- src/selection-chemistry.h | 2 +- 3 files changed, 47 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/object-set.cpp b/src/object-set.cpp index 1b994106a..92bcf6b07 100644 --- a/src/object-set.cpp +++ b/src/object-set.cpp @@ -24,7 +24,6 @@ bool ObjectSet::add(SPObject* object) { g_return_val_if_fail(object != NULL, false); g_return_val_if_fail(SP_IS_OBJECT(object), false); - // any ancestor is in the set - do nothing if (_anyAncestorIsInSet(object)) { return false; @@ -68,7 +67,7 @@ bool ObjectSet::includes(SPObject *object) { g_return_val_if_fail(object != NULL, false); g_return_val_if_fail(SP_IS_OBJECT(object), false); - return container.get().find(object) != container.get().end(); + return _container.get().find(object) != _container.get().end(); } void ObjectSet::clear() { @@ -77,7 +76,7 @@ void ObjectSet::clear() { } int ObjectSet::size() { - return container.size(); + return _container.size(); } bool ObjectSet::_anyAncestorIsInSet(SPObject *object) { @@ -105,22 +104,22 @@ void ObjectSet::_removeDescendantsFromSet(SPObject *object) { } void ObjectSet::_remove(SPObject *object) { - releaseConnections[object].disconnect(); - releaseConnections.erase(object); - container.get().erase(object); - _remove_3D_boxes_recursively(object); + _releaseConnections[object].disconnect(); + _releaseConnections.erase(object); + _container.get().erase(object); + _remove3DBoxesRecursively(object); _releaseSignals(object); } void ObjectSet::_add(SPObject *object) { - releaseConnections[object] = object->connectRelease(sigc::hide_return(sigc::mem_fun(*this, &ObjectSet::remove))); - container.push_back(object); - _add_3D_boxes_recursively(object); + _releaseConnections[object] = object->connectRelease(sigc::hide_return(sigc::mem_fun(*this, &ObjectSet::remove))); + _container.push_back(object); + _add3DBoxesRecursively(object); _connectSignals(object); } void ObjectSet::_clear() { - for (auto object: container) { + for (auto object: _container) { _remove(object); } } @@ -173,16 +172,16 @@ void ObjectSet::toggle(SPObject *obj) { } bool ObjectSet::isEmpty() { - return container.size() == 0; + return _container.size() == 0; } SPObject *ObjectSet::single() { - return container.size() == 1 ? *container.begin() : nullptr; + return _container.size() == 1 ? *_container.begin() : nullptr; } SPItem *ObjectSet::singleItem() { - if (container.size() == 1) { - SPObject* obj = *container.begin(); + if (_container.size() == 1) { + SPObject* obj = *_container.begin(); if (SP_IS_ITEM(obj)) { return SP_ITEM(obj); } @@ -225,7 +224,7 @@ SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { } SPObjectRange ObjectSet::objects() { - return SPObjectRange(container.get().begin(), container.get().end()); + return SPObjectRange(_container.get().begin(), _container.get().end()); } Inkscape::XML::Node *ObjectSet::singleRepr() { @@ -309,7 +308,6 @@ boost::optional ObjectSet::center() const { } } - std::list const ObjectSet::perspList() { std::list pl; for (std::list::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { @@ -335,7 +333,7 @@ std::list const ObjectSet::box3DList(Persp3D *persp) { return boxes; } -void ObjectSet::_add_3D_boxes_recursively(SPObject *obj) { +void ObjectSet::_add3DBoxesRecursively(SPObject *obj) { std::list boxes = box3d_extract_boxes(obj); for (std::list::iterator i = boxes.begin(); i != boxes.end(); ++i) { @@ -344,7 +342,7 @@ void ObjectSet::_add_3D_boxes_recursively(SPObject *obj) { } } -void ObjectSet::_remove_3D_boxes_recursively(SPObject *obj) { +void ObjectSet::_remove3DBoxesRecursively(SPObject *obj) { std::list boxes = box3d_extract_boxes(obj); for (std::list::iterator i = boxes.begin(); i != boxes.end(); ++i) { @@ -359,3 +357,14 @@ void ObjectSet::_remove_3D_boxes_recursively(SPObject *obj) { } } // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/object-set.h b/src/object-set.h index b4178bd37..2772afbe2 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -198,21 +198,21 @@ public: /** Returns a range of selected SPItems. */ SPItemRange items() { - return SPItemRange(container.get() + return SPItemRange(_container.get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_item())); }; /** Returns a range of selected groups. */ SPGroupRange groups() { - return SPGroupRange (container.get() + return SPGroupRange (_container.get() | boost::adaptors::filtered(is_group()) | boost::adaptors::transformed(object_to_group())); } /** Returns a range of the xml nodes of all selected objects. */ XMLNodeRange xmlNodes() { - return XMLNodeRange(container.get() + return XMLNodeRange(_container.get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())); } @@ -299,13 +299,13 @@ protected: void _removeAncestorsFromSet(SPObject *object); SPItem *_sizeistItem(bool sml, CompareSize compare); SPObject *_getMutualAncestor(SPObject *object); - virtual void _add_3D_boxes_recursively(SPObject *obj); - virtual void _remove_3D_boxes_recursively(SPObject *obj); + virtual void _add3DBoxesRecursively(SPObject *obj); + virtual void _remove3DBoxesRecursively(SPObject *obj); - multi_index_container container; + multi_index_container _container; GC::soft_ptr _desktop; std::list _3dboxes; - std::unordered_map releaseConnections; + std::unordered_map _releaseConnections; }; @@ -316,3 +316,14 @@ typedef ObjectSet::XMLNodeRange XMLNodeRange; } // namespace Inkscape #endif //INKSCAPE_PROTOTYPE_OBJECTSET_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index cfae84eef..f6cd4829a 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -109,7 +109,7 @@ void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false ) void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false ); void sp_selection_to_layer( SPDesktop *desktop, SPObject *layer, bool suppressDone = false ); -void sp_selection_apply_affine(Inkscape::ObjectSet *selection, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true, bool adjust_transf_center = true); +void sp_selection_apply_affine(Inkscape::ObjectSet *set, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true, bool adjust_transf_center = true); void sp_selection_remove_transform (SPDesktop *desktop); void sp_selection_scale_absolute (Inkscape::ObjectSet *set, double x0, double x1, double y0, double y1); void sp_selection_scale_relative(Inkscape::ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale); -- cgit v1.2.3 From ff4fbbc93f67afd6cbf851691833a50d6c76b350 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 27 Jul 2016 12:19:03 +0200 Subject: Renamed some functions, fixed tests (bzr r14954.1.28) --- src/file.cpp | 10 ++--- src/object-set.h | 10 ++--- src/selection-chemistry.cpp | 97 ++++++++++++++++++++-------------------- src/selection-chemistry.h | 39 ++++++++-------- src/seltrans.cpp | 2 +- src/sp-object.cpp | 3 ++ src/ui/clipboard.cpp | 4 +- src/ui/dialog/export.cpp | 2 +- src/ui/dialog/transformation.cpp | 22 ++++----- src/ui/interface.cpp | 4 +- src/verbs.cpp | 18 ++++---- src/widgets/select-toolbar.cpp | 2 +- 12 files changed, 109 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/file.cpp b/src/file.cpp index 9ba180cb4..8743e3b67 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1129,14 +1129,14 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) Inkscape::Selection *selection = desktop->getSelection(); selection->setReprList(pasted_objects_not); Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); sp_selection_delete(desktop); // Change the selection to the freshly pasted objects selection->setReprList(pasted_objects); // Apply inverse of parent transform - sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); // Update (among other things) all curves in paths, for bounds() to work target_document->ensureUpToDate(); @@ -1166,7 +1166,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) m.unSetup(); } - sp_selection_move_relative(selection, offset); + sp_object_set_move_relative(selection, offset); } } @@ -1271,7 +1271,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // c2p is identity matrix at this point unless ensureUpToDate is called doc->ensureUpToDate(); Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); // move to mouse pointer { @@ -1279,7 +1279,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); - sp_selection_move_relative(selection, m, false); + sp_object_set_move_relative(selection, m, false); } } } diff --git a/src/object-set.h b/src/object-set.h index 2772afbe2..fae365f70 100644 --- a/src/object-set.h +++ b/src/object-set.h @@ -86,7 +86,7 @@ typedef boost::multi_index_container< boost::multi_index::hashed_unique< boost::multi_index::tag, boost::multi_index::identity> - >> multi_index_container; + >> MultiIndexContainer; typedef boost::any_range< SPObject*, @@ -97,9 +97,9 @@ typedef boost::any_range< class ObjectSet { public: enum CompareSize {HORIZONTAL, VERTICAL, AREA}; - typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_item())) SPItemRange; - typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_group()) | boost::adaptors::transformed(object_to_group())) SPGroupRange; - typedef decltype(multi_index_container().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())) XMLNodeRange; + typedef decltype(MultiIndexContainer().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_item())) SPItemRange; + typedef decltype(MultiIndexContainer().get() | boost::adaptors::filtered(is_group()) | boost::adaptors::transformed(object_to_group())) SPGroupRange; + typedef decltype(MultiIndexContainer().get() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())) XMLNodeRange; ObjectSet(SPDesktop* desktop): _desktop(desktop) {}; ObjectSet(): _desktop(nullptr) {}; @@ -302,7 +302,7 @@ protected: virtual void _add3DBoxesRecursively(SPObject *obj); virtual void _remove3DBoxesRecursively(SPObject *obj); - multi_index_container _container; + MultiIndexContainer _container; GC::soft_ptr _desktop; std::list _3dboxes; std::unordered_map _releaseConnections; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index e8c408ed8..cd0a29b05 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -694,7 +694,7 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop) sp_edit_select_all_full(desktop, true, true); } -static Inkscape::XML::Node* sp_selection_group(ObjectSet *set) { +static Inkscape::XML::Node* sp_object_set_group(ObjectSet *set) { SPDocument *doc = set->desktop()->getDocument(); Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); @@ -764,14 +764,14 @@ static Inkscape::XML::Node* sp_selection_group(ObjectSet *set) { return group; } -void sp_selection_group_ui(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) { // Check if something is selected. if (selection->isEmpty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select some objects to group.")); return; } - Inkscape::XML::Node* group = sp_selection_group(selection); + Inkscape::XML::Node* group = sp_object_set_group(selection); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_GROUP, C_("Verb", "Group")); @@ -823,7 +823,7 @@ void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDeskto } -static void sp_selection_ungroup(ObjectSet *set) +static void sp_object_set_ungroup(ObjectSet *set) { GSList *groups = NULL; for (auto g: set->groups()) { @@ -882,7 +882,7 @@ static void sp_selection_ungroup(ObjectSet *set) set->setList(new_select); } -void sp_selection_ungroup_ui(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) { if (selection->isEmpty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a group to ungroup.")); @@ -893,7 +893,7 @@ void sp_selection_ungroup_ui(Inkscape::Selection *selection, SPDesktop *desktop) return; } - sp_selection_ungroup(selection); + sp_object_set_ungroup(selection); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); @@ -978,7 +978,7 @@ bool sp_item_repr_compare_position_bool(SPObject const *first, SPObject const *s ((SPItem*)second)->getRepr())<0; } -void sp_selection_raise(ObjectSet* set) { +void sp_object_set_raise(ObjectSet *set) { std::vector items(set->items().begin(), set->items().end()); Inkscape::XML::Node *grepr = const_cast(items.front()->parent->getRepr()); @@ -1013,7 +1013,7 @@ void sp_selection_raise(ObjectSet* set) { } } -void sp_selection_raise_ui(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { if (selection->items().empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise.")); @@ -1025,14 +1025,14 @@ void sp_selection_raise_ui(Inkscape::Selection *selection, SPDesktop *desktop) selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from different groups or layers.")); return; } - sp_selection_raise(selection); + sp_object_set_raise(selection); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, //TRANSLATORS: "Raise" means "to raise an object" in the undo history C_("Undo action", "Raise")); } -void sp_selection_raise_to_top(ObjectSet* set) { +void sp_object_set_raise_to_top(ObjectSet *set) { std::vector rl(set->xmlNodes().begin(), set->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); @@ -1042,7 +1042,7 @@ void sp_selection_raise_to_top(ObjectSet* set) { } } -void sp_selection_raise_to_top_ui(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop) { SPDocument *document = selection->layers()->getDocument(); @@ -1057,13 +1057,13 @@ void sp_selection_raise_to_top_ui(Inkscape::Selection *selection, SPDesktop *des return; } - sp_selection_raise_to_top(selection); + sp_object_set_raise_to_top(selection); DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, _("Raise to top")); } -void sp_selection_lower(ObjectSet *set) { +void sp_object_set_lower(ObjectSet *set) { std::vector items(set->items().begin(), set->items().end()); Inkscape::XML::Node *grepr = const_cast(items.front()->parent->getRepr()); @@ -1102,7 +1102,7 @@ void sp_selection_lower(ObjectSet *set) { } } -void sp_selection_lower_ui(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { if (selection->items().empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower.")); @@ -1115,14 +1115,14 @@ void sp_selection_lower_ui(Inkscape::Selection *selection, SPDesktop *desktop) return; } - sp_selection_lower(selection); + sp_object_set_lower(selection); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, //TRANSLATORS: "Lower" means "to lower an object" in the undo history C_("Undo action", "Lower")); } -void sp_selection_lower_to_bottom(ObjectSet *set) { +void sp_object_set_lower_to_bottom(ObjectSet *set) { std::vector rl(set->xmlNodes().begin(), set->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); @@ -1143,7 +1143,7 @@ void sp_selection_lower_to_bottom(ObjectSet *set) { } } -void sp_selection_lower_to_bottom_ui(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop) { if (selection->isEmpty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower to bottom.")); @@ -1156,7 +1156,7 @@ void sp_selection_lower_to_bottom_ui(Inkscape::Selection *selection, SPDesktop * return; } - sp_selection_lower_to_bottom(selection); + sp_object_set_lower_to_bottom(selection); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_TO_BACK, _("Lower to bottom")); @@ -1484,7 +1484,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) } static bool -selection_contains_original(SPItem *item, ObjectSet* set) +object_set_contains_original(SPItem *item, ObjectSet *set) { bool contains_original = false; @@ -1512,14 +1512,14 @@ selection_contains_original(SPItem *item, ObjectSet* set) static bool -selection_contains_both_clone_and_original(ObjectSet *set) +object_set_contains_both_clone_and_original(ObjectSet *set) { bool clone_with_original = false; auto items = set->items(); for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if (item) { - clone_with_original |= selection_contains_original(item, set); + clone_with_original |= object_set_contains_original(item, set); if (clone_with_original) break; } @@ -1533,7 +1533,8 @@ value of set_i2d==false is only used by seltrans when it's dragging objects live that case, items are already in the new position, but the repr is in the old, and this function then simply updates the repr from item->transform. */ -void sp_selection_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool set_i2d, bool compensate, bool adjust_transf_center) +void sp_object_set_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool set_i2d, bool compensate, + bool adjust_transf_center) { if (set->isEmpty()) return; @@ -1581,7 +1582,7 @@ void sp_selection_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool #endif // we're moving both a clone and its original or any ancestor in clone chain? - bool transform_clone_with_original = selection_contains_original(item, set); + bool transform_clone_with_original = object_set_contains_original(item, set); // ...both a text-on-path and its path? bool transform_textpath_with_path = ((dynamic_cast(item) && item->firstChild() && dynamic_cast(item->firstChild())) @@ -1724,7 +1725,7 @@ void sp_selection_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool } } -void sp_selection_remove_transform(SPDesktop *desktop) +void sp_object_set_remove_transform(SPDesktop *desktop) { if (desktop == NULL) return; @@ -1741,9 +1742,9 @@ void sp_selection_remove_transform(SPDesktop *desktop) } void -sp_selection_scale_absolute(ObjectSet *set, - double const x0, double const x1, - double const y0, double const y1) +sp_object_set_scale_absolute(ObjectSet *set, + double x0, double x1, + double y0, double y1) { if (set->isEmpty()) return; @@ -1761,11 +1762,11 @@ sp_selection_scale_absolute(ObjectSet *set, Geom::Translate const o2n(x0, y0); Geom::Affine const final( p2o * scale * o2n ); - sp_selection_apply_affine(set, final); + sp_object_set_apply_affine(set, final); } -void sp_selection_scale_relative(ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale) +void sp_object_set_scale_relative(ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale) { if (set->isEmpty()) return; @@ -1786,21 +1787,21 @@ void sp_selection_scale_relative(ObjectSet *set, Geom::Point const &align, Geom: Geom::Translate const n2d(-align); Geom::Translate const d2n(align); Geom::Affine const final( n2d * scale * d2n ); - sp_selection_apply_affine(set, final); + sp_object_set_apply_affine(set, final); } void -sp_selection_rotate_relative(ObjectSet *set, Geom::Point const ¢er, gdouble const angle_degrees) +sp_object_set_rotate_relative(ObjectSet *set, Geom::Point const ¢er, double angle_degrees) { Geom::Translate const d2n(center); Geom::Translate const n2d(-center); Geom::Rotate const rotate(Geom::Rotate::from_degrees(angle_degrees)); Geom::Affine const final( Geom::Affine(n2d) * rotate * d2n ); - sp_selection_apply_affine(set, final); + sp_object_set_apply_affine(set, final); } void -sp_selection_skew_relative(ObjectSet *set, Geom::Point const &align, double dx, double dy) +sp_object_set_skew_relative(ObjectSet *set, Geom::Point const &align, double dx, double dy) { Geom::Translate const d2n(align); Geom::Translate const n2d(-align); @@ -1808,17 +1809,17 @@ sp_selection_skew_relative(ObjectSet *set, Geom::Point const &align, double dx, dx, 1, 0, 0); Geom::Affine const final( n2d * skew * d2n ); - sp_selection_apply_affine(set, final); + sp_object_set_apply_affine(set, final); } -void sp_selection_move_relative(ObjectSet *set, Geom::Point const &move, bool compensate) +void sp_object_set_move_relative(ObjectSet *set, Geom::Point const &move, bool compensate) { - sp_selection_apply_affine(set, Geom::Affine(Geom::Translate(move)), true, compensate); + sp_object_set_apply_affine(set, Geom::Affine(Geom::Translate(move)), true, compensate); } -void sp_selection_move_relative(ObjectSet *set, double dx, double dy) +void sp_object_set_move_relative(ObjectSet *set, double dx, double dy) { - sp_selection_apply_affine(set, Geom::Affine(Geom::Translate(dx, dy))); + sp_object_set_apply_affine(set, Geom::Affine(Geom::Translate(dx, dy))); } /** @@ -1858,7 +1859,7 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees) return; } - sp_selection_rotate_relative(selection, *center, angle_degrees); + sp_object_set_rotate_relative(selection, *center, angle_degrees); DocumentUndo::maybeDone(selection->desktop()->getDocument(), ( ( angle_degrees > 0 ) @@ -2207,7 +2208,7 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle) gdouble const zangle = 180 * atan2(zmove, r) / M_PI; - sp_selection_rotate_relative(selection, *center, zangle); + sp_object_set_rotate_relative(selection, *center, zangle); DocumentUndo::maybeDone(selection->desktop()->getDocument(), ( (angle > 0) @@ -2237,7 +2238,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow) } double const times = 1.0 + grow / max_len; - sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); + sp_object_set_scale_relative(selection, center, Geom::Scale(times, times)); DocumentUndo::maybeDone(selection->desktop()->getDocument(), ( (grow > 0) @@ -2266,7 +2267,7 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times) } Geom::Point const center(sel_bbox->midpoint()); - sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); + sp_object_set_scale_relative(selection, center, Geom::Scale(times, times)); DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_CONTEXT_SELECT, _("Scale by whole factor")); } @@ -2278,7 +2279,7 @@ sp_selection_move(Inkscape::Selection *selection, gdouble dx, gdouble dy) return; } - sp_selection_move_relative(selection, dx, dy); + sp_object_set_move_relative(selection, dx, dy); SPDocument *doc = selection->layers()->getDocument(); if (dx == 0) { @@ -2304,7 +2305,7 @@ sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy) gdouble const zoom = selection->desktop()->current_zoom(); gdouble const zdx = dx / zoom; gdouble const zdy = dy / zoom; - sp_selection_move_relative(selection, zdx, zdy); + sp_object_set_move_relative(selection, zdx, zdy); SPDocument *doc = selection->layers()->getDocument(); if (dx == 0) { @@ -3476,7 +3477,7 @@ void sp_selection_untile(SPDesktop *desktop) } } -void sp_selection_get_export_hints(ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi) +void sp_object_set_get_export_hints(ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi) { if (set->isEmpty()) { return; @@ -3627,7 +3628,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) float hint_xdpi = 0, hint_ydpi = 0; Glib::ustring hint_filename; // take resolution hint from the selected objects - sp_selection_get_export_hints(selection, hint_filename, &hint_xdpi, &hint_ydpi); + sp_object_set_get_export_hints(selection, hint_filename, &hint_xdpi, &hint_ydpi); if (hint_xdpi != 0) { res = hint_xdpi; } else { @@ -3892,7 +3893,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // FIXME: temporary patch to prevent crash! // Remove this when bboxes are fixed to not blow up on an item clipped/masked with its own clone - bool clone_with_original = selection_contains_both_clone_and_original(selection); + bool clone_with_original = object_set_contains_both_clone_and_original(selection); if (clone_with_original) { return; // in this version, you cannot clip/mask an object with its own clone } @@ -3957,7 +3958,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_select.clear(); - Inkscape::XML::Node *group = sp_selection_group(set); + Inkscape::XML::Node *group = sp_object_set_group(set); group->setAttribute("inkscape:groupmode", "maskhelper"); // apply clip/mask only to newly created group diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index f6cd4829a..ca9062320 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -75,19 +75,19 @@ void sp_selection_unsymbol(SPDesktop *desktop); void sp_selection_tile(SPDesktop *desktop, bool apply = true); void sp_selection_untile(SPDesktop *desktop); -void sp_selection_group_ui(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_ungroup_ui(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_raise(Inkscape::ObjectSet* set); -void sp_selection_raise_to_top(Inkscape::ObjectSet* set); -void sp_selection_lower(Inkscape::ObjectSet *set); -void sp_selection_lower_to_bottom(Inkscape::ObjectSet *set); +void sp_object_set_raise(Inkscape::ObjectSet *set); +void sp_object_set_raise_to_top(Inkscape::ObjectSet *set); +void sp_object_set_lower(Inkscape::ObjectSet *set); +void sp_object_set_lower_to_bottom(Inkscape::ObjectSet *set); -void sp_selection_raise_ui(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_raise_to_top_ui(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_lower_ui(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_lower_to_bottom_ui(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop); SPCSSAttr *take_style_from_item (SPObject *object); @@ -109,14 +109,15 @@ void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false ) void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false ); void sp_selection_to_layer( SPDesktop *desktop, SPObject *layer, bool suppressDone = false ); -void sp_selection_apply_affine(Inkscape::ObjectSet *set, Geom::Affine const &affine, bool set_i2d = true, bool compensate = true, bool adjust_transf_center = true); -void sp_selection_remove_transform (SPDesktop *desktop); -void sp_selection_scale_absolute (Inkscape::ObjectSet *set, double x0, double x1, double y0, double y1); -void sp_selection_scale_relative(Inkscape::ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale); -void sp_selection_rotate_relative (Inkscape::ObjectSet *set, Geom::Point const ¢er, double angle); -void sp_selection_skew_relative (Inkscape::ObjectSet *set, Geom::Point const &align, double dx, double dy); -void sp_selection_move_relative (Inkscape::ObjectSet *set, Geom::Point const &move, bool compensate = true); -void sp_selection_move_relative (Inkscape::ObjectSet *set, double dx, double dy); +void sp_object_set_apply_affine(Inkscape::ObjectSet *set, Geom::Affine const &affine, bool set_i2d = true, + bool compensate = true, bool adjust_transf_center = true); +void sp_object_set_remove_transform(SPDesktop *desktop); +void sp_object_set_scale_absolute(Inkscape::ObjectSet *set, double x0, double x1, double y0, double y1); +void sp_object_set_scale_relative(Inkscape::ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale); +void sp_object_set_rotate_relative(Inkscape::ObjectSet *set, Geom::Point const ¢er, double angle); +void sp_object_set_skew_relative(Inkscape::ObjectSet *set, Geom::Point const &align, double dx, double dy); +void sp_object_set_move_relative(Inkscape::ObjectSet *set, Geom::Point const &move, bool compensate = true); +void sp_object_set_move_relative(Inkscape::ObjectSet *set, double dx, double dy); void sp_selection_rotate_90 (SPDesktop *desktop, bool ccw); void sp_selection_rotate (Inkscape::Selection *selection, double angle); @@ -157,7 +158,7 @@ void scroll_to_show_item(SPDesktop *desktop, SPItem *item); void sp_undo (SPDesktop *desktop, SPDocument *doc); void sp_redo (SPDesktop *desktop, SPDocument *doc); -void sp_selection_get_export_hints (Inkscape::ObjectSet* set, Glib::ustring &filename, float *xdpi, float *ydpi); +void sp_object_set_get_export_hints(Inkscape::ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi); void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, float *xdpi, float *ydpi); void sp_selection_create_bitmap_copy (SPDesktop *desktop); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index f6cb9166c..3054913b6 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -445,7 +445,7 @@ void Inkscape::SelTrans::ungrab() if (!_current_relative_affine.isIdentity()) { // we can have a identity affine // when trying to stretch a perfectly vertical line in horizontal direction, which will not be allowed by the handles; - sp_selection_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE)? true : false); + sp_object_set_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE) ? true : false); if (_center) { *_center *= _current_relative_affine; _center_is_set = true; diff --git a/src/sp-object.cpp b/src/sp-object.cpp index ccd70f4cb..27c788d75 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -151,6 +151,9 @@ SPObject::~SPObject() { sp_object_unref(this->_successor, NULL); this->_successor = NULL; } + if (parent) { + parent->children.erase(parent->children.iterator_to(*this)); + } if( style == NULL ) { // style pointer could be NULL if unreffed too many times. diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index b25a70b15..504a5e2ce 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -539,8 +539,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a else { Geom::OptRect sel_size = selection->visualBounds(); if ( sel_size ) { - sp_selection_scale_relative(selection, sel_size->midpoint(), - _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); + sp_object_set_scale_relative(selection, sel_size->midpoint(), + _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); } } pasted = true; diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 4ab007408..08fc25464 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -814,7 +814,7 @@ void Export::onAreaToggled () case SELECTION_SELECTION: if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) { - sp_selection_get_export_hints (SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi); + sp_object_set_get_export_hints(SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi); /* If we still don't have a filename -- let's build one that's nice */ diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index d4a0ffd68..d82b5ded3 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -723,12 +723,12 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (!prefs->getBool("/dialogs/transformation/applyseparately")) { // move selection as a whole if (_check_move_relative.get_active()) { - sp_selection_move_relative(selection, x, y); + sp_object_set_move_relative(selection, x, y); } else { Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { - sp_selection_move_relative(selection, - x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); + sp_object_set_move_relative(selection, + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } else { @@ -791,8 +791,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } else { Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { - sp_selection_move_relative(selection, - x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); + sp_object_set_move_relative(selection, + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } @@ -856,7 +856,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); - sp_selection_apply_affine(selection, scaler); + sp_object_set_apply_affine(selection, scaler); } } @@ -882,7 +882,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } else { boost::optional center = selection->center(); if (center) { - sp_selection_rotate_relative(selection, *center, angle); + sp_object_set_rotate_relative(selection, *center, angle); } } @@ -949,7 +949,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, not used.")); return; } - sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY); + sp_object_set_skew_relative(selection, *center, 0.01 * skewX, 0.01 * skewY); } else if (_units_skew.isRadial()) { //deg or rad double angleX = _scalar_skew_horizontal.getValue("rad"); double angleY = _scalar_skew_vertical.getValue("rad"); @@ -962,7 +962,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) } double skewX = tan(-angleX); double skewY = tan(angleY); - sp_selection_skew_relative(selection, *center, skewX, skewY); + sp_object_set_skew_relative(selection, *center, skewX, skewY); } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); @@ -970,7 +970,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, not used.")); return; } - sp_selection_skew_relative(selection, *center, skewX/height, skewY/width); + sp_object_set_skew_relative(selection, *center, skewX / height, skewY / width); } } } @@ -1003,7 +1003,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) item->updateRepr(); } } else { - sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform + sp_object_set_apply_affine(selection, displayed); // post-multiply each object's transform } DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM, diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index d19526105..eb3034ca3 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1250,7 +1250,7 @@ sp_ui_drag_data_received(GtkWidget *widget, Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); - sp_selection_move_relative(selection, m, false); + sp_object_set_move_relative(selection, m, false); } } @@ -1916,7 +1916,7 @@ void ContextMenu::MakeGroupMenu(void) void ContextMenu::ActivateGroup(void) { - sp_selection_group_ui(_desktop->selection, _desktop); + sp_selection_group(_desktop->selection, _desktop); } void ContextMenu::ActivateUngroup(void) diff --git a/src/verbs.cpp b/src/verbs.cpp index 8255ea1ea..d6c239e86 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1133,22 +1133,22 @@ void SelectionVerb::perform(SPAction *action, void *data) sp_selected_path_slice(selection, dt); break; case SP_VERB_SELECTION_TO_FRONT: - sp_selection_raise_to_top_ui(selection, dt); + sp_selection_raise_to_top(selection, dt); break; case SP_VERB_SELECTION_TO_BACK: - sp_selection_lower_to_bottom_ui(selection, dt); + sp_selection_lower_to_bottom(selection, dt); break; case SP_VERB_SELECTION_RAISE: - sp_selection_raise_ui(selection, dt); + sp_selection_raise(selection, dt); break; case SP_VERB_SELECTION_LOWER: - sp_selection_lower_ui(selection, dt); + sp_selection_lower(selection, dt); break; case SP_VERB_SELECTION_GROUP: - sp_selection_group_ui(selection, dt); + sp_selection_group(selection, dt); break; case SP_VERB_SELECTION_UNGROUP: - sp_selection_ungroup_ui(selection, dt); + sp_selection_ungroup(selection, dt); break; case SP_VERB_SELECTION_UNGROUP_POP_SELECTION: sp_selection_ungroup_pop_selection(selection, dt); @@ -1520,7 +1520,7 @@ void ObjectVerb::perform( SPAction *action, void *data) sp_selection_rotate_90(dt, true); break; case SP_VERB_OBJECT_FLATTEN: - sp_selection_remove_transform(dt); + sp_object_set_remove_transform(dt); break; case SP_VERB_OBJECT_FLOW_TEXT: text_flow_into_shape(); @@ -1532,12 +1532,12 @@ void ObjectVerb::perform( SPAction *action, void *data) flowtext_to_text(); break; case SP_VERB_OBJECT_FLIP_HORIZONTAL: - sp_selection_scale_relative(sel, center, Geom::Scale(-1.0, 1.0)); + sp_object_set_scale_relative(sel, center, Geom::Scale(-1.0, 1.0)); DocumentUndo::done(dt->getDocument(), SP_VERB_OBJECT_FLIP_HORIZONTAL, _("Flip horizontally")); break; case SP_VERB_OBJECT_FLIP_VERTICAL: - sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0)); + sp_object_set_scale_relative(sel, center, Geom::Scale(1.0, -1.0)); DocumentUndo::done(dt->getDocument(), SP_VERB_OBJECT_FLIP_VERTICAL, _("Flip vertically")); break; diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 9851b0606..322c33cc3 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -257,7 +257,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, GObject *tbl) scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, 0, false, false, x0, y0, x1, y1); } - sp_selection_apply_affine(selection, scaler); + sp_object_set_apply_affine(selection, scaler); DocumentUndo::maybeDone(document, actionkey, SP_VERB_CONTEXT_SELECT, _("Transform by toolbar")); -- cgit v1.2.3