From a7f2b2ba3f13ceb60376802f4a31e104153839e8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 17 Feb 2015 03:00:37 +0100 Subject: At first, I was thinking "I just have to go to the selection file, and change that GSList* with a std::list, then resolve the few problems" So, i tried that. And I will continue tomorrow, and the days after, on and on. (bzr r13922.1.1) --- src/conn-avoid-ref.cpp | 5 +- src/desktop-style.cpp | 120 ++-- src/desktop-style.h | 25 +- src/extension/execution-env.cpp | 8 +- src/extension/implementation/implementation.cpp | 7 +- src/extension/implementation/script.cpp | 7 +- src/extension/internal/bitmap/imagemagick.cpp | 16 +- src/extension/internal/bluredge.cpp | 7 +- src/extension/internal/cairo-renderer.cpp | 8 +- src/extension/internal/filter/filter.cpp | 8 +- src/extension/internal/grid.cpp | 7 +- src/extension/internal/latex-text-renderer.cpp | 8 +- src/file.cpp | 6 +- src/filter-chemistry.cpp | 2 +- src/gradient-chemistry.cpp | 12 +- src/gradient-drag.cpp | 17 +- src/graphlayout.cpp | 10 +- src/graphlayout.h | 4 +- src/helper/png-write.cpp | 12 +- src/helper/png-write.h | 9 +- src/live_effects/lpe-knot.cpp | 6 +- src/main.cpp | 23 +- src/object-snapper.cpp | 5 +- src/path-chemistry.cpp | 125 ++-- src/path-chemistry.h | 2 +- src/removeoverlap.cpp | 12 +- src/removeoverlap.h | 2 +- src/selcue.cpp | 19 +- src/selection-chemistry.cpp | 779 +++++++++++------------- src/selection-chemistry.h | 11 +- src/selection-describer.cpp | 34 +- src/selection.cpp | 159 +++-- src/selection.h | 38 +- src/seltrans.cpp | 54 +- src/seltrans.h | 2 +- src/snap.cpp | 14 +- src/snap.h | 8 +- src/sp-conn-end.cpp | 5 +- src/sp-defs.cpp | 9 +- src/sp-filter.cpp | 9 +- src/sp-item-group.cpp | 91 ++- src/sp-item-group.h | 5 +- src/sp-lpe-item.cpp | 30 +- src/sp-marker.cpp | 6 +- src/sp-marker.h | 2 +- src/sp-object.cpp | 6 +- src/sp-object.h | 10 +- src/sp-pattern.cpp | 6 +- src/sp-pattern.h | 2 +- src/sp-switch.cpp | 24 +- src/sp-switch.h | 2 +- src/splivarot.cpp | 102 ++-- src/text-chemistry.cpp | 83 ++- src/text-editing.cpp | 7 +- src/trace/trace.cpp | 8 +- src/ui/clipboard.cpp | 33 +- src/ui/dialog/align-and-distribute.cpp | 87 +-- src/ui/dialog/clonetiler.cpp | 14 +- src/ui/dialog/export.cpp | 28 +- src/ui/dialog/filter-effects-dialog.cpp | 27 +- src/ui/dialog/find.cpp | 92 +-- src/ui/dialog/find.h | 11 +- src/ui/dialog/glyphs.cpp | 12 +- src/ui/interface.cpp | 17 +- src/unclump.cpp | 57 +- src/unclump.h | 3 +- src/vanishing-point.cpp | 26 +- src/widgets/arc-toolbar.cpp | 33 +- src/widgets/connector-toolbar.cpp | 16 +- src/widgets/fill-style.cpp | 32 +- src/widgets/gradient-toolbar.cpp | 15 +- src/widgets/mesh-toolbar.cpp | 10 +- src/widgets/rect-toolbar.cpp | 18 +- src/widgets/spiral-toolbar.cpp | 16 +- src/widgets/star-toolbar.cpp | 38 +- src/widgets/stroke-style.cpp | 29 +- src/widgets/stroke-style.h | 2 +- src/widgets/text-toolbar.cpp | 34 +- 78 files changed, 1283 insertions(+), 1365 deletions(-) (limited to 'src') diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index c13b9a5d3..f2cde352c 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -252,8 +252,9 @@ static std::vector approxItemWithPoints(SPItem const *item, const G { SPGroup* group = SP_GROUP(item); // consider all first-order children - for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) { - SPItem* child_item = SP_ITEM(i->data); + SelContainer itemlist = sp_item_group_item_list(group); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem* child_item = SP_ITEM(*i); std::vector child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); } diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index ee9fa39ec..39dfad44b 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -194,10 +194,10 @@ 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); - - for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) { + SelContainer const itemlist = desktop->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { /* last used styles for 3D box faces are stored separately */ - SPObject *obj = reinterpret_cast(i->data); // TODO unsafe until Selection is refactored. + SPObject *obj = reinterpret_cast(*i); // TODO unsafe until Selection is refactored. Box3DSide *side = dynamic_cast(obj); if (side) { const char * descr = box3d_side_axes_string(side); @@ -234,8 +234,9 @@ 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); - for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = reinterpret_cast(i->data); + SelContainer const itemlist = desktop->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = reinterpret_cast(*i); // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) if (isTextualItem(item)) { @@ -438,17 +439,16 @@ sp_desktop_get_font_size_tool(SPDesktop *desktop) /** Determine average stroke width, simple method */ // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually gdouble -stroke_average_width (GSList const *objects) +stroke_average_width (const SelContainer &objects) { - if (g_slist_length ((GSList *) objects) == 0) + if (objects.empty()) return Geom::infinity(); gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - - for (GSList const *l = objects; l != NULL; l = l->next) { - SPObject *obj = reinterpret_cast(l->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); SPItem *item = dynamic_cast(obj); if (!item) { continue; @@ -471,7 +471,7 @@ stroke_average_width (GSList const *objects) if (notstroked) return Geom::infinity(); - return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked); + return avgwidth / (objects.size() - n_notstroked); } static bool vectorsClose( std::vector const &lhs, std::vector const &rhs ) @@ -492,9 +492,9 @@ static bool vectorsClose( std::vector const &lhs, std::vector co * Write to style_res the average fill or stroke of list of objects, if applicable. */ int -objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill) +objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -514,8 +514,8 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -674,7 +674,7 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill } // Not color - if (g_slist_length(objects) > 1) { + if (objects.size() > 1) { return QUERY_STYLE_MULTIPLE_SAME; } else { return QUERY_STYLE_SINGLE; @@ -685,9 +685,9 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill * Write to style_res the average opacity of a list of objects. */ int -objects_query_opacity (GSList *objects, SPStyle *style_res) +objects_query_opacity (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -698,8 +698,8 @@ objects_query_opacity (GSList *objects, SPStyle *style_res) guint opacity_items = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -739,9 +739,9 @@ objects_query_opacity (GSList *objects, SPStyle *style_res) * Write to style_res the average stroke width of a list of objects. */ int -objects_query_strokewidth (GSList *objects, SPStyle *style_res) +objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -754,8 +754,8 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) int n_stroked = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -815,9 +815,9 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) * Write to style_res the average miter limit of a list of objects. */ int -objects_query_miterlimit (GSList *objects, SPStyle *style_res) +objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -828,8 +828,8 @@ objects_query_miterlimit (GSList *objects, SPStyle *style_res) gdouble prev_ml = -1; bool same_ml = true; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; } @@ -875,9 +875,9 @@ objects_query_miterlimit (GSList *objects, SPStyle *style_res) * Write to style_res the stroke cap of a list of objects. */ int -objects_query_strokecap (GSList *objects, SPStyle *style_res) +objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -887,8 +887,8 @@ objects_query_strokecap (GSList *objects, SPStyle *style_res) bool same_cap = true; int n_stroked = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; } @@ -929,9 +929,9 @@ objects_query_strokecap (GSList *objects, SPStyle *style_res) * Write to style_res the stroke join of a list of objects. */ int -objects_query_strokejoin (GSList *objects, SPStyle *style_res) +objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -941,8 +941,8 @@ objects_query_strokejoin (GSList *objects, SPStyle *style_res) bool same_join = true; int n_stroked = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; } @@ -984,7 +984,7 @@ objects_query_strokejoin (GSList *objects, SPStyle *style_res) * Write to style_res the average font size and spacing of objects. */ int -objects_query_fontnumbers (GSList *objects, SPStyle *style_res) +objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) { bool different = false; @@ -1004,8 +1004,8 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) int texts = 0; int no_size = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { continue; @@ -1116,15 +1116,15 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) * Write to style_res the average font style of objects. */ int -objects_query_fontstyle (GSList *objects, SPStyle *style_res) +objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) { bool different = false; bool set = false; int texts = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { continue; @@ -1173,7 +1173,7 @@ objects_query_fontstyle (GSList *objects, SPStyle *style_res) * Write to style_res the baseline numbers. */ static int -objects_query_baselines (GSList *objects, SPStyle *style_res) +objects_query_baselines (const SelContainer &objects, SPStyle *style_res) { bool different = false; @@ -1192,8 +1192,8 @@ objects_query_baselines (GSList *objects, SPStyle *style_res) int texts = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { continue; @@ -1269,7 +1269,7 @@ objects_query_baselines (GSList *objects, SPStyle *style_res) * Write to style_res the average font family of objects. */ int -objects_query_fontfamily (GSList *objects, SPStyle *style_res) +objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1280,8 +1280,8 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res) } style_res->font_family.set = FALSE; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1325,7 +1325,7 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res) } static int -objects_query_fontspecification (GSList *objects, SPStyle *style_res) +objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1336,8 +1336,8 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res) } style_res->font_specification.set = FALSE; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1385,7 +1385,7 @@ objects_query_fontspecification (GSList *objects, SPStyle *style_res) } static int -objects_query_blend (GSList *objects, SPStyle *style_res) +objects_query_blend (const SelContainer &objects, SPStyle *style_res) { const int empty_prev = -2; const int complex_filter = 5; @@ -1394,8 +1394,8 @@ objects_query_blend (GSList *objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -1471,9 +1471,9 @@ objects_query_blend (GSList *objects, SPStyle *style_res) * Write to style_res the average blurring of a list of objects. */ int -objects_query_blur (GSList *objects, SPStyle *style_res) +objects_query_blur (const SelContainer &objects, SPStyle *style_res) { - if (g_slist_length(objects) == 0) { + if (objects.empty()) { /* No objects, set empty */ return QUERY_STYLE_NOTHING; } @@ -1484,8 +1484,8 @@ objects_query_blur (GSList *objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (GSList const *i = objects; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; } @@ -1553,7 +1553,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res) * the result to style, return appropriate flag. */ int -sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property) +sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property) { if (property == QUERY_STYLE_PROPERTY_FILL) { return objects_query_fillstroke (list, style, true); @@ -1606,7 +1606,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 ((GSList *) desktop->selection->itemList(), style, property); + return sp_desktop_query_style_from_list (desktop->selection->itemList(), style, property); } return QUERY_STYLE_NOTHING; diff --git a/src/desktop-style.h b/src/desktop-style.h index 40ca27e9e..0e40a2652 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -13,6 +13,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "selection.h" // SelContainer class ColorRGBA; class SPCSSAttr; class SPDesktop; @@ -64,21 +65,21 @@ guint32 sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, double sp_desktop_get_font_size_tool (SPDesktop *desktop); void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text); -gdouble stroke_average_width (GSList const *objects); +gdouble stroke_average_width (const SelContainer &objects); -int objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill); -int objects_query_fontnumbers (GSList *objects, SPStyle *style_res); -int objects_query_fontstyle (GSList *objects, SPStyle *style_res); -int objects_query_fontfamily (GSList *objects, SPStyle *style_res); -int objects_query_opacity (GSList *objects, SPStyle *style_res); -int objects_query_strokewidth (GSList *objects, SPStyle *style_res); -int objects_query_miterlimit (GSList *objects, SPStyle *style_res); -int objects_query_strokecap (GSList *objects, SPStyle *style_res); -int objects_query_strokejoin (GSList *objects, SPStyle *style_res); +int objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill); +int objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res); +int objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res); +int objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res); +int objects_query_opacity (const SelContainer &objects, SPStyle *style_res); +int objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res); +int objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res); +int objects_query_strokecap (const SelContainer &objects, SPStyle *style_res); +int objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res); -int objects_query_blur (GSList *objects, SPStyle *style_res); +int objects_query_blur (const SelContainer &objects, SPStyle *style_res); -int sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property); +int sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property); int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 13b8d60c4..66a8c4358 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -64,14 +64,12 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - Inkscape::Util::GSListConstIterator selected = - desktop->getSelection()->itemList(); - while ( selected != NULL ) { + SelContainer selected = desktop->getSelection()->itemList(); + for(SelContainer::const_iterator x=selected.begin();x!=selected.end();x++){ Glib::ustring selected_id; - selected_id = (*selected)->getId(); + selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); //std::cout << "Selected: " << selected_id << std::endl; - ++selected; } } diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 52f63499a..6eff3ede3 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -48,11 +48,10 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); using Inkscape::Util::GSListConstIterator; - // FIXME very unsafe cast - GSListConstIterator selected = ((SPDesktop *)view)->getSelection()->itemList(); + SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; - if (selected != NULL) { - const SPItem * item = *selected; + if (!selected.empty()) { + const SPItem * item = SP_ITEM(selected.front()); first_select = item->getRepr(); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index bbc567f75..f396e9848 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -689,14 +689,13 @@ void Script::effect(Inkscape::Extension::Effect *module, return; } - Inkscape::Util::GSListConstIterator selected = + SelContainer selected = desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - while ( selected != NULL ) { + for(SelContainer::const_iterator x=selected.begin();x!=selected.end();x++){ Glib::ustring selected_id; selected_id += "--id="; - selected_id += (*selected)->getId(); + selected_id += (*x)->getId(); params.insert(params.begin(), selected_id); - ++selected; } file_listener fileout; diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 76f35415e..87ef30887 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -70,8 +70,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const GSList *selectedItemList = desktop->selection->itemList(); - int selectCount = g_slist_length((GSList *)selectedItemList); + const SelContainer selectedItemList = desktop->selection->itemList(); + int selectCount = selectedItemList.size(); // Init the data-holders _nodes = new Inkscape::XML::Node*[selectCount]; @@ -83,9 +83,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (; selectedItemList != NULL; selectedItemList = g_slist_next(selectedItemList)) - { - SPItem *item = SP_ITEM(selectedItemList->data); + for (SelContainer::const_iterator i=selectedItemList.begin();i!=selectedItemList.end();i++) { + SPItem *item = static_cast(*i); Inkscape::XML::Node *node = reinterpret_cast(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) { @@ -243,11 +242,10 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie using Inkscape::Util::GSListConstIterator; - // FIXME very unsafe cast - GSListConstIterator selected = ((SPDesktop *)view)->getSelection()->itemList(); + SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; - if (selected != NULL) { - first_select = (*selected)->getRepr(); + if (!selected.empty()) { + first_select = (selected.front())->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 3ce537d9f..138172715 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -65,13 +65,12 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least - std::list items; - items.insert >(items.end(), selection->itemList(), NULL); + SelContainer items(selection->itemList()); selection->clear(); - for(std::list::iterator item = items.begin(); + for(SelContainer::iterator item = items.begin(); item != items.end(); ++item) { - SPItem * spitem = *item; + SPItem * spitem = static_cast(*item); std::vector new_items(steps); Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 1f48d2097..7ce5cdf8a 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -294,14 +294,14 @@ static void sp_group_render(SPGroup *group, CairoRenderContext *ctx) CairoRenderer *renderer = ctx->getRenderer(); TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); - GSList *l = g_slist_reverse(group->childList(false)); - while (l) { - SPObject *o = reinterpret_cast(l->data); + SelContainer l(group->childList(false)); + l.reverse(); + for(SelContainer::const_iterator x=l.begin();x!=l.end();x++){ + SPObject *o = reinterpret_cast(*x); SPItem *item = dynamic_cast(o); if (item) { renderer->renderItem(ctx, item); } - l = g_slist_remove (l, o); } } diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index a2c565699..821c023ac 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -125,17 +125,15 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie //printf("Calling filter effect\n"); Inkscape::Selection * selection = ((SPDesktop *)document)->selection; - using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least - std::list items; - items.insert >(items.end(), selection->itemList(), NULL); + SelContainer items(selection->itemList()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); - for(std::list::iterator item = items.begin(); + for(SelContainer::iterator item = items.begin(); item != items.end(); ++item) { - SPItem * spitem = *item; + SPItem * spitem = static_cast(*item); Inkscape::XML::Node * node = spitem->getRepr(); SPCSSAttr * css = sp_repr_css_attr(node, "style"); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 270edfe44..4c12f629c 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -192,11 +192,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View using Inkscape::Util::GSListConstIterator; - // FIXME very unsafe cast - GSListConstIterator selected = ((SPDesktop *)view)->getSelection()->itemList(); + SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; - if (selected != NULL) { - first_select = (*selected)->getRepr(); + if (!selected.empty()) { + first_select = (selected.front())->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index ab0733848..dab27a0e1 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -228,14 +228,14 @@ LaTeXTextRenderer::writePostamble() void LaTeXTextRenderer::sp_group_render(SPGroup *group) { - GSList *l = g_slist_reverse(group->childList(false)); - while (l) { - SPObject *o = reinterpret_cast(l->data); + SelContainer l = (group->childList(false)); + l.reverse(); + for(SelContainer::const_iterator x=l.begin();x!=l.end();x++){ + SPObject *o = reinterpret_cast(*x); SPItem *item = dynamic_cast(o); if (item) { renderItem(item); } - l = g_slist_remove (l, o); } } diff --git a/src/file.cpp b/src/file.cpp index 72516d776..4325c838b 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1063,7 +1063,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) desktop->doc()->importDefs(clipdoc); // copy objects - GSList *pasted_objects = NULL; + std::list pasted_objects; for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { // Don't copy metadata, defs, named views and internal clipboard contents to the document if (!strcmp(obj->name(), "svg:defs")) { @@ -1082,7 +1082,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) target_parent->appendChild(obj_copy); Inkscape::GC::release(obj_copy); - pasted_objects = g_slist_prepend(pasted_objects, (gpointer) obj_copy); + pasted_objects.push_front(dynamic_cast(obj_copy)); } // Change the selection to the freshly pasted objects @@ -1123,8 +1123,6 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) sp_selection_move_relative(selection, offset); } - - g_slist_free(pasted_objects); } diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 9298a1ffc..c89cf6220 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -23,9 +23,9 @@ #include "filter-chemistry.h" #include "filter-enums.h" - #include "filters/blend.h" #include "filters/gaussian-blur.h" +#include "selection.h" #include "sp-filter.h" #include "sp-filter-reference.h" #include "svg/css-ostringstream.h" diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index cf75f6cf0..5f1da6cf1 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1570,8 +1570,9 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa { Inkscape::Selection *selection = desktop->getSelection(); - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - sp_item_gradient_invert_vector_color(SP_ITEM(i->data), fill_or_stroke); + const SelContainer list=selection->itemList(); + for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + sp_item_gradient_invert_vector_color(SP_ITEM(*i), fill_or_stroke); } // we did an undoable action @@ -1594,9 +1595,10 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) if (drag && drag->selected) { drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); + const SelContainer list=selection->itemList(); + for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_FILL); + sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_STROKE); } } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 154b7339b..649928060 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2082,9 +2082,9 @@ void GrDrag::updateDraggers() this->draggers = NULL; g_return_if_fail(this->selection != NULL); - - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer list = this->selection->itemList(); + for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { @@ -2151,9 +2151,9 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { - - SPItem *item = SP_ITEM(i->data); + SelContainer list = this->selection->itemList(); + for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -2295,8 +2295,9 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer list = this->selection->itemList(); + for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + SPItem *item = SP_ITEM(*i); Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { // Remember the edges of the bbox and the center axis diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index e5d61ab64..613440269 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -88,9 +88,9 @@ struct CheckProgress : TestConvergence { * Scans the items list and places those items that are * not connectors in filtered */ -void filterConnectors(GSList const *const items, list &filtered) { - for(GSList *i=(GSList *)items; i!=NULL; i=i->next) { - SPItem *item=SP_ITEM(i->data); +void filterConnectors(SelContainer const &items, list &filtered) { + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = SP_ITEM(*i); if(!isConnector(item)) { filtered.push_back(item); } @@ -101,8 +101,8 @@ void filterConnectors(GSList const *const items, list &filtered) { * connectors between them, and uses graph layout techniques to find * a nice layout */ -void graphlayout(GSList const *const items) { - if(!items) { +void graphlayout(SelContainer const &items) { + if(items.empty()) { return; } diff --git a/src/graphlayout.h b/src/graphlayout.h index 0ffb645b6..c38f9471c 100644 --- a/src/graphlayout.h +++ b/src/graphlayout.h @@ -19,10 +19,10 @@ typedef struct _GSList GSList; class SPItem; -void graphlayout(GSList const *const items); +void graphlayout(SelContainer const &items); bool isConnector(SPItem const *const item); -void filterConnectors(GSList const *const items, std::list &filtered); +void filterConnectors(SelContainer const &items, std::list &filtered); #endif // SEEN_GRAPHLAYOUT_H diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 32e50b537..55fef5a4c 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -361,19 +361,19 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v /** * Hide all items that are not listed in list, recursively, skipping groups and defs. */ -static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) +static void hide_other_items_recursively(SPObject *o, const SelContainer &list, unsigned dkey) { if ( SP_IS_ITEM(o) && !SP_IS_DEFS(o) && !SP_IS_ROOT(o) && !SP_IS_GROUP(o) - && !g_slist_find(list, o) ) + && list.end()==find(list.begin(),list.end(),o)) { SP_ITEM(o)->invoke_hide(dkey); } // recurse - if (!g_slist_find(list, o)) { + 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); } @@ -387,7 +387,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned int (*status) (float, void *), void *data, bool force_overwrite, - GSList *items_only) + const SelContainer &items_only) { return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); @@ -399,7 +399,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned (*status)(float, void *), void *data, bool force_overwrite, - GSList *items_only) + const SelContainer &items_only) { g_return_val_if_fail(doc != NULL, EXPORT_ERROR); g_return_val_if_fail(filename != NULL, EXPORT_ERROR); @@ -457,7 +457,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, // We show all and then hide all items we don't want, instead of showing only requested items, // because that would not work if the shown item references something in defs - if (items_only) { + if (!items_only.empty()) { hide_other_items_recursively(doc->getRoot(), items_only, dkey); } diff --git a/src/helper/png-write.h b/src/helper/png-write.h index 8c04b25dc..47fad1b41 100644 --- a/src/helper/png-write.h +++ b/src/helper/png-write.h @@ -16,6 +16,11 @@ #include #include <2geom/forward.h> + +//should be in selection.h +typedef std::list SelContainer; + + class SPDocument; enum ExportResult { @@ -33,12 +38,12 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, double x0, double y0, double x1, double y1, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const SelContainer &items_only = SelContainer()); ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, Geom::Rect const &area, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const SelContainer &items_only = SelContainer()); #endif // SEEN_SP_PNG_WRITE_H diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 3876aa24b..95a6b16dd 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -505,9 +505,9 @@ LPEKnot::doEffect_path (std::vector const &path_in) static void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &paths, std::vector &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { - GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); if (SP_IS_LPE_ITEM(subitem)) { collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); } diff --git a/src/main.cpp b/src/main.cpp index 15576109d..25dc91f14 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1156,7 +1156,7 @@ static int sp_process_file_list(GSList *fl) } if (sp_export_svg) { if (sp_export_text_to_path) { - GSList *items = NULL; + SelContainer items; SPRoot *root = doc->getRoot(); doc->ensureUpToDate(); for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { @@ -1166,17 +1166,17 @@ static int sp_process_file_list(GSList *fl) } te_update_layout_now_recursive(item); - items = g_slist_append(items, item); + items.push_back(item); } - GSList *selected = NULL; - GSList *to_select = NULL; + SelContainer selected; + SelContainer to_select; - sp_item_list_to_curves(items, &selected, &to_select); + sp_item_list_to_curves(items, selected, to_select); - g_slist_free (items); - g_slist_free (selected); - g_slist_free (to_select); + items.clear(); + selected.clear(); + to_select.clear(); } if(sp_export_id) { doc->ensureUpToDate(); @@ -1435,7 +1435,7 @@ static int sp_do_export_png(SPDocument *doc) g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored."); } - GSList *items = NULL; + SelContainer items; Geom::Rect area; if (sp_export_id || sp_export_area_drawing) { @@ -1459,7 +1459,7 @@ static int sp_do_export_png(SPDocument *doc) return 1; } - items = g_slist_prepend (items, SP_ITEM(o)); + items.push_front(SP_ITEM(o)); if (sp_export_id_only) { g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id); @@ -1647,7 +1647,7 @@ static int sp_do_export_png(SPDocument *doc) if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, - dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL) == 1 ) { + dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : SelContainer()) == 1 ) { g_print("Bitmap saved as: %s\n", filename.c_str()); } else { g_warning("Bitmap failed to save to: %s", filename.c_str()); @@ -1657,7 +1657,6 @@ static int sp_do_export_png(SPDocument *doc) } } - g_slist_free (items); return retcode; } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 338f91463..960b5087b 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -237,8 +237,9 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, // current selection (see the comment in SelTrans::centerRequest()) bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); if (old_pref2) { - for ( GSList const *itemlist = _snapmanager->getRotationCenterSource(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { - if ((*i).item == reinterpret_cast(itemlist->data)) { + SelContainer rotationSource=_snapmanager->getRotationCenterSource(); + for ( SelContainer::const_iterator itemlist=rotationSource.begin();itemlist!=rotationSource.end();itemlist++) { + if ((*i).item == reinterpret_cast(*itemlist)) { // don't snap to this item's rotation center _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); break; diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 5f6e1495b..a5e71b720 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -44,13 +44,22 @@ using Inkscape::DocumentUndo; + +inline bool less_than_objects(SPObject const *first, SPObject const *second) +{ + return sp_repr_compare_position(first->getRepr(), + second->getRepr())<0; +} + void sp_selected_path_combine(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); + + SelContainer items(selection->itemList()); - if (g_slist_length((GSList *) selection->itemList()) < 1) { + if (items.size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to combine.")); return; } @@ -59,28 +68,26 @@ sp_selected_path_combine(SPDesktop *desktop) // set "busy" cursor desktop->setWaitingCursor(); - GSList *items = g_slist_copy((GSList *) selection->itemList()); - items = sp_degroup_list (items); // descend into any groups in selection - GSList *to_paths = NULL; - for (GSList *i = items; i != NULL; i = i->next) { - SPItem *item = (SPItem *) i->data; + SelContainer to_paths; + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + SPItem *item = (SPItem *) (*i); if (!dynamic_cast(item) && !dynamic_cast(item)) { - to_paths = g_slist_prepend(to_paths, item); + to_paths.push_front(item); } } - GSList *converted = NULL; - bool did = sp_item_list_to_curves(to_paths, &items, &converted); - g_slist_free(to_paths); - for (GSList *i = converted; i != NULL; i = i->next) - items = g_slist_prepend(items, doc->getObjectByRepr((Inkscape::XML::Node*)(i->data))); + SelContainer converted; + bool did = sp_item_list_to_curves(to_paths, items, converted); + to_paths.clear(); + for (SelContainer::const_iterator i=converted.begin();i!=converted.end();i++) + items.push_front(doc->getObjectByRepr((Inkscape::XML::Node*)(*i))); items = sp_degroup_list (items); // converting to path may have added more groups, descend again - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); - items = g_slist_reverse(items); - assert(items); // cannot be NULL because of list length check at top of function + items.sort(less_than_objects); + items.reverse(); + assert(!items.empty()); // cannot be NULL because of list length check at top of function // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one gint position = 0; @@ -97,9 +104,9 @@ sp_selected_path_combine(SPDesktop *desktop) selection->clear(); } - for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = (SPItem *) i->data; + SPItem *item = (SPItem *) (*i); SPPath *path = dynamic_cast(item); if (!path) { continue; @@ -136,7 +143,6 @@ sp_selected_path_combine(SPDesktop *desktop) } } - g_slist_free(items); if (did) { first->deleteObject(false); @@ -200,11 +206,10 @@ sp_selected_path_break_apart(SPDesktop *desktop) bool did = false; - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); - items != NULL; - items = items->next) { + SelContainer itemlist(selection->itemList()); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = (SPItem *) items->data; + SPItem *item = (SPItem *) (*i); SPPath *path = dynamic_cast(item); if (!path) { @@ -241,7 +246,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) curve->unref(); - GSList *reprs = NULL; + SelContainer reprs; for (GSList *l = list; l != NULL; l = l->next) { curve = (SPCurve *) l->data; @@ -267,14 +272,14 @@ sp_selected_path_break_apart(SPDesktop *desktop) if (l == list) repr->setAttribute("id", id); - reprs = g_slist_prepend (reprs, repr); + reprs.push_front(dynamic_cast(repr)); Inkscape::GC::release(repr); } selection->setReprList(reprs); - g_slist_free(reprs); + reprs.clear(); g_slist_free(list); g_free(style); g_free(path_effect); @@ -307,18 +312,18 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b desktop->setWaitingCursor(); } - GSList *selected = g_slist_copy((GSList *) selection->itemList()); - GSList *to_select = NULL; + SelContainer selected(selection->itemList()); + SelContainer to_select; selection->clear(); - GSList *items = g_slist_copy(selected); + SelContainer items(selected); - did = sp_item_list_to_curves(items, &selected, &to_select); + did = sp_item_list_to_curves(items, selected, to_select); - g_slist_free (items); + items.clear(); selection->setReprList(to_select); selection->addList(selected); - g_slist_free (to_select); - g_slist_free (selected); + to_select.clear(); + selected.clear(); if (interactive && desktop) { desktop->clearWaitingCursor(); @@ -341,33 +346,29 @@ void sp_selected_to_lpeitems(SPDesktop *desktop) return; } - GSList *selected = g_slist_copy((GSList *) selection->itemList()); - GSList *to_select = NULL; + SelContainer selected(selection->itemList()); + SelContainer to_select; selection->clear(); - GSList *items = g_slist_copy(selected); + SelContainer items(selected); + - sp_item_list_to_curves(items, &selected, &to_select, true); + sp_item_list_to_curves(items, selected, to_select, true); - g_slist_free(items); - items = 0; + items.clear(); selection->setReprList(to_select); selection->addList(selected); - g_slist_free(to_select); - to_select = 0; - g_slist_free(selected); - selected = 0; + to_select.clear(); + selected.clear(); } bool -sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems) +sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelContainer &to_select, bool skip_all_lpeitems) { bool did = false; - for (; - items != NULL; - items = items->next) { + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(items->data)); + SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); SPDocument *document = item->document; @@ -398,9 +399,9 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); if (repr) { - *to_select = g_slist_prepend (*to_select, repr); + to_select.push_front(dynamic_cast(repr)); did = true; - *selected = g_slist_remove (*selected, item); + selected.remove(item); } continue; @@ -408,17 +409,17 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec if (group) { group->removeAllPathEffects(true); - GSList *item_list = sp_item_group_item_list(group); + SelContainer item_list = sp_item_group_item_list(group); - GSList *item_to_select = NULL; - GSList *item_selected = NULL; + SelContainer item_to_select; + SelContainer item_selected; - if (sp_item_list_to_curves(item_list, &item_selected, &item_to_select)) + if (sp_item_list_to_curves(item_list, item_selected, item_to_select)) did = true; - g_slist_free(item_list); - g_slist_free(item_to_select); - g_slist_free(item_selected); + item_list.clear(); + item_to_select.clear(); + item_selected.clear(); continue; } @@ -428,7 +429,7 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec continue; did = true; - *selected = g_slist_remove (*selected, item); + selected.remove(item); // remember the position of the item gint pos = item->getRepr()->position(); @@ -470,7 +471,7 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec /* Buglet: We don't re-add the (new version of the) object to the selection of any other * desktops where it was previously selected. */ - *to_select = g_slist_prepend (*to_select, repr); + to_select.push_front(dynamic_cast(repr)); Inkscape::GC::release(repr); } @@ -612,9 +613,9 @@ void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); - GSList *items = (GSList *) selection->itemList(); + SelContainer items = selection->itemList(); - if (!items) { + if (items.empty()) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to reverse.")); return; } @@ -626,9 +627,9 @@ sp_selected_path_reverse(SPDesktop *desktop) bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); - for (GSList *i = items; i != NULL; i = i->next) { + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ - SPPath *path = dynamic_cast(static_cast(i->data)); + SPPath *path = dynamic_cast(static_cast(*i)); if (!path) { continue; } diff --git a/src/path-chemistry.h b/src/path-chemistry.h index a2150440c..388268af4 100644 --- a/src/path-chemistry.h +++ b/src/path-chemistry.h @@ -33,7 +33,7 @@ void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desk void sp_selected_to_lpeitems(SPDesktop *desktop); Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); void sp_selected_path_reverse (SPDesktop *desktop); -bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems = false); +bool sp_item_list_to_curves(const SelContainer &items, SelContainer &selected, SelContainer &to_select, bool skip_all_lpeitems = false); #endif // SEEN_PATH_CHEMISTRY_H diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index ba5740e55..9009de5e9 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -38,20 +38,20 @@ namespace { * such that rectangular bounding boxes are separated by at least xGap * horizontally and yGap vertically */ -void removeoverlap(GSList const *const items, double const xGap, double const yGap) { +void removeoverlap(SelContainer const &items, double const xGap, double const yGap) { using Inkscape::Util::GSListConstIterator; - std::list selected; - selected.insert >(selected.end(), items, NULL); + SelContainer selected(items); std::vector records; std::vector rs; Geom::Point const gap(xGap, yGap); - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) { + SPItem* item=static_cast(*it); using Geom::X; using Geom::Y; - Geom::OptRect item_box((*it)->desktopVisualBounds()); + Geom::OptRect item_box((item)->desktopVisualBounds()); if (item_box) { Geom::Point min(item_box->min() - .5*gap); Geom::Point max(item_box->max() + .5*gap); @@ -67,7 +67,7 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG min[Y] = max[Y] = (min[Y] + max[Y])/2; } Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]); - records.push_back(Record(*it, item_box->midpoint(), vspc_rect)); + records.push_back(Record(item, item_box->midpoint(), vspc_rect)); rs.push_back(vspc_rect); } } diff --git a/src/removeoverlap.h b/src/removeoverlap.h index 7109c9513..d050ca9ef 100644 --- a/src/removeoverlap.h +++ b/src/removeoverlap.h @@ -15,6 +15,6 @@ typedef struct _GSList GSList; -void removeoverlap(GSList const *items, double xGap, double yGap); +void removeoverlap(SelContainer const &items, double xGap, double yGap); #endif // SEEN_REMOVEOVERLAP_H diff --git a/src/selcue.cpp b/src/selcue.cpp index d2fa0970a..0fab6e5a8 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -96,15 +96,16 @@ void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs) void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) { - GSList const *items = _selection->itemList(); - if (_item_bboxes.size() != g_slist_length((GSList *) items)) { + const SelContainer items = _selection->itemList(); + if (_item_bboxes.size() != items.size()) { _newItemBboxes(); return; } int bcount = 0; - for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { - SPItem *item = static_cast(l->data); + SelContainer ll=_selection->itemList(); + for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + SPItem *item = static_cast(*l); SPCanvasItem* box = _item_bboxes[bcount ++]; if (box) { @@ -145,8 +146,9 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); - for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { - SPItem *item = static_cast(l->data); + SelContainer ll=_selection->itemList(); + for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + SPItem *item = static_cast(*l); Geom::OptRect const b = (prefs_bbox == 0) ? item->desktopVisualBounds() : item->desktopGeometricBounds(); @@ -199,8 +201,9 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { - SPItem *item = static_cast(l->data); + SelContainer ll=_selection->itemList(); + for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + SPItem *item = static_cast(*l); SPCanvasItem* baseline_point = NULL; if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index c9837aabe..f20df1594 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -279,25 +279,23 @@ void SelectionHelper::fixSelection(SPDesktop *dt) Inkscape::Selection *selection = dt->getSelection(); - GSList *items = NULL; + SelContainer items ; - GSList const *selList = selection->itemList(); + SelContainer const selList = selection->itemList(); - for( GSList const *i = selList; i; i = i->next ) { - SPItem *item = dynamic_cast(static_cast(i->data)); + for( SelContainer::const_iterator i=selList.begin();i!=selList.end();i++ ) { + SPItem *item = dynamic_cast(static_cast(*i)); if( item && !dt->isLayer(item) && (!item->isLocked())) { - items = g_slist_prepend(items, item); + items.push_front(item); } } selection->setList(items); - if(items) { - g_slist_free(items); - } + items.clear(); } } // namespace Inkscape @@ -307,7 +305,7 @@ void SelectionHelper::fixSelection(SPDesktop *dt) * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', * then prepends the copy to 'clip'. */ -static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, SelContainer &clip, Inkscape::XML::Document* xml_doc) { Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -323,18 +321,18 @@ static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t copy->setAttribute("transform", affinestr); g_free(affinestr); - *clip = g_slist_prepend(*clip, copy); + clip.push_front(dynamic_cast(copy)); } -static void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_impl(SelContainer const &items, SelContainer &clip, Inkscape::XML::Document* xml_doc) { // Sort items: - GSList *sorted_items = g_slist_copy(const_cast(items)); - sorted_items = g_slist_sort(static_cast(sorted_items), (GCompareFunc) sp_object_compare_position); + SelContainer sorted_items(items); + sorted_items.sort(sp_object_compare_position); // Copy item reprs: - for (GSList *i = sorted_items; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(SP_OBJECT(i->data)); + for (SelContainer::const_iterator i = sorted_items.begin();i!=sorted_items.end();i++) { + SPItem *item = dynamic_cast(SP_OBJECT(*i)); if (item) { sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); } else { @@ -342,22 +340,22 @@ static void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape: } } - *clip = g_slist_reverse(*clip); - g_slist_free(static_cast(sorted_items)); + clip.reverse(); + sorted_items.clear(); } // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items. -static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip) +static SelContainer sp_selection_paste_impl(SPDocument *doc, SPObject *parent, SelContainer &clip) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); SPItem *parentItem = dynamic_cast(parent); g_assert(parentItem != NULL); - GSList *copied = NULL; + SelContainer copied; // add objects to document - for (GSList *l = *clip; l != NULL; l = l->next) { - Inkscape::XML::Node *repr = static_cast(l->data); + for (SelContainer::const_iterator l=clip.begin();l!=clip.end();l++) { + Inkscape::XML::Node *repr = dynamic_cast(*l); Inkscape::XML::Node *copy = repr->duplicate(xml_doc); // premultiply the item transform by the accumulated parent transform in the paste layer @@ -375,19 +373,19 @@ static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList } parent->appendChildRepr(copy); - copied = g_slist_prepend(copied, copy); + copied.push_front(dynamic_cast(copy)); Inkscape::GC::release(copy); } return copied; } -static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true) +static void sp_selection_delete_impl(SelContainer const &items, bool propagate = true, bool propagate_descendants = true) { - for (GSList const *i = items ; i ; i = i->next ) { - sp_object_ref(static_cast(i->data), NULL); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + sp_object_ref(static_cast(*i), NULL); } - for (GSList const *i = items; i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + SPItem *item = static_cast(*i); item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, NULL); } @@ -414,11 +412,10 @@ void sp_selection_delete(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing was deleted.")); return; } - - GSList *selected = g_slist_copy(const_cast(selection->itemList())); + SelContainer selected(selection->itemList()); selection->clear(); sp_selection_delete_impl(selected); - g_slist_free(selected); + selected.clear(); desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); /* a tool may have set up private information in it's selection context @@ -446,6 +443,10 @@ static void add_ids_recursive(std::vector &ids, SPObject *obj) } } +bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b){ + return sp_repr_compare_position(dynamic_cast(a),dynamic_cast(b)); +} + void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) { if (desktop == NULL) { @@ -461,16 +462,15 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to duplicate.")); return; } - - GSList *reprs = g_slist_copy(const_cast(selection->reprList())); + SelContainer reprs(selection->reprList()); selection->clear(); // sorting items from different parents sorts each parent's subset without possibly mixing // them, just what we need - reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position); + reprs.sort(sp_repr_compare_position_obj); - GSList *newsel = NULL; + SelContainer newsel; std::vector old_ids; std::vector new_ids; @@ -478,8 +478,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value"); const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true); - while (reprs) { - Inkscape::XML::Node *old_repr = static_cast(reprs->data); + while (!reprs.empty()) { + Inkscape::XML::Node *old_repr = dynamic_cast(reprs.front()); Inkscape::XML::Node *parent = old_repr->parent(); Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); @@ -500,8 +500,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) } } - newsel = g_slist_prepend(newsel, copy); - reprs = g_slist_remove(reprs, reprs->data); + newsel.push_front(dynamic_cast(copy)); + reprs.pop_front(); Inkscape::GC::release(copy); } @@ -548,7 +548,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) selection->setReprList(newsel); - g_slist_free(newsel); + newsel.clear(); } void sp_edit_clear_all(Inkscape::Selection *selection) @@ -561,11 +561,11 @@ void sp_edit_clear_all(Inkscape::Selection *selection) SPGroup *group = dynamic_cast(selection->layers()->currentLayer()); g_return_if_fail(group != NULL); - GSList *items = sp_item_group_item_list(group); + SelContainer items = sp_item_group_item_list(group); - while (items) { - reinterpret_cast(items->data)->deleteObject(); - items = g_slist_remove(items, items->data); + while (!items.empty()) { + reinterpret_cast(items.front())->deleteObject(); + items.pop_front(); } DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, @@ -582,7 +582,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) * onlysensitive - TRUE includes only non-locked items * ingroups - TRUE to recursively get grouped items children */ -GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) +SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, SelContainer const &exclude) { for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { SPItem *item = dynamic_cast(child); @@ -590,10 +590,10 @@ GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onl !desktop->isLayer(item) && (!onlysensitive || !item->isLocked()) && (!onlyvisible || !desktop->itemIsHidden(item)) && - (!exclude || !g_slist_find(const_cast(exclude), child)) + (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child)) ) { - list = g_slist_prepend(list, item); + list.push_front(item); } if (ingroups || (item && desktop->isLayer(item))) { @@ -618,9 +618,9 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); - GSList *items = NULL; + SelContainer items ; - GSList const *exclude = NULL; + SelContainer exclude; if (invert) { exclude = selection->itemList(); } @@ -634,39 +634,41 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i (onlyvisible && dt->itemIsHidden(dynamic_cast(dt->currentLayer()))) ) return; - GSList *all_items = sp_item_group_item_list(dynamic_cast(dt->currentLayer())); + SelContainer all_items = sp_item_group_item_list(dynamic_cast(dt->currentLayer())); - for (GSList *i = all_items; i; i = i->next) { - SPItem *item = dynamic_cast(static_cast(i->data)); + for (SelContainer::const_iterator i=all_items.begin();i!=all_items.end();i++) { + SPItem *item = dynamic_cast(static_cast(*i)); if (item && (!onlysensitive || !item->isLocked())) { if (!onlyvisible || !dt->itemIsHidden(item)) { if (!dt->isLayer(item)) { - if (!invert || !g_slist_find(const_cast(exclude), item)) { - items = g_slist_prepend(items, item); // leave it in the list + if (!invert || exclude.end() == std::find(exclude.begin(),exclude.end(),item)) { + items.push_front(item); // leave it in the list } } } } } - g_slist_free(all_items); + all_items.clear(); break; } case PREFS_SELECTION_LAYER_RECURSIVE: { - items = get_all_items(NULL, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); + SelContainer x; + items = get_all_items(x, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } default: { - items = get_all_items(NULL, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); + SelContainer x; + items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } } selection->setList(items); - if (items) { - g_slist_free(items); + if (!items.empty()) { + items.clear(); } } @@ -690,16 +692,16 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop) sp_edit_select_all_full(desktop, true, true); } -static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { +static void sp_selection_group_impl(SelContainer p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { - p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); + p.sort(sp_repr_compare_position_obj); // Remember the position and parent of the topmost object. - gint topmost = (static_cast(g_slist_last(p)->data))->position(); - Inkscape::XML::Node *topmost_parent = (static_cast(g_slist_last(p)->data))->parent(); + gint topmost = (dynamic_cast(p.back()))->position(); + Inkscape::XML::Node *topmost_parent = (dynamic_cast(p.back()))->parent(); - while (p) { - Inkscape::XML::Node *current = static_cast(p->data); + while (!p.empty()) { + Inkscape::XML::Node *current = dynamic_cast(p.front()); if (current->parent() == topmost_parent) { Inkscape::XML::Node *spnew = current->duplicate(xml_doc); @@ -708,7 +710,7 @@ static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inksc Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - GSList *temp_clip = NULL; + SelContainer temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -724,15 +726,15 @@ static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inksc // then, if this is clone, looking up its original in that array and pre-multiplying // it by the inverse of that original's transform diff. - sp_selection_copy_one(current, item_t, &temp_clip, xml_doc); + sp_selection_copy_one(current, item_t, temp_clip, xml_doc); sp_repr_unparent(current); // paste into topmost_parent (temporarily) - GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip); - if (temp_clip) g_slist_free(temp_clip); - if (copied) { // if success, + SelContainer copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); + if (!temp_clip.empty())temp_clip.clear() ; + if (!copied.empty()) { // if success, // take pasted object (now in topmost_parent) - Inkscape::XML::Node *in_topmost = static_cast(copied->data); + Inkscape::XML::Node *in_topmost = dynamic_cast(copied.front()); // make a copy Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); // remove pasted @@ -740,10 +742,10 @@ static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inksc // put its copy into group group->appendChild(spnew); Inkscape::GC::release(spnew); - g_slist_free(copied); + copied.clear(); } } - p = g_slist_remove(p, current); + p.pop_front(); } // Add the new group to the topmost members' parent @@ -764,9 +766,7 @@ void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) return; } - GSList const *l = const_cast(selection->reprList()); - - GSList *p = g_slist_copy(const_cast(l)); + SelContainer p (selection->reprList()); selection->clear(); @@ -802,11 +802,11 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } // first check whether there is anything to ungroup - GSList *old_select = const_cast(selection->itemList()); - GSList *new_select = NULL; + SelContainer old_select = selection->itemList(); + SelContainer new_select; GSList *groups = NULL; - for (GSList *item = old_select; item; item = item->next) { - SPItem *obj = static_cast(item->data); + for (SelContainer::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { + SPItem *obj = static_cast(*item); if (dynamic_cast(obj)) { groups = g_slist_prepend(groups, obj); } @@ -818,14 +818,14 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) return; } - GSList *items = g_slist_copy(old_select); + SelContainer items(old_select); selection->clear(); // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. GSList *clones_to_unlink = NULL; - for (GSList *item = items; item; item = item->next) { - SPUse *use = dynamic_cast(static_cast(item->data)); + for (SelContainer::const_iterator item = items.begin(); item!=items.end(); item++) { + SPUse *use = dynamic_cast(static_cast(*item)); SPItem *original = use; while (dynamic_cast(original)) { @@ -833,7 +833,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } if (g_slist_find(groups, original) != NULL) { - clones_to_unlink = g_slist_prepend(clones_to_unlink, item->data); + clones_to_unlink = g_slist_prepend(clones_to_unlink, *item); } } @@ -844,57 +844,57 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) for (GSList *item = clones_to_unlink; item; item = item->next) { SPUse *use = static_cast(item->data); - GSList *items_node = g_slist_find(items, item->data); - items_node->data = use->unlink(); + SelContainer::iterator items_node = std::find(items.begin(),items.end(), item->data); + (*items_node) = use->unlink(); } g_slist_free(clones_to_unlink); // do the actual work - for (GSList *item = items; item; item = item->next) { - SPItem *obj = static_cast(item->data); + for (SelContainer::iterator item = items.begin(); item!=items.end(); item++) { + SPItem *obj = static_cast(*item); // ungroup only the groups marked earlier - if (g_slist_find(groups, item->data) != NULL) { - GSList *children = NULL; - sp_item_group_ungroup(dynamic_cast(obj), &children, false); + if (g_slist_find(groups, *item) != NULL) { + SelContainer children; + sp_item_group_ungroup(dynamic_cast(obj), children, false); // add the items resulting from ungrouping to the selection - new_select = g_slist_concat(new_select, children); - item->data = NULL; // zero out the original pointer, which is no longer valid + new_select.splice(new_select.end(),children); + (*item) = NULL; // zero out the original pointer, which is no longer valid } else { // if not a group, keep in the selection - new_select = g_slist_append(new_select, item->data); + new_select.push_back(*item); } } selection->addList(new_select); - g_slist_free(new_select); - g_slist_free(items); + new_select.clear(); + items.clear(); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); } /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */ -GSList * -sp_degroup_list(GSList *items) +SelContainer +sp_degroup_list(SelContainer &items) { - GSList *out = NULL; + SelContainer out; bool has_groups = false; - for (GSList *item = items; item; item = item->next) { - SPGroup *group = dynamic_cast(static_cast(item->data)); + for (SelContainer::const_iterator item=items.begin();item!=items.end();item++) { + SPGroup *group = dynamic_cast(static_cast(*item)); if (!group) { - out = g_slist_prepend(out, item->data); + out.push_front(*item); } else { has_groups = true; - GSList *members = sp_item_group_item_list(group); - for (GSList *member = members; member; member = member->next) { - out = g_slist_prepend(out, member->data); + SelContainer members = sp_item_group_item_list(group); + for (SelContainer::const_iterator member=members.begin();member!=members.end();member++) { + out.push_front(*member); } - g_slist_free(members); + members.clear(); } } - out = g_slist_reverse(out); - g_slist_free(items); + out.reverse(); + items.clear(); if (has_groups) { // recurse if we unwrapped a group - it may have contained others out = sp_degroup_list(out); @@ -906,18 +906,19 @@ sp_degroup_list(GSList *items) /** If items in the list have a common parent, return it, otherwise return NULL */ static SPGroup * -sp_item_list_common_parent_group(GSList const *items) +sp_item_list_common_parent_group(SelContainer const items) { - if (!items) { + if (items.empty()) { return NULL; } - SPObject *parent = SP_OBJECT(items->data)->parent; + SPObject *parent = SP_OBJECT(items.front())->parent; // Strictly speaking this CAN happen, if user selects from Inkscape::XML editor if (!dynamic_cast(parent)) { return NULL; } - for (items = items->next; items; items = items->next) { - if (SP_OBJECT(items->data)->parent != parent) { + for (SelContainer::const_iterator item=items.begin();item!=items.end();item++) { + if((*item)==items.front())continue; + if (SP_OBJECT(*item)->parent != parent) { return NULL; } } @@ -927,13 +928,13 @@ sp_item_list_common_parent_group(GSList const *items) /** Finds out the minimum common bbox of the selected items. */ static Geom::OptRect -enclose_items(GSList const *items) +enclose_items(SelContainer const &items) { - g_assert(items != NULL); + g_assert(!items.empty()); Geom::OptRect r; - for (GSList const *i = items; i; i = i->next) { - r.unionWith(static_cast(i->data)->desktopVisualBounds()); + for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + r.unionWith(static_cast(*i)->desktopVisualBounds()); } return r; } @@ -948,11 +949,17 @@ static SPObject *prev_sibling(SPObject *child) return prev; } +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) +{ + return sp_repr_compare_position(((SPItem*)first)->getRepr(), + ((SPItem*)second)->getRepr())<0; +} + void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { - GSList const *items = const_cast(selection->itemList()); - if (!items) { + SelContainer items= selection->itemList(); + if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise.")); return; } @@ -966,16 +973,16 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) Inkscape::XML::Node *grepr = const_cast(group->getRepr()); /* Construct reverse-ordered list of selected children. */ - GSList *rev = g_slist_copy(const_cast(items)); - rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position); + SelContainer rev(items); + rev.sort(sp_item_repr_compare_position_obj); // Determine the common bbox of the selected items. Geom::OptRect selected = enclose_items(items); // Iterate over all objects in the selection (starting from top). if (selected) { - while (rev) { - SPObject *child = reinterpret_cast(rev->data); + while (!rev.empty()) { + SPObject *child = reinterpret_cast(rev.front()); // for each selected object, find the next sibling for (SPObject *newref = child->next; newref; newref = newref->next) { // if the sibling is an item AND overlaps our selection, @@ -984,7 +991,7 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) Geom::OptRect newref_bbox = newItem->desktopVisualBounds(); if ( newref_bbox && selected->intersects(*newref_bbox) ) { // AND if it's not one of our selected objects, - if (!g_slist_find(const_cast(items), newref)) { + if ( std::find(items.begin(),items.end(),newref)==items.end()) { // move the selected object after that sibling grepr->changeOrder(child->getRepr(), newref->getRepr()); } @@ -992,10 +999,10 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) } } } - rev = g_slist_remove(rev, child); + rev.pop_front(); } } else { - g_slist_free(rev); + rev.clear(); } DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, @@ -1012,7 +1019,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - GSList const *items = const_cast(selection->itemList()); + SelContainer items = selection->itemList(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1020,15 +1027,15 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - GSList *rl = g_slist_copy(const_cast(selection->reprList())); - rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position); + SelContainer rl(selection->reprList()); + rl.sort(sp_repr_compare_position_obj); - for (GSList *l = rl; l != NULL; l = l->next) { - Inkscape::XML::Node *repr = static_cast(l->data); + for (SelContainer::iterator l=rl.begin(); l!=rl.end();l++) { + Inkscape::XML::Node *repr = dynamic_cast(*l); repr->setPosition(-1); } - g_slist_free(rl); + rl.clear(); DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, _("Raise to top")); @@ -1036,8 +1043,8 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { - GSList const *items = const_cast(selection->itemList()); - if (!items) { + SelContainer items = selection->itemList(); + if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower.")); return; } @@ -1054,14 +1061,14 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) Geom::OptRect selected = enclose_items(items); /* Construct direct-ordered list of selected children. */ - GSList *rev = g_slist_copy(const_cast(items)); - rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position); - rev = g_slist_reverse(rev); + SelContainer rev(items); + rev.sort(sp_item_repr_compare_position_obj); + rev.reverse(); // Iterate over all objects in the selection (starting from top). if (selected) { - while (rev) { - SPObject *child = reinterpret_cast(rev->data); + while (!rev.empty()) { + SPObject *child = reinterpret_cast(rev.front()); // for each selected object, find the prev sibling for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { // if the sibling is an item AND overlaps our selection, @@ -1070,7 +1077,7 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) Geom::OptRect ref_bbox = newItem->desktopVisualBounds(); if ( ref_bbox && selected->intersects(*ref_bbox) ) { // AND if it's not one of our selected objects, - if (!g_slist_find(const_cast(items), newref)) { + if (items.end()==std::find(items.begin(),items.end(),newref)) { // move the selected object before that sibling SPObject *put_after = prev_sibling(newref); if (put_after) @@ -1082,10 +1089,10 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) } } } - rev = g_slist_remove(rev, child); + rev.pop_front(); } } else { - g_slist_free(rev); + rev.clear(); } DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, @@ -1102,7 +1109,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - GSList const *items = const_cast(selection->itemList()); + SelContainer items =selection->itemList(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1110,15 +1117,14 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - GSList *rl; - rl = g_slist_copy(const_cast(selection->reprList())); - rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position); - rl = g_slist_reverse(rl); + SelContainer rl(selection->reprList()); + rl.sort(sp_repr_compare_position_obj); + rl.reverse(); - for (GSList *l = rl; l != NULL; l = l->next) { + for (SelContainer::const_iterator l=rl.begin();l!=rl.end();l++) { gint minpos; SPObject *pp, *pc; - Inkscape::XML::Node *repr = static_cast(l->data); + Inkscape::XML::Node *repr = dynamic_cast(*l); pp = document->getObjectByRepr(repr->parent()); minpos = 0; g_assert(dynamic_cast(pp)); @@ -1130,7 +1136,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des repr->setPosition(minpos); } - g_slist_free(rl); + rl.clear(); DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, _("Lower to bottom")); @@ -1269,9 +1275,9 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to remove live path effects from.")); return; } - - for ( GSList const *itemlist = selection->itemList(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { - SPItem *item = reinterpret_cast(itemlist->data); + SelContainer list=selection->itemList(); + for ( SelContainer::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { + SPItem *item = reinterpret_cast(*itemlist); sp_selection_remove_livepatheffect_impl(item); @@ -1331,25 +1337,25 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) return; } - GSList const *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items(selection->itemList()); bool no_more = false; // Set to true, if no more layers above SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); if (next) { - GSList *temp_clip = NULL; - sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); + SelContainer temp_clip; + sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); sp_selection_delete_impl(items, false, false); next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers - GSList *copied; + SelContainer copied; if (next) { - copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip); + copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); } else { - copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip); + copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip); no_more = true; } - selection->setReprList((GSList const *) copied); - g_slist_free(copied); - if (temp_clip) g_slist_free(temp_clip); + selection->setReprList(copied); + copied.clear(); + if (!temp_clip.empty()) temp_clip.clear(); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT, @@ -1363,7 +1369,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above.")); } - g_slist_free(const_cast(items)); + items.clear(); } void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) @@ -1376,25 +1382,25 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) return; } - GSList const *items = g_slist_copy(const_cast(selection->itemList())); + const SelContainer items(selection->itemList()); bool no_more = false; // Set to true, if no more layers below SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); if (next) { - GSList *temp_clip = NULL; - sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs + SelContainer temp_clip; + sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers - GSList *copied; + SelContainer copied; if (next) { - copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip); + copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); } else { - copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip); + copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip); no_more = true; } - selection->setReprList((GSList const *) copied); - g_slist_free(copied); - if (temp_clip) g_slist_free(temp_clip); + selection->setReprList( copied); + copied.clear(); + if (!temp_clip.empty()) temp_clip.clear(); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV, @@ -1407,8 +1413,6 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) if (no_more) { dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers below.")); } - - g_slist_free(const_cast(items)); } void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) @@ -1421,24 +1425,22 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) return; } - GSList const *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items(selection->itemList()); if (moveto) { - GSList *temp_clip = NULL; - sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs + SelContainer temp_clip; + sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); - GSList *copied = sp_selection_paste_impl(dt->getDocument(), moveto, &temp_clip); - selection->setReprList((GSList const *) copied); - g_slist_free(copied); - if (temp_clip) g_slist_free(temp_clip); + SelContainer copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); + selection->setReprList(copied); + copied.clear(); + if (!temp_clip.empty()) temp_clip.clear(); if (moveto) dt->setCurrentLayer(moveto); if ( !suppressDone ) { DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO, _("Move selection to layer")); } } - - g_slist_free(const_cast(items)); } static bool @@ -1473,8 +1475,9 @@ static bool selection_contains_both_clone_and_original(Inkscape::Selection *selection) { bool clone_with_original = false; - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { - SPItem *item = dynamic_cast(static_cast(l->data)); + SelContainer items = selection->itemList(); + for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + SPItem *item = dynamic_cast(static_cast(*l)); if (item) { clone_with_original |= selection_contains_original(item, selection); if (clone_with_original) @@ -1517,9 +1520,9 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons persp3d_apply_affine_transformation(transf_persp, affine); } - - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { - SPItem *item = dynamic_cast(static_cast(l->data)); + SelContainer items = selection->itemList(); + for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + SPItem *item = dynamic_cast(static_cast(*l)); if( dynamic_cast(item) ) { // An SVG element cannot have a transform. We could change 'x' and 'y' in response @@ -1688,10 +1691,9 @@ void sp_selection_remove_transform(SPDesktop *desktop) Inkscape::Selection *selection = desktop->getSelection(); - GSList const *l = const_cast(selection->reprList()); - while (l != NULL) { - ((Inkscape::XML::Node*)l->data)->setAttribute("transform", NULL, false); - l = l->next; + SelContainer items = selection->itemList(); + for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + ((Inkscape::XML::Node*)*l)->setAttribute("transform", NULL, false); } DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN, @@ -1789,10 +1791,10 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) if (selection->isEmpty()) return; - GSList const *l = selection->itemList(); + SelContainer items = selection->itemList(); Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw - for (GSList const *l2 = l ; l2 != NULL ; l2 = l2->next) { - SPItem *item = dynamic_cast(static_cast(l2->data)); + for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + SPItem *item = dynamic_cast(static_cast(*l)); if (item) { sp_item_rotate_rel(item, rot_90); } else { @@ -1848,15 +1850,15 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - - GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); - GSList *all_matches = NULL; + SelContainer x,y; + SelContainer all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + SelContainer all_matches; Inkscape::Selection *selection = desktop->getSelection(); - - for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { - SPItem *sel = dynamic_cast(static_cast(sel_iter->data)); - GSList *matches = all_list; + SelContainer items = selection->itemList(); + for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + SPItem *sel = dynamic_cast(static_cast(*sel_iter)); + SelContainer matches = all_list; if (fill) { matches = sp_get_same_fill_or_stroke_color(sel, matches, SP_FILL_COLOR); } @@ -1868,19 +1870,12 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES); matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_MARKERS); } - all_matches = g_slist_concat (all_matches, matches); + all_matches.splice(all_matches.end(), matches); } selection->clear(); selection->setList(all_matches); - if (all_matches) { - g_slist_free(all_matches); - } - if (all_list) { - g_slist_free(all_list); - } - } @@ -1901,14 +1896,15 @@ void sp_select_same_object_type(SPDesktop *desktop) bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - - GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); - GSList *matches = all_list; + SelContainer x,y; + SelContainer all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + SelContainer matches = all_list; Inkscape::Selection *selection = desktop->getSelection(); - for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { - SPItem *sel = dynamic_cast(static_cast(sel_iter->data)); + SelContainer items=selection->itemList(); + for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + SPItem *sel = dynamic_cast(static_cast(*sel_iter)); if (sel) { matches = sp_get_same_object_type(sel, matches); } else { @@ -1919,12 +1915,6 @@ void sp_select_same_object_type(SPDesktop *desktop) selection->clear(); selection->setList(matches); - if (matches) { - g_slist_free(matches); - } - if (all_list) { - g_slist_free(all_list); - } } /* @@ -1944,13 +1934,14 @@ void sp_select_same_stroke_style(SPDesktop *desktop) bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); - GSList *matches = all_list; + SelContainer x,y; + SelContainer matches = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); Inkscape::Selection *selection = desktop->getSelection(); + SelContainer items=selection->itemList(); - for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { - SPItem *sel = dynamic_cast(static_cast(sel_iter->data)); + for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + SPItem *sel = dynamic_cast(static_cast(*sel_iter)); if (sel) { matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_WIDTH); matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES); @@ -1963,27 +1954,21 @@ void sp_select_same_stroke_style(SPDesktop *desktop) selection->clear(); selection->setList(matches); - if (matches) { - g_slist_free(matches); - } - if (all_list) { - g_slist_free(all_list); - } } /* * Find all items in src list that have the same fill or stroke style as sel * Return the list of matching items */ -GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) +SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type) { - GSList *matches = NULL; + SelContainer matches ; gboolean match = false; SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); - for (GSList *i = src; i != NULL; i = i->next) { - SPItem *iter = dynamic_cast(static_cast(i->data)); + for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + SPItem *iter = dynamic_cast(static_cast(*i)); if (iter) { SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); match = false; @@ -2022,7 +2007,7 @@ GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrok } if (match) { - matches = g_slist_prepend(matches, iter); + matches.push_front(iter); } } else { g_assert_not_reached(); @@ -2073,17 +2058,16 @@ static bool item_type_match (SPItem *i, SPItem *j) * Find all items in src list that have the same object type as sel by type * Return the list of matching items */ -GSList *sp_get_same_object_type(SPItem *sel, GSList *src) +SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src) { - GSList *matches = NULL; + SelContainer matches; - for (GSList *i = src; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(static_cast(i->data)); + for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + SPItem *item = dynamic_cast(static_cast(*i)); if (item && item_type_match(sel, item)) { - matches = g_slist_prepend (matches, item); + matches.push_front(item); } } - return matches; } @@ -2091,9 +2075,9 @@ GSList *sp_get_same_object_type(SPItem *sel, GSList *src) * Find all items in src list that have the same stroke style as sel by type * Return the list of matching items */ -GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) +SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type) { - GSList *matches = NULL; + SelContainer matches; gboolean match = false; SPStyle *sel_style = sel->style; @@ -2106,16 +2090,15 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy * Stroke width needs to handle transformations, so call this function * to get the transformed stroke width */ - GSList *objects = NULL; + SelContainer objects; SPStyle *sel_style_for_width = NULL; if (type == SP_STROKE_STYLE_WIDTH) { - objects = g_slist_prepend(objects, sel); + objects.push_front(sel); sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, sel_style_for_width); } - - for (GSList *i = src; i != NULL; i = i->next) { - SPItem *iter = dynamic_cast(static_cast(i->data)); + for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + SPItem *iter = dynamic_cast(static_cast(*i)); if (iter) { SPStyle *iter_style = iter->style; match = false; @@ -2123,15 +2106,15 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy if (type == SP_STROKE_STYLE_WIDTH) { match = (sel_style->stroke_width.set == iter_style->stroke_width.set); if (sel_style->stroke_width.set && iter_style->stroke_width.set) { - GSList *objects = NULL; - objects = g_slist_prepend(objects, iter); + SelContainer objects; + objects.push_front(iter); SPStyle tmp_style(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, &tmp_style); if (sel_style_for_width) { match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed); } - g_slist_free(objects); + objects.clear(); } } else if (type == SP_STROKE_STYLE_DASHES ) { @@ -2154,7 +2137,7 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy } if (match) { - matches = g_slist_prepend(matches, iter); + matches.push_front(iter); } } else { g_assert_not_reached(); @@ -2162,8 +2145,6 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy } if( sel_style_for_width != NULL ) delete sel_style_for_width; - g_slist_free(objects); - return matches; } @@ -2320,11 +2301,11 @@ sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy) namespace { template -SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, +SPItem *next_item(SPDesktop *desktop, SelContainer &path, SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); template -SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, SPObject *root, +SPItem *next_item_from_list(SPDesktop *desktop, SelContainer const &items, SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); struct Forward { @@ -2618,17 +2599,17 @@ void sp_selection_clone(SPDesktop *desktop) return; } - GSList *reprs = g_slist_copy(const_cast(selection->reprList())); + SelContainer reprs (selection->reprList()); selection->clear(); // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need - reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position); + reprs.sort(sp_repr_compare_position_obj); - GSList *newsel = NULL; + SelContainer newsel; - while (reprs) { - Inkscape::XML::Node *sel_repr = static_cast(reprs->data); + while (!reprs.empty()) { + Inkscape::XML::Node *sel_repr = dynamic_cast(reprs.front()); Inkscape::XML::Node *parent = sel_repr->parent(); Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); @@ -2644,8 +2625,8 @@ void sp_selection_clone(SPDesktop *desktop) // add the new clone to the top of the original's parent parent->appendChild(clone); - newsel = g_slist_prepend(newsel, clone); - reprs = g_slist_remove(reprs, sel_repr); + newsel.push_front(dynamic_cast(clone)); + reprs.pop_front(); Inkscape::GC::release(clone); } @@ -2653,8 +2634,6 @@ void sp_selection_clone(SPDesktop *desktop) C_("Action", "Clone")); selection->setReprList(newsel); - - g_slist_free(newsel); } void @@ -2680,11 +2659,9 @@ sp_selection_relink(SPDesktop *desktop) // Get a copy of current selection. bool relinked = false; - for (GSList *items = const_cast(selection->itemList()); - items != NULL; - items = items->next) - { - SPItem *item = static_cast(items->data); + SelContainer items=selection->itemList(); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = static_cast(*i); if (dynamic_cast(item)) { item->getRepr()->setAttribute("xlink:href", newref); @@ -2718,13 +2695,11 @@ sp_selection_unlink(SPDesktop *desktop) } // Get a copy of current selection. - GSList *new_select = NULL; + SelContainer new_select; bool unlinked = false; - for (GSList *items = g_slist_copy(const_cast(selection->itemList())); - items != NULL; - items = items->next) - { - SPItem *item = static_cast(items->data); + SelContainer items=selection->itemList(); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = static_cast(*i); if (dynamic_cast(item)) { SPObject *tspan = sp_tref_convert_to_tspan(item); @@ -2740,7 +2715,7 @@ sp_selection_unlink(SPDesktop *desktop) if (!(dynamic_cast(item) || dynamic_cast(item))) { // keep the non-use item in the new selection - new_select = g_slist_prepend(new_select, item); + new_select.push_front(item); continue; } @@ -2750,7 +2725,7 @@ sp_selection_unlink(SPDesktop *desktop) unlink = use->unlink(); // Unable to unlink use (external or invalid href?) if (!unlink) { - new_select = g_slist_prepend(new_select, item); + new_select.push_front(item); continue; } } else /*if (SP_IS_TREF(use))*/ { @@ -2760,13 +2735,12 @@ sp_selection_unlink(SPDesktop *desktop) unlinked = true; // Add ungrouped items to the new selection. - new_select = g_slist_prepend(new_select, unlink); + new_select.push_front(unlink); } - if (new_select) { // set new selection + if (!new_select.empty()) { // set new selection selection->clear(); selection->setList(new_select); - g_slist_free(new_select); } if (!unlinked) { desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("No clones to unlink in the selection.")); @@ -2789,7 +2763,9 @@ sp_select_clone_original(SPDesktop *desktop) gchar const *error = _("Select a clone to go to its original. Select a linked offset to go to its source. Select a text on path to go to the path. Select a flowed text to go to its frame."); // Check if other than two objects are selected - if (g_slist_length(const_cast(selection->itemList())) != 1 || !item) { + + SelContainer items=selection->itemList(); + if (items.size() != 1 || !item) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); return; } @@ -2886,14 +2862,15 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) Inkscape::SVGOStringStream os; SPObject * firstItem = NULL; - for (const GSList * item = selection->itemList(); item != NULL; item = item->next) { - if (SP_IS_SHAPE(item->data) || SP_IS_TEXT(item->data)) { + SelContainer items=selection->itemList(); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { if (firstItem) { os << "|"; } else { - firstItem = SP_ITEM(item->data); + firstItem = SP_ITEM(*i); } - os << '#' << SP_ITEM(item->data)->getId() << ",0"; + os << '#' << SP_ITEM(*i)->getId() << ",0"; } } if (firstItem) { @@ -2970,12 +2947,12 @@ 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]; - GSList *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items(selection->itemList()); //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items->data)->parent; + SPObject *parent = SP_OBJECT(items.front())->parent; Geom::Affine parent_transform; { @@ -2988,10 +2965,10 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) } // Create a list of duplicates, to be pasted inside marker element. - GSList *repr_copies = NULL; - for (GSList *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); - repr_copies = g_slist_prepend(repr_copies, dup); + SelContainer repr_copies; + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); + repr_copies.push_front(dynamic_cast(dup)); } Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); @@ -2999,8 +2976,8 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) if (apply) { // Delete objects so that their clones don't get alerted; // the objects will be restored inside the marker element. - for (GSList *i = items; i != NULL; i = i->next) { - SPObject *item = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPObject *item = reinterpret_cast(*i); item->deleteObject(false); } } @@ -3019,7 +2996,6 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) prefs->setInt("/options/clonecompensation/value", saved_compensation); - g_slist_free(items); DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, _("Objects to marker")); @@ -3028,8 +3004,9 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { SPGroup *group = dynamic_cast(item); if (group && !dynamic_cast(item) && !wholegroups) { - for (GSList *i = sp_item_group_item_list(group); i != NULL; i = i->next) { - sp_selection_to_guides_recursive(static_cast(i->data), wholegroups); + SelContainer items=sp_item_group_item_list(group); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + sp_selection_to_guides_recursive(static_cast(*i), wholegroups); } } else { item->convert_to_guides(); @@ -3044,9 +3021,9 @@ 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 - GSList *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items(selection->itemList()); - if (!items) { + if (items.empty()) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to convert to guides.")); return; } @@ -3059,8 +3036,8 @@ void sp_selection_to_guides(SPDesktop *desktop) // and its entry in the selection list is invalid (crash). // Therefore: first convert all, then delete all. - for (GSList const *i = items; i != NULL; i = i->next) { - sp_selection_to_guides_recursive(static_cast(i->data), wholegroups); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + sp_selection_to_guides_recursive(static_cast(*i), wholegroups); } if (deleteitems) { @@ -3068,8 +3045,6 @@ void sp_selection_to_guides(SPDesktop *desktop) sp_selection_delete_impl(items); } - g_slist_free(items); - DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); } @@ -3112,18 +3087,18 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) doc->ensureUpToDate(); - GSList *items = g_slist_copy(const_cast(selection->list())); + SelContainer items(selection->list()); // Keep track of parent, this is where will be inserted. - Inkscape::XML::Node *the_first_repr = reinterpret_cast( items->data )->getRepr(); + Inkscape::XML::Node *the_first_repr = reinterpret_cast( items.front() )->getRepr(); Inkscape::XML::Node *the_parent_repr = the_first_repr->parent(); // Find out if we have a single group bool single_group = false; SPGroup *the_group = NULL; Geom::Affine transform; - if( g_slist_length( items ) == 1 ) { - SPObject *object = reinterpret_cast( items->data ); + if( items.size() == 1 ) { + SPObject *object = reinterpret_cast( items.front() ); the_group = dynamic_cast(object); if ( the_group ) { single_group = true; @@ -3134,7 +3109,6 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) if( transform.isTranslation() ) { // Create new list from group children. - g_slist_free(items); items = object->childList(false); // Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals @@ -3180,8 +3154,8 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) } // Move selected items to new - for (GSList *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); repr->parent()->removeChild(repr); symbol_repr->addChild(repr,NULL); } @@ -3207,7 +3181,6 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) // Clean up Inkscape::GC::release(symbol_repr); - g_slist_free(items); DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol")); } @@ -3248,26 +3221,25 @@ void sp_selection_unsymbol(SPDesktop *desktop) desktop->currentLayer()->getRepr()->appendChild(group); // Move all children of symbol to group - GSList* children = symbol->childList(false); + SelContainer children = symbol->childList(false); // Converting a group to a symbol inserts a group for non-translational transform. // In converting a symbol back to a group we strip out the inserted group (or any other // group that only adds a transform to the symbol content). - if( g_slist_length( children ) == 1 ) { - SPObject *object = reinterpret_cast( children->data ); + if( children.size() == 1 ) { + SPObject *object = reinterpret_cast( children.front() ); if ( dynamic_cast( object ) ) { if( object->getAttribute("style") == NULL || object->getAttribute("class") == NULL ) { group->setAttribute("transform", object->getAttribute("transform")); - g_slist_free(children); children = object->childList(false); } } } - for (GSList* i = children; i != NULL; i = i->next ) { - Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); + for (SelContainer::const_iterator i=children.begin();i!=children.end();i++){ + Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); repr->parent()->removeChild(repr); group->addChild(repr,NULL); } @@ -3293,7 +3265,6 @@ void sp_selection_unsymbol(SPDesktop *desktop) // Clean up Inkscape::GC::release(group); - g_slist_free(children); DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol")); } @@ -3328,12 +3299,12 @@ sp_selection_tile(SPDesktop *desktop, bool apply) move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); - GSList *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items (selection->itemList()); - items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); + items.sort(sp_object_compare_position); // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items->data)->parent; + SPObject *parent = SP_OBJECT(items.front())->parent; Geom::Affine parent_transform; @@ -3347,23 +3318,23 @@ sp_selection_tile(SPDesktop *desktop, bool apply) } // remember the position of the first item - gint pos = SP_OBJECT(items->data)->getRepr()->position(); + gint pos = SP_OBJECT(items.front())->getRepr()->position(); // create a list of duplicates - GSList *repr_copies = NULL; - for (GSList *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); - repr_copies = g_slist_prepend(repr_copies, dup); + SelContainer repr_copies; + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); + repr_copies.push_front(dynamic_cast(dup)); } // restore the z-order after prepends - repr_copies = g_slist_reverse(repr_copies); + repr_copies.reverse(); Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); if (apply) { // delete objects so that their clones don't get alerted; this object will be restored shortly - for (GSList *i = items; i != NULL; i = i->next) { - SPObject *item = reinterpret_cast(i->data); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPObject *item = reinterpret_cast(*i); item->deleteObject(false); } } @@ -3409,7 +3380,6 @@ sp_selection_tile(SPDesktop *desktop, bool apply) selection->set(rectangle); } - g_slist_free(items); DocumentUndo::done(doc, SP_VERB_EDIT_TILE, _("Objects to pattern")); @@ -3432,15 +3402,13 @@ void sp_selection_untile(SPDesktop *desktop) return; } - GSList *new_select = NULL; + SelContainer new_select; bool did = false; - for (GSList *items = g_slist_copy(const_cast(selection->itemList())); - items != NULL; - items = items->next) { - - SPItem *item = static_cast(items->data); + SelContainer items(selection->itemList()); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = static_cast(*i); SPStyle *style = item->style; @@ -3476,7 +3444,7 @@ void sp_selection_untile(SPDesktop *desktop) Geom::Affine transform( i->transform * pat_transform ); i->doWriteTransform(i->getRepr(), transform); - new_select = g_slist_prepend(new_select, i); + new_select.push_front(i); } else { g_assert_not_reached(); } @@ -3503,18 +3471,14 @@ void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring return; } - GSList const *reprlst = selection->reprList(); + SelContainer const reprlst = selection->reprList(); bool filename_search = TRUE; bool xdpi_search = TRUE; bool ydpi_search = TRUE; - for (; reprlst != NULL && - filename_search && - xdpi_search && - ydpi_search; - reprlst = reprlst->next) { + for (SelContainer::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){ gchar const *dpi_string; - Inkscape::XML::Node * repr = static_cast(reprlst->data); + Inkscape::XML::Node * repr = dynamic_cast(*i); if (filename_search) { const gchar* tmp = repr->attribute("inkscape:export-filename"); @@ -3600,10 +3564,10 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // List of the items to show; all others will be hidden - GSList *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items(selection->itemList()); // Sort items so that the topmost comes last - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); + items.sort(sp_item_repr_compare_position_obj); // Generate a random value from the current time (you may create bitmap from the same object(s) // multiple times, and this is done so that they don't clash) @@ -3614,7 +3578,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Create the filename. gchar *const basename = g_strdup_printf("%s-%s-%u.png", document->getName(), - SP_OBJECT(items->data)->getRepr()->attribute("id"), + SP_OBJECT(items.front())->getRepr()->attribute("id"), current); // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, // digits, and a few other chars, with "_" @@ -3634,8 +3598,8 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) //g_print("%s\n", filepath); // Remember parent and z-order of the topmost one - gint pos = SP_OBJECT(g_slist_last(items)->data)->getRepr()->position(); - SPObject *parent_object = SP_OBJECT(g_slist_last(items)->data)->parent; + gint pos = SP_OBJECT(items.back())->getRepr()->position(); + SPObject *parent_object = SP_OBJECT(items.back())->parent; Inkscape::XML::Node *parent = parent_object->getRepr(); // Calculate resolution @@ -3727,8 +3691,6 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) true, /*bool force_overwrite,*/ items); - g_slist_free(items); - // Run filter, if any if (run) { g_print("Running external filter: %s\n", run); @@ -3803,22 +3765,22 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) return; } - GSList const *l = const_cast(selection->reprList()); + SelContainer l=selection->reprList(); - GSList *p = g_slist_copy(const_cast(l)); + SelContainer p(l); - p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); + p.sort(sp_repr_compare_position_obj); selection->clear(); - gint topmost = (static_cast(g_slist_last(p)->data))->position(); - Inkscape::XML::Node *topmost_parent = (static_cast(g_slist_last(p)->data))->parent(); + gint topmost = (dynamic_cast(p.back()))->position(); + Inkscape::XML::Node *topmost_parent = (dynamic_cast(p.back()))->parent(); Inkscape::XML::Node *inner = xml_doc->createElement("svg:g"); inner->setAttribute("inkscape:label", "Clip"); - while (p) { - Inkscape::XML::Node *current = static_cast(p->data); + while (!p.empty()) { + Inkscape::XML::Node *current = dynamic_cast(p.front()); if (current->parent() == topmost_parent) { Inkscape::XML::Node *spnew = current->duplicate(xml_doc); @@ -3827,7 +3789,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - GSList *temp_clip = NULL; + SelContainer temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -3843,15 +3805,14 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) // then, if this is clone, looking up its original in that array and pre-multiplying // it by the inverse of that original's transform diff. - sp_selection_copy_one(current, item_t, &temp_clip, xml_doc); + sp_selection_copy_one(current, item_t, temp_clip, xml_doc); sp_repr_unparent(current); // paste into topmost_parent (temporarily) - GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip); - if (temp_clip) g_slist_free(temp_clip); - if (copied) { // if success, + SelContainer copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); + if (!copied.empty()) { // if success, // take pasted object (now in topmost_parent) - Inkscape::XML::Node *in_topmost = static_cast(copied->data); + Inkscape::XML::Node *in_topmost = dynamic_cast(copied.front()); // make a copy Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); // remove pasted @@ -3859,10 +3820,9 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) // put its copy into group inner->appendChild(spnew); Inkscape::GC::release(spnew); - g_slist_free(copied); } } - p = g_slist_remove(p, current); + p.pop_front(); } Inkscape::XML::Node *outer = xml_doc->createElement("svg:g"); @@ -3920,7 +3880,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 || NULL == selection->itemList()->next )) { + } else if (!apply_to_layer && ( is_empty || selection->itemList().size()==1 )) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and object(s) to apply clippath or mask to.")); return; } @@ -3935,9 +3895,9 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ doc->ensureUpToDate(); - GSList *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items(selection->itemList()); - items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); + items.sort(sp_object_compare_position); // See lp bug #542004 selection->clear(); @@ -3946,7 +3906,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ GSList *mask_items = NULL; GSList *apply_to_items = NULL; GSList *items_to_delete = NULL; - GSList *items_to_select = NULL; + SelContainer items_to_select; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool topmost = prefs->getBool("/options/maskobject/topmost", true); @@ -3957,38 +3917,38 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // all selected items are used for mask, which is applied to a layer apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); - for (GSList *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); - SPObject *item = reinterpret_cast(i->data); + SPObject *item = reinterpret_cast(*i); if (remove_original) { items_to_delete = g_slist_prepend(items_to_delete, item); } else { - items_to_select = g_slist_prepend(items_to_select, item); + items_to_select.push_front(item); } } } else if (!topmost) { // topmost item is used as a mask, which is applied to other items in a selection - GSList *i = items; - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(items.front())->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); if (remove_original) { - SPObject *item = reinterpret_cast(i->data); + SPObject *item = reinterpret_cast(items.front()); items_to_delete = g_slist_prepend(items_to_delete, item); } - for (i = i->next; i != NULL; i = i->next) { - apply_to_items = g_slist_prepend(apply_to_items, i->data); - items_to_select = g_slist_prepend(items_to_select, i->data); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + if(i==items.begin())continue; + apply_to_items = g_slist_prepend(apply_to_items, *i); + items_to_select.push_front(*i); } } else { GSList *i = NULL; - for (i = items; NULL != i->next; i = i->next) { - apply_to_items = g_slist_prepend(apply_to_items, i->data); - items_to_select = g_slist_prepend(items_to_select, i->data); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + apply_to_items = g_slist_prepend(apply_to_items, *i); + items_to_select.push_front(*i); } Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); @@ -3999,9 +3959,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_delete = g_slist_prepend(items_to_delete, item); } } - - g_slist_free(items); - items = NULL; + items.clear(); if (apply_to_items && grouping == PREFS_MASKOBJECT_GROUPING_ALL) { // group all those objects into one group @@ -4011,24 +3969,22 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // make a note we should ungroup this when unsetting mask group->setAttribute("inkscape:groupmode", "maskhelper"); - GSList *reprs_to_group = NULL; + SelContainer reprs_to_group; for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { - reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT(i->data)->getRepr()); - items_to_select = g_slist_remove(items_to_select, i->data); + reprs_to_group.push_front(dynamic_cast(SP_OBJECT(i->data)->getRepr())); + items_to_select.remove(static_cast(i->data)); } - reprs_to_group = g_slist_reverse(reprs_to_group); + reprs_to_group.reverse(); sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); - reprs_to_group = NULL; - // apply clip/mask only to newly created group g_slist_free(apply_to_items); apply_to_items = NULL; apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group)); - items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group)); + items_to_select.push_front(doc->getObjectByRepr(group)); Inkscape::GC::release(group); } @@ -4068,7 +4024,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ Inkscape::XML::Node *spnew = current->duplicate(xml_doc); gint position = current->position(); - items_to_select = g_slist_remove(items_to_select, item); + items_to_select.remove(item); current->parent()->appendChild(group); sp_repr_unparent(current); group->appendChild(spnew); @@ -4077,7 +4033,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // Apply clip/mask to group instead apply_mask_to = group; - items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group)); + items_to_select.push_front(doc->getObjectByRepr(group)); Inkscape::GC::release(spnew); Inkscape::GC::release(group); } @@ -4092,14 +4048,13 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ for (GSList *i = items_to_delete; NULL != i; i = i->next) { SPObject *item = reinterpret_cast(i->data); item->deleteObject(false); - items_to_select = g_slist_remove(items_to_select, item); + items_to_select.remove(item); } g_slist_free(items_to_delete); - items_to_select = g_slist_reverse(items_to_select); + items_to_select.reverse(); selection->addList(items_to_select); - g_slist_free(items_to_select); if (apply_clip_path) { DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); @@ -4131,20 +4086,20 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map referenced_objects; - GSList *items = g_slist_copy(const_cast(selection->itemList())); + SelContainer items(selection->itemList()); selection->clear(); GSList *items_to_ungroup = NULL; - GSList *items_to_select = g_slist_copy(items); - items_to_select = g_slist_reverse(items_to_select); + SelContainer items_to_select(items); + items_to_select.reverse(); // SPObject* refers to a group containing the clipped path or mask itself, // whereas SPItem* refers to the item being clipped or masked - for (GSList const *i = items; NULL != i; i = i->next) { + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ if (remove_original) { // remember referenced mask/clippath, so orphaned masks can be moved back to document - SPItem *item = reinterpret_cast(i->data); + SPItem *item = reinterpret_cast(*i); Inkscape::URIReference *uri_ref = NULL; if (apply_clip_path) { @@ -4159,9 +4114,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { } } - SP_OBJECT(i->data)->getRepr()->setAttribute(attributeName, "none"); + SP_OBJECT(*i)->getRepr()->setAttribute(attributeName, "none"); - SPGroup *group = dynamic_cast(static_cast(i->data)); + SPGroup *group = dynamic_cast(static_cast(*i)); if (ungroup_masked && group) { // if we had previously enclosed masked object in group, // add it to list so we can ungroup it later @@ -4173,7 +4128,6 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { } } - g_slist_free(items); // restore mask objects into a document for ( std::map::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { @@ -4207,7 +4161,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0); SPItem *mask_item = static_cast(desktop->getDocument()->getObjectByRepr(repr)); - items_to_select = g_slist_prepend(items_to_select, mask_item); + items_to_select.push_front(mask_item); // transform mask, so it is moved the same spot where mask was applied Geom::Affine transform(mask_item->transform); @@ -4222,10 +4176,10 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { SPGroup *group = dynamic_cast(static_cast(i->data)); if (group) { - items_to_select = g_slist_remove(items_to_select, group); - GSList *children = NULL; - sp_item_group_ungroup(group, &children, false); - items_to_select = g_slist_concat(children, items_to_select); + items_to_select.remove(group); + SelContainer children; + sp_item_group_ungroup(group, children, false); + items_to_select.splice(items_to_select.begin(),children); } else { g_assert_not_reached(); } @@ -4234,9 +4188,8 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { g_slist_free(items_to_ungroup); // rebuild selection - items_to_select = g_slist_reverse(items_to_select); + items_to_select.reverse(); selection->addList(items_to_select); - g_slist_free(items_to_select); if (apply_clip_path) { DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index d86906548..bc317d556 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -19,6 +19,7 @@ #include <2geom/forward.h> #include "sp-item.h" +#include "selection.h" class SPCSSAttr; class SPDesktop; @@ -142,9 +143,9 @@ enum SPSelectStrokeStyleType { void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style); void sp_select_same_stroke_style(SPDesktop *desktop); void sp_select_same_object_type(SPDesktop *desktop); -GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type); -GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type); -GSList *sp_get_same_object_type(SPItem *sel, GSList *src); +SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type); +SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type); +SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src); void scroll_to_show_item(SPDesktop *desktop, SPItem *item); @@ -171,9 +172,9 @@ void unlock_all_in_all_layers(SPDesktop *dt); void unhide_all(SPDesktop *dt); void unhide_all_in_all_layers(SPDesktop *dt); -GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude); +SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, SelContainer const &exclude); -GSList *sp_degroup_list (GSList *items); +SelContainer sp_degroup_list (SelContainer &items); /* selection cycling */ typedef enum diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index f7814fd57..0625c4002 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -40,14 +40,14 @@ #include "sp-spiral.h" // Returns a list of terms for the items to be used in the statusbar -char* collect_terms (GSList *items) +char* collect_terms (const SelContainer &items) { GSList *check = NULL; std::stringstream ss; bool first = true; - for (GSList *i = (GSList *)items; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(reinterpret_cast(i->data)); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *item = dynamic_cast(reinterpret_cast(*iter)); if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -61,12 +61,12 @@ char* collect_terms (GSList *items) } // Returns the number of terms in the list -static int count_terms (GSList *items) +static int count_terms (const SelContainer &items) { GSList *check = NULL; int count=0; - for (GSList *i = (GSList *)items; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(reinterpret_cast(i->data)); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *item = dynamic_cast(reinterpret_cast(*iter)); if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -79,11 +79,11 @@ static int count_terms (GSList *items) } // Returns the number of filtered items in the list -static int count_filtered (GSList *items) +static int count_filtered (const SelContainer &items) { int count=0; - for (GSList *i = items; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(reinterpret_cast((i->data))); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *item = dynamic_cast(reinterpret_cast((*iter))); if (item) { count += item->isFiltered(); } @@ -122,12 +122,12 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin } void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { - GSList const *items = selection->itemList(); + SelContainer const items = selection->itemList(); - if (!items) { // no items + if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); } else { - SPItem *item = dynamic_cast(reinterpret_cast(items->data)); + SPItem *item = dynamic_cast(reinterpret_cast(items.front())); g_assert(item != NULL); SPObject *layer = selection->layers()->layerForObject(item); SPObject *root = selection->layers()->currentRoot(); @@ -188,7 +188,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select g_free (layer_name); g_free (parent_name); - if (!items->next) { // one item + if (items.size()==1) { // one item char *item_desc = item->detailedDescription(); bool isUse = dynamic_cast(item) != NULL; @@ -228,9 +228,9 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select g_free(item_desc); } else { // multiple items - int objcount = g_slist_length((GSList *)items); - char *terms = collect_terms ((GSList *)items); - int n_terms = count_terms((GSList *)items); + int objcount = items.size(); + char *terms = collect_terms (items); + int n_terms = count_terms(items); gchar *objects_str = g_strdup_printf(ngettext( "%i objects selected of type %s", @@ -241,7 +241,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select // indicate all, some, or none filtered gchar *filt_str = NULL; - int n_filt = count_filtered((GSList *)items); //all filtered + int n_filt = count_filtered(items); //all filtered if (n_filt) { filt_str = g_strdup_printf(ngettext("; %d filtered object ", "; %d filtered objects ", n_filt), n_filt); diff --git a/src/selection.cpp b/src/selection.cpp index 81139d044..b509f4272 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -42,9 +42,9 @@ namespace Inkscape { Selection::Selection(LayerModel *layers, SPDesktop *desktop) : - _objs(NULL), - _reprs(NULL), - _items(NULL), + _objs(SelContainer()), + _reprs(SelContainer()), + _items(SelContainer()), _layers(layers), _desktop(desktop), _selection_context(NULL), @@ -121,17 +121,14 @@ Selection::_releaseContext(SPObject *obj) } void Selection::_invalidateCachedLists() { - g_slist_free(_items); - _items = NULL; - - g_slist_free(_reprs); - _reprs = NULL; + _items.clear(); + _reprs.clear(); } void Selection::_clear() { _invalidateCachedLists(); - while (_objs) { - SPObject *obj=reinterpret_cast(_objs->data); + while (!_objs.empty()) { + SPObject *obj=reinterpret_cast(_objs.front()); _remove(obj); } } @@ -148,7 +145,7 @@ bool Selection::includes(SPObject *obj) const { g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE); - return ( g_slist_find(_objs, obj) != NULL ); + return ( find(_objs.begin(),_objs.end(),obj)!=_objs.end() ); } void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) { @@ -180,7 +177,7 @@ void Selection::_add(SPObject *obj) { _removeObjectDescendants(obj); _removeObjectAncestors(obj); - _objs = g_slist_prepend(_objs, obj); + _objs.push_front(obj); add_3D_boxes_recursively(obj); @@ -234,26 +231,26 @@ void Selection::_remove(SPObject *obj) { remove_3D_boxes_recursively(obj); - _objs = g_slist_remove(_objs, obj); + _objs.remove(obj); } -void Selection::setList(GSList const *list) { +void Selection::setList(SelContainer const &list) { // Clear and add, or just clear with emit. - if (list != NULL) { + if (!list.empty()) { _clear(); addList(list); } else clear(); } -void Selection::addList(GSList const *list) { +void Selection::addList(SelContainer const &list) { - if (list == NULL) + if (list.empty()) return; _invalidateCachedLists(); - for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) { - SPObject *obj = reinterpret_cast(iter->data); + for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { + SPObject *obj = reinterpret_cast(*iter); if (includes(obj)) continue; _add (obj); } @@ -261,11 +258,11 @@ void Selection::addList(GSList const *list) { _emitChanged(); } -void Selection::setReprList(GSList const *list) { +void Selection::setReprList(SelContainer const &list) { _clear(); - for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) { - SPObject *obj=_objectForXMLNode(reinterpret_cast(iter->data)); + for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { + SPObject *obj=_objectForXMLNode(reinterpret_cast(*iter)); if (obj) { _add(obj); } @@ -279,34 +276,34 @@ void Selection::clear() { _emitChanged(); } -GSList const *Selection::list() { +SelContainer const &Selection::list() { return _objs; } -GSList const *Selection::itemList() { - if (_items) { +SelContainer const &Selection::itemList() { + if (!_items.empty()) { return _items; } - for ( GSList const *iter=_objs ; iter != NULL ; iter = iter->next ) { - SPObject *obj=reinterpret_cast(iter->data); + for ( SelContainer::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { + SPObject *obj=reinterpret_cast(*iter); if (SP_IS_ITEM(obj)) { - _items = g_slist_prepend(_items, SP_ITEM(obj)); + _items.push_front(SP_ITEM(obj)); } } - _items = g_slist_reverse(_items); + _items.reverse(); return _items; } -GSList const *Selection::reprList() { - if (_reprs) { return _reprs; } - - for ( GSList const *iter=itemList() ; iter != NULL ; iter = iter->next ) { - SPObject *obj=reinterpret_cast(iter->data); - _reprs = g_slist_prepend(_reprs, obj->getRepr()); +SelContainer const &Selection::reprList() { + if (!_reprs.empty()) { return _reprs; } + SelContainer list = itemList(); + for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { + SPObject *obj=reinterpret_cast(*iter); + _reprs.push_front(dynamic_cast(obj->getRepr())); } - _reprs = g_slist_reverse(_reprs); + _reprs.reverse(); return _reprs; } @@ -337,17 +334,17 @@ std::list const Selection::box3DList(Persp3D *persp) { } SPObject *Selection::single() { - if ( _objs != NULL && _objs->next == NULL ) { - return reinterpret_cast(_objs->data); + if ( _objs.size() == 1 ) { + return reinterpret_cast(_objs.front()); } else { return NULL; } } SPItem *Selection::singleItem() { - GSList const *items=itemList(); - if ( items != NULL && items->next == NULL ) { - return reinterpret_cast(items->data); + SelContainer const items=itemList(); + if ( !items.size()==1) { + return reinterpret_cast(items.front()); } else { return NULL; } @@ -362,12 +359,12 @@ SPItem *Selection::largestItem(Selection::CompareSize compare) { } SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { - GSList const *items = const_cast(this)->itemList(); + SelContainer const items = const_cast(this)->itemList(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; - for ( GSList const *i = items; i != NULL ; i = i->next ) { - Geom::OptRect obox = SP_ITEM(i->data)->desktopPreferredBounds(); + for ( SelContainer::const_iterator i=items.begin();i!=items.end();i++ ) { + Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); if (!obox || obox.isEmpty()) continue; Geom::Rect bbox = *obox; @@ -376,7 +373,7 @@ SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { size = sml ? size : size * -1; if (size < max) { max = size; - ist = SP_ITEM(i->data); + ist = SP_ITEM(*i); } } return ist; @@ -395,22 +392,22 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect Selection::geometricBounds() const { - GSList const *items = const_cast(this)->itemList(); + SelContainer const items = const_cast(this)->itemList(); Geom::OptRect bbox; - for ( GSList const *i = items ; i != NULL ; i = i->next ) { - bbox.unionWith(SP_ITEM(i->data)->desktopGeometricBounds()); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); } return bbox; } Geom::OptRect Selection::visualBounds() const { - GSList const *items = const_cast(this)->itemList(); + SelContainer const items = const_cast(this)->itemList(); Geom::OptRect bbox; - for ( GSList const *i = items ; i != NULL ; i = i->next ) { - bbox.unionWith(SP_ITEM(i->data)->desktopVisualBounds()); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); } return bbox; } @@ -427,11 +424,11 @@ Geom::OptRect Selection::preferredBounds() const Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; - GSList const *items = const_cast(this)->itemList(); - if (!items) return bbox; + SelContainer const items = const_cast(this)->itemList(); + if (items.empty()) return bbox; - for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) { - SPItem *item = SP_ITEM(iter->data); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *item = SP_ITEM(*iter); bbox |= item->documentBounds(type); } @@ -441,9 +438,9 @@ Geom::OptRect Selection::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 Selection::center() const { - GSList *items = (GSList *) const_cast(this)->itemList(); - if (items) { - SPItem *first = reinterpret_cast(g_slist_last(items)->data); // from the first item in selection + SelContainer const items = const_cast(this)->itemList(); + if (!items.empty()) { + SPItem *first = reinterpret_cast(items.back()); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly return first->getCenter(); } @@ -457,13 +454,13 @@ boost::optional Selection::center() const { } std::vector Selection::getSnapPoints(SnapPreferences const *snapprefs) const { - GSList const *items = const_cast(this)->itemList(); + SelContainer const items = const_cast(this)->itemList(); 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 p; - for (GSList const *iter = items; iter != NULL; iter = iter->next) { - SPItem *this_item = SP_ITEM(iter->data); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *this_item = SP_ITEM(*iter); this_item->getSnappoints(p, &snapprefs_dummy); //Include the transformation origin for snapping @@ -477,10 +474,8 @@ std::vector Selection::getSnapPoints(SnapPreferenc } void Selection::_removeObjectDescendants(SPObject *obj) { - GSList *iter, *next; - for ( iter = _objs ; iter ; iter = next ) { - next = iter->next; - SPObject *sel_obj=reinterpret_cast(iter->data); + for ( SelContainer::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { + SPObject *sel_obj=reinterpret_cast(*iter); SPObject *parent = sel_obj->parent; while (parent) { if ( parent == obj ) { @@ -511,32 +506,24 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { return object; } -guint Selection::numberOfLayers() { - GSList const *items = const_cast(this)->itemList(); - GSList *layers = NULL; - for (GSList const *iter = items; iter != NULL; iter = iter->next) { - SPObject *layer = _layers->layerForObject(SP_OBJECT(iter->data)); - if (g_slist_find (layers, layer) == NULL) { - layers = g_slist_prepend (layers, layer); - } +uint Selection::numberOfLayers() { + SelContainer const items = const_cast(this)->itemList(); + std::set layers; + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPObject *layer = _layers->layerForObject(SP_OBJECT(*iter)); + layers.insert(layer); } - guint ret = g_slist_length (layers); - g_slist_free (layers); - return ret; + return layers.size(); } guint Selection::numberOfParents() { - GSList const *items = const_cast(this)->itemList(); - GSList *parents = NULL; - for (GSList const *iter = items; iter != NULL; iter = iter->next) { - SPObject *parent = SP_OBJECT(iter->data)->parent; - if (g_slist_find (parents, parent) == NULL) { - parents = g_slist_prepend (parents, parent); - } + SelContainer const items = const_cast(this)->itemList(); + std::set parents; + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPObject *parent = SP_OBJECT(*iter)->parent; + parents.insert(parent); } - guint ret = g_slist_length (parents); - g_slist_free (parents); - return ret; + return parents.size(); } } diff --git a/src/selection.h b/src/selection.h index 5964b20e8..7171b8742 100644 --- a/src/selection.h +++ b/src/selection.h @@ -19,6 +19,11 @@ #include #include +#include +#include +#include +#include + #include "gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" @@ -26,11 +31,13 @@ #include "sp-item.h" + class SPDesktop; class SPItem; class SPBox3D; class Persp3D; -typedef struct _GSList GSList; + +typedef std::list SelContainer; namespace Inkscape { class LayerModel; @@ -39,6 +46,15 @@ class Node; } } +/*template +const GSList* std_list_to_GS_list(const std::list list) const +{ + gpointer l=NULL; + for(auto x:list){ + + } +}*/ + namespace Inkscape { /** @@ -154,21 +170,21 @@ public: * * @param objs the objects to select */ - void setList(GSList const *objs); + void setList(SelContainer const &objs); /** * Adds the specified objects to selection, without deselecting first. * * @param objs the objects to select */ - void addList(GSList const *objs); + void addList(SelContainer const &objs); /** * Clears the selection and selects the specified objects. * * @param repr a list of xml nodes for the items to select */ - void setReprList(GSList const *reprs); + void setReprList(std::list const &reprs); /** Add items from an STL iterator range to the selection. * \param from the begin iterator @@ -192,7 +208,7 @@ public: /** * Returns true if no items are selected. */ - bool isEmpty() const { return _objs == NULL; } + bool isEmpty() const { return _objs.empty(); } /** * Returns true if the given object is selected. @@ -238,13 +254,13 @@ public: XML::Node *singleRepr(); /** Returns the list of selected objects. */ - GSList const *list(); + std::list const &list(); /** Returns the list of selected SPItems. */ - GSList const *itemList(); + std::list const &itemList(); /** Returns a list of the xml nodes of all selected objects. */ /// \todo only returns reprs of SPItems currently; need a separate /// method for that - GSList const *reprList(); + std::list const &reprList(); /** Returns a list of all perspectives which have a 3D box in the current selection. (these may also be nested in groups) */ @@ -360,9 +376,9 @@ private: /** Releases an active layer object that is being removed. */ void _releaseContext(SPObject *obj); - mutable GSList *_objs; - mutable GSList *_reprs; - mutable GSList *_items; + mutable std::list _objs; + mutable std::list _reprs; + mutable std::list _items; void add_box_perspective(SPBox3D *box); void add_3D_boxes_recursively(SPObject *obj); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 5e4c0642e..8c06356db 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -112,7 +112,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _opposite_for_bboxpoints(Geom::Point(0,0)), _origin_for_specpoints(Geom::Point(0,0)), _origin_for_bboxpoints(Geom::Point(0,0)), - _stamp_cache(NULL), + _stamp_cache(SelContainer()), _message_context(desktop->messageStack()), _bounding_box_prefs_observer(*this) { @@ -239,8 +239,9 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { - SPItem *it = SP_ITEM(l->data); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = SP_ITEM(*iter); it->setCenter(p); // only set the value; updating repr and document_done will be done once, on ungrab } @@ -268,8 +269,9 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - for (GSList const *l = selection->itemList(); l; l = l->next) { - SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(l->data), NULL)); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(*iter), NULL)); _items.push_back(it); _items_const.push_back(it); _items_affines.push_back(it->i2dt_affine()); @@ -370,7 +372,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s } _updateHandles(); - g_return_if_fail(_stamp_cache == NULL); + g_return_if_fail(_stamp_cache.empty()); } void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point const &norm) @@ -433,9 +435,8 @@ void Inkscape::SelTrans::ungrab() sp_canvas_item_hide(_l[i]); } - if (_stamp_cache) { - g_slist_free(_stamp_cache); - _stamp_cache = NULL; + if (!_stamp_cache.empty()) { + _stamp_cache.clear(); } _message_context.clear(); @@ -491,8 +492,9 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { - SPItem *it = SP_ITEM(l->data); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = SP_ITEM(*iter); it->updateRepr(); } DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, @@ -515,26 +517,25 @@ void Inkscape::SelTrans::stamp() Inkscape::Selection *selection = _desktop->getSelection(); bool fixup = !_grabbed; - if ( fixup && _stamp_cache ) { + if ( fixup && !_stamp_cache.empty() ) { // TODO - give a proper fix. Simple temporary work-around for the grab() issue - g_slist_free(_stamp_cache); - _stamp_cache = NULL; + _stamp_cache.clear(); } /* stamping mode */ if (!_empty) { - GSList *l; - if (_stamp_cache) { + SelContainer l; + if (!_stamp_cache.empty()) { l = _stamp_cache; } else { /* Build cache */ - l = g_slist_copy((GSList *) selection->itemList()); - l = g_slist_sort(l, (GCompareFunc) sp_object_compare_position); + l = selection->itemList(); + l.sort(sp_object_compare_position); _stamp_cache = l; } - while (l) { - SPItem *original_item = SP_ITEM(l->data); + for(SelContainer::const_iterator x=l.begin();x!=l.end();x++) { + SPItem *original_item = SP_ITEM(*x); Inkscape::XML::Node *original_repr = original_item->getRepr(); // remember the position of the item @@ -568,16 +569,14 @@ void Inkscape::SelTrans::stamp() } Inkscape::GC::release(copy_repr); - l = l->next; } DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, _("Stamp")); } - if ( fixup && _stamp_cache ) { + if ( fixup && !_stamp_cache.empty() ) { // TODO - give a proper fix. Simple temporary work-around for the grab() issue - g_slist_free(_stamp_cache); - _stamp_cache = NULL; + _stamp_cache.clear(); } } @@ -712,8 +711,9 @@ 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 - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { - SPItem *it = SP_ITEM(l->data); + SelContainer items=_desktop->selection->itemList(); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *it = SP_ITEM(*iter); it->unsetCenter(); it->updateRepr(); _center_is_set = false; // center has changed @@ -1283,7 +1283,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 - GSList *items = (GSList *) const_cast(_selection)->itemList(); + SelContainer items = const_cast(_selection)->itemList(); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); diff --git a/src/seltrans.h b/src/seltrans.h index d5db1542d..8f9c329ed 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -187,7 +187,7 @@ private: SPCtrlLine *_l[4]; unsigned int _sel_changed_id; unsigned int _sel_modified_id; - GSList *_stamp_cache; + SelContainer _stamp_cache; Geom::Point _origin; ///< position of origin for transforms Geom::Point _point; ///< original position of the knot being used for the current transform diff --git a/src/snap.cpp b/src/snap.cpp index 8138e4546..a7145b834 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -43,7 +43,7 @@ SnapManager::SnapManager(SPNamedView const *v) : object(this, 0), snapprefs(), _named_view(v), - _rotation_center_source_items(NULL), + _rotation_center_source_items(SelContainer()), _guide_to_ignore(NULL), _desktop(NULL), _snapindicator(true), @@ -1013,7 +1013,7 @@ void SnapManager::setup(SPDesktop const *desktop, _snapindicator = snapindicator; _unselected_nodes = unselected_nodes; _guide_to_ignore = guide_to_ignore; - _rotation_center_source_items = NULL; + _rotation_center_source_items.clear(); } void SnapManager::setup(SPDesktop const *desktop, @@ -1031,7 +1031,7 @@ void SnapManager::setup(SPDesktop const *desktop, _snapindicator = snapindicator; _unselected_nodes = unselected_nodes; _guide_to_ignore = guide_to_ignore; - _rotation_center_source_items = NULL; + _rotation_center_source_items.clear(); } /// Setup, taking the list of items to ignore from the desktop's selection. @@ -1049,13 +1049,13 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, _snapindicator = snapindicator; _unselected_nodes = unselected_nodes; _guide_to_ignore = guide_to_ignore; - _rotation_center_source_items = NULL; + _rotation_center_source_items.clear(); _items_to_ignore.clear(); Inkscape::Selection *sel = _desktop->selection; - GSList const *items = sel->itemList(); - for (GSList *i = const_cast(items); i; i = i->next) { - _items_to_ignore.push_back(static_cast(i->data)); + SelContainer const items = sel->itemList(); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + _items_to_ignore.push_back(static_cast(*i)); } } diff --git a/src/snap.h b/src/snap.h index 20b2b246f..012eb072b 100644 --- a/src/snap.h +++ b/src/snap.h @@ -136,7 +136,7 @@ public: std::vector *unselected_nodes = NULL, SPGuide *guide_to_ignore = NULL); - void unSetup() {_rotation_center_source_items = NULL; + void unSetup() {_rotation_center_source_items.clear(); _guide_to_ignore = NULL; _desktop = NULL; _unselected_nodes = NULL;} @@ -145,8 +145,8 @@ public: // of this rotation center; this reference is used to make sure that we do not snap a rotation // center to itself // NOTE: Must be called after calling setup(), not before! - void setRotationCenterSource(GSList *items) {_rotation_center_source_items = items;} - GSList const *getRotationCenterSource() {return _rotation_center_source_items;} + void setRotationCenterSource(const SelContainer &items) {_rotation_center_source_items = items;} + SelContainer getRotationCenterSource() {return _rotation_center_source_items;} // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a // point if snapping has occurred (by overwriting p); otherwise p is untouched @@ -490,7 +490,7 @@ protected: private: std::vector _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method - GSList *_rotation_center_source_items; // to avoid snapping a rotation center to itself + SelContainer _rotation_center_source_items; // to avoid snapping a rotation center to itself SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged SPDesktop const *_desktop; bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index 3e5398ced..bd139277d 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -50,8 +50,9 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p // consider all first-order children double child_pos = 0.0; - for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) { - SPItem* child_item = SP_ITEM(i->data); + SelContainer g = sp_item_group_item_list(group); + for (SelContainer::const_iterator i = g.begin();i!=g.end();i++) { + SPItem* child_item = SP_ITEM(*i); try_get_intersect_point_with_item_recursive(conn_pv, child_item, item_transform * child_item->transform, child_pos); if (intersect_pos < child_pos) diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index 334570076..d52fa038a 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -46,11 +46,10 @@ void SPDefs::update(SPCtx *ctx, guint flags) { } flags &= SP_OBJECT_MODIFIED_CASCADE; - - GSList *l = g_slist_reverse(this->childList(true)); - while (l) { - SPObject *child = SP_OBJECT(l->data); - l = g_slist_remove(l, child); + SelContainer l(this->childList(true)); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *child = SP_OBJECT(*i); if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); } diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 9cb33a6f3..bf8f7a5a4 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -244,11 +244,10 @@ void SPFilter::update(SPCtx *ctx, guint flags) { childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } childflags &= SP_OBJECT_MODIFIED_CASCADE; - - GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate)); - while (l) { - SPObject *child = SP_OBJECT (l->data); - l = g_slist_remove (l, child); + SelContainer l(this->childList(true, SPObject::ActionUpdate)); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *child = SP_OBJECT (*i); if( SP_IS_FILTER_PRIMITIVE( child ) ) { child->updateDisplay(ctx, childflags); } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index b1ba37de2..e6531c6be 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -171,11 +171,10 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } childflags &= SP_OBJECT_MODIFIED_CASCADE; - - GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate)); - while (l) { - SPObject *child = SP_OBJECT (l->data); - l = g_slist_remove (l, child); + SelContainer l=this->childList(true, SPObject::ActionUpdate); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *child = SP_OBJECT (*i); if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { SPItem *item = dynamic_cast(child); @@ -211,20 +210,16 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { void SPGroup::modified(guint flags) { // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl; SPLPEItem::modified(flags); - - SPObject *child; - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = g_slist_reverse(this->childList(true)); - - while (l) { - child = SP_OBJECT (l->data); - l = g_slist_remove (l, child); + SelContainer l=this->childList(true); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *child = SP_OBJECT (*i); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); @@ -296,35 +291,28 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox Geom::OptRect bbox; // TODO CPPIFY: replace this const_cast later - GSList *l = const_cast(this)->childList(false, SPObject::ActionBBox); - - while (l) { - SPObject *o = SP_OBJECT (l->data); - + SelContainer l=const_cast(this)->childList(false, SPObject::ActionBBox); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast(o); if (item && !item->isHidden()) { Geom::Affine const ct(item->transform * transform); bbox |= item->bounds(bboxtype, ct); } - - l = g_slist_remove (l, o); } return bbox; } void SPGroup::print(SPPrintContext *ctx) { - GSList *l = g_slist_reverse(this->childList(false)); - - while (l) { - SPObject *o = SP_OBJECT (l->data); - + SelContainer l=this->childList(false); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast(o); if (item) { item->invoke_print(ctx); } - - l = g_slist_remove (l, o); } } @@ -372,17 +360,15 @@ Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int k } void SPGroup::hide (unsigned int key) { - GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); - - while (l) { - SPObject *o = SP_OBJECT (l->data); + SelContainer l=this->childList(false, SPObject::ActionShow); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast(o); if (item) { item->invoke_hide(key); } - - l = g_slist_remove (l, o); } // SPLPEItem::onHide(key); @@ -401,7 +387,7 @@ void SPGroup::snappoints(std::vector &p, Inkscape: void -sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) +sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) { g_return_if_fail (group != NULL); @@ -560,8 +546,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) } Inkscape::GC::release(repr); - if (children && item) { - *children = g_slist_prepend(*children, item); + if (!children.empty() && item) { + children.push_front(dynamic_cast(item)); } items = g_slist_remove (items, items->data); @@ -576,19 +562,18 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) * some API for list aspect of SPGroup */ -GSList *sp_item_group_item_list(SPGroup * group) +SelContainer sp_item_group_item_list(SPGroup * group) { - g_return_val_if_fail(group != NULL, NULL); - - GSList *s = NULL; + SelContainer s; + g_return_val_if_fail(group != NULL, s); for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { if ( dynamic_cast(o) ) { - s = g_slist_prepend(s, o); + s.push_front(o); } } - - return g_slist_reverse (s); + s.reverse(); + return s; } SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name) @@ -809,9 +794,10 @@ gint SPGroup::getItemCount() const { void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { Inkscape::DrawingItem *ac = NULL; - GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); - while (l) { - SPObject *o = SP_OBJECT (l->data); + SelContainer l=this->childList(false, SPObject::ActionShow); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem * child = dynamic_cast(o); if (child) { ac = child->invoke_show (drawing, key, flags); @@ -819,7 +805,6 @@ void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem * ai->appendChild(ac); } } - l = g_slist_remove (l, o); } } @@ -828,10 +813,10 @@ void SPGroup::update_patheffect(bool write) { g_message("sp_group_update_patheffect: %p\n", lpeitem); #endif - GSList const *item_list = sp_item_group_item_list(this); + SelContainer const item_list = sp_item_group_item_list(this); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); SPLPEItem *lpeItem = dynamic_cast(subitem); if (lpeItem) { @@ -856,10 +841,10 @@ void SPGroup::update_patheffect(bool write) { static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList const *item_list = sp_item_group_item_list(group); + SelContainer const item_list = sp_item_group_item_list(group); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); SPGroup *subGroup = dynamic_cast(subitem); if (subGroup) { diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 15bb58f22..9a5ee0161 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -15,6 +15,7 @@ #include #include "sp-lpe-item.h" +#include "selection.h"//SelContainer #define SP_GROUP(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_GROUP(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -95,10 +96,10 @@ public: virtual void update_patheffect(bool write); }; -void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true); +void sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done = true); -GSList *sp_item_group_item_list (SPGroup *group); +SelContainer sp_item_group_item_list (SPGroup *group); SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name); #endif diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index f059ab531..1305efd83 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -353,9 +353,9 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); } if (SP_IS_GROUP(lpeitem)) { - GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem)); } @@ -387,9 +387,9 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); } } - GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); } @@ -680,9 +680,9 @@ SPLPEItem::apply_to_clippath(SPItem *item) } } if(SP_IS_GROUP(item)){ - GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); apply_to_clippath(SP_ITEM(subitem)); } } @@ -732,9 +732,9 @@ SPLPEItem::apply_to_mask(SPItem *item) } } if(SP_IS_GROUP(item)){ - GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); apply_to_mask(SP_ITEM(subitem)); } } @@ -746,9 +746,9 @@ SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item) if (!SP_IS_GROUP(group)) { return; } - GSList *item_list = sp_item_group_item_list(SP_GROUP(group)); - for ( GSList *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast(iter->data); + SelContainer item_list = sp_item_group_item_list(SP_GROUP(group)); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast(*iter); if (SP_IS_GROUP(subitem)) { apply_to_clip_or_mask_group(SP_ITEM(subitem), item); } else if (SP_IS_SHAPE(subitem)) { diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 371a6c35c..66b445265 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -429,7 +429,7 @@ sp_marker_hide (SPMarker *marker, unsigned int key) } -const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) +const gchar *generate_marker(SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -452,8 +452,8 @@ const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *docum const gchar *mark_id = repr->attribute("id"); SPObject *mark_object = document->getObjectById(mark_id); - for (GSList *i = reprs; i != NULL; i = i->next) { - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); + for (SelContainer::const_iterator i=reprs.begin();i!=reprs.end();i++){ + Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-marker.h b/src/sp-marker.h index e804fd7dc..594c164c5 100644 --- a/src/sp-marker.h +++ b/src/sp-marker.h @@ -101,7 +101,7 @@ Inkscape::DrawingItem *sp_marker_show_instance (SPMarker *marker, Inkscape::Draw unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); -const char *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); +const char *generate_marker (SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); SPObject *sp_marker_fork_if_necessary(SPObject *marker); #endif diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 7d24a978e..3ea480f66 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -382,14 +382,14 @@ void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr) sp_repr_css_change(this->getRepr(), css, attr); } -GSList *SPObject::childList(bool add_ref, Action) { - GSList *l = NULL; +SelContainer SPObject::childList(bool add_ref, Action) { + SelContainer l; for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { if (add_ref) { sp_object_ref (child); } - l = g_slist_prepend (l, child); + l.push_front(child); } return l; diff --git a/src/sp-object.h b/src/sp-object.h index ff80eaefc..858587611 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -47,11 +47,14 @@ class SPObject; #define SP_OBJECT_WRITE_ALL (1 << 2) #define SP_OBJECT_WRITE_NO_CHILDREN (1 << 3) + + #include #include #include #include #include +#include #include "version.h" #include "util/forward-pointer-iterator.h" @@ -60,6 +63,11 @@ class SPCSSAttr; class SPStyle; typedef struct _GSList GSList; +//should be in selection.h +typedef std::list SelContainer; + + + namespace Inkscape { namespace XML { class Node; @@ -330,7 +338,7 @@ public: * Retrieves the children as a GSList object, optionally ref'ing the children * in the process, if add_ref is specified. */ - GSList *childList(bool add_ref, Action action = ActionGeneral); + SelContainer childList(bool add_ref, Action action = ActionGeneral); /** * Append repr as child of this object. diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 961ab0f84..d5eff9796 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -408,7 +408,7 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se g_free(c); } -const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) +const gchar *pattern_tile(const SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -426,8 +426,8 @@ const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document const gchar *pat_id = repr->attribute("id"); SPObject *pat_object = document->getObjectById(pat_id); - for (GSList *i = reprs; i != NULL; i = i->next) { - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); + for (SelContainer::const_iterator i=reprs.begin();i!=reprs.end();i++){ + Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-pattern.h b/src/sp-pattern.h index f021101e2..0e2b058b5 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -89,7 +89,7 @@ SPPattern *pattern_chain (SPPattern *pattern); SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); -const char *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); +const char *pattern_tile (const SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); SPPattern *pattern_getroot (SPPattern *pat); diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index db6db9909..0090f1855 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -55,21 +55,22 @@ SPObject *SPSwitch::_evaluateFirst() { return first; } -GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) { +SelContainer SPSwitch::_childList(bool add_ref, SPObject::Action action) { if ( action != SPObject::ActionGeneral ) { return this->childList(add_ref, action); } SPObject *child = _evaluateFirst(); + SelContainer x; if (NULL == child) - return NULL; + return x; if (add_ref) { //g_object_ref (G_OBJECT (child)); sp_object_ref(child); } - - return g_slist_prepend (NULL, child); + x.push_front(child); + return x; } const char *SPSwitch::displayName() const { @@ -109,10 +110,9 @@ void SPSwitch::_reevaluate(bool /*add_to_drawing*/) { _releaseLastItem(_cached_item); - for ( GSList *l = _childList(false, SPObject::ActionShow); - NULL != l ; l = g_slist_remove (l, l->data)) - { - SPObject *o = SP_OBJECT (l->data); + SelContainer item_list = _childList(false, SPObject::ActionShow); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *o = SP_OBJECT (*iter); if ( !SP_IS_ITEM (o) ) { continue; } @@ -144,10 +144,10 @@ void SPSwitch::_releaseLastItem(SPObject *obj) void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { SPObject *evaluated_child = this->_evaluateFirst(); - GSList *l = this->_childList(false, SPObject::ActionShow); + SelContainer l = this->_childList(false, SPObject::ActionShow); - while (l) { - SPObject *o = SP_OBJECT (l->data); + for ( SelContainer::const_iterator iter=l.begin();iter!=l.end();iter++) { + SPObject *o = SP_OBJECT (*iter); if (SP_IS_ITEM (o)) { SPItem * child = SP_ITEM(o); @@ -158,8 +158,6 @@ void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem ai->appendChild(ac); } } - - l = g_slist_remove (l, o); } } diff --git a/src/sp-switch.h b/src/sp-switch.h index 4fce1f5a6..6a83072e7 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -29,7 +29,7 @@ public: void resetChildEvaluated() { _reevaluate(); } - GSList *_childList(bool add_ref, SPObject::Action action); + SelContainer _childList(bool add_ref, SPObject::Action action); virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); SPObject *_evaluateFirst(); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 8bb3e9897..aec7051e0 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -60,6 +60,11 @@ using Inkscape::DocumentUndo; bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); +//SHOULD DISAPPEAR +bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b){ + return sp_repr_compare_position(dynamic_cast(a),dynamic_cast(b)); +} + 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_do_offset(SPDesktop *desktop, bool expand, double prefOffset); void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating); @@ -326,21 +331,21 @@ 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(); - GSList *il = (GSList *) selection->itemList(); + SelContainer il= selection->itemList(); // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) - if ( (g_slist_length(il) < 2) && (bop != bool_op_union)) { + if ( (il.size() < 2) && (bop != bool_op_union)) { boolop_display_error_message(desktop, _("Select at least 2 paths to perform a boolean operation.")); return; } - else if ( g_slist_length(il) < 1 ) { + else if ( il.size() < 1 ) { boolop_display_error_message(desktop, _("Select at least 1 path to perform a boolean union.")); return; } - g_assert(il != NULL); + g_assert(!il.empty()); - if (g_slist_length(il) > 2) { + if (il.size() > 2) { if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { boolop_display_error_message(desktop, _("Select exactly 2 paths to perform difference, division, or path cut.")); return; @@ -354,8 +359,8 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice) { // check in the tree to find which element of the selection list is topmost (for 2-operand commands only) - Inkscape::XML::Node *a = SP_OBJECT(il->data)->getRepr(); - Inkscape::XML::Node *b = SP_OBJECT(il->next->data)->getRepr(); + Inkscape::XML::Node *a = SP_OBJECT(il.front())->getRepr(); + Inkscape::XML::Node *b = SP_OBJECT(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.")); @@ -394,38 +399,36 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } } - il = g_slist_copy(il); - g_assert(il != NULL); + g_assert(!il.empty()); // first check if all the input objects have shapes // otherwise bail out - for (GSList *l = il; l != NULL; l = l->next) + for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++) { - SPItem *item = SP_ITEM(l->data); + SPItem *item = SP_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.")); - g_slist_free(il); return; } } // extract the livarot Paths from the source objects // also get the winding rule specified in the style - int nbOriginaux = g_slist_length(il); + int nbOriginaux = il.size(); std::vector originaux(nbOriginaux); std::vector origWind(nbOriginaux); int curOrig; { curOrig = 0; - for (GSList *l = il; l != NULL; l = l->next) + for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++) { // apply live path effects prior to performing boolean operation - if (SP_IS_LPE_ITEM(l->data)) { - SP_LPE_ITEM(l->data)->removeAllPathEffects(true); + if (SP_IS_LPE_ITEM(*l)) { + SP_LPE_ITEM(*l)->removeAllPathEffects(true); } - SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast(il->data)->getRepr(), "style"); + SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast(il.front())->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); if (val && strcmp(val, "nonzero") == 0) { origWind[curOrig]= fill_nonZero; @@ -435,11 +438,10 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool origWind[curOrig]= fill_nonZero; } - originaux[curOrig] = Path_for_item((SPItem *) l->data, true, true); + originaux[curOrig] = Path_for_item((SPItem *) (*l), true, true); if (originaux[curOrig] == NULL || originaux[curOrig]->descr_cmd.size() <= 1) { for (int i = curOrig; i >= 0; i--) delete originaux[i]; - g_slist_free(il); return; } curOrig++; @@ -472,7 +474,8 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool theShapeA->ConvertToShape(theShape, origWind[0]); curOrig = 1; - for (GSList *l = il->next; l != NULL; l = l->next) { + for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + if(*l==il.front())continue; originaux[curOrig]->ConvertWithBackData(0.1); originaux[curOrig]->Fill(theShape, curOrig); @@ -668,15 +671,13 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (res->descr_cmd.size() <= 1) { // only one command, presumably a moveto: it isn't a path - for (GSList *l = il; l != NULL; l = l->next) - { - SP_OBJECT(l->data)->deleteObject(); + for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + SP_OBJECT(*l)->deleteObject(); } DocumentUndo::done(doc, SP_VERB_NONE, description); selection->clear(); delete res; - g_slist_free(il); return; } @@ -684,19 +685,17 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SPObject *source; if ( bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { if (reverseOrderForOp) { - source = SP_OBJECT(il->data); + source = SP_OBJECT(il.front()); } else { - source = SP_OBJECT(il->next->data); + source = SP_OBJECT(il.back()); } } else { // find out the bottom object - GSList *sorted = g_slist_copy((GSList *) selection->reprList()); - - sorted = g_slist_sort(sorted, (GCompareFunc) sp_repr_compare_position); + SelContainer sorted(selection->reprList()); - source = doc->getObjectByRepr((Inkscape::XML::Node *)sorted->data); + sorted.sort(sp_repr_compare_position_obj); - g_slist_free(sorted); + source = doc->getObjectByRepr((Inkscape::XML::Node *)sorted.front()); } // adjust style properties that depend on a possible transform in the source object in order @@ -721,17 +720,16 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool gchar *desc = source->desc(); // remove source paths selection->clear(); - for (GSList *l = il; l != NULL; l = l->next) { + for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ // if this is the bottommost object, - if (!strcmp(reinterpret_cast(l->data)->getRepr()->attribute("id"), id)) { + if (!strcmp(reinterpret_cast(*l)->getRepr()->attribute("id"), id)) { // delete it so that its clones don't get alerted; this object will be restored shortly, with the same id - SP_OBJECT(l->data)->deleteObject(false); + SP_OBJECT(*l)->deleteObject(false); } else { // delete the object for real, so that its clones can take appropriate action - SP_OBJECT(l->data)->deleteObject(); + SP_OBJECT(*l)->deleteObject(); } } - g_slist_free(il); // premultiply by the inverse of parent's repr SPItem *parent_item = SP_ITEM(doc->getObjectByRepr(parent)); @@ -1159,12 +1157,9 @@ sp_selected_path_outline(SPDesktop *desktop) } bool did = false; - - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); - items != NULL; - items = items->next) { - - SPItem *item = SP_ITEM(items->data); + SelContainer il(selection->itemList()); + for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + SPItem *item = SP_ITEM(*l); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) continue; @@ -1774,12 +1769,9 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } bool did = false; - - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); - items != NULL; - items = items->next) { - - SPItem *item = SP_ITEM(items->data); + SelContainer il(selection->itemList()); + for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + SPItem *item = SP_ITEM(*l); SPCurve *curve = NULL; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) @@ -1975,7 +1967,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) static bool sp_selected_path_simplify_items(SPDesktop *desktop, - Inkscape::Selection *selection, GSList *items, + Inkscape::Selection *selection, SelContainer &items, float threshold, bool justCoalesce, float angleLimit, bool breakableAngles, bool modifySelection); @@ -1994,7 +1986,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, //If this is a group, do the children instead if (SP_IS_GROUP(item)) { - GSList *items = sp_item_group_item_list(SP_GROUP(item)); + SelContainer items = sp_item_group_item_list(SP_GROUP(item)); return sp_selected_path_simplify_items(desktop, selection, items, threshold, justCoalesce, @@ -2119,7 +2111,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, bool sp_selected_path_simplify_items(SPDesktop *desktop, - Inkscape::Selection *selection, GSList *items, + Inkscape::Selection *selection, SelContainer &items, float threshold, bool justCoalesce, float angleLimit, bool breakableAngles, bool modifySelection) @@ -2145,13 +2137,13 @@ sp_selected_path_simplify_items(SPDesktop *desktop, gdouble simplifySize = selectionSize; int pathsSimplified = 0; - int totalPathCount = g_slist_length(items); + int totalPathCount = items.size(); // set "busy" cursor desktop->setWaitingCursor(); - for (; items != NULL; items = items->next) { - SPItem *item = (SPItem *) items->data; + for (SelContainer::const_iterator l = items.begin(); l != items.end(); l++){ + SPItem *item = SP_ITEM(*l); if (!(SP_IS_GROUP(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item))) continue; @@ -2199,7 +2191,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju return; } - GSList *items = g_slist_copy((GSList *) selection->itemList()); + SelContainer items(selection->itemList()); bool didSomething = sp_selected_path_simplify_items(desktop, selection, items, threshold, diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 65b59f2ad..391e255a5 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -43,11 +43,10 @@ using Inkscape::DocumentUndo; static SPItem * flowtext_in_selection(Inkscape::Selection *selection) { - for (GSList *items = (GSList *) selection->itemList(); - items != NULL; - items = items->next) { - if (SP_IS_FLOWTEXT(items->data)) - return ((SPItem *) items->data); + SelContainer items = selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + if (SP_IS_FLOWTEXT(*i)) + return ((SPItem *) *i); } return NULL; } @@ -55,11 +54,10 @@ flowtext_in_selection(Inkscape::Selection *selection) static SPItem * text_or_flowtext_in_selection(Inkscape::Selection *selection) { - for (GSList *items = (GSList *) selection->itemList(); - items != NULL; - items = items->next) { - if (SP_IS_TEXT(items->data) || SP_IS_FLOWTEXT(items->data)) - return ((SPItem *) items->data); + SelContainer items = selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) + return ((SPItem *) *i); } return NULL; } @@ -67,11 +65,10 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) static SPItem * shape_in_selection(Inkscape::Selection *selection) { - for (GSList *items = (GSList *) selection->itemList(); - items != NULL; - items = items->next) { - if (SP_IS_SHAPE(items->data)) - return ((SPItem *) items->data); + SelContainer items = selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + if (SP_IS_SHAPE(*i)) + return ((SPItem *) *i); } return NULL; } @@ -90,7 +87,7 @@ text_put_on_path() Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - if (!text || !shape || g_slist_length((GSList *) selection->itemList()) != 2) { + if (!text || !shape || selection->itemList().size() != 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a text and a path to put text on path.")); return; } @@ -199,11 +196,9 @@ text_remove_from_path() } bool did = false; - - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); - items != NULL; - items = items->next) { - SPObject *obj = SP_OBJECT(items->data); + SelContainer items(selection->itemList()); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPObject *obj = SP_OBJECT(*i); if (SP_IS_TEXT_TEXTPATH(obj)) { SPObject *tp = obj->firstChild(); @@ -219,7 +214,7 @@ text_remove_from_path() } else { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Remove text from path")); - selection->setList(g_slist_copy((GSList *) selection->itemList())); // reselect to update statusbar description + selection->setList(selection->itemList()); // reselect to update statusbar description } } @@ -265,10 +260,9 @@ text_remove_all_kerns() bool did = false; - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); - items != NULL; - items = items->next) { - SPObject *obj = SP_OBJECT(items->data); + SelContainer items = selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPObject *obj = SP_OBJECT(*i); if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { continue; @@ -302,7 +296,7 @@ text_flow_into_shape() SPItem *text = text_or_flowtext_in_selection(selection); SPItem *shape = shape_in_selection(selection); - if (!text || !shape || g_slist_length((GSList *) selection->itemList()) < 2) { + if (!text || !shape || selection->itemList().size() < 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a text and one or more paths or shapes to flow text into frame.")); return; } @@ -326,10 +320,9 @@ text_flow_into_shape() g_return_if_fail(SP_IS_FLOWREGION(object)); /* Add clones */ - for (GSList *items = (GSList *) selection->itemList(); - items != NULL; - items = items->next) { - SPItem *item = SP_ITEM(items->data); + SelContainer items = selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_SHAPE(item)){ Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); clone->setAttribute("x", "0"); @@ -394,23 +387,22 @@ text_unflow () Inkscape::Selection *selection = desktop->getSelection(); - if (!flowtext_in_selection(selection) || g_slist_length((GSList *) selection->itemList()) < 1) { + if (!flowtext_in_selection(selection) || selection->itemList().size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a flowed text to unflow it.")); return; } - GSList *new_objs = NULL; + SelContainer new_objs; GSList *old_objs = NULL; - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); - items != NULL; - items = items->next) { + SelContainer items = selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ - if (!SP_IS_FLOWTEXT(SP_OBJECT(items->data))) { + if (!SP_IS_FLOWTEXT(SP_OBJECT(*i))) { continue; } - SPItem *flowtext = SP_ITEM(items->data); + SPItem *flowtext = SP_ITEM(*i); // we discard transform when unflowing, but we must preserve expansion which is visible as // font size multiplier @@ -451,7 +443,7 @@ text_unflow () SPText *text = SP_TEXT(text_object); text->_adjustFontsizeRecursive(text, ex); - new_objs = g_slist_prepend (new_objs, text_object); + new_objs.push_front(text_object); old_objs = g_slist_prepend (old_objs, flowtext); Inkscape::GC::release(rtext); @@ -466,7 +458,6 @@ text_unflow () } g_slist_free (old_objs); - g_slist_free (new_objs); DocumentUndo::done(doc, SP_VERB_CONTEXT_TEXT, _("Unflow flowed text")); @@ -487,11 +478,11 @@ flowtext_to_text() bool did = false; - GSList *reprs = NULL; - GSList *items = g_slist_copy((GSList *) selection->itemList()); - for (; items != NULL; items = items->next) { + SelContainer reprs; + SelContainer items(selection->itemList()); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = (SPItem *) items->data; + SPItem *item = (SPItem *) *i; if (!SP_IS_FLOWTEXT(item)) continue; @@ -519,10 +510,9 @@ flowtext_to_text() Inkscape::GC::release(repr); item->deleteObject(); - reprs = g_slist_prepend(reprs, repr); + reprs.push_front(dynamic_cast(repr)); } - g_slist_free(items); if (did) { DocumentUndo::done(desktop->getDocument(), @@ -535,7 +525,6 @@ flowtext_to_text() _("No flowed text(s) to convert in the selection.")); } - g_slist_free(reprs); } diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 4a962ab4c..44d90b4ae 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -67,12 +67,11 @@ static void te_update_layout_now (SPItem *item) void te_update_layout_now_recursive(SPItem *item) { if (SP_IS_GROUP(item)) { - GSList *item_list = sp_item_group_item_list(SP_GROUP(item)); - for(GSList* elem = item_list; elem; elem = elem->next) { - SPItem* list_item = static_cast(elem->data); + SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); + for(SelContainer::const_iterator i=item_list.begin();i!=item_list.end();i++){ + SPItem* list_item = static_cast(*i); te_update_layout_now_recursive(list_item); } - g_slist_free(item_list); } else if (SP_IS_TEXT(item)) SP_TEXT(item)->rebuildLayout(); else if (SP_IS_FLOWTEXT (item)) diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index cc3d000a3..892ecdb87 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -65,7 +65,7 @@ SPImage *Tracer::getSelectedSPImage() if (sioxEnabled) { SPImage *img = NULL; - GSList const *list = sel->itemList(); + SelContainer const list = sel->itemList(); std::vector items; sioxShapes.clear(); @@ -74,13 +74,13 @@ SPImage *Tracer::getSelectedSPImage() them as bottom-to-top so that we can discover the image and any SPItems above it */ - for ( ; list ; list=list->next) + for(SelContainer::const_iterator x=list.begin();x!=list.end();x++){ { - if (!SP_IS_ITEM(list->data)) + if (!SP_IS_ITEM(*x)) { continue; } - SPItem *item = SP_ITEM(list->data); + SPItem *item = SP_ITEM(*x); items.insert(items.begin(), item); } std::vector::iterator iter; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 94a1eb2dc..20b43af3b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -523,8 +523,9 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { - for (GSList *i = const_cast(selection->itemList()) ; i ; i = i->next) { - SPItem *item = dynamic_cast(static_cast(i->data)); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); if ( obj_size ) { @@ -578,8 +579,9 @@ 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); - for (GSList *itemptr = const_cast(selection->itemList()) ; itemptr ; itemptr = itemptr->next) { - SPItem *item = reinterpret_cast(itemptr->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); _applyPathEffect(item, effectstack); } @@ -659,10 +661,10 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) */ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { - GSList const *items = selection->itemList(); // copy the defs used by all items - for (GSList *i = const_cast(items) ; i != NULL ; i = i->next) { - SPItem *item = dynamic_cast(static_cast(i->data)); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (item) { _copyUsedDefs(item); } else { @@ -671,11 +673,11 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) } // copy the representation of the items - GSList *sorted_items = g_slist_copy(const_cast(items)); - sorted_items = g_slist_sort(sorted_items, (GCompareFunc) sp_object_compare_position); + SelContainer sorted_items(itemlist); + sorted_items.sort(sp_object_compare_position); - for (GSList *i = sorted_items ; i ; i = i->next) { - SPItem *item = dynamic_cast(static_cast(i->data)); + for(SelContainer::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){ + SPItem *item = SP_ITEM(*i); if (item) { Inkscape::XML::Node *obj = item->getRepr(); Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root); @@ -695,8 +697,8 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) } // copy style for Paste Style action - if (sorted_items) { - SPObject *object = static_cast(sorted_items->data); + if (!sorted_items.empty()) { + SPObject *object = static_cast(sorted_items.front()); SPItem *item = dynamic_cast(object); if (item) { SPCSSAttr *style = take_style_from_item(item); @@ -719,7 +721,6 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) sp_repr_set_point(_clipnode, "max", size->max()); } - g_slist_free(sorted_items); } @@ -1156,8 +1157,8 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) sp_repr_get_double(nv, "inkscape:pageopacity", &opacity); bgcolor |= SP_COLOR_F_TO_U(opacity); } - - sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, NULL); + SelContainer x; + sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, x); } else { diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 65bc94011..562bc28b7 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -98,8 +98,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); using Inkscape::Util::GSListConstIterator; - std::list selected; - selected.insert >(selected.end(), selection->itemList(), NULL); + SelContainer selected(selection->itemList()); if (selected.empty()) return; const Coeffs &a = _allCoeffs[index]; @@ -149,18 +148,19 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) b = selection->preferredBounds(); //Move each item in the selected list separately - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) { + SPItem* item=static_cast (*it); desktop->getDocument()->ensureUpToDate(); if (!sel_as_group) - b = (*it)->desktopPreferredBounds(); - if (b && (!focus || (*it) != focus)) { + b = (item)->desktopPreferredBounds(); + if (b && (!focus || (item) != focus)) { Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); Geom::Point const mp_rel( mp - sp ); if (LInfty(mp_rel) > 1e-9) { - sp_item_move_rel(*it, Geom::Translate(mp_rel)); + sp_item_move_rel(item, Geom::Translate(mp_rel)); changed = true; } } @@ -251,25 +251,24 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - std::list selected; - selected.insert >(selected.end(), selection->itemList(), NULL); + SelContainer selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects - std::list::iterator second(selected.begin()); + SelContainer::iterator second(selected.begin()); ++second; if (second == selected.end()) return; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box"); std::vector< BBoxSort > sorted; - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) - { - Geom::OptRect bbox = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); + {SPItem *item=static_cast(*it); + Geom::OptRect bbox = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (bbox) { - sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd)); + sorted.push_back(BBoxSort(item, *bbox, _orientation, _kBegin, _kEnd)); } } //sort bbox by anchors @@ -541,6 +540,10 @@ private : return (a->isSiblingOf(b)); } + static bool local_obj_compare(SPObject* a,SPObject* b){ + return ActionExchangePositions::sort_compare(static_cast(a),static_cast(b)); + } + virtual void on_button_click() { SPDesktop *desktop = _dialog.getDesktop(); @@ -550,8 +553,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - std::list selected; - selected.insert >(selected.end(), selection->itemList(), NULL); + SelContainer selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -569,20 +571,22 @@ private : } else { // sorting by ZOrder is outomatically done by not setting the center center.reset(); } - selected.sort(ActionExchangePositions::sort_compare); + selected.sort(local_obj_compare); } - std::list::iterator it(selected.begin()); - Geom::Point p1 = (*it)->getCenter(); + SelContainer::iterator it(selected.begin()); + SPItem* item=static_cast(*it); + Geom::Point p1 = (item)->getCenter(); for (++it ;it != selected.end(); ++it) { - Geom::Point p2 = (*it)->getCenter(); + item=static_cast(*it); + Geom::Point p2 = (item)->getCenter(); Geom::Point delta = p1 - p2; - sp_item_move_rel((*it),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + sp_item_move_rel((item),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); p1 = p2; } - Geom::Point p2 = selected.front()->getCenter(); + Geom::Point p2 = static_cast(selected.front())->getCenter(); Geom::Point delta = p1 - p2; - sp_item_move_rel(selected.front(),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + sp_item_move_rel(static_cast(selected.front()),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -615,8 +619,8 @@ 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); - - unclump ((GSList *) _dialog.getDesktop()->getSelection()->itemList()); + SelContainer x(_dialog.getDesktop()->getSelection()->itemList()); + unclump (x); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -647,8 +651,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - std::list selected; - selected.insert >(selected.end(), selection->itemList(), NULL); + SelContainer selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -672,12 +675,13 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) { + SPItem* item=static_cast(*it); desktop->getDocument()->ensureUpToDate(); - Geom::OptRect item_box = !prefs_bbox ? (*it)->desktopVisualBounds() : (*it)->desktopGeometricBounds(); + Geom::OptRect item_box = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (item_box) { // find new center, staying within bbox double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box)[Geom::X].extent() /2 + @@ -686,7 +690,7 @@ private : g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::Y].extent() - (*item_box)[Geom::Y].extent()); // displacement is the new center minus old: Geom::Point t = Geom::Point (x, y) - 0.5*(item_box->max() + item_box->min()); - sp_item_move_rel(*it, Geom::Translate(t)); + sp_item_move_rel(item, Geom::Translate(t)); } } @@ -746,8 +750,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - std::list selected; - selected.insert >(selected.end(), selection->itemList(), NULL); + SelContainer selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -758,20 +761,21 @@ private : std::vector sorted; - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) { - if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) { - Inkscape::Text::Layout const *layout = te_get_layout(*it); + SPItem* item=static_cast(*it); + if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { + Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * (*it)->i2dt_affine(); + Geom::Point base = *pt * (item)->i2dt_affine(); if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X]; if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y]; if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X]; if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y]; - Baselines b (*it, base, _orientation); + Baselines b (item, base, _orientation); sorted.push_back(b); } } @@ -801,18 +805,19 @@ private : } } else { - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) { - if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) { - Inkscape::Text::Layout const *layout = te_get_layout(*it); + SPItem* item=static_cast(*it); + if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { + Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional pt = layout->baselineAnchorPoint(); if (pt) { - Geom::Point base = *pt * (*it)->i2dt_affine(); + Geom::Point base = *pt * (item)->i2dt_affine(); Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] - base[_orientation]; - sp_item_move_rel(*it, Geom::Translate(t)); + sp_item_move_rel(item, Geom::Translate(t)); changed = true; } } diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index fede30b26..abfab8b19 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -1359,7 +1359,7 @@ void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, Gtk return; } - if (g_slist_length ((GSList *) selection->itemList()) > 1) { + if (selection->itemList().size() > 1) { gtk_widget_set_sensitive (buttons, FALSE); gtk_label_set_markup (GTK_LABEL(status), _("More than one object selected.")); return; @@ -2096,7 +2096,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) { + if (selection->isEmpty() || selection->itemList().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to unclump.")); return; } @@ -2104,11 +2104,11 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) SPObject *obj = selection->singleItem(); SPObject *parent = obj->parent; - GSList *to_unclump = NULL; // not including the original + SelContainer 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 = g_slist_prepend (to_unclump, child); + to_unclump.push_front(child); } } @@ -2116,8 +2116,6 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) unclump (to_unclump); - g_slist_free (to_unclump); - DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, _("Unclump tiled clones")); } @@ -2147,7 +2145,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || g_slist_length((GSList *) selection->itemList()) > 1) { + if (selection->isEmpty() || selection->itemList().size() > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select one object whose tiled clones to remove.")); return; } @@ -2225,7 +2223,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) } // Check if more than one object is selected. - if (g_slist_length((GSList *) selection->itemList()) > 1) { + if (selection->itemList().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 6d90c792e..fc6094c9f 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -605,7 +605,7 @@ void Export::onBatchClicked () void Export::updateCheckbuttons () { - gint num = g_slist_length((GSList *) SP_ACTIVE_DESKTOP->getSelection()->itemList()); + gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().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)); @@ -817,9 +817,9 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const GSList * reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = (Inkscape::XML::Node *)reprlst->data; + const SelContainer reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); + for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = (Inkscape::XML::Node *)(*i); if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1010,7 +1010,7 @@ void Export::onExport () if (batch_export.get_active ()) { // Batch export of selected objects - gint num = g_slist_length(const_cast(desktop->getSelection()->itemList())); + gint num = (desktop->getSelection()->itemList()).size(); gint n = 0; if (num < 1) { @@ -1024,8 +1024,9 @@ void Export::onExport () gint export_count = 0; - for (GSList *i = const_cast(desktop->getSelection()->itemList()); i && !interrupted; i = i->next) { - SPItem *item = reinterpret_cast(i->data); + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ + SPItem *item = reinterpret_cast(*i); prog_dlg->set_data("current", GINT_TO_POINTER(n)); prog_dlg->set_data("total", GINT_TO_POINTER(num)); @@ -1063,13 +1064,13 @@ void Export::onExport () _("Exporting file %s..."), safeFile), desktop); MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file %s..."), safeFile), desktop); - + SelContainer x; if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking - hide ? const_cast(desktop->getSelection()->itemList()) : NULL + hide ? (desktop->getSelection()->itemList()) : x )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1153,12 +1154,13 @@ void Export::onExport () prog_dlg->set_data("total", GINT_TO_POINTER(0)); /* Do export */ + SelContainer x; ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, onProgressCallback, (void*)prog_dlg, FALSE, - hide ? const_cast(desktop->getSelection()->itemList()) : NULL + hide ? (desktop->getSelection()->itemList()) : x ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); @@ -1224,7 +1226,7 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - const GSList * reprlst; + SelContainer reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; @@ -1232,8 +1234,8 @@ void Export::onExport () DocumentUndo::setUndoSensitive(doc, false); reprlst = desktop->getSelection()->reprList(); - for(; reprlst != NULL; reprlst = reprlst->next) { - Inkscape::XML::Node * repr = static_cast(reprlst->data); + for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = dynamic_cast(*i); const gchar * temp_string; Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 3da0e0043..657d6771b 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -690,7 +690,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0); + Inkscape::XML::Node* node = (Inkscape::XML::Node*) sel->reprList().front(); if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; @@ -1465,9 +1465,9 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } std::set used; - - for (GSList const *i = sel->itemList(); i != NULL; i = i->next) { - SPObject *obj = SP_OBJECT (i->data); + SelContainer itemlist=sel->itemList(); + for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPStyle *style = obj->style; if (!style || !SP_IS_ITEM(obj)) { continue; @@ -1545,10 +1545,9 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri if((*iter)[_columns.sel] == 1) filter = 0; - GSList const *items = sel->itemList(); - - for (GSList const *i = items; i != NULL; i = i->next) { - SPItem * item = SP_ITEM(i->data); + SelContainer itemlist=sel->itemList(); + for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + SPItem * item = SP_ITEM(*i); SPStyle *style = item->style; g_assert(style != NULL); @@ -1650,12 +1649,13 @@ void FilterEffectsDialog::FilterModifier::remove_filter() SPDocument* doc = filter->document; // Delete all references to this filter - GSList *all = get_all_items(NULL, _desktop->currentRoot(), _desktop, false, false, true, NULL); - for (GSList *i = all; i != NULL; i = i->next) { - if (!SP_IS_ITEM(i->data)) { + SelContainer x,y; + SelContainer all = get_all_items(x, _desktop->currentRoot(), _desktop, false, false, true, y); + for(SelContainer::const_iterator i=all.begin(); all.end() != i; i++) { + if (!SP_IS_ITEM(*i)) { continue; } - SPItem *item = SP_ITEM(i->data); + SPItem *item = SP_ITEM(*i); if (!item->style) { continue; } @@ -1668,9 +1668,6 @@ void FilterEffectsDialog::FilterModifier::remove_filter() } } } - if (all) { - g_slist_free(all); - } //XML Tree being used directly here while it shouldn't be. sp_repr_unparent(filter->getRepr()); diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 951cb01ea..43ecb60ac 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -549,7 +549,7 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas } -GSList *Find::filter_fields (GSList *l, bool exact, bool casematch) +SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) { Glib::ustring tmp = entry_find.getEntry()->get_text(); if (tmp.empty()) { @@ -557,17 +557,17 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch) } gchar* text = g_strdup(tmp.c_str()); - GSList *in = l; - GSList *out = NULL; + SelContainer in = l; + SelContainer out; if (check_searchin_text.get_active()) { - for (GSList *i = in; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_text_match(item, text, exact, casematch)) { - if (!g_slist_find(out, i->data)) { - out = g_slist_prepend (out, i->data); + if (out.end()==find(out.begin(),out.end(), *i)) { + out.push_front(*i); if (_action_replace) { item_text_match(item, text, exact, casematch, _action_replace); } @@ -584,12 +584,12 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch) bool attrvalue = check_attributevalue.get_active(); if (ids) { - for (GSList *i = in; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); if (item_id_match(item, text, exact, casematch)) { - if (!g_slist_find(out, i->data)) { - out = g_slist_prepend (out, i->data); + if (out.end()==find(out.begin(),out.end(), *i)) { + out.push_front(*i); if (_action_replace) { item_id_match(item, text, exact, casematch, _action_replace); } @@ -600,14 +600,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch) if (style) { - for (GSList *i = in; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_style_match(item, text, exact, casematch)) { - if (!g_slist_find(out, i->data)) - if (!g_slist_find(out, i->data)) { - out = g_slist_prepend (out, i->data); + if (out.end()==find(out.begin(),out.end(), *i)){ + out.push_front(*i); if (_action_replace) { item_style_match(item, text, exact, casematch, _action_replace); } @@ -618,13 +617,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch) if (attrname) { - for (GSList *i = in; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_attr_match(item, text, exact, casematch)) { - if (!g_slist_find(out, i->data)) { - out = g_slist_prepend (out, i->data); + if (out.end()==find(out.begin(),out.end(), *i)) { + out.push_front(*i); if (_action_replace) { item_attr_match(item, text, exact, casematch, _action_replace); } @@ -635,13 +634,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch) if (attrvalue) { - for (GSList *i = in; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_attrvalue_match(item, text, exact, casematch)) { - if (!g_slist_find(out, i->data)) { - out = g_slist_prepend (out, i->data); + if (out.end()==find(out.begin(),out.end(), *i)) { + out.push_front(*i); if (_action_replace) { item_attrvalue_match(item, text, exact, casematch, _action_replace); } @@ -652,13 +651,13 @@ GSList *Find::filter_fields (GSList *l, bool exact, bool casematch) if (font) { - for (GSList *i = in; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_font_match(item, text, exact, casematch)) { - if (!g_slist_find(out, i->data)) { - out = g_slist_prepend (out, i->data); + if (out.end()==find(out.begin(),out.end(),*i)) { + out.push_front(*i); if (_action_replace) { item_font_match(item, text, exact, casematch, _action_replace); } @@ -716,29 +715,29 @@ bool Find::item_type_match (SPItem *item) return false; } -GSList *Find::filter_types (GSList *l) +SelContainer Find::filter_types (SelContainer &l) { - GSList *n = NULL; - for (GSList *i = l; i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + SelContainer n; + for(SelContainer::const_iterator i=l.begin(); l.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_type_match(item)) { - n = g_slist_prepend (n, i->data); + n.push_front(*i); } } return n; } -GSList *Find::filter_list (GSList *l, bool exact, bool casematch) +SelContainer &Find::filter_list (SelContainer &l, bool exact, bool casematch) { l = filter_types (l); l = filter_fields (l, exact, casematch); return l; } -GSList *Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked) +SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool locked) { if (dynamic_cast(r)) { return l; // we're not interested in items in defs @@ -752,7 +751,7 @@ GSList *Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked) SPItem *item = dynamic_cast(child); if (item && !child->cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { - l = g_slist_prepend (l, child); + l.push_front(child); } } l = all_items (child, l, hidden, locked); @@ -760,16 +759,17 @@ GSList *Find::all_items (SPObject *r, GSList *l, bool hidden, bool locked) return l; } -GSList *Find::all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked) +SelContainer &Find::all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked) { - for (GSList *i = (GSList *) s->itemList(); i != NULL; i = i->next) { - SPObject *obj = reinterpret_cast(i->data); + SelContainer itemlist=s->itemList(); + for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item && !item->cloned && !desktop->isLayer(item)) { if (!ancestor || ancestor->isAncestorOf(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { - l = g_slist_prepend (l, i->data); + l.push_back(*i); } } } @@ -817,7 +817,7 @@ void Find::onAction() bool casematch = check_case_sensitive.get_active(); blocked = true; - GSList *l = NULL; + SelContainer l; if (check_scope_selection.get_active()) { if (check_scope_layer.get_active()) { l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked); @@ -831,12 +831,12 @@ void Find::onAction() l = all_items(desktop->getDocument()->getRoot(), l, hidden, locked); } } - guint all = g_slist_length (l); + guint all = l.size(); - GSList *n = filter_list (l, exact, casematch); + SelContainer n = filter_list (l, exact, casematch); - if (n != NULL) { - int count = g_slist_length (n); + if (!n.empty()) { + int count = n.size(); desktop->messageStack()->flashF(Inkscape::NORMAL_MESSAGE, // TRANSLATORS: "%s" is replaced with "exact" or "partial" when this string is displayed ngettext("%d object found (out of %d), %s match.", @@ -857,7 +857,7 @@ void Find::onAction() Inkscape::Selection *selection = desktop->getSelection(); selection->clear(); selection->setList(n); - SPObject *obj = reinterpret_cast(n->data); + SPObject *obj = reinterpret_cast(n.front()); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); scroll_to_show_item(desktop, item); diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index c0c635f94..1aded96f2 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -16,6 +16,7 @@ # include #endif +#include "selection.h" #include "ui/widget/panel.h" #include "ui/widget/button.h" #include "ui/widget/entry.h" @@ -148,10 +149,10 @@ protected: /** * Function to filter a list of items based on the item type by calling each item_XXX_match function */ - GSList * filter_fields (GSList *l, bool exact, bool casematch); + SelContainer filter_fields (SelContainer &l, bool exact, bool casematch); bool item_type_match (SPItem *item); - GSList * filter_types (GSList *l); - GSList * filter_list (GSList *l, bool exact, bool casematch); + SelContainer filter_types (SelContainer &l); + SelContainer & filter_list (SelContainer &l, bool exact, bool casematch); /** * Find a string within a string and returns true if found with options for exact and casematching @@ -172,12 +173,12 @@ protected: * recursive function to return a list of all the items in the SPObject tree * */ - GSList * all_items (SPObject *r, GSList *l, bool hidden, bool locked); + SelContainer & all_items (SPObject *r, SelContainer &l, bool hidden, bool locked); /** * to return a list of all the selected items * */ - GSList * all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked); + SelContainer & all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked); /** * Shrink the dialog size when the expander widget is closed diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 2b9053da9..1ef97b996 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -578,9 +578,10 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) void GlyphsPanel::insertText() { SPItem *textItem = 0; - for (const GSList *item = targetDesktop->selection->itemList(); item; item = item->next ) { - if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) { - textItem = SP_ITEM(item->data); + SelContainer itemlist=targetDesktop->selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { + textItem = SP_ITEM(*i); break; } } @@ -687,8 +688,9 @@ void GlyphsPanel::selectionModifiedCB(guint flags) void GlyphsPanel::calcCanInsert() { int items = 0; - for (const GSList *item = targetDesktop->selection->itemList(); item; item = item->next ) { - if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) { + SelContainer itemlist=targetDesktop->selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { ++items; } } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 28a65e0b4..86cf629c1 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1906,11 +1906,10 @@ void ContextMenu::ActivateGroup(void) void ContextMenu::ActivateUngroup(void) { - GSList *children = NULL; + SelContainer children; - sp_item_group_ungroup(static_cast(_item), &children); + sp_item_group_ungroup(static_cast(_item), children); _desktop->selection->setList(children); - g_slist_free(children); } void ContextMenu::MakeAnchorMenu(void) @@ -1959,10 +1958,9 @@ void ContextMenu::AnchorLinkFollow(void) void ContextMenu::AnchorLinkRemove(void) { - GSList *children = NULL; - sp_item_group_ungroup(static_cast(_item), &children, false); + SelContainer children; + sp_item_group_ungroup(static_cast(_item), children, false); DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link")); - g_slist_free(children); } void ContextMenu::MakeImageMenu (void) @@ -2051,8 +2049,6 @@ void ContextMenu::ImageEdit(void) _desktop->selection->set(_item); } - GSList const *selected = _desktop->selection->itemList(); - GError* errThing = 0; Glib::ustring cmdline = getImageEditorName(); Glib::ustring name; @@ -2079,8 +2075,9 @@ void ContextMenu::ImageEdit(void) } #endif - for (GSList const *iter = selected; iter != NULL; iter = iter->next) { - Inkscape::XML::Node *ir = SP_ITEM(iter->data)->getRepr(); + SelContainer itemlist=_desktop->selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + Inkscape::XML::Node *ir = SP_ITEM(*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); if (strncmp (href,"file:",5) == 0) { diff --git a/src/unclump.cpp b/src/unclump.cpp index 940369d7a..d1cfc6628 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -168,13 +168,12 @@ unclump_dist (SPItem *item1, SPItem *item2) /** Average unclump_dist from item to others */ -static double unclump_average (SPItem *item, GSList *others) +static double unclump_average (SPItem *item, SelContainer &others) { int n = 0; double sum = 0; - - for (GSList *i = others; i != NULL; i = i->next) { - SPItem *other = SP_ITEM (i->data); + for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + SPItem *other = SP_ITEM (*i); if (other == item) continue; @@ -192,13 +191,13 @@ static double unclump_average (SPItem *item, GSList *others) /** Closest to item among others */ -static SPItem *unclump_closest (SPItem *item, GSList *others) +static SPItem *unclump_closest (SPItem *item, SelContainer &others) { double min = HUGE_VAL; SPItem *closest = NULL; - for (GSList *i = others; i != NULL; i = i->next) { - SPItem *other = SP_ITEM (i->data); + for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + SPItem *other = SP_ITEM (*i); if (other == item) continue; @@ -216,13 +215,12 @@ static SPItem *unclump_closest (SPItem *item, GSList *others) /** Most distant from item among others */ -static SPItem *unclump_farest (SPItem *item, GSList *others) +static SPItem *unclump_farest (SPItem *item, SelContainer &others) { double max = -HUGE_VAL; SPItem *farest = NULL; - - for (GSList *i = others; i != NULL; i = i->next) { - SPItem *other = SP_ITEM (i->data); + for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + SPItem *other = SP_ITEM (*i); if (other == item) continue; @@ -242,8 +240,8 @@ Removes from the \a rest list those items that are "behind" \a closest as seen f i.e. those on the other side of the line through \a closest perpendicular to the direction from \a item to \a closest. Returns a newly created list which must be freed. */ -static GSList * -unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest) +static SelContainer +unclump_remove_behind (SPItem *item, SPItem *closest, SelContainer &rest) { Geom::Point it = unclump_center (item); Geom::Point p1 = unclump_center (closest); @@ -260,10 +258,9 @@ unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest) // substitute the item into it: double val_item = A * it[Geom::X] + B * it[Geom::Y] + C; - GSList *out = NULL; - - for (GSList *i = rest; i != NULL; i = i->next) { - SPItem *other = SP_ITEM (i->data); + SelContainer out; + for (SelContainer::const_iterator i = rest.begin(); i != rest.end();i++) { + SPItem *other = SP_ITEM (*i); if (other == item) continue; @@ -274,7 +271,7 @@ unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest) if (val_item * val_other <= 1e-6) { // different signs, which means item and other are on the different sides of p1-p2 line; skip } else { - out = g_slist_prepend (out, other); + out.push_front(other); } } @@ -334,34 +331,32 @@ similar to "engraver dots". The only distribution which is unchanged by unclumpi grid. May be called repeatedly for stronger effect. */ void -unclump (GSList *items) +unclump (SelContainer &items) { c_cache.clear(); wh_cache.clear(); - for (GSList *i = items; i != NULL; i = i->next) { // for each original/clone x: - SPItem *item = SP_ITEM (i->data); + for (SelContainer::const_iterator i = items.begin(); i != items.end();i++) { // for each original/clone x: + SPItem *item = SP_ITEM (*i); - GSList *nei = NULL; + SelContainer nei; - GSList *rest = g_slist_copy (items); - rest = g_slist_remove (rest, item); + SelContainer rest(items); + rest.remove(item); - while (rest != NULL) { + while (!rest.empty()) { SPItem *closest = unclump_closest (item, rest); if (closest) { - nei = g_slist_prepend (nei, closest); - rest = g_slist_remove (rest, closest); - GSList *new_rest = unclump_remove_behind (item, closest, rest); - g_slist_free (rest); + nei.push_front(closest); + rest.remove(closest); + SelContainer new_rest = unclump_remove_behind (item, closest, rest); rest = new_rest; } else { - g_slist_free (rest); break; } } - if (g_slist_length (nei) >= 2) { + if ( (nei.size()) >= 2) { double ave = unclump_average (item, nei); SPItem *closest = unclump_closest (item, nei); diff --git a/src/unclump.h b/src/unclump.h index 2411cb713..54f43ffde 100644 --- a/src/unclump.h +++ b/src/unclump.h @@ -12,8 +12,9 @@ #define SEEN_DIALOGS_UNCLUMP_H typedef struct _GSList GSList; +#include "selection.h" -void unclump(GSList *items); +void unclump(SelContainer &items); #endif /* !UNCLUMP_H_SEEN */ diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index b62aacbc5..98a3eaa67 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -256,8 +256,9 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list sel_boxes; - for (GSList const* i = sel->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=sel->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box && this->hasBox(box)) { sel_boxes.push_back(box); @@ -395,8 +396,9 @@ 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(); - for (GSList const* i = sel->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=sel->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { vp = this->findVPWithBox(box); @@ -577,8 +579,9 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=this->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { VanishingPoint vp; @@ -609,8 +612,9 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { - SPItem *item = static_cast(i->data); + SelContainer itemlist=this->selection->itemList(); + for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { this->drawLinesForFace (box, Proj::X); @@ -626,11 +630,11 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - GSList *sel = (GSList *) selection->itemList(); - if (!sel) + SelContainer sel = selection->itemList(); + if (sel.empty()) return; // no selection - if (g_slist_length (sel) > 1) { + if (sel.size() > 1) { // Currently we only show handles if a single box is selected return; } diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 8a64854be..23c248129 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -97,12 +97,9 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL); bool modmade = false; - for (GSList const *items = desktop->getSelection()->itemList(); - items != NULL; - items = items->next) - { - SPItem *item = SP_ITEM(items->data); - + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -166,11 +163,9 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) bool modmade = false; if ( ege_select_one_action_get_active(act) != 0 ) { - for (GSList const *items = desktop->getSelection()->itemList(); - items != NULL; - items = items->next) - { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", "true"); @@ -179,11 +174,9 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } } } else { - for (GSList const *items = desktop->getSelection()->itemList(); - items != NULL; - items = items->next) - { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", NULL); @@ -271,11 +264,9 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb purge_repr_listener( tbl, tbl ); - for (GSList const *items = selection->itemList(); - items != NULL; - items = items->next) - { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index c906f7de4..401ce932a 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -76,7 +76,6 @@ static void sp_connector_path_set_ignore(void) static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl ) { SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); - Inkscape::Selection * selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); if (!DocumentUndo::getUndoSensitive(doc)) { @@ -98,9 +97,9 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl gchar *value = is_orthog ? orthog_str : polyline_str ; bool modmade = false; - GSList *l = (GSList *) selection->itemList(); - while (l) { - SPItem *item = SP_ITEM(l->data); + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (Inkscape::UI::Tools::cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-type", @@ -108,7 +107,6 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl item->avoidRef->handleSettingChange(); modmade = true; } - l = l->next; } if (!modmade) { @@ -126,7 +124,6 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) { SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); - Inkscape::Selection * selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); if (!DocumentUndo::getUndoSensitive(doc)) { @@ -147,9 +144,9 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) g_ascii_dtostr(value, G_ASCII_DTOSTR_BUF_SIZE, newValue); bool modmade = false; - GSList *l = (GSList *) selection->itemList(); - while (l) { - SPItem *item = SP_ITEM(l->data); + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (Inkscape::UI::Tools::cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-curvature", @@ -157,7 +154,6 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) item->avoidRef->handleSettingChange(); modmade = true; } - l = l->next; } if (!modmade) { diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index d60a92b8b..2c298b04d 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -481,7 +481,7 @@ void FillNStroke::updateFromPaint() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); + SelContainer const items = selection->itemList(); switch (psel->mode) { case SPPaintSelector::MODE_EMPTY: @@ -543,7 +543,7 @@ void FillNStroke::updateFromPaint() case SPPaintSelector::MODE_GRADIENT_LINEAR: case SPPaintSelector::MODE_GRADIENT_RADIAL: case SPPaintSelector::MODE_SWATCH: - if (items) { + if (!items.empty()) { SPGradientType const gradient_type = ( psel->mode != SPPaintSelector::MODE_GRADIENT_RADIAL ? SP_GRADIENT_TYPE_LINEAR : SP_GRADIENT_TYPE_RADIAL ); @@ -561,7 +561,7 @@ void FillNStroke::updateFromPaint() /* No vector in paint selector should mean that we just changed mode */ SPStyle query(desktop->doc()); - int result = objects_query_fillstroke(const_cast(items), &query, kind == FILL); + int result = objects_query_fillstroke(items, &query, kind == FILL); if (result == QUERY_STYLE_MULTIPLE_SAME) { SPIPaint &targPaint = (kind == FILL) ? query.fill : query.stroke; SPColor common; @@ -576,39 +576,39 @@ void FillNStroke::updateFromPaint() } } - for (GSList const *i = items; i != NULL; i = i->next) { + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { - sp_repr_css_change_recursive(reinterpret_cast(i->data)->getRepr(), css, "style"); + sp_repr_css_change_recursive(reinterpret_cast(*i)->getRepr(), css, "style"); } if (!vector) { SPGradient *gr = sp_gradient_vector_for_object( document, desktop, - reinterpret_cast(i->data), + reinterpret_cast(*i), (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE, createSwatch ); if ( gr && createSwatch ) { gr->setSwatch(); } - sp_item_set_gradient(SP_ITEM(i->data), + sp_item_set_gradient(SP_ITEM(*i), gr, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); } else { - sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); + sp_item_set_gradient(SP_ITEM(*i), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); } } } else { // We have changed from another gradient type, or modified spread/units within // this gradient type. vector = sp_gradient_ensure_vector_normalized(vector); - for (GSList const *i = items; i != NULL; i = i->next) { + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { - sp_repr_css_change_recursive(reinterpret_cast(i->data)->getRepr(), css, "style"); + sp_repr_css_change_recursive(reinterpret_cast(*i)->getRepr(), css, "style"); } - SPGradient *gr = sp_item_set_gradient(SP_ITEM(i->data), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); + SPGradient *gr = sp_item_set_gradient(SP_ITEM(*i), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); psel->pushAttrsToGradient( gr ); } } @@ -625,7 +625,7 @@ void FillNStroke::updateFromPaint() case SPPaintSelector::MODE_PATTERN: - if (items) { + if (!items.empty()) { SPPattern *pattern = psel->getPattern(); if (!pattern) { @@ -648,12 +648,12 @@ void FillNStroke::updateFromPaint() // cannot just call sp_desktop_set_style, because we don't want to touch those // objects who already have the same root pattern but through a different href // chain. FIXME: move this to a sp_item_set_pattern - for (GSList const *i = items; i != NULL; i = i->next) { - Inkscape::XML::Node *selrepr = reinterpret_cast(i->data)->getRepr(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + Inkscape::XML::Node *selrepr = reinterpret_cast(*i)->getRepr(); if ( (kind == STROKE) && !selrepr) { continue; } - SPObject *selobj = reinterpret_cast(i->data); + SPObject *selobj = reinterpret_cast(*i); SPStyle *style = selobj->style; if (style && ((kind == FILL) ? style->fill : style->stroke).isPaintserver()) { @@ -686,7 +686,7 @@ void FillNStroke::updateFromPaint() break; case SPPaintSelector::MODE_UNSET: - if (items) { + if (!items.empty()) { SPCSSAttr *css = sp_repr_css_attr_new(); if (kind == FILL) { sp_repr_css_unset_property(css, "fill"); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 7ce04403b..b9608130b 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -116,8 +116,9 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient } // If no drag or no dragger selected, act on selection - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - gr_apply_gradient_to_item(SP_ITEM(i->data), gr, initialType, initialMode, initialMode); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + gr_apply_gradient_to_item(SP_ITEM(*i), gr, initialType, initialMode, initialMode); } } @@ -217,8 +218,9 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr { SPGradient *gradient = 0; - for (GSList const* i = selection->itemList(); i; i = i->next) { - SPItem *item = SP_ITEM(i->data); // get the items gradient, not the getVector() version + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -284,8 +286,9 @@ void gr_read_selection( Inkscape::Selection *selection, } // If no selected dragger, read desktop selection - for (GSList const* i = selection->itemList(); i; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 3d549047a..b4176db6f 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -87,8 +87,9 @@ void ms_read_selection( Inkscape::Selection *selection, bool first = true; ms_smooth = SP_MESH_SMOOTH_NONE; - for (GSList const* i = selection->itemList(); i; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { @@ -213,8 +214,9 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient { SPMeshGradient *gradient = 0; - for (GSList const* i = selection->itemList(); i; i = i->next) { - SPItem *item = SP_ITEM(i->data); // get the items gradient, not the getVector() version + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 016aa4987..1f19867ee 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -106,12 +106,13 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - for (GSList const *items = selection->itemList(); items != NULL; items = items->next) { - if (SP_IS_RECT(items->data)) { + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + if (SP_IS_RECT(*i)) { if (gtk_adjustment_get_value(adj) != 0) { - (SP_RECT(items->data)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, desktop->getNamedView()->svg_units)); + (SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, desktop->getNamedView()->svg_units)); } else { - SP_OBJECT(items->data)->getRepr()->setAttribute(value_name, NULL); + SP_OBJECT(*i)->getRepr()->setAttribute(value_name, NULL); } modmade = true; } @@ -243,12 +244,11 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO } purge_repr_listener( tbl, tbl ); - for (GSList const *items = selection->itemList(); - items != NULL; - items = items->next) { - if (SP_IS_RECT(reinterpret_cast(items->data))) { + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + if (SP_IS_RECT(reinterpret_cast(*i))) { n_selected++; - item = reinterpret_cast(items->data); + item = reinterpret_cast(*i); repr = item->getRepr(); } } diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 3fb0015c1..2f4ad481d 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -79,11 +79,9 @@ 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; - for (GSList const *items = desktop->getSelection()->itemList(); - items != NULL; - items = items->next) - { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=desktop->getSelection()->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_SPIRAL(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double( repr, namespaced_name, @@ -197,11 +195,9 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, purge_repr_listener( tbl, tbl ); - for (GSList const *items = selection->itemList(); - items != NULL; - items = items->next) - { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_SPIRAL(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index cf12391c1..37daf69d0 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -83,9 +83,9 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_int(repr,"sodipodi:sides", @@ -128,9 +128,9 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -178,7 +178,6 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d g_object_set_data( dataKludge, "freeze", GINT_TO_POINTER(TRUE) ); Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); GtkAction* prop_action = GTK_ACTION( g_object_get_data( dataKludge, "prop_action" ) ); bool modmade = false; @@ -186,8 +185,9 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d gtk_action_set_sensitive( prop_action, !flat ); } - for (; items != NULL; items = items->next) { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("inkscape:flatsided", flat ? "true" : "false" ); @@ -224,9 +224,9 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:rounded", @@ -264,9 +264,9 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:randomized", @@ -367,11 +367,9 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) purge_repr_listener( tbl, tbl ); - for (GSList const *items = selection->itemList(); - items != NULL; - items = items->next) - { - SPItem* item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 5ca06a795..2599fe537 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -475,9 +475,9 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - GSList const *items = selection->itemList(); - for (; items != NULL; items = items->next) { - SPItem *item = reinterpret_cast(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + SPItem *item = SP_ITEM(*i); if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using continue; } @@ -901,8 +901,8 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - GSList const *objects = sel->itemList(); - SPObject * const object = SP_OBJECT(objects->data); + SelContainer const objects = sel->itemList(); + SPObject * const object = SP_OBJECT(objects.front()); SPStyle * const style = object->style; /* Markers */ @@ -957,13 +957,12 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - - GSList const *items = selection->itemList(); + SelContainer items=selection->itemList(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); - if (items) { + if (!items.empty()) { #if WITH_GTKMM_3_0 double width_typed = (*widthAdj)->get_value(); double const miterlimit = (*miterLimitAdj)->get_value(); @@ -978,13 +977,13 @@ StrokeStyle::scaleLine() int ndash; dashSelector->get_dash(&ndash, &dash, &offset); - for (GSList const *i = items; i != NULL; i = i->next) { + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ /* Set stroke width */ double width; if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { width = Inkscape::Util::Quantity::convert(width_typed, unit, "px"); } else { // percentage - gdouble old_w = SP_OBJECT(i->data)->style->stroke_width.computed; + gdouble old_w = SP_OBJECT(*i)->style->stroke_width.computed; width = old_w * width_typed / 100; } @@ -1003,7 +1002,7 @@ StrokeStyle::scaleLine() /* Set dash */ setScaledDash(css, ndash, dash, offset, width); - sp_desktop_apply_css_recursive (SP_OBJECT(i->data), css, true); + sp_desktop_apply_css_recursive (SP_OBJECT(*i), css, true); } g_free(dash); @@ -1144,7 +1143,7 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active) * that marker. */ void -StrokeStyle::updateAllMarkers(GSList const *objects) +StrokeStyle::updateAllMarkers(SelContainer const &objects) { struct { MarkerComboBox *key; int loc; } const keyloc[] = { { startMarkerCombo, SP_MARKER_LOC_START }, @@ -1153,8 +1152,8 @@ StrokeStyle::updateAllMarkers(GSList const *objects) }; bool all_texts = true; - for (GSList *i = (GSList *) objects; i != NULL; i = i->next) { - if (!SP_IS_TEXT (i->data)) { + for(SelContainer::const_iterator i=objects.begin();i!=objects.end();i++){ + if (!SP_IS_TEXT (*i)) { all_texts = false; } } @@ -1167,7 +1166,7 @@ StrokeStyle::updateAllMarkers(GSList const *objects) // We show markers of the first object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = SP_OBJECT(objects->data); + SPObject *object = SP_OBJECT(objects.front()); for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { // For all three marker types, diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index 83048cb76..286305ec3 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -153,7 +153,7 @@ private: }; void updateLine(); - void updateAllMarkers(GSList const *objects); + void updateAllMarkers(SelContainer const &objects); void updateMarkerHist(SPMarkerLoc const which); void setDashSelectorFromStyle(SPDashSelector *dsel, SPStyle *style); void setJoinType (unsigned const jointype); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 3d2e6eef8..ba7dfc1fd 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -366,9 +366,10 @@ 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(); - for (GSList const *items = selection->itemList(); items != NULL; items = items->next) { - if (SP_IS_TEXT(SP_ITEM(items->data))) { - SPItem *item = SP_ITEM(items->data); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + if (SP_IS_TEXT(SP_ITEM(*i))) { + SPItem *item = SP_ITEM(*i); unsigned writing_mode = item->style->writing_mode.value; // below, variable names suggest horizontal move, but we check the writing direction @@ -517,11 +518,11 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Until deprecated sodipodi:linespacing purged: Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); bool modmade = false; - for (; items != NULL; items = items->next) { - if (SP_IS_TEXT (items->data)) { - SP_OBJECT(items->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); + SelContainer itemlist=selection->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + if (SP_IS_TEXT (*i)) { + SP_OBJECT(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); modmade = true; } } @@ -863,12 +864,11 @@ 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; - for (GSList const *items = SP_ACTIVE_DESKTOP->getSelection()->itemList(); - items != NULL; - items = items->next) { + SelContainer itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ // const gchar* id = reinterpret_cast(items->data)->getId(); // std::cout << " " << id << std::endl; - if( SP_IS_FLOWTEXT(SP_ITEM(items->data))) { + if( SP_IS_FLOWTEXT(SP_ITEM(*i))) { isFlow = true; // std::cout << " Found flowed text" << std::endl; break; @@ -1153,14 +1153,14 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p //std::cout << "text_toolbox_missing_font_cb: selecting: " << family << std::endl; // Get all items with matching font-family set (not inherited!). - GSList *selectList = NULL; + SelContainer selectList; SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDocument *document = desktop->getDocument(); - GSList *allList = get_all_items(NULL, document->getRoot(), desktop, false, false, true, NULL); - for (GSList *i = allList; i != NULL; i = i->next) { - - SPItem *item = SP_ITEM(i->data); + SelContainer x,y; + SelContainer allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y); + for(SelContainer::const_iterator i=allList.begin();i!=allList.end();i++){ + SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; if (style) { @@ -1177,7 +1177,7 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p if (family_style.compare( family ) == 0 ) { //std::cout << " found: " << item->getId() << std::endl; - selectList = g_slist_prepend (selectList, item); + selectList.push_front(static_cast(item)); } } } -- cgit v1.2.3 From 193b25a53c51a36fe9538e03203b0054c8cfc355 Mon Sep 17 00:00:00 2001 From: mc <> Date: Wed, 18 Feb 2015 02:02:37 +0100 Subject: Just... some... more... lines... (bzr r13922.1.2) --- src/desktop.cpp | 2 +- src/desktop.h | 2 +- src/document.cpp | 32 ++++++++--------- src/document.h | 9 ++--- src/selection-chemistry.cpp | 13 ++++--- src/splivarot.h | 3 +- src/trace/trace.cpp | 6 ++-- src/ui/dialog/font-substitution.cpp | 24 +++++-------- src/ui/dialog/font-substitution.h | 6 ++-- src/ui/dialog/grid-arrange-tab.cpp | 54 ++++++++++++++++------------- src/ui/dialog/icon-preview.cpp | 8 ++--- src/ui/dialog/objects.cpp | 8 ++--- src/ui/dialog/pixelartdialog.cpp | 8 ++--- src/ui/dialog/polar-arrange-tab.cpp | 14 +++----- src/ui/dialog/print.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.cpp | 4 +-- src/ui/dialog/swatches.cpp | 6 ++-- src/ui/dialog/tags.cpp | 11 +++--- src/ui/dialog/text-edit.cpp | 26 +++++++------- src/ui/dialog/transformation.cpp | 41 ++++++++++++---------- src/ui/tools/connector-tool.cpp | 8 ++--- src/ui/tools/eraser-tool.cpp | 31 +++++++---------- src/ui/tools/gradient-tool.cpp | 43 +++++++++++++---------- src/ui/tools/gradient-tool.h | 3 +- src/ui/tools/lpe-tool.cpp | 8 ++--- src/ui/tools/measure-tool.cpp | 6 ++-- src/ui/tools/mesh-tool.cpp | 34 +++++++++++------- src/ui/tools/node-tool.cpp | 10 +++--- src/ui/tools/select-tool.cpp | 5 ++- src/ui/tools/spray-tool.cpp | 32 +++++++---------- src/ui/tools/text-tool.cpp | 7 ++-- src/ui/tools/tool-base.cpp | 6 ++-- src/ui/tools/tweak-tool.cpp | 25 ++++++------- src/ui/widget/object-composite-settings.cpp | 3 +- src/ui/widget/style-subject.cpp | 34 +++++++++--------- src/ui/widget/style-subject.h | 15 ++++---- 36 files changed, 270 insertions(+), 279 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index cdf8f276c..64353e582 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -716,7 +716,7 @@ Inkscape::UI::Widget::Dock* SPDesktop::getDock() { /** * \see SPDocument::getItemFromListAtPointBottom() */ -SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const +SPItem *SPDesktop::getItemFromListAtPointBottom(const SelContainer &list, Geom::Point const &p) const { g_return_val_if_fail (doc() != NULL, NULL); return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); diff --git a/src/desktop.h b/src/desktop.h index a0b9592d0..8765fa699 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -319,7 +319,7 @@ public: //void push_event_context (GType type, const gchar *config, unsigned int key); void set_coordinate_status (Geom::Point p); - SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const; + SPItem *getItemFromListAtPointBottom(const SelContainer &list, Geom::Point const &p) const; SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; SPItem *getGroupAtPoint(Geom::Point const &p) const; Geom::Point point() const; diff --git a/src/document.cpp b/src/document.cpp index 11971e63d..5c49ff6c3 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1235,7 +1235,7 @@ static bool overlaps(Geom::Rect const &area, Geom::Rect const &box) return area.intersects(box); } -static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, +static SelContainer &find_items_in_area(SelContainer &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false) { g_return_val_if_fail(SP_IS_GROUP(group), s); @@ -1248,7 +1248,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, SPItem *child = SP_ITEM(o); Geom::OptRect box = child->desktopVisualBounds(); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { - s = g_slist_append(s, child); + s.push_back(child); } } } @@ -1275,7 +1275,7 @@ static bool item_is_in_group(SPItem *item, SPGroup *group) return inGroup; } -SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive) +SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, SelContainer const &list,Geom::Point const &p, bool take_insensitive) { g_return_val_if_fail(group, NULL); SPItem *bottomMost = 0; @@ -1289,7 +1289,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); if (arenaitem && arenaitem->pick(p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { - if (g_slist_find((GSList *) list, item) != NULL) { + if (find(list.begin(),list.end(),item)==list.end() ) { bottomMost = item; } } @@ -1391,11 +1391,11 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin * Assumes box is normalized (and g_asserts it!) * */ -GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const +SelContainer SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const { - g_return_val_if_fail(this->priv != NULL, NULL); - - return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within); + SelContainer x; + g_return_val_if_fail(this->priv != NULL, x); + return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within); } /* @@ -1405,16 +1405,16 @@ GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) cons * */ -GSList *SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const +SelContainer SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const { - g_return_val_if_fail(this->priv != NULL, NULL); - - return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps); + SelContainer x; + g_return_val_if_fail(this->priv != NULL, x); + return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps); } -GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector points) const +SelContainer SPDocument::getItemsAtPoints(unsigned const key, std::vector points) const { - GSList *items = NULL; + SelContainer items; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // When picking along the path, we don't want small objects close together @@ -1426,8 +1426,8 @@ GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector #include #include +#include "selection.h" namespace Avoid { class Router; @@ -232,7 +233,7 @@ public: /** * Returns the bottommost item from the list which is at the point, or NULL if none. */ - static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const &p, bool take_insensitive = false); + static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const SelContainer &list, Geom::Point const &p, bool take_insensitive = false); static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri, char const *base, char const *name, unsigned int keepalive, @@ -256,10 +257,10 @@ public: bool addResource(char const *key, SPObject *object); bool removeResource(char const *key, SPObject *object); const GSList *getResourceList(char const *key) const; - GSList *getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; - GSList *getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; + SelContainer getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; + SelContainer getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; - GSList *getItemsAtPoints(unsigned const key, std::vector points) const; + SelContainer getItemsAtPoints(unsigned const key, std::vector points) const; SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; void changeUriAndHrefs(char const *uri); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f20df1594..05711e734 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -442,10 +442,10 @@ static void add_ids_recursive(std::vector &ids, SPObject *obj) } } } - +/* bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b){ return sp_repr_compare_position(dynamic_cast(a),dynamic_cast(b)); -} +}*/ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) { @@ -2301,7 +2301,7 @@ sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy) namespace { template -SPItem *next_item(SPDesktop *desktop, SelContainer &path, SPObject *root, +SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); template @@ -2481,19 +2481,18 @@ void sp_selection_edit_clip_or_mask(SPDesktop * /*dt*/, bool /*clip*/) namespace { template -SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, +SPItem *next_item_from_list(SPDesktop *desktop, SelContainer const items, SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) { SPObject *current=root; - while (items) { - SPItem *item = dynamic_cast(static_cast(items->data)); + for(SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + SPItem *item = dynamic_cast(static_cast(*i)); if ( root->isAncestorOf(item) && ( !only_in_viewport || desktop->isWithinViewport(item) ) ) { current = item; break; } - items = items->next; } GSList *path=NULL; diff --git a/src/splivarot.h b/src/splivarot.h index ba314399f..79b9b98a6 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -10,6 +10,7 @@ #include <2geom/forward.h> #include <2geom/path.h> #include "livarot/Path.h" +#include "sp-object.h"//kill it class SPCurve; class SPDesktop; @@ -18,7 +19,7 @@ class SPItem; namespace Inkscape { class Selection; } - +bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b);//kill it with fire // boolean operations // work on the current selection // selection has 2 contain exactly 2 items diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 892ecdb87..2becca5cc 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -74,13 +74,13 @@ SPImage *Tracer::getSelectedSPImage() them as bottom-to-top so that we can discover the image and any SPItems above it */ - for(SelContainer::const_iterator x=list.begin();x!=list.end();x++){ + for (SelContainer::const_iterator i=list.begin() ; list.end()!=i ; i++) { - if (!SP_IS_ITEM(*x)) + if (!SP_IS_ITEM(*i)) { continue; } - SPItem *item = SP_ITEM(*x); + SPItem *item = SP_ITEM(*i); items.insert(items.begin(), item); } std::vector::iterator iter; diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index ae03bdf0e..625ed99b9 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -70,19 +70,15 @@ FontSubstitution::checkFontSubstitutions(SPDocument* doc) int show_dlg = prefs->getInt("/options/font/substitutedlg", 0); if (show_dlg) { Glib::ustring out; - GSList *l = getFontReplacedItems(doc, &out); + SelContainer l = getFontReplacedItems(doc, &out); if (out.length() > 0) { show(out, l); } - if (l) { - g_slist_free(l); - l = NULL; - } } } void -FontSubstitution::show(Glib::ustring out, GSList *l) +FontSubstitution::show(Glib::ustring out, SelContainer &l) { Gtk::MessageDialog warning(_("\nSome fonts are not available and have been substituted."), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true); @@ -152,20 +148,18 @@ FontSubstitution::show(Glib::ustring out, GSList *l) * b. Build up a list of the objects rendered fonts - taken for the objects layout/spans * If there are fonts in a. that are not in b. then those fonts have been substituted. */ -GSList * FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *out) +SelContainer FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *out) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - GSList *allList = NULL; - GSList *outList = NULL; + SelContainer allList; + SelContainer outList,x,y; std::set setErrors; std::set setFontSpans; std::map mapFontStyles; - allList = get_all_items(NULL, doc->getRoot(), desktop, false, false, true, NULL); - - for (GSList *i = allList; i != NULL; i = i->next) { - - SPItem *item = SP_ITEM(i->data); + allList = get_all_items(x, doc->getRoot(), desktop, false, false, true, y); + for(SelContainer::const_iterator i = allList.begin();i!=allList.end();i++){ + SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; Glib::ustring family = ""; @@ -254,7 +248,7 @@ GSList * FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring * Glib::ustring err = Glib::ustring::compose( _("Font '%1' substituted with '%2'"), fonts.c_str(), subName.c_str()); setErrors.insert(err); - outList = g_slist_prepend (outList, item); + outList.push_front(item); } } diff --git a/src/ui/dialog/font-substitution.h b/src/ui/dialog/font-substitution.h index 1c445081b..eed7adcf2 100644 --- a/src/ui/dialog/font-substitution.h +++ b/src/ui/dialog/font-substitution.h @@ -13,7 +13,7 @@ #define INKSCAPE_UI_FONT_SUBSTITUTION_H #include - +#include "selection.h" class SPDocument; namespace Inkscape { @@ -25,13 +25,13 @@ public: FontSubstitution(); virtual ~FontSubstitution(); void checkFontSubstitutions(SPDocument* doc); - void show(Glib::ustring out, GSList *l); + void show(Glib::ustring out, SelContainer &l); static FontSubstitution &getInstance() { return *new FontSubstitution(); } Glib::ustring getSubstituteFontName (Glib::ustring font); protected: - GSList *getFontReplacedItems(SPDocument* doc, Glib::ustring *out); + SelContainer getFontReplacedItems(SPDocument* doc, Glib::ustring *out); private: FontSubstitution(FontSubstitution const &d); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index d3ccb9bde..ba8616d9b 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -109,6 +109,13 @@ static int sp_compare_y_position(SPItem *first, SPItem *second) return 0; } +static bool sp_compare_y_position_obj(SPObject *first, SPObject *second){ + return sp_compare_y_position(static_cast(first),static_cast(second))<0; +} +static bool sp_compare_x_position_obj(SPObject *first, SPObject *second){ + return sp_compare_x_position(static_cast(first),static_cast(second))<0; +} + namespace Inkscape { namespace UI { @@ -168,10 +175,10 @@ void GridArrangeTab::arrange() desktop->getDocument()->ensureUpToDate(); Inkscape::Selection *selection = desktop->getSelection(); - const GSList *items = selection ? selection->itemList() : 0; + const SelContainer items = selection ? selection->itemList() : SelContainer(); cnt=0; - for (; items != NULL; items = items->next) { - SPItem *item = SP_ITEM(items->data); + for(SelContainer::const_iterator i = items.begin();i!=items.end();i++){ + SPItem *item = SP_ITEM(*i); Geom::OptRect b = item->documentVisualBounds(); if (!b) { continue; @@ -198,20 +205,19 @@ void GridArrangeTab::arrange() // require the sorting done before we can calculate row heights etc. g_return_if_fail(selection); - const GSList *items2 = selection->itemList(); - GSList *rev = g_slist_copy(const_cast(items2)); - GSList *sorted = NULL; - rev = g_slist_sort(rev, (GCompareFunc) sp_compare_y_position); - sorted = g_slist_sort(rev, (GCompareFunc) sp_compare_x_position); + SelContainer rev(selection->itemList()); + rev.sort(sp_compare_y_position_obj); + SelContainer sorted(rev); + sorted.sort(sp_compare_x_position_obj); // Calculate individual Row and Column sizes if necessary cnt=0; - const GSList *sizes = sorted; - for (; sizes != NULL; sizes = sizes->next) { - SPItem *item = SP_ITEM(sizes->data); + const SelContainer sizes(sorted); + for (SelContainer::const_iterator i = sizes.begin();i!=sizes.end();i++) { + SPItem *item = SP_ITEM(*i); Geom::OptRect b = item->documentVisualBounds(); if (b) { width = b->dimensions()[Geom::X]; @@ -308,12 +314,14 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h } cnt=0; - for (row_cnt=0; ((sorted != NULL) && (row_cntdata); - sorted = sorted->next; + col_cnt = 0; + for(;it!=sorted.end()&&colnext) { @@ -374,8 +382,8 @@ void GridArrangeTab::on_row_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); - GSList const *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); + SelContainer const items = selection->itemList(); + int selcount = items.size(); double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); NoOfRowsSpinner.set_value(PerCol); @@ -400,8 +408,7 @@ void GridArrangeTab::on_col_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail(selection); - GSList const *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); + int selcount = selection->itemList().size(); double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); NoOfColsSpinner.set_value(PerRow); @@ -538,10 +545,10 @@ void GridArrangeTab::updateSelection() updating = true; SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; - GSList const *items = selection ? selection->itemList() : 0; + SelContainer const items = selection ? selection->itemList() : SelContainer(); - if (items) { - int selcount = g_slist_length((GSList *)items); + if (!items.empty()) { + int selcount = items.size(); if (NoOfColsSpinner.get_value() > 1 && NoOfRowsSpinner.get_value() > 1){ // Update the number of rows assuming number of columns wanted remains same. @@ -609,8 +616,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) g_return_if_fail( selection ); int selcount = 1; if (!selection->isEmpty()) { - GSList const *items = selection->itemList(); - selcount = g_slist_length((GSList *)items); + selcount = selection->itemList().size(); } diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index b908a90cb..79e5b556d 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -366,16 +366,14 @@ void IconPreviewPanel::refreshPreview() if ( sel ) { //g_message("found a selection to play with"); - GSList const *items = sel->itemList(); - while ( items && !target ) { - SPItem* item = SP_ITEM( items->data ); + SelContainer const items = sel->itemList(); + for(SelContainer::const_iterator i=items.begin();!target && i!=items.end();i++){ + SPItem* item = SP_ITEM( *i); gchar const *id = item->getId(); if ( id ) { targetId = id; target = item; } - - items = g_slist_next(items); } } } diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index c95529a56..0ae3027c7 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -479,15 +479,15 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); SPItem *item = NULL; - for (const GSList * iter = sel->itemList(); iter != NULL; iter = iter->next) - { - item = reinterpret_cast(iter->data); + SelContainer const items = sel->itemList(); + for(SelContainer::const_iterator i=items.begin(); i!=items.end();i++){ + item = reinterpret_cast(*i); if (setOpacity) { _setCompositingValues(item); setOpacity = false; } - _store->foreach(sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_checkForSelected), item, iter->next == NULL)); + _store->foreach(sigc::bind( sigc::mem_fun(*this, &ObjectsPanel::_checkForSelected), item, (*i)==items.back())); } if (!item) { if (_desktop->currentLayer() && SP_IS_ITEM(_desktop->currentLayer())) { diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 5113f172a..273a378e5 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -372,12 +372,12 @@ void PixelArtDialogImpl::vectorize() return; } - for ( GSList const *list = desktop->selection->itemList() ; list - ; list = list->next ) { - if ( !SP_IS_IMAGE(list->data) ) + SelContainer const items = desktop->selection->itemList(); + for(SelContainer::const_iterator i=items.begin(); i!=items.end();i++){ + if ( !SP_IS_IMAGE(*i) ) continue; - SPImage *img = SP_IMAGE(list->data); + SPImage *img = SP_IMAGE(*i); Input input; input.pixbuf = Glib::wrap(img->pixbuf->getPixbufRaw(), true); input.x = img->x; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 281958998..8a382fc93 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -297,19 +297,18 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { Inkscape::Selection *selection = parent->getDesktop()->getSelection(); - const GSList *items, *tmp; - tmp = items = selection->itemList(); + const SelContainer tmp(selection->itemList()); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); int count = 0; - while(tmp) + for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) { if(arrangeOnEllipse) { - SPItem *item = SP_ITEM(tmp->data); + SPItem *item = SP_ITEM(*i); if(arrangeOnFirstEllipse) { @@ -322,7 +321,6 @@ void PolarArrangeTab::arrange() referenceEllipse = SP_GENERICELLIPSE(item); } } - tmp = tmp->next; ++count; } @@ -374,11 +372,10 @@ void PolarArrangeTab::arrange() Geom::Point realCenter = Geom::Point(cx, cy) * transformation; - tmp = items; int i = 0; - while(tmp) + for(SelContainer::const_iterator it=tmp.begin();it!=tmp.end();it++) { - SPItem *item = SP_ITEM(tmp->data); + SPItem *item = SP_ITEM(*it); // Ignore the reference ellipse if any if(item != referenceEllipse) @@ -396,7 +393,6 @@ void PolarArrangeTab::arrange() ++i; } - tmp = tmp->next; } DocumentUndo::done(parent->getDesktop()->getDocument(), SP_VERB_SELECTION_ARRANGE, diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index a015d28f9..dc98b6032 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -81,7 +81,7 @@ static void draw_page( width, height, (unsigned long)(Inkscape::Util::Quantity::convert(width, "px", "in") * dpi), (unsigned long)(Inkscape::Util::Quantity::convert(height, "px", "in") * dpi), - dpi, dpi, bgcolor, NULL, NULL, true, NULL); + dpi, dpi, bgcolor, NULL, NULL, true, SelContainer()); // This doesn't seem to work: //context->set_cairo_context ( Cairo::Context::create (Cairo::ImageSurface::create_from_png (tmp_png) ), dpi, dpi ); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index bc228633d..8f5601e3a 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 = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0); + Inkscape::XML::Node* node = (Inkscape::XML::Node*)(sel->reprList().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 = (Inkscape::XML::Node*) g_slist_nth_data((GSList *)sel->reprList(), 0); + Inkscape::XML::Node* node = (Inkscape::XML::Node*)(sel->reprList().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 8759039c3..da24ad605 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -123,10 +123,10 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) bool shown = false; if ( desktop && desktop->doc() ) { Inkscape::Selection *selection = desktop->getSelection(); - GSList const *items = selection->itemList(); - if (items) { + SelContainer const items = selection->itemList(); + if (!items.empty()) { SPStyle query( desktop->doc() ); - int result = objects_query_fillstroke(const_cast(items), &query, true); + int result = objects_query_fillstroke((items), &query, true); if ( (result == QUERY_STYLE_MULTIPLE_SAME) || (result == QUERY_STYLE_SINGLE) ) { // could be pertinent if (query.fill.isPaintserver()) { diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 8a104d137..ba3a6b914 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -371,9 +371,10 @@ void TagsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); - for (const GSList * iter = sel->list(); iter != NULL; iter = iter->next) + SelContainer tmp=sel->list(); + for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) { - SPObject *obj = reinterpret_cast(iter->data); + SPObject *obj = reinterpret_cast(*i); _store->foreach(sigc::bind( sigc::mem_fun(*this, &TagsPanel::_checkForSelected), obj)); } _selectedConnection.unblock(); @@ -668,9 +669,9 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) if (col == _tree.get_column(COL_ADD - 1) && down_at_add) { if (SP_IS_TAG(obj)) { bool wasadded = false; - for (const GSList * iter = _desktop->selection->itemList(); iter != NULL; iter = iter->next) - { - SPObject *newobj = reinterpret_cast(iter->data); + SelContainer items=_desktop->selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPObject *newobj = reinterpret_cast(*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) { diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index a8be8b543..593261ec5 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -418,12 +418,11 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - for (const GSList *item = SP_ACTIVE_DESKTOP->getSelection()->itemList(); - item != NULL; - item = item->next) + SelContainer tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) { - if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) - return SP_ITEM (item->data); + if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) + return SP_ITEM (*i); } return NULL; @@ -437,11 +436,10 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - for (const GSList *item = SP_ACTIVE_DESKTOP->getSelection()->itemList(); - item != NULL; - item = item->next) + SelContainer tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) { - if (SP_IS_TEXT(item->data) || SP_IS_FLOWTEXT(item->data)) + if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) ++items; } @@ -542,20 +540,20 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const GSList *item_list = desktop->getSelection()->itemList(); + const SelContainer item_list = desktop->getSelection()->itemList(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); - for (; item_list != NULL; item_list = item_list->next) { + for(SelContainer::const_iterator i=item_list.begin();i!=item_list.end();i++){ // apply style to the reprs of all text objects in the selection - if (SP_IS_TEXT (item_list->data)) { + if (SP_IS_TEXT (*i)) { // backwards compatibility: - reinterpret_cast(item_list->data)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); + reinterpret_cast(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++items; } - else if (SP_IS_FLOWTEXT (item_list->data)) + else if (SP_IS_FLOWTEXT (*i)) // no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext ++items; } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 233d99750..8c52144e0 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -655,7 +655,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - Geom::Affine current (SP_ITEM(selection->itemList()->data)->transform); // take from the first item in selection + Geom::Affine current (SP_ITEM(selection->itemList().front())->transform); // take from the first item in selection Geom::Affine new_displayed = current; @@ -741,19 +741,19 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { // shift each object relatively to the previous one using Inkscape::Util::GSListConstIterator; - std::list selected; - selected.insert >(selected.end(), selection->itemList(), NULL); + SelContainer selected(selection->itemList()); if (selected.empty()) return; if (fabs(x) > 1e-6) { std::vector< BBoxSort > sorted; - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->desktopPreferredBounds(); + SPItem* item=static_cast(*it); + Geom::OptRect bbox = (item)->desktopPreferredBounds(); if (bbox) { - sorted.push_back(BBoxSort(*it, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); + sorted.push_back(BBoxSort(item, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } } //sort bbox by anchors @@ -771,13 +771,14 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } if (fabs(y) > 1e-6) { std::vector< BBoxSort > sorted; - for (std::list::iterator it(selected.begin()); + for (SelContainer::iterator it(selected.begin()); it != selected.end(); ++it) { - Geom::OptRect bbox = (*it)->desktopPreferredBounds(); + SPItem* item=static_cast(*it); + Geom::OptRect bbox = (item)->desktopPreferredBounds(); if (bbox) { - sorted.push_back(BBoxSort(*it, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); + sorted.push_back(BBoxSort(item, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } } //sort bbox by anchors @@ -815,8 +816,9 @@ 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")) { - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { - SPItem *item = SP_ITEM(l->data); + SelContainer tmp=selection->itemList(); + for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + SPItem *item = SP_ITEM(*i); Geom::OptRect bbox_pref = item->desktopPreferredBounds(); Geom::OptRect bbox_geom = item->desktopGeometricBounds(); if (bbox_pref && bbox_geom) { @@ -878,8 +880,9 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } if (prefs->getBool("/dialogs/transformation/applyseparately")) { - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { - SPItem *item = SP_ITEM(l->data); + SelContainer tmp=selection->itemList(); + for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + SPItem *item = SP_ITEM(*i); sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } } else { @@ -897,8 +900,9 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { - SPItem *item = SP_ITEM(l->data); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i = items.begin();i!=items.end();i++){ + SPItem *item = SP_ITEM(*i); if (!_units_skew.isAbsolute()) { // percentage double skewX = _scalar_skew_horizontal.getValue("%"); @@ -998,8 +1002,9 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) } if (_check_replace_matrix.get_active()) { - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { - SPItem *item = SP_ITEM(l->data); + SelContainer tmp=selection->itemList(); + for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + SPItem *item = SP_ITEM(*i); item->set_item_transform(displayed); SP_OBJECT(item)->updateRepr(); } @@ -1150,7 +1155,7 @@ void Transformation::onReplaceMatrixToggled() double f = _scalar_transform_f.getValue(); Geom::Affine displayed (a, b, c, d, e, f); - Geom::Affine current = SP_ITEM(selection->itemList()->data)->transform; // take from the first item in selection + Geom::Affine current = SP_ITEM(selection->itemList().front())->transform; // take from the first item in selection Geom::Affine new_displayed; if (_check_replace_matrix.get_active()) { diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 26a4eadd5..fc40c20e7 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1313,12 +1313,12 @@ void cc_selection_set_avoid(bool const set_avoid) Inkscape::Selection *selection = desktop->getSelection(); - GSList *l = const_cast(selection->itemList()); int changes = 0; - while (l) { - SPItem *item = SP_ITEM(l->data); + SelContainer l = selection->itemList(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++) { + SPItem *item = SP_ITEM(*i); char const *value = (set_avoid) ? "true" : NULL; @@ -1327,8 +1327,6 @@ void cc_selection_set_avoid(bool const set_avoid) item->avoidRef->handleSettingChange(); changes++; } - - l = l->next; } if (changes == 0) { diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 1b4dcfe25..3526e015a 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -676,7 +676,7 @@ void EraserTool::set_to_accumulated() { Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; - GSList* toWorkOn = 0; + SelContainer toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { @@ -686,16 +686,16 @@ void EraserTool::set_to_accumulated() { toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - toWorkOn = g_slist_remove( toWorkOn, acid ); + toWorkOn.remove(static_cast(acid) ); } else { - toWorkOn = g_slist_copy(const_cast(selection->itemList())); + toWorkOn = selection->itemList(); wasSelection = true; } - if ( g_slist_length(toWorkOn) > 0 ) { + if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (GSList *i = toWorkOn ; i ; i = i->next ) { - SPItem *item = SP_ITEM(i->data); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + SPItem *item = SP_ITEM(*i); if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); @@ -712,13 +712,10 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - GSList *nowSel = g_slist_copy(const_cast(selection->itemList())); - - for (GSList const *i2 = nowSel ; i2 ; i2 = i2->next ) { - remainingItems.push_back(SP_ITEM(i2->data)); + SelContainer nowSel(selection->itemList()); + for (SelContainer::const_iterator i2 = nowSel.begin();i!=nowSel.end();i++) { + remainingItems.push_back(SP_ITEM(*i2)); } - - g_slist_free(nowSel); } } else { remainingItems.push_back(item); @@ -726,20 +723,18 @@ void EraserTool::set_to_accumulated() { } } } else { - for (GSList *i = toWorkOn ; i ; i = i->next ) { - sp_object_ref( SP_ITEM(i->data), 0 ); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + sp_object_ref( SP_ITEM(*i), 0 ); } - for (GSList *i = toWorkOn ; i ; i = i->next ) { - SPItem *item = SP_ITEM(i->data); + for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + SPItem *item = SP_ITEM(*i); item->deleteObject(true); sp_object_unref(item); workDone = true; } } - g_slist_free(toWorkOn); - if ( !eraserMode ) { //sp_selection_delete(desktop); remainingItems.clear(); diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 5da30da7b..d1db5fb93 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -116,7 +116,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) { if (selection == NULL) { return; } - guint n_obj = g_slist_length((GSList *) selection->itemList()); + guint n_obj = selection->itemList().size(); if (!drag->isNonEmpty() || selection->isEmpty()) return; @@ -502,10 +502,11 @@ 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()->data), this->mousepoint_doc, event->button.time); + sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer items=selection->itemList(); + for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + SPItem *item = SP_ITEM(*i); SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -889,6 +890,12 @@ bool GradientTool::root_handler(GdkEvent* event) { return ret; } +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) +{ + return sp_repr_compare_position(((SPItem*)first)->getRepr(), + ((SPItem*)second)->getRepr())<0; +} + static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -908,32 +915,32 @@ 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 - GSList *items = g_slist_copy ((GSList *) selection->itemList()); - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); + SelContainer items(selection->itemList()); + items.sort(sp_item_repr_compare_position_obj); // take topmost - vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke); - g_slist_free (items); + vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - for (GSList const *i = selection->itemList(); i != NULL; i = i->next) { + SelContainer itemlist = selection->itemList(); + for (SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(i->data)->getRepr(), css, "style"); + sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); if (type == SP_GRADIENT_TYPE_LINEAR) { - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_END, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_END, 0, pt, fill_or_stroke, true, false); } else if (type == SP_GRADIENT_TYPE_RADIAL) { - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_R1, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_R1, 0, pt, fill_or_stroke, true, false); } - SP_OBJECT(i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG); + SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } if (ec->_grdrag) { ec->_grdrag->updateDraggers(); @@ -942,7 +949,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 (SP_ITEM(selection->itemList()->data), + ec->_grdrag->grabKnot (SP_ITEM(selection->itemList().front()), 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); @@ -951,7 +958,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 = g_slist_length((GSList *) selection->itemList()); + int n_objects = selection->itemList().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/gradient-tool.h b/src/ui/tools/gradient-tool.h index 6fe3bca9f..786aed372 100644 --- a/src/ui/tools/gradient-tool.h +++ b/src/ui/tools/gradient-tool.h @@ -18,6 +18,7 @@ #include #include #include "ui/tools/tool-base.h" +class SPObject;//kill it #define SP_GRADIENT_CONTEXT(obj) (dynamic_cast((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_GRADIENT_CONTEXT(obj) (dynamic_cast((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) @@ -25,12 +26,12 @@ namespace Inkscape { namespace UI { namespace Tools { +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second);//kill it class GradientTool : public ToolBase { public: GradientTool(); virtual ~GradientTool(); - Geom::Point origin; bool cursor_addnode; diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index c9b656397..ce0ad7a9a 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -407,10 +407,10 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - - for (GSList const *i = selection->itemList(); i != NULL; i = i->next) { - if (SP_IS_PATH(i->data)) { - path = SP_PATH(i->data); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + if (SP_IS_PATH(*i)) { + path = SP_PATH(*i); curve = path->getCurve(); Geom::Piecewise > pwd2 = paths_to_pw(curve->get_pathvector()); canvas_text = (SPCanvasText *) sp_canvastext_new(tmpgrp, lc->desktop, Geom::Point(0,0), ""); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index b7e54b9c8..8d52210ff 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -441,10 +441,10 @@ bool MeasureTool::root_handler(GdkEvent* event) { // TODO switch to a different variable name. The single letter 'l' is easy to misread. //select elements crossed by line segment: - GSList *items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); + SelContainer items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector intersection_times; - for (GSList *l = items; l != NULL; l = l->next) { - SPItem *item = static_cast(l->data); + for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + SPItem *item = static_cast(*i); if (SP_IS_SHAPE(item)) { calculate_intersections(desktop, item, lineseg, SP_SHAPE(item)->getCurve(), intersection_times); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index d333b932e..1cc06a5b9 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -48,6 +48,7 @@ // Mesh specific #include "ui/tools/mesh-tool.h" +#include "ui/tools/gradient-tool.h"//not needed #include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" @@ -113,7 +114,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { return; } - guint n_obj = g_slist_length((GSList *) selection->itemList()); + guint n_obj = selection->itemList().size(); if (!drag->isNonEmpty() || selection->isEmpty()) { return; @@ -477,11 +478,12 @@ 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, SP_ITEM(selection->itemList()->data), this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { - SPItem *item = SP_ITEM(i->data); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = SP_ITEM(*i); SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -930,6 +932,12 @@ bool MeshTool::root_handler(GdkEvent* event) { return ret; } +/* +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) +{ + return sp_repr_compare_position(((SPItem*)first)->getRepr(), + ((SPItem*)second)->getRepr())<0; +}*/ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -950,27 +958,27 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ } else { // Starting from empty space: // Sort items so that the topmost comes last - GSList *items = g_slist_copy ((GSList *) selection->itemList()); - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); + SelContainer items(selection->itemList()); + items.sort(sp_item_repr_compare_position_obj); // take topmost - vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke); - g_slist_free (items); + vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } // HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - for (GSList const *i = selection->itemList(); i != NULL; i = i->next) { + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(i->data)->getRepr(), css, "style"); + sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); // We don't need to do anything. Mesh is already sized appropriately. - SP_OBJECT(i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG); + SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } // if (ec->_grdrag) { // ec->_grdrag->updateDraggers(); @@ -988,7 +996,7 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = g_slist_length((GSList *) selection->itemList()); + int n_objects = selection->itemList().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 caec901a6..46c978c84 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -420,10 +420,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set shapes; - GSList const *ilist = sel->itemList(); - - for (GSList *i = const_cast(ilist); i; i = i->next) { - SPObject *obj = static_cast(i->data); + SelContainer items=sel->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPObject *obj = static_cast(*i); if (SP_IS_ITEM(obj)) { gather_items(this, NULL, static_cast(obj), SHAPE_ROLE_NORMAL, shapes); @@ -668,9 +667,8 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { if (this->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes Inkscape::Selection *selection = this->desktop->selection; - GSList *items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); + SelContainer items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); selection->setList(items); - g_slist_free(items); } else { if (!held_shift(*event)) { this->_selected_nodes->clear(); diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 939b1a0b3..f84170631 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -481,7 +481,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = static_cast(selection->itemList()->data); + SPItem *clicked_item = static_cast(selection->itemList().front()); if (dynamic_cast(clicked_item) && !dynamic_cast(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); @@ -718,7 +718,7 @@ bool SelectTool::root_handler(GdkEvent* event) { if (r->is_started() && !within_tolerance) { // this was a rubberband drag - GSList *items = NULL; + SelContainer items; if (r->getMode() == RUBBERBAND_MODE_RECT) { Geom::OptRect const b = r->getRectangle(); @@ -739,7 +739,6 @@ bool SelectTool::root_handler(GdkEvent* event) { selection->setList (items); } - g_slist_free (items); } else { // it was just a click, or a too small rubberband r->stop(); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index a01c5c55b..d339f6d19 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -188,7 +188,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -436,11 +436,9 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - for (GSList *items = g_slist_copy(const_cast(selection->itemList())); - items != NULL; - items = items->next) { - - SPItem *item1 = dynamic_cast(static_cast(items->data)); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator it=items.begin();it!=items.end();it++){ + SPItem *item1 = dynamic_cast(static_cast(*it)); if (i == 1) { parent_item = item1; } @@ -552,20 +550,16 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - GSList *const original_selection = g_slist_copy(const_cast(selection->itemList())); + SelContainer const items(selection->itemList()); - for (GSList *items = original_selection; - items != NULL; - items = items->next) { - SPItem *item = dynamic_cast(static_cast(items->data)); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_ref(item); } - for (GSList *items = original_selection; - items != NULL; - items = items->next) { - SPItem *item = dynamic_cast(static_cast(items->data)); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); if (is_transform_modes(tc->mode)) { @@ -579,10 +573,8 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } } - for (GSList *items = original_selection; - items != NULL; - items = items->next) { - SPItem *item = dynamic_cast(static_cast(items->data)); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_unref(item); } @@ -658,7 +650,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index df0583d67..a4370256d 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -1470,7 +1470,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) } sp_text_context_validate_cursor_iterators(this); - GSList *styles_list = NULL; + SelContainer styles_list; Inkscape::Text::Layout::iterator begin_it, end_it; if (this->text_sel_start < this->text_sel_end) { @@ -1486,7 +1486,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) } } for (Inkscape::Text::Layout::iterator it = begin_it ; it < end_it ; it.nextStartOfSpan()) { - SPObject const *pos_obj = 0; + SPObject *pos_obj = 0; void *rawptr = 0; layout->getSourceOfCharacter(it, &rawptr); if (!rawptr || !SP_IS_OBJECT(rawptr)) { @@ -1496,12 +1496,11 @@ int TextTool::_styleQueried(SPStyle *style, int property) while (SP_IS_STRING(pos_obj) && pos_obj->parent) { pos_obj = pos_obj->parent; // SPStrings don't have style } - styles_list = g_slist_prepend(styles_list, (gpointer)pos_obj); + styles_list.push_front(pos_obj); } int result = sp_desktop_query_style_from_list (styles_list, style, property); - g_slist_free(styles_list); return result; } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index a07f2fb86..cc05f9775 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1178,11 +1178,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, SPItem * sp_event_context_over_item(SPDesktop *desktop, SPItem *item, Geom::Point const &p) { - GSList *temp = NULL; - temp = g_slist_prepend(temp, item); + SelContainer temp; + temp.push_front(static_cast(item)); SPItem *item_at_point = desktop->getItemFromListAtPointBottom(temp, p); - g_slist_free(temp); - return item_at_point; } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 5e53fdb93..9342127ce 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -163,7 +163,7 @@ void TweakTool::update_cursor (bool with_shift) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); sel_message = g_strdup_printf(ngettext("%i object selected","%i objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("Nothing selected")); @@ -382,14 +382,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } if (dynamic_cast(item) || dynamic_cast(item)) { - GSList *items = g_slist_prepend (NULL, item); - GSList *selected = NULL; - GSList *to_select = NULL; + SelContainer items; + items.push_back(item); + SelContainer selected; + SelContainer to_select; SPDocument *doc = item->document; - sp_item_list_to_curves (items, &selected, &to_select); - g_slist_free (items); - SPObject* newObj = doc->getObjectByRepr(static_cast(to_select->data)); - g_slist_free (to_select); + sp_item_list_to_curves (items, selected, to_select); + SPObject* newObj = doc->getObjectByRepr(dynamic_cast(to_select.front())); item = dynamic_cast(newObj); g_assert(item != NULL); selection->add(item); @@ -1088,11 +1087,9 @@ 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); - for (GSList *items = g_slist_copy(const_cast(selection->itemList())); - items != NULL; - items = items->next) { - - SPItem *item = dynamic_cast(static_cast(items->data)); + SelContainer items=selection->itemList(); + for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + SPItem *item = dynamic_cast(static_cast(*i)); if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { @@ -1199,7 +1196,7 @@ bool TweakTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = g_slist_length(const_cast(desktop->selection->itemList())); + num = desktop->selection->itemList().size(); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to tweak.")); diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 00a74c4fe..ddf67fb5b 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -125,7 +125,8 @@ ObjectCompositeSettings::_blendBlurValueChanged() const Glib::ustring blendmode = _fe_cb.get_blend_mode(); //apply created filter to every selected item - for (StyleSubject::iterator i = _subject->begin() ; i != _subject->end() ; ++i ) { + SelContainer sel=_subject->getDesktop()->getSelection()->itemList(); + for (SelContainer::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) { if (!SP_IS_ITEM(*i)) { continue; } diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index a48370d9b..9d09e67d3 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -54,7 +54,7 @@ Inkscape::Selection *StyleSubject::Selection::_getSelection() const { return NULL; } } - +/* StyleSubject::iterator StyleSubject::Selection::begin() { Inkscape::Selection *selection = _getSelection(); if (selection) { @@ -62,7 +62,7 @@ StyleSubject::iterator StyleSubject::Selection::begin() { } else { return iterator(NULL); } -} +}*/ Geom::OptRect StyleSubject::Selection::getBounds(SPItem::BBoxType type) { Inkscape::Selection *selection = _getSelection(); @@ -104,8 +104,7 @@ void StyleSubject::Selection::setCSS(SPCSSAttr *css) { } StyleSubject::CurrentLayer::CurrentLayer() { - _element.data = NULL; - _element.next = NULL; + _element = NULL; } StyleSubject::CurrentLayer::~CurrentLayer() { @@ -114,10 +113,10 @@ StyleSubject::CurrentLayer::~CurrentLayer() { void StyleSubject::CurrentLayer::_setLayer(SPObject *layer) { _layer_release.disconnect(); _layer_modified.disconnect(); - if (_element.data) { - sp_object_unref(static_cast(_element.data), NULL); + if (_element) { + sp_object_unref(static_cast(_element), NULL); } - _element.data = layer; + _element = layer; if (layer) { sp_object_ref(layer, NULL); _layer_release = layer->connectRelease(sigc::hide(sigc::bind(sigc::mem_fun(*this, &CurrentLayer::_setLayer), (SPObject *)NULL))); @@ -127,20 +126,17 @@ void StyleSubject::CurrentLayer::_setLayer(SPObject *layer) { } SPObject *StyleSubject::CurrentLayer::_getLayer() const { - return static_cast(_element.data); + return static_cast(_element); } -GSList *StyleSubject::CurrentLayer::_getLayerSList() const { - if (_element.data) { - return &_element; - } else { - return NULL; - } -} +SPObject *StyleSubject::CurrentLayer::_getLayerSList() const { + return _element; +} +/* StyleSubject::iterator StyleSubject::CurrentLayer::begin() { return iterator(_getLayerSList()); -} +}*/ Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { SPObject *layer = _getLayer(); @@ -152,8 +148,10 @@ Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { } int StyleSubject::CurrentLayer::queryStyle(SPStyle *query, int property) { - GSList *list = _getLayerSList(); - if (list) { + SelContainer list; + SPObject* i=_getLayerSList(); + if (i) { + list.push_back(i); return sp_desktop_query_style_from_list(list, query, property); } else { return QUERY_STYLE_NOTHING; diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h index 47da91732..60f979eb0 100644 --- a/src/ui/widget/style-subject.h +++ b/src/ui/widget/style-subject.h @@ -35,7 +35,8 @@ public: class Selection; class CurrentLayer; - typedef Util::GSListConstIterator iterator; + //typedef Util::GSListConstIterator iterator; + typedef std::list::iterator iterator; StyleSubject(); virtual ~StyleSubject(); @@ -43,8 +44,8 @@ public: void setDesktop(SPDesktop *desktop); SPDesktop *getDesktop() const { return _desktop; } - virtual iterator begin() = 0; - virtual iterator end() { return iterator(NULL); } +// virtual iterator begin() = 0; +// virtual iterator end() { return iterator(NULL); } virtual Geom::OptRect getBounds(SPItem::BBoxType type) = 0; virtual int queryStyle(SPStyle *query, int property) = 0; virtual void setCSS(SPCSSAttr *css) = 0; @@ -67,7 +68,7 @@ public: Selection(); ~Selection(); - virtual iterator begin(); +// virtual iterator begin(); virtual Geom::OptRect getBounds(SPItem::BBoxType type); virtual int queryStyle(SPStyle *query, int property); virtual void setCSS(SPCSSAttr *css); @@ -88,7 +89,7 @@ public: CurrentLayer(); ~CurrentLayer(); - virtual iterator begin(); +// virtual iterator begin(); virtual Geom::OptRect getBounds(SPItem::BBoxType type); virtual int queryStyle(SPStyle *query, int property); virtual void setCSS(SPCSSAttr *css); @@ -99,12 +100,12 @@ protected: private: SPObject *_getLayer() const; void _setLayer(SPObject *layer); - GSList *_getLayerSList() const; + SPObject *_getLayerSList() const; sigc::connection _layer_switched; sigc::connection _layer_release; sigc::connection _layer_modified; - mutable GSList _element; + mutable SPObject* _element; }; } -- cgit v1.2.3 From cc22d3551937d17c596e4dd209060b16a714d463 Mon Sep 17 00:00:00 2001 From: Mc <> Date: Wed, 18 Feb 2015 02:17:25 +0100 Subject: OMG IT'S COMPILING. IT'S REALLY COMPILING ! (Of course it segfaults (what did you expect ?)) (bzr r13922.1.3) --- src/selection-chemistry.cpp | 174 +++++++++++++++++++++----------------------- 1 file changed, 83 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 05711e734..c213e76e4 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2298,17 +2298,9 @@ sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy) } } -namespace { -template -SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, - bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); - -template -SPItem *next_item_from_list(SPDesktop *desktop, SelContainer const &items, SPObject *root, - bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); -struct Forward { +typedef struct Forward { typedef SPObject *Iterator; static Iterator children(SPObject *o) { return o->firstChild(); } @@ -2317,9 +2309,9 @@ struct Forward { static SPObject *object(Iterator i) { return i; } static Iterator next(Iterator i) { return i->getNext(); } -}; +} Forward; -struct ListReverse { +typedef struct ListReverse { typedef GSList *Iterator; static Iterator children(SPObject *o) { @@ -2350,8 +2342,87 @@ private: } return list; } -}; +} ListReverse; + + + +template +SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, + bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) +{ + typename D::Iterator children; + typename D::Iterator iter; + + SPItem *found=NULL; + + if (path) { + SPObject *object=reinterpret_cast(path->data); + g_assert(object->parent == root); + if (desktop->isLayer(object)) { + found = next_item(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); + } + iter = children = D::siblings_after(object); + } else { + iter = children = D::children(root); + } + + while ( iter && !found ) { + SPObject *object=D::object(iter); + if (desktop->isLayer(object)) { + if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers + found = next_item(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); + } + } else { + SPItem *item = dynamic_cast(object); + if ( item && + ( !only_in_viewport || desktop->isWithinViewport(item) ) && + ( !onlyvisible || !desktop->itemIsHidden(item)) && + ( !onlysensitive || !item->isLocked()) && + !desktop->isLayer(item) ) + { + found = item; + } + } + iter = D::next(iter); + } + + D::dispose(children); + return found; +} + + +template +SPItem *next_item_from_list(SPDesktop *desktop, SelContainer const items, + SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) +{ + SPObject *current=root; + for(SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + SPItem *item = dynamic_cast(static_cast(*i)); + if ( root->isAncestorOf(item) && + ( !only_in_viewport || desktop->isWithinViewport(item) ) ) + { + current = item; + break; + } + } + + GSList *path=NULL; + while ( current != root ) { + path = g_slist_prepend(path, current); + current = current->parent; + } + + SPItem *next; + // first, try from the current object + next = next_item(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); + g_slist_free(path); + + if (!next) { // if we ran out of objects, start over at the root + next = next_item(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); + } + + return next; } void @@ -2478,87 +2549,8 @@ void sp_selection_edit_clip_or_mask(SPDesktop * /*dt*/, bool /*clip*/) } -namespace { -template -SPItem *next_item_from_list(SPDesktop *desktop, SelContainer const items, - SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) -{ - SPObject *current=root; - for(SelContainer::const_iterator i = items.begin();i!=items.end();i++) { - SPItem *item = dynamic_cast(static_cast(*i)); - if ( root->isAncestorOf(item) && - ( !only_in_viewport || desktop->isWithinViewport(item) ) ) - { - current = item; - break; - } - } - GSList *path=NULL; - while ( current != root ) { - path = g_slist_prepend(path, current); - current = current->parent; - } - - SPItem *next; - // first, try from the current object - next = next_item(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); - g_slist_free(path); - - if (!next) { // if we ran out of objects, start over at the root - next = next_item(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); - } - - return next; -} - -template -SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, - bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) -{ - typename D::Iterator children; - typename D::Iterator iter; - - SPItem *found=NULL; - - if (path) { - SPObject *object=reinterpret_cast(path->data); - g_assert(object->parent == root); - if (desktop->isLayer(object)) { - found = next_item(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); - } - iter = children = D::siblings_after(object); - } else { - iter = children = D::children(root); - } - - while ( iter && !found ) { - SPObject *object=D::object(iter); - if (desktop->isLayer(object)) { - if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers - found = next_item(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); - } - } else { - SPItem *item = dynamic_cast(object); - if ( item && - ( !only_in_viewport || desktop->isWithinViewport(item) ) && - ( !onlyvisible || !desktop->itemIsHidden(item)) && - ( !onlysensitive || !item->isLocked()) && - !desktop->isLayer(item) ) - { - found = item; - } - } - iter = D::next(iter); - } - - D::dispose(children); - - return found; -} - -} /** * If \a item is not entirely visible then adjust visible area to centre on the centre on of -- cgit v1.2.3 From 9e21d00fb1053897420f80d05a9815c5b2bbf312 Mon Sep 17 00:00:00 2001 From: mc <> Date: Wed, 18 Feb 2015 11:25:23 +0100 Subject: I can't really understand why, but i can now launch inkscape without it segfaulting. That's an improvement. Next thing: code cleaning, replacing containers with vectors (bzr r13922.1.4) --- src/selection-chemistry.cpp | 82 ++++++++++++++------------------- src/selection.cpp | 10 ++-- src/selection.h | 4 +- src/splivarot.cpp | 6 +-- src/ui/dialog/export.cpp | 12 ++--- src/ui/dialog/filter-effects-dialog.cpp | 2 +- src/ui/dialog/svg-fonts-dialog.cpp | 4 +- 7 files changed, 53 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index c213e76e4..9f27ca22e 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -462,13 +462,13 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to duplicate.")); return; } - SelContainer reprs(selection->reprList()); + std::vector reprs(selection->reprList()); selection->clear(); // sorting items from different parents sorts each parent's subset without possibly mixing // them, just what we need - reprs.sort(sp_repr_compare_position_obj); + sort(reprs.begin(),reprs.end(),sp_repr_compare_position); SelContainer newsel; @@ -478,8 +478,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value"); const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true); - while (!reprs.empty()) { - Inkscape::XML::Node *old_repr = dynamic_cast(reprs.front()); + for(std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ + Inkscape::XML::Node *old_repr = (*i); Inkscape::XML::Node *parent = old_repr->parent(); Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); @@ -501,7 +501,6 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) } newsel.push_front(dynamic_cast(copy)); - reprs.pop_front(); Inkscape::GC::release(copy); } @@ -692,16 +691,16 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop) sp_edit_select_all_full(desktop, true, true); } -static void sp_selection_group_impl(SelContainer p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { +static void sp_selection_group_impl(std::vector p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { - p.sort(sp_repr_compare_position_obj); + sort(p.begin(),p.end(),sp_repr_compare_position); // Remember the position and parent of the topmost object. gint topmost = (dynamic_cast(p.back()))->position(); Inkscape::XML::Node *topmost_parent = (dynamic_cast(p.back()))->parent(); - while (!p.empty()) { - Inkscape::XML::Node *current = dynamic_cast(p.front()); + for(std::vector::const_iterator i=p.begin();i!=p.end();i++){ + Inkscape::XML::Node *current = (*i); if (current->parent() == topmost_parent) { Inkscape::XML::Node *spnew = current->duplicate(xml_doc); @@ -745,7 +744,6 @@ static void sp_selection_group_impl(SelContainer p, Inkscape::XML::Node *group, copied.clear(); } } - p.pop_front(); } // Add the new group to the topmost members' parent @@ -766,7 +764,7 @@ void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) return; } - SelContainer p (selection->reprList()); + std::vector p (selection->reprList()); selection->clear(); @@ -1027,16 +1025,14 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - SelContainer rl(selection->reprList()); - rl.sort(sp_repr_compare_position_obj); + std::vector rl(selection->reprList()); + sort(rl.begin(),rl.end(),sp_repr_compare_position); - for (SelContainer::iterator l=rl.begin(); l!=rl.end();l++) { - Inkscape::XML::Node *repr = dynamic_cast(*l); + for (std::vector::const_iterator l=rl.begin(); l!=rl.end();l++) { + Inkscape::XML::Node *repr =(*l); repr->setPosition(-1); } - rl.clear(); - DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, _("Raise to top")); } @@ -1117,14 +1113,13 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - SelContainer rl(selection->reprList()); - rl.sort(sp_repr_compare_position_obj); - rl.reverse(); + std::vector rl(selection->reprList()); + sort(rl.begin(),rl.end(),sp_repr_compare_position); - for (SelContainer::const_iterator l=rl.begin();l!=rl.end();l++) { + for (std::vector::const_reverse_iterator l=rl.rbegin();l!=rl.rend();l++) { gint minpos; SPObject *pp, *pc; - Inkscape::XML::Node *repr = dynamic_cast(*l); + Inkscape::XML::Node *repr = (*l); pp = document->getObjectByRepr(repr->parent()); minpos = 0; g_assert(dynamic_cast(pp)); @@ -1136,8 +1131,6 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des repr->setPosition(minpos); } - rl.clear(); - DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, _("Lower to bottom")); } @@ -1691,9 +1684,9 @@ void sp_selection_remove_transform(SPDesktop *desktop) Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items = selection->itemList(); - for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { - ((Inkscape::XML::Node*)*l)->setAttribute("transform", NULL, false); + std::vector items = selection->reprList(); + for (std::vector::const_iterator l=items.begin();l!=items.end() ;l++) { + (*l)->setAttribute("transform", NULL, false); } DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN, @@ -2590,17 +2583,17 @@ void sp_selection_clone(SPDesktop *desktop) return; } - SelContainer reprs (selection->reprList()); + std::vector reprs (selection->reprList()); selection->clear(); // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need - reprs.sort(sp_repr_compare_position_obj); + sort(reprs.begin(),reprs.end(),sp_repr_compare_position); SelContainer newsel; - while (!reprs.empty()) { - Inkscape::XML::Node *sel_repr = dynamic_cast(reprs.front()); + for(std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ + Inkscape::XML::Node *sel_repr = *i; Inkscape::XML::Node *parent = sel_repr->parent(); Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); @@ -2617,7 +2610,6 @@ void sp_selection_clone(SPDesktop *desktop) parent->appendChild(clone); newsel.push_front(dynamic_cast(clone)); - reprs.pop_front(); Inkscape::GC::release(clone); } @@ -3462,14 +3454,14 @@ void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring return; } - SelContainer const reprlst = selection->reprList(); + std::vector const reprlst = selection->reprList(); bool filename_search = TRUE; bool xdpi_search = TRUE; bool ydpi_search = TRUE; - for (SelContainer::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){ + for (std::vector::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){ gchar const *dpi_string; - Inkscape::XML::Node * repr = dynamic_cast(*i); + Inkscape::XML::Node * repr = (*i); if (filename_search) { const gchar* tmp = repr->attribute("inkscape:export-filename"); @@ -3756,22 +3748,20 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) return; } - SelContainer l=selection->reprList(); - - SelContainer p(l); + std::vector p(selection->reprList()); - p.sort(sp_repr_compare_position_obj); + sort(p.begin(),p.end(),sp_repr_compare_position); selection->clear(); - gint topmost = (dynamic_cast(p.back()))->position(); - Inkscape::XML::Node *topmost_parent = (dynamic_cast(p.back()))->parent(); + int topmost = (p.back())->position(); + Inkscape::XML::Node *topmost_parent = (p.back())->parent(); Inkscape::XML::Node *inner = xml_doc->createElement("svg:g"); inner->setAttribute("inkscape:label", "Clip"); - while (!p.empty()) { - Inkscape::XML::Node *current = dynamic_cast(p.front()); + for(std::vector::const_iterator i=p.begin();i!=p.end();i++){ + Inkscape::XML::Node *current = *i; if (current->parent() == topmost_parent) { Inkscape::XML::Node *spnew = current->duplicate(xml_doc); @@ -3813,7 +3803,6 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) Inkscape::GC::release(spnew); } } - p.pop_front(); } Inkscape::XML::Node *outer = xml_doc->createElement("svg:g"); @@ -3960,13 +3949,12 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // make a note we should ungroup this when unsetting mask group->setAttribute("inkscape:groupmode", "maskhelper"); - SelContainer reprs_to_group; + std::vector reprs_to_group; for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { - reprs_to_group.push_front(dynamic_cast(SP_OBJECT(i->data)->getRepr())); + reprs_to_group.push_back(static_cast(i->data)->getRepr()); items_to_select.remove(static_cast(i->data)); } - reprs_to_group.reverse(); sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); diff --git a/src/selection.cpp b/src/selection.cpp index b509f4272..cbde9a799 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -43,7 +43,7 @@ namespace Inkscape { Selection::Selection(LayerModel *layers, SPDesktop *desktop) : _objs(SelContainer()), - _reprs(SelContainer()), + _reprs(std::vector()), _items(SelContainer()), _layers(layers), _desktop(desktop), @@ -296,15 +296,13 @@ SelContainer const &Selection::itemList() { return _items; } -SelContainer const &Selection::reprList() { +std::vector const &Selection::reprList() { if (!_reprs.empty()) { return _reprs; } SelContainer list = itemList(); for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { SPObject *obj=reinterpret_cast(*iter); - _reprs.push_front(dynamic_cast(obj->getRepr())); + _reprs.push_back(obj->getRepr()); } - _reprs.reverse(); - return _reprs; } @@ -343,7 +341,7 @@ SPObject *Selection::single() { SPItem *Selection::singleItem() { SelContainer const items=itemList(); - if ( !items.size()==1) { + if ( items.size()==1) { return reinterpret_cast(items.front()); } else { return NULL; diff --git a/src/selection.h b/src/selection.h index 7171b8742..f85c6346b 100644 --- a/src/selection.h +++ b/src/selection.h @@ -260,7 +260,7 @@ public: /** Returns a list of the xml nodes of all selected objects. */ /// \todo only returns reprs of SPItems currently; need a separate /// method for that - std::list const &reprList(); + std::vector const &reprList(); /** Returns a list of all perspectives which have a 3D box in the current selection. (these may also be nested in groups) */ @@ -377,7 +377,7 @@ private: void _releaseContext(SPObject *obj); mutable std::list _objs; - mutable std::list _reprs; + mutable std::vector _reprs; mutable std::list _items; void add_box_perspective(SPBox3D *box); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index aec7051e0..107dfc629 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -691,11 +691,11 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool } } else { // find out the bottom object - SelContainer sorted(selection->reprList()); + std::vector sorted(selection->reprList()); - sorted.sort(sp_repr_compare_position_obj); + sort(sorted.begin(),sorted.end(),sp_repr_compare_position); - source = doc->getObjectByRepr((Inkscape::XML::Node *)sorted.front()); + source = doc->getObjectByRepr(sorted.front()); } // adjust style properties that depend on a possible transform in the source object in order diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index fc6094c9f..0667ba721 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -817,9 +817,9 @@ void Export::onAreaToggled () one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const SelContainer reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); - for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { - Inkscape::XML::Node * repr = (Inkscape::XML::Node *)(*i); + const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); + for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { + Inkscape::XML::Node * repr = (*i); if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1226,7 +1226,7 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - SelContainer reprlst; + std::vector reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; @@ -1234,8 +1234,8 @@ void Export::onExport () DocumentUndo::setUndoSensitive(doc, false); reprlst = desktop->getSelection()->reprList(); - for(SelContainer::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { - Inkscape::XML::Node * repr = dynamic_cast(*i); + for(std::vector::const_iterator 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()); const gchar* docURI=SP_ACTIVE_DOCUMENT->getURI(); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 657d6771b..f67c1d173 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -690,7 +690,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = (Inkscape::XML::Node*) sel->reprList().front(); + Inkscape::XML::Node* node = sel->reprList().front(); if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 8f5601e3a..12b423602 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 = (Inkscape::XML::Node*)(sel->reprList().front()); + Inkscape::XML::Node* node = sel->reprList().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 = (Inkscape::XML::Node*)(sel->reprList().front()); + Inkscape::XML::Node* node = sel->reprList().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."); -- cgit v1.2.3 From 5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 04:25:21 +0100 Subject: Put a few std::vector (bzr r13922.1.5) --- src/conn-avoid-ref.cpp | 4 +- src/desktop-style.cpp | 66 ++--- src/desktop-style.h | 24 +- src/desktop.cpp | 2 +- src/desktop.h | 2 +- src/document.cpp | 20 +- src/document.h | 8 +- src/extension/execution-env.cpp | 4 +- src/extension/implementation/implementation.cpp | 2 +- src/extension/implementation/script.cpp | 4 +- src/extension/internal/bitmap/imagemagick.cpp | 6 +- src/extension/internal/bluredge.cpp | 4 +- src/extension/internal/filter/filter.cpp | 4 +- src/extension/internal/grid.cpp | 2 +- src/file.cpp | 4 +- src/gradient-chemistry.cpp | 8 +- src/gradient-drag.cpp | 12 +- src/graphlayout.cpp | 6 +- src/graphlayout.h | 4 +- src/helper/png-write.cpp | 6 +- src/helper/png-write.h | 4 +- src/live_effects/lpe-knot.cpp | 4 +- src/main.cpp | 12 +- src/object-snapper.cpp | 4 +- src/path-chemistry.cpp | 73 ++--- src/path-chemistry.h | 2 +- src/removeoverlap.cpp | 6 +- src/removeoverlap.h | 2 +- src/selcue.cpp | 14 +- src/selection-chemistry.cpp | 373 ++++++++++++------------ src/selection-chemistry.h | 10 +- src/selection-describer.cpp | 14 +- src/selection.cpp | 56 ++-- src/selection.h | 10 +- src/seltrans.cpp | 26 +- src/seltrans.h | 2 +- src/snap.cpp | 6 +- src/snap.h | 6 +- src/sp-conn-end.cpp | 4 +- src/sp-item-group.cpp | 19 +- src/sp-item-group.h | 4 +- src/sp-lpe-item.cpp | 20 +- src/sp-marker.cpp | 6 +- src/sp-marker.h | 2 +- src/sp-pattern.cpp | 4 +- src/sp-pattern.h | 2 +- src/splivarot.cpp | 30 +- src/text-chemistry.cpp | 40 +-- src/text-editing.cpp | 4 +- src/trace/trace.cpp | 4 +- src/ui/clipboard.cpp | 20 +- src/ui/dialog/align-and-distribute.cpp | 32 +- src/ui/dialog/clonetiler.cpp | 7 +- src/ui/dialog/export.cpp | 8 +- src/ui/dialog/filter-effects-dialog.cpp | 14 +- src/ui/dialog/find.cpp | 54 ++-- src/ui/dialog/find.h | 10 +- src/ui/dialog/font-substitution.cpp | 18 +- src/ui/dialog/font-substitution.h | 4 +- src/ui/dialog/glyphs.cpp | 8 +- src/ui/dialog/grid-arrange-tab.cpp | 21 +- src/ui/dialog/icon-preview.cpp | 4 +- src/ui/dialog/objects.cpp | 4 +- src/ui/dialog/pixelartdialog.cpp | 4 +- src/ui/dialog/polar-arrange-tab.cpp | 6 +- src/ui/dialog/print.cpp | 2 +- src/ui/dialog/swatches.cpp | 2 +- src/ui/dialog/tags.cpp | 4 +- src/ui/dialog/text-edit.cpp | 12 +- src/ui/dialog/transformation.cpp | 22 +- src/ui/interface.cpp | 8 +- src/ui/tools/connector-tool.cpp | 4 +- src/ui/tools/eraser-tool.cpp | 18 +- src/ui/tools/gradient-tool.cpp | 12 +- src/ui/tools/lpe-tool.cpp | 4 +- src/ui/tools/measure-tool.cpp | 4 +- src/ui/tools/mesh-tool.cpp | 12 +- src/ui/tools/node-tool.cpp | 6 +- src/ui/tools/select-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 14 +- src/ui/tools/text-tool.cpp | 4 +- src/ui/tools/tool-base.cpp | 4 +- src/ui/tools/tweak-tool.cpp | 12 +- src/ui/widget/object-composite-settings.cpp | 4 +- src/ui/widget/style-subject.cpp | 4 +- src/unclump.cpp | 36 +-- src/unclump.h | 2 +- src/vanishing-point.cpp | 18 +- src/widgets/arc-toolbar.cpp | 16 +- src/widgets/connector-toolbar.cpp | 8 +- src/widgets/fill-style.cpp | 8 +- src/widgets/gradient-toolbar.cpp | 12 +- src/widgets/mesh-toolbar.cpp | 8 +- src/widgets/rect-toolbar.cpp | 8 +- src/widgets/spiral-toolbar.cpp | 8 +- src/widgets/star-toolbar.cpp | 24 +- src/widgets/stroke-style.cpp | 14 +- src/widgets/stroke-style.h | 2 +- src/widgets/text-toolbar.cpp | 22 +- 99 files changed, 744 insertions(+), 765 deletions(-) (limited to 'src') diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index f2cde352c..fb9fbd935 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -252,8 +252,8 @@ static std::vector approxItemWithPoints(SPItem const *item, const G { SPGroup* group = SP_GROUP(item); // consider all first-order children - SelContainer itemlist = sp_item_group_item_list(group); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist = sp_item_group_item_list(group); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem* child_item = SP_ITEM(*i); std::vector child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 39dfad44b..0c661ebfb 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -194,8 +194,8 @@ 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); - SelContainer const itemlist = desktop->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector const itemlist = desktop->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { /* last used styles for 3D box faces are stored separately */ SPObject *obj = reinterpret_cast(*i); // TODO unsafe until Selection is refactored. Box3DSide *side = dynamic_cast(obj); @@ -234,8 +234,8 @@ 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); - SelContainer const itemlist = desktop->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector const itemlist = desktop->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = reinterpret_cast(*i); // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) @@ -439,7 +439,7 @@ sp_desktop_get_font_size_tool(SPDesktop *desktop) /** Determine average stroke width, simple method */ // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually gdouble -stroke_average_width (const SelContainer &objects) +stroke_average_width (const std::vector &objects) { if (objects.empty()) return Geom::infinity(); @@ -447,7 +447,7 @@ stroke_average_width (const SelContainer &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); SPItem *item = dynamic_cast(obj); if (!item) { @@ -492,7 +492,7 @@ static bool vectorsClose( std::vector const &lhs, std::vector co * Write to style_res the average fill or stroke of list of objects, if applicable. */ int -objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill) +objects_query_fillstroke (const std::vector &objects, SPStyle *style_res, bool const isfill) { if (objects.empty()) { /* No objects, set empty */ @@ -514,7 +514,7 @@ objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -685,7 +685,7 @@ objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool * Write to style_res the average opacity of a list of objects. */ int -objects_query_opacity (const SelContainer &objects, SPStyle *style_res) +objects_query_opacity (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -698,7 +698,7 @@ objects_query_opacity (const SelContainer &objects, SPStyle *style_res) guint opacity_items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -739,7 +739,7 @@ objects_query_opacity (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average stroke width of a list of objects. */ int -objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) +objects_query_strokewidth (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -754,7 +754,7 @@ objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -815,7 +815,7 @@ objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average miter limit of a list of objects. */ int -objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) +objects_query_miterlimit (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -828,7 +828,7 @@ objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) gdouble prev_ml = -1; bool same_ml = true; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -875,7 +875,7 @@ objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) * Write to style_res the stroke cap of a list of objects. */ int -objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) +objects_query_strokecap (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -887,7 +887,7 @@ objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) bool same_cap = true; int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -929,7 +929,7 @@ objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) * Write to style_res the stroke join of a list of objects. */ int -objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) +objects_query_strokejoin (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -941,7 +941,7 @@ objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) bool same_join = true; int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -984,7 +984,7 @@ objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font size and spacing of objects. */ int -objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) +objects_query_fontnumbers (const std::vector &objects, SPStyle *style_res) { bool different = false; @@ -1004,7 +1004,7 @@ objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) int texts = 0; int no_size = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1116,14 +1116,14 @@ objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font style of objects. */ int -objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) +objects_query_fontstyle (const std::vector &objects, SPStyle *style_res) { bool different = false; bool set = false; int texts = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1173,7 +1173,7 @@ objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) * Write to style_res the baseline numbers. */ static int -objects_query_baselines (const SelContainer &objects, SPStyle *style_res) +objects_query_baselines (const std::vector &objects, SPStyle *style_res) { bool different = false; @@ -1192,7 +1192,7 @@ objects_query_baselines (const SelContainer &objects, SPStyle *style_res) int texts = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1269,7 +1269,7 @@ objects_query_baselines (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font family of objects. */ int -objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) +objects_query_fontfamily (const std::vector &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1280,7 +1280,7 @@ objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) } style_res->font_family.set = FALSE; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1325,7 +1325,7 @@ objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) } static int -objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res) +objects_query_fontspecification (const std::vector &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1336,7 +1336,7 @@ objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res } style_res->font_specification.set = FALSE; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1385,7 +1385,7 @@ objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res } static int -objects_query_blend (const SelContainer &objects, SPStyle *style_res) +objects_query_blend (const std::vector &objects, SPStyle *style_res) { const int empty_prev = -2; const int complex_filter = 5; @@ -1394,7 +1394,7 @@ objects_query_blend (const SelContainer &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -1471,7 +1471,7 @@ objects_query_blend (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average blurring of a list of objects. */ int -objects_query_blur (const SelContainer &objects, SPStyle *style_res) +objects_query_blur (const std::vector &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -1484,7 +1484,7 @@ objects_query_blur (const SelContainer &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -1553,7 +1553,7 @@ objects_query_blur (const SelContainer &objects, SPStyle *style_res) * the result to style, return appropriate flag. */ int -sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property) +sp_desktop_query_style_from_list (const std::vector &list, SPStyle *style, int property) { if (property == QUERY_STYLE_PROPERTY_FILL) { return objects_query_fillstroke (list, style, true); diff --git a/src/desktop-style.h b/src/desktop-style.h index 0e40a2652..7ca25b9ae 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -65,21 +65,21 @@ guint32 sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, double sp_desktop_get_font_size_tool (SPDesktop *desktop); void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text); -gdouble stroke_average_width (const SelContainer &objects); +gdouble stroke_average_width (const std::vector &objects); -int objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill); -int objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res); -int objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res); -int objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res); -int objects_query_opacity (const SelContainer &objects, SPStyle *style_res); -int objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res); -int objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res); -int objects_query_strokecap (const SelContainer &objects, SPStyle *style_res); -int objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res); +int objects_query_fillstroke (const std::vector &objects, SPStyle *style_res, bool const isfill); +int objects_query_fontnumbers (const std::vector &objects, SPStyle *style_res); +int objects_query_fontstyle (const std::vector &objects, SPStyle *style_res); +int objects_query_fontfamily (const std::vector &objects, SPStyle *style_res); +int objects_query_opacity (const std::vector &objects, SPStyle *style_res); +int objects_query_strokewidth (const std::vector &objects, SPStyle *style_res); +int objects_query_miterlimit (const std::vector &objects, SPStyle *style_res); +int objects_query_strokecap (const std::vector &objects, SPStyle *style_res); +int objects_query_strokejoin (const std::vector &objects, SPStyle *style_res); -int objects_query_blur (const SelContainer &objects, SPStyle *style_res); +int objects_query_blur (const std::vector &objects, SPStyle *style_res); -int sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property); +int sp_desktop_query_style_from_list (const std::vector &list, SPStyle *style, int property); int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); diff --git a/src/desktop.cpp b/src/desktop.cpp index 64353e582..0cf0a3872 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -716,7 +716,7 @@ Inkscape::UI::Widget::Dock* SPDesktop::getDock() { /** * \see SPDocument::getItemFromListAtPointBottom() */ -SPItem *SPDesktop::getItemFromListAtPointBottom(const SelContainer &list, Geom::Point const &p) const +SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector &list, Geom::Point const &p) const { g_return_val_if_fail (doc() != NULL, NULL); return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); diff --git a/src/desktop.h b/src/desktop.h index 8765fa699..754e09766 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -319,7 +319,7 @@ public: //void push_event_context (GType type, const gchar *config, unsigned int key); void set_coordinate_status (Geom::Point p); - SPItem *getItemFromListAtPointBottom(const SelContainer &list, Geom::Point const &p) const; + SPItem *getItemFromListAtPointBottom(const std::vector &list, Geom::Point const &p) const; SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; SPItem *getGroupAtPoint(Geom::Point const &p) const; Geom::Point point() const; diff --git a/src/document.cpp b/src/document.cpp index 5c49ff6c3..07ad10505 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1235,7 +1235,7 @@ static bool overlaps(Geom::Rect const &area, Geom::Rect const &box) return area.intersects(box); } -static SelContainer &find_items_in_area(SelContainer &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, +static std::vector &find_items_in_area(std::vector &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false) { g_return_val_if_fail(SP_IS_GROUP(group), s); @@ -1275,7 +1275,7 @@ static bool item_is_in_group(SPItem *item, SPGroup *group) return inGroup; } -SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, SelContainer const &list,Geom::Point const &p, bool take_insensitive) +SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector const &list,Geom::Point const &p, bool take_insensitive) { g_return_val_if_fail(group, NULL); SPItem *bottomMost = 0; @@ -1391,9 +1391,9 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin * Assumes box is normalized (and g_asserts it!) * */ -SelContainer SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const +std::vector SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const { - SelContainer x; + std::vector x; g_return_val_if_fail(this->priv != NULL, x); return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within); } @@ -1405,16 +1405,16 @@ SelContainer SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) * */ -SelContainer SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const +std::vector SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const { - SelContainer x; + std::vector x; g_return_val_if_fail(this->priv != NULL, x); return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps); } -SelContainer SPDocument::getItemsAtPoints(unsigned const key, std::vector points) const +std::vector SPDocument::getItemsAtPoints(unsigned const key, std::vector points) const { - SelContainer items; + std::vector items; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // When picking along the path, we don't want small objects close together @@ -1423,11 +1423,11 @@ SelContainer SPDocument::getItemsAtPoints(unsigned const key, std::vectorgetDouble("/options/cursortolerance/value", 1.0); prefs->setDouble("/options/cursortolerance/value", 0.25); - for(unsigned int i = 0; i < points.size(); i++) { + for(int i = points.size()-1;i>=0; i--) { SPItem *item = getItemAtPoint(key, points[i], false, NULL); if (item && items.end()==find(items.begin(),items.end(), item)) - items.push_front(item); + items.push_back(item); } // and now we restore it back diff --git a/src/document.h b/src/document.h index 87262a079..57ff7643c 100644 --- a/src/document.h +++ b/src/document.h @@ -233,7 +233,7 @@ public: /** * Returns the bottommost item from the list which is at the point, or NULL if none. */ - static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const SelContainer &list, Geom::Point const &p, bool take_insensitive = false); + static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const std::vector &list, Geom::Point const &p, bool take_insensitive = false); static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri, char const *base, char const *name, unsigned int keepalive, @@ -257,10 +257,10 @@ public: bool addResource(char const *key, SPObject *object); bool removeResource(char const *key, SPObject *object); const GSList *getResourceList(char const *key) const; - SelContainer getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; - SelContainer getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; + std::vector getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; + std::vector getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; - SelContainer getItemsAtPoints(unsigned const key, std::vector points) const; + std::vector getItemsAtPoints(unsigned const key, std::vector points) const; SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; void changeUriAndHrefs(char const *uri); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 66a8c4358..90a7810e6 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -64,8 +64,8 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - SelContainer selected = desktop->getSelection()->itemList(); - for(SelContainer::const_iterator x=selected.begin();x!=selected.end();x++){ + std::vector selected = desktop->getSelection()->itemList(); + for(std::vector::const_iterator x=selected.begin();x!=selected.end();x++){ Glib::ustring selected_id; selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 6eff3ede3..cea6d139f 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -48,7 +48,7 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); using Inkscape::Util::GSListConstIterator; - SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { const SPItem * item = SP_ITEM(selected.front()); diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index f396e9848..95d5c7edc 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -689,9 +689,9 @@ void Script::effect(Inkscape::Extension::Effect *module, return; } - SelContainer selected = + std::vector selected = desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - for(SelContainer::const_iterator x=selected.begin();x!=selected.end();x++){ + for(std::vector::const_iterator x=selected.begin();x!=selected.end();x++){ Glib::ustring selected_id; selected_id += "--id="; selected_id += (*x)->getId(); diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 87ef30887..64abd6c4d 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -70,7 +70,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const SelContainer selectedItemList = desktop->selection->itemList(); + const std::vector selectedItemList = desktop->selection->itemList(); int selectCount = selectedItemList.size(); // Init the data-holders @@ -83,7 +83,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (SelContainer::const_iterator i=selectedItemList.begin();i!=selectedItemList.end();i++) { + for (std::vector::const_iterator i=selectedItemList.begin();i!=selectedItemList.end();i++) { SPItem *item = static_cast(*i); Inkscape::XML::Node *node = reinterpret_cast(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) @@ -242,7 +242,7 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie using Inkscape::Util::GSListConstIterator; - SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); 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 138172715..257cac161 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -65,10 +65,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); selection->clear(); - for(SelContainer::iterator item = items.begin(); + for(std::vector::iterator item = items.begin(); item != items.end(); ++item) { SPItem * spitem = static_cast(*item); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 821c023ac..a5eb7de60 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -126,12 +126,12 @@ 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 - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); - for(SelContainer::iterator item = items.begin(); + for(std::vector::iterator item = items.begin(); item != items.end(); ++item) { SPItem * spitem = static_cast(*item); Inkscape::XML::Node * node = spitem->getRepr(); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 4c12f629c..440c6b822 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -192,7 +192,7 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View using Inkscape::Util::GSListConstIterator; - SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = (selected.front())->getRepr(); diff --git a/src/file.cpp b/src/file.cpp index 4325c838b..f9dbe00a7 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1063,7 +1063,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) desktop->doc()->importDefs(clipdoc); // copy objects - std::list pasted_objects; + std::vector pasted_objects; for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { // Don't copy metadata, defs, named views and internal clipboard contents to the document if (!strcmp(obj->name(), "svg:defs")) { @@ -1082,7 +1082,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) target_parent->appendChild(obj_copy); Inkscape::GC::release(obj_copy); - pasted_objects.push_front(dynamic_cast(obj_copy)); + pasted_objects.push_back((obj_copy)); } // Change the selection to the freshly pasted objects diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 5f1da6cf1..a72423bbb 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1570,8 +1570,8 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa { Inkscape::Selection *selection = desktop->getSelection(); - const SelContainer list=selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + const std::vector list=selection->itemList(); + for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { sp_item_gradient_invert_vector_color(SP_ITEM(*i), fill_or_stroke); } @@ -1595,8 +1595,8 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) if (drag && drag->selected) { drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - const SelContainer list=selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + const std::vector list=selection->itemList(); + for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_FILL); sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_STROKE); } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 649928060..525fc074f 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2082,8 +2082,8 @@ void GrDrag::updateDraggers() this->draggers = NULL; g_return_if_fail(this->selection != NULL); - SelContainer list = this->selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + std::vector list = this->selection->itemList(); + for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -2151,8 +2151,8 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); - SelContainer list = this->selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + std::vector list = this->selection->itemList(); + for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -2295,8 +2295,8 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); - SelContainer list = this->selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + std::vector list = this->selection->itemList(); + for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { SPItem *item = SP_ITEM(*i); Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 613440269..4d590173a 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -88,8 +88,8 @@ struct CheckProgress : TestConvergence { * Scans the items list and places those items that are * not connectors in filtered */ -void filterConnectors(SelContainer const &items, list &filtered) { - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ +void filterConnectors(std::vector const &items, list &filtered) { + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); if(!isConnector(item)) { filtered.push_back(item); @@ -101,7 +101,7 @@ void filterConnectors(SelContainer const &items, list &filtered) { * connectors between them, and uses graph layout techniques to find * a nice layout */ -void graphlayout(SelContainer const &items) { +void graphlayout(std::vector const &items) { if(items.empty()) { return; } diff --git a/src/graphlayout.h b/src/graphlayout.h index c38f9471c..9794dd6b5 100644 --- a/src/graphlayout.h +++ b/src/graphlayout.h @@ -19,10 +19,10 @@ typedef struct _GSList GSList; class SPItem; -void graphlayout(SelContainer const &items); +void graphlayout(std::vector const &items); bool isConnector(SPItem const *const item); -void filterConnectors(SelContainer const &items, std::list &filtered); +void filterConnectors(std::vector const &items, std::list &filtered); #endif // SEEN_GRAPHLAYOUT_H diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 55fef5a4c..fc365c435 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -361,7 +361,7 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v /** * Hide all items that are not listed in list, recursively, skipping groups and defs. */ -static void hide_other_items_recursively(SPObject *o, const SelContainer &list, unsigned dkey) +static void hide_other_items_recursively(SPObject *o, const std::vector &list, unsigned dkey) { if ( SP_IS_ITEM(o) && !SP_IS_DEFS(o) @@ -387,7 +387,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned int (*status) (float, void *), void *data, bool force_overwrite, - const SelContainer &items_only) + const std::vector &items_only) { return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); @@ -399,7 +399,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned (*status)(float, void *), void *data, bool force_overwrite, - const SelContainer &items_only) + const std::vector &items_only) { g_return_val_if_fail(doc != NULL, EXPORT_ERROR); g_return_val_if_fail(filename != NULL, EXPORT_ERROR); diff --git a/src/helper/png-write.h b/src/helper/png-write.h index 47fad1b41..04ca85cd6 100644 --- a/src/helper/png-write.h +++ b/src/helper/png-write.h @@ -38,12 +38,12 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, double x0, double y0, double x1, double y1, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const SelContainer &items_only = SelContainer()); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector &items_only = std::vector()); ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, Geom::Rect const &area, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const SelContainer &items_only = SelContainer()); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector &items_only = std::vector()); #endif // SEEN_SP_PNG_WRITE_H diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 95a6b16dd..6cdf09180 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -505,8 +505,8 @@ LPEKnot::doEffect_path (std::vector const &path_in) static void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &paths, std::vector &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { - SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); if (SP_IS_LPE_ITEM(subitem)) { collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); diff --git a/src/main.cpp b/src/main.cpp index 25dc91f14..c62b9cd25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1156,7 +1156,7 @@ static int sp_process_file_list(GSList *fl) } if (sp_export_svg) { if (sp_export_text_to_path) { - SelContainer items; + std::vector items; SPRoot *root = doc->getRoot(); doc->ensureUpToDate(); for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { @@ -1169,8 +1169,8 @@ static int sp_process_file_list(GSList *fl) items.push_back(item); } - SelContainer selected; - SelContainer to_select; + std::vector selected; + std::vector to_select; sp_item_list_to_curves(items, selected, to_select); @@ -1435,7 +1435,7 @@ static int sp_do_export_png(SPDocument *doc) g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored."); } - SelContainer items; + std::vector items; Geom::Rect area; if (sp_export_id || sp_export_area_drawing) { @@ -1459,7 +1459,7 @@ static int sp_do_export_png(SPDocument *doc) return 1; } - items.push_front(SP_ITEM(o)); + items.push_back(SP_ITEM(o)); if (sp_export_id_only) { g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id); @@ -1647,7 +1647,7 @@ static int sp_do_export_png(SPDocument *doc) if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, - dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : SelContainer()) == 1 ) { + dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector()) == 1 ) { g_print("Bitmap saved as: %s\n", filename.c_str()); } else { g_warning("Bitmap failed to save to: %s", filename.c_str()); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 960b5087b..830c3c1db 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -237,8 +237,8 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, // current selection (see the comment in SelTrans::centerRequest()) bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); if (old_pref2) { - SelContainer rotationSource=_snapmanager->getRotationCenterSource(); - for ( SelContainer::const_iterator itemlist=rotationSource.begin();itemlist!=rotationSource.end();itemlist++) { + std::vector rotationSource=_snapmanager->getRotationCenterSource(); + for ( std::vector::const_iterator itemlist=rotationSource.begin();itemlist!=rotationSource.end();itemlist++) { if ((*i).item == reinterpret_cast(*itemlist)) { // don't snap to this item's rotation center _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index a5e71b720..ae1e0064f 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -51,13 +51,19 @@ inline bool less_than_objects(SPObject const *first, SPObject const *second) second->getRepr())<0; } +inline bool less_than_items(SPItem const *first, SPItem const *second) +{ + return sp_repr_compare_position(first->getRepr(), + second->getRepr())<0; +} + void sp_selected_path_combine(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); if (items.size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to combine.")); @@ -70,23 +76,22 @@ sp_selected_path_combine(SPDesktop *desktop) items = sp_degroup_list (items); // descend into any groups in selection - SelContainer to_paths; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + std::vector to_paths; + for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++) { SPItem *item = (SPItem *) (*i); if (!dynamic_cast(item) && !dynamic_cast(item)) { - to_paths.push_front(item); + to_paths.push_back(item); } } - SelContainer converted; + std::vector converted; bool did = sp_item_list_to_curves(to_paths, items, converted); to_paths.clear(); - for (SelContainer::const_iterator i=converted.begin();i!=converted.end();i++) - items.push_front(doc->getObjectByRepr((Inkscape::XML::Node*)(*i))); + for (std::vector::const_iterator i=converted.begin();i!=converted.end();i++) + items.push_back((SPItem*)doc->getObjectByRepr((Inkscape::XML::Node*)(*i))); items = sp_degroup_list (items); // converting to path may have added more groups, descend again - items.sort(less_than_objects); - items.reverse(); + sort(items.begin(),items.end(),less_than_objects); assert(!items.empty()); // cannot be NULL because of list length check at top of function // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one @@ -104,7 +109,7 @@ sp_selected_path_combine(SPDesktop *desktop) selection->clear(); } - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ SPItem *item = (SPItem *) (*i); SPPath *path = dynamic_cast(item); @@ -206,8 +211,8 @@ sp_selected_path_break_apart(SPDesktop *desktop) bool did = false; - SelContainer itemlist(selection->itemList()); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist(selection->itemList()); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = (SPItem *) (*i); @@ -246,7 +251,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) curve->unref(); - SelContainer reprs; + std::vector reprs; for (GSList *l = list; l != NULL; l = l->next) { curve = (SPCurve *) l->data; @@ -272,14 +277,13 @@ sp_selected_path_break_apart(SPDesktop *desktop) if (l == list) repr->setAttribute("id", id); - reprs.push_front(dynamic_cast(repr)); + reprs.push_back(repr); Inkscape::GC::release(repr); } - + //reverse selection->setReprList(reprs); - reprs.clear(); g_slist_free(list); g_free(style); g_free(path_effect); @@ -312,10 +316,10 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b desktop->setWaitingCursor(); } - SelContainer selected(selection->itemList()); - SelContainer to_select; + std::vector selected(selection->itemList()); + std::vector to_select; selection->clear(); - SelContainer items(selected); + std::vector items(selected); did = sp_item_list_to_curves(items, selected, to_select); @@ -346,27 +350,24 @@ void sp_selected_to_lpeitems(SPDesktop *desktop) return; } - SelContainer selected(selection->itemList()); - SelContainer to_select; + std::vector selected(selection->itemList()); + std::vector to_select; selection->clear(); - SelContainer items(selected); + std::vector items(selected); sp_item_list_to_curves(items, selected, to_select, true); - items.clear(); selection->setReprList(to_select); selection->addList(selected); - to_select.clear(); - selected.clear(); } bool -sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelContainer &to_select, bool skip_all_lpeitems) +sp_item_list_to_curves(const std::vector &items, std::vector& selected, std::vector &to_select, bool skip_all_lpeitems) { bool did = false; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); @@ -399,9 +400,9 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); if (repr) { - to_select.push_front(dynamic_cast(repr)); + to_select.push_back(repr); did = true; - selected.remove(item); + selected.erase(find(selected.begin(),selected.end(),item)); } continue; @@ -409,10 +410,10 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon if (group) { group->removeAllPathEffects(true); - SelContainer item_list = sp_item_group_item_list(group); + std::vector item_list = sp_item_group_item_list(group); - SelContainer item_to_select; - SelContainer item_selected; + std::vector item_to_select; + std::vector item_selected; if (sp_item_list_to_curves(item_list, item_selected, item_to_select)) did = true; @@ -429,7 +430,7 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon continue; did = true; - selected.remove(item); + selected.erase(find(selected.begin(),selected.end(),item)); // remember the position of the item gint pos = item->getRepr()->position(); @@ -471,7 +472,7 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon /* Buglet: We don't re-add the (new version of the) object to the selection of any other * desktops where it was previously selected. */ - to_select.push_front(dynamic_cast(repr)); + to_select.push_back(repr); Inkscape::GC::release(repr); } @@ -613,7 +614,7 @@ void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items = selection->itemList(); + std::vector items = selection->itemList(); if (items.empty()) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to reverse.")); @@ -627,7 +628,7 @@ sp_selected_path_reverse(SPDesktop *desktop) bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPPath *path = dynamic_cast(static_cast(*i)); if (!path) { diff --git a/src/path-chemistry.h b/src/path-chemistry.h index 388268af4..f454167a9 100644 --- a/src/path-chemistry.h +++ b/src/path-chemistry.h @@ -33,7 +33,7 @@ void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desk void sp_selected_to_lpeitems(SPDesktop *desktop); Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); void sp_selected_path_reverse (SPDesktop *desktop); -bool sp_item_list_to_curves(const SelContainer &items, SelContainer &selected, SelContainer &to_select, bool skip_all_lpeitems = false); +bool sp_item_list_to_curves(const std::vector &items, std::vector &selected, std::vector &to_select, bool skip_all_lpeitems = false); #endif // SEEN_PATH_CHEMISTRY_H diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 9009de5e9..7cb1694e3 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -38,14 +38,14 @@ namespace { * such that rectangular bounding boxes are separated by at least xGap * horizontally and yGap vertically */ -void removeoverlap(SelContainer const &items, double const xGap, double const yGap) { +void removeoverlap(std::vector const &items, double const xGap, double const yGap) { using Inkscape::Util::GSListConstIterator; - SelContainer selected(items); + std::vector selected(items); std::vector records; std::vector rs; Geom::Point const gap(xGap, yGap); - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { diff --git a/src/removeoverlap.h b/src/removeoverlap.h index d050ca9ef..d873663d1 100644 --- a/src/removeoverlap.h +++ b/src/removeoverlap.h @@ -15,6 +15,6 @@ typedef struct _GSList GSList; -void removeoverlap(SelContainer const &items, double xGap, double yGap); +void removeoverlap(std::vector const &items, double xGap, double yGap); #endif // SEEN_REMOVEOVERLAP_H diff --git a/src/selcue.cpp b/src/selcue.cpp index 0fab6e5a8..f48378cdc 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -96,15 +96,15 @@ void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs) void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) { - const SelContainer items = _selection->itemList(); + const std::vector items = _selection->itemList(); if (_item_bboxes.size() != items.size()) { _newItemBboxes(); return; } int bcount = 0; - SelContainer ll=_selection->itemList(); - for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + std::vector ll=_selection->itemList(); + for (std::vector::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast(*l); SPCanvasItem* box = _item_bboxes[bcount ++]; @@ -146,8 +146,8 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); - SelContainer ll=_selection->itemList(); - for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + std::vector ll=_selection->itemList(); + for (std::vector::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast(*l); Geom::OptRect const b = (prefs_bbox == 0) ? @@ -201,8 +201,8 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - SelContainer ll=_selection->itemList(); - for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + std::vector ll=_selection->itemList(); + for (std::vector::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast(*l); SPCanvasItem* baseline_point = NULL; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 9f27ca22e..f1c96b6b8 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -279,23 +279,21 @@ void SelectionHelper::fixSelection(SPDesktop *dt) Inkscape::Selection *selection = dt->getSelection(); - SelContainer items ; + std::vector items ; - SelContainer const selList = selection->itemList(); + std::vector const selList = selection->itemList(); - for( SelContainer::const_iterator i=selList.begin();i!=selList.end();i++ ) { + for( std::vector::const_reverse_iterator i=selList.rbegin();i!=selList.rend();i++ ) { SPItem *item = dynamic_cast(static_cast(*i)); if( item && !dt->isLayer(item) && (!item->isLocked())) { - items.push_front(item); + items.push_back(item); } } selection->setList(items); - - items.clear(); } } // namespace Inkscape @@ -305,7 +303,7 @@ void SelectionHelper::fixSelection(SPDesktop *dt) * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', * then prepends the copy to 'clip'. */ -static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, SelContainer &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector &clip, Inkscape::XML::Document* xml_doc) { Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -321,17 +319,17 @@ static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t copy->setAttribute("transform", affinestr); g_free(affinestr); - clip.push_front(dynamic_cast(copy)); + clip.insert(clip.begin(),dynamic_cast(copy)); } -static void sp_selection_copy_impl(SelContainer const &items, SelContainer &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_impl(std::vector const &items, std::vector &clip, Inkscape::XML::Document* xml_doc) { // Sort items: - SelContainer sorted_items(items); - sorted_items.sort(sp_object_compare_position); + std::vector sorted_items(items); + sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); // Copy item reprs: - for (SelContainer::const_iterator i = sorted_items.begin();i!=sorted_items.end();i++) { + for (std::vector::const_iterator i = sorted_items.begin();i!=sorted_items.end();i++) { SPItem *item = dynamic_cast(SP_OBJECT(*i)); if (item) { sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); @@ -339,22 +337,22 @@ static void sp_selection_copy_impl(SelContainer const &items, SelContainer &clip g_assert_not_reached(); } } - - clip.reverse(); + std::vector tmp(clip); + for(int i=0;i sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector &clip) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); SPItem *parentItem = dynamic_cast(parent); g_assert(parentItem != NULL); - SelContainer copied; + std::vector copied; // add objects to document - for (SelContainer::const_iterator l=clip.begin();l!=clip.end();l++) { + for (std::vector::const_iterator l=clip.begin();l!=clip.end();l++) { Inkscape::XML::Node *repr = dynamic_cast(*l); Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -373,18 +371,18 @@ static SelContainer sp_selection_paste_impl(SPDocument *doc, SPObject *parent, S } parent->appendChildRepr(copy); - copied.push_front(dynamic_cast(copy)); + copied.push_back(copy); Inkscape::GC::release(copy); } return copied; } -static void sp_selection_delete_impl(SelContainer const &items, bool propagate = true, bool propagate_descendants = true) +static void sp_selection_delete_impl(std::vector const &items, bool propagate = true, bool propagate_descendants = true) { - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { sp_object_ref(static_cast(*i), NULL); } - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { SPItem *item = static_cast(*i); item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, NULL); @@ -412,7 +410,7 @@ void sp_selection_delete(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing was deleted.")); return; } - SelContainer selected(selection->itemList()); + std::vector selected(selection->itemList()); selection->clear(); sp_selection_delete_impl(selected); selected.clear(); @@ -470,7 +468,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) // them, just what we need sort(reprs.begin(),reprs.end(),sp_repr_compare_position); - SelContainer newsel; + std::vector newsel; std::vector old_ids; std::vector new_ids; @@ -500,7 +498,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) } } - newsel.push_front(dynamic_cast(copy)); + newsel.push_back(copy); Inkscape::GC::release(copy); } @@ -546,8 +544,6 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) } selection->setReprList(newsel); - - newsel.clear(); } void sp_edit_clear_all(Inkscape::Selection *selection) @@ -560,11 +556,10 @@ void sp_edit_clear_all(Inkscape::Selection *selection) SPGroup *group = dynamic_cast(selection->layers()->currentLayer()); g_return_if_fail(group != NULL); - SelContainer items = sp_item_group_item_list(group); + std::vector items = sp_item_group_item_list(group); - while (!items.empty()) { - reinterpret_cast(items.front())->deleteObject(); - items.pop_front(); + for(int i=0;i(items[i])->deleteObject(); } DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, @@ -581,7 +576,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) * onlysensitive - TRUE includes only non-locked items * ingroups - TRUE to recursively get grouped items children */ -SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, SelContainer const &exclude) +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); @@ -592,7 +587,7 @@ SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *deskt (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child)) ) { - list.push_front(item); + list.insert(list.begin(),item); } if (ingroups || (item && desktop->isLayer(item))) { @@ -617,9 +612,9 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); - SelContainer items ; + std::vector items ; - SelContainer exclude; + std::vector exclude; if (invert) { exclude = selection->itemList(); } @@ -633,16 +628,16 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i (onlyvisible && dt->itemIsHidden(dynamic_cast(dt->currentLayer()))) ) return; - SelContainer all_items = sp_item_group_item_list(dynamic_cast(dt->currentLayer())); + std::vector all_items = sp_item_group_item_list(dynamic_cast(dt->currentLayer())); - for (SelContainer::const_iterator i=all_items.begin();i!=all_items.end();i++) { + for (std::vector::const_reverse_iterator i=all_items.rbegin();i!=all_items.rend();i++) { SPItem *item = dynamic_cast(static_cast(*i)); if (item && (!onlysensitive || !item->isLocked())) { if (!onlyvisible || !dt->itemIsHidden(item)) { if (!dt->isLayer(item)) { if (!invert || exclude.end() == std::find(exclude.begin(),exclude.end(),item)) { - items.push_front(item); // leave it in the list + items.push_back(item); // leave it in the list } } } @@ -653,12 +648,12 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i break; } case PREFS_SELECTION_LAYER_RECURSIVE: { - SelContainer x; + std::vector x; items = get_all_items(x, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } default: { - SelContainer x; + std::vector x; items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } @@ -709,7 +704,7 @@ static void sp_selection_group_impl(std::vector p, Inkscap Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - SelContainer temp_clip; + std::vector temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -729,11 +724,11 @@ static void sp_selection_group_impl(std::vector p, Inkscap sp_repr_unparent(current); // paste into topmost_parent (temporarily) - SelContainer copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); + std::vector copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); if (!temp_clip.empty())temp_clip.clear() ; if (!copied.empty()) { // if success, // take pasted object (now in topmost_parent) - Inkscape::XML::Node *in_topmost = dynamic_cast(copied.front()); + Inkscape::XML::Node *in_topmost = copied.back(); // make a copy Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); // remove pasted @@ -800,10 +795,10 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } // first check whether there is anything to ungroup - SelContainer old_select = selection->itemList(); - SelContainer new_select; + std::vector old_select = selection->itemList(); + std::vector new_select; GSList *groups = NULL; - for (SelContainer::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { + for (std::vector::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { SPItem *obj = static_cast(*item); if (dynamic_cast(obj)) { groups = g_slist_prepend(groups, obj); @@ -816,13 +811,13 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) return; } - SelContainer items(old_select); + std::vector items(old_select); selection->clear(); // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. GSList *clones_to_unlink = NULL; - for (SelContainer::const_iterator item = items.begin(); item!=items.end(); item++) { + for (std::vector::const_iterator item = items.begin(); item!=items.end(); item++) { SPUse *use = dynamic_cast(static_cast(*item)); SPItem *original = use; @@ -842,21 +837,21 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) for (GSList *item = clones_to_unlink; item; item = item->next) { SPUse *use = static_cast(item->data); - SelContainer::iterator items_node = std::find(items.begin(),items.end(), item->data); + std::vector::iterator items_node = std::find(items.begin(),items.end(), item->data); (*items_node) = use->unlink(); } g_slist_free(clones_to_unlink); // do the actual work - for (SelContainer::iterator item = items.begin(); item!=items.end(); item++) { + for (std::vector::iterator item = items.begin(); item!=items.end(); item++) { SPItem *obj = static_cast(*item); // ungroup only the groups marked earlier if (g_slist_find(groups, *item) != NULL) { - SelContainer children; + std::vector children; sp_item_group_ungroup(dynamic_cast(obj), children, false); // add the items resulting from ungrouping to the selection - new_select.splice(new_select.end(),children); + new_select.insert(new_select.end(),children.begin(),children.end()); (*item) = NULL; // zero out the original pointer, which is no longer valid } else { // if not a group, keep in the selection @@ -873,25 +868,24 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */ -SelContainer -sp_degroup_list(SelContainer &items) +std::vector +sp_degroup_list(std::vector &items) { - SelContainer out; + std::vector out; bool has_groups = false; - for (SelContainer::const_iterator item=items.begin();item!=items.end();item++) { + for (std::vector::const_iterator item=items.begin();item!=items.end();item++) { SPGroup *group = dynamic_cast(static_cast(*item)); if (!group) { - out.push_front(*item); + out.push_back(*item); } else { has_groups = true; - SelContainer members = sp_item_group_item_list(group); - for (SelContainer::const_iterator member=members.begin();member!=members.end();member++) { - out.push_front(*member); + std::vector members = sp_item_group_item_list(group); + for (std::vector::const_iterator member=members.begin();member!=members.end();member++) { + out.push_back(*member); } members.clear(); } } - out.reverse(); items.clear(); if (has_groups) { // recurse if we unwrapped a group - it may have contained others @@ -904,7 +898,7 @@ sp_degroup_list(SelContainer &items) /** If items in the list have a common parent, return it, otherwise return NULL */ static SPGroup * -sp_item_list_common_parent_group(SelContainer const items) +sp_item_list_common_parent_group(std::vector const items) { if (items.empty()) { return NULL; @@ -914,7 +908,7 @@ sp_item_list_common_parent_group(SelContainer const items) if (!dynamic_cast(parent)) { return NULL; } - for (SelContainer::const_iterator item=items.begin();item!=items.end();item++) { + for (std::vector::const_iterator item=items.begin();item!=items.end();item++) { if((*item)==items.front())continue; if (SP_OBJECT(*item)->parent != parent) { return NULL; @@ -926,12 +920,12 @@ sp_item_list_common_parent_group(SelContainer const items) /** Finds out the minimum common bbox of the selected items. */ static Geom::OptRect -enclose_items(SelContainer const &items) +enclose_items(std::vector const &items) { g_assert(!items.empty()); Geom::OptRect r; - for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i = items.begin();i!=items.end();i++) { r.unionWith(static_cast(*i)->desktopVisualBounds()); } return r; @@ -956,7 +950,7 @@ int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *sec void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { - SelContainer items= selection->itemList(); + std::vector items= selection->itemList(); if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to raise.")); return; @@ -971,16 +965,16 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) Inkscape::XML::Node *grepr = const_cast(group->getRepr()); /* Construct reverse-ordered list of selected children. */ - SelContainer rev(items); - rev.sort(sp_item_repr_compare_position_obj); + std::vector rev(items); + sort(rev.begin(),rev.end(),sp_item_repr_compare_position); // Determine the common bbox of the selected items. Geom::OptRect selected = enclose_items(items); // Iterate over all objects in the selection (starting from top). if (selected) { - while (!rev.empty()) { - SPObject *child = reinterpret_cast(rev.front()); + for (std::vector::const_iterator item=rev.begin();item!=rev.end();item++) { + SPObject *child = reinterpret_cast(*item); // for each selected object, find the next sibling for (SPObject *newref = child->next; newref; newref = newref->next) { // if the sibling is an item AND overlaps our selection, @@ -997,7 +991,6 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) } } } - rev.pop_front(); } } else { rev.clear(); @@ -1017,7 +1010,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - SelContainer items = selection->itemList(); + std::vector items = selection->itemList(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1039,7 +1032,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { - SelContainer items = selection->itemList(); + std::vector items = selection->itemList(); if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select object(s) to lower.")); return; @@ -1057,14 +1050,13 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) Geom::OptRect selected = enclose_items(items); /* Construct direct-ordered list of selected children. */ - SelContainer rev(items); - rev.sort(sp_item_repr_compare_position_obj); - rev.reverse(); + std::vector rev(items); + sort(rev.begin(),rev.end(),sp_item_repr_compare_position); // Iterate over all objects in the selection (starting from top). if (selected) { - while (!rev.empty()) { - SPObject *child = reinterpret_cast(rev.front()); + for (std::vector::const_reverse_iterator item=rev.rbegin();item!=rev.rend();item++) { + SPObject *child = reinterpret_cast(*item); // for each selected object, find the prev sibling for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { // if the sibling is an item AND overlaps our selection, @@ -1085,7 +1077,6 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) } } } - rev.pop_front(); } } else { rev.clear(); @@ -1105,7 +1096,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - SelContainer items =selection->itemList(); + std::vector items =selection->itemList(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1268,8 +1259,8 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to remove live path effects from.")); return; } - SelContainer list=selection->itemList(); - for ( SelContainer::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { + std::vector list=selection->itemList(); + for ( std::vector::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { SPItem *item = reinterpret_cast(*itemlist); sp_selection_remove_livepatheffect_impl(item); @@ -1330,16 +1321,16 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) return; } - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); bool no_more = false; // Set to true, if no more layers above SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); if (next) { - SelContainer temp_clip; + std::vector temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); sp_selection_delete_impl(items, false, false); next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers - SelContainer copied; + std::vector copied; if (next) { copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); } else { @@ -1375,16 +1366,16 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) return; } - const SelContainer items(selection->itemList()); + const std::vector items(selection->itemList()); bool no_more = false; // Set to true, if no more layers below SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); if (next) { - SelContainer temp_clip; + std::vector temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers - SelContainer copied; + std::vector copied; if (next) { copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); } else { @@ -1418,13 +1409,13 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) return; } - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); if (moveto) { - SelContainer temp_clip; + std::vector temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); - SelContainer copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); + std::vector copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); selection->setReprList(copied); copied.clear(); if (!temp_clip.empty()) temp_clip.clear(); @@ -1468,8 +1459,8 @@ static bool selection_contains_both_clone_and_original(Inkscape::Selection *selection) { bool clone_with_original = false; - SelContainer items = selection->itemList(); - for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + std::vector items = selection->itemList(); + for (std::vector::const_iterator l=items.begin();l!=items.end() ;l++) { SPItem *item = dynamic_cast(static_cast(*l)); if (item) { clone_with_original |= selection_contains_original(item, selection); @@ -1513,8 +1504,8 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons persp3d_apply_affine_transformation(transf_persp, affine); } - SelContainer items = selection->itemList(); - for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + std::vector items = selection->itemList(); + for (std::vector::const_iterator l=items.begin();l!=items.end() ;l++) { SPItem *item = dynamic_cast(static_cast(*l)); if( dynamic_cast(item) ) { @@ -1784,9 +1775,9 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) if (selection->isEmpty()) return; - SelContainer items = selection->itemList(); + std::vector items = selection->itemList(); Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw - for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + for (std::vector::const_iterator l=items.begin();l!=items.end() ;l++) { SPItem *item = dynamic_cast(static_cast(*l)); if (item) { sp_item_rotate_rel(item, rot_90); @@ -1843,15 +1834,15 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - SelContainer x,y; - SelContainer all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); - SelContainer all_matches; + std::vector x,y; + std::vector all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + std::vector all_matches; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items = selection->itemList(); - for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + std::vector items = selection->itemList(); + for (std::vector::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { SPItem *sel = dynamic_cast(static_cast(*sel_iter)); - SelContainer matches = all_list; + std::vector matches = all_list; if (fill) { matches = sp_get_same_fill_or_stroke_color(sel, matches, SP_FILL_COLOR); } @@ -1863,7 +1854,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES); matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_MARKERS); } - all_matches.splice(all_matches.end(), matches); + all_matches.insert(all_matches.end(), matches.begin(),matches.end()); } selection->clear(); @@ -1889,14 +1880,14 @@ void sp_select_same_object_type(SPDesktop *desktop) bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - SelContainer x,y; - SelContainer all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); - SelContainer matches = all_list; + std::vector x,y; + std::vector all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + std::vector matches = all_list; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + std::vector items=selection->itemList(); + for (std::vector::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { SPItem *sel = dynamic_cast(static_cast(*sel_iter)); if (sel) { matches = sp_get_same_object_type(sel, matches); @@ -1927,13 +1918,13 @@ void sp_select_same_stroke_style(SPDesktop *desktop) bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - SelContainer x,y; - SelContainer matches = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + std::vector x,y; + std::vector matches = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items=selection->itemList(); + std::vector items=selection->itemList(); - for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + for (std::vector::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { SPItem *sel = dynamic_cast(static_cast(*sel_iter)); if (sel) { matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_WIDTH); @@ -1953,14 +1944,14 @@ void sp_select_same_stroke_style(SPDesktop *desktop) * Find all items in src list that have the same fill or stroke style as sel * Return the list of matching items */ -SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type) +std::vector sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector &src, SPSelectStrokeStyleType type) { - SelContainer matches ; + std::vector matches ; gboolean match = false; SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); - for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + for (std::vector::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { SPItem *iter = dynamic_cast(static_cast(*i)); if (iter) { SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); @@ -2000,7 +1991,7 @@ SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SP } if (match) { - matches.push_front(iter); + matches.push_back(iter); } } else { g_assert_not_reached(); @@ -2051,14 +2042,14 @@ static bool item_type_match (SPItem *i, SPItem *j) * Find all items in src list that have the same object type as sel by type * Return the list of matching items */ -SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src) +std::vector sp_get_same_object_type(SPItem *sel, std::vector &src) { - SelContainer matches; + std::vector matches; - for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + for (std::vector::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { SPItem *item = dynamic_cast(static_cast(*i)); if (item && item_type_match(sel, item)) { - matches.push_front(item); + matches.push_back(item); } } return matches; @@ -2068,9 +2059,9 @@ SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src) * Find all items in src list that have the same stroke style as sel by type * Return the list of matching items */ -SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type) +std::vector sp_get_same_stroke_style(SPItem *sel, std::vector &src, SPSelectStrokeStyleType type) { - SelContainer matches; + std::vector matches; gboolean match = false; SPStyle *sel_style = sel->style; @@ -2083,14 +2074,14 @@ SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectSt * Stroke width needs to handle transformations, so call this function * to get the transformed stroke width */ - SelContainer objects; + std::vector objects; SPStyle *sel_style_for_width = NULL; if (type == SP_STROKE_STYLE_WIDTH) { - objects.push_front(sel); + objects.push_back(sel); sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, sel_style_for_width); } - for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + for (std::vector::const_iterator i=src.begin();i!=src.end();i++) { SPItem *iter = dynamic_cast(static_cast(*i)); if (iter) { SPStyle *iter_style = iter->style; @@ -2099,8 +2090,8 @@ SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectSt if (type == SP_STROKE_STYLE_WIDTH) { match = (sel_style->stroke_width.set == iter_style->stroke_width.set); if (sel_style->stroke_width.set && iter_style->stroke_width.set) { - SelContainer objects; - objects.push_front(iter); + std::vector objects; + objects.insert(objects.begin(),iter); SPStyle tmp_style(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, &tmp_style); @@ -2130,7 +2121,7 @@ SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectSt } if (match) { - matches.push_front(iter); + matches.insert(matches.begin(),iter); } } else { g_assert_not_reached(); @@ -2386,11 +2377,11 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, template -SPItem *next_item_from_list(SPDesktop *desktop, SelContainer const items, +SPItem *next_item_from_list(SPDesktop *desktop, std::vector const items, SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) { SPObject *current=root; - for(SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + for(std::vector::const_iterator i = items.begin();i!=items.end();i++) { SPItem *item = dynamic_cast(static_cast(*i)); if ( root->isAncestorOf(item) && ( !only_in_viewport || desktop->isWithinViewport(item) ) ) @@ -2590,7 +2581,7 @@ void sp_selection_clone(SPDesktop *desktop) // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need sort(reprs.begin(),reprs.end(),sp_repr_compare_position); - SelContainer newsel; + std::vector newsel; for(std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ Inkscape::XML::Node *sel_repr = *i; @@ -2609,7 +2600,7 @@ void sp_selection_clone(SPDesktop *desktop) // add the new clone to the top of the original's parent parent->appendChild(clone); - newsel.push_front(dynamic_cast(clone)); + newsel.push_back(clone); Inkscape::GC::release(clone); } @@ -2642,8 +2633,8 @@ sp_selection_relink(SPDesktop *desktop) // Get a copy of current selection. bool relinked = false; - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = static_cast(*i); if (dynamic_cast(item)) { @@ -2678,10 +2669,10 @@ sp_selection_unlink(SPDesktop *desktop) } // Get a copy of current selection. - SelContainer new_select; + std::vector new_select; bool unlinked = false; - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ SPItem *item = static_cast(*i); if (dynamic_cast(item)) { @@ -2698,7 +2689,7 @@ sp_selection_unlink(SPDesktop *desktop) if (!(dynamic_cast(item) || dynamic_cast(item))) { // keep the non-use item in the new selection - new_select.push_front(item); + new_select.push_back(item); continue; } @@ -2708,7 +2699,7 @@ sp_selection_unlink(SPDesktop *desktop) unlink = use->unlink(); // Unable to unlink use (external or invalid href?) if (!unlink) { - new_select.push_front(item); + new_select.push_back(item); continue; } } else /*if (SP_IS_TREF(use))*/ { @@ -2718,7 +2709,7 @@ sp_selection_unlink(SPDesktop *desktop) unlinked = true; // Add ungrouped items to the new selection. - new_select.push_front(unlink); + new_select.push_back(unlink); } if (!new_select.empty()) { // set new selection @@ -2747,7 +2738,7 @@ sp_select_clone_original(SPDesktop *desktop) // Check if other than two objects are selected - SelContainer items=selection->itemList(); + std::vector items=selection->itemList(); if (items.size() != 1 || !item) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); return; @@ -2845,8 +2836,8 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) Inkscape::SVGOStringStream os; SPObject * firstItem = NULL; - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { if (firstItem) { os << "|"; @@ -2930,7 +2921,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]; - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? @@ -2948,10 +2939,10 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) } // Create a list of duplicates, to be pasted inside marker element. - SelContainer repr_copies; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector repr_copies; + for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); - repr_copies.push_front(dynamic_cast(dup)); + repr_copies.push_back(dup); } Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); @@ -2959,7 +2950,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) if (apply) { // Delete objects so that their clones don't get alerted; // the objects will be restored inside the marker element. - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPObject *item = reinterpret_cast(*i); item->deleteObject(false); } @@ -2987,8 +2978,8 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { SPGroup *group = dynamic_cast(item); if (group && !dynamic_cast(item) && !wholegroups) { - SelContainer items=sp_item_group_item_list(group); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=sp_item_group_item_list(group); + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ sp_selection_to_guides_recursive(static_cast(*i), wholegroups); } } else { @@ -3004,7 +2995,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 - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); if (items.empty()) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to convert to guides.")); @@ -3019,7 +3010,7 @@ void sp_selection_to_guides(SPDesktop *desktop) // and its entry in the selection list is invalid (crash). // Therefore: first convert all, then delete all. - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ sp_selection_to_guides_recursive(static_cast(*i), wholegroups); } @@ -3282,9 +3273,9 @@ sp_selection_tile(SPDesktop *desktop, bool apply) move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); - SelContainer items (selection->itemList()); + std::vector items (selection->itemList()); - items.sort(sp_object_compare_position); + sort(items.begin(),items.end(),sp_object_compare_position); // bottommost object, after sorting SPObject *parent = SP_OBJECT(items.front())->parent; @@ -3304,19 +3295,17 @@ sp_selection_tile(SPDesktop *desktop, bool apply) gint pos = SP_OBJECT(items.front())->getRepr()->position(); // create a list of duplicates - SelContainer repr_copies; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector repr_copies; + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); - repr_copies.push_front(dynamic_cast(dup)); + repr_copies.push_back(dup); } - // restore the z-order after prepends - repr_copies.reverse(); Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); if (apply) { // delete objects so that their clones don't get alerted; this object will be restored shortly - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPObject *item = reinterpret_cast(*i); item->deleteObject(false); } @@ -3385,12 +3374,12 @@ void sp_selection_untile(SPDesktop *desktop) return; } - SelContainer new_select; + std::vector new_select; bool did = false; - SelContainer items(selection->itemList()); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items(selection->itemList()); + for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ SPItem *item = static_cast(*i); SPStyle *style = item->style; @@ -3427,7 +3416,7 @@ void sp_selection_untile(SPDesktop *desktop) Geom::Affine transform( i->transform * pat_transform ); i->doWriteTransform(i->getRepr(), transform); - new_select.push_front(i); + new_select.push_back(i); } else { g_assert_not_reached(); } @@ -3547,10 +3536,10 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // List of the items to show; all others will be hidden - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); // Sort items so that the topmost comes last - items.sort(sp_item_repr_compare_position_obj); + sort(items.begin(),items.end(),sp_item_repr_compare_position); // Generate a random value from the current time (you may create bitmap from the same object(s) // multiple times, and this is done so that they don't clash) @@ -3770,7 +3759,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - SelContainer temp_clip; + std::vector temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -3790,10 +3779,10 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) sp_repr_unparent(current); // paste into topmost_parent (temporarily) - SelContainer copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); + std::vector copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); if (!copied.empty()) { // if success, // take pasted object (now in topmost_parent) - Inkscape::XML::Node *in_topmost = dynamic_cast(copied.front()); + Inkscape::XML::Node *in_topmost = copied.back(); // make a copy Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); // remove pasted @@ -3875,9 +3864,9 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ doc->ensureUpToDate(); - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); - items.sort(sp_object_compare_position); + sort(items.begin(),items.end(),sp_object_compare_position); // See lp bug #542004 selection->clear(); @@ -3886,7 +3875,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ GSList *mask_items = NULL; GSList *apply_to_items = NULL; GSList *items_to_delete = NULL; - SelContainer items_to_select; + std::vector items_to_select; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool topmost = prefs->getBool("/options/maskobject/topmost", true); @@ -3897,7 +3886,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // all selected items are used for mask, which is applied to a layer apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); @@ -3906,7 +3895,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_delete = g_slist_prepend(items_to_delete, item); } else { - items_to_select.push_front(item); + items_to_select.push_back((SPItem*)item); } } } else if (!topmost) { @@ -3919,16 +3908,16 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_delete = g_slist_prepend(items_to_delete, item); } - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { if(i==items.begin())continue; apply_to_items = g_slist_prepend(apply_to_items, *i); - items_to_select.push_front(*i); + items_to_select.push_back(*i); } } else { GSList *i = NULL; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { apply_to_items = g_slist_prepend(apply_to_items, *i); - items_to_select.push_front(*i); + items_to_select.push_back(*i); } Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); @@ -3953,7 +3942,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { reprs_to_group.push_back(static_cast(i->data)->getRepr()); - items_to_select.remove(static_cast(i->data)); + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),static_cast(i->data))); } sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); @@ -3963,7 +3952,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ apply_to_items = NULL; apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group)); - items_to_select.push_front(doc->getObjectByRepr(group)); + items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); Inkscape::GC::release(group); } @@ -4003,7 +3992,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ Inkscape::XML::Node *spnew = current->duplicate(xml_doc); gint position = current->position(); - items_to_select.remove(item); + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); current->parent()->appendChild(group); sp_repr_unparent(current); group->appendChild(spnew); @@ -4012,7 +4001,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // Apply clip/mask to group instead apply_mask_to = group; - items_to_select.push_front(doc->getObjectByRepr(group)); + items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); Inkscape::GC::release(spnew); Inkscape::GC::release(group); } @@ -4027,12 +4016,10 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ for (GSList *i = items_to_delete; NULL != i; i = i->next) { SPObject *item = reinterpret_cast(i->data); item->deleteObject(false); - items_to_select.remove(item); + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); } g_slist_free(items_to_delete); - items_to_select.reverse(); - selection->addList(items_to_select); if (apply_clip_path) { @@ -4065,17 +4052,16 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map referenced_objects; - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); selection->clear(); GSList *items_to_ungroup = NULL; - SelContainer items_to_select(items); - items_to_select.reverse(); + std::vector items_to_select(items); // SPObject* refers to a group containing the clipped path or mask itself, // whereas SPItem* refers to the item being clipped or masked - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (remove_original) { // remember referenced mask/clippath, so orphaned masks can be moved back to document SPItem *item = reinterpret_cast(*i); @@ -4140,7 +4126,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0); SPItem *mask_item = static_cast(desktop->getDocument()->getObjectByRepr(repr)); - items_to_select.push_front(mask_item); + items_to_select.push_back(mask_item); // transform mask, so it is moved the same spot where mask was applied Geom::Affine transform(mask_item->transform); @@ -4155,10 +4141,10 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { SPGroup *group = dynamic_cast(static_cast(i->data)); if (group) { - items_to_select.remove(group); - SelContainer children; + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),group)); + std::vector children; sp_item_group_ungroup(group, children, false); - items_to_select.splice(items_to_select.begin(),children); + items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend()); } else { g_assert_not_reached(); } @@ -4167,7 +4153,6 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { g_slist_free(items_to_ungroup); // rebuild selection - items_to_select.reverse(); selection->addList(items_to_select); if (apply_clip_path) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index bc317d556..2acd62c02 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -143,9 +143,9 @@ enum SPSelectStrokeStyleType { void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style); void sp_select_same_stroke_style(SPDesktop *desktop); void sp_select_same_object_type(SPDesktop *desktop); -SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type); -SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type); -SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src); +std::vector sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector &src, SPSelectStrokeStyleType type); +std::vector sp_get_same_stroke_style(SPItem *sel, std::vector &src, SPSelectStrokeStyleType type); +std::vector sp_get_same_object_type(SPItem *sel, std::vector &src); void scroll_to_show_item(SPDesktop *desktop, SPItem *item); @@ -172,9 +172,9 @@ void unlock_all_in_all_layers(SPDesktop *dt); void unhide_all(SPDesktop *dt); void unhide_all_in_all_layers(SPDesktop *dt); -SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, SelContainer const &exclude); +std::vector &get_all_items(std::vector &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector const &exclude); -SelContainer sp_degroup_list (SelContainer &items); +std::vector sp_degroup_list (std::vector &items); /* selection cycling */ typedef enum diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 0625c4002..d86cfa700 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -40,13 +40,13 @@ #include "sp-spiral.h" // Returns a list of terms for the items to be used in the statusbar -char* collect_terms (const SelContainer &items) +char* collect_terms (const std::vector &items) { GSList *check = NULL; std::stringstream ss; bool first = true; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = dynamic_cast(reinterpret_cast(*iter)); if (item) { const char *term = item->displayName(); @@ -61,11 +61,11 @@ char* collect_terms (const SelContainer &items) } // Returns the number of terms in the list -static int count_terms (const SelContainer &items) +static int count_terms (const std::vector &items) { GSList *check = NULL; int count=0; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = dynamic_cast(reinterpret_cast(*iter)); if (item) { const char *term = item->displayName(); @@ -79,10 +79,10 @@ static int count_terms (const SelContainer &items) } // Returns the number of filtered items in the list -static int count_filtered (const SelContainer &items) +static int count_filtered (const std::vector &items) { int count=0; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = dynamic_cast(reinterpret_cast((*iter))); if (item) { count += item->isFiltered(); @@ -122,7 +122,7 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin } void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { - SelContainer const items = selection->itemList(); + std::vector const items = selection->itemList(); if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); diff --git a/src/selection.cpp b/src/selection.cpp index cbde9a799..2e8251048 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -44,7 +44,7 @@ namespace Inkscape { Selection::Selection(LayerModel *layers, SPDesktop *desktop) : _objs(SelContainer()), _reprs(std::vector()), - _items(SelContainer()), + _items(std::vector()), _layers(layers), _desktop(desktop), _selection_context(NULL), @@ -234,7 +234,7 @@ void Selection::_remove(SPObject *obj) { _objs.remove(obj); } -void Selection::setList(SelContainer const &list) { +void Selection::setList(std::vector const &list) { // Clear and add, or just clear with emit. if (!list.empty()) { _clear(); @@ -242,14 +242,14 @@ void Selection::setList(SelContainer const &list) { } else clear(); } -void Selection::addList(SelContainer const &list) { +void Selection::addList(std::vector const &list) { if (list.empty()) return; _invalidateCachedLists(); - for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { + for ( std::vector::const_iterator iter=list.begin();iter!=list.end();iter++ ) { SPObject *obj = reinterpret_cast(*iter); if (includes(obj)) continue; _add (obj); @@ -258,11 +258,11 @@ void Selection::addList(SelContainer const &list) { _emitChanged(); } -void Selection::setReprList(SelContainer const &list) { +void Selection::setReprList(std::vector const &list) { _clear(); - for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { - SPObject *obj=_objectForXMLNode(reinterpret_cast(*iter)); + for ( std::vector::const_reverse_iterator iter=list.rbegin();iter!=list.rend();iter++ ) { + SPObject *obj=_objectForXMLNode(*iter); if (obj) { _add(obj); } @@ -280,7 +280,7 @@ SelContainer const &Selection::list() { return _objs; } -SelContainer const &Selection::itemList() { +std::vector const &Selection::itemList() { if (!_items.empty()) { return _items; } @@ -288,18 +288,16 @@ SelContainer const &Selection::itemList() { for ( SelContainer::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { SPObject *obj=reinterpret_cast(*iter); if (SP_IS_ITEM(obj)) { - _items.push_front(SP_ITEM(obj)); + _items.push_back(SP_ITEM(obj)); } } - _items.reverse(); - return _items; } std::vector const &Selection::reprList() { if (!_reprs.empty()) { return _reprs; } - SelContainer list = itemList(); - for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { + std::vector list = itemList(); + for ( std::vector::const_iterator iter=list.begin();iter!=list.end();iter++ ) { SPObject *obj=reinterpret_cast(*iter); _reprs.push_back(obj->getRepr()); } @@ -340,7 +338,7 @@ SPObject *Selection::single() { } SPItem *Selection::singleItem() { - SelContainer const items=itemList(); + std::vector const items=itemList(); if ( items.size()==1) { return reinterpret_cast(items.front()); } else { @@ -357,11 +355,11 @@ SPItem *Selection::largestItem(Selection::CompareSize compare) { } SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; - for ( SelContainer::const_iterator i=items.begin();i!=items.end();i++ ) { + for ( std::vector::const_iterator i=items.begin();i!=items.end();i++ ) { Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); if (!obox || obox.isEmpty()) continue; Geom::Rect bbox = *obox; @@ -390,10 +388,10 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect Selection::geometricBounds() const { - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); Geom::OptRect bbox; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); } return bbox; @@ -401,10 +399,10 @@ Geom::OptRect Selection::geometricBounds() const Geom::OptRect Selection::visualBounds() const { - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); Geom::OptRect bbox; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); } return bbox; @@ -422,10 +420,10 @@ Geom::OptRect Selection::preferredBounds() const Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); if (items.empty()) return bbox; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = SP_ITEM(*iter); bbox |= item->documentBounds(type); } @@ -436,7 +434,7 @@ Geom::OptRect Selection::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 Selection::center() const { - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); if (!items.empty()) { SPItem *first = reinterpret_cast(items.back()); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly @@ -452,12 +450,12 @@ boost::optional Selection::center() const { } std::vector Selection::getSnapPoints(SnapPreferences const *snapprefs) const { - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); 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 p; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *this_item = SP_ITEM(*iter); this_item->getSnappoints(p, &snapprefs_dummy); @@ -505,9 +503,9 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { } uint Selection::numberOfLayers() { - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); std::set layers; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *layer = _layers->layerForObject(SP_OBJECT(*iter)); layers.insert(layer); } @@ -515,9 +513,9 @@ uint Selection::numberOfLayers() { } guint Selection::numberOfParents() { - SelContainer const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); std::set parents; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *parent = SP_OBJECT(*iter)->parent; parents.insert(parent); } diff --git a/src/selection.h b/src/selection.h index f85c6346b..2d5e7c34a 100644 --- a/src/selection.h +++ b/src/selection.h @@ -170,21 +170,21 @@ public: * * @param objs the objects to select */ - void setList(SelContainer const &objs); + void setList(std::vector const &objs); /** * Adds the specified objects to selection, without deselecting first. * * @param objs the objects to select */ - void addList(SelContainer const &objs); + void addList(std::vector const &objs); /** * Clears the selection and selects the specified objects. * * @param repr a list of xml nodes for the items to select */ - void setReprList(std::list const &reprs); + void setReprList(std::vector const &reprs); /** Add items from an STL iterator range to the selection. * \param from the begin iterator @@ -256,7 +256,7 @@ public: /** Returns the list of selected objects. */ std::list const &list(); /** Returns the list of selected SPItems. */ - std::list const &itemList(); + std::vector const &itemList(); /** Returns a list of the xml nodes of all selected objects. */ /// \todo only returns reprs of SPItems currently; need a separate /// method for that @@ -378,7 +378,7 @@ private: mutable std::list _objs; mutable std::vector _reprs; - mutable std::list _items; + mutable std::vector _items; void add_box_perspective(SPBox3D *box); void add_3D_boxes_recursively(SPObject *obj); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 8c06356db..0a428edf2 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -112,7 +112,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _opposite_for_bboxpoints(Geom::Point(0,0)), _origin_for_specpoints(Geom::Point(0,0)), _origin_for_bboxpoints(Geom::Point(0,0)), - _stamp_cache(SelContainer()), + _stamp_cache(std::vector()), _message_context(desktop->messageStack()), _bounding_box_prefs_observer(*this) { @@ -239,8 +239,8 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->setCenter(p); // only set the value; updating repr and document_done will be done once, on ungrab @@ -269,8 +269,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(*iter), NULL)); _items.push_back(it); _items_const.push_back(it); @@ -492,8 +492,8 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->updateRepr(); } @@ -524,17 +524,17 @@ void Inkscape::SelTrans::stamp() /* stamping mode */ if (!_empty) { - SelContainer l; + std::vector l; if (!_stamp_cache.empty()) { l = _stamp_cache; } else { /* Build cache */ l = selection->itemList(); - l.sort(sp_object_compare_position); + sort(l.begin(),l.end(),sp_object_compare_position); _stamp_cache = l; } - for(SelContainer::const_iterator x=l.begin();x!=l.end();x++) { + for(std::vector::const_iterator x=l.begin();x!=l.end();x++) { SPItem *original_item = SP_ITEM(*x); Inkscape::XML::Node *original_repr = original_item->getRepr(); @@ -711,8 +711,8 @@ 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 - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector items=_desktop->selection->itemList(); + for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->unsetCenter(); it->updateRepr(); @@ -1283,7 +1283,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 - SelContainer items = const_cast(_selection)->itemList(); + std::vector items = const_cast(_selection)->itemList(); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); diff --git a/src/seltrans.h b/src/seltrans.h index 8f9c329ed..26c2e9cd9 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -187,7 +187,7 @@ private: SPCtrlLine *_l[4]; unsigned int _sel_changed_id; unsigned int _sel_modified_id; - SelContainer _stamp_cache; + std::vector _stamp_cache; Geom::Point _origin; ///< position of origin for transforms Geom::Point _point; ///< original position of the knot being used for the current transform diff --git a/src/snap.cpp b/src/snap.cpp index a7145b834..c711874d7 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -43,7 +43,7 @@ SnapManager::SnapManager(SPNamedView const *v) : object(this, 0), snapprefs(), _named_view(v), - _rotation_center_source_items(SelContainer()), + _rotation_center_source_items(std::vector()), _guide_to_ignore(NULL), _desktop(NULL), _snapindicator(true), @@ -1053,8 +1053,8 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, _items_to_ignore.clear(); Inkscape::Selection *sel = _desktop->selection; - SelContainer const items = sel->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + std::vector const items = sel->itemList(); + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { _items_to_ignore.push_back(static_cast(*i)); } } diff --git a/src/snap.h b/src/snap.h index 012eb072b..49bdbfa7c 100644 --- a/src/snap.h +++ b/src/snap.h @@ -145,8 +145,8 @@ public: // of this rotation center; this reference is used to make sure that we do not snap a rotation // center to itself // NOTE: Must be called after calling setup(), not before! - void setRotationCenterSource(const SelContainer &items) {_rotation_center_source_items = items;} - SelContainer getRotationCenterSource() {return _rotation_center_source_items;} + void setRotationCenterSource(const std::vector &items) {_rotation_center_source_items = items;} + const std::vector &getRotationCenterSource() {return _rotation_center_source_items;} // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a // point if snapping has occurred (by overwriting p); otherwise p is untouched @@ -490,7 +490,7 @@ protected: private: std::vector _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method - SelContainer _rotation_center_source_items; // to avoid snapping a rotation center to itself + std::vector _rotation_center_source_items; // to avoid snapping a rotation center to itself SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged SPDesktop const *_desktop; bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index bd139277d..d09699f41 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -50,8 +50,8 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p // consider all first-order children double child_pos = 0.0; - SelContainer g = sp_item_group_item_list(group); - for (SelContainer::const_iterator i = g.begin();i!=g.end();i++) { + std::vector g = sp_item_group_item_list(group); + for (std::vector::const_iterator i = g.begin();i!=g.end();i++) { SPItem* child_item = SP_ITEM(*i); try_get_intersect_point_with_item_recursive(conn_pv, child_item, item_transform * child_item->transform, child_pos); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index e6531c6be..f09a4ee47 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -387,7 +387,7 @@ void SPGroup::snappoints(std::vector &p, Inkscape: void -sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) +sp_item_group_ungroup (SPGroup *group, std::vector &children, bool do_done) { g_return_if_fail (group != NULL); @@ -547,7 +547,7 @@ sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) Inkscape::GC::release(repr); if (!children.empty() && item) { - children.push_front(dynamic_cast(item)); + children.insert(children.begin(),item); } items = g_slist_remove (items, items->data); @@ -562,17 +562,16 @@ sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) * some API for list aspect of SPGroup */ -SelContainer sp_item_group_item_list(SPGroup * group) +std::vector sp_item_group_item_list(SPGroup * group) { - SelContainer s; + 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_front(o); + s.push_back((SPItem*)o); } } - s.reverse(); return s; } @@ -813,9 +812,9 @@ void SPGroup::update_patheffect(bool write) { g_message("sp_group_update_patheffect: %p\n", lpeitem); #endif - SelContainer const item_list = sp_item_group_item_list(this); + std::vector const item_list = sp_item_group_item_list(this); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); SPLPEItem *lpeItem = dynamic_cast(subitem); @@ -841,9 +840,9 @@ void SPGroup::update_patheffect(bool write) { static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - SelContainer const item_list = sp_item_group_item_list(group); + std::vector const item_list = sp_item_group_item_list(group); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); SPGroup *subGroup = dynamic_cast(subitem); diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 9a5ee0161..dcabea78c 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -96,10 +96,10 @@ public: virtual void update_patheffect(bool write); }; -void sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done = true); +void sp_item_group_ungroup (SPGroup *group, std::vector &children, bool do_done = true); -SelContainer sp_item_group_item_list (SPGroup *group); +std::vector sp_item_group_item_list (SPGroup *group); SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name); #endif diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 1305efd83..1f4704e22 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -353,8 +353,8 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); } if (SP_IS_GROUP(lpeitem)) { - SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem)); @@ -387,8 +387,8 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); } } - SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); @@ -680,8 +680,8 @@ SPLPEItem::apply_to_clippath(SPItem *item) } } if(SP_IS_GROUP(item)){ - SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); apply_to_clippath(SP_ITEM(subitem)); } @@ -732,8 +732,8 @@ SPLPEItem::apply_to_mask(SPItem *item) } } if(SP_IS_GROUP(item)){ - SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); apply_to_mask(SP_ITEM(subitem)); } @@ -746,8 +746,8 @@ SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item) if (!SP_IS_GROUP(group)) { return; } - SelContainer item_list = sp_item_group_item_list(SP_GROUP(group)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = sp_item_group_item_list(SP_GROUP(group)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast(*iter); if (SP_IS_GROUP(subitem)) { apply_to_clip_or_mask_group(SP_ITEM(subitem), item); diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 66b445265..5bb80bd39 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -429,7 +429,7 @@ sp_marker_hide (SPMarker *marker, unsigned int key) } -const gchar *generate_marker(SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) +const gchar *generate_marker(std::vector &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -452,8 +452,8 @@ const gchar *generate_marker(SelContainer &reprs, Geom::Rect bounds, SPDocument const gchar *mark_id = repr->attribute("id"); SPObject *mark_object = document->getObjectById(mark_id); - for (SelContainer::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); + for (std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ + Inkscape::XML::Node *node = (*i); SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-marker.h b/src/sp-marker.h index 594c164c5..56cbaf94f 100644 --- a/src/sp-marker.h +++ b/src/sp-marker.h @@ -101,7 +101,7 @@ Inkscape::DrawingItem *sp_marker_show_instance (SPMarker *marker, Inkscape::Draw unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); -const char *generate_marker (SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); +const char *generate_marker (std::vector &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); SPObject *sp_marker_fork_if_necessary(SPObject *marker); #endif diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index d5eff9796..33d66c5dc 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -408,7 +408,7 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se g_free(c); } -const gchar *pattern_tile(const SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) +const gchar *pattern_tile(const std::vector &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -426,7 +426,7 @@ const gchar *pattern_tile(const SelContainer &reprs, Geom::Rect bounds, SPDocume const gchar *pat_id = repr->attribute("id"); SPObject *pat_object = document->getObjectById(pat_id); - for (SelContainer::const_iterator i=reprs.begin();i!=reprs.end();i++){ + for (std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 0e2b058b5..34dd5a05b 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -89,7 +89,7 @@ SPPattern *pattern_chain (SPPattern *pattern); SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); -const char *pattern_tile (const SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); +const char *pattern_tile (const std::vector &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); SPPattern *pattern_getroot (SPPattern *pat); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 107dfc629..6e47dfff3 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -331,7 +331,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(); - SelContainer il= selection->itemList(); + std::vector il= selection->itemList(); // 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)) { @@ -403,7 +403,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // first check if all the input objects have shapes // otherwise bail out - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++) + for (std::vector::const_iterator l = il.begin(); l != il.end(); l++) { SPItem *item = SP_ITEM(*l); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item)) @@ -421,7 +421,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool int curOrig; { curOrig = 0; - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++) + for (std::vector::const_iterator l = il.begin(); l != il.end(); l++) { // apply live path effects prior to performing boolean operation if (SP_IS_LPE_ITEM(*l)) { @@ -474,7 +474,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool theShapeA->ConvertToShape(theShape, origWind[0]); curOrig = 1; - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ if(*l==il.front())continue; originaux[curOrig]->ConvertWithBackData(0.1); @@ -671,7 +671,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (res->descr_cmd.size() <= 1) { // only one command, presumably a moveto: it isn't a path - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SP_OBJECT(*l)->deleteObject(); } DocumentUndo::done(doc, SP_VERB_NONE, description); @@ -720,7 +720,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool gchar *desc = source->desc(); // remove source paths selection->clear(); - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + 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)) { // delete it so that its clones don't get alerted; this object will be restored shortly, with the same id @@ -1157,8 +1157,8 @@ sp_selected_path_outline(SPDesktop *desktop) } bool did = false; - SelContainer il(selection->itemList()); - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + std::vector il(selection->itemList()); + for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = SP_ITEM(*l); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) @@ -1769,8 +1769,8 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } bool did = false; - SelContainer il(selection->itemList()); - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + std::vector il(selection->itemList()); + for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = SP_ITEM(*l); SPCurve *curve = NULL; @@ -1967,7 +1967,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) static bool sp_selected_path_simplify_items(SPDesktop *desktop, - Inkscape::Selection *selection, SelContainer &items, + Inkscape::Selection *selection, std::vector &items, float threshold, bool justCoalesce, float angleLimit, bool breakableAngles, bool modifySelection); @@ -1986,7 +1986,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, //If this is a group, do the children instead if (SP_IS_GROUP(item)) { - SelContainer items = sp_item_group_item_list(SP_GROUP(item)); + std::vector items = sp_item_group_item_list(SP_GROUP(item)); return sp_selected_path_simplify_items(desktop, selection, items, threshold, justCoalesce, @@ -2111,7 +2111,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, bool sp_selected_path_simplify_items(SPDesktop *desktop, - Inkscape::Selection *selection, SelContainer &items, + Inkscape::Selection *selection, std::vector &items, float threshold, bool justCoalesce, float angleLimit, bool breakableAngles, bool modifySelection) @@ -2142,7 +2142,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, // set "busy" cursor desktop->setWaitingCursor(); - for (SelContainer::const_iterator l = items.begin(); l != items.end(); l++){ + for (std::vector::const_iterator l = items.begin(); l != items.end(); l++){ SPItem *item = SP_ITEM(*l); if (!(SP_IS_GROUP(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item))) @@ -2191,7 +2191,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju return; } - SelContainer items(selection->itemList()); + std::vector items(selection->itemList()); bool didSomething = sp_selected_path_simplify_items(desktop, selection, items, threshold, diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 391e255a5..33192a330 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -43,8 +43,8 @@ using Inkscape::DocumentUndo; static SPItem * flowtext_in_selection(Inkscape::Selection *selection) { - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items = selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_FLOWTEXT(*i)) return ((SPItem *) *i); } @@ -54,8 +54,8 @@ flowtext_in_selection(Inkscape::Selection *selection) static SPItem * text_or_flowtext_in_selection(Inkscape::Selection *selection) { - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items = selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return ((SPItem *) *i); } @@ -65,8 +65,8 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) static SPItem * shape_in_selection(Inkscape::Selection *selection) { - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items = selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_SHAPE(*i)) return ((SPItem *) *i); } @@ -196,8 +196,8 @@ text_remove_from_path() } bool did = false; - SelContainer items(selection->itemList()); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items(selection->itemList()); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPObject *obj = SP_OBJECT(*i); if (SP_IS_TEXT_TEXTPATH(obj)) { @@ -260,8 +260,8 @@ text_remove_all_kerns() bool did = false; - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items = selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPObject *obj = SP_OBJECT(*i); if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { @@ -320,8 +320,8 @@ text_flow_into_shape() g_return_if_fail(SP_IS_FLOWREGION(object)); /* Add clones */ - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items = selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_SHAPE(item)){ Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); @@ -392,11 +392,11 @@ text_unflow () return; } - SelContainer new_objs; + std::vector new_objs; GSList *old_objs = NULL; - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items = selection->itemList(); + for(std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ if (!SP_IS_FLOWTEXT(SP_OBJECT(*i))) { continue; @@ -443,7 +443,7 @@ text_unflow () SPText *text = SP_TEXT(text_object); text->_adjustFontsizeRecursive(text, ex); - new_objs.push_front(text_object); + new_objs.push_back((SPItem*)text_object); old_objs = g_slist_prepend (old_objs, flowtext); Inkscape::GC::release(rtext); @@ -478,9 +478,9 @@ flowtext_to_text() bool did = false; - SelContainer reprs; - SelContainer items(selection->itemList()); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector reprs; + std::vector items(selection->itemList()); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = (SPItem *) *i; @@ -510,7 +510,7 @@ flowtext_to_text() Inkscape::GC::release(repr); item->deleteObject(); - reprs.push_front(dynamic_cast(repr)); + reprs.push_back(repr); } diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 44d90b4ae..88210dc0b 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -67,8 +67,8 @@ static void te_update_layout_now (SPItem *item) void te_update_layout_now_recursive(SPItem *item) { if (SP_IS_GROUP(item)) { - SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); - for(SelContainer::const_iterator i=item_list.begin();i!=item_list.end();i++){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); + for(std::vector::const_iterator i=item_list.begin();i!=item_list.end();i++){ SPItem* list_item = static_cast(*i); te_update_layout_now_recursive(list_item); } diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 2becca5cc..4853f127c 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -65,7 +65,7 @@ SPImage *Tracer::getSelectedSPImage() if (sioxEnabled) { SPImage *img = NULL; - SelContainer const list = sel->itemList(); + std::vector const list = sel->itemList(); std::vector items; sioxShapes.clear(); @@ -74,7 +74,7 @@ SPImage *Tracer::getSelectedSPImage() them as bottom-to-top so that we can discover the image and any SPItems above it */ - for (SelContainer::const_iterator i=list.begin() ; list.end()!=i ; i++) + for (std::vector::const_iterator i=list.begin() ; list.end()!=i ; i++) { if (!SP_IS_ITEM(*i)) { diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 20b43af3b..6c15121c2 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -523,8 +523,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); @@ -579,8 +579,8 @@ 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); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); _applyPathEffect(item, effectstack); } @@ -662,8 +662,8 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { // copy the defs used by all items - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (item) { _copyUsedDefs(item); @@ -673,10 +673,10 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) } // copy the representation of the items - SelContainer sorted_items(itemlist); - sorted_items.sort(sp_object_compare_position); + std::vector sorted_items(itemlist); + sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); - for(SelContainer::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){ + for(std::vector::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){ SPItem *item = SP_ITEM(*i); if (item) { Inkscape::XML::Node *obj = item->getRepr(); @@ -1157,7 +1157,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) sp_repr_get_double(nv, "inkscape:pageopacity", &opacity); bgcolor |= SP_COLOR_F_TO_U(opacity); } - SelContainer x; + std::vector x; sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, x); } else diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 562bc28b7..34dbd150b 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -98,7 +98,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector selected(selection->itemList()); if (selected.empty()) return; const Coeffs &a = _allCoeffs[index]; @@ -148,7 +148,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) b = selection->preferredBounds(); //Move each item in the selected list separately - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { SPItem* item=static_cast (*it); @@ -251,18 +251,18 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects - SelContainer::iterator second(selected.begin()); + std::vector::iterator second(selected.begin()); ++second; if (second == selected.end()) return; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box"); std::vector< BBoxSort > sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) {SPItem *item=static_cast(*it); @@ -540,10 +540,6 @@ private : return (a->isSiblingOf(b)); } - static bool local_obj_compare(SPObject* a,SPObject* b){ - return ActionExchangePositions::sort_compare(static_cast(a),static_cast(b)); - } - virtual void on_button_click() { SPDesktop *desktop = _dialog.getDesktop(); @@ -553,7 +549,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -571,9 +567,9 @@ private : } else { // sorting by ZOrder is outomatically done by not setting the center center.reset(); } - selected.sort(local_obj_compare); + sort(selected.begin(),selected.end(),sort_compare); } - SelContainer::iterator it(selected.begin()); + std::vector::iterator it(selected.begin()); SPItem* item=static_cast(*it); Geom::Point p1 = (item)->getCenter(); for (++it ;it != selected.end(); ++it) @@ -619,7 +615,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); - SelContainer x(_dialog.getDesktop()->getSelection()->itemList()); + std::vector x(_dialog.getDesktop()->getSelection()->itemList()); unclump (x); // restore compensation setting @@ -651,7 +647,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -675,7 +671,7 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -750,7 +746,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -761,7 +757,7 @@ private : std::vector sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -805,7 +801,7 @@ private : } } else { - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index abfab8b19..680757373 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2104,16 +2104,17 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) SPObject *obj = selection->singleItem(); SPObject *parent = obj->parent; - SelContainer to_unclump; // not including the original + 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_front(child); + to_unclump.push_back((SPItem*)child); } } desktop->getDocument()->ensureUpToDate(); - + std::vector tu2(to_unclump); + for(int i=0;igetDocument(), SP_VERB_DIALOG_CLONETILER, diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 0667ba721..32eed088c 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1024,8 +1024,8 @@ void Export::onExport () gint export_count = 0; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ SPItem *item = reinterpret_cast(*i); prog_dlg->set_data("current", GINT_TO_POINTER(n)); @@ -1064,7 +1064,7 @@ void Export::onExport () _("Exporting file %s..."), safeFile), desktop); MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file %s..."), safeFile), desktop); - SelContainer x; + std::vector x; if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, nv->pagecolor, @@ -1154,7 +1154,7 @@ void Export::onExport () prog_dlg->set_data("total", GINT_TO_POINTER(0)); /* Do export */ - SelContainer x; + std::vector x; ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index f67c1d173..a6312140d 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1465,8 +1465,8 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } std::set used; - SelContainer itemlist=sel->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector itemlist=sel->itemList(); + for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPStyle *style = obj->style; if (!style || !SP_IS_ITEM(obj)) { @@ -1545,8 +1545,8 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri if((*iter)[_columns.sel] == 1) filter = 0; - SelContainer itemlist=sel->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector itemlist=sel->itemList(); + for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { SPItem * item = SP_ITEM(*i); SPStyle *style = item->style; g_assert(style != NULL); @@ -1649,9 +1649,9 @@ void FilterEffectsDialog::FilterModifier::remove_filter() SPDocument* doc = filter->document; // Delete all references to this filter - SelContainer x,y; - SelContainer all = get_all_items(x, _desktop->currentRoot(), _desktop, false, false, true, y); - for(SelContainer::const_iterator i=all.begin(); all.end() != i; i++) { + std::vector x,y; + std::vector all = get_all_items(x, _desktop->currentRoot(), _desktop, false, false, true, y); + for(std::vector::const_iterator i=all.begin(); all.end() != i; i++) { if (!SP_IS_ITEM(*i)) { continue; } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 43ecb60ac..283d79c0d 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -549,7 +549,7 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas } -SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) +std::vector Find::filter_fields (std::vector &l, bool exact, bool casematch) { Glib::ustring tmp = entry_find.getEntry()->get_text(); if (tmp.empty()) { @@ -557,17 +557,17 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) } gchar* text = g_strdup(tmp.c_str()); - SelContainer in = l; - SelContainer out; + std::vector in = l; + std::vector out; if (check_searchin_text.get_active()) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_text_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_text_match(item, text, exact, casematch, _action_replace); } @@ -584,12 +584,12 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) bool attrvalue = check_attributevalue.get_active(); if (ids) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); if (item_id_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_id_match(item, text, exact, casematch, _action_replace); } @@ -600,13 +600,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (style) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_style_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)){ - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_style_match(item, text, exact, casematch, _action_replace); } @@ -617,13 +617,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (attrname) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_attr_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_attr_match(item, text, exact, casematch, _action_replace); } @@ -634,13 +634,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (attrvalue) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_attrvalue_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_attrvalue_match(item, text, exact, casematch, _action_replace); } @@ -651,13 +651,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (font) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_font_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(),*i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_font_match(item, text, exact, casematch, _action_replace); } @@ -715,29 +715,29 @@ bool Find::item_type_match (SPItem *item) return false; } -SelContainer Find::filter_types (SelContainer &l) +std::vector Find::filter_types (std::vector &l) { - SelContainer n; - for(SelContainer::const_iterator i=l.begin(); l.end() != i; i++) { + std::vector n; + for(std::vector::const_reverse_iterator i=l.rbegin(); l.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_type_match(item)) { - n.push_front(*i); + n.push_back(*i); } } return n; } -SelContainer &Find::filter_list (SelContainer &l, bool exact, bool casematch) +std::vector &Find::filter_list (std::vector &l, bool exact, bool casematch) { l = filter_types (l); l = filter_fields (l, exact, casematch); return l; } -SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool locked) +std::vector &Find::all_items (SPObject *r, std::vector &l, bool hidden, bool locked) { if (dynamic_cast(r)) { return l; // we're not interested in items in defs @@ -751,7 +751,7 @@ SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool l SPItem *item = dynamic_cast(child); if (item && !child->cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { - l.push_front(child); + l.insert(l.begin(),(SPItem*)child); } } l = all_items (child, l, hidden, locked); @@ -759,10 +759,10 @@ SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool l return l; } -SelContainer &Find::all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked) +std::vector &Find::all_selection_items (Inkscape::Selection *s, std::vector &l, SPObject *ancestor, bool hidden, bool locked) { - SelContainer itemlist=s->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector itemlist=s->itemList(); + for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); @@ -817,7 +817,7 @@ void Find::onAction() bool casematch = check_case_sensitive.get_active(); blocked = true; - SelContainer l; + std::vector l; if (check_scope_selection.get_active()) { if (check_scope_layer.get_active()) { l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked); @@ -833,7 +833,7 @@ void Find::onAction() } guint all = l.size(); - SelContainer n = filter_list (l, exact, casematch); + std::vector n = filter_list (l, exact, casematch); if (!n.empty()) { int count = n.size(); diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 1aded96f2..61f4463ae 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -149,10 +149,10 @@ protected: /** * Function to filter a list of items based on the item type by calling each item_XXX_match function */ - SelContainer filter_fields (SelContainer &l, bool exact, bool casematch); + std::vector filter_fields (std::vector &l, bool exact, bool casematch); bool item_type_match (SPItem *item); - SelContainer filter_types (SelContainer &l); - SelContainer & filter_list (SelContainer &l, bool exact, bool casematch); + std::vector filter_types (std::vector &l); + std::vector & filter_list (std::vector &l, bool exact, bool casematch); /** * Find a string within a string and returns true if found with options for exact and casematching @@ -173,12 +173,12 @@ protected: * recursive function to return a list of all the items in the SPObject tree * */ - SelContainer & all_items (SPObject *r, SelContainer &l, bool hidden, bool locked); + std::vector & all_items (SPObject *r, std::vector &l, bool hidden, bool locked); /** * to return a list of all the selected items * */ - SelContainer & all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked); + std::vector & all_selection_items (Inkscape::Selection *s, std::vector &l, SPObject *ancestor, bool hidden, bool locked); /** * Shrink the dialog size when the expander widget is closed diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 625ed99b9..e9a0fc017 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -70,7 +70,7 @@ FontSubstitution::checkFontSubstitutions(SPDocument* doc) int show_dlg = prefs->getInt("/options/font/substitutedlg", 0); if (show_dlg) { Glib::ustring out; - SelContainer l = getFontReplacedItems(doc, &out); + std::vector l = getFontReplacedItems(doc, &out); if (out.length() > 0) { show(out, l); } @@ -78,7 +78,7 @@ FontSubstitution::checkFontSubstitutions(SPDocument* doc) } void -FontSubstitution::show(Glib::ustring out, SelContainer &l) +FontSubstitution::show(Glib::ustring out, std::vector &l) { Gtk::MessageDialog warning(_("\nSome fonts are not available and have been substituted."), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true); @@ -148,17 +148,17 @@ FontSubstitution::show(Glib::ustring out, SelContainer &l) * b. Build up a list of the objects rendered fonts - taken for the objects layout/spans * If there are fonts in a. that are not in b. then those fonts have been substituted. */ -SelContainer FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *out) +std::vector FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *out) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - SelContainer allList; - SelContainer outList,x,y; + std::vector allList; + std::vector outList,x,y; std::set setErrors; std::set setFontSpans; std::map mapFontStyles; allList = get_all_items(x, doc->getRoot(), desktop, false, false, true, y); - for(SelContainer::const_iterator i = allList.begin();i!=allList.end();i++){ + for(std::vector::const_iterator i = allList.begin();i!=allList.end();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; Glib::ustring family = ""; @@ -214,8 +214,8 @@ SelContainer FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustri } // Check if any document styles are not in the actual layout - std::map::const_iterator mapIter; - for (mapIter = mapFontStyles.begin(); mapIter != mapFontStyles.end(); ++mapIter) { + std::map::const_reverse_iterator mapIter; + for (mapIter = mapFontStyles.rbegin(); mapIter != mapFontStyles.rend(); ++mapIter) { SPItem *item = mapIter->first; Glib::ustring fonts = mapIter->second; @@ -248,7 +248,7 @@ SelContainer FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustri Glib::ustring err = Glib::ustring::compose( _("Font '%1' substituted with '%2'"), fonts.c_str(), subName.c_str()); setErrors.insert(err); - outList.push_front(item); + outList.push_back(item); } } diff --git a/src/ui/dialog/font-substitution.h b/src/ui/dialog/font-substitution.h index eed7adcf2..cdb4e22b4 100644 --- a/src/ui/dialog/font-substitution.h +++ b/src/ui/dialog/font-substitution.h @@ -25,13 +25,13 @@ public: FontSubstitution(); virtual ~FontSubstitution(); void checkFontSubstitutions(SPDocument* doc); - void show(Glib::ustring out, SelContainer &l); + void show(Glib::ustring out, std::vector &l); static FontSubstitution &getInstance() { return *new FontSubstitution(); } Glib::ustring getSubstituteFontName (Glib::ustring font); protected: - SelContainer getFontReplacedItems(SPDocument* doc, Glib::ustring *out); + std::vector getFontReplacedItems(SPDocument* doc, Glib::ustring *out); private: FontSubstitution(FontSubstitution const &d); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 1ef97b996..fa469dc4b 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -578,8 +578,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) void GlyphsPanel::insertText() { SPItem *textItem = 0; - SelContainer itemlist=targetDesktop->selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector itemlist=targetDesktop->selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { textItem = SP_ITEM(*i); break; @@ -688,8 +688,8 @@ void GlyphsPanel::selectionModifiedCB(guint flags) void GlyphsPanel::calcCanInsert() { int items = 0; - SelContainer itemlist=targetDesktop->selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector itemlist=targetDesktop->selection->itemList(); + 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 ba8616d9b..d62032e9d 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -175,9 +175,9 @@ void GridArrangeTab::arrange() desktop->getDocument()->ensureUpToDate(); Inkscape::Selection *selection = desktop->getSelection(); - const SelContainer items = selection ? selection->itemList() : SelContainer(); + const std::vector items = selection ? selection->itemList() : std::vector(); cnt=0; - for(SelContainer::const_iterator i = items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i = items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); Geom::OptRect b = item->documentVisualBounds(); if (!b) { @@ -205,18 +205,17 @@ void GridArrangeTab::arrange() // require the sorting done before we can calculate row heights etc. g_return_if_fail(selection); - SelContainer rev(selection->itemList()); - rev.sort(sp_compare_y_position_obj); - SelContainer sorted(rev); - sorted.sort(sp_compare_x_position_obj); + std::vector sorted(selection->itemList()); + sort(sorted.begin(),sorted.end(),sp_compare_y_position); + sort(sorted.begin(),sorted.end(),sp_compare_x_position); // Calculate individual Row and Column sizes if necessary cnt=0; - const SelContainer sizes(sorted); - for (SelContainer::const_iterator i = sizes.begin();i!=sizes.end();i++) { + const std::vector sizes(sorted); + for (std::vector::const_iterator i = sizes.begin();i!=sizes.end();i++) { SPItem *item = SP_ITEM(*i); Geom::OptRect b = item->documentVisualBounds(); if (b) { @@ -314,7 +313,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h } cnt=0; - SelContainer::iterator it = sorted.begin(); + std::vector::iterator it = sorted.begin(); for (row_cnt=0; ((it != sorted.end()) && (row_cntselection : 0; g_return_if_fail( selection ); - SelContainer const items = selection->itemList(); + std::vector const items = selection->itemList(); int selcount = items.size(); double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); @@ -545,7 +544,7 @@ void GridArrangeTab::updateSelection() updating = true; SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; - SelContainer const items = selection ? selection->itemList() : SelContainer(); + std::vector const items = selection ? selection->itemList() : std::vector(); if (!items.empty()) { int selcount = items.size(); diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 79e5b556d..6ad3d61ac 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -366,8 +366,8 @@ void IconPreviewPanel::refreshPreview() if ( sel ) { //g_message("found a selection to play with"); - SelContainer const items = sel->itemList(); - for(SelContainer::const_iterator i=items.begin();!target && i!=items.end();i++){ + std::vector const items = sel->itemList(); + for(std::vector::const_iterator i=items.begin();!target && i!=items.end();i++){ SPItem* item = SP_ITEM( *i); gchar const *id = item->getId(); if ( id ) { diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 0ae3027c7..d60780f78 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -479,8 +479,8 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); SPItem *item = NULL; - SelContainer const items = sel->itemList(); - for(SelContainer::const_iterator i=items.begin(); i!=items.end();i++){ + std::vector const items = sel->itemList(); + for(std::vector::const_iterator i=items.begin(); i!=items.end();i++){ item = reinterpret_cast(*i); if (setOpacity) { diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 273a378e5..760391df6 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -372,8 +372,8 @@ void PixelArtDialogImpl::vectorize() return; } - SelContainer const items = desktop->selection->itemList(); - for(SelContainer::const_iterator i=items.begin(); i!=items.end();i++){ + std::vector const items = desktop->selection->itemList(); + 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 8a382fc93..a68e73caf 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -297,14 +297,14 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { Inkscape::Selection *selection = parent->getDesktop()->getSelection(); - const SelContainer tmp(selection->itemList()); + const std::vector tmp(selection->itemList()); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); int count = 0; - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) + for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++) { if(arrangeOnEllipse) { @@ -373,7 +373,7 @@ void PolarArrangeTab::arrange() Geom::Point realCenter = Geom::Point(cx, cy) * transformation; int i = 0; - for(SelContainer::const_iterator it=tmp.begin();it!=tmp.end();it++) + for(std::vector::const_iterator it=tmp.begin();it!=tmp.end();it++) { SPItem *item = SP_ITEM(*it); diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index dc98b6032..351971294 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -81,7 +81,7 @@ static void draw_page( width, height, (unsigned long)(Inkscape::Util::Quantity::convert(width, "px", "in") * dpi), (unsigned long)(Inkscape::Util::Quantity::convert(height, "px", "in") * dpi), - dpi, dpi, bgcolor, NULL, NULL, true, SelContainer()); + dpi, dpi, bgcolor, NULL, NULL, true, std::vector()); // This doesn't seem to work: //context->set_cairo_context ( Cairo::Context::create (Cairo::ImageSurface::create_from_png (tmp_png) ), dpi, dpi ); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index da24ad605..72677c07e 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(); - SelContainer const items = selection->itemList(); + std::vector const items = selection->itemList(); 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 ba3a6b914..c2df5fc1c 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -669,8 +669,8 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) if (col == _tree.get_column(COL_ADD - 1) && down_at_add) { if (SP_IS_TAG(obj)) { bool wasadded = false; - SelContainer items=_desktop->selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=_desktop->selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPObject *newobj = reinterpret_cast(*i); bool addchild = true; for ( SPObject *child = obj->children; child != NULL; child = child->next) { diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 593261ec5..1c1cf5937 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -418,8 +418,8 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - SelContainer tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) + std::vector tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return SP_ITEM (*i); @@ -436,8 +436,8 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - SelContainer tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) + std::vector tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) ++items; @@ -540,11 +540,11 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const SelContainer item_list = desktop->getSelection()->itemList(); + const std::vector item_list = desktop->getSelection()->itemList(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); - for(SelContainer::const_iterator i=item_list.begin();i!=item_list.end();i++){ + for(std::vector::const_iterator i=item_list.begin();i!=item_list.end();i++){ // apply style to the reprs of all text objects in the selection if (SP_IS_TEXT (*i)) { diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 8c52144e0..0f81a7e58 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -741,12 +741,12 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { // shift each object relatively to the previous one using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector selected(selection->itemList()); if (selected.empty()) return; if (fabs(x) > 1e-6) { std::vector< BBoxSort > sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -771,7 +771,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } if (fabs(y) > 1e-6) { std::vector< BBoxSort > sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -816,8 +816,8 @@ 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")) { - SelContainer tmp=selection->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + std::vector tmp=selection->itemList(); + for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++){ SPItem *item = SP_ITEM(*i); Geom::OptRect bbox_pref = item->desktopPreferredBounds(); Geom::OptRect bbox_geom = item->desktopGeometricBounds(); @@ -880,8 +880,8 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } if (prefs->getBool("/dialogs/transformation/applyseparately")) { - SelContainer tmp=selection->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + std::vector tmp=selection->itemList(); + for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++){ SPItem *item = SP_ITEM(*i); sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } @@ -900,8 +900,8 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i = items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i = items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); if (!_units_skew.isAbsolute()) { // percentage @@ -1002,8 +1002,8 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) } if (_check_replace_matrix.get_active()) { - SelContainer tmp=selection->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + std::vector tmp=selection->itemList(); + for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++){ SPItem *item = SP_ITEM(*i); item->set_item_transform(displayed); SP_OBJECT(item)->updateRepr(); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 86cf629c1..43e35df9d 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1906,7 +1906,7 @@ void ContextMenu::ActivateGroup(void) void ContextMenu::ActivateUngroup(void) { - SelContainer children; + std::vector children; sp_item_group_ungroup(static_cast(_item), children); _desktop->selection->setList(children); @@ -1958,7 +1958,7 @@ void ContextMenu::AnchorLinkFollow(void) void ContextMenu::AnchorLinkRemove(void) { - SelContainer children; + std::vector children; sp_item_group_ungroup(static_cast(_item), children, false); DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link")); } @@ -2075,8 +2075,8 @@ void ContextMenu::ImageEdit(void) } #endif - SelContainer itemlist=_desktop->selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=_desktop->selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ Inkscape::XML::Node *ir = SP_ITEM(*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 fc40c20e7..9c6eead16 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1316,8 +1316,8 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - SelContainer l = selection->itemList(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++) { + std::vector l = selection->itemList(); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++) { SPItem *item = SP_ITEM(*i); char const *value = (set_avoid) ? "true" : NULL; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 3526e015a..520b93e72 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -676,8 +676,7 @@ void EraserTool::set_to_accumulated() { Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; - SelContainer toWorkOn; - + std::vector toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds); @@ -685,16 +684,15 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - - toWorkOn.remove(static_cast(acid) ); + toWorkOn.erase(find(toWorkOn.begin(),toWorkOn.end(),acid)); } else { - toWorkOn = selection->itemList(); + toWorkOn= selection->itemList(); wasSelection = true; } if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); if ( eraserMode ) { @@ -712,8 +710,8 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - SelContainer nowSel(selection->itemList()); - for (SelContainer::const_iterator i2 = nowSel.begin();i!=nowSel.end();i++) { + std::vector nowSel(selection->itemList()); + for (std::vector::const_iterator i2 = nowSel.begin();i!=nowSel.end();i2++) { remainingItems.push_back(SP_ITEM(*i2)); } } @@ -723,11 +721,11 @@ void EraserTool::set_to_accumulated() { } } } else { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { sp_object_ref( SP_ITEM(*i), 0 ); } - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); item->deleteObject(true); sp_object_unref(item); diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index d1db5fb93..6f7b220ed 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -504,8 +504,8 @@ bool GradientTool::root_handler(GdkEvent* event) { // 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); } else { - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + std::vector items=selection->itemList(); + for (std::vector::const_iterator i = items.begin();i!=items.end();i++) { SPItem *item = SP_ITEM(*i); SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -915,8 +915,8 @@ 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 - SelContainer items(selection->itemList()); - items.sort(sp_item_repr_compare_position_obj); + std::vector items(selection->itemList()); + 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); } @@ -925,8 +925,8 @@ 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"); - SelContainer itemlist = selection->itemList(); - for (SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist = selection->itemList(); + for (std::vector::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index ce0ad7a9a..290eeef87 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -407,8 +407,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); curve = path->getCurve(); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 8d52210ff..2b44639c8 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -441,9 +441,9 @@ bool MeasureTool::root_handler(GdkEvent* event) { // TODO switch to a different variable name. The single letter 'l' is easy to misread. //select elements crossed by line segment: - SelContainer items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); + std::vector items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector intersection_times; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { SPItem *item = static_cast(*i); if (SP_IS_SHAPE(item)) { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 1cc06a5b9..0a34e4855 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -481,8 +481,8 @@ bool MeshTool::root_handler(GdkEvent* event) { sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -958,8 +958,8 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ } else { // Starting from empty space: // Sort items so that the topmost comes last - SelContainer items(selection->itemList()); - items.sort(sp_item_repr_compare_position_obj); + std::vector items(selection->itemList()); + 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); } @@ -968,8 +968,8 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 46c978c84..6ddb379cc 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -420,8 +420,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set shapes; - SelContainer items=sel->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=sel->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPObject *obj = static_cast(*i); if (SP_IS_ITEM(obj)) { @@ -667,7 +667,7 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { if (this->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes Inkscape::Selection *selection = this->desktop->selection; - SelContainer items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); + std::vector items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); selection->setList(items); } else { if (!held_shift(*event)) { diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index f84170631..25cbf76a4 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -718,7 +718,7 @@ bool SelectTool::root_handler(GdkEvent* event) { if (r->is_started() && !within_tolerance) { // this was a rubberband drag - SelContainer items; + std::vector items; if (r->getMode() == RUBBERBAND_MODE_RECT) { Geom::OptRect const b = r->getRectangle(); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index d339f6d19..ac41f3a34 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -436,9 +436,9 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator it=items.begin();it!=items.end();it++){ - SPItem *item1 = dynamic_cast(static_cast(*it)); + std::vector items=selection->itemList(); + for(std::vector::const_iterator it=items.begin();it!=items.end();it++){ + SPItem *item1 = *it; if (i == 1) { parent_item = item1; } @@ -550,15 +550,15 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - SelContainer const items(selection->itemList()); + std::vector const items(selection->itemList()); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_ref(item); } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); @@ -573,7 +573,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); g_assert(item != NULL); sp_object_unref(item); diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index a4370256d..48c109688 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -1470,7 +1470,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) } sp_text_context_validate_cursor_iterators(this); - SelContainer styles_list; + std::vector styles_list; Inkscape::Text::Layout::iterator begin_it, end_it; if (this->text_sel_start < this->text_sel_end) { @@ -1496,7 +1496,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) while (SP_IS_STRING(pos_obj) && pos_obj->parent) { pos_obj = pos_obj->parent; // SPStrings don't have style } - styles_list.push_front(pos_obj); + styles_list.insert(styles_list.begin(),(SPItem*)pos_obj); } int result = sp_desktop_query_style_from_list (styles_list, style, property); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index cc05f9775..def8080d0 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1178,8 +1178,8 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, SPItem * sp_event_context_over_item(SPDesktop *desktop, SPItem *item, Geom::Point const &p) { - SelContainer temp; - temp.push_front(static_cast(item)); + std::vector temp; + temp.push_back(item); SPItem *item_at_point = desktop->getItemFromListAtPointBottom(temp, p); return item_at_point; } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 9342127ce..6f7764506 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -382,13 +382,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } if (dynamic_cast(item) || dynamic_cast(item)) { - SelContainer items; + std::vector items; items.push_back(item); - SelContainer selected; - SelContainer to_select; + std::vector selected; + std::vector to_select; SPDocument *doc = item->document; sp_item_list_to_curves (items, selected, to_select); - SPObject* newObj = doc->getObjectByRepr(dynamic_cast(to_select.front())); + SPObject* newObj = doc->getObjectByRepr(to_select.back()); item = dynamic_cast(newObj); g_assert(item != NULL); selection->add(item); @@ -1087,8 +1087,8 @@ 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); - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector items=selection->itemList(); + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast(static_cast(*i)); if (is_color_mode (tc->mode)) { diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index ddf67fb5b..598a90e95 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -125,8 +125,8 @@ ObjectCompositeSettings::_blendBlurValueChanged() const Glib::ustring blendmode = _fe_cb.get_blend_mode(); //apply created filter to every selected item - SelContainer sel=_subject->getDesktop()->getSelection()->itemList(); - for (SelContainer::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) { + std::vector sel=_subject->getDesktop()->getSelection()->itemList(); + for (std::vector::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) { if (!SP_IS_ITEM(*i)) { continue; } diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index 9d09e67d3..1ded546dd 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -148,10 +148,10 @@ Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { } int StyleSubject::CurrentLayer::queryStyle(SPStyle *query, int property) { - SelContainer list; + std::vector list; SPObject* i=_getLayerSList(); if (i) { - list.push_back(i); + list.push_back((SPItem*)i); return sp_desktop_query_style_from_list(list, query, property); } else { return QUERY_STYLE_NOTHING; diff --git a/src/unclump.cpp b/src/unclump.cpp index d1cfc6628..29608befa 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -168,11 +168,11 @@ unclump_dist (SPItem *item1, SPItem *item2) /** Average unclump_dist from item to others */ -static double unclump_average (SPItem *item, SelContainer &others) +static double unclump_average (SPItem *item, std::list &others) { int n = 0; double sum = 0; - for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + for (std::list::const_iterator i = others.begin(); i != others.end();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -191,12 +191,12 @@ static double unclump_average (SPItem *item, SelContainer &others) /** Closest to item among others */ -static SPItem *unclump_closest (SPItem *item, SelContainer &others) +static SPItem *unclump_closest (SPItem *item, std::list &others) { double min = HUGE_VAL; SPItem *closest = NULL; - for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + for (std::list::const_iterator i = others.begin(); i != others.end();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -215,11 +215,11 @@ static SPItem *unclump_closest (SPItem *item, SelContainer &others) /** Most distant from item among others */ -static SPItem *unclump_farest (SPItem *item, SelContainer &others) +static SPItem *unclump_farest (SPItem *item, std::list &others) { double max = -HUGE_VAL; SPItem *farest = NULL; - for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + for (std::list::const_iterator i = others.begin(); i != others.end();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -240,8 +240,8 @@ Removes from the \a rest list those items that are "behind" \a closest as seen f i.e. those on the other side of the line through \a closest perpendicular to the direction from \a item to \a closest. Returns a newly created list which must be freed. */ -static SelContainer -unclump_remove_behind (SPItem *item, SPItem *closest, SelContainer &rest) +static std::vector +unclump_remove_behind (SPItem *item, SPItem *closest, std::list &rest) { Geom::Point it = unclump_center (item); Geom::Point p1 = unclump_center (closest); @@ -258,8 +258,8 @@ unclump_remove_behind (SPItem *item, SPItem *closest, SelContainer &rest) // substitute the item into it: double val_item = A * it[Geom::X] + B * it[Geom::Y] + C; - SelContainer out; - for (SelContainer::const_iterator i = rest.begin(); i != rest.end();i++) { + std::vector out; + for (std::list::const_reverse_iterator i = rest.rbegin(); i != rest.rend();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -271,7 +271,7 @@ unclump_remove_behind (SPItem *item, SPItem *closest, SelContainer &rest) if (val_item * val_other <= 1e-6) { // different signs, which means item and other are on the different sides of p1-p2 line; skip } else { - out.push_front(other); + out.push_back(other); } } @@ -331,17 +331,18 @@ similar to "engraver dots". The only distribution which is unchanged by unclumpi grid. May be called repeatedly for stronger effect. */ void -unclump (SelContainer &items) +unclump (std::vector &items) { c_cache.clear(); wh_cache.clear(); - for (SelContainer::const_iterator i = items.begin(); i != items.end();i++) { // for each original/clone x: + for (std::vector::const_iterator i = items.begin(); i != items.end();i++) { // for each original/clone x: SPItem *item = SP_ITEM (*i); - SelContainer nei; + std::list nei; - SelContainer rest(items); + std::list rest; + for(int i=0;i new_rest = unclump_remove_behind (item, closest, rest); + rest.clear(); + for(int i=0;i &items); #endif /* !UNCLUMP_H_SEEN */ diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 98a3eaa67..770845f38 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -256,8 +256,8 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list sel_boxes; - SelContainer itemlist=sel->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=sel->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box && this->hasBox(box)) { @@ -396,8 +396,8 @@ 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(); - SelContainer itemlist=sel->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=sel->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { @@ -579,8 +579,8 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - SelContainer itemlist=this->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=this->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { @@ -612,8 +612,8 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - SelContainer itemlist=this->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector itemlist=this->selection->itemList(); + for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast(*i); SPBox3D *box = dynamic_cast(item); if (box) { @@ -630,7 +630,7 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - SelContainer sel = selection->itemList(); + std::vector sel = selection->itemList(); if (sel.empty()) return; // no selection diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 23c248129..cb24bb8aa 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -97,8 +97,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL); bool modmade = false; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { @@ -163,8 +163,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) bool modmade = false; if ( ege_select_one_action_get_active(act) != 0 ) { - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -174,8 +174,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } } } else { - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +264,8 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { n_selected++; diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 401ce932a..49cf8e6fd 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -97,8 +97,8 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl gchar *value = is_orthog ? orthog_str : polyline_str ; bool modmade = false; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (Inkscape::UI::Tools::cc_item_is_connector(item)) { @@ -144,8 +144,8 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) g_ascii_dtostr(value, G_ASCII_DTOSTR_BUF_SIZE, newValue); bool modmade = false; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (Inkscape::UI::Tools::cc_item_is_connector(item)) { diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 2c298b04d..dbb84efba 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -481,7 +481,7 @@ void FillNStroke::updateFromPaint() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - SelContainer const items = selection->itemList(); + std::vector const items = selection->itemList(); switch (psel->mode) { case SPPaintSelector::MODE_EMPTY: @@ -576,7 +576,7 @@ void FillNStroke::updateFromPaint() } } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { sp_repr_css_change_recursive(reinterpret_cast(*i)->getRepr(), css, "style"); @@ -602,7 +602,7 @@ void FillNStroke::updateFromPaint() // We have changed from another gradient type, or modified spread/units within // this gradient type. vector = sp_gradient_ensure_vector_normalized(vector); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { sp_repr_css_change_recursive(reinterpret_cast(*i)->getRepr(), css, "style"); @@ -648,7 +648,7 @@ void FillNStroke::updateFromPaint() // cannot just call sp_desktop_set_style, because we don't want to touch those // objects who already have the same root pattern but through a different href // chain. FIXME: move this to a sp_item_set_pattern - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ Inkscape::XML::Node *selrepr = reinterpret_cast(*i)->getRepr(); if ( (kind == STROKE) && !selrepr) { continue; diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index b9608130b..5aa654a80 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -116,8 +116,8 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient } // If no drag or no dragger selected, act on selection - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ gr_apply_gradient_to_item(SP_ITEM(*i), gr, initialType, initialMode, initialMode); } } @@ -218,8 +218,8 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr { SPGradient *gradient = 0; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -286,8 +286,8 @@ void gr_read_selection( Inkscape::Selection *selection, } // If no selected dragger, read desktop selection - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index b4176db6f..682c61e77 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -87,8 +87,8 @@ void ms_read_selection( Inkscape::Selection *selection, bool first = true; ms_smooth = SP_MESH_SMOOTH_NONE; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -214,8 +214,8 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient { SPMeshGradient *gradient = 0; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 1f19867ee..65078af01 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -106,8 +106,8 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_RECT(*i)) { if (gtk_adjustment_get_value(adj) != 0) { (SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, desktop->getNamedView()->svg_units)); @@ -244,8 +244,8 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO } purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_RECT(reinterpret_cast(*i))) { n_selected++; item = reinterpret_cast(*i); diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 2f4ad481d..6f967e8ae 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -79,8 +79,8 @@ 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; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=desktop->getSelection()->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_SPIRAL(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -195,8 +195,8 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_SPIRAL(item)) { n_selected++; diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 37daf69d0..1946dee6e 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -83,8 +83,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -128,8 +128,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -185,8 +185,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d gtk_action_set_sensitive( prop_action, !flat ); } - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -224,8 +224,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +264,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -367,8 +367,8 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { n_selected++; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 2599fe537..65390819b 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -475,8 +475,8 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using continue; @@ -901,7 +901,7 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - SelContainer const objects = sel->itemList(); + std::vector const objects = sel->itemList(); SPObject * const object = SP_OBJECT(objects.front()); SPStyle * const style = object->style; @@ -957,7 +957,7 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items=selection->itemList(); + std::vector items=selection->itemList(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); @@ -977,7 +977,7 @@ StrokeStyle::scaleLine() int ndash; dashSelector->get_dash(&ndash, &dash, &offset); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ /* Set stroke width */ double width; if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { @@ -1143,7 +1143,7 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active) * that marker. */ void -StrokeStyle::updateAllMarkers(SelContainer const &objects) +StrokeStyle::updateAllMarkers(std::vector const &objects) { struct { MarkerComboBox *key; int loc; } const keyloc[] = { { startMarkerCombo, SP_MARKER_LOC_START }, @@ -1152,7 +1152,7 @@ StrokeStyle::updateAllMarkers(SelContainer const &objects) }; bool all_texts = true; - for(SelContainer::const_iterator i=objects.begin();i!=objects.end();i++){ + for(std::vector::const_iterator i=objects.begin();i!=objects.end();i++){ if (!SP_IS_TEXT (*i)) { all_texts = false; } diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index 286305ec3..2605e1acf 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -153,7 +153,7 @@ private: }; void updateLine(); - void updateAllMarkers(SelContainer const &objects); + void updateAllMarkers(std::vector const &objects); void updateMarkerHist(SPMarkerLoc const which); void setDashSelectorFromStyle(SPDashSelector *dsel, SPStyle *style); void setJoinType (unsigned const jointype); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index ba7dfc1fd..71915377e 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -366,8 +366,8 @@ 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(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_TEXT(SP_ITEM(*i))) { SPItem *item = SP_ITEM(*i); @@ -519,8 +519,8 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Until deprecated sodipodi:linespacing purged: Inkscape::Selection *selection = desktop->getSelection(); bool modmade = false; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=selection->itemList(); + for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_TEXT (*i)) { SP_OBJECT(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); modmade = true; @@ -864,8 +864,8 @@ 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; - SelContainer itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + 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; if( SP_IS_FLOWTEXT(SP_ITEM(*i))) { @@ -1153,13 +1153,13 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p //std::cout << "text_toolbox_missing_font_cb: selecting: " << family << std::endl; // Get all items with matching font-family set (not inherited!). - SelContainer selectList; + std::vector selectList; SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDocument *document = desktop->getDocument(); - SelContainer x,y; - SelContainer allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y); - for(SelContainer::const_iterator i=allList.begin();i!=allList.end();i++){ + std::vector x,y; + std::vector allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y); + for(std::vector::const_reverse_iterator i=allList.rbegin();i!=allList.rend();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -1177,7 +1177,7 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p if (family_style.compare( family ) == 0 ) { //std::cout << " found: " << item->getId() << std::endl; - selectList.push_front(static_cast(item)); + selectList.push_back(item); } } } -- cgit v1.2.3 From 7e4b6f793d31d3245bd8afbf6f10aa255ac3e7ae Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 20:20:09 +0100 Subject: added a set to the Selection (bzr r13922.1.6) --- src/extension/internal/cairo-renderer.cpp | 5 ++--- src/extension/internal/latex-text-renderer.cpp | 5 ++--- src/selection-chemistry.cpp | 10 ++++----- src/selection.cpp | 23 ++++++++++++++------ src/selection.h | 12 +++++------ src/sp-defs.cpp | 5 ++--- src/sp-filter.cpp | 5 ++--- src/sp-item-group.cpp | 29 +++++++++++--------------- src/sp-object.cpp | 6 +++--- src/sp-object.h | 5 +++-- src/sp-switch.cpp | 14 ++++++------- src/sp-switch.h | 2 +- src/ui/dialog/grid-arrange-tab.cpp | 28 ++++++++++--------------- src/ui/dialog/tags.cpp | 4 ++-- src/ui/tools/eraser-tool.cpp | 2 +- src/xml/repr-util.cpp | 12 +++++------ src/xml/repr.h | 3 ++- 17 files changed, 83 insertions(+), 87 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 7ce5cdf8a..f614ec745 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -294,9 +294,8 @@ static void sp_group_render(SPGroup *group, CairoRenderContext *ctx) CairoRenderer *renderer = ctx->getRenderer(); TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); - SelContainer l(group->childList(false)); - l.reverse(); - for(SelContainer::const_iterator x=l.begin();x!=l.end();x++){ + std::vector l(group->childList(false)); + for(std::vector::const_iterator x=l.begin();x!=l.end();x++){ SPObject *o = reinterpret_cast(*x); SPItem *item = dynamic_cast(o); if (item) { diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index dab27a0e1..a2de264ab 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -228,9 +228,8 @@ LaTeXTextRenderer::writePostamble() void LaTeXTextRenderer::sp_group_render(SPGroup *group) { - SelContainer l = (group->childList(false)); - l.reverse(); - for(SelContainer::const_iterator x=l.begin();x!=l.end();x++){ + std::vector l = (group->childList(false)); + for(std::vector::const_iterator x=l.begin();x!=l.end();x++){ SPObject *o = reinterpret_cast(*x); SPItem *item = dynamic_cast(o); if (item) { diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f1c96b6b8..736e020dd 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -558,7 +558,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) g_return_if_fail(group != NULL); std::vector items = sp_item_group_item_list(group); - for(int i=0;i(items[i])->deleteObject(); } @@ -3061,7 +3061,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) doc->ensureUpToDate(); - SelContainer items(selection->list()); + std::vector items(selection->list()); // Keep track of parent, this is where will be inserted. Inkscape::XML::Node *the_first_repr = reinterpret_cast( items.front() )->getRepr(); @@ -3128,7 +3128,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) } // Move selected items to new - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); repr->parent()->removeChild(repr); symbol_repr->addChild(repr,NULL); @@ -3195,7 +3195,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) desktop->currentLayer()->getRepr()->appendChild(group); // Move all children of symbol to group - SelContainer children = symbol->childList(false); + std::vector children = symbol->childList(false); // Converting a group to a symbol inserts a group for non-translational transform. // In converting a symbol back to a group we strip out the inserted group (or any other @@ -3212,7 +3212,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) } } - for (SelContainer::const_iterator i=children.begin();i!=children.end();i++){ + for (std::vector::const_iterator i=children.begin();i!=children.end();i++){ Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); repr->parent()->removeChild(repr); group->addChild(repr,NULL); diff --git a/src/selection.cpp b/src/selection.cpp index 2e8251048..fd3b6abae 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -42,7 +42,9 @@ namespace Inkscape { Selection::Selection(LayerModel *layers, SPDesktop *desktop) : - _objs(SelContainer()), + _objs(std::list()), + _objs_vector(std::vector()), + _objs_set(std::set()), _reprs(std::vector()), _items(std::vector()), _layers(layers), @@ -145,7 +147,7 @@ bool Selection::includes(SPObject *obj) const { g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE); - return ( find(_objs.begin(),_objs.end(),obj)!=_objs.end() ); + return ( _objs_set.find(obj)!=_objs_set.end() ); } void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) { @@ -178,6 +180,7 @@ void Selection::_add(SPObject *obj) { _removeObjectAncestors(obj); _objs.push_front(obj); + _objs_set.insert(obj); add_3D_boxes_recursively(obj); @@ -232,6 +235,7 @@ void Selection::_remove(SPObject *obj) { remove_3D_boxes_recursively(obj); _objs.remove(obj); + _objs_set.erase(obj); } void Selection::setList(std::vector const &list) { @@ -276,8 +280,15 @@ void Selection::clear() { _emitChanged(); } -SelContainer const &Selection::list() { - return _objs; +std::vector const &Selection::list() { + if(!_objs_vector.empty()) + return _objs_vector; + + for ( std::list::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { + _objs_vector.push_back(*iter); + } + return _objs_vector; + } std::vector const &Selection::itemList() { @@ -285,7 +296,7 @@ std::vector const &Selection::itemList() { return _items; } - for ( SelContainer::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { + for ( std::list::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { SPObject *obj=reinterpret_cast(*iter); if (SP_IS_ITEM(obj)) { _items.push_back(SP_ITEM(obj)); @@ -470,7 +481,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc } void Selection::_removeObjectDescendants(SPObject *obj) { - for ( SelContainer::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { + for ( std::list::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { SPObject *sel_obj=reinterpret_cast(*iter); SPObject *parent = sel_obj->parent; while (parent) { diff --git a/src/selection.h b/src/selection.h index 2d5e7c34a..e40810ded 100644 --- a/src/selection.h +++ b/src/selection.h @@ -16,14 +16,10 @@ #include #include #include +#include #include #include -#include -#include -#include -#include - #include "gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" @@ -254,7 +250,7 @@ public: XML::Node *singleRepr(); /** Returns the list of selected objects. */ - std::list const &list(); + std::vector const &list(); /** Returns the list of selected SPItems. */ std::vector const &itemList(); /** Returns a list of the xml nodes of all selected objects. */ @@ -376,7 +372,9 @@ private: /** Releases an active layer object that is being removed. */ void _releaseContext(SPObject *obj); - mutable std::list _objs; + mutable std::list _objs; //to more efficiently remove arbitrary elements + mutable std::vector _objs_vector; // to be returned by list(); + mutable std::set _objs_set; //to efficiently test if object is selected mutable std::vector _reprs; mutable std::vector _items; diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index d52fa038a..76843fd28 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -46,9 +46,8 @@ void SPDefs::update(SPCtx *ctx, guint flags) { } flags &= SP_OBJECT_MODIFIED_CASCADE; - SelContainer l(this->childList(true)); - l.reverse(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l(this->childList(true)); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ SPObject *child = SP_OBJECT(*i); if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index bf8f7a5a4..93a979287 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -244,9 +244,8 @@ void SPFilter::update(SPCtx *ctx, guint flags) { childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } childflags &= SP_OBJECT_MODIFIED_CASCADE; - SelContainer l(this->childList(true, SPObject::ActionUpdate)); - l.reverse(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l(this->childList(true, SPObject::ActionUpdate)); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ SPObject *child = SP_OBJECT (*i); if( SP_IS_FILTER_PRIMITIVE( child ) ) { child->updateDisplay(ctx, childflags); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index f09a4ee47..8a40df5ed 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -171,9 +171,8 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } childflags &= SP_OBJECT_MODIFIED_CASCADE; - SelContainer l=this->childList(true, SPObject::ActionUpdate); - l.reverse(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l=this->childList(true, SPObject::ActionUpdate); + for(std::vector ::const_iterator i=l.begin();i!=l.end();i++){ SPObject *child = SP_OBJECT (*i); if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { @@ -216,9 +215,8 @@ void SPGroup::modified(guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - SelContainer l=this->childList(true); - l.reverse(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l=this->childList(true); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ SPObject *child = SP_OBJECT (*i); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { @@ -291,8 +289,8 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox Geom::OptRect bbox; // TODO CPPIFY: replace this const_cast later - SelContainer l=const_cast(this)->childList(false, SPObject::ActionBBox); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l=const_cast(this)->childList(false, SPObject::ActionBBox); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast(o); if (item && !item->isHidden()) { @@ -305,9 +303,8 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } void SPGroup::print(SPPrintContext *ctx) { - SelContainer l=this->childList(false); - l.reverse(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l=this->childList(false); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast(o); if (item) { @@ -360,9 +357,8 @@ Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int k } void SPGroup::hide (unsigned int key) { - SelContainer l=this->childList(false, SPObject::ActionShow); - l.reverse(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l=this->childList(false, SPObject::ActionShow); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast(o); @@ -793,9 +789,8 @@ gint SPGroup::getItemCount() const { void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { Inkscape::DrawingItem *ac = NULL; - SelContainer l=this->childList(false, SPObject::ActionShow); - l.reverse(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + std::vector l=this->childList(false, SPObject::ActionShow); + for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ SPObject *o = SP_OBJECT (*i); SPItem * child = dynamic_cast(o); if (child) { diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 3ea480f66..6cc5d7114 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -382,14 +382,14 @@ void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr) sp_repr_css_change(this->getRepr(), css, attr); } -SelContainer SPObject::childList(bool add_ref, Action) { - SelContainer l; +std::vector SPObject::childList(bool add_ref, Action) { + std::vector l; for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { if (add_ref) { sp_object_ref (child); } - l.push_front(child); + l.push_back(child); } return l; diff --git a/src/sp-object.h b/src/sp-object.h index 858587611..1f3032a52 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -55,6 +55,7 @@ class SPObject; #include #include #include +#include #include "version.h" #include "util/forward-pointer-iterator.h" @@ -335,10 +336,10 @@ public: enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; /** - * Retrieves the children as a GSList object, optionally ref'ing the children + * Retrieves the children as a std vector object, optionally ref'ing the children * in the process, if add_ref is specified. */ - SelContainer childList(bool add_ref, Action action = ActionGeneral); + std::vector childList(bool add_ref, Action action = ActionGeneral); /** * Append repr as child of this object. diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 0090f1855..2c9427df8 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -55,13 +55,13 @@ SPObject *SPSwitch::_evaluateFirst() { return first; } -SelContainer SPSwitch::_childList(bool add_ref, SPObject::Action action) { +std::vector SPSwitch::_childList(bool add_ref, SPObject::Action action) { if ( action != SPObject::ActionGeneral ) { return this->childList(add_ref, action); } SPObject *child = _evaluateFirst(); - SelContainer x; + std::vector x; if (NULL == child) return x; @@ -69,7 +69,7 @@ SelContainer SPSwitch::_childList(bool add_ref, SPObject::Action action) { //g_object_ref (G_OBJECT (child)); sp_object_ref(child); } - x.push_front(child); + x.push_back(child); return x; } @@ -110,8 +110,8 @@ void SPSwitch::_reevaluate(bool /*add_to_drawing*/) { _releaseLastItem(_cached_item); - SelContainer item_list = _childList(false, SPObject::ActionShow); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector item_list = _childList(false, SPObject::ActionShow); + for ( std::vector::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) { SPObject *o = SP_OBJECT (*iter); if ( !SP_IS_ITEM (o) ) { continue; @@ -144,9 +144,9 @@ void SPSwitch::_releaseLastItem(SPObject *obj) void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { SPObject *evaluated_child = this->_evaluateFirst(); - SelContainer l = this->_childList(false, SPObject::ActionShow); + std::vector l = this->_childList(false, SPObject::ActionShow); - for ( SelContainer::const_iterator iter=l.begin();iter!=l.end();iter++) { + for ( std::vector::const_reverse_iterator iter=l.rbegin();iter!=l.rend();iter++) { SPObject *o = SP_OBJECT (*iter); if (SP_IS_ITEM (o)) { diff --git a/src/sp-switch.h b/src/sp-switch.h index 6a83072e7..7152e1b82 100644 --- a/src/sp-switch.h +++ b/src/sp-switch.h @@ -29,7 +29,7 @@ public: void resetChildEvaluated() { _reevaluate(); } - SelContainer _childList(bool add_ref, SPObject::Action action); + std::vector _childList(bool add_ref, SPObject::Action action); virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags); SPObject *_evaluateFirst(); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index d62032e9d..10498b0f9 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -48,7 +48,7 @@ * 0 *elem1 == *elem2 * >0 *elem1 goes after *elem2 */ -static int sp_compare_x_position(SPItem *first, SPItem *second) +static bool sp_compare_x_position(SPItem *first, SPItem *second) { using Geom::X; using Geom::Y; @@ -58,7 +58,7 @@ static int sp_compare_x_position(SPItem *first, SPItem *second) if ( !a || !b ) { // FIXME? - return 0; + return false; } double const a_height = a->dimensions()[Y]; @@ -76,44 +76,38 @@ static int sp_compare_x_position(SPItem *first, SPItem *second) } if (!a_in_b_vert) { - return -1; + return true; } if (a_in_b_vert && a->min()[X] > b->min()[X]) { - return 1; + return false; } if (a_in_b_vert && a->min()[X] < b->min()[X]) { - return -1; + return true; } - return 0; + return false; } /* * Sort items by their y co-ordinates. */ -static int sp_compare_y_position(SPItem *first, SPItem *second) +static bool sp_compare_y_position(SPItem *first, SPItem *second) { Geom::OptRect a = first->documentVisualBounds(); Geom::OptRect b = second->documentVisualBounds(); if ( !a || !b ) { // FIXME? - return 0; + return false; } if (a->min()[Geom::Y] > b->min()[Geom::Y]) { - return 1; + return false; } if (a->min()[Geom::Y] < b->min()[Geom::Y]) { - return -1; + return true; } - return 0; -} -static bool sp_compare_y_position_obj(SPObject *first, SPObject *second){ - return sp_compare_y_position(static_cast(first),static_cast(second))<0; -} -static bool sp_compare_x_position_obj(SPObject *first, SPObject *second){ - return sp_compare_x_position(static_cast(first),static_cast(second))<0; + return false; } diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index c2df5fc1c..bd34c7c66 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -371,8 +371,8 @@ void TagsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); - SelContainer tmp=sel->list(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) + std::vector tmp=sel->list(); + for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++) { SPObject *obj = reinterpret_cast(*i); _store->foreach(sigc::bind( sigc::mem_fun(*this, &TagsPanel::_checkForSelected), obj)); diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 520b93e72..b61a108f0 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -711,7 +711,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()); - for (std::vector::const_iterator i2 = nowSel.begin();i!=nowSel.end();i2++) { + for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) { remainingItems.push_back(SP_ITEM(*i2)); } } diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 12280ea5a..447f2ff40 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -259,7 +259,7 @@ gchar const *sp_xml_ns_prefix_uri(gchar const *prefix) * -1 first object's position is less than the second * @todo Rewrite this function's description to be understandable */ -int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second) +bool sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second) { int p1, p2; if (first->parent() == second->parent()) { @@ -276,9 +276,9 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No g_assert(ancestor != NULL); if (ancestor == first) { - return 1; + return false; } else if (ancestor == second) { - return -1; + return true; } else { Inkscape::XML::Node const *to_first = AncetreFils(first, ancestor); Inkscape::XML::Node const *to_second = AncetreFils(second, ancestor); @@ -288,9 +288,9 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No } } - if (p1 > p2) return 1; - if (p1 < p2) return -1; - return 0; + if (p1 > p2) return false; + if (p1 < p2) return true; + return false; /* effic: Assuming that the parent--child relationship is consistent (i.e. that the parent really does contain first and second among diff --git a/src/xml/repr.h b/src/xml/repr.h index e1d7fdfd6..c96560a98 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -118,7 +118,8 @@ unsigned sp_repr_set_svg_double(Inkscape::XML::Node *repr, char const *key, doub unsigned sp_repr_set_point(Inkscape::XML::Node *repr, char const *key, Geom::Point const & val); unsigned sp_repr_get_point(Inkscape::XML::Node *repr, char const *key, Geom::Point *val); -int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second); +//c++-style comparison : returns (bool)(a Date: Mon, 23 Feb 2015 22:41:06 +0100 Subject: Removed eclipse files, added removed pot file (bzr r13922.1.7) --- src/helper/png-write.h | 4 ---- src/selection.h | 2 -- src/sp-object.h | 3 --- 3 files changed, 9 deletions(-) (limited to 'src') diff --git a/src/helper/png-write.h b/src/helper/png-write.h index 04ca85cd6..2657fb635 100644 --- a/src/helper/png-write.h +++ b/src/helper/png-write.h @@ -14,12 +14,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include #include <2geom/forward.h> -//should be in selection.h -typedef std::list SelContainer; - class SPDocument; diff --git a/src/selection.h b/src/selection.h index e40810ded..71be6dd6b 100644 --- a/src/selection.h +++ b/src/selection.h @@ -33,8 +33,6 @@ class SPItem; class SPBox3D; class Persp3D; -typedef std::list SelContainer; - namespace Inkscape { class LayerModel; namespace XML { diff --git a/src/sp-object.h b/src/sp-object.h index 1f3032a52..7c189b01b 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -64,9 +64,6 @@ class SPCSSAttr; class SPStyle; typedef struct _GSList GSList; -//should be in selection.h -typedef std::list SelContainer; - namespace Inkscape { -- cgit v1.2.3 From 9a7fa4d1899d30ec745107823f307b2a0bf3172f Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 03:10:36 +0100 Subject: corrected the casts (hopefully) (bzr r13922.1.10) --- src/conn-avoid-ref.cpp | 4 +- src/desktop-style.cpp | 38 +++--- src/desktop-style.h | 2 +- src/document.cpp | 2 +- src/document.h | 1 - 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/cairo-renderer.cpp | 2 +- src/extension/internal/filter/filter.cpp | 2 +- src/extension/internal/grid.cpp | 2 +- src/extension/internal/latex-text-renderer.cpp | 4 +- src/file.cpp | 2 +- src/filter-chemistry.cpp | 2 +- src/gradient-chemistry.cpp | 10 +- src/gradient-drag.cpp | 12 +- src/graphlayout.cpp | 4 +- src/live_effects/lpe-knot.cpp | 2 +- src/main.cpp | 3 - src/object-snapper.cpp | 4 +- src/path-chemistry.cpp | 49 +++----- src/removeoverlap.cpp | 2 +- src/selcue.cpp | 10 +- src/selection-chemistry.cpp | 148 ++++++++++-------------- src/selection-chemistry.h | 1 - src/selection-describer.cpp | 8 +- src/selection.cpp | 16 +-- src/selection.h | 8 -- src/seltrans.cpp | 9 +- src/snap.cpp | 2 +- src/sp-conn-end.cpp | 2 +- src/sp-defs.cpp | 2 +- src/sp-filter.cpp | 2 +- src/sp-item-group.cpp | 14 +-- src/sp-item-group.h | 1 - src/sp-marker.cpp | 2 +- src/sp-object.h | 4 - src/sp-pattern.cpp | 2 +- src/sp-switch.cpp | 4 +- src/splivarot.cpp | 21 ++-- src/splivarot.h | 3 +- src/text-chemistry.cpp | 10 +- src/text-editing.cpp | 2 +- src/trace/trace.cpp | 2 +- src/ui/clipboard.cpp | 10 +- src/ui/dialog/align-and-distribute.cpp | 26 ++--- src/ui/dialog/export.cpp | 4 +- src/ui/dialog/filter-effects-dialog.cpp | 6 +- src/ui/dialog/find.cpp | 2 +- src/ui/dialog/find.h | 1 - src/ui/dialog/font-substitution.cpp | 2 +- src/ui/dialog/font-substitution.h | 3 +- src/ui/dialog/glyphs.cpp | 2 +- src/ui/dialog/grid-arrange-tab.cpp | 2 +- src/ui/dialog/icon-preview.cpp | 2 +- src/ui/dialog/objects.cpp | 2 +- src/ui/dialog/polar-arrange-tab.cpp | 4 +- src/ui/dialog/tags.cpp | 2 +- src/ui/dialog/text-edit.cpp | 2 +- src/ui/dialog/transformation.cpp | 20 ++-- src/ui/interface.cpp | 2 +- src/ui/tools/connector-tool.cpp | 2 +- src/ui/tools/eraser-tool.cpp | 10 +- src/ui/tools/gradient-tool.cpp | 20 ++-- src/ui/tools/gradient-tool.h | 3 +- src/ui/tools/measure-tool.cpp | 2 +- src/ui/tools/mesh-tool.cpp | 11 +- src/ui/tools/select-tool.cpp | 2 +- src/ui/tools/spray-tool.cpp | 6 +- src/ui/tools/tweak-tool.cpp | 2 +- src/unclump.cpp | 10 +- src/unclump.h | 1 - src/vanishing-point.cpp | 8 +- src/widgets/arc-toolbar.cpp | 8 +- src/widgets/connector-toolbar.cpp | 4 +- src/widgets/fill-style.cpp | 6 +- src/widgets/gradient-toolbar.cpp | 6 +- src/widgets/mesh-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 | 7 +- src/widgets/text-toolbar.cpp | 8 +- 85 files changed, 294 insertions(+), 370 deletions(-) (limited to 'src') diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index fb9fbd935..eb6694233 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -253,8 +253,8 @@ static std::vector approxItemWithPoints(SPItem const *item, const G SPGroup* group = SP_GROUP(item); // consider all first-order children std::vector itemlist = sp_item_group_item_list(group); - for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem* child_item = SP_ITEM(*i); + for (std::vector::const_iterator i = itemlist.begin(); i != itemlist.end(); i++) { + SPItem* child_item = *i; std::vector child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); } diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index e1a81f00a..82f66dcdf 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -195,9 +195,9 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); std::vector const itemlist = desktop->selection->itemList(); - for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { /* last used styles for 3D box faces are stored separately */ - SPObject *obj = reinterpret_cast(*i); // TODO unsafe until Selection is refactored. + SPObject *obj = reinterpret_cast(*i); Box3DSide *side = dynamic_cast(obj); if (side) { const char * descr = box3d_side_axes_string(side); @@ -235,8 +235,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write css_no_text = sp_css_attr_unset_text(css_no_text); std::vector const itemlist = desktop->selection->itemList(); - for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = reinterpret_cast(*i); + for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { + SPItem *item = *i; // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) if (isTextualItem(item)) { @@ -447,9 +447,9 @@ stroke_average_width (const std::vector &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); - SPItem *item = dynamic_cast(obj); + SPItem *item = *i; if (!item) { continue; } @@ -514,7 +514,7 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i!= objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -698,7 +698,7 @@ objects_query_opacity (const std::vector &objects, SPStyle *style_res) guint opacity_items = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -754,7 +754,7 @@ objects_query_strokewidth (const std::vector &objects, SPStyle *style_r int n_stroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -828,7 +828,7 @@ objects_query_miterlimit (const std::vector &objects, SPStyle *style_re gdouble prev_ml = -1; bool same_ml = true; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -887,7 +887,7 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res bool same_cap = true; int n_stroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -941,7 +941,7 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re bool same_join = true; int n_stroked = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!dynamic_cast(obj)) { continue; @@ -1004,7 +1004,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r int texts = 0; int no_size = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1123,7 +1123,7 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1192,7 +1192,7 @@ objects_query_baselines (const std::vector &objects, SPStyle *style_res int texts = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!isTextualItem(obj)) { @@ -1280,7 +1280,7 @@ objects_query_fontfamily (const std::vector &objects, SPStyle *style_re } style_res->font_family.set = FALSE; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1336,7 +1336,7 @@ objects_query_fontspecification (const std::vector &objects, SPStyle *s } style_res->font_specification.set = FALSE; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; @@ -1394,7 +1394,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; @@ -1484,7 +1484,7 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (std::vector::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { SPObject *obj = reinterpret_cast(*i); if (!obj) { continue; diff --git a/src/desktop-style.h b/src/desktop-style.h index 7ca25b9ae..a72f49776 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -13,11 +13,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "selection.h" // SelContainer class ColorRGBA; class SPCSSAttr; class SPDesktop; class SPObject; +class SPItem; class SPStyle; typedef struct _GSList GSList; namespace Inkscape { diff --git a/src/document.cpp b/src/document.cpp index 07ad10505..0582f1a70 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1289,7 +1289,7 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); 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; } } diff --git a/src/document.h b/src/document.h index 57ff7643c..bc5b2745a 100644 --- a/src/document.h +++ b/src/document.h @@ -27,7 +27,6 @@ #include #include #include -#include "selection.h" namespace Avoid { class Router; diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 90a7810e6..971f0b64a 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -65,7 +65,7 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp if (desktop != NULL) { std::vector selected = desktop->getSelection()->itemList(); - for(std::vector::const_iterator x=selected.begin();x!=selected.end();x++){ + for(std::vector::const_iterator x = selected.begin(); x != selected.end(); x++){ Glib::ustring selected_id; selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index cea6d139f..11c494b18 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -51,7 +51,7 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { - const SPItem * item = SP_ITEM(selected.front()); + const SPItem * item = selected.front(); first_select = item->getRepr(); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 95d5c7edc..5c708cf9a 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -691,7 +691,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 - for(std::vector::const_iterator x=selected.begin();x!=selected.end();x++){ + for(std::vector::const_iterator x = selected.begin(); x != selected.end(); x++){ Glib::ustring selected_id; selected_id += "--id="; selected_id += (*x)->getId(); diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 64abd6c4d..3a29b3dc0 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -83,8 +83,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (std::vector::const_iterator i=selectedItemList.begin();i!=selectedItemList.end();i++) { - SPItem *item = static_cast(*i); + for (std::vector::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); i++) { + SPItem *item = *i; Inkscape::XML::Node *node = reinterpret_cast(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) { diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 257cac161..b80e5ddbb 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -70,7 +70,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View for(std::vector::iterator item = items.begin(); item != items.end(); ++item) { - SPItem * spitem = static_cast(*item); + SPItem * spitem = *item; std::vector new_items(steps); Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index f614ec745..b30c8892e 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -295,7 +295,7 @@ static void sp_group_render(SPGroup *group, CairoRenderContext *ctx) TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); std::vector l(group->childList(false)); - for(std::vector::const_iterator x=l.begin();x!=l.end();x++){ + for(std::vector::const_iterator x = l.begin(); x!= l.end(); x++){ SPObject *o = reinterpret_cast(*x); SPItem *item = dynamic_cast(o); if (item) { diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index a5eb7de60..65162af22 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -133,7 +133,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie for(std::vector::iterator item = items.begin(); item != items.end(); ++item) { - SPItem * spitem = static_cast(*item); + SPItem * spitem = *item; Inkscape::XML::Node * node = spitem->getRepr(); SPCSSAttr * css = sp_repr_css_attr(node, "style"); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 440c6b822..60d606a02 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -195,7 +195,7 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = (selected.front())->getRepr(); + first_select = selected[0]->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index a2de264ab..831a8d030 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -229,8 +229,8 @@ LaTeXTextRenderer::writePostamble() void LaTeXTextRenderer::sp_group_render(SPGroup *group) { std::vector l = (group->childList(false)); - for(std::vector::const_iterator x=l.begin();x!=l.end();x++){ - SPObject *o = reinterpret_cast(*x); + for(std::vector::const_iterator x = l.begin(); x != l.end(); x++){ + SPObject *o = *x; SPItem *item = dynamic_cast(o); if (item) { renderItem(item); diff --git a/src/file.cpp b/src/file.cpp index f33e284b2..07e41c550 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1088,7 +1088,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) target_parent->appendChild(obj_copy); Inkscape::GC::release(obj_copy); - pasted_objects.push_back((obj_copy)); + pasted_objects.push_back(obj_copy); } // Change the selection to the freshly pasted objects diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index c89cf6220..9298a1ffc 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -23,9 +23,9 @@ #include "filter-chemistry.h" #include "filter-enums.h" + #include "filters/blend.h" #include "filters/gaussian-blur.h" -#include "selection.h" #include "sp-filter.h" #include "sp-filter-reference.h" #include "svg/css-ostringstream.h" diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index a72423bbb..b59b38475 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1571,8 +1571,8 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa Inkscape::Selection *selection = desktop->getSelection(); const std::vector list=selection->itemList(); - for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { - sp_item_gradient_invert_vector_color(SP_ITEM(*i), fill_or_stroke); + for (std::vector::const_iterator i = list.begin(); i != list.end(); i++) { + sp_item_gradient_invert_vector_color(*i, fill_or_stroke); } // we did an undoable action @@ -1596,9 +1596,9 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) 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(); - for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { - sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_FILL); - sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_STROKE); + 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 525fc074f..5a49435d4 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2083,8 +2083,8 @@ void GrDrag::updateDraggers() g_return_if_fail(this->selection != NULL); std::vector list = this->selection->itemList(); - for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector::const_iterator i = list.begin(); i != list.end(); i++) { + SPItem *item = *i; SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { @@ -2152,8 +2152,8 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); std::vector list = this->selection->itemList(); - for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector::const_iterator i = list.begin(); i != list.end(); i++) { + SPItem *item = *i; SPStyle *style = item->style; @@ -2296,8 +2296,8 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); std::vector list = this->selection->itemList(); - for (std::vector::const_iterator i=list.begin();i!=list.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector::const_iterator i = list.begin(); i != list.end(); i++) { + SPItem *item = *i; Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { // Remember the edges of the bbox and the center axis diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 4d590173a..40994347c 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -89,8 +89,8 @@ struct CheckProgress : TestConvergence { * not connectors in filtered */ void filterConnectors(std::vector const &items, list &filtered) { - for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + for(std::vector::const_iterator i = items.begin();i !=items.end(); i++){ + SPItem *item = *i; if(!isConnector(item)) { filtered.push_back(item); } diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 6cdf09180..7a1d391a3 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -506,7 +506,7 @@ static void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &paths, std::vector &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + for ( std::vector::const_iterator iter = item_list.begin(); iter != item_list.end(); iter++) { SPObject *subitem = static_cast(*iter); if (SP_IS_LPE_ITEM(subitem)) { collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); diff --git a/src/main.cpp b/src/main.cpp index c62b9cd25..062edcb98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1174,9 +1174,6 @@ static int sp_process_file_list(GSList *fl) sp_item_list_to_curves(items, selected, to_select); - items.clear(); - selected.clear(); - to_select.clear(); } if(sp_export_id) { doc->ensureUpToDate(); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 830c3c1db..f9c189c58 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -238,8 +238,8 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); if (old_pref2) { std::vector rotationSource=_snapmanager->getRotationCenterSource(); - for ( std::vector::const_iterator itemlist=rotationSource.begin();itemlist!=rotationSource.end();itemlist++) { - if ((*i).item == reinterpret_cast(*itemlist)) { + for ( std::vector::const_iterator itemlist = rotationSource.begin(); itemlist != rotationSource.end(); itemlist++) { + if ((*i).item == *itemlist) { // don't snap to this item's rotation center _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); break; diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index ae1e0064f..53ad96596 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -45,16 +45,10 @@ using Inkscape::DocumentUndo; -inline bool less_than_objects(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(first->getRepr(), - second->getRepr())<0; -} - inline bool less_than_items(SPItem const *first, SPItem const *second) { return sp_repr_compare_position(first->getRepr(), - second->getRepr())<0; + second->getRepr())>0; } void @@ -77,21 +71,19 @@ sp_selected_path_combine(SPDesktop *desktop) items = sp_degroup_list (items); // descend into any groups in selection std::vector to_paths; - for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++) { - SPItem *item = (SPItem *) (*i); - if (!dynamic_cast(item) && !dynamic_cast(item)) { - to_paths.push_back(item); + for (std::vector::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) { + if (!dynamic_cast(*i) && !dynamic_cast(*i)) { + to_paths.push_back(*i); } } std::vector converted; bool did = sp_item_list_to_curves(to_paths, items, converted); - to_paths.clear(); - for (std::vector::const_iterator i=converted.begin();i!=converted.end();i++) - items.push_back((SPItem*)doc->getObjectByRepr((Inkscape::XML::Node*)(*i))); + for (std::vector::const_iterator i = converted.begin(); i != converted.end(); i++) + items.push_back((SPItem*)doc->getObjectByRepr(*i)); items = sp_degroup_list (items); // converting to path may have added more groups, descend again - sort(items.begin(),items.end(),less_than_objects); + sort(items.begin(),items.end(),less_than_items); assert(!items.empty()); // cannot be NULL because of list length check at top of function // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one @@ -109,9 +101,9 @@ sp_selected_path_combine(SPDesktop *desktop) selection->clear(); } - for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ + for (std::vector::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++){ - SPItem *item = (SPItem *) (*i); + SPItem *item = *i; SPPath *path = dynamic_cast(item); if (!path) { continue; @@ -212,9 +204,9 @@ sp_selected_path_break_apart(SPDesktop *desktop) bool did = false; std::vector itemlist(selection->itemList()); - for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + for (std::vector::const_iterator i = itemlist.begin(); i != itemlist.end(); i++){ - SPItem *item = (SPItem *) (*i); + SPItem *item = *i; SPPath *path = dynamic_cast(item); if (!path) { @@ -277,11 +269,10 @@ sp_selected_path_break_apart(SPDesktop *desktop) if (l == list) repr->setAttribute("id", id); - reprs.push_back(repr); + reprs.insert(reprs.begin(),repr); Inkscape::GC::release(repr); } - //reverse selection->setReprList(reprs); g_slist_free(list); @@ -323,11 +314,8 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b did = sp_item_list_to_curves(items, selected, to_select); - items.clear(); selection->setReprList(to_select); selection->addList(selected); - to_select.clear(); - selected.clear(); if (interactive && desktop) { desktop->clearWaitingCursor(); @@ -367,9 +355,9 @@ sp_item_list_to_curves(const std::vector &items, std::vector& { bool did = false; - for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i = items.begin(); i != items.end(); i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; g_assert(item != NULL); SPDocument *document = item->document; @@ -400,7 +388,7 @@ sp_item_list_to_curves(const std::vector &items, std::vector& Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); if (repr) { - to_select.push_back(repr); + to_select.insert(to_select.begin(),repr); did = true; selected.erase(find(selected.begin(),selected.end(),item)); } @@ -418,9 +406,6 @@ sp_item_list_to_curves(const std::vector &items, std::vector& if (sp_item_list_to_curves(item_list, item_selected, item_to_select)) did = true; - item_list.clear(); - item_to_select.clear(); - item_selected.clear(); continue; } @@ -472,7 +457,7 @@ sp_item_list_to_curves(const std::vector &items, std::vector& /* Buglet: We don't re-add the (new version of the) object to the selection of any other * desktops where it was previously selected. */ - to_select.push_back(repr); + to_select.insert(to_select.begin(),repr); Inkscape::GC::release(repr); } @@ -628,7 +613,7 @@ sp_selected_path_reverse(SPDesktop *desktop) bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); - for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector::const_iterator i = items.begin(); i != items.end(); i++){ SPPath *path = dynamic_cast(static_cast(*i)); if (!path) { diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 7cb1694e3..01ce2c47e 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -49,7 +49,7 @@ void removeoverlap(std::vector const &items, double const xGap, double it != selected.end(); ++it) { - SPItem* item=static_cast(*it); + SPItem* item = *it; using Geom::X; using Geom::Y; Geom::OptRect item_box((item)->desktopVisualBounds()); if (item_box) { diff --git a/src/selcue.cpp b/src/selcue.cpp index f48378cdc..76eae3fa8 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -104,8 +104,8 @@ void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) int bcount = 0; std::vector ll=_selection->itemList(); - for (std::vector::const_iterator l=ll.begin();l!=ll.end();l++) { - SPItem *item = static_cast(*l); + for (std::vector::const_iterator l = ll.begin(); l != ll.end(); l++) { + SPItem *item = *l; SPCanvasItem* box = _item_bboxes[bcount ++]; if (box) { @@ -147,8 +147,8 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); std::vector ll=_selection->itemList(); - for (std::vector::const_iterator l=ll.begin();l!=ll.end();l++) { - SPItem *item = static_cast(*l); + for (std::vector::const_iterator l = ll.begin(); l != ll.end(); l++) { + SPItem *item = *l; Geom::OptRect const b = (prefs_bbox == 0) ? item->desktopVisualBounds() : item->desktopGeometricBounds(); @@ -201,7 +201,7 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - std::vector ll=_selection->itemList(); + std::vector ll = _selection->itemList(); for (std::vector::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast(*l); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 3c91392cf..d6f8b8a37 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -283,8 +283,8 @@ void SelectionHelper::fixSelection(SPDesktop *dt) std::vector const selList = selection->itemList(); - for( std::vector::const_reverse_iterator i=selList.rbegin();i!=selList.rend();i++ ) { - SPItem *item = dynamic_cast(static_cast(*i)); + for( std::vector::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++ ) { + SPItem *item = *i; if( item && !dt->isLayer(item) && (!item->isLocked())) @@ -303,7 +303,7 @@ void SelectionHelper::fixSelection(SPDesktop *dt) * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', * then prepends the copy to 'clip'. */ -static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector &clip, Inkscape::XML::Document* xml_doc) { Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -319,31 +319,32 @@ static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t copy->setAttribute("transform", affinestr); g_free(affinestr); - clip.insert(clip.begin(),dynamic_cast(copy)); + clip.insert(clip.begin(),copy); } -static void sp_selection_copy_impl(std::vector const &items, std::vector &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_impl(std::vector const &items, std::vector &clip, Inkscape::XML::Document* xml_doc) { // Sort items: std::vector sorted_items(items); sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); // Copy item reprs: - for (std::vector::const_iterator i = sorted_items.begin();i!=sorted_items.end();i++) { - SPItem *item = dynamic_cast(SP_OBJECT(*i)); + for (std::vector::const_iterator i = sorted_items.begin(); i != sorted_items.end(); i++) { + SPItem *item = *i; if (item) { sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); } else { g_assert_not_reached(); } } - std::vector tmp(clip); - for(int i=0;i tmp(clip); + for(int i=0;i sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector &clip) +static std::vector sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector &clip) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); @@ -352,8 +353,8 @@ static std::vector sp_selection_paste_impl(SPDocument *doc std::vector copied; // add objects to document - for (std::vector::const_iterator l=clip.begin();l!=clip.end();l++) { - Inkscape::XML::Node *repr = dynamic_cast(*l); + for (std::vector::const_iterator l = clip.begin(); l != clip.end(); l++) { + Inkscape::XML::Node *repr = *l; Inkscape::XML::Node *copy = repr->duplicate(xml_doc); // premultiply the item transform by the accumulated parent transform in the paste layer @@ -379,11 +380,11 @@ static std::vector sp_selection_paste_impl(SPDocument *doc static void sp_selection_delete_impl(std::vector const &items, bool propagate = true, bool propagate_descendants = true) { - for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { - sp_object_ref(static_cast(*i), NULL); + for (std::vector::const_iterator i = items.begin(); i != items.end(); i++) { + sp_object_ref(*i, NULL); } - for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { - SPItem *item = static_cast(*i); + for (std::vector::const_iterator i = items.begin(); i != items.end(); i++) { + SPItem *item = *i; item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, NULL); } @@ -413,7 +414,6 @@ void sp_selection_delete(SPDesktop *desktop) std::vector selected(selection->itemList()); selection->clear(); sp_selection_delete_impl(selected); - selected.clear(); desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); /* a tool may have set up private information in it's selection context @@ -440,10 +440,6 @@ static void add_ids_recursive(std::vector &ids, SPObject *obj) } } } -/* -bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b){ - return sp_repr_compare_position(dynamic_cast(a),dynamic_cast(b)); -}*/ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) { @@ -476,8 +472,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value"); const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true); - for(std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *old_repr = (*i); + for(std::vector::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ + Inkscape::XML::Node *old_repr = *i; Inkscape::XML::Node *parent = old_repr->parent(); Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); @@ -558,7 +554,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) g_return_if_fail(group != NULL); std::vector items = sp_item_group_item_list(group); - for(unsigned int i=0;i(items[i])->deleteObject(); } @@ -644,7 +640,6 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i } } - all_items.clear(); break; } case PREFS_SELECTION_LAYER_RECURSIVE: { @@ -653,17 +648,14 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i break; } default: { - std::vector x; - items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); + std::vector x; + items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } } selection->setList(items); - if (!items.empty()) { - items.clear(); - } } void sp_edit_select_all(SPDesktop *desktop) @@ -694,8 +686,8 @@ static void sp_selection_group_impl(std::vector p, Inkscap gint topmost = (dynamic_cast(p.back()))->position(); Inkscape::XML::Node *topmost_parent = (dynamic_cast(p.back()))->parent(); - for(std::vector::const_iterator i=p.begin();i!=p.end();i++){ - Inkscape::XML::Node *current = (*i); + for(std::vector::const_iterator i = p.begin(); i != p.end(); i++){ + Inkscape::XML::Node *current = *i; if (current->parent() == topmost_parent) { Inkscape::XML::Node *spnew = current->duplicate(xml_doc); @@ -704,7 +696,7 @@ static void sp_selection_group_impl(std::vector p, Inkscap Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - std::vector temp_clip; + std::vector temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -817,7 +809,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. GSList *clones_to_unlink = NULL; - for (std::vector::const_iterator item = items.begin(); item!=items.end(); item++) { + for (std::vector::const_iterator item = items.begin(); item != items.end(); item++) { SPUse *use = dynamic_cast(static_cast(*item)); SPItem *original = use; @@ -838,13 +830,13 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) for (GSList *item = clones_to_unlink; item; item = item->next) { SPUse *use = static_cast(item->data); std::vector::iterator items_node = std::find(items.begin(),items.end(), item->data); - (*items_node) = use->unlink(); + *items_node = use->unlink(); } g_slist_free(clones_to_unlink); // do the actual work - for (std::vector::iterator item = items.begin(); item!=items.end(); item++) { - SPItem *obj = static_cast(*item); + for (std::vector::iterator item = items.begin(); item != items.end(); item++) { + SPItem *obj = *item; // ungroup only the groups marked earlier if (g_slist_find(groups, *item) != NULL) { @@ -852,7 +844,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) sp_item_group_ungroup(dynamic_cast(obj), children, false); // add the items resulting from ungrouping to the selection new_select.insert(new_select.end(),children.begin(),children.end()); - (*item) = NULL; // zero out the original pointer, which is no longer valid + *item = NULL; // zero out the original pointer, which is no longer valid } else { // if not a group, keep in the selection new_select.push_back(*item); @@ -860,8 +852,6 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } selection->addList(new_select); - new_select.clear(); - items.clear(); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); @@ -886,7 +876,6 @@ sp_degroup_list(std::vector &items) members.clear(); } } - items.clear(); if (has_groups) { // recurse if we unwrapped a group - it may have contained others out = sp_degroup_list(out); @@ -903,13 +892,13 @@ sp_item_list_common_parent_group(std::vector const items) if (items.empty()) { return NULL; } - SPObject *parent = SP_OBJECT(items.front())->parent; + SPObject *parent = SP_OBJECT(items[0])->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.front())continue; + if((*item)==items[0])continue; if (SP_OBJECT(*item)->parent != parent) { return NULL; } @@ -992,10 +981,7 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) } } } - } else { - rev.clear(); } - DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, //TRANSLATORS: "Raise" means "to raise an object" in the undo history C_("Undo action", "Raise")); @@ -1078,8 +1064,6 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) } } } - } else { - rev.clear(); } DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, @@ -1261,7 +1245,7 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) } std::vector list=selection->itemList(); for ( std::vector::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { - SPItem *item = reinterpret_cast(*itemlist); + SPItem *item = *itemlist; sp_selection_remove_livepatheffect_impl(item); @@ -1318,7 +1302,7 @@ void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool a void sp_selection_change_layer_maintain_clones(std::vector const &items,SPObject *where) { for (std::vector::const_iterator i = items.begin(); i != items.end(); i++) { - SPItem *item = dynamic_cast(SP_OBJECT(*i)); + SPItem *item = *i; if (item) { SPItem *oldparent = dynamic_cast(item->parent); SPItem *newparent = dynamic_cast(where); @@ -1346,7 +1330,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); if (next) { sp_selection_change_layer_maintain_clones(items,next); - std::vector temp_clip; + std::vector temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); sp_selection_delete_impl(items, false, false); next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers @@ -1358,8 +1342,6 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) no_more = true; } selection->setReprList(copied); - copied.clear(); - if (!temp_clip.empty()) temp_clip.clear(); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT, @@ -1373,7 +1355,6 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above.")); } - items.clear(); } void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) @@ -1392,7 +1373,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); if (next) { sp_selection_change_layer_maintain_clones(items,next); - std::vector temp_clip; + std::vector temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers @@ -1404,8 +1385,6 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) no_more = true; } selection->setReprList( copied); - copied.clear(); - if (!temp_clip.empty()) temp_clip.clear(); if (next) dt->setCurrentLayer(next); if ( !suppressDone ) { DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV, @@ -1434,7 +1413,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) if (moveto) { sp_selection_change_layer_maintain_clones(items,moveto); - std::vector temp_clip; + std::vector temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs sp_selection_delete_impl(items, false, false); std::vector copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); @@ -1483,7 +1462,7 @@ selection_contains_both_clone_and_original(Inkscape::Selection *selection) bool clone_with_original = false; std::vector items = selection->itemList(); for (std::vector::const_iterator l=items.begin();l!=items.end() ;l++) { - SPItem *item = dynamic_cast(static_cast(*l)); + SPItem *item = *l; if (item) { clone_with_original |= selection_contains_original(item, selection); if (clone_with_original) @@ -1528,7 +1507,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } std::vector items = selection->itemList(); for (std::vector::const_iterator l=items.begin();l!=items.end() ;l++) { - SPItem *item = dynamic_cast(static_cast(*l)); + SPItem *item = *l; if( dynamic_cast(item) ) { // An SVG element cannot have a transform. We could change 'x' and 'y' in response @@ -1800,7 +1779,7 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) std::vector items = selection->itemList(); 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 = dynamic_cast(static_cast(*l)); + SPItem *item = *l; if (item) { sp_item_rotate_rel(item, rot_90); } else { @@ -1863,7 +1842,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea Inkscape::Selection *selection = desktop->getSelection(); std::vector items = selection->itemList(); for (std::vector::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { - SPItem *sel = dynamic_cast(static_cast(*sel_iter)); + SPItem *sel = *sel_iter; std::vector matches = all_list; if (fill && stroke && style) { matches = sp_get_same_style(sel, matches); @@ -1911,7 +1890,7 @@ void sp_select_same_object_type(SPDesktop *desktop) std::vector items=selection->itemList(); for (std::vector::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { - SPItem *sel = dynamic_cast(static_cast(*sel_iter)); + SPItem *sel = *sel_iter; if (sel) { matches = sp_get_same_object_type(sel, matches); } else { @@ -1938,7 +1917,7 @@ std::vector sp_get_same_fill_or_stroke_color(SPItem *sel, std::vectorstyle->fill) : &(sel->style->stroke); for (std::vector::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { - SPItem *iter = dynamic_cast(static_cast(*i)); + SPItem *iter = *i; if (iter) { SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); match = false; @@ -2033,7 +2012,7 @@ std::vector sp_get_same_object_type(SPItem *sel, std::vector & std::vector matches; for (std::vector::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; if (item && item_type_match(sel, item) && !item->cloned) { matches.push_back(item); } @@ -2091,7 +2070,6 @@ std::vector sp_get_same_style(SPItem *sel, std::vector &src, S if (sel_style_for_width) { match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed); } - objects.clear(); } } match_g = match_g && match; @@ -2579,7 +2557,7 @@ void sp_selection_clone(SPDesktop *desktop) std::vector newsel; - for(std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ + for(std::vector::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ Inkscape::XML::Node *sel_repr = *i; Inkscape::XML::Node *parent = sel_repr->parent(); @@ -2631,7 +2609,7 @@ sp_selection_relink(SPDesktop *desktop) bool relinked = false; std::vector items=selection->itemList(); for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = static_cast(*i); + SPItem *item = *i; if (dynamic_cast(item)) { item->getRepr()->setAttribute("xlink:href", newref); @@ -2669,7 +2647,7 @@ sp_selection_unlink(SPDesktop *desktop) bool unlinked = false; std::vector items=selection->itemList(); for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ - SPItem *item = static_cast(*i); + SPItem *item = *i; if (dynamic_cast(item)) { SPObject *tspan = sp_tref_convert_to_tspan(item); @@ -2922,7 +2900,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items.front())->parent; + SPObject *parent = SP_OBJECT(items[0])->parent; Geom::Affine parent_transform; { @@ -2976,7 +2954,7 @@ static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { if (group && !dynamic_cast(item) && !wholegroups) { std::vector items=sp_item_group_item_list(group); for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ - sp_selection_to_guides_recursive(static_cast(*i), wholegroups); + sp_selection_to_guides_recursive(*i, wholegroups); } } else { item->convert_to_guides(); @@ -3007,7 +2985,7 @@ void sp_selection_to_guides(SPDesktop *desktop) // Therefore: first convert all, then delete all. for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ - sp_selection_to_guides_recursive(static_cast(*i), wholegroups); + sp_selection_to_guides_recursive(*i, wholegroups); } if (deleteitems) { @@ -3060,7 +3038,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) std::vector items(selection->list()); // Keep track of parent, this is where will be inserted. - Inkscape::XML::Node *the_first_repr = reinterpret_cast( items.front() )->getRepr(); + Inkscape::XML::Node *the_first_repr = items[0]->getRepr(); Inkscape::XML::Node *the_parent_repr = the_first_repr->parent(); // Find out if we have a single group @@ -3068,7 +3046,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) SPGroup *the_group = NULL; Geom::Affine transform; if( items.size() == 1 ) { - SPObject *object = reinterpret_cast( items.front() ); + SPObject *object = items[0]; the_group = dynamic_cast(object); if ( the_group ) { single_group = true; @@ -3125,7 +3103,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) // Move selected items to new for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ - Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); + Inkscape::XML::Node *repr = (*i)->getRepr(); repr->parent()->removeChild(repr); symbol_repr->addChild(repr,NULL); } @@ -3197,7 +3175,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) // In converting a symbol back to a group we strip out the inserted group (or any other // group that only adds a transform to the symbol content). if( children.size() == 1 ) { - SPObject *object = reinterpret_cast( children.front() ); + SPObject *object = children[0]; if ( dynamic_cast( object ) ) { if( object->getAttribute("style") == NULL || object->getAttribute("class") == NULL ) { @@ -3209,7 +3187,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) } for (std::vector::const_iterator i=children.begin();i!=children.end();i++){ - Inkscape::XML::Node *repr = SP_OBJECT(*i)->getRepr(); + Inkscape::XML::Node *repr = (*i)->getRepr(); repr->parent()->removeChild(repr); group->addChild(repr,NULL); } @@ -3274,7 +3252,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) sort(items.begin(),items.end(),sp_object_compare_position); // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items.front())->parent; + SPObject *parent = SP_OBJECT(items[0])->parent; Geom::Affine parent_transform; @@ -3288,7 +3266,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) } // remember the position of the first item - gint pos = SP_OBJECT(items.front())->getRepr()->position(); + gint pos = SP_OBJECT(items[0])->getRepr()->position(); // create a list of duplicates std::vector repr_copies; @@ -3446,7 +3424,7 @@ void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring for (std::vector::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){ gchar const *dpi_string; - Inkscape::XML::Node * repr = (*i); + Inkscape::XML::Node *repr = *i; if (filename_search) { const gchar* tmp = repr->attribute("inkscape:export-filename"); @@ -3546,7 +3524,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Create the filename. gchar *const basename = g_strdup_printf("%s-%s-%u.png", document->getName(), - SP_OBJECT(items.front())->getRepr()->attribute("id"), + SP_OBJECT(items[0])->getRepr()->attribute("id"), current); // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, // digits, and a few other chars, with "_" @@ -3755,7 +3733,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - std::vector temp_clip; + std::vector temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -3896,7 +3874,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ } } else if (!topmost) { // topmost item is used as a mask, which is applied to other items in a selection - Inkscape::XML::Node *dup = SP_OBJECT(items.front())->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup = SP_OBJECT(items[0])->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); if (remove_original) { @@ -4060,7 +4038,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (remove_original) { // remember referenced mask/clippath, so orphaned masks can be moved back to document - SPItem *item = reinterpret_cast(*i); + SPItem *item = *i; Inkscape::URIReference *uri_ref = NULL; if (apply_clip_path) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index ce0b5d3da..8bcab664b 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -19,7 +19,6 @@ #include <2geom/forward.h> #include "sp-item.h" -#include "selection.h" class SPCSSAttr; class SPDesktop; diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index d86cfa700..441ce6ea6 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -47,7 +47,7 @@ char* collect_terms (const std::vector &items) bool first = true; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *item = dynamic_cast(reinterpret_cast(*iter)); + SPItem *item = *iter; if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -66,7 +66,7 @@ static int count_terms (const std::vector &items) GSList *check = NULL; int count=0; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *item = dynamic_cast(reinterpret_cast(*iter)); + SPItem *item = *iter; if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -83,7 +83,7 @@ static int count_filtered (const std::vector &items) { int count=0; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *item = dynamic_cast(reinterpret_cast((*iter))); + SPItem *item = *iter; if (item) { count += item->isFiltered(); } @@ -127,7 +127,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); } else { - SPItem *item = dynamic_cast(reinterpret_cast(items.front())); + SPItem *item = items[0]; g_assert(item != NULL); SPObject *layer = selection->layers()->layerForObject(item); SPObject *root = selection->layers()->currentRoot(); diff --git a/src/selection.cpp b/src/selection.cpp index fd3b6abae..19e78512b 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -130,7 +130,7 @@ void Selection::_invalidateCachedLists() { void Selection::_clear() { _invalidateCachedLists(); while (!_objs.empty()) { - SPObject *obj=reinterpret_cast(_objs.front()); + SPObject *obj=_objs.front(); _remove(obj); } } @@ -254,7 +254,7 @@ void Selection::addList(std::vector const &list) { _invalidateCachedLists(); for ( std::vector::const_iterator iter=list.begin();iter!=list.end();iter++ ) { - SPObject *obj = reinterpret_cast(*iter); + SPObject *obj = *iter; if (includes(obj)) continue; _add (obj); } @@ -297,7 +297,7 @@ std::vector const &Selection::itemList() { } for ( std::list::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { - SPObject *obj=reinterpret_cast(*iter); + SPObject *obj=*iter; if (SP_IS_ITEM(obj)) { _items.push_back(SP_ITEM(obj)); } @@ -342,7 +342,7 @@ std::list const Selection::box3DList(Persp3D *persp) { SPObject *Selection::single() { if ( _objs.size() == 1 ) { - return reinterpret_cast(_objs.front()); + return _objs.front(); } else { return NULL; } @@ -351,7 +351,7 @@ SPObject *Selection::single() { SPItem *Selection::singleItem() { std::vector const items=itemList(); if ( items.size()==1) { - return reinterpret_cast(items.front()); + return items[0]; } else { return NULL; } @@ -447,7 +447,7 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const boost::optional Selection::center() const { std::vector const items = const_cast(this)->itemList(); if (!items.empty()) { - SPItem *first = reinterpret_cast(items.back()); // from the first item in selection + SPItem *first = items.back(); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly return first->getCenter(); } @@ -467,7 +467,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center std::vector p; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *this_item = SP_ITEM(*iter); + SPItem *this_item = *iter; this_item->getSnappoints(p, &snapprefs_dummy); //Include the transformation origin for snapping @@ -482,7 +482,7 @@ std::vector Selection::getSnapPoints(SnapPreferenc void Selection::_removeObjectDescendants(SPObject *obj) { for ( std::list::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { - SPObject *sel_obj=reinterpret_cast(*iter); + SPObject *sel_obj= *iter; SPObject *parent = sel_obj->parent; while (parent) { if ( parent == obj ) { diff --git a/src/selection.h b/src/selection.h index 71be6dd6b..9eada3eed 100644 --- a/src/selection.h +++ b/src/selection.h @@ -40,14 +40,6 @@ class Node; } } -/*template -const GSList* std_list_to_GS_list(const std::list list) const -{ - gpointer l=NULL; - for(auto x:list){ - - } -}*/ namespace Inkscape { diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 0a428edf2..61d8a1ab1 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -434,8 +434,7 @@ void Inkscape::SelTrans::ungrab() for (int i = 0; i < 4; i++) sp_canvas_item_hide(_l[i]); } - - if (!_stamp_cache.empty()) { + if(!_stamp_cache.empty()){ _stamp_cache.clear(); } @@ -494,7 +493,7 @@ void Inkscape::SelTrans::ungrab() // we were dragging center; update reprs and commit undoable action std::vector items=_desktop->selection->itemList(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = SP_ITEM(*iter); + SPItem *it = *iter; it->updateRepr(); } DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, @@ -535,7 +534,7 @@ void Inkscape::SelTrans::stamp() } for(std::vector::const_iterator x=l.begin();x!=l.end();x++) { - SPItem *original_item = SP_ITEM(*x); + SPItem *original_item = *x; Inkscape::XML::Node *original_repr = original_item->getRepr(); // remember the position of the item @@ -713,7 +712,7 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa // Unset the center position for all selected items std::vector items=_desktop->selection->itemList(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = SP_ITEM(*iter); + SPItem *it = *iter; it->unsetCenter(); it->updateRepr(); _center_is_set = false; // center has changed diff --git a/src/snap.cpp b/src/snap.cpp index c711874d7..31cafafcd 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1055,7 +1055,7 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, Inkscape::Selection *sel = _desktop->selection; std::vector const items = sel->itemList(); for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { - _items_to_ignore.push_back(static_cast(*i)); + _items_to_ignore.push_back(*i); } } diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index d09699f41..1e478d1c9 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -52,7 +52,7 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p double child_pos = 0.0; std::vector g = sp_item_group_item_list(group); for (std::vector::const_iterator i = g.begin();i!=g.end();i++) { - SPItem* child_item = SP_ITEM(*i); + SPItem* child_item = *i; try_get_intersect_point_with_item_recursive(conn_pv, child_item, item_transform * child_item->transform, child_pos); if (intersect_pos < child_pos) diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index 76843fd28..74d29a05c 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -48,7 +48,7 @@ void SPDefs::update(SPCtx *ctx, guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; std::vector l(this->childList(true)); for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT(*i); + SPObject *child = *i; if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); } diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index 93a979287..5386a4373 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -246,7 +246,7 @@ void SPFilter::update(SPCtx *ctx, guint flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; std::vector l(this->childList(true, SPObject::ActionUpdate)); for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT (*i); + SPObject *child = *i; if( SP_IS_FILTER_PRIMITIVE( child ) ) { child->updateDisplay(ctx, childflags); } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index d58676235..620c0b70f 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -173,7 +173,7 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; std::vector l=this->childList(true, SPObject::ActionUpdate); for(std::vector ::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT (*i); + SPObject *child = *i; if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { SPItem *item = dynamic_cast(child); @@ -217,7 +217,7 @@ void SPGroup::modified(guint flags) { std::vector l=this->childList(true); for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *child = SP_OBJECT (*i); + SPObject *child = *i; if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); @@ -289,9 +289,9 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox Geom::OptRect bbox; // TODO CPPIFY: replace this const_cast later - std::vector l=const_cast(this)->childList(false, SPObject::ActionBBox); + std::vector l = const_cast(this)->childList(false, SPObject::ActionBBox); for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *o = SP_OBJECT (*i); + SPObject *o = *i; SPItem *item = dynamic_cast(o); if (item && !item->isHidden()) { Geom::Affine const ct(item->transform * transform); @@ -305,7 +305,7 @@ 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 = SP_OBJECT (*i); + SPObject *o = *i; SPItem *item = dynamic_cast(o); if (item) { item->invoke_print(ctx); @@ -359,7 +359,7 @@ Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int k void SPGroup::hide (unsigned int key) { std::vector l=this->childList(false, SPObject::ActionShow); for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *o = SP_OBJECT (*i); + SPObject *o = *i; SPItem *item = dynamic_cast(o); if (item) { @@ -799,7 +799,7 @@ void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem * Inkscape::DrawingItem *ac = NULL; std::vector l=this->childList(false, SPObject::ActionShow); for(std::vector::const_iterator i=l.begin();i!=l.end();i++){ - SPObject *o = SP_OBJECT (*i); + SPObject *o = *i; SPItem * child = dynamic_cast(o); if (child) { ac = child->invoke_show (drawing, key, flags); diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 2258c2133..fc0b6382f 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -15,7 +15,6 @@ #include #include "sp-lpe-item.h" -#include "selection.h"//SelContainer #define SP_GROUP(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_GROUP(obj) (dynamic_cast((SPObject*)obj) != NULL) diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 5bb80bd39..9618c5484 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -453,7 +453,7 @@ const gchar *generate_marker(std::vector &reprs, Geom::Rec SPObject *mark_object = document->getObjectById(mark_id); for (std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *node = (*i); + Inkscape::XML::Node *node = *i; SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-object.h b/src/sp-object.h index 8651258bd..df773fea7 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -47,8 +47,6 @@ class SPObject; #define SP_OBJECT_WRITE_ALL (1 << 2) #define SP_OBJECT_WRITE_NO_CHILDREN (1 << 3) - - #include #include #include @@ -64,8 +62,6 @@ class SPCSSAttr; class SPStyle; typedef struct _GSList GSList; - - namespace Inkscape { namespace XML { class Node; diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 33d66c5dc..b3aeec7bd 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -427,7 +427,7 @@ const gchar *pattern_tile(const std::vector &reprs, Geom:: SPObject *pat_object = document->getObjectById(pat_id); for (std::vector::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); + Inkscape::XML::Node *node = *i; SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index 2c9427df8..f252438a4 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -112,7 +112,7 @@ void SPSwitch::_reevaluate(bool /*add_to_drawing*/) { std::vector item_list = _childList(false, SPObject::ActionShow); for ( std::vector::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) { - SPObject *o = SP_OBJECT (*iter); + SPObject *o = *iter; if ( !SP_IS_ITEM (o) ) { continue; } @@ -147,7 +147,7 @@ void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem std::vector l = this->_childList(false, SPObject::ActionShow); for ( std::vector::const_reverse_iterator iter=l.rbegin();iter!=l.rend();iter++) { - SPObject *o = SP_OBJECT (*iter); + SPObject *o = *iter; if (SP_IS_ITEM (o)) { SPItem * child = SP_ITEM(o); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 6e47dfff3..bc09802f0 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -60,11 +60,6 @@ using Inkscape::DocumentUndo; bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); -//SHOULD DISAPPEAR -bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b){ - return sp_repr_compare_position(dynamic_cast(a),dynamic_cast(b)); -} - 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_do_offset(SPDesktop *desktop, bool expand, double prefOffset); void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating); @@ -405,7 +400,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // otherwise bail out for (std::vector::const_iterator l = il.begin(); l != il.end(); l++) { - SPItem *item = SP_ITEM(*l); + 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.")); @@ -428,7 +423,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SP_LPE_ITEM(*l)->removeAllPathEffects(true); } - SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast(il.front())->getRepr(), "style"); + SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast(il[0])->getRepr(), "style"); gchar const *val = sp_repr_css_property(css, "fill-rule", NULL); if (val && strcmp(val, "nonzero") == 0) { origWind[curOrig]= fill_nonZero; @@ -438,7 +433,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool origWind[curOrig]= fill_nonZero; } - originaux[curOrig] = Path_for_item((SPItem *) (*l), true, true); + originaux[curOrig] = Path_for_item(*l, true, true); if (originaux[curOrig] == NULL || originaux[curOrig]->descr_cmd.size() <= 1) { for (int i = curOrig; i >= 0; i--) delete originaux[i]; @@ -475,7 +470,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool curOrig = 1; for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ - if(*l==il.front())continue; + if(*l==il[0])continue; originaux[curOrig]->ConvertWithBackData(0.1); originaux[curOrig]->Fill(theShape, curOrig); @@ -685,7 +680,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SPObject *source; if ( bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { if (reverseOrderForOp) { - source = SP_OBJECT(il.front()); + source = SP_OBJECT(il[0]); } else { source = SP_OBJECT(il.back()); } @@ -1159,7 +1154,7 @@ sp_selected_path_outline(SPDesktop *desktop) bool did = false; std::vector il(selection->itemList()); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ - SPItem *item = SP_ITEM(*l); + SPItem *item = *l; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) continue; @@ -1771,7 +1766,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) bool did = false; std::vector il(selection->itemList()); for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ - SPItem *item = SP_ITEM(*l); + SPItem *item = *l; SPCurve *curve = NULL; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) @@ -2143,7 +2138,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, desktop->setWaitingCursor(); for (std::vector::const_iterator l = items.begin(); l != items.end(); l++){ - SPItem *item = SP_ITEM(*l); + SPItem *item = *l; if (!(SP_IS_GROUP(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item))) continue; diff --git a/src/splivarot.h b/src/splivarot.h index 79b9b98a6..ba314399f 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -10,7 +10,6 @@ #include <2geom/forward.h> #include <2geom/path.h> #include "livarot/Path.h" -#include "sp-object.h"//kill it class SPCurve; class SPDesktop; @@ -19,7 +18,7 @@ class SPItem; namespace Inkscape { class Selection; } -bool sp_repr_compare_position_obj(SPObject* &a,SPObject* &b);//kill it with fire + // boolean operations // work on the current selection // selection has 2 contain exactly 2 items diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 33192a330..eadab90dd 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -46,7 +46,7 @@ flowtext_in_selection(Inkscape::Selection *selection) std::vector items = selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_FLOWTEXT(*i)) - return ((SPItem *) *i); + return *i; } return NULL; } @@ -57,7 +57,7 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) std::vector items = selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) - return ((SPItem *) *i); + return *i; } return NULL; } @@ -68,7 +68,7 @@ shape_in_selection(Inkscape::Selection *selection) std::vector items = selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_SHAPE(*i)) - return ((SPItem *) *i); + return *i; } return NULL; } @@ -402,7 +402,7 @@ text_unflow () continue; } - SPItem *flowtext = SP_ITEM(*i); + SPItem *flowtext = *i; // we discard transform when unflowing, but we must preserve expansion which is visible as // font size multiplier @@ -482,7 +482,7 @@ flowtext_to_text() std::vector items(selection->itemList()); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = (SPItem *) *i; + SPItem *item = *i; if (!SP_IS_FLOWTEXT(item)) continue; diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 88210dc0b..050e223eb 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -69,7 +69,7 @@ void te_update_layout_now_recursive(SPItem *item) if (SP_IS_GROUP(item)) { std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); for(std::vector::const_iterator i=item_list.begin();i!=item_list.end();i++){ - SPItem* list_item = static_cast(*i); + SPItem* list_item = *i; te_update_layout_now_recursive(list_item); } } else if (SP_IS_TEXT(item)) diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 4853f127c..91c230920 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -80,7 +80,7 @@ SPImage *Tracer::getSelectedSPImage() { continue; } - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; items.insert(items.begin(), item); } std::vector::iterator iter; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 52bc24f5f..a38a52371 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -525,7 +525,7 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a if (separately) { std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); if ( obj_size ) { @@ -581,7 +581,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) sp_selected_to_lpeitems(desktop); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; _applyPathEffect(item, effectstack); } @@ -664,7 +664,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // copy the defs used by all items std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (item) { _copyUsedDefs(item); } else { @@ -677,7 +677,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); for(std::vector::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (item) { Inkscape::XML::Node *obj = item->getRepr(); Inkscape::XML::Node *obj_copy = _copyNode(obj, _doc, _root); @@ -706,7 +706,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // copy style for Paste Style action if (!sorted_items.empty()) { - SPObject *object = static_cast(sorted_items.front()); + SPObject *object = static_cast(sorted_items[0]); SPItem *item = dynamic_cast(object); if (item) { SPCSSAttr *style = take_style_from_item(item); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 34dbd150b..1ee72dcbc 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -151,7 +151,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it) { - SPItem* item=static_cast (*it); + SPItem* item= *it; desktop->getDocument()->ensureUpToDate(); if (!sel_as_group) b = (item)->desktopPreferredBounds(); @@ -264,8 +264,8 @@ private : std::vector< BBoxSort > sorted; for (std::vector::iterator it(selected.begin()); it != selected.end(); - ++it) - {SPItem *item=static_cast(*it); + ++it){ + SPItem *item = *it; Geom::OptRect bbox = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (bbox) { sorted.push_back(BBoxSort(item, *bbox, _orientation, _kBegin, _kEnd)); @@ -570,19 +570,19 @@ private : sort(selected.begin(),selected.end(),sort_compare); } std::vector::iterator it(selected.begin()); - SPItem* item=static_cast(*it); - Geom::Point p1 = (item)->getCenter(); + SPItem* item = *it; + Geom::Point p1 = item->getCenter(); for (++it ;it != selected.end(); ++it) { - item=static_cast(*it); - Geom::Point p2 = (item)->getCenter(); + item = *it; + Geom::Point p2 = item->getCenter(); Geom::Point delta = p1 - p2; - sp_item_move_rel((item),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + sp_item_move_rel(item,Geom::Translate(delta[Geom::X],delta[Geom::Y] )); p1 = p2; } - Geom::Point p2 = static_cast(selected.front())->getCenter(); + Geom::Point p2 = selected.front()->getCenter(); Geom::Point delta = p1 - p2; - sp_item_move_rel(static_cast(selected.front()),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + sp_item_move_rel(selected.front(),Geom::Translate(delta[Geom::X],delta[Geom::Y] )); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -675,7 +675,7 @@ private : it != selected.end(); ++it) { - SPItem* item=static_cast(*it); + SPItem* item = *it; desktop->getDocument()->ensureUpToDate(); Geom::OptRect item_box = !prefs_bbox ? (item)->desktopVisualBounds() : (item)->desktopGeometricBounds(); if (item_box) { @@ -761,7 +761,7 @@ private : it != selected.end(); ++it) { - SPItem* item=static_cast(*it); + SPItem* item = *it; if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional pt = layout->baselineAnchorPoint(); @@ -805,7 +805,7 @@ private : it != selected.end(); ++it) { - SPItem* item=static_cast(*it); + SPItem* item = *it; if (SP_IS_TEXT (item) || SP_IS_FLOWTEXT (item)) { Inkscape::Text::Layout const *layout = te_get_layout(item); boost::optional pt = layout->baselineAnchorPoint(); diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 32eed088c..ca3971019 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -819,7 +819,7 @@ void Export::onAreaToggled () const gchar * id = "object"; const std::vector reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); for(std::vector::const_iterator i=reprlst.begin(); reprlst.end() != i; i++) { - Inkscape::XML::Node * repr = (*i); + Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { id = repr->attribute("id"); break; @@ -1026,7 +1026,7 @@ void Export::onExport () std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ - SPItem *item = reinterpret_cast(*i); + SPItem *item = *i; prog_dlg->set_data("current", GINT_TO_POINTER(n)); prog_dlg->set_data("total", GINT_TO_POINTER(num)); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index a6312140d..45c8ce68a 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -690,7 +690,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->reprList()[0]; if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; @@ -1547,7 +1547,7 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri std::vector itemlist=sel->itemList(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { - SPItem * item = SP_ITEM(*i); + SPItem * item = *i; SPStyle *style = item->style; g_assert(style != NULL); @@ -1655,7 +1655,7 @@ void FilterEffectsDialog::FilterModifier::remove_filter() if (!SP_IS_ITEM(*i)) { continue; } - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (!item->style) { continue; } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 283d79c0d..dde040036 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -857,7 +857,7 @@ void Find::onAction() Inkscape::Selection *selection = desktop->getSelection(); selection->clear(); selection->setList(n); - SPObject *obj = reinterpret_cast(n.front()); + SPObject *obj = reinterpret_cast(n[0]); SPItem *item = dynamic_cast(obj); g_assert(item != NULL); scroll_to_show_item(desktop, item); diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 61f4463ae..4bcb900b6 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -16,7 +16,6 @@ # include #endif -#include "selection.h" #include "ui/widget/panel.h" #include "ui/widget/button.h" #include "ui/widget/entry.h" diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index e9a0fc017..1be87d180 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -159,7 +159,7 @@ std::vector FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli allList = get_all_items(x, doc->getRoot(), desktop, false, false, true, y); for(std::vector::const_iterator i = allList.begin();i!=allList.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; Glib::ustring family = ""; diff --git a/src/ui/dialog/font-substitution.h b/src/ui/dialog/font-substitution.h index cdb4e22b4..0818d778c 100644 --- a/src/ui/dialog/font-substitution.h +++ b/src/ui/dialog/font-substitution.h @@ -13,7 +13,8 @@ #define INKSCAPE_UI_FONT_SUBSTITUTION_H #include -#include "selection.h" + +class SPItem; class SPDocument; namespace Inkscape { diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index fa469dc4b..7ca277ea2 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -581,7 +581,7 @@ void GlyphsPanel::insertText() std::vector itemlist=targetDesktop->selection->itemList(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { - textItem = SP_ITEM(*i); + textItem = *i; break; } } diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 10498b0f9..8bd130c2e 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -172,7 +172,7 @@ void GridArrangeTab::arrange() const std::vector items = selection ? selection->itemList() : std::vector(); cnt=0; for(std::vector::const_iterator i = items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; Geom::OptRect b = item->documentVisualBounds(); if (!b) { continue; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 6ad3d61ac..e9ee7802d 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -368,7 +368,7 @@ void IconPreviewPanel::refreshPreview() std::vector const items = sel->itemList(); for(std::vector::const_iterator i=items.begin();!target && i!=items.end();i++){ - SPItem* item = SP_ITEM( *i); + SPItem* item = *i; gchar const *id = item->getId(); if ( id ) { targetId = id; diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 6e09be2ba..781c6ef93 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -479,7 +479,7 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { SPItem *item = NULL; std::vector const items = sel->itemList(); for(std::vector::const_iterator i=items.begin(); i!=items.end();i++){ - item = reinterpret_cast(*i); + item = *i; if (setOpacity) { _setCompositingValues(item); diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index a68e73caf..af1386e27 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -308,7 +308,7 @@ void PolarArrangeTab::arrange() { if(arrangeOnEllipse) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if(arrangeOnFirstEllipse) { @@ -375,7 +375,7 @@ void PolarArrangeTab::arrange() int i = 0; for(std::vector::const_iterator it=tmp.begin();it!=tmp.end();it++) { - SPItem *item = SP_ITEM(*it); + SPItem *item = *it; // Ignore the reference ellipse if any if(item != referenceEllipse) diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index b677711ff..5fab9fcfc 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -355,7 +355,7 @@ void TagsPanel::_objectsSelected( Selection *sel ) { std::vector tmp=sel->list(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; _store->foreach(sigc::bind( sigc::mem_fun(*this, &TagsPanel::_checkForSelected), obj)); } _selectedConnection.unblock(); diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 1c1cf5937..9c4790379 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -422,7 +422,7 @@ SPItem *TextEdit::getSelectedTextItem (void) for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) - return SP_ITEM (*i); + return *i; } return NULL; diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 0f81a7e58..459e6e937 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -655,7 +655,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - Geom::Affine current (SP_ITEM(selection->itemList().front())->transform); // take from the first item in selection + Geom::Affine current (selection->itemList()[0]->transform); // take from the first item in selection Geom::Affine new_displayed = current; @@ -750,8 +750,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - SPItem* item=static_cast(*it); - Geom::OptRect bbox = (item)->desktopPreferredBounds(); + SPItem* item = *it; + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(item, *bbox, Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } @@ -775,8 +775,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) it != selected.end(); ++it) { - SPItem* item=static_cast(*it); - Geom::OptRect bbox = (item)->desktopPreferredBounds(); + SPItem* item = *it; + Geom::OptRect bbox = item->desktopPreferredBounds(); if (bbox) { sorted.push_back(BBoxSort(item, *bbox, Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } @@ -818,7 +818,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) if (prefs->getBool("/dialogs/transformation/applyseparately")) { std::vector tmp=selection->itemList(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; Geom::OptRect bbox_pref = item->desktopPreferredBounds(); Geom::OptRect bbox_geom = item->desktopGeometricBounds(); if (bbox_pref && bbox_geom) { @@ -882,7 +882,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) if (prefs->getBool("/dialogs/transformation/applyseparately")) { std::vector tmp=selection->itemList(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } } else { @@ -902,7 +902,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) if (prefs->getBool("/dialogs/transformation/applyseparately")) { std::vector items=selection->itemList(); for(std::vector::const_iterator i = items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (!_units_skew.isAbsolute()) { // percentage double skewX = _scalar_skew_horizontal.getValue("%"); @@ -1004,7 +1004,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) if (_check_replace_matrix.get_active()) { std::vector tmp=selection->itemList(); for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; item->set_item_transform(displayed); SP_OBJECT(item)->updateRepr(); } @@ -1155,7 +1155,7 @@ void Transformation::onReplaceMatrixToggled() double f = _scalar_transform_f.getValue(); Geom::Affine displayed (a, b, c, d, e, f); - Geom::Affine current = SP_ITEM(selection->itemList().front())->transform; // take from the first item in selection + Geom::Affine current = selection->itemList()[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 193dff33c..760d19e89 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -2077,7 +2077,7 @@ void ContextMenu::ImageEdit(void) std::vector itemlist=_desktop->selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - Inkscape::XML::Node *ir = SP_ITEM(*i)->getRepr(); + Inkscape::XML::Node *ir = (*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); if (strncmp (href,"file:",5) == 0) { diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 9c6eead16..f48e572df 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1318,7 +1318,7 @@ void cc_selection_set_avoid(bool const set_avoid) std::vector l = selection->itemList(); for(std::vector::const_iterator i=l.begin();i!=l.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; char const *value = (set_avoid) ? "true" : NULL; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index b61a108f0..adbbb2bd3 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -692,8 +692,8 @@ void EraserTool::set_to_accumulated() { if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + for (std::vector::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); i++){ + SPItem *item = *i; if ( eraserMode ) { Geom::OptRect bbox = item->visualBounds(); @@ -712,7 +712,7 @@ void EraserTool::set_to_accumulated() { // If the item was not completely erased, track the new remainder. std::vector nowSel(selection->itemList()); for (std::vector::const_iterator i2 = nowSel.begin();i2!=nowSel.end();i2++) { - remainingItems.push_back(SP_ITEM(*i2)); + remainingItems.push_back(*i2); } } } else { @@ -722,11 +722,11 @@ void EraserTool::set_to_accumulated() { } } else { for (std::vector ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - sp_object_ref( SP_ITEM(*i), 0 ); + sp_object_ref( *i, 0 ); } for (std::vector::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; item->deleteObject(true); sp_object_unref(item); workDone = true; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 6f7b220ed..21ad18c26 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -506,7 +506,7 @@ bool GradientTool::root_handler(GdkEvent* event) { } else { std::vector items=selection->itemList(); for (std::vector::const_iterator i = items.begin();i!=items.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -890,12 +890,6 @@ bool GradientTool::root_handler(GdkEvent* event) { return ret; } -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(((SPItem*)first)->getRepr(), - ((SPItem*)second)->getRepr())<0; -} - static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -931,14 +925,14 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); if (type == SP_GRADIENT_TYPE_LINEAR) { - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_END, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_LG_END, 0, pt, fill_or_stroke, true, false); } else if (type == SP_GRADIENT_TYPE_RADIAL) { - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); - sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_R1, 0, pt, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); + sp_item_gradient_set_coords (*i, POINT_RG_R1, 0, pt, fill_or_stroke, true, false); } SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } @@ -949,7 +943,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 (SP_ITEM(selection->itemList().front()), + ec->_grdrag->grabKnot (selection->itemList()[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); diff --git a/src/ui/tools/gradient-tool.h b/src/ui/tools/gradient-tool.h index 786aed372..6fe3bca9f 100644 --- a/src/ui/tools/gradient-tool.h +++ b/src/ui/tools/gradient-tool.h @@ -18,7 +18,6 @@ #include #include #include "ui/tools/tool-base.h" -class SPObject;//kill it #define SP_GRADIENT_CONTEXT(obj) (dynamic_cast((Inkscape::UI::Tools::ToolBase*)obj)) #define SP_IS_GRADIENT_CONTEXT(obj) (dynamic_cast((const Inkscape::UI::Tools::ToolBase*)obj) != NULL) @@ -26,12 +25,12 @@ class SPObject;//kill it namespace Inkscape { namespace UI { namespace Tools { -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second);//kill it class GradientTool : public ToolBase { public: GradientTool(); virtual ~GradientTool(); + Geom::Point origin; bool cursor_addnode; diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 2b44639c8..5295a16c0 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -444,7 +444,7 @@ bool MeasureTool::root_handler(GdkEvent* event) { std::vector items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector intersection_times; for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; if (SP_IS_SHAPE(item)) { calculate_intersections(desktop, item, lineseg, SP_SHAPE(item)->getCurve(), intersection_times); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 0a34e4855..c8e032089 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -48,7 +48,6 @@ // Mesh specific #include "ui/tools/mesh-tool.h" -#include "ui/tools/gradient-tool.h"//not needed #include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" @@ -478,12 +477,12 @@ 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, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. std::vector items=selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -932,12 +931,6 @@ bool MeshTool::root_handler(GdkEvent* event) { return ret; } -/* -int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) -{ - return sp_repr_compare_position(((SPItem*)first)->getRepr(), - ((SPItem*)second)->getRepr())<0; -}*/ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 25cbf76a4..fbc1a9e6c 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -481,7 +481,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = static_cast(selection->itemList().front()); + SPItem *clicked_item = selection->itemList()[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 ac41f3a34..d92d326e0 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -553,13 +553,13 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point std::vector const items(selection->itemList()); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; g_assert(item != NULL); sp_object_ref(item); } for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; g_assert(item != NULL); if (is_transform_modes(tc->mode)) { @@ -574,7 +574,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; g_assert(item != NULL); sp_object_unref(item); } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 6f7764506..8c5e4215e 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -1089,7 +1089,7 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point std::vector items=selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { diff --git a/src/unclump.cpp b/src/unclump.cpp index 29608befa..81c958937 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -173,7 +173,7 @@ static double unclump_average (SPItem *item, std::list &others) int n = 0; double sum = 0; for (std::list::const_iterator i = others.begin(); i != others.end();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -197,7 +197,7 @@ static SPItem *unclump_closest (SPItem *item, std::list &others) SPItem *closest = NULL; for (std::list::const_iterator i = others.begin(); i != others.end();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -220,7 +220,7 @@ static SPItem *unclump_farest (SPItem *item, std::list &others) double max = -HUGE_VAL; SPItem *farest = NULL; for (std::list::const_iterator i = others.begin(); i != others.end();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -260,7 +260,7 @@ unclump_remove_behind (SPItem *item, SPItem *closest, std::list &rest) std::vector out; for (std::list::const_reverse_iterator i = rest.rbegin(); i != rest.rend();i++) { - SPItem *other = SP_ITEM (*i); + SPItem *other = *i; if (other == item) continue; @@ -337,7 +337,7 @@ unclump (std::vector &items) wh_cache.clear(); for (std::vector::const_iterator i = items.begin(); i != items.end();i++) { // for each original/clone x: - SPItem *item = SP_ITEM (*i); + SPItem *item = *i; std::list nei; diff --git a/src/unclump.h b/src/unclump.h index 407628f3a..461e99d0b 100644 --- a/src/unclump.h +++ b/src/unclump.h @@ -12,7 +12,6 @@ #define SEEN_DIALOGS_UNCLUMP_H typedef struct _GSList GSList; -#include "selection.h" void unclump(std::vector &items); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 770845f38..46f895c06 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -258,7 +258,7 @@ VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list sel_boxes; std::vector itemlist=sel->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box && this->hasBox(box)) { sel_boxes.push_back(box); @@ -398,7 +398,7 @@ VPDragger::VPsOfSelectedBoxes() { Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); std::vector itemlist=sel->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box) { vp = this->findVPWithBox(box); @@ -581,7 +581,7 @@ VPDrag::updateDraggers () std::vector itemlist=this->selection->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box) { VanishingPoint vp; @@ -614,7 +614,7 @@ VPDrag::updateLines () std::vector itemlist=this->selection->itemList(); for (std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { - SPItem *item = static_cast(*i); + SPItem *item = *i; SPBox3D *box = dynamic_cast(item); if (box) { this->drawLinesForFace (box, Proj::X); diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index cb24bb8aa..71418e238 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -99,7 +99,7 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v bool modmade = false; std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); @@ -165,7 +165,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) if ( ege_select_one_action_get_active(act) != 0 ) { std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", "true"); @@ -176,7 +176,7 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } else { std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("sodipodi:open", NULL); @@ -266,7 +266,7 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 49cf8e6fd..1c99f283d 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -99,7 +99,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl bool modmade = false; std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-type", @@ -146,7 +146,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) bool modmade = false; std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { item->setAttribute( "inkscape:connector-curvature", diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index dbb84efba..7d5a89cf5 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -591,11 +591,11 @@ void FillNStroke::updateFromPaint() if ( gr && createSwatch ) { gr->setSwatch(); } - sp_item_set_gradient(SP_ITEM(*i), + sp_item_set_gradient(*i, gr, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); } else { - sp_item_set_gradient(SP_ITEM(*i), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); + sp_item_set_gradient(*i, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); } } } else { @@ -608,7 +608,7 @@ void FillNStroke::updateFromPaint() sp_repr_css_change_recursive(reinterpret_cast(*i)->getRepr(), css, "style"); } - SPGradient *gr = sp_item_set_gradient(SP_ITEM(*i), vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); + SPGradient *gr = sp_item_set_gradient(*i, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); psel->pushAttrsToGradient( gr ); } } diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 5aa654a80..6743dd23a 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -118,7 +118,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(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - gr_apply_gradient_to_item(SP_ITEM(*i), gr, initialType, initialMode, initialMode); + gr_apply_gradient_to_item(*i, gr, initialType, initialMode, initialMode); } } @@ -220,7 +220,7 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version + SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -288,7 +288,7 @@ void gr_read_selection( Inkscape::Selection *selection, // If no selected dragger, read desktop selection std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 682c61e77..49fc7b67c 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -89,7 +89,7 @@ void ms_read_selection( Inkscape::Selection *selection, std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { @@ -216,7 +216,7 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version + SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 65078af01..2b07dd3b9 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -246,9 +246,9 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - if (SP_IS_RECT(reinterpret_cast(*i))) { + if (SP_IS_RECT(*i)) { n_selected++; - item = reinterpret_cast(*i); + item = *i; repr = item->getRepr(); } } diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 6f967e8ae..751a60f06 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -81,7 +81,7 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr bool modmade = false; std::vector itemlist=desktop->getSelection()->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_SPIRAL(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double( repr, namespaced_name, @@ -197,7 +197,7 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_SPIRAL(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 1946dee6e..96005d7df 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -85,7 +85,7 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu Inkscape::Selection *selection = desktop->getSelection(); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_int(repr,"sodipodi:sides", @@ -130,7 +130,7 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl Inkscape::Selection *selection = desktop->getSelection(); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -187,7 +187,7 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); repr->setAttribute("inkscape:flatsided", flat ? "true" : "false" ); @@ -226,7 +226,7 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg Inkscape::Selection *selection = desktop->getSelection(); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:rounded", @@ -266,7 +266,7 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl Inkscape::Selection *selection = desktop->getSelection(); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); sp_repr_set_svg_double(repr, "inkscape:randomized", @@ -369,7 +369,7 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_STAR(item)) { n_selected++; repr = item->getRepr(); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 65390819b..c05ef93e7 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -477,7 +477,7 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, Inkscape::Selection *selection = spw->desktop->getSelection(); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - SPItem *item = SP_ITEM(*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 continue; } @@ -902,7 +902,7 @@ StrokeStyle::updateLine() return; std::vector const objects = sel->itemList(); - SPObject * const object = SP_OBJECT(objects.front()); + SPObject * const object = SP_OBJECT(objects[0]); SPStyle * const style = object->style; /* Markers */ @@ -1155,6 +1155,7 @@ StrokeStyle::updateAllMarkers(std::vector const &objects) for(std::vector::const_iterator i=objects.begin();i!=objects.end();i++){ if (!SP_IS_TEXT (*i)) { all_texts = false; + break; } } @@ -1166,7 +1167,7 @@ StrokeStyle::updateAllMarkers(std::vector const &objects) // We show markers of the first object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = SP_OBJECT(objects.front()); + SPObject *object = SP_OBJECT(objects[0]); for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { // For all three marker types, diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 71915377e..6b0fb34e6 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -368,8 +368,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) Inkscape::Selection *selection = desktop->getSelection(); std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ - if (SP_IS_TEXT(SP_ITEM(*i))) { - SPItem *item = SP_ITEM(*i); + if (SP_IS_TEXT(*i)) { + SPItem *item = *i; unsigned writing_mode = item->style->writing_mode.value; // below, variable names suggest horizontal move, but we check the writing direction @@ -868,7 +868,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ 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; - if( SP_IS_FLOWTEXT(SP_ITEM(*i))) { + if( SP_IS_FLOWTEXT(*i)) { isFlow = true; // std::cout << " Found flowed text" << std::endl; break; @@ -1160,7 +1160,7 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p std::vector x,y; std::vector allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y); for(std::vector::const_reverse_iterator i=allList.rbegin();i!=allList.rend();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; SPStyle *style = item->style; if (style) { -- cgit v1.2.3 From 9bdc157f705ca61516e599cb416580283d21ec35 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Fri, 27 Feb 2015 04:21:48 +0100 Subject: more cast cleanup (bzr r13922.1.11) --- src/desktop-style.cpp | 29 ++++++++++---------- src/extension/implementation/implementation.cpp | 2 +- src/extension/internal/cairo-renderer.cpp | 3 +-- src/extension/internal/latex-text-renderer.cpp | 3 +-- src/live_effects/lpe-knot.cpp | 2 +- src/path-chemistry.cpp | 4 +-- src/selcue.cpp | 2 +- src/selection-chemistry.cpp | 36 ++++++++++++------------- src/selection.cpp | 2 +- src/seltrans.cpp | 2 +- src/sp-item-group.cpp | 4 +-- src/sp-lpe-item.cpp | 10 +++---- src/splivarot.cpp | 10 +++---- src/text-chemistry.cpp | 8 +++--- src/ui/clipboard.cpp | 2 +- src/ui/dialog/filter-effects-dialog.cpp | 2 +- src/ui/dialog/find.cpp | 18 ++++++------- src/ui/dialog/grid-arrange-tab.cpp | 2 +- src/ui/dialog/tags.cpp | 2 +- src/ui/dialog/text-edit.cpp | 2 +- src/ui/tools/gradient-tool.cpp | 2 +- src/ui/tools/mesh-tool.cpp | 6 ++--- src/ui/tools/node-tool.cpp | 2 +- src/ui/widget/style-subject.cpp | 4 +-- src/widgets/fill-style.cpp | 8 +++--- src/widgets/rect-toolbar.cpp | 2 +- src/widgets/stroke-style.cpp | 4 +-- src/widgets/text-toolbar.cpp | 2 +- 28 files changed, 86 insertions(+), 89 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 82f66dcdf..afdc3064a 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -197,7 +197,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write std::vector const itemlist = desktop->selection->itemList(); for (std::vector::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { /* last used styles for 3D box faces are stored separately */ - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; Box3DSide *side = dynamic_cast(obj); if (side) { const char * descr = box3d_side_axes_string(side); @@ -448,7 +448,6 @@ stroke_average_width (const std::vector &objects) bool notstroked = true; int n_notstroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); SPItem *item = *i; if (!item) { continue; @@ -515,7 +514,7 @@ objects_query_fillstroke (const std::vector &objects, SPStyle *style_re bool same_color = true; for (std::vector::const_iterator i = objects.begin(); i!= objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -699,7 +698,7 @@ objects_query_opacity (const std::vector &objects, SPStyle *style_res) for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -755,7 +754,7 @@ objects_query_strokewidth (const std::vector &objects, SPStyle *style_r int n_stroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -829,7 +828,7 @@ objects_query_miterlimit (const std::vector &objects, SPStyle *style_re bool same_ml = true; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; } @@ -888,7 +887,7 @@ objects_query_strokecap (const std::vector &objects, SPStyle *style_res int n_stroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; } @@ -942,7 +941,7 @@ objects_query_strokejoin (const std::vector &objects, SPStyle *style_re int n_stroked = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!dynamic_cast(obj)) { continue; } @@ -1005,7 +1004,7 @@ objects_query_fontnumbers (const std::vector &objects, SPStyle *style_r int no_size = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!isTextualItem(obj)) { continue; @@ -1124,7 +1123,7 @@ objects_query_fontstyle (const std::vector &objects, SPStyle *style_res int texts = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!isTextualItem(obj)) { continue; @@ -1193,7 +1192,7 @@ objects_query_baselines (const std::vector &objects, SPStyle *style_res int texts = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!isTextualItem(obj)) { continue; @@ -1281,7 +1280,7 @@ objects_query_fontfamily (const std::vector &objects, SPStyle *style_re style_res->font_family.set = FALSE; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1337,7 +1336,7 @@ objects_query_fontspecification (const std::vector &objects, SPStyle *s style_res->font_specification.set = FALSE; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; // std::cout << " " << reinterpret_cast(i->data)->getId() << std::endl; if (!isTextualItem(obj)) { @@ -1395,7 +1394,7 @@ objects_query_blend (const std::vector &objects, SPStyle *style_res) guint items = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } @@ -1485,7 +1484,7 @@ objects_query_blur (const std::vector &objects, SPStyle *style_res) guint items = 0; for (std::vector::const_iterator i = objects.begin(); i != objects.end(); i++) { - SPObject *obj = reinterpret_cast(*i); + SPObject *obj = *i; if (!obj) { continue; } diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 11c494b18..717ca3310 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -51,7 +51,7 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { - const SPItem * item = selected.front(); + const SPItem * item = selected[0]; first_select = item->getRepr(); } diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index b30c8892e..a2cea014b 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -296,8 +296,7 @@ static void sp_group_render(SPGroup *group, CairoRenderContext *ctx) std::vector l(group->childList(false)); for(std::vector::const_iterator x = l.begin(); x!= l.end(); x++){ - SPObject *o = reinterpret_cast(*x); - SPItem *item = dynamic_cast(o); + SPItem *item = static_cast(*x); if (item) { renderer->renderItem(ctx, item); } diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp index 831a8d030..ab863f8b1 100644 --- a/src/extension/internal/latex-text-renderer.cpp +++ b/src/extension/internal/latex-text-renderer.cpp @@ -230,8 +230,7 @@ void LaTeXTextRenderer::sp_group_render(SPGroup *group) { std::vector l = (group->childList(false)); for(std::vector::const_iterator x = l.begin(); x != l.end(); x++){ - SPObject *o = *x; - SPItem *item = dynamic_cast(o); + SPItem *item = static_cast(*x); if (item) { renderItem(item); } diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 7a1d391a3..6ec4b969b 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -507,7 +507,7 @@ collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector &paths, if (SP_IS_GROUP(lpeitem)) { std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( std::vector::const_iterator iter = item_list.begin(); iter != item_list.end(); iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; if (SP_IS_LPE_ITEM(subitem)) { collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); } diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 53ad96596..b128535bc 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -48,7 +48,7 @@ using Inkscape::DocumentUndo; inline bool less_than_items(SPItem const *first, SPItem const *second) { return sp_repr_compare_position(first->getRepr(), - second->getRepr())>0; + second->getRepr())<0; } void @@ -615,7 +615,7 @@ sp_selected_path_reverse(SPDesktop *desktop) for (std::vector::const_iterator i = items.begin(); i != items.end(); i++){ - SPPath *path = dynamic_cast(static_cast(*i)); + SPPath *path = dynamic_cast(*i); if (!path) { continue; } diff --git a/src/selcue.cpp b/src/selcue.cpp index 76eae3fa8..c73219b7d 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -203,7 +203,7 @@ void Inkscape::SelCue::_newTextBaselines() std::vector ll = _selection->itemList(); for (std::vector::const_iterator l=ll.begin();l!=ll.end();l++) { - SPItem *item = static_cast(*l); + SPItem *item = *l; SPCanvasItem* baseline_point = NULL; if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index d6f8b8a37..0100e1040 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -555,7 +555,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) std::vector items = sp_item_group_item_list(group); for(unsigned int i = 0; i < items.size(); i++){ - reinterpret_cast(items[i])->deleteObject(); + items[i]->deleteObject(); } DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, @@ -627,7 +627,7 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i std::vector all_items = sp_item_group_item_list(dynamic_cast(dt->currentLayer())); for (std::vector::const_reverse_iterator i=all_items.rbegin();i!=all_items.rend();i++) { - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; if (item && (!onlysensitive || !item->isLocked())) { if (!onlyvisible || !dt->itemIsHidden(item)) { @@ -683,8 +683,8 @@ static void sp_selection_group_impl(std::vector p, Inkscap sort(p.begin(),p.end(),sp_repr_compare_position); // Remember the position and parent of the topmost object. - gint topmost = (dynamic_cast(p.back()))->position(); - Inkscape::XML::Node *topmost_parent = (dynamic_cast(p.back()))->parent(); + gint topmost = p.back()->position(); + Inkscape::XML::Node *topmost_parent = p.back()->parent(); for(std::vector::const_iterator i = p.begin(); i != p.end(); i++){ Inkscape::XML::Node *current = *i; @@ -791,7 +791,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) std::vector new_select; GSList *groups = NULL; for (std::vector::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { - SPItem *obj = static_cast(*item); + SPItem *obj = *item; if (dynamic_cast(obj)) { groups = g_slist_prepend(groups, obj); } @@ -810,7 +810,7 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) // in the items list. GSList *clones_to_unlink = NULL; for (std::vector::const_iterator item = items.begin(); item != items.end(); item++) { - SPUse *use = dynamic_cast(static_cast(*item)); + SPUse *use = dynamic_cast(*item); SPItem *original = use; while (dynamic_cast(original)) { @@ -864,7 +864,7 @@ sp_degroup_list(std::vector &items) std::vector out; bool has_groups = false; for (std::vector::const_iterator item=items.begin();item!=items.end();item++) { - SPGroup *group = dynamic_cast(static_cast(*item)); + SPGroup *group = dynamic_cast(*item); if (!group) { out.push_back(*item); } else { @@ -915,7 +915,7 @@ enclose_items(std::vector const &items) Geom::OptRect r; for (std::vector::const_iterator i = items.begin();i!=items.end();i++) { - r.unionWith(static_cast(*i)->desktopVisualBounds()); + r.unionWith((*i)->desktopVisualBounds()); } return r; } @@ -963,7 +963,7 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) // Iterate over all objects in the selection (starting from top). if (selected) { for (std::vector::const_iterator item=rev.begin();item!=rev.end();item++) { - SPObject *child = reinterpret_cast(*item); + SPObject *child = *item; // for each selected object, find the next sibling for (SPObject *newref = child->next; newref; newref = newref->next) { // if the sibling is an item AND overlaps our selection, @@ -1042,7 +1042,7 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) // Iterate over all objects in the selection (starting from top). if (selected) { for (std::vector::const_reverse_iterator item=rev.rbegin();item!=rev.rend();item++) { - SPObject *child = reinterpret_cast(*item); + SPObject *child = *item; // for each selected object, find the prev sibling for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { // if the sibling is an item AND overlaps our selection, @@ -2053,7 +2053,7 @@ std::vector sp_get_same_style(SPItem *sel, std::vector &src, S } bool match_g; for (std::vector::const_iterator i=src.begin();i!=src.end();i++) { - SPItem *iter = dynamic_cast(static_cast(*i)); + SPItem *iter = *i; if (iter) { match_g=true; SPStyle *iter_style = iter->style; @@ -2356,7 +2356,7 @@ SPItem *next_item_from_list(SPDesktop *desktop, std::vector const items { SPObject *current=root; for(std::vector::const_iterator i = items.begin();i!=items.end();i++) { - SPItem *item = dynamic_cast(static_cast(*i)); + SPItem *item = *i; if ( root->isAncestorOf(item) && ( !only_in_viewport || desktop->isWithinViewport(item) ) ) { @@ -2925,7 +2925,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) // Delete objects so that their clones don't get alerted; // the objects will be restored inside the marker element. for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPObject *item = reinterpret_cast(*i); + SPObject *item = *i; item->deleteObject(false); } } @@ -3280,7 +3280,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) if (apply) { // delete objects so that their clones don't get alerted; this object will be restored shortly for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPObject *item = reinterpret_cast(*i); + SPObject *item = *i; item->deleteObject(false); } } @@ -3354,7 +3354,7 @@ void sp_selection_untile(SPDesktop *desktop) std::vector items(selection->itemList()); for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ - SPItem *item = static_cast(*i); + SPItem *item = *i; SPStyle *style = item->style; @@ -3864,7 +3864,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); - SPObject *item = reinterpret_cast(*i); + SPObject *item = *i; if (remove_original) { items_to_delete = g_slist_prepend(items_to_delete, item); } @@ -3878,7 +3878,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ mask_items = g_slist_prepend(mask_items, dup); if (remove_original) { - SPObject *item = reinterpret_cast(items.front()); + SPObject *item = items.front(); items_to_delete = g_slist_prepend(items_to_delete, item); } @@ -4055,7 +4055,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { SP_OBJECT(*i)->getRepr()->setAttribute(attributeName, "none"); - SPGroup *group = dynamic_cast(static_cast(*i)); + SPGroup *group = dynamic_cast(*i); if (ungroup_masked && group) { // if we had previously enclosed masked object in group, // add it to list so we can ungroup it later diff --git a/src/selection.cpp b/src/selection.cpp index 19e78512b..7e8190237 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -309,7 +309,7 @@ std::vector const &Selection::reprList() { if (!_reprs.empty()) { return _reprs; } std::vector list = itemList(); for ( std::vector::const_iterator iter=list.begin();iter!=list.end();iter++ ) { - SPObject *obj=reinterpret_cast(*iter); + SPObject *obj = *iter; _reprs.push_back(obj->getRepr()); } return _reprs; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 61d8a1ab1..bfb8d53f1 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -271,7 +271,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s std::vector items=_desktop->selection->itemList(); for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPItem *it = reinterpret_cast(sp_object_ref(SP_ITEM(*iter), NULL)); + SPItem *it = static_cast(sp_object_ref(*iter, NULL)); _items.push_back(it); _items_const.push_back(it); _items_affines.push_back(it->i2dt_affine()); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 620c0b70f..64ad9ff43 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -818,7 +818,7 @@ void SPGroup::update_patheffect(bool write) { std::vector const item_list = sp_item_group_item_list(this); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; SPLPEItem *lpeItem = dynamic_cast(subitem); if (lpeItem) { @@ -846,7 +846,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) std::vector const item_list = sp_item_group_item_list(group); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; SPGroup *subGroup = dynamic_cast(subitem); if (subGroup) { diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 1f4704e22..6228f3692 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -355,7 +355,7 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) if (SP_IS_GROUP(lpeitem)) { std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem)); } @@ -389,7 +389,7 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) } std::vector item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); } @@ -682,7 +682,7 @@ SPLPEItem::apply_to_clippath(SPItem *item) if(SP_IS_GROUP(item)){ std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; apply_to_clippath(SP_ITEM(subitem)); } } @@ -734,7 +734,7 @@ SPLPEItem::apply_to_mask(SPItem *item) if(SP_IS_GROUP(item)){ std::vector item_list = sp_item_group_item_list(SP_GROUP(item)); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; apply_to_mask(SP_ITEM(subitem)); } } @@ -748,7 +748,7 @@ SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item) } std::vector item_list = sp_item_group_item_list(SP_GROUP(group)); for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { - SPObject *subitem = static_cast(*iter); + SPObject *subitem = *iter; if (SP_IS_GROUP(subitem)) { apply_to_clip_or_mask_group(SP_ITEM(subitem), item); } else if (SP_IS_SHAPE(subitem)) { diff --git a/src/splivarot.cpp b/src/splivarot.cpp index bc09802f0..c668199c0 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -667,7 +667,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool { // only one command, presumably a moveto: it isn't a path for (std::vector::const_iterator l = il.begin(); l != il.end(); l++){ - SP_OBJECT(*l)->deleteObject(); + (*l)->deleteObject(); } DocumentUndo::done(doc, SP_VERB_NONE, description); selection->clear(); @@ -680,9 +680,9 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SPObject *source; if ( bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { if (reverseOrderForOp) { - source = SP_OBJECT(il[0]); + source = il[0]; } else { - source = SP_OBJECT(il.back()); + source = il.back(); } } else { // find out the bottom object @@ -719,10 +719,10 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // if this is the bottommost object, if (!strcmp(reinterpret_cast(*l)->getRepr()->attribute("id"), id)) { // delete it so that its clones don't get alerted; this object will be restored shortly, with the same id - SP_OBJECT(*l)->deleteObject(false); + (*l)->deleteObject(false); } else { // delete the object for real, so that its clones can take appropriate action - SP_OBJECT(*l)->deleteObject(); + (*l)->deleteObject(); } } diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index eadab90dd..5d57ac020 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -198,7 +198,7 @@ text_remove_from_path() bool did = false; std::vector items(selection->itemList()); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPObject *obj = SP_OBJECT(*i); + SPObject *obj = *i; if (SP_IS_TEXT_TEXTPATH(obj)) { SPObject *tp = obj->firstChild(); @@ -262,7 +262,7 @@ text_remove_all_kerns() std::vector items = selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPObject *obj = SP_OBJECT(*i); + SPObject *obj = *i; if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { continue; @@ -322,7 +322,7 @@ text_flow_into_shape() /* Add clones */ std::vector items = selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; if (SP_IS_SHAPE(item)){ Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); clone->setAttribute("x", "0"); @@ -398,7 +398,7 @@ text_unflow () std::vector items = selection->itemList(); for(std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ - if (!SP_IS_FLOWTEXT(SP_OBJECT(*i))) { + if (!SP_IS_FLOWTEXT(*i)) { continue; } diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index a38a52371..3fe935e7d 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -706,7 +706,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // copy style for Paste Style action if (!sorted_items.empty()) { - SPObject *object = static_cast(sorted_items[0]); + SPObject *object = sorted_items[0]; SPItem *item = dynamic_cast(object); if (item) { SPCSSAttr *style = take_style_from_item(item); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 45c8ce68a..cb2771503 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1467,7 +1467,7 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) std::set used; std::vector itemlist=sel->itemList(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPStyle *style = obj->style; if (!style || !SP_IS_ITEM(obj)) { continue; diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index dde040036..173acca93 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -562,7 +562,7 @@ std::vector Find::filter_fields (std::vector &l, bool exact, b if (check_searchin_text.get_active()) { for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_text_match(item, text, exact, casematch)) { @@ -585,7 +585,7 @@ std::vector Find::filter_fields (std::vector &l, bool exact, b if (ids) { for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); if (item_id_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { @@ -601,7 +601,7 @@ std::vector Find::filter_fields (std::vector &l, bool exact, b if (style) { for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_style_match(item, text, exact, casematch)) { @@ -618,7 +618,7 @@ std::vector Find::filter_fields (std::vector &l, bool exact, b if (attrname) { for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_attr_match(item, text, exact, casematch)) { @@ -635,7 +635,7 @@ std::vector Find::filter_fields (std::vector &l, bool exact, b if (attrvalue) { for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_attrvalue_match(item, text, exact, casematch)) { @@ -652,7 +652,7 @@ std::vector Find::filter_fields (std::vector &l, bool exact, b if (font) { for(std::vector::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_font_match(item, text, exact, casematch)) { @@ -719,7 +719,7 @@ std::vector Find::filter_types (std::vector &l) { std::vector n; for(std::vector::const_reverse_iterator i=l.rbegin(); l.rend() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item_type_match(item)) { @@ -763,7 +763,7 @@ std::vector &Find::all_selection_items (Inkscape::Selection *s, std::ve { std::vector itemlist=s->itemList(); for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { - SPObject *obj = SP_OBJECT (*i); + SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); if (item && !item->cloned && !desktop->isLayer(item)) { @@ -857,7 +857,7 @@ void Find::onAction() Inkscape::Selection *selection = desktop->getSelection(); selection->clear(); selection->setList(n); - SPObject *obj = reinterpret_cast(n[0]); + SPObject *obj = n[0]; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); scroll_to_show_item(desktop, item); diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 8bd130c2e..4465d73a9 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -210,7 +210,7 @@ void GridArrangeTab::arrange() cnt=0; const std::vector sizes(sorted); for (std::vector::const_iterator i = sizes.begin();i!=sizes.end();i++) { - SPItem *item = SP_ITEM(*i); + SPItem *item = *i; Geom::OptRect b = item->documentVisualBounds(); if (b) { width = b->dimensions()[Geom::X]; diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index 5fab9fcfc..ed71c826f 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -652,7 +652,7 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) bool wasadded = false; std::vector items=_desktop->selection->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPObject *newobj = reinterpret_cast(*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) { diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 9c4790379..815aa12ef 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -549,7 +549,7 @@ void TextEdit::onApply() if (SP_IS_TEXT (*i)) { // backwards compatibility: - reinterpret_cast(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); + (*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); ++items; } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 21ad18c26..a9e109b5c 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -934,7 +934,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta sp_item_gradient_set_coords (*i, POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false); sp_item_gradient_set_coords (*i, POINT_RG_R1, 0, pt, fill_or_stroke, true, false); } - SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); + (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } if (ec->_grdrag) { ec->_grdrag->updateDraggers(); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index c8e032089..2c817694e 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -965,13 +965,13 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); + sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); - sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke); + sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); // We don't need to do anything. Mesh is already sized appropriately. - SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); + (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG); } // if (ec->_grdrag) { // ec->_grdrag->updateDraggers(); diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 6ddb379cc..374386686 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -422,7 +422,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::vector items=sel->itemList(); for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - SPObject *obj = static_cast(*i); + SPObject *obj = *i; if (SP_IS_ITEM(obj)) { gather_items(this, NULL, static_cast(obj), SHAPE_ROLE_NORMAL, shapes); diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index 1ded546dd..95b89bf5f 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -114,7 +114,7 @@ void StyleSubject::CurrentLayer::_setLayer(SPObject *layer) { _layer_release.disconnect(); _layer_modified.disconnect(); if (_element) { - sp_object_unref(static_cast(_element), NULL); + sp_object_unref(_element, NULL); } _element = layer; if (layer) { @@ -126,7 +126,7 @@ void StyleSubject::CurrentLayer::_setLayer(SPObject *layer) { } SPObject *StyleSubject::CurrentLayer::_getLayer() const { - return static_cast(_element); + return _element; } SPObject *StyleSubject::CurrentLayer::_getLayerSList() const { diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 7d5a89cf5..1d258bbb0 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -579,7 +579,7 @@ void FillNStroke::updateFromPaint() for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { - sp_repr_css_change_recursive(reinterpret_cast(*i)->getRepr(), css, "style"); + sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); } if (!vector) { @@ -605,7 +605,7 @@ void FillNStroke::updateFromPaint() for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { - sp_repr_css_change_recursive(reinterpret_cast(*i)->getRepr(), css, "style"); + sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); } SPGradient *gr = sp_item_set_gradient(*i, vector, gradient_type, (kind == FILL) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE); @@ -649,11 +649,11 @@ void FillNStroke::updateFromPaint() // objects who already have the same root pattern but through a different href // chain. FIXME: move this to a sp_item_set_pattern for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ - Inkscape::XML::Node *selrepr = reinterpret_cast(*i)->getRepr(); + Inkscape::XML::Node *selrepr = (*i)->getRepr(); if ( (kind == STROKE) && !selrepr) { continue; } - SPObject *selobj = reinterpret_cast(*i); + SPObject *selobj = *i; SPStyle *style = selobj->style; if (style && ((kind == FILL) ? style->fill : style->stroke).isPaintserver()) { diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 2b07dd3b9..37ffd7553 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -112,7 +112,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * if (gtk_adjustment_get_value(adj) != 0) { (SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, desktop->getNamedView()->svg_units)); } else { - SP_OBJECT(*i)->getRepr()->setAttribute(value_name, NULL); + (*i)->getRepr()->setAttribute(value_name, NULL); } modmade = true; } diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index c05ef93e7..481fa0609 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -983,7 +983,7 @@ StrokeStyle::scaleLine() if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { width = Inkscape::Util::Quantity::convert(width_typed, unit, "px"); } else { // percentage - gdouble old_w = SP_OBJECT(*i)->style->stroke_width.computed; + gdouble old_w = (*i)->style->stroke_width.computed; width = old_w * width_typed / 100; } @@ -1167,7 +1167,7 @@ StrokeStyle::updateAllMarkers(std::vector const &objects) // We show markers of the first object in the list only // FIXME: use the first in the list that has the marker of each type, if any - SPObject *object = SP_OBJECT(objects[0]); + SPObject *object = objects[0]; for (unsigned i = 0; i < G_N_ELEMENTS(keyloc); ++i) { // For all three marker types, diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 6b0fb34e6..2160cad2e 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -522,7 +522,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) std::vector itemlist=selection->itemList(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_TEXT (*i)) { - SP_OBJECT(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); + (*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); modmade = true; } } -- cgit v1.2.3 From 746649e82ce4b1ea144dabdee26d4abab510cce8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 26 Apr 2015 14:23:26 +0200 Subject: fix (bzr r13922.1.14) --- src/widgets/rect-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 29a10a534..96ba699dc 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -110,7 +110,7 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_RECT(*i)) { if (gtk_adjustment_get_value(adj) != 0) { - (SP_RECT(items->data)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); + (SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); } else { (*i)->getRepr()->setAttribute(value_name, NULL); } -- cgit v1.2.3 From 60bdd590969d1c32c392a8fed15f4ceac4a678d2 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Mon, 27 Apr 2015 01:12:03 +0200 Subject: Just reread the entire diff against trunk. Given the diff size, i must have forgotten things, but hopefully, there are only very few changes of semantics: ->childList is now in the intuitive order (childList()[0] is now firstChild) -> sp_selection_paste_impl is now in the opposite order (change is local to selection-chemistry.cpp, and simplify a few things) -> selection.setReprList now takes the list in the opposite order. It was always the case (the list was always reversed before handing to it) -> a few comparison functions now work "the c++ way": the C way was to return -1 if ab, now they return (bool)(agetSelection(); selection->setReprList(pasted_objects); diff --git a/src/main.cpp b/src/main.cpp index 66452906b..d1ebdc3bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1641,7 +1641,9 @@ static int sp_do_export_png(SPDocument *doc) g_print("Background RRGGBBAA: %08x\n", bgcolor); g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi); - + + reverse(items.begin(),items.end()); + if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector()) == 1 ) { diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index b128535bc..bb313ef1a 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -269,7 +269,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) if (l == list) repr->setAttribute("id", id); - reprs.insert(reprs.begin(),repr); + reprs.push_back(repr); Inkscape::GC::release(repr); } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 0100e1040..c1d4f58e4 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -337,10 +337,7 @@ static void sp_selection_copy_impl(std::vector const &items, std::vecto g_assert_not_reached(); } } - std::vector tmp(clip); - for(int i=0;i copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); selection->setReprList(copied); - copied.clear(); if (!temp_clip.empty()) temp_clip.clear(); if (moveto) dt->setCurrentLayer(moveto); if ( !suppressDone ) { @@ -2051,7 +2047,7 @@ std::vector sp_get_same_style(SPItem *sel, std::vector &src, S sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, sel_style_for_width); } - bool match_g; + bool match_g; for (std::vector::const_iterator i=src.begin();i!=src.end();i++) { SPItem *iter = *i; if (iter) { @@ -3186,7 +3182,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) } } - for (std::vector::const_iterator i=children.begin();i!=children.end();i++){ + for (std::vector::const_reverse_iterator i=children.rbegin();i!=children.rend();i++){ Inkscape::XML::Node *repr = (*i)->getRepr(); repr->parent()->removeChild(repr); group->addChild(repr,NULL); diff --git a/src/selection.cpp b/src/selection.cpp index 7e8190237..d9266b599 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -42,9 +42,9 @@ namespace Inkscape { Selection::Selection(LayerModel *layers, SPDesktop *desktop) : - _objs(std::list()), - _objs_vector(std::vector()), - _objs_set(std::set()), + _objs(std::list()), + _objs_vector(std::vector()), + _objs_set(std::set()), _reprs(std::vector()), _items(std::vector()), _layers(layers), @@ -281,10 +281,10 @@ void Selection::clear() { } std::vector const &Selection::list() { - if(!_objs_vector.empty()) + if(!_objs_vector.empty()) return _objs_vector; - for ( std::list::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { + for ( std::list::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { _objs_vector.push_back(*iter); } return _objs_vector; @@ -349,7 +349,7 @@ SPObject *Selection::single() { } SPItem *Selection::singleItem() { - std::vector const items=itemList(); + std::vector const items=itemList(); if ( items.size()==1) { return items[0]; } else { @@ -366,7 +366,7 @@ SPItem *Selection::largestItem(Selection::CompareSize compare) { } SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; @@ -399,7 +399,7 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect Selection::geometricBounds() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); Geom::OptRect bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { @@ -410,7 +410,7 @@ Geom::OptRect Selection::geometricBounds() const Geom::OptRect Selection::visualBounds() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); Geom::OptRect bbox; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { @@ -445,7 +445,7 @@ Geom::OptRect Selection::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 Selection::center() const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); if (!items.empty()) { SPItem *first = items.back(); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly @@ -461,7 +461,7 @@ boost::optional Selection::center() const { } std::vector Selection::getSnapPoints(SnapPreferences const *snapprefs) const { - std::vector const items = const_cast(this)->itemList(); + std::vector const items = const_cast(this)->itemList(); 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 @@ -514,8 +514,8 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { } uint Selection::numberOfLayers() { - std::vector const items = const_cast(this)->itemList(); - std::set layers; + std::vector const items = const_cast(this)->itemList(); + std::set layers; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *layer = _layers->layerForObject(SP_OBJECT(*iter)); layers.insert(layer); @@ -524,8 +524,8 @@ uint Selection::numberOfLayers() { } guint Selection::numberOfParents() { - std::vector const items = const_cast(this)->itemList(); - std::set parents; + std::vector const items = const_cast(this)->itemList(); + std::set parents; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *parent = SP_OBJECT(*iter)->parent; parents.insert(parent); diff --git a/src/sp-object.h b/src/sp-object.h index df773fea7..f5d47be05 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -52,7 +52,6 @@ class SPObject; #include #include #include -#include #include #include "version.h" diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 5d57ac020..9fc862ad2 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -396,7 +396,7 @@ text_unflow () GSList *old_objs = NULL; std::vector items = selection->itemList(); - for(std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ + for(std::vector::const_iterator i=items.begin();i!=items.end();i++){ if (!SP_IS_FLOWTEXT(*i)) { continue; @@ -452,6 +452,7 @@ text_unflow () } selection->clear(); + reverse(new_objs.begin(),new_objs.end()); selection->setList(new_objs); for (GSList *i = old_objs; i; i = i->next) { SP_OBJECT(i->data)->deleteObject (true); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b348bdcad..f84a2ffd6 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2113,8 +2113,7 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) } desktop->getDocument()->ensureUpToDate(); - std::vector tu2(to_unclump); - for(int i=0;igetDocument(), SP_VERB_DIALOG_CLONETILER, diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 173acca93..a8ac42a1b 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -762,7 +762,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(); - for(std::vector::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + for(std::vector::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; i++) { SPObject *obj = *i; SPItem *item = dynamic_cast(obj); g_assert(item != NULL); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 76c748ae0..76b52f9be 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -378,7 +378,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P std::vector to_select; SPDocument *doc = item->document; sp_item_list_to_curves (items, selected, to_select); - SPObject* newObj = doc->getObjectByRepr(to_select.back()); + SPObject* newObj = doc->getObjectByRepr(to_select[0]); item = dynamic_cast(newObj); g_assert(item != NULL); selection->add(item); -- cgit v1.2.3 From 4bd4a89e23064b6782728d7965b12443978dcd29 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 28 Apr 2015 00:56:20 +0200 Subject: removed a few "using Inkscape::Util::GSListConstIterator" (bzr r13922.1.16) --- src/extension/implementation/implementation.cpp | 1 - src/extension/internal/bitmap/imagemagick.cpp | 2 -- src/extension/internal/bluredge.cpp | 1 - src/extension/internal/grid.cpp | 2 -- src/removeoverlap.cpp | 1 - src/ui/dialog/align-and-distribute.cpp | 5 ----- src/ui/dialog/transformation.cpp | 1 - 7 files changed, 13 deletions(-) (limited to 'src') diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 717ca3310..b0ff3e91c 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -47,7 +47,6 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); - using Inkscape::Util::GSListConstIterator; std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 3a29b3dc0..5e4c930bc 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -240,8 +240,6 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie { SPDocument * current_document = view->doc(); - using Inkscape::Util::GSListConstIterator; - std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index b80e5ddbb..9f19f8b3b 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -63,7 +63,6 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); - using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least std::vector items(selection->itemList()); selection->clear(); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 60d606a02..932d9a0d0 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -190,8 +190,6 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - using Inkscape::Util::GSListConstIterator; - std::vector selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index 01ce2c47e..9ea75de0d 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -39,7 +39,6 @@ namespace { * horizontally and yGap vertically */ void removeoverlap(std::vector const &items, double const xGap, double const yGap) { - using Inkscape::Util::GSListConstIterator; std::vector selected(items); std::vector records; std::vector rs; diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 1ee72dcbc..882427912 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -97,7 +97,6 @@ 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"); - using Inkscape::Util::GSListConstIterator; std::vector selected(selection->itemList()); if (selected.empty()) return; @@ -250,7 +249,6 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - using Inkscape::Util::GSListConstIterator; std::vector selected(selection->itemList()); if (selected.empty()) return; @@ -548,7 +546,6 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - using Inkscape::Util::GSListConstIterator; std::vector selected(selection->itemList()); if (selected.empty()) return; @@ -646,7 +643,6 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - using Inkscape::Util::GSListConstIterator; std::vector selected(selection->itemList()); if (selected.empty()) return; @@ -745,7 +741,6 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - using Inkscape::Util::GSListConstIterator; std::vector selected(selection->itemList()); if (selected.empty()) return; diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 459e6e937..5bd3cb309 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -740,7 +740,6 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { // shift each object relatively to the previous one - using Inkscape::Util::GSListConstIterator; std::vector selected(selection->itemList()); if (selected.empty()) return; -- cgit v1.2.3 From 643c75ddbbbea2f018050faa1e7e38c71482418a Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 28 Apr 2015 01:20:57 +0200 Subject: removed a few useless SP_OBJECT() casts (bzr r13922.1.17) --- src/selection-chemistry.cpp | 28 ++++++++++++++-------------- src/selection.cpp | 4 ++-- src/splivarot.cpp | 4 ++-- src/ui/dialog/object-attributes.cpp | 2 +- src/ui/dialog/transformation.cpp | 2 +- src/ui/tools/gradient-tool.cpp | 2 +- src/widgets/stroke-style.cpp | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index c1d4f58e4..7255e80cb 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -889,14 +889,14 @@ sp_item_list_common_parent_group(std::vector const items) if (items.empty()) { return NULL; } - SPObject *parent = SP_OBJECT(items[0])->parent; + SPObject *parent = items[0]->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; - if (SP_OBJECT(*item)->parent != parent) { + if ((*item)->parent != parent) { return NULL; } } @@ -2896,7 +2896,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items[0])->parent; + SPObject *parent = items[0]->parent; Geom::Affine parent_transform; { @@ -2911,7 +2911,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) // Create a list of duplicates, to be pasted inside marker element. std::vector repr_copies; for (std::vector::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ - Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); repr_copies.push_back(dup); } @@ -3248,7 +3248,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) sort(items.begin(),items.end(),sp_object_compare_position); // bottommost object, after sorting - SPObject *parent = SP_OBJECT(items[0])->parent; + SPObject *parent = items[0]->parent; Geom::Affine parent_transform; @@ -3262,12 +3262,12 @@ sp_selection_tile(SPDesktop *desktop, bool apply) } // remember the position of the first item - gint pos = SP_OBJECT(items[0])->getRepr()->position(); + gint pos = items[0]->getRepr()->position(); // create a list of duplicates std::vector repr_copies; for (std::vector::const_iterator i=items.begin();i!=items.end();i++){ - Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); repr_copies.push_back(dup); } @@ -3520,7 +3520,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) // Create the filename. gchar *const basename = g_strdup_printf("%s-%s-%u.png", document->getName(), - SP_OBJECT(items[0])->getRepr()->attribute("id"), + items[0]->getRepr()->attribute("id"), current); // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, // digits, and a few other chars, with "_" @@ -3540,8 +3540,8 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) //g_print("%s\n", filepath); // Remember parent and z-order of the topmost one - gint pos = SP_OBJECT(items.back())->getRepr()->position(); - SPObject *parent_object = SP_OBJECT(items.back())->parent; + gint pos = items.back()->getRepr()->position(); + SPObject *parent_object = items.back()->parent; Inkscape::XML::Node *parent = parent_object->getRepr(); // Calculate resolution @@ -3857,7 +3857,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); for (std::vector::const_iterator i=items.begin();i!=items.end();i++) { - Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); SPObject *item = *i; @@ -3870,7 +3870,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ } } else if (!topmost) { // topmost item is used as a mask, which is applied to other items in a selection - Inkscape::XML::Node *dup = SP_OBJECT(items[0])->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *dup = items[0]->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); if (remove_original) { @@ -4049,7 +4049,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { } } - SP_OBJECT(*i)->getRepr()->setAttribute(attributeName, "none"); + (*i)->getRepr()->setAttribute(attributeName, "none"); SPGroup *group = dynamic_cast(*i); if (ungroup_masked && group) { @@ -4070,7 +4070,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { GSList *items_to_move = NULL; for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { // Collect all clipped paths and masks within a single group - Inkscape::XML::Node *copy = SP_OBJECT(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/selection.cpp b/src/selection.cpp index d9266b599..b2fb6447e 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -517,7 +517,7 @@ uint Selection::numberOfLayers() { std::vector const items = const_cast(this)->itemList(); std::set layers; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPObject *layer = _layers->layerForObject(SP_OBJECT(*iter)); + SPObject *layer = _layers->layerForObject(*iter); layers.insert(layer); } return layers.size(); @@ -527,7 +527,7 @@ guint Selection::numberOfParents() { std::vector const items = const_cast(this)->itemList(); std::set parents; for ( std::vector::const_iterator iter=items.begin();iter!=items.end();iter++ ) { - SPObject *parent = SP_OBJECT(*iter)->parent; + SPObject *parent = (*iter)->parent; parents.insert(parent); } return parents.size(); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index a04dedda9..f61a30462 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -354,8 +354,8 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice) { // check in the tree to find which element of the selection list is topmost (for 2-operand commands only) - Inkscape::XML::Node *a = SP_OBJECT(il.front())->getRepr(); - Inkscape::XML::Node *b = SP_OBJECT(il.back())->getRepr(); + Inkscape::XML::Node *a = il.front()->getRepr(); + 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.")); diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp index f43a15225..1bc570f43 100644 --- a/src/ui/dialog/object-attributes.cpp +++ b/src/ui/dialog/object-attributes.cpp @@ -127,7 +127,7 @@ void ObjectAttributes::widget_setup (void) blocked = true; // CPPIFY - SPObject *obj = SP_OBJECT(item); //to get the selected item + SPObject *obj = item; //to get the selected item // GObjectClass *klass = G_OBJECT_GET_CLASS(obj); //to deduce the object's type // GType type = G_TYPE_FROM_CLASS(klass); const SPAttrDesc *desc; diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 5bd3cb309..f571828ce 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -1005,7 +1005,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) for(std::vector::const_iterator i=tmp.begin();i!=tmp.end();i++){ SPItem *item = *i; item->set_item_transform(displayed); - SP_OBJECT(item)->updateRepr(); + item->updateRepr(); } } else { sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index bf38b5ca5..526671515 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -913,7 +913,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta for (std::vector::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { //FIXME: see above - sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); + sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); sp_item_set_gradient(*i, vector, (SPGradientType) type, fill_or_stroke); diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 481fa0609..482ca7af4 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -902,7 +902,7 @@ StrokeStyle::updateLine() return; std::vector const objects = sel->itemList(); - SPObject * const object = SP_OBJECT(objects[0]); + SPObject * const object = objects[0]; SPStyle * const style = object->style; /* Markers */ @@ -1002,7 +1002,7 @@ StrokeStyle::scaleLine() /* Set dash */ setScaledDash(css, ndash, dash, offset, width); - sp_desktop_apply_css_recursive (SP_OBJECT(*i), css, true); + sp_desktop_apply_css_recursive ((*i), css, true); } g_free(dash); -- cgit v1.2.3 From 71fcf846f0cb03e8f73ef72f1174b7e05f03d1c0 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 29 Apr 2015 23:03:20 +0200 Subject: corrected test file (bzr r13922.1.20) --- src/object-test.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/object-test.h b/src/object-test.h index 06363c372..4f0be3251 100644 --- a/src/object-test.h +++ b/src/object-test.h @@ -204,7 +204,8 @@ public: assert(n_group != NULL); begin = clock(); - sp_item_group_ungroup(n_group, NULL, false); + std::vector ch; + sp_item_group_ungroup(n_group, ch, false); end = clock(); std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to ungroup a with " << num_elements << " elements\n"; -- cgit v1.2.3