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/desktop-style.cpp | 120 +++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'src/desktop-style.cpp') 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; -- 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/desktop-style.cpp | 66 +++++++++++++++++++++++++-------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/desktop-style.cpp') 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); -- 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/desktop-style.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/desktop-style.cpp') 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; -- 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 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'src/desktop-style.cpp') 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; } -- cgit v1.2.3