Merge lp:~mc.../inkscape/SelContainer into lp:~inkscape.dev/inkscape/trunk

Proposed by Mc
Status: Merged
Merged at revision: 14074
Proposed branch: lp:~mc.../inkscape/SelContainer
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 8772 lines (+1576/-1810)
114 files modified
AUTHORS (+1/-0)
src/conn-avoid-ref.cpp (+3/-2)
src/desktop-style.cpp (+60/-61)
src/desktop-style.h (+16/-15)
src/desktop.cpp (+1/-1)
src/desktop.h (+1/-1)
src/document.cpp (+17/-17)
src/document.h (+4/-4)
src/extension/execution-env.cpp (+3/-5)
src/extension/implementation/implementation.cpp (+3/-5)
src/extension/implementation/script.cpp (+3/-4)
src/extension/internal/bitmap/imagemagick.cpp (+7/-11)
src/extension/internal/bluredge.cpp (+2/-4)
src/extension/internal/cairo-renderer.cpp (+3/-5)
src/extension/internal/filter/filter.cpp (+2/-4)
src/extension/internal/grid.cpp (+3/-6)
src/extension/internal/latex-text-renderer.cpp (+3/-5)
src/file.cpp (+2/-5)
src/gradient-chemistry.cpp (+7/-5)
src/gradient-drag.cpp (+9/-8)
src/graphlayout.cpp (+5/-5)
src/graphlayout.h (+2/-2)
src/helper/png-write.cpp (+6/-6)
src/helper/png-write.h (+4/-3)
src/live_effects/lpe-knot.cpp (+3/-3)
src/main.cpp (+13/-15)
src/object-snapper.cpp (+3/-2)
src/object-test.h (+2/-1)
src/path-chemistry.cpp (+57/-72)
src/path-chemistry.h (+1/-1)
src/removeoverlap.cpp (+6/-7)
src/removeoverlap.h (+1/-1)
src/selcue.cpp (+11/-8)
src/selection-chemistry.cpp (+415/-518)
src/selection-chemistry.h (+5/-4)
src/selection-describer.cpp (+17/-17)
src/selection.cpp (+83/-89)
src/selection.h (+15/-11)
src/seltrans.cpp (+27/-28)
src/seltrans.h (+1/-1)
src/snap.cpp (+7/-7)
src/snap.h (+4/-4)
src/sp-conn-end.cpp (+3/-2)
src/sp-defs.cpp (+3/-5)
src/sp-filter.cpp (+3/-5)
src/sp-item-group.cpp (+32/-53)
src/sp-item-group.h (+6/-4)
src/sp-lpe-item.cpp (+15/-15)
src/sp-marker.cpp (+3/-3)
src/sp-marker.h (+1/-1)
src/sp-object.cpp (+3/-3)
src/sp-object.h (+3/-2)
src/sp-pattern.cpp (+3/-3)
src/sp-pattern.h (+1/-1)
src/sp-switch.cpp (+11/-13)
src/sp-switch.h (+1/-1)
src/splivarot.cpp (+44/-57)
src/text-chemistry.cpp (+37/-47)
src/text-editing.cpp (+3/-4)
src/trace/trace.cpp (+4/-4)
src/ui/clipboard.cpp (+17/-16)
src/ui/dialog/align-and-distribute.cpp (+41/-45)
src/ui/dialog/clonetiler.cpp (+7/-9)
src/ui/dialog/export.cpp (+15/-13)
src/ui/dialog/filter-effects-dialog.cpp (+12/-15)
src/ui/dialog/find.cpp (+48/-48)
src/ui/dialog/find.h (+5/-5)
src/ui/dialog/font-substitution.cpp (+11/-17)
src/ui/dialog/font-substitution.h (+3/-2)
src/ui/dialog/glyphs.cpp (+7/-5)
src/ui/dialog/grid-arrange-tab.cpp (+34/-35)
src/ui/dialog/icon-preview.cpp (+3/-5)
src/ui/dialog/object-attributes.cpp (+1/-1)
src/ui/dialog/objects.cpp (+4/-4)
src/ui/dialog/pixelartdialog.cpp (+4/-4)
src/ui/dialog/polar-arrange-tab.cpp (+5/-9)
src/ui/dialog/print.cpp (+1/-1)
src/ui/dialog/svg-fonts-dialog.cpp (+2/-2)
src/ui/dialog/swatches.cpp (+3/-3)
src/ui/dialog/tags.cpp (+6/-5)
src/ui/dialog/text-edit.cpp (+12/-14)
src/ui/dialog/transformation.cpp (+24/-20)
src/ui/interface.cpp (+7/-10)
src/ui/tools/connector-tool.cpp (+3/-5)
src/ui/tools/eraser-tool.cpp (+13/-20)
src/ui/tools/gradient-tool.cpp (+19/-18)
src/ui/tools/lpe-tool.cpp (+4/-4)
src/ui/tools/measure-tool.cpp (+3/-3)
src/ui/tools/mesh-tool.cpp (+14/-13)
src/ui/tools/node-tool.cpp (+4/-6)
src/ui/tools/select-tool.cpp (+2/-3)
src/ui/tools/spray-tool.cpp (+12/-20)
src/ui/tools/text-tool.cpp (+3/-4)
src/ui/tools/tool-base.cpp (+2/-4)
src/ui/tools/tweak-tool.cpp (+11/-14)
src/ui/widget/object-composite-settings.cpp (+2/-1)
src/ui/widget/style-subject.cpp (+19/-21)
src/ui/widget/style-subject.h (+8/-7)
src/unclump.cpp (+32/-35)
src/unclump.h (+1/-1)
src/vanishing-point.cpp (+15/-11)
src/widgets/arc-toolbar.cpp (+12/-21)
src/widgets/connector-toolbar.cpp (+6/-10)
src/widgets/fill-style.cpp (+16/-16)
src/widgets/gradient-toolbar.cpp (+9/-6)
src/widgets/mesh-toolbar.cpp (+6/-4)
src/widgets/rect-toolbar.cpp (+9/-9)
src/widgets/spiral-toolbar.cpp (+6/-10)
src/widgets/star-toolbar.cpp (+18/-20)
src/widgets/stroke-style.cpp (+15/-15)
src/widgets/stroke-style.h (+1/-1)
src/widgets/text-toolbar.cpp (+17/-17)
src/xml/repr-util.cpp (+6/-6)
src/xml/repr.h (+2/-1)
To merge this branch: bzr merge lp:~mc.../inkscape/SelContainer
Reviewer Review Type Date Requested Status
Alex Valavanis Needs Fixing
Liam P. White (community) Approve
Review via email: mp+250681@code.launchpad.net

Description of the change

Hi all,

This branch is a proposal to replace a lot of GSLists with std::vectors, more specifically in all the places that deal with the selection.

Basically, selection->itemList() and similar methods now return a reference to a vector of SPItem* instead of a GSList (and similarly for other getters and setters from the selection)

To post a comment you must log in.
lp:~mc.../inkscape/SelContainer updated
13929. By Marc Jeanmougin <email address hidden>

Removed eclipse files, added removed pot file

13930. By Marc Jeanmougin <email address hidden>

Merge, resolved conflicts

13931. By Marc Jeanmougin <email address hidden>

should replace buggy pot file

Revision history for this message
Liam P. White (liampwhite) wrote :

I added some fancy new diff comments that should help show where things need fixing.

review: Needs Fixing (code)
Revision history for this message
Mc (mc...) wrote :

> I added some fancy new diff comments that should help show where things need
> fixing.

Thanks a lot for your comments !

I actually meant to change the semantics of SPObject::childList : It used to return a GSList, whose *last* element was the first child, and to be reversed in many places.

Now it returns a vector whose *first* element is the first child, so that allows us to actually simplify a lot of things (use push_back instead of insert in all the places that deals with childList)

I'll try to apply your comments as soon as i can.

Revision history for this message
Krzysztof Kosinski (tweenk) wrote :

Converting Selection to a vector is not the best thing to do. Selection
should be a data structure equivalent to Java's LinkedHashSet, because the
most common operation is lookup (whether something is in the selection) and
we also need to remember the selection's order for purposes such as Boolean
operations.

Regards, Krzysztof

2015-02-24 12:08 GMT+01:00 Mc <email address hidden>:

> > I added some fancy new diff comments that should help show where things
> need
> > fixing.
>
> Thanks a lot for your comments !
>
> I actually meant to change the semantics of SPObject::childList : It used
> to return a GSList, whose *last* element was the first child, and to be
> reversed in many places.
>
> Now it returns a vector whose *first* element is the first child, so that
> allows us to actually simplify a lot of things (use push_back instead of
> insert in all the places that deals with childList)
>
> I'll try to apply your comments as soon as i can.
> --
> https://code.launchpad.net/~mc.../inkscape/SelContainer/+merge/250681
> You are subscribed to branch lp:inkscape.
>

Revision history for this message
Mc (mc...) wrote :

This is not contradictory: since only the selection object needs to be able to do the lookups, this data structure can be internal to Selection, and does not need to be whatever is sent to anyone who calls itemList() (I don't really favor introducing iteration over boost objects everywhere just for that, stl is enough for stuff out of the selection class (ie: iterate) )

(I actually also added a std::set to make lookups logarithmic, alongside with the vectors change. I agree that it could be made one container, internally to the selection class, but vector+set prevents to do the copying from the boost thing)

> Converting Selection to a vector is not the best thing to do. Selection
> should be a data structure equivalent to Java's LinkedHashSet, because the
> most common operation is lookup (whether something is in the selection) and
> we also need to remember the selection's order for purposes such as Boolean
> operations.
>
> Regards, Krzysztof

Revision history for this message
Krzysztof Kosinski (tweenk) wrote :

Some more comments.

1. Please follow the coding style.
https://inkscape.org/en/develop/coding-style/

2. I don't really understand what you mean by "introducing iteration over boost objects".

3. While simply replacing GSList with vectors is an obvious improvement, I think the correct approach is to make a new data structure, that will encapsulate what we mean by a selection of objects (a list of unique items none of which is a descendant of any other), but which will not be tied to the GUI concept of selection. One could use Boost MultiIndex for this. Then you would return this structure (or references to it) instead of std::vector. The new structure could be a template called SelectionSet, with typedefs SelectionSet<SPObject> = ObjectSet and SelectionSet<SPItem> = ItemSet. Still, I would not be opposed to incorporating the simple GSList -> vector change first and introducing selection sets later.

Revision history for this message
Liam P. White (liampwhite) wrote :

> I would not be opposed to incorporating the simple GSList -> vector change first and introducing selection sets later.

Then let's do that.

lp:~mc.../inkscape/SelContainer updated
13932. By Marc Jeanmougin <email address hidden>

corrected the casts (hopefully)

13933. By Marc Jeanmougin <email address hidden>

more cast cleanup

13934. By Marc Jeanmougin <email address hidden>

merge

13935. By Marc Jeanmougin <email address hidden>

merging

13936. By Marc Jeanmougin <email address hidden>

fix

13937. By Marc Jeanmougin <email address hidden>

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 a<b, 0 if a==b and 1 if a>b, now they return (bool)(a<b)

13938. By Marc Jeanmougin <email address hidden>

removed a few "using Inkscape::Util::GSListConstIterator"

13939. By Marc Jeanmougin <email address hidden>

removed a few useless SP_OBJECT() casts

13940. By Marc Jeanmougin <email address hidden>

merge with trunk

Revision history for this message
Liam P. White (liampwhite) wrote :

Approving for merge — may need some small post-merge cleanups but otherwise don't see any issues obstructing merge at this point.

review: Approve
lp:~mc.../inkscape/SelContainer updated
13941. By Marc Jeanmougin <email address hidden>

updated with trunk

13942. By Marc Jeanmougin <email address hidden>

corrected test file

Revision history for this message
Alex Valavanis (valavanisalex) wrote :

This introduces a build failure if using --enable-dbusapi configuration flag. This is because the src/extension/dbus/* tree hasn't yet been migrated to the new selection API.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'AUTHORS'
--- AUTHORS 2014-05-12 22:02:09 +0000
+++ AUTHORS 2015-04-29 21:03:59 +0000
@@ -80,6 +80,7 @@
80Jean-Olivier Irisson80Jean-Olivier Irisson
81Bob Jamison81Bob Jamison
82Ted Janeczko82Ted Janeczko
83Marc Jeanmougin
83jEsuSdA84jEsuSdA
84Lauris Kaplinski85Lauris Kaplinski
85Lynn Kerby86Lynn Kerby
8687
=== modified file 'src/conn-avoid-ref.cpp'
--- src/conn-avoid-ref.cpp 2014-12-21 21:58:32 +0000
+++ src/conn-avoid-ref.cpp 2015-04-29 21:03:59 +0000
@@ -252,8 +252,9 @@
252 {252 {
253 SPGroup* group = SP_GROUP(item);253 SPGroup* group = SP_GROUP(item);
254 // consider all first-order children254 // consider all first-order children
255 for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) {255 std::vector<SPItem*> itemlist = sp_item_group_item_list(group);
256 SPItem* child_item = SP_ITEM(i->data);256 for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++) {
257 SPItem* child_item = *i;
257 std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform);258 std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform);
258 poly_points.insert(poly_points.end(), child_points.begin(), child_points.end());259 poly_points.insert(poly_points.end(), child_points.begin(), child_points.end());
259 }260 }
260261
=== modified file 'src/desktop-style.cpp'
--- src/desktop-style.cpp 2015-02-22 18:04:11 +0000
+++ src/desktop-style.cpp 2015-04-29 21:03:59 +0000
@@ -194,10 +194,10 @@
194 sp_repr_css_merge(css_write, css);194 sp_repr_css_merge(css_write, css);
195 sp_css_attr_unset_uris(css_write);195 sp_css_attr_unset_uris(css_write);
196 prefs->mergeStyle("/desktop/style", css_write);196 prefs->mergeStyle("/desktop/style", css_write);
197197 std::vector<SPItem*> const itemlist = desktop->selection->itemList();
198 for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) {198 for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) {
199 /* last used styles for 3D box faces are stored separately */199 /* last used styles for 3D box faces are stored separately */
200 SPObject *obj = reinterpret_cast<SPObject *>(i->data); // TODO unsafe until Selection is refactored.200 SPObject *obj = *i;
201 Box3DSide *side = dynamic_cast<Box3DSide *>(obj);201 Box3DSide *side = dynamic_cast<Box3DSide *>(obj);
202 if (side) {202 if (side) {
203 const char * descr = box3d_side_axes_string(side);203 const char * descr = box3d_side_axes_string(side);
@@ -234,8 +234,9 @@
234 sp_repr_css_merge(css_no_text, css);234 sp_repr_css_merge(css_no_text, css);
235 css_no_text = sp_css_attr_unset_text(css_no_text);235 css_no_text = sp_css_attr_unset_text(css_no_text);
236236
237 for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) {237 std::vector<SPItem*> const itemlist = desktop->selection->itemList();
238 SPItem *item = reinterpret_cast<SPItem *>(i->data);238 for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) {
239 SPItem *item = *i;
239240
240 // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME)241 // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME)
241 if (isTextualItem(item)) {242 if (isTextualItem(item)) {
@@ -438,18 +439,16 @@
438/** Determine average stroke width, simple method */439/** Determine average stroke width, simple method */
439// see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually440// see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually
440gdouble441gdouble
441stroke_average_width (GSList const *objects)442stroke_average_width (const std::vector<SPItem*> &objects)
442{443{
443 if (g_slist_length ((GSList *) objects) == 0)444 if (objects.empty())
444 return Geom::infinity();445 return Geom::infinity();
445446
446 gdouble avgwidth = 0.0;447 gdouble avgwidth = 0.0;
447 bool notstroked = true;448 bool notstroked = true;
448 int n_notstroked = 0;449 int n_notstroked = 0;
449450 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
450 for (GSList const *l = objects; l != NULL; l = l->next) {451 SPItem *item = *i;
451 SPObject *obj = reinterpret_cast<SPObject *>(l->data);
452 SPItem *item = dynamic_cast<SPItem *>(obj);
453 if (!item) {452 if (!item) {
454 continue;453 continue;
455 }454 }
@@ -471,7 +470,7 @@
471 if (notstroked)470 if (notstroked)
472 return Geom::infinity();471 return Geom::infinity();
473472
474 return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked);473 return avgwidth / (objects.size() - n_notstroked);
475}474}
476475
477static bool vectorsClose( std::vector<double> const &lhs, std::vector<double> const &rhs )476static bool vectorsClose( std::vector<double> const &lhs, std::vector<double> const &rhs )
@@ -492,9 +491,9 @@
492 * Write to style_res the average fill or stroke of list of objects, if applicable.491 * Write to style_res the average fill or stroke of list of objects, if applicable.
493 */492 */
494int493int
495objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill)494objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill)
496{495{
497 if (g_slist_length(objects) == 0) {496 if (objects.empty()) {
498 /* No objects, set empty */497 /* No objects, set empty */
499 return QUERY_STYLE_NOTHING;498 return QUERY_STYLE_NOTHING;
500 }499 }
@@ -514,8 +513,8 @@
514 prev[0] = prev[1] = prev[2] = 0.0;513 prev[0] = prev[1] = prev[2] = 0.0;
515 bool same_color = true;514 bool same_color = true;
516515
517 for (GSList const *i = objects; i != NULL; i = i->next) {516 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i!= objects.end(); i++) {
518 SPObject *obj = reinterpret_cast<SPObject *>(i->data);517 SPObject *obj = *i;
519 if (!obj) {518 if (!obj) {
520 continue;519 continue;
521 }520 }
@@ -674,7 +673,7 @@
674 }673 }
675674
676 // Not color675 // Not color
677 if (g_slist_length(objects) > 1) {676 if (objects.size() > 1) {
678 return QUERY_STYLE_MULTIPLE_SAME;677 return QUERY_STYLE_MULTIPLE_SAME;
679 } else {678 } else {
680 return QUERY_STYLE_SINGLE;679 return QUERY_STYLE_SINGLE;
@@ -685,9 +684,9 @@
685 * Write to style_res the average opacity of a list of objects.684 * Write to style_res the average opacity of a list of objects.
686 */685 */
687int686int
688objects_query_opacity (GSList *objects, SPStyle *style_res)687objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res)
689{688{
690 if (g_slist_length(objects) == 0) {689 if (objects.empty()) {
691 /* No objects, set empty */690 /* No objects, set empty */
692 return QUERY_STYLE_NOTHING;691 return QUERY_STYLE_NOTHING;
693 }692 }
@@ -698,8 +697,8 @@
698 guint opacity_items = 0;697 guint opacity_items = 0;
699698
700699
701 for (GSList const *i = objects; i != NULL; i = i->next) {700 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
702 SPObject *obj = reinterpret_cast<SPObject *>(i->data);701 SPObject *obj = *i;
703 if (!obj) {702 if (!obj) {
704 continue;703 continue;
705 }704 }
@@ -739,9 +738,9 @@
739 * Write to style_res the average stroke width of a list of objects.738 * Write to style_res the average stroke width of a list of objects.
740 */739 */
741int740int
742objects_query_strokewidth (GSList *objects, SPStyle *style_res)741objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res)
743{742{
744 if (g_slist_length(objects) == 0) {743 if (objects.empty()) {
745 /* No objects, set empty */744 /* No objects, set empty */
746 return QUERY_STYLE_NOTHING;745 return QUERY_STYLE_NOTHING;
747 }746 }
@@ -754,8 +753,8 @@
754753
755 int n_stroked = 0;754 int n_stroked = 0;
756755
757 for (GSList const *i = objects; i != NULL; i = i->next) {756 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
758 SPObject *obj = reinterpret_cast<SPObject *>(i->data);757 SPObject *obj = *i;
759 if (!obj) {758 if (!obj) {
760 continue;759 continue;
761 }760 }
@@ -815,9 +814,9 @@
815 * Write to style_res the average miter limit of a list of objects.814 * Write to style_res the average miter limit of a list of objects.
816 */815 */
817int816int
818objects_query_miterlimit (GSList *objects, SPStyle *style_res)817objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res)
819{818{
820 if (g_slist_length(objects) == 0) {819 if (objects.empty()) {
821 /* No objects, set empty */820 /* No objects, set empty */
822 return QUERY_STYLE_NOTHING;821 return QUERY_STYLE_NOTHING;
823 }822 }
@@ -828,8 +827,8 @@
828 gdouble prev_ml = -1;827 gdouble prev_ml = -1;
829 bool same_ml = true;828 bool same_ml = true;
830829
831 for (GSList const *i = objects; i != NULL; i = i->next) {830 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
832 SPObject *obj = reinterpret_cast<SPObject *>(i->data);831 SPObject *obj = *i;
833 if (!dynamic_cast<SPItem *>(obj)) {832 if (!dynamic_cast<SPItem *>(obj)) {
834 continue;833 continue;
835 }834 }
@@ -875,9 +874,9 @@
875 * Write to style_res the stroke cap of a list of objects.874 * Write to style_res the stroke cap of a list of objects.
876 */875 */
877int876int
878objects_query_strokecap (GSList *objects, SPStyle *style_res)877objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res)
879{878{
880 if (g_slist_length(objects) == 0) {879 if (objects.empty()) {
881 /* No objects, set empty */880 /* No objects, set empty */
882 return QUERY_STYLE_NOTHING;881 return QUERY_STYLE_NOTHING;
883 }882 }
@@ -887,8 +886,8 @@
887 bool same_cap = true;886 bool same_cap = true;
888 int n_stroked = 0;887 int n_stroked = 0;
889888
890 for (GSList const *i = objects; i != NULL; i = i->next) {889 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
891 SPObject *obj = reinterpret_cast<SPObject *>(i->data);890 SPObject *obj = *i;
892 if (!dynamic_cast<SPItem *>(obj)) {891 if (!dynamic_cast<SPItem *>(obj)) {
893 continue;892 continue;
894 }893 }
@@ -929,9 +928,9 @@
929 * Write to style_res the stroke join of a list of objects.928 * Write to style_res the stroke join of a list of objects.
930 */929 */
931int930int
932objects_query_strokejoin (GSList *objects, SPStyle *style_res)931objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res)
933{932{
934 if (g_slist_length(objects) == 0) {933 if (objects.empty()) {
935 /* No objects, set empty */934 /* No objects, set empty */
936 return QUERY_STYLE_NOTHING;935 return QUERY_STYLE_NOTHING;
937 }936 }
@@ -941,8 +940,8 @@
941 bool same_join = true;940 bool same_join = true;
942 int n_stroked = 0;941 int n_stroked = 0;
943942
944 for (GSList const *i = objects; i != NULL; i = i->next) {943 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
945 SPObject *obj = reinterpret_cast<SPObject *>(i->data);944 SPObject *obj = *i;
946 if (!dynamic_cast<SPItem *>(obj)) {945 if (!dynamic_cast<SPItem *>(obj)) {
947 continue;946 continue;
948 }947 }
@@ -984,7 +983,7 @@
984 * Write to style_res the average font size and spacing of objects.983 * Write to style_res the average font size and spacing of objects.
985 */984 */
986int985int
987objects_query_fontnumbers (GSList *objects, SPStyle *style_res)986objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res)
988{987{
989 bool different = false;988 bool different = false;
990989
@@ -1004,8 +1003,8 @@
1004 int texts = 0;1003 int texts = 0;
1005 int no_size = 0;1004 int no_size = 0;
10061005
1007 for (GSList const *i = objects; i != NULL; i = i->next) {1006 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
1008 SPObject *obj = reinterpret_cast<SPObject *>(i->data);1007 SPObject *obj = *i;
10091008
1010 if (!isTextualItem(obj)) {1009 if (!isTextualItem(obj)) {
1011 continue;1010 continue;
@@ -1116,15 +1115,15 @@
1116 * Write to style_res the average font style of objects.1115 * Write to style_res the average font style of objects.
1117 */1116 */
1118int1117int
1119objects_query_fontstyle (GSList *objects, SPStyle *style_res)1118objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res)
1120{1119{
1121 bool different = false;1120 bool different = false;
1122 bool set = false;1121 bool set = false;
11231122
1124 int texts = 0;1123 int texts = 0;
11251124
1126 for (GSList const *i = objects; i != NULL; i = i->next) {1125 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
1127 SPObject *obj = reinterpret_cast<SPObject *>(i->data);1126 SPObject *obj = *i;
11281127
1129 if (!isTextualItem(obj)) {1128 if (!isTextualItem(obj)) {
1130 continue;1129 continue;
@@ -1173,7 +1172,7 @@
1173 * Write to style_res the baseline numbers.1172 * Write to style_res the baseline numbers.
1174 */1173 */
1175static int1174static int
1176objects_query_baselines (GSList *objects, SPStyle *style_res)1175objects_query_baselines (const std::vector<SPItem*> &objects, SPStyle *style_res)
1177{1176{
1178 bool different = false;1177 bool different = false;
11791178
@@ -1192,8 +1191,8 @@
11921191
1193 int texts = 0;1192 int texts = 0;
11941193
1195 for (GSList const *i = objects; i != NULL; i = i->next) {1194 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
1196 SPObject *obj = reinterpret_cast<SPObject *>(i->data);1195 SPObject *obj = *i;
11971196
1198 if (!isTextualItem(obj)) {1197 if (!isTextualItem(obj)) {
1199 continue;1198 continue;
@@ -1269,7 +1268,7 @@
1269 * Write to style_res the average font family of objects.1268 * Write to style_res the average font family of objects.
1270 */1269 */
1271int1270int
1272objects_query_fontfamily (GSList *objects, SPStyle *style_res)1271objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res)
1273{1272{
1274 bool different = false;1273 bool different = false;
1275 int texts = 0;1274 int texts = 0;
@@ -1280,8 +1279,8 @@
1280 }1279 }
1281 style_res->font_family.set = FALSE;1280 style_res->font_family.set = FALSE;
12821281
1283 for (GSList const *i = objects; i != NULL; i = i->next) {1282 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
1284 SPObject *obj = reinterpret_cast<SPObject *>(i->data);1283 SPObject *obj = *i;
12851284
1286 // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl;1285 // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl;
1287 if (!isTextualItem(obj)) {1286 if (!isTextualItem(obj)) {
@@ -1325,7 +1324,7 @@
1325}1324}
13261325
1327static int1326static int
1328objects_query_fontspecification (GSList *objects, SPStyle *style_res)1327objects_query_fontspecification (const std::vector<SPItem*> &objects, SPStyle *style_res)
1329{1328{
1330 bool different = false;1329 bool different = false;
1331 int texts = 0;1330 int texts = 0;
@@ -1336,8 +1335,8 @@
1336 }1335 }
1337 style_res->font_specification.set = FALSE;1336 style_res->font_specification.set = FALSE;
13381337
1339 for (GSList const *i = objects; i != NULL; i = i->next) {1338 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
1340 SPObject *obj = reinterpret_cast<SPObject *>(i->data);1339 SPObject *obj = *i;
13411340
1342 // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl;1341 // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl;
1343 if (!isTextualItem(obj)) {1342 if (!isTextualItem(obj)) {
@@ -1385,7 +1384,7 @@
1385}1384}
13861385
1387static int1386static int
1388objects_query_blend (GSList *objects, SPStyle *style_res)1387objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res)
1389{1388{
1390 const int empty_prev = -2;1389 const int empty_prev = -2;
1391 const int complex_filter = 5;1390 const int complex_filter = 5;
@@ -1394,8 +1393,8 @@
1394 bool same_blend = true;1393 bool same_blend = true;
1395 guint items = 0;1394 guint items = 0;
13961395
1397 for (GSList const *i = objects; i != NULL; i = i->next) {1396 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
1398 SPObject *obj = reinterpret_cast<SPObject *>(i->data);1397 SPObject *obj = *i;
1399 if (!obj) {1398 if (!obj) {
1400 continue;1399 continue;
1401 }1400 }
@@ -1471,9 +1470,9 @@
1471 * Write to style_res the average blurring of a list of objects.1470 * Write to style_res the average blurring of a list of objects.
1472 */1471 */
1473int1472int
1474objects_query_blur (GSList *objects, SPStyle *style_res)1473objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res)
1475{1474{
1476 if (g_slist_length(objects) == 0) {1475 if (objects.empty()) {
1477 /* No objects, set empty */1476 /* No objects, set empty */
1478 return QUERY_STYLE_NOTHING;1477 return QUERY_STYLE_NOTHING;
1479 }1478 }
@@ -1484,8 +1483,8 @@
1484 guint blur_items = 0;1483 guint blur_items = 0;
1485 guint items = 0;1484 guint items = 0;
14861485
1487 for (GSList const *i = objects; i != NULL; i = i->next) {1486 for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
1488 SPObject *obj = reinterpret_cast<SPObject *>(i->data);1487 SPObject *obj = *i;
1489 if (!obj) {1488 if (!obj) {
1490 continue;1489 continue;
1491 }1490 }
@@ -1553,7 +1552,7 @@
1553 * the result to style, return appropriate flag.1552 * the result to style, return appropriate flag.
1554 */1553 */
1555int1554int
1556sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property)1555sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property)
1557{1556{
1558 if (property == QUERY_STYLE_PROPERTY_FILL) {1557 if (property == QUERY_STYLE_PROPERTY_FILL) {
1559 return objects_query_fillstroke (list, style, true);1558 return objects_query_fillstroke (list, style, true);
@@ -1606,7 +1605,7 @@
16061605
1607 // otherwise, do querying and averaging over selection1606 // otherwise, do querying and averaging over selection
1608 if (desktop->selection != NULL) {1607 if (desktop->selection != NULL) {
1609 return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property);1608 return sp_desktop_query_style_from_list (desktop->selection->itemList(), style, property);
1610 }1609 }
16111610
1612 return QUERY_STYLE_NOTHING;1611 return QUERY_STYLE_NOTHING;
16131612
=== modified file 'src/desktop-style.h'
--- src/desktop-style.h 2014-10-08 02:22:03 +0000
+++ src/desktop-style.h 2015-04-29 21:03:59 +0000
@@ -17,6 +17,7 @@
17class SPCSSAttr;17class SPCSSAttr;
18class SPDesktop;18class SPDesktop;
19class SPObject;19class SPObject;
20class SPItem;
20class SPStyle;21class SPStyle;
21typedef struct _GSList GSList;22typedef struct _GSList GSList;
22namespace Inkscape {23namespace Inkscape {
@@ -64,21 +65,21 @@
64double sp_desktop_get_font_size_tool (SPDesktop *desktop);65double sp_desktop_get_font_size_tool (SPDesktop *desktop);
65void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text);66void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text);
6667
67gdouble stroke_average_width (GSList const *objects);68gdouble stroke_average_width (const std::vector<SPItem*> &objects);
6869
69int objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill);70int objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill);
70int objects_query_fontnumbers (GSList *objects, SPStyle *style_res);71int objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res);
71int objects_query_fontstyle (GSList *objects, SPStyle *style_res);72int objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res);
72int objects_query_fontfamily (GSList *objects, SPStyle *style_res);73int objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res);
73int objects_query_opacity (GSList *objects, SPStyle *style_res);74int objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res);
74int objects_query_strokewidth (GSList *objects, SPStyle *style_res);75int objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res);
75int objects_query_miterlimit (GSList *objects, SPStyle *style_res);76int objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res);
76int objects_query_strokecap (GSList *objects, SPStyle *style_res);77int objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res);
77int objects_query_strokejoin (GSList *objects, SPStyle *style_res);78int objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res);
7879
79int objects_query_blur (GSList *objects, SPStyle *style_res);80int objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res);
8081
81int sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property);82int sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property);
82int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property);83int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property);
83bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query);84bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query);
8485
8586
=== modified file 'src/desktop.cpp'
--- src/desktop.cpp 2015-02-25 01:04:28 +0000
+++ src/desktop.cpp 2015-04-29 21:03:59 +0000
@@ -716,7 +716,7 @@
716/**716/**
717 * \see SPDocument::getItemFromListAtPointBottom()717 * \see SPDocument::getItemFromListAtPointBottom()
718 */718 */
719SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const719SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const
720{720{
721 g_return_val_if_fail (doc() != NULL, NULL);721 g_return_val_if_fail (doc() != NULL, NULL);
722 return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p);722 return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p);
723723
=== modified file 'src/desktop.h'
--- src/desktop.h 2014-12-21 21:58:32 +0000
+++ src/desktop.h 2015-04-29 21:03:59 +0000
@@ -319,7 +319,7 @@
319 //void push_event_context (GType type, const gchar *config, unsigned int key);319 //void push_event_context (GType type, const gchar *config, unsigned int key);
320320
321 void set_coordinate_status (Geom::Point p);321 void set_coordinate_status (Geom::Point p);
322 SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const;322 SPItem *getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const;
323 SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const;323 SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const;
324 SPItem *getGroupAtPoint(Geom::Point const &p) const;324 SPItem *getGroupAtPoint(Geom::Point const &p) const;
325 Geom::Point point() const;325 Geom::Point point() const;
326326
=== modified file 'src/document.cpp'
--- src/document.cpp 2015-03-21 11:41:01 +0000
+++ src/document.cpp 2015-04-29 21:03:59 +0000
@@ -1266,7 +1266,7 @@
1266 return area.intersects(box);1266 return area.intersects(box);
1267}1267}
12681268
1269static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area,1269static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area,
1270 bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false)1270 bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false)
1271{1271{
1272 g_return_val_if_fail(SP_IS_GROUP(group), s);1272 g_return_val_if_fail(SP_IS_GROUP(group), s);
@@ -1279,7 +1279,7 @@
1279 SPItem *child = SP_ITEM(o);1279 SPItem *child = SP_ITEM(o);
1280 Geom::OptRect box = child->desktopVisualBounds();1280 Geom::OptRect box = child->desktopVisualBounds();
1281 if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {1281 if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
1282 s = g_slist_append(s, child);1282 s.push_back(child);
1283 }1283 }
1284 }1284 }
1285 }1285 }
@@ -1306,7 +1306,7 @@
1306 return inGroup;1306 return inGroup;
1307}1307}
13081308
1309SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive)1309SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive)
1310{1310{
1311 g_return_val_if_fail(group, NULL);1311 g_return_val_if_fail(group, NULL);
1312 SPItem *bottomMost = 0;1312 SPItem *bottomMost = 0;
@@ -1320,7 +1320,7 @@
1320 Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey);1320 Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey);
1321 if (arenaitem && arenaitem->pick(p, delta, 1) != NULL1321 if (arenaitem && arenaitem->pick(p, delta, 1) != NULL
1322 && (take_insensitive || item->isVisibleAndUnlocked(dkey))) {1322 && (take_insensitive || item->isVisibleAndUnlocked(dkey))) {
1323 if (g_slist_find((GSList *) list, item) != NULL) {1323 if (find(list.begin(),list.end(),item)!=list.end() ) {
1324 bottomMost = item;1324 bottomMost = item;
1325 }1325 }
1326 }1326 }
@@ -1422,11 +1422,11 @@
1422 * Assumes box is normalized (and g_asserts it!)1422 * Assumes box is normalized (and g_asserts it!)
1423 *1423 *
1424 */1424 */
1425GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const1425std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const
1426{1426{
1427 g_return_val_if_fail(this->priv != NULL, NULL);1427 std::vector<SPItem*> x;
14281428 g_return_val_if_fail(this->priv != NULL, x);
1429 return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within);1429 return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within);
1430}1430}
14311431
1432/*1432/*
@@ -1436,16 +1436,16 @@
1436 *1436 *
1437 */1437 */
14381438
1439GSList *SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const1439std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const
1440{1440{
1441 g_return_val_if_fail(this->priv != NULL, NULL);1441 std::vector<SPItem*> x;
14421442 g_return_val_if_fail(this->priv != NULL, x);
1443 return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps);1443 return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps);
1444}1444}
14451445
1446GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const1446std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const
1447{1447{
1448 GSList *items = NULL;1448 std::vector<SPItem*> items;
1449 Inkscape::Preferences *prefs = Inkscape::Preferences::get();1449 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
14501450
1451 // When picking along the path, we don't want small objects close together1451 // When picking along the path, we don't want small objects close together
@@ -1454,11 +1454,11 @@
1454 gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0);1454 gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
1455 prefs->setDouble("/options/cursortolerance/value", 0.25);1455 prefs->setDouble("/options/cursortolerance/value", 0.25);
14561456
1457 for(unsigned int i = 0; i < points.size(); i++) {1457 for(int i = points.size()-1;i>=0; i--) {
1458 SPItem *item = getItemAtPoint(key, points[i],1458 SPItem *item = getItemAtPoint(key, points[i],
1459 false, NULL);1459 false, NULL);
1460 if (item && !g_slist_find(items, item))1460 if (item && items.end()==find(items.begin(),items.end(), item))
1461 items = g_slist_prepend (items, item);1461 items.push_back(item);
1462 }1462 }
14631463
1464 // and now we restore it back1464 // and now we restore it back
14651465
=== modified file 'src/document.h'
--- src/document.h 2015-03-21 11:41:01 +0000
+++ src/document.h 2015-04-29 21:03:59 +0000
@@ -232,7 +232,7 @@
232 /**232 /**
233 * Returns the bottommost item from the list which is at the point, or NULL if none.233 * Returns the bottommost item from the list which is at the point, or NULL if none.
234 */234 */
235 static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const &p, bool take_insensitive = false);235 static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const std::vector<SPItem*> &list, Geom::Point const &p, bool take_insensitive = false);
236236
237 static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri,237 static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri,
238 char const *base, char const *name, unsigned int keepalive,238 char const *base, char const *name, unsigned int keepalive,
@@ -259,10 +259,10 @@
259 bool addResource(char const *key, SPObject *object);259 bool addResource(char const *key, SPObject *object);
260 bool removeResource(char const *key, SPObject *object);260 bool removeResource(char const *key, SPObject *object);
261 const GSList *getResourceList(char const *key) const;261 const GSList *getResourceList(char const *key) const;
262 GSList *getItemsInBox(unsigned int dkey, Geom::Rect const &box) const;262 std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box) const;
263 GSList *getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const;263 std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const;
264 SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const;264 SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const;
265 GSList *getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const;265 std::vector<SPItem*> getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const;
266 SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const;266 SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const;
267267
268 void changeUriAndHrefs(char const *uri);268 void changeUriAndHrefs(char const *uri);
269269
=== modified file 'src/extension/execution-env.cpp'
--- src/extension/execution-env.cpp 2015-04-27 23:38:31 +0000
+++ src/extension/execution-env.cpp 2015-04-29 21:03:59 +0000
@@ -60,14 +60,12 @@
60 sp_namedview_document_from_window(desktop);60 sp_namedview_document_from_window(desktop);
6161
62 if (desktop != NULL) {62 if (desktop != NULL) {
63 Inkscape::Util::GSListConstIterator<SPItem *> selected =63 std::vector<SPItem*> selected = desktop->getSelection()->itemList();
64 desktop->getSelection()->itemList();64 for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){
65 while ( selected != NULL ) {
66 Glib::ustring selected_id;65 Glib::ustring selected_id;
67 selected_id = (*selected)->getId();66 selected_id = (*x)->getId();
68 _selected.insert(_selected.end(), selected_id);67 _selected.insert(_selected.end(), selected_id);
69 //std::cout << "Selected: " << selected_id << std::endl;68 //std::cout << "Selected: " << selected_id << std::endl;
70 ++selected;
71 }69 }
72 }70 }
7371
7472
=== modified file 'src/extension/implementation/implementation.cpp'
--- src/extension/implementation/implementation.cpp 2014-12-21 21:58:32 +0000
+++ src/extension/implementation/implementation.cpp 2015-04-29 21:03:59 +0000
@@ -47,12 +47,10 @@
4747
48 SPDocument * current_document = view->doc();48 SPDocument * current_document = view->doc();
4949
50 using Inkscape::Util::GSListConstIterator;50 std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList();
51 // FIXME very unsafe cast
52 GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList();
53 Inkscape::XML::Node const* first_select = NULL;51 Inkscape::XML::Node const* first_select = NULL;
54 if (selected != NULL) {52 if (!selected.empty()) {
55 const SPItem * item = *selected;53 const SPItem * item = selected[0];
56 first_select = item->getRepr();54 first_select = item->getRepr();
57 }55 }
5856
5957
=== modified file 'src/extension/implementation/script.cpp'
--- src/extension/implementation/script.cpp 2015-04-27 16:01:19 +0000
+++ src/extension/implementation/script.cpp 2015-04-29 21:03:59 +0000
@@ -689,14 +689,13 @@
689 return;689 return;
690 }690 }
691691
692 Inkscape::Util::GSListConstIterator<SPItem *> selected =692 std::vector<SPItem*> selected =
693 desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer693 desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer
694 while ( selected != NULL ) {694 for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){
695 Glib::ustring selected_id;695 Glib::ustring selected_id;
696 selected_id += "--id=";696 selected_id += "--id=";
697 selected_id += (*selected)->getId();697 selected_id += (*x)->getId();
698 params.insert(params.begin(), selected_id);698 params.insert(params.begin(), selected_id);
699 ++selected;
700 }699 }
701700
702 file_listener fileout;701 file_listener fileout;
703702
=== modified file 'src/extension/internal/bitmap/imagemagick.cpp'
--- src/extension/internal/bitmap/imagemagick.cpp 2015-04-27 23:38:31 +0000
+++ src/extension/internal/bitmap/imagemagick.cpp 2015-04-29 21:03:59 +0000
@@ -66,8 +66,8 @@
66 _imageItems(NULL)66 _imageItems(NULL)
67{67{
68 SPDesktop *desktop = (SPDesktop*)view;68 SPDesktop *desktop = (SPDesktop*)view;
69 const GSList *selectedItemList = desktop->selection->itemList();69 const std::vector<SPItem*> selectedItemList = desktop->selection->itemList();
70 int selectCount = g_slist_length((GSList *)selectedItemList);70 int selectCount = selectedItemList.size();
71 71
72 // Init the data-holders72 // Init the data-holders
73 _nodes = new Inkscape::XML::Node*[selectCount];73 _nodes = new Inkscape::XML::Node*[selectCount];
@@ -79,9 +79,8 @@
79 _imageItems = new SPItem*[selectCount];79 _imageItems = new SPItem*[selectCount];
8080
81 // Loop through selected items81 // Loop through selected items
82 for (; selectedItemList != NULL; selectedItemList = g_slist_next(selectedItemList))82 for (std::vector<SPItem*>::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); i++) {
83 {83 SPItem *item = *i;
84 SPItem *item = SP_ITEM(selectedItemList->data);
85 Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr());84 Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr());
86 if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image"))85 if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image"))
87 {86 {
@@ -237,13 +236,10 @@
237{236{
238 SPDocument * current_document = view->doc();237 SPDocument * current_document = view->doc();
239238
240 using Inkscape::Util::GSListConstIterator;239 std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList();
241
242 // FIXME very unsafe cast
243 GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList();
244 Inkscape::XML::Node * first_select = NULL;240 Inkscape::XML::Node * first_select = NULL;
245 if (selected != NULL) {241 if (!selected.empty()) {
246 first_select = (*selected)->getRepr();242 first_select = (selected.front())->getRepr();
247 }243 }
248244
249 return module->autogui(current_document, first_select, changeSignal);245 return module->autogui(current_document, first_select, changeSignal);
250246
=== modified file 'src/extension/internal/bluredge.cpp'
--- src/extension/internal/bluredge.cpp 2014-03-27 01:33:44 +0000
+++ src/extension/internal/bluredge.cpp 2015-04-29 21:03:59 +0000
@@ -63,13 +63,11 @@
63 Inkscape::Preferences *prefs = Inkscape::Preferences::get();63 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
64 double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px");64 double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px");
6565
66 using Inkscape::Util::GSListConstIterator;
67 // TODO need to properly refcount the items, at least66 // TODO need to properly refcount the items, at least
68 std::list<SPItem *> items;67 std::vector<SPItem*> items(selection->itemList());
69 items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL);
70 selection->clear();68 selection->clear();
7169
72 for(std::list<SPItem *>::iterator item = items.begin();70 for(std::vector<SPItem*>::iterator item = items.begin();
73 item != items.end(); ++item) {71 item != items.end(); ++item) {
74 SPItem * spitem = *item;72 SPItem * spitem = *item;
7573
7674
=== modified file 'src/extension/internal/cairo-renderer.cpp'
--- src/extension/internal/cairo-renderer.cpp 2015-03-17 17:09:10 +0000
+++ src/extension/internal/cairo-renderer.cpp 2015-04-29 21:03:59 +0000
@@ -294,14 +294,12 @@
294 CairoRenderer *renderer = ctx->getRenderer();294 CairoRenderer *renderer = ctx->getRenderer();
295 TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value)));295 TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value)));
296296
297 GSList *l = g_slist_reverse(group->childList(false));297 std::vector<SPObject*> l(group->childList(false));
298 while (l) {298 for(std::vector<SPObject*>::const_iterator x = l.begin(); x!= l.end(); x++){
299 SPObject *o = reinterpret_cast<SPObject *>(l->data);299 SPItem *item = static_cast<SPItem*>(*x);
300 SPItem *item = dynamic_cast<SPItem *>(o);
301 if (item) {300 if (item) {
302 renderer->renderItem(ctx, item);301 renderer->renderItem(ctx, item);
303 }302 }
304 l = g_slist_remove (l, o);
305 }303 }
306}304}
307305
308306
=== modified file 'src/extension/internal/filter/filter.cpp'
--- src/extension/internal/filter/filter.cpp 2014-03-27 01:33:44 +0000
+++ src/extension/internal/filter/filter.cpp 2015-04-29 21:03:59 +0000
@@ -125,15 +125,13 @@
125 //printf("Calling filter effect\n");125 //printf("Calling filter effect\n");
126 Inkscape::Selection * selection = ((SPDesktop *)document)->selection;126 Inkscape::Selection * selection = ((SPDesktop *)document)->selection;
127127
128 using Inkscape::Util::GSListConstIterator;
129 // TODO need to properly refcount the items, at least128 // TODO need to properly refcount the items, at least
130 std::list<SPItem *> items;129 std::vector<SPItem*> items(selection->itemList());
131 items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL);
132130
133 Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc();131 Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc();
134 Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr();132 Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr();
135133
136 for(std::list<SPItem *>::iterator item = items.begin();134 for(std::vector<SPItem*>::iterator item = items.begin();
137 item != items.end(); ++item) {135 item != items.end(); ++item) {
138 SPItem * spitem = *item;136 SPItem * spitem = *item;
139 Inkscape::XML::Node * node = spitem->getRepr();137 Inkscape::XML::Node * node = spitem->getRepr();
140138
=== modified file 'src/extension/internal/grid.cpp'
--- src/extension/internal/grid.cpp 2015-04-27 23:38:31 +0000
+++ src/extension/internal/grid.cpp 2015-04-29 21:03:59 +0000
@@ -186,13 +186,10 @@
186{186{
187 SPDocument * current_document = view->doc();187 SPDocument * current_document = view->doc();
188188
189 using Inkscape::Util::GSListConstIterator;189 std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList();
190
191 // FIXME very unsafe cast
192 GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList();
193 Inkscape::XML::Node * first_select = NULL;190 Inkscape::XML::Node * first_select = NULL;
194 if (selected != NULL) {191 if (!selected.empty()) {
195 first_select = (*selected)->getRepr();192 first_select = selected[0]->getRepr();
196 }193 }
197194
198 return module->autogui(current_document, first_select, changeSignal);195 return module->autogui(current_document, first_select, changeSignal);
199196
=== modified file 'src/extension/internal/latex-text-renderer.cpp'
--- src/extension/internal/latex-text-renderer.cpp 2014-11-10 17:39:33 +0000
+++ src/extension/internal/latex-text-renderer.cpp 2015-04-29 21:03:59 +0000
@@ -228,14 +228,12 @@
228228
229void LaTeXTextRenderer::sp_group_render(SPGroup *group)229void LaTeXTextRenderer::sp_group_render(SPGroup *group)
230{230{
231 GSList *l = g_slist_reverse(group->childList(false));231 std::vector<SPObject*> l = (group->childList(false));
232 while (l) {232 for(std::vector<SPObject*>::const_iterator x = l.begin(); x != l.end(); x++){
233 SPObject *o = reinterpret_cast<SPObject *>(l->data);233 SPItem *item = static_cast<SPItem*>(*x);
234 SPItem *item = dynamic_cast<SPItem *>(o);
235 if (item) {234 if (item) {
236 renderItem(item);235 renderItem(item);
237 }236 }
238 l = g_slist_remove (l, o);
239 }237 }
240}238}
241239
242240
=== modified file 'src/file.cpp'
--- src/file.cpp 2015-02-23 16:48:29 +0000
+++ src/file.cpp 2015-04-29 21:03:59 +0000
@@ -1069,7 +1069,7 @@
1069 desktop->doc()->importDefs(clipdoc);1069 desktop->doc()->importDefs(clipdoc);
10701070
1071 // copy objects1071 // copy objects
1072 GSList *pasted_objects = NULL;1072 std::vector<Inkscape::XML::Node*> pasted_objects;
1073 for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) {1073 for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) {
1074 // Don't copy metadata, defs, named views and internal clipboard contents to the document1074 // Don't copy metadata, defs, named views and internal clipboard contents to the document
1075 if (!strcmp(obj->name(), "svg:defs")) {1075 if (!strcmp(obj->name(), "svg:defs")) {
@@ -1088,9 +1088,8 @@
1088 target_parent->appendChild(obj_copy);1088 target_parent->appendChild(obj_copy);
1089 Inkscape::GC::release(obj_copy);1089 Inkscape::GC::release(obj_copy);
10901090
1091 pasted_objects = g_slist_prepend(pasted_objects, (gpointer) obj_copy);1091 pasted_objects.push_back(obj_copy);
1092 }1092 }
1093
1094 // Change the selection to the freshly pasted objects1093 // Change the selection to the freshly pasted objects
1095 Inkscape::Selection *selection = desktop->getSelection();1094 Inkscape::Selection *selection = desktop->getSelection();
1096 selection->setReprList(pasted_objects);1095 selection->setReprList(pasted_objects);
@@ -1129,8 +1128,6 @@
11291128
1130 sp_selection_move_relative(selection, offset);1129 sp_selection_move_relative(selection, offset);
1131 }1130 }
1132
1133 g_slist_free(pasted_objects);
1134}1131}
11351132
11361133
11371134
=== modified file 'src/gradient-chemistry.cpp'
--- src/gradient-chemistry.cpp 2015-03-01 08:57:53 +0000
+++ src/gradient-chemistry.cpp 2015-04-29 21:03:59 +0000
@@ -1570,8 +1570,9 @@
1570{1570{
1571 Inkscape::Selection *selection = desktop->getSelection();1571 Inkscape::Selection *selection = desktop->getSelection();
15721572
1573 for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {1573 const std::vector<SPItem*> list=selection->itemList();
1574 sp_item_gradient_invert_vector_color(SP_ITEM(i->data), fill_or_stroke);1574 for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) {
1575 sp_item_gradient_invert_vector_color(*i, fill_or_stroke);
1575 }1576 }
15761577
1577 // we did an undoable action1578 // we did an undoable action
@@ -1594,9 +1595,10 @@
1594 if (drag && drag->selected) {1595 if (drag && drag->selected) {
1595 drag->selected_reverse_vector();1596 drag->selected_reverse_vector();
1596 } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients)1597 } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients)
1597 for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {1598 const std::vector<SPItem*> list=selection->itemList();
1598 sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL);1599 for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) {
1599 sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE);1600 sp_item_gradient_reverse_vector(*i, Inkscape::FOR_FILL);
1601 sp_item_gradient_reverse_vector(*i, Inkscape::FOR_STROKE);
1600 }1602 }
1601 }1603 }
16021604
16031605
=== modified file 'src/gradient-drag.cpp'
--- src/gradient-drag.cpp 2015-03-01 08:57:53 +0000
+++ src/gradient-drag.cpp 2015-04-29 21:03:59 +0000
@@ -2082,9 +2082,9 @@
2082 this->draggers = NULL;2082 this->draggers = NULL;
20832083
2084 g_return_if_fail(this->selection != NULL);2084 g_return_if_fail(this->selection != NULL);
20852085 std::vector<SPItem*> list = this->selection->itemList();
2086 for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) {2086 for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) {
2087 SPItem *item = SP_ITEM(i->data);2087 SPItem *item = *i;
2088 SPStyle *style = item->style;2088 SPStyle *style = item->style;
20892089
2090 if (style && (style->fill.isPaintserver())) {2090 if (style && (style->fill.isPaintserver())) {
@@ -2151,9 +2151,9 @@
21512151
2152 g_return_if_fail(this->selection != NULL);2152 g_return_if_fail(this->selection != NULL);
21532153
2154 for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) {2154 std::vector<SPItem*> list = this->selection->itemList();
21552155 for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) {
2156 SPItem *item = SP_ITEM(i->data);2156 SPItem *item = *i;
21572157
2158 SPStyle *style = item->style;2158 SPStyle *style = item->style;
21592159
@@ -2295,8 +2295,9 @@
22952295
2296 g_return_if_fail (this->selection != NULL);2296 g_return_if_fail (this->selection != NULL);
22972297
2298 for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) {2298 std::vector<SPItem*> list = this->selection->itemList();
2299 SPItem *item = SP_ITEM(i->data);2299 for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) {
2300 SPItem *item = *i;
2300 Geom::OptRect rect = item->desktopVisualBounds();2301 Geom::OptRect rect = item->desktopVisualBounds();
2301 if (rect) {2302 if (rect) {
2302 // Remember the edges of the bbox and the center axis2303 // Remember the edges of the bbox and the center axis
23032304
=== modified file 'src/graphlayout.cpp'
--- src/graphlayout.cpp 2014-11-26 01:35:57 +0000
+++ src/graphlayout.cpp 2015-04-29 21:03:59 +0000
@@ -88,9 +88,9 @@
88 * Scans the items list and places those items that are88 * Scans the items list and places those items that are
89 * not connectors in filtered89 * not connectors in filtered
90 */90 */
91void filterConnectors(GSList const *const items, list<SPItem *> &filtered) {91void filterConnectors(std::vector<SPItem*> const &items, list<SPItem *> &filtered) {
92 for(GSList *i=(GSList *)items; i!=NULL; i=i->next) {92 for(std::vector<SPItem*>::const_iterator i = items.begin();i !=items.end(); i++){
93 SPItem *item=SP_ITEM(i->data);93 SPItem *item = *i;
94 if(!isConnector(item)) {94 if(!isConnector(item)) {
95 filtered.push_back(item);95 filtered.push_back(item);
96 }96 }
@@ -101,8 +101,8 @@
101* connectors between them, and uses graph layout techniques to find101* connectors between them, and uses graph layout techniques to find
102* a nice layout102* a nice layout
103*/103*/
104void graphlayout(GSList const *const items) {104void graphlayout(std::vector<SPItem*> const &items) {
105 if(!items) {105 if(items.empty()) {
106 return;106 return;
107 }107 }
108108
109109
=== modified file 'src/graphlayout.h'
--- src/graphlayout.h 2014-10-08 02:22:03 +0000
+++ src/graphlayout.h 2015-04-29 21:03:59 +0000
@@ -19,10 +19,10 @@
19typedef struct _GSList GSList;19typedef struct _GSList GSList;
20class SPItem;20class SPItem;
2121
22void graphlayout(GSList const *const items);22void graphlayout(std::vector<SPItem*> const &items);
2323
24bool isConnector(SPItem const *const item);24bool isConnector(SPItem const *const item);
2525
26void filterConnectors(GSList const *const items, std::list<SPItem *> &filtered);26void filterConnectors(std::vector<SPItem*> const &items, std::list<SPItem *> &filtered);
2727
28#endif // SEEN_GRAPHLAYOUT_H28#endif // SEEN_GRAPHLAYOUT_H
2929
=== modified file 'src/helper/png-write.cpp'
--- src/helper/png-write.cpp 2014-10-05 16:38:15 +0000
+++ src/helper/png-write.cpp 2015-04-29 21:03:59 +0000
@@ -361,19 +361,19 @@
361/**361/**
362 * Hide all items that are not listed in list, recursively, skipping groups and defs.362 * Hide all items that are not listed in list, recursively, skipping groups and defs.
363 */363 */
364static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey)364static void hide_other_items_recursively(SPObject *o, const std::vector<SPItem*> &list, unsigned dkey)
365{365{
366 if ( SP_IS_ITEM(o)366 if ( SP_IS_ITEM(o)
367 && !SP_IS_DEFS(o)367 && !SP_IS_DEFS(o)
368 && !SP_IS_ROOT(o)368 && !SP_IS_ROOT(o)
369 && !SP_IS_GROUP(o)369 && !SP_IS_GROUP(o)
370 && !g_slist_find(list, o) )370 && list.end()==find(list.begin(),list.end(),o))
371 {371 {
372 SP_ITEM(o)->invoke_hide(dkey);372 SP_ITEM(o)->invoke_hide(dkey);
373 }373 }
374374
375 // recurse375 // recurse
376 if (!g_slist_find(list, o)) {376 if (list.end()==find(list.begin(),list.end(),o)) {
377 for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) {377 for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) {
378 hide_other_items_recursively(child, list, dkey);378 hide_other_items_recursively(child, list, dkey);
379 }379 }
@@ -387,7 +387,7 @@
387 unsigned long bgcolor,387 unsigned long bgcolor,
388 unsigned int (*status) (float, void *),388 unsigned int (*status) (float, void *),
389 void *data, bool force_overwrite,389 void *data, bool force_overwrite,
390 GSList *items_only)390 const std::vector<SPItem*> &items_only)
391{391{
392 return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)),392 return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)),
393 width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only);393 width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only);
@@ -399,7 +399,7 @@
399 unsigned long bgcolor,399 unsigned long bgcolor,
400 unsigned (*status)(float, void *),400 unsigned (*status)(float, void *),
401 void *data, bool force_overwrite,401 void *data, bool force_overwrite,
402 GSList *items_only)402 const std::vector<SPItem*> &items_only)
403{403{
404 g_return_val_if_fail(doc != NULL, EXPORT_ERROR);404 g_return_val_if_fail(doc != NULL, EXPORT_ERROR);
405 g_return_val_if_fail(filename != NULL, EXPORT_ERROR);405 g_return_val_if_fail(filename != NULL, EXPORT_ERROR);
@@ -457,7 +457,7 @@
457457
458 // We show all and then hide all items we don't want, instead of showing only requested items,458 // We show all and then hide all items we don't want, instead of showing only requested items,
459 // because that would not work if the shown item references something in defs459 // because that would not work if the shown item references something in defs
460 if (items_only) {460 if (!items_only.empty()) {
461 hide_other_items_recursively(doc->getRoot(), items_only, dkey);461 hide_other_items_recursively(doc->getRoot(), items_only, dkey);
462 }462 }
463463
464464
=== modified file 'src/helper/png-write.h'
--- src/helper/png-write.h 2014-03-27 01:33:44 +0000
+++ src/helper/png-write.h 2015-04-29 21:03:59 +0000
@@ -14,8 +14,9 @@
14 * Released under GNU GPL, read the file 'COPYING' for more information14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */15 */
1616
17#include <glib.h>
18#include <2geom/forward.h>17#include <2geom/forward.h>
18
19
19class SPDocument;20class SPDocument;
2021
21enum ExportResult {22enum ExportResult {
@@ -33,12 +34,12 @@
33 double x0, double y0, double x1, double y1,34 double x0, double y0, double x1, double y1,
34 unsigned long int width, unsigned long int height, double xdpi, double ydpi,35 unsigned long int width, unsigned long int height, double xdpi, double ydpi,
35 unsigned long bgcolor,36 unsigned long bgcolor,
36 unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL);37 unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>());
3738
38ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename,39ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename,
39 Geom::Rect const &area,40 Geom::Rect const &area,
40 unsigned long int width, unsigned long int height, double xdpi, double ydpi,41 unsigned long int width, unsigned long int height, double xdpi, double ydpi,
41 unsigned long bgcolor,42 unsigned long bgcolor,
42 unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL);43 unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>());
4344
44#endif // SEEN_SP_PNG_WRITE_H45#endif // SEEN_SP_PNG_WRITE_H
4546
=== modified file 'src/live_effects/lpe-knot.cpp'
--- src/live_effects/lpe-knot.cpp 2015-03-08 16:10:20 +0000
+++ src/live_effects/lpe-knot.cpp 2015-04-29 21:03:59 +0000
@@ -505,9 +505,9 @@
505static void505static void
506collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){506collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){
507 if (SP_IS_GROUP(lpeitem)) {507 if (SP_IS_GROUP(lpeitem)) {
508 GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem));508 std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem));
509 for ( GSList const *iter = item_list; iter; iter = iter->next ) {509 for ( std::vector<SPItem*>::const_iterator iter = item_list.begin(); iter != item_list.end(); iter++) {
510 SPObject *subitem = static_cast<SPObject *>(iter->data);510 SPObject *subitem = *iter;
511 if (SP_IS_LPE_ITEM(subitem)) {511 if (SP_IS_LPE_ITEM(subitem)) {
512 collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths);512 collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths);
513 }513 }
514514
=== modified file 'src/main.cpp'
--- src/main.cpp 2015-02-26 02:49:35 +0000
+++ src/main.cpp 2015-04-29 21:03:59 +0000
@@ -1156,7 +1156,7 @@
1156 }1156 }
1157 if (sp_export_svg) {1157 if (sp_export_svg) {
1158 if (sp_export_text_to_path) {1158 if (sp_export_text_to_path) {
1159 GSList *items = NULL;1159 std::vector<SPItem*> items;
1160 SPRoot *root = doc->getRoot();1160 SPRoot *root = doc->getRoot();
1161 doc->ensureUpToDate();1161 doc->ensureUpToDate();
1162 for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) {1162 for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) {
@@ -1166,17 +1166,14 @@
1166 }1166 }
11671167
1168 te_update_layout_now_recursive(item);1168 te_update_layout_now_recursive(item);
1169 items = g_slist_append(items, item);1169 items.push_back(item);
1170 }1170 }
11711171
1172 GSList *selected = NULL;1172 std::vector<SPItem*> selected;
1173 GSList *to_select = NULL;1173 std::vector<Inkscape::XML::Node*> to_select;
11741174
1175 sp_item_list_to_curves(items, &selected, &to_select);1175 sp_item_list_to_curves(items, selected, to_select);
11761176
1177 g_slist_free (items);
1178 g_slist_free (selected);
1179 g_slist_free (to_select);
1180 }1177 }
1181 if(sp_export_id) {1178 if(sp_export_id) {
1182 doc->ensureUpToDate();1179 doc->ensureUpToDate();
@@ -1435,7 +1432,7 @@
1435 g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored.");1432 g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored.");
1436 }1433 }
14371434
1438 GSList *items = NULL;1435 std::vector<SPItem*> items;
14391436
1440 Geom::Rect area;1437 Geom::Rect area;
1441 if (sp_export_id || sp_export_area_drawing) {1438 if (sp_export_id || sp_export_area_drawing) {
@@ -1459,7 +1456,7 @@
1459 return 1;1456 return 1;
1460 }1457 }
14611458
1462 items = g_slist_prepend (items, SP_ITEM(o));1459 items.push_back(SP_ITEM(o));
14631460
1464 if (sp_export_id_only) {1461 if (sp_export_id_only) {
1465 g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id);1462 g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id);
@@ -1644,10 +1641,12 @@
1644 g_print("Background RRGGBBAA: %08x\n", bgcolor);1641 g_print("Background RRGGBBAA: %08x\n", bgcolor);
16451642
1646 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);1643 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);
16471644
1645 reverse(items.begin(),items.end());
1646
1648 if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {1647 if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) {
1649 if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi,1648 if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi,
1650 dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL) == 1 ) {1649 dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector<SPItem*>()) == 1 ) {
1651 g_print("Bitmap saved as: %s\n", filename.c_str());1650 g_print("Bitmap saved as: %s\n", filename.c_str());
1652 } else {1651 } else {
1653 g_warning("Bitmap failed to save to: %s", filename.c_str());1652 g_warning("Bitmap failed to save to: %s", filename.c_str());
@@ -1657,7 +1656,6 @@
1657 }1656 }
1658 }1657 }
16591658
1660 g_slist_free (items);
1661 return retcode;1659 return retcode;
1662}1660}
16631661
16641662
=== modified file 'src/object-snapper.cpp'
--- src/object-snapper.cpp 2014-11-10 17:39:33 +0000
+++ src/object-snapper.cpp 2015-04-29 21:03:59 +0000
@@ -237,8 +237,9 @@
237 // current selection (see the comment in SelTrans::centerRequest())237 // current selection (see the comment in SelTrans::centerRequest())
238 bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER);238 bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER);
239 if (old_pref2) {239 if (old_pref2) {
240 for ( GSList const *itemlist = _snapmanager->getRotationCenterSource(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) {240 std::vector<SPItem*> rotationSource=_snapmanager->getRotationCenterSource();
241 if ((*i).item == reinterpret_cast<SPItem*>(itemlist->data)) {241 for ( std::vector<SPItem*>::const_iterator itemlist = rotationSource.begin(); itemlist != rotationSource.end(); itemlist++) {
242 if ((*i).item == *itemlist) {
242 // don't snap to this item's rotation center243 // don't snap to this item's rotation center
243 _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false);244 _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false);
244 break;245 break;
245246
=== modified file 'src/object-test.h'
--- src/object-test.h 2015-02-21 16:23:30 +0000
+++ src/object-test.h 2015-04-29 21:03:59 +0000
@@ -204,7 +204,8 @@
204 assert(n_group != NULL);204 assert(n_group != NULL);
205205
206 begin = clock();206 begin = clock();
207 sp_item_group_ungroup(n_group, NULL, false);207 std::vector<SPItem*> ch;
208 sp_item_group_ungroup(n_group, ch, false);
208 end = clock();209 end = clock();
209210
210 std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to ungroup a <g> with " << num_elements << " elements\n";211 std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to ungroup a <g> with " << num_elements << " elements\n";
211212
=== modified file 'src/path-chemistry.cpp'
--- src/path-chemistry.cpp 2015-04-28 14:26:17 +0000
+++ src/path-chemistry.cpp 2015-04-29 21:03:59 +0000
@@ -44,13 +44,22 @@
4444
45using Inkscape::DocumentUndo;45using Inkscape::DocumentUndo;
4646
47
48inline bool less_than_items(SPItem const *first, SPItem const *second)
49{
50 return sp_repr_compare_position(first->getRepr(),
51 second->getRepr())<0;
52}
53
47void54void
48sp_selected_path_combine(SPDesktop *desktop)55sp_selected_path_combine(SPDesktop *desktop)
49{56{
50 Inkscape::Selection *selection = desktop->getSelection();57 Inkscape::Selection *selection = desktop->getSelection();
51 SPDocument *doc = desktop->getDocument();58 SPDocument *doc = desktop->getDocument();
59
60 std::vector<SPItem*> items(selection->itemList());
52 61
53 if (g_slist_length((GSList *) selection->itemList()) < 1) {62 if (items.size() < 1) {
54 desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine."));63 desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine."));
55 return;64 return;
56 }65 }
@@ -59,28 +68,23 @@
59 // set "busy" cursor68 // set "busy" cursor
60 desktop->setWaitingCursor();69 desktop->setWaitingCursor();
6170
62 GSList *items = g_slist_copy((GSList *) selection->itemList());
63
64 items = sp_degroup_list (items); // descend into any groups in selection71 items = sp_degroup_list (items); // descend into any groups in selection
6572
66 GSList *to_paths = NULL;73 std::vector<SPItem*> to_paths;
67 for (GSList *i = items; i != NULL; i = i->next) {74 for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) {
68 SPItem *item = (SPItem *) i->data;75 if (!dynamic_cast<SPPath *>(*i) && !dynamic_cast<SPGroup *>(*i)) {
69 if (!dynamic_cast<SPPath *>(item) && !dynamic_cast<SPGroup *>(item)) {76 to_paths.push_back(*i);
70 to_paths = g_slist_prepend(to_paths, item);
71 }77 }
72 }78 }
73 GSList *converted = NULL;79 std::vector<Inkscape::XML::Node*> converted;
74 bool did = sp_item_list_to_curves(to_paths, &items, &converted);80 bool did = sp_item_list_to_curves(to_paths, items, converted);
75 g_slist_free(to_paths);81 for (std::vector<Inkscape::XML::Node*>::const_iterator i = converted.begin(); i != converted.end(); i++)
76 for (GSList *i = converted; i != NULL; i = i->next)82 items.push_back((SPItem*)doc->getObjectByRepr(*i));
77 items = g_slist_prepend(items, doc->getObjectByRepr((Inkscape::XML::Node*)(i->data)));
7883
79 items = sp_degroup_list (items); // converting to path may have added more groups, descend again84 items = sp_degroup_list (items); // converting to path may have added more groups, descend again
8085
81 items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position);86 sort(items.begin(),items.end(),less_than_items);
82 items = g_slist_reverse(items);87 assert(!items.empty()); // cannot be NULL because of list length check at top of function
83 assert(items); // cannot be NULL because of list length check at top of function
8488
85 // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one89 // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one
86 gint position = 0;90 gint position = 0;
@@ -97,9 +101,9 @@
97 selection->clear();101 selection->clear();
98 }102 }
99103
100 for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom104 for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++){
101105
102 SPItem *item = (SPItem *) i->data;106 SPItem *item = *i;
103 SPPath *path = dynamic_cast<SPPath *>(item);107 SPPath *path = dynamic_cast<SPPath *>(item);
104 if (!path) {108 if (!path) {
105 continue;109 continue;
@@ -136,7 +140,6 @@
136 }140 }
137 }141 }
138142
139 g_slist_free(items);
140143
141 if (did) {144 if (did) {
142 first->deleteObject(false);145 first->deleteObject(false);
@@ -200,11 +203,10 @@
200203
201 bool did = false;204 bool did = false;
202205
203 for (GSList *items = g_slist_copy((GSList *) selection->itemList());206 std::vector<SPItem*> itemlist(selection->itemList());
204 items != NULL;207 for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++){
205 items = items->next) {
206208
207 SPItem *item = (SPItem *) items->data;209 SPItem *item = *i;
208210
209 SPPath *path = dynamic_cast<SPPath *>(item);211 SPPath *path = dynamic_cast<SPPath *>(item);
210 if (!path) {212 if (!path) {
@@ -241,7 +243,7 @@
241243
242 curve->unref();244 curve->unref();
243245
244 GSList *reprs = NULL;246 std::vector<Inkscape::XML::Node*> reprs;
245 for (GSList *l = list; l != NULL; l = l->next) {247 for (GSList *l = list; l != NULL; l = l->next) {
246 curve = (SPCurve *) l->data;248 curve = (SPCurve *) l->data;
247249
@@ -267,14 +269,12 @@
267 if (l == list)269 if (l == list)
268 repr->setAttribute("id", id);270 repr->setAttribute("id", id);
269271
270 reprs = g_slist_prepend (reprs, repr);272 reprs.push_back(repr);
271273
272 Inkscape::GC::release(repr);274 Inkscape::GC::release(repr);
273 }275 }
274
275 selection->setReprList(reprs);276 selection->setReprList(reprs);
276277
277 g_slist_free(reprs);
278 g_slist_free(list);278 g_slist_free(list);
279 g_free(style);279 g_free(style);
280 g_free(path_effect);280 g_free(path_effect);
@@ -307,18 +307,15 @@
307 desktop->setWaitingCursor();307 desktop->setWaitingCursor();
308 }308 }
309309
310 GSList *selected = g_slist_copy((GSList *) selection->itemList());310 std::vector<SPItem*> selected(selection->itemList());
311 GSList *to_select = NULL;311 std::vector<Inkscape::XML::Node*> to_select;
312 selection->clear();312 selection->clear();
313 GSList *items = g_slist_copy(selected);313 std::vector<SPItem*> items(selected);
314314
315 did = sp_item_list_to_curves(items, &selected, &to_select);315 did = sp_item_list_to_curves(items, selected, to_select);
316316
317 g_slist_free (items);
318 selection->setReprList(to_select);317 selection->setReprList(to_select);
319 selection->addList(selected);318 selection->addList(selected);
320 g_slist_free (to_select);
321 g_slist_free (selected);
322319
323 if (interactive && desktop) {320 if (interactive && desktop) {
324 desktop->clearWaitingCursor();321 desktop->clearWaitingCursor();
@@ -341,33 +338,24 @@
341 return;338 return;
342 }339 }
343340
344 GSList *selected = g_slist_copy((GSList *) selection->itemList());341 std::vector<SPItem*> selected(selection->itemList());
345 GSList *to_select = NULL;342 std::vector<Inkscape::XML::Node*> to_select;
346 selection->clear();343 selection->clear();
347 GSList *items = g_slist_copy(selected);344 std::vector<SPItem*> items(selected);
348345
349 sp_item_list_to_curves(items, &selected, &to_select, true);346
350347 sp_item_list_to_curves(items, selected, to_select, true);
351 g_slist_free(items);348
352 items = 0;
353 selection->setReprList(to_select);349 selection->setReprList(to_select);
354 selection->addList(selected);350 selection->addList(selected);
355 g_slist_free(to_select);
356 to_select = 0;
357 g_slist_free(selected);
358 selected = 0;
359}351}
360352
361bool353bool
362sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems)354sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& selected, std::vector<Inkscape::XML::Node*> &to_select, bool skip_all_lpeitems)
363{355{
364 bool did = false;356 bool did = false;
365357 for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){
366 for (;358 SPItem *item = *i;
367 items != NULL;
368 items = items->next) {
369
370 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
371 g_assert(item != NULL);359 g_assert(item != NULL);
372 SPDocument *document = item->document;360 SPDocument *document = item->document;
373361
@@ -398,9 +386,9 @@
398 Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr();386 Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr();
399 387
400 if (repr) {388 if (repr) {
401 *to_select = g_slist_prepend (*to_select, repr);389 to_select.insert(to_select.begin(),repr);
402 did = true;390 did = true;
403 *selected = g_slist_remove (*selected, item);391 selected.erase(find(selected.begin(),selected.end(),item));
404 }392 }
405393
406 continue;394 continue;
@@ -408,17 +396,14 @@
408 396
409 if (group) {397 if (group) {
410 group->removeAllPathEffects(true);398 group->removeAllPathEffects(true);
411 GSList *item_list = sp_item_group_item_list(group);399 std::vector<SPItem*> item_list = sp_item_group_item_list(group);
412 400
413 GSList *item_to_select = NULL;401 std::vector<Inkscape::XML::Node*> item_to_select;
414 GSList *item_selected = NULL;402 std::vector<SPItem*> item_selected;
415 403
416 if (sp_item_list_to_curves(item_list, &item_selected, &item_to_select))404 if (sp_item_list_to_curves(item_list, item_selected, item_to_select))
417 did = true;405 did = true;
418406
419 g_slist_free(item_list);
420 g_slist_free(item_to_select);
421 g_slist_free(item_selected);
422407
423 continue;408 continue;
424 }409 }
@@ -428,7 +413,7 @@
428 continue;413 continue;
429414
430 did = true;415 did = true;
431 *selected = g_slist_remove (*selected, item);416 selected.erase(find(selected.begin(),selected.end(),item));
432417
433 // remember the position of the item418 // remember the position of the item
434 gint pos = item->getRepr()->position();419 gint pos = item->getRepr()->position();
@@ -470,7 +455,7 @@
470455
471 /* Buglet: We don't re-add the (new version of the) object to the selection of any other456 /* Buglet: We don't re-add the (new version of the) object to the selection of any other
472 * desktops where it was previously selected. */457 * desktops where it was previously selected. */
473 *to_select = g_slist_prepend (*to_select, repr);458 to_select.insert(to_select.begin(),repr);
474 Inkscape::GC::release(repr);459 Inkscape::GC::release(repr);
475 }460 }
476 461
@@ -622,9 +607,9 @@
622sp_selected_path_reverse(SPDesktop *desktop)607sp_selected_path_reverse(SPDesktop *desktop)
623{608{
624 Inkscape::Selection *selection = desktop->getSelection();609 Inkscape::Selection *selection = desktop->getSelection();
625 GSList *items = (GSList *) selection->itemList();610 std::vector<SPItem*> items = selection->itemList();
626611
627 if (!items) {612 if (items.empty()) {
628 desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));613 desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
629 return;614 return;
630 }615 }
@@ -636,9 +621,9 @@
636 bool did = false;621 bool did = false;
637 desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));622 desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));
638623
639 for (GSList *i = items; i != NULL; i = i->next) {624 for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){
640625
641 SPPath *path = dynamic_cast<SPPath *>(static_cast<SPObject *>(i->data));626 SPPath *path = dynamic_cast<SPPath *>(*i);
642 if (!path) {627 if (!path) {
643 continue;628 continue;
644 }629 }
645630
=== modified file 'src/path-chemistry.h'
--- src/path-chemistry.h 2014-10-08 02:22:03 +0000
+++ src/path-chemistry.h 2015-04-29 21:03:59 +0000
@@ -33,7 +33,7 @@
33void sp_selected_to_lpeitems(SPDesktop *desktop);33void sp_selected_to_lpeitems(SPDesktop *desktop);
34Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy);34Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy);
35void sp_selected_path_reverse (SPDesktop *desktop);35void sp_selected_path_reverse (SPDesktop *desktop);
36bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems = false);36bool sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*> &selected, std::vector<Inkscape::XML::Node*> &to_select, bool skip_all_lpeitems = false);
3737
38#endif // SEEN_PATH_CHEMISTRY_H38#endif // SEEN_PATH_CHEMISTRY_H
3939
4040
=== modified file 'src/removeoverlap.cpp'
--- src/removeoverlap.cpp 2014-03-27 01:33:44 +0000
+++ src/removeoverlap.cpp 2015-04-29 21:03:59 +0000
@@ -38,20 +38,19 @@
38* such that rectangular bounding boxes are separated by at least xGap38* such that rectangular bounding boxes are separated by at least xGap
39* horizontally and yGap vertically39* horizontally and yGap vertically
40*/40*/
41void removeoverlap(GSList const *const items, double const xGap, double const yGap) {41void removeoverlap(std::vector<SPItem*> const &items, double const xGap, double const yGap) {
42 using Inkscape::Util::GSListConstIterator;42 std::vector<SPItem*> selected(items);
43 std::list<SPItem *> selected;
44 selected.insert<GSListConstIterator<SPItem *> >(selected.end(), items, NULL);
45 std::vector<Record> records;43 std::vector<Record> records;
46 std::vector<Rectangle *> rs;44 std::vector<Rectangle *> rs;
4745
48 Geom::Point const gap(xGap, yGap);46 Geom::Point const gap(xGap, yGap);
49 for (std::list<SPItem *>::iterator it(selected.begin());47 for (std::vector<SPItem*>::iterator it(selected.begin());
50 it != selected.end();48 it != selected.end();
51 ++it)49 ++it)
52 {50 {
51 SPItem* item = *it;
53 using Geom::X; using Geom::Y;52 using Geom::X; using Geom::Y;
54 Geom::OptRect item_box((*it)->desktopVisualBounds());53 Geom::OptRect item_box((item)->desktopVisualBounds());
55 if (item_box) {54 if (item_box) {
56 Geom::Point min(item_box->min() - .5*gap);55 Geom::Point min(item_box->min() - .5*gap);
57 Geom::Point max(item_box->max() + .5*gap);56 Geom::Point max(item_box->max() + .5*gap);
@@ -67,7 +66,7 @@
67 min[Y] = max[Y] = (min[Y] + max[Y])/2;66 min[Y] = max[Y] = (min[Y] + max[Y])/2;
68 }67 }
69 Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]);68 Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]);
70 records.push_back(Record(*it, item_box->midpoint(), vspc_rect));69 records.push_back(Record(item, item_box->midpoint(), vspc_rect));
71 rs.push_back(vspc_rect);70 rs.push_back(vspc_rect);
72 }71 }
73 }72 }
7473
=== modified file 'src/removeoverlap.h'
--- src/removeoverlap.h 2014-10-08 02:22:03 +0000
+++ src/removeoverlap.h 2015-04-29 21:03:59 +0000
@@ -15,6 +15,6 @@
1515
16typedef struct _GSList GSList;16typedef struct _GSList GSList;
1717
18void removeoverlap(GSList const *items, double xGap, double yGap);18void removeoverlap(std::vector<SPItem*> const &items, double xGap, double yGap);
1919
20#endif // SEEN_REMOVEOVERLAP_H20#endif // SEEN_REMOVEOVERLAP_H
2121
=== modified file 'src/selcue.cpp'
--- src/selcue.cpp 2014-12-21 21:58:32 +0000
+++ src/selcue.cpp 2015-04-29 21:03:59 +0000
@@ -96,15 +96,16 @@
9696
97void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox)97void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox)
98{98{
99 GSList const *items = _selection->itemList();99 const std::vector<SPItem*> items = _selection->itemList();
100 if (_item_bboxes.size() != g_slist_length((GSList *) items)) {100 if (_item_bboxes.size() != items.size()) {
101 _newItemBboxes();101 _newItemBboxes();
102 return;102 return;
103 }103 }
104104
105 int bcount = 0;105 int bcount = 0;
106 for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {106 std::vector<SPItem*> ll=_selection->itemList();
107 SPItem *item = static_cast<SPItem *>(l->data);107 for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) {
108 SPItem *item = *l;
108 SPCanvasItem* box = _item_bboxes[bcount ++];109 SPCanvasItem* box = _item_bboxes[bcount ++];
109110
110 if (box) {111 if (box) {
@@ -145,8 +146,9 @@
145146
146 int prefs_bbox = prefs->getBool("/tools/bounding_box");147 int prefs_bbox = prefs->getBool("/tools/bounding_box");
147 148
148 for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {149 std::vector<SPItem*> ll=_selection->itemList();
149 SPItem *item = static_cast<SPItem *>(l->data);150 for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) {
151 SPItem *item = *l;
150152
151 Geom::OptRect const b = (prefs_bbox == 0) ?153 Geom::OptRect const b = (prefs_bbox == 0) ?
152 item->desktopVisualBounds() : item->desktopGeometricBounds();154 item->desktopVisualBounds() : item->desktopGeometricBounds();
@@ -199,8 +201,9 @@
199 }201 }
200 _text_baselines.clear();202 _text_baselines.clear();
201203
202 for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {204 std::vector<SPItem*> ll = _selection->itemList();
203 SPItem *item = static_cast<SPItem *>(l->data);205 for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) {
206 SPItem *item = *l;
204207
205 SPCanvasItem* baseline_point = NULL;208 SPCanvasItem* baseline_point = NULL;
206 if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline209 if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline
207210
=== modified file 'src/selection-chemistry.cpp'
--- src/selection-chemistry.cpp 2015-02-21 16:23:30 +0000
+++ src/selection-chemistry.cpp 2015-04-29 21:03:59 +0000
@@ -279,25 +279,21 @@
279279
280 Inkscape::Selection *selection = dt->getSelection();280 Inkscape::Selection *selection = dt->getSelection();
281 281
282 GSList *items = NULL;282 std::vector<SPItem*> items ;
283283
284 GSList const *selList = selection->itemList();284 std::vector<SPItem*> const selList = selection->itemList();
285285
286 for( GSList const *i = selList; i; i = i->next ) {286 for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++ ) {
287 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));287 SPItem *item = *i;
288 if( item &&288 if( item &&
289 !dt->isLayer(item) &&289 !dt->isLayer(item) &&
290 (!item->isLocked()))290 (!item->isLocked()))
291 {291 {
292 items = g_slist_prepend(items, item);292 items.push_back(item);
293 }293 }
294 }294 }
295295
296 selection->setList(items);296 selection->setList(items);
297
298 if(items) {
299 g_slist_free(items);
300 }
301}297}
302298
303} // namespace Inkscape299} // namespace Inkscape
@@ -307,7 +303,7 @@
307 * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',303 * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',
308 * then prepends the copy to 'clip'.304 * then prepends the copy to 'clip'.
309 */305 */
310static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc)306static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc)
311{307{
312 Inkscape::XML::Node *copy = repr->duplicate(xml_doc);308 Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
313309
@@ -323,41 +319,39 @@
323 copy->setAttribute("transform", affinestr);319 copy->setAttribute("transform", affinestr);
324 g_free(affinestr);320 g_free(affinestr);
325321
326 *clip = g_slist_prepend(*clip, copy);322 clip.insert(clip.begin(),copy);
327}323}
328324
329static void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc)325static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc)
330{326{
331 // Sort items:327 // Sort items:
332 GSList *sorted_items = g_slist_copy(const_cast<GSList *>(items));328 std::vector<SPItem*> sorted_items(items);
333 sorted_items = g_slist_sort(static_cast<GSList *>(sorted_items), (GCompareFunc) sp_object_compare_position);329 sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position);
334330
335 // Copy item reprs:331 // Copy item reprs:
336 for (GSList *i = sorted_items; i != NULL; i = i->next) {332 for (std::vector<SPItem*>::const_iterator i = sorted_items.begin(); i != sorted_items.end(); i++) {
337 SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(i->data));333 SPItem *item = *i;
338 if (item) {334 if (item) {
339 sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc);335 sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc);
340 } else {336 } else {
341 g_assert_not_reached();337 g_assert_not_reached();
342 }338 }
343 }339 }
344340 reverse(clip.begin(),clip.end());
345 *clip = g_slist_reverse(*clip);
346 g_slist_free(static_cast<GSList *>(sorted_items));
347}341}
348342
349// TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items.343// TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items.
350static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip)344static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<Inkscape::XML::Node*> &clip)
351{345{
352 Inkscape::XML::Document *xml_doc = doc->getReprDoc();346 Inkscape::XML::Document *xml_doc = doc->getReprDoc();
353347
354 SPItem *parentItem = dynamic_cast<SPItem *>(parent);348 SPItem *parentItem = dynamic_cast<SPItem *>(parent);
355 g_assert(parentItem != NULL);349 g_assert(parentItem != NULL);
356350
357 GSList *copied = NULL;351 std::vector<Inkscape::XML::Node*> copied;
358 // add objects to document352 // add objects to document
359 for (GSList *l = *clip; l != NULL; l = l->next) {353 for (std::vector<Inkscape::XML::Node*>::const_iterator l = clip.begin(); l != clip.end(); l++) {
360 Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data);354 Inkscape::XML::Node *repr = *l;
361 Inkscape::XML::Node *copy = repr->duplicate(xml_doc);355 Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
362356
363 // premultiply the item transform by the accumulated parent transform in the paste layer357 // premultiply the item transform by the accumulated parent transform in the paste layer
@@ -375,19 +369,19 @@
375 }369 }
376370
377 parent->appendChildRepr(copy);371 parent->appendChildRepr(copy);
378 copied = g_slist_prepend(copied, copy);372 copied.push_back(copy);
379 Inkscape::GC::release(copy);373 Inkscape::GC::release(copy);
380 }374 }
381 return copied;375 return copied;
382}376}
383377
384static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true)378static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool propagate = true, bool propagate_descendants = true)
385{379{
386 for (GSList const *i = items ; i ; i = i->next ) {380 for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
387 sp_object_ref(static_cast<SPItem *>(i->data), NULL);381 sp_object_ref(*i, NULL);
388 }382 }
389 for (GSList const *i = items; i != NULL; i = i->next) {383 for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
390 SPItem *item = static_cast<SPItem *>(i->data);384 SPItem *item = *i;
391 item->deleteObject(propagate, propagate_descendants);385 item->deleteObject(propagate, propagate_descendants);
392 sp_object_unref(item, NULL);386 sp_object_unref(item, NULL);
393 }387 }
@@ -414,11 +408,9 @@
414 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted."));408 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted."));
415 return;409 return;
416 }410 }
417411 std::vector<SPItem*> selected(selection->itemList());
418 GSList *selected = g_slist_copy(const_cast<GSList *>(selection->itemList()));
419 selection->clear();412 selection->clear();
420 sp_selection_delete_impl(selected);413 sp_selection_delete_impl(selected);
421 g_slist_free(selected);
422 desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);414 desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
423415
424 /* a tool may have set up private information in it's selection context416 /* a tool may have set up private information in it's selection context
@@ -461,16 +453,15 @@
461 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate."));453 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate."));
462 return;454 return;
463 }455 }
464456 std::vector<Inkscape::XML::Node*> reprs(selection->reprList());
465 GSList *reprs = g_slist_copy(const_cast<GSList *>(selection->reprList()));
466457
467 selection->clear();458 selection->clear();
468459
469 // sorting items from different parents sorts each parent's subset without possibly mixing460 // sorting items from different parents sorts each parent's subset without possibly mixing
470 // them, just what we need461 // them, just what we need
471 reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position);462 sort(reprs.begin(),reprs.end(),sp_repr_compare_position);
472463
473 GSList *newsel = NULL;464 std::vector<Inkscape::XML::Node*> newsel;
474465
475 std::vector<const gchar *> old_ids;466 std::vector<const gchar *> old_ids;
476 std::vector<const gchar *> new_ids;467 std::vector<const gchar *> new_ids;
@@ -478,8 +469,8 @@
478 bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value");469 bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value");
479 const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true);470 const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true);
480471
481 while (reprs) {472 for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){
482 Inkscape::XML::Node *old_repr = static_cast<Inkscape::XML::Node *>(reprs->data);473 Inkscape::XML::Node *old_repr = *i;
483 Inkscape::XML::Node *parent = old_repr->parent();474 Inkscape::XML::Node *parent = old_repr->parent();
484 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);475 Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
485476
@@ -500,8 +491,7 @@
500 }491 }
501 }492 }
502493
503 newsel = g_slist_prepend(newsel, copy);494 newsel.push_back(copy);
504 reprs = g_slist_remove(reprs, reprs->data);
505 Inkscape::GC::release(copy);495 Inkscape::GC::release(copy);
506 }496 }
507497
@@ -547,8 +537,6 @@
547 }537 }
548538
549 selection->setReprList(newsel);539 selection->setReprList(newsel);
550
551 g_slist_free(newsel);
552}540}
553541
554void sp_edit_clear_all(Inkscape::Selection *selection)542void sp_edit_clear_all(Inkscape::Selection *selection)
@@ -561,11 +549,10 @@
561549
562 SPGroup *group = dynamic_cast<SPGroup *>(selection->layers()->currentLayer());550 SPGroup *group = dynamic_cast<SPGroup *>(selection->layers()->currentLayer());
563 g_return_if_fail(group != NULL);551 g_return_if_fail(group != NULL);
564 GSList *items = sp_item_group_item_list(group);552 std::vector<SPItem*> items = sp_item_group_item_list(group);
565553
566 while (items) {554 for(unsigned int i = 0; i < items.size(); i++){
567 reinterpret_cast<SPObject*>(items->data)->deleteObject();555 items[i]->deleteObject();
568 items = g_slist_remove(items, items->data);
569 }556 }
570557
571 DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL,558 DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL,
@@ -582,7 +569,7 @@
582 * onlysensitive - TRUE includes only non-locked items569 * onlysensitive - TRUE includes only non-locked items
583 * ingroups - TRUE to recursively get grouped items children570 * ingroups - TRUE to recursively get grouped items children
584 */571 */
585GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude)572std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude)
586{573{
587 for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) {574 for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) {
588 SPItem *item = dynamic_cast<SPItem *>(child);575 SPItem *item = dynamic_cast<SPItem *>(child);
@@ -590,10 +577,10 @@
590 !desktop->isLayer(item) &&577 !desktop->isLayer(item) &&
591 (!onlysensitive || !item->isLocked()) &&578 (!onlysensitive || !item->isLocked()) &&
592 (!onlyvisible || !desktop->itemIsHidden(item)) &&579 (!onlyvisible || !desktop->itemIsHidden(item)) &&
593 (!exclude || !g_slist_find(const_cast<GSList *>(exclude), child))580 (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child))
594 )581 )
595 {582 {
596 list = g_slist_prepend(list, item);583 list.insert(list.begin(),item);
597 }584 }
598585
599 if (ingroups || (item && desktop->isLayer(item))) {586 if (ingroups || (item && desktop->isLayer(item))) {
@@ -618,9 +605,9 @@
618 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);605 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
619 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);606 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
620607
621 GSList *items = NULL;608 std::vector<SPItem*> items ;
622609
623 GSList const *exclude = NULL;610 std::vector<SPItem*> exclude;
624 if (invert) {611 if (invert) {
625 exclude = selection->itemList();612 exclude = selection->itemList();
626 }613 }
@@ -634,40 +621,38 @@
634 (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))) )621 (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))) )
635 return;622 return;
636623
637 GSList *all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer()));624 std::vector<SPItem*> all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer()));
638625
639 for (GSList *i = all_items; i; i = i->next) {626 for (std::vector<SPItem*>::const_reverse_iterator i=all_items.rbegin();i!=all_items.rend();i++) {
640 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));627 SPItem *item = *i;
641628
642 if (item && (!onlysensitive || !item->isLocked())) {629 if (item && (!onlysensitive || !item->isLocked())) {
643 if (!onlyvisible || !dt->itemIsHidden(item)) {630 if (!onlyvisible || !dt->itemIsHidden(item)) {
644 if (!dt->isLayer(item)) {631 if (!dt->isLayer(item)) {
645 if (!invert || !g_slist_find(const_cast<GSList *>(exclude), item)) {632 if (!invert || exclude.end() == std::find(exclude.begin(),exclude.end(),item)) {
646 items = g_slist_prepend(items, item); // leave it in the list633 items.push_back(item); // leave it in the list
647 }634 }
648 }635 }
649 }636 }
650 }637 }
651 }638 }
652639
653 g_slist_free(all_items);
654 break;640 break;
655 }641 }
656 case PREFS_SELECTION_LAYER_RECURSIVE: {642 case PREFS_SELECTION_LAYER_RECURSIVE: {
657 items = get_all_items(NULL, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude);643 std::vector<SPItem*> x;
644 items = get_all_items(x, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude);
658 break;645 break;
659 }646 }
660 default: {647 default: {
661 items = get_all_items(NULL, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude);648 std::vector<SPItem*> x;
649 items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude);
662 break;650 break;
663 }651 }
664 }652 }
665653
666 selection->setList(items);654 selection->setList(items);
667655
668 if (items) {
669 g_slist_free(items);
670 }
671}656}
672657
673void sp_edit_select_all(SPDesktop *desktop)658void sp_edit_select_all(SPDesktop *desktop)
@@ -690,16 +675,16 @@
690 sp_edit_select_all_full(desktop, true, true);675 sp_edit_select_all_full(desktop, true, true);
691}676}
692677
693static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) {678static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) {
694679
695 p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position);680 sort(p.begin(),p.end(),sp_repr_compare_position);
696681
697 // Remember the position and parent of the topmost object.682 // Remember the position and parent of the topmost object.
698 gint topmost = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->position();683 gint topmost = p.back()->position();
699 Inkscape::XML::Node *topmost_parent = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->parent();684 Inkscape::XML::Node *topmost_parent = p.back()->parent();
700685
701 while (p) {686 for(std::vector<Inkscape::XML::Node*>::const_iterator i = p.begin(); i != p.end(); i++){
702 Inkscape::XML::Node *current = static_cast<Inkscape::XML::Node *>(p->data);687 Inkscape::XML::Node *current = *i;
703688
704 if (current->parent() == topmost_parent) {689 if (current->parent() == topmost_parent) {
705 Inkscape::XML::Node *spnew = current->duplicate(xml_doc);690 Inkscape::XML::Node *spnew = current->duplicate(xml_doc);
@@ -708,7 +693,7 @@
708 Inkscape::GC::release(spnew);693 Inkscape::GC::release(spnew);
709 topmost --; // only reduce count for those items deleted from topmost_parent694 topmost --; // only reduce count for those items deleted from topmost_parent
710 } else { // move it to topmost_parent first695 } else { // move it to topmost_parent first
711 GSList *temp_clip = NULL;696 std::vector<Inkscape::XML::Node*> temp_clip;
712697
713 // At this point, current may already have no item, due to its being a clone whose original is already moved away698 // At this point, current may already have no item, due to its being a clone whose original is already moved away
714 // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform699 // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform
@@ -724,15 +709,15 @@
724 // then, if this is clone, looking up its original in that array and pre-multiplying709 // then, if this is clone, looking up its original in that array and pre-multiplying
725 // it by the inverse of that original's transform diff.710 // it by the inverse of that original's transform diff.
726711
727 sp_selection_copy_one(current, item_t, &temp_clip, xml_doc);712 sp_selection_copy_one(current, item_t, temp_clip, xml_doc);
728 sp_repr_unparent(current);713 sp_repr_unparent(current);
729714
730 // paste into topmost_parent (temporarily)715 // paste into topmost_parent (temporarily)
731 GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip);716 std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
732 if (temp_clip) g_slist_free(temp_clip);717 if (!temp_clip.empty())temp_clip.clear() ;
733 if (copied) { // if success,718 if (!copied.empty()) { // if success,
734 // take pasted object (now in topmost_parent)719 // take pasted object (now in topmost_parent)
735 Inkscape::XML::Node *in_topmost = static_cast<Inkscape::XML::Node *>(copied->data);720 Inkscape::XML::Node *in_topmost = copied.back();
736 // make a copy721 // make a copy
737 Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc);722 Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc);
738 // remove pasted723 // remove pasted
@@ -740,10 +725,9 @@
740 // put its copy into group725 // put its copy into group
741 group->appendChild(spnew);726 group->appendChild(spnew);
742 Inkscape::GC::release(spnew);727 Inkscape::GC::release(spnew);
743 g_slist_free(copied);728 copied.clear();
744 }729 }
745 }730 }
746 p = g_slist_remove(p, current);
747 }731 }
748732
749 // Add the new group to the topmost members' parent733 // Add the new group to the topmost members' parent
@@ -764,9 +748,7 @@
764 return;748 return;
765 }749 }
766750
767 GSList const *l = const_cast<GSList *>(selection->reprList());751 std::vector<Inkscape::XML::Node*> p (selection->reprList());
768
769 GSList *p = g_slist_copy(const_cast<GSList *>(l));
770752
771 selection->clear();753 selection->clear();
772754
@@ -802,11 +784,11 @@
802 }784 }
803785
804 // first check whether there is anything to ungroup786 // first check whether there is anything to ungroup
805 GSList *old_select = const_cast<GSList *>(selection->itemList());787 std::vector<SPItem*> old_select = selection->itemList();
806 GSList *new_select = NULL;788 std::vector<SPItem*> new_select;
807 GSList *groups = NULL;789 GSList *groups = NULL;
808 for (GSList *item = old_select; item; item = item->next) {790 for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); item++) {
809 SPItem *obj = static_cast<SPItem*>(item->data);791 SPItem *obj = *item;
810 if (dynamic_cast<SPGroup *>(obj)) {792 if (dynamic_cast<SPGroup *>(obj)) {
811 groups = g_slist_prepend(groups, obj);793 groups = g_slist_prepend(groups, obj);
812 }794 }
@@ -818,14 +800,14 @@
818 return;800 return;
819 }801 }
820802
821 GSList *items = g_slist_copy(old_select);803 std::vector<SPItem*> items(old_select);
822 selection->clear();804 selection->clear();
823805
824 // If any of the clones refer to the groups, unlink them and replace them with successors806 // If any of the clones refer to the groups, unlink them and replace them with successors
825 // in the items list.807 // in the items list.
826 GSList *clones_to_unlink = NULL;808 GSList *clones_to_unlink = NULL;
827 for (GSList *item = items; item; item = item->next) {809 for (std::vector<SPItem*>::const_iterator item = items.begin(); item != items.end(); item++) {
828 SPUse *use = dynamic_cast<SPUse *>(static_cast<SPItem *>(item->data));810 SPUse *use = dynamic_cast<SPUse *>(*item);
829811
830 SPItem *original = use;812 SPItem *original = use;
831 while (dynamic_cast<SPUse *>(original)) {813 while (dynamic_cast<SPUse *>(original)) {
@@ -833,7 +815,7 @@
833 }815 }
834816
835 if (g_slist_find(groups, original) != NULL) {817 if (g_slist_find(groups, original) != NULL) {
836 clones_to_unlink = g_slist_prepend(clones_to_unlink, item->data);818 clones_to_unlink = g_slist_prepend(clones_to_unlink, *item);
837 }819 }
838 }820 }
839821
@@ -844,57 +826,53 @@
844826
845 for (GSList *item = clones_to_unlink; item; item = item->next) {827 for (GSList *item = clones_to_unlink; item; item = item->next) {
846 SPUse *use = static_cast<SPUse *>(item->data);828 SPUse *use = static_cast<SPUse *>(item->data);
847 GSList *items_node = g_slist_find(items, item->data);829 std::vector<SPItem*>::iterator items_node = std::find(items.begin(),items.end(), item->data);
848 items_node->data = use->unlink();830 *items_node = use->unlink();
849 }831 }
850 g_slist_free(clones_to_unlink);832 g_slist_free(clones_to_unlink);
851833
852 // do the actual work834 // do the actual work
853 for (GSList *item = items; item; item = item->next) {835 for (std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); item++) {
854 SPItem *obj = static_cast<SPItem *>(item->data);836 SPItem *obj = *item;
855837
856 // ungroup only the groups marked earlier838 // ungroup only the groups marked earlier
857 if (g_slist_find(groups, item->data) != NULL) {839 if (g_slist_find(groups, *item) != NULL) {
858 GSList *children = NULL;840 std::vector<SPItem*> children;
859 sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), &children, false);841 sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), children, false);
860 // add the items resulting from ungrouping to the selection842 // add the items resulting from ungrouping to the selection
861 new_select = g_slist_concat(new_select, children);843 new_select.insert(new_select.end(),children.begin(),children.end());
862 item->data = NULL; // zero out the original pointer, which is no longer valid844 *item = NULL; // zero out the original pointer, which is no longer valid
863 } else {845 } else {
864 // if not a group, keep in the selection846 // if not a group, keep in the selection
865 new_select = g_slist_append(new_select, item->data);847 new_select.push_back(*item);
866 }848 }
867 }849 }
868850
869 selection->addList(new_select);851 selection->addList(new_select);
870 g_slist_free(new_select);
871 g_slist_free(items);
872852
873 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP,853 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP,
874 _("Ungroup"));854 _("Ungroup"));
875}855}
876856
877/** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */857/** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */
878GSList *858std::vector<SPItem*>
879sp_degroup_list(GSList *items)859sp_degroup_list(std::vector<SPItem*> &items)
880{860{
881 GSList *out = NULL;861 std::vector<SPItem*> out;
882 bool has_groups = false;862 bool has_groups = false;
883 for (GSList *item = items; item; item = item->next) {863 for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) {
884 SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(item->data));864 SPGroup *group = dynamic_cast<SPGroup *>(*item);
885 if (!group) {865 if (!group) {
886 out = g_slist_prepend(out, item->data);866 out.push_back(*item);
887 } else {867 } else {
888 has_groups = true;868 has_groups = true;
889 GSList *members = sp_item_group_item_list(group);869 std::vector<SPItem*> members = sp_item_group_item_list(group);
890 for (GSList *member = members; member; member = member->next) {870 for (std::vector<SPItem*>::const_iterator member=members.begin();member!=members.end();member++) {
891 out = g_slist_prepend(out, member->data);871 out.push_back(*member);
892 }872 }
893 g_slist_free(members);873 members.clear();
894 }874 }
895 }875 }
896 out = g_slist_reverse(out);
897 g_slist_free(items);
898876
899 if (has_groups) { // recurse if we unwrapped a group - it may have contained others877 if (has_groups) { // recurse if we unwrapped a group - it may have contained others
900 out = sp_degroup_list(out);878 out = sp_degroup_list(out);
@@ -906,18 +884,19 @@
906884
907/** If items in the list have a common parent, return it, otherwise return NULL */885/** If items in the list have a common parent, return it, otherwise return NULL */
908static SPGroup *886static SPGroup *
909sp_item_list_common_parent_group(GSList const *items)887sp_item_list_common_parent_group(std::vector<SPItem*> const items)
910{888{
911 if (!items) {889 if (items.empty()) {
912 return NULL;890 return NULL;
913 }891 }
914 SPObject *parent = SP_OBJECT(items->data)->parent;892 SPObject *parent = items[0]->parent;
915 // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor893 // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor
916 if (!dynamic_cast<SPGroup *>(parent)) {894 if (!dynamic_cast<SPGroup *>(parent)) {
917 return NULL;895 return NULL;
918 }896 }
919 for (items = items->next; items; items = items->next) {897 for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) {
920 if (SP_OBJECT(items->data)->parent != parent) {898 if((*item)==items[0])continue;
899 if ((*item)->parent != parent) {
921 return NULL;900 return NULL;
922 }901 }
923 }902 }
@@ -927,13 +906,13 @@
927906
928/** Finds out the minimum common bbox of the selected items. */907/** Finds out the minimum common bbox of the selected items. */
929static Geom::OptRect908static Geom::OptRect
930enclose_items(GSList const *items)909enclose_items(std::vector<SPItem*> const &items)
931{910{
932 g_assert(items != NULL);911 g_assert(!items.empty());
933912
934 Geom::OptRect r;913 Geom::OptRect r;
935 for (GSList const *i = items; i; i = i->next) {914 for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) {
936 r.unionWith(static_cast<SPItem *>(i->data)->desktopVisualBounds());915 r.unionWith((*i)->desktopVisualBounds());
937 }916 }
938 return r;917 return r;
939}918}
@@ -948,11 +927,17 @@
948 return prev;927 return prev;
949}928}
950929
930int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second)
931{
932 return sp_repr_compare_position(((SPItem*)first)->getRepr(),
933 ((SPItem*)second)->getRepr())<0;
934}
935
951void936void
952sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop)937sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop)
953{938{
954 GSList const *items = const_cast<GSList *>(selection->itemList());939 std::vector<SPItem*> items= selection->itemList();
955 if (!items) {940 if (items.empty()) {
956 selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise."));941 selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise."));
957 return;942 return;
958 }943 }
@@ -966,16 +951,16 @@
966 Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr());951 Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr());
967952
968 /* Construct reverse-ordered list of selected children. */953 /* Construct reverse-ordered list of selected children. */
969 GSList *rev = g_slist_copy(const_cast<GSList *>(items));954 std::vector<SPItem*> rev(items);
970 rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position);955 sort(rev.begin(),rev.end(),sp_item_repr_compare_position);
971956
972 // Determine the common bbox of the selected items.957 // Determine the common bbox of the selected items.
973 Geom::OptRect selected = enclose_items(items);958 Geom::OptRect selected = enclose_items(items);
974959
975 // Iterate over all objects in the selection (starting from top).960 // Iterate over all objects in the selection (starting from top).
976 if (selected) {961 if (selected) {
977 while (rev) {962 for (std::vector<SPItem*>::const_iterator item=rev.begin();item!=rev.end();item++) {
978 SPObject *child = reinterpret_cast<SPObject*>(rev->data);963 SPObject *child = *item;
979 // for each selected object, find the next sibling964 // for each selected object, find the next sibling
980 for (SPObject *newref = child->next; newref; newref = newref->next) {965 for (SPObject *newref = child->next; newref; newref = newref->next) {
981 // if the sibling is an item AND overlaps our selection,966 // if the sibling is an item AND overlaps our selection,
@@ -984,7 +969,7 @@
984 Geom::OptRect newref_bbox = newItem->desktopVisualBounds();969 Geom::OptRect newref_bbox = newItem->desktopVisualBounds();
985 if ( newref_bbox && selected->intersects(*newref_bbox) ) {970 if ( newref_bbox && selected->intersects(*newref_bbox) ) {
986 // AND if it's not one of our selected objects,971 // AND if it's not one of our selected objects,
987 if (!g_slist_find(const_cast<GSList *>(items), newref)) {972 if ( std::find(items.begin(),items.end(),newref)==items.end()) {
988 // move the selected object after that sibling973 // move the selected object after that sibling
989 grepr->changeOrder(child->getRepr(), newref->getRepr());974 grepr->changeOrder(child->getRepr(), newref->getRepr());
990 }975 }
@@ -992,12 +977,8 @@
992 }977 }
993 }978 }
994 }979 }
995 rev = g_slist_remove(rev, child);
996 }980 }
997 } else {
998 g_slist_free(rev);
999 }981 }
1000
1001 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE,982 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE,
1002 //TRANSLATORS: "Raise" means "to raise an object" in the undo history983 //TRANSLATORS: "Raise" means "to raise an object" in the undo history
1003 C_("Undo action", "Raise"));984 C_("Undo action", "Raise"));
@@ -1012,7 +993,7 @@
1012 return;993 return;
1013 }994 }
1014995
1015 GSList const *items = const_cast<GSList *>(selection->itemList());996 std::vector<SPItem*> items = selection->itemList();
1016997
1017 SPGroup const *group = sp_item_list_common_parent_group(items);998 SPGroup const *group = sp_item_list_common_parent_group(items);
1018 if (!group) {999 if (!group) {
@@ -1020,24 +1001,22 @@
1020 return;1001 return;
1021 }1002 }
10221003
1023 GSList *rl = g_slist_copy(const_cast<GSList *>(selection->reprList()));1004 std::vector<Inkscape::XML::Node*> rl(selection->reprList());
1024 rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position);1005 sort(rl.begin(),rl.end(),sp_repr_compare_position);
10251006
1026 for (GSList *l = rl; l != NULL; l = l->next) {1007 for (std::vector<Inkscape::XML::Node*>::const_iterator l=rl.begin(); l!=rl.end();l++) {
1027 Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data);1008 Inkscape::XML::Node *repr =(*l);
1028 repr->setPosition(-1);1009 repr->setPosition(-1);
1029 }1010 }
10301011
1031 g_slist_free(rl);
1032
1033 DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT,1012 DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT,
1034 _("Raise to top"));1013 _("Raise to top"));
1035}1014}
10361015
1037void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop)1016void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop)
1038{1017{
1039 GSList const *items = const_cast<GSList *>(selection->itemList());1018 std::vector<SPItem*> items = selection->itemList();
1040 if (!items) {1019 if (items.empty()) {
1041 selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower."));1020 selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower."));
1042 return;1021 return;
1043 }1022 }
@@ -1054,14 +1033,13 @@
1054 Geom::OptRect selected = enclose_items(items);1033 Geom::OptRect selected = enclose_items(items);
10551034
1056 /* Construct direct-ordered list of selected children. */1035 /* Construct direct-ordered list of selected children. */
1057 GSList *rev = g_slist_copy(const_cast<GSList *>(items));1036 std::vector<SPItem*> rev(items);
1058 rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position);1037 sort(rev.begin(),rev.end(),sp_item_repr_compare_position);
1059 rev = g_slist_reverse(rev);
10601038
1061 // Iterate over all objects in the selection (starting from top).1039 // Iterate over all objects in the selection (starting from top).
1062 if (selected) {1040 if (selected) {
1063 while (rev) {1041 for (std::vector<SPItem*>::const_reverse_iterator item=rev.rbegin();item!=rev.rend();item++) {
1064 SPObject *child = reinterpret_cast<SPObject*>(rev->data);1042 SPObject *child = *item;
1065 // for each selected object, find the prev sibling1043 // for each selected object, find the prev sibling
1066 for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) {1044 for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) {
1067 // if the sibling is an item AND overlaps our selection,1045 // if the sibling is an item AND overlaps our selection,
@@ -1070,7 +1048,7 @@
1070 Geom::OptRect ref_bbox = newItem->desktopVisualBounds();1048 Geom::OptRect ref_bbox = newItem->desktopVisualBounds();
1071 if ( ref_bbox && selected->intersects(*ref_bbox) ) {1049 if ( ref_bbox && selected->intersects(*ref_bbox) ) {
1072 // AND if it's not one of our selected objects,1050 // AND if it's not one of our selected objects,
1073 if (!g_slist_find(const_cast<GSList *>(items), newref)) {1051 if (items.end()==std::find(items.begin(),items.end(),newref)) {
1074 // move the selected object before that sibling1052 // move the selected object before that sibling
1075 SPObject *put_after = prev_sibling(newref);1053 SPObject *put_after = prev_sibling(newref);
1076 if (put_after)1054 if (put_after)
@@ -1082,10 +1060,7 @@
1082 }1060 }
1083 }1061 }
1084 }1062 }
1085 rev = g_slist_remove(rev, child);
1086 }1063 }
1087 } else {
1088 g_slist_free(rev);
1089 }1064 }
10901065
1091 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER,1066 DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER,
@@ -1102,7 +1077,7 @@
1102 return;1077 return;
1103 }1078 }
11041079
1105 GSList const *items = const_cast<GSList *>(selection->itemList());1080 std::vector<SPItem*> items =selection->itemList();
11061081
1107 SPGroup const *group = sp_item_list_common_parent_group(items);1082 SPGroup const *group = sp_item_list_common_parent_group(items);
1108 if (!group) {1083 if (!group) {
@@ -1110,15 +1085,13 @@
1110 return;1085 return;
1111 }1086 }
11121087
1113 GSList *rl;1088 std::vector<Inkscape::XML::Node*> rl(selection->reprList());
1114 rl = g_slist_copy(const_cast<GSList *>(selection->reprList()));1089 sort(rl.begin(),rl.end(),sp_repr_compare_position);
1115 rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position);
1116 rl = g_slist_reverse(rl);
11171090
1118 for (GSList *l = rl; l != NULL; l = l->next) {1091 for (std::vector<Inkscape::XML::Node*>::const_reverse_iterator l=rl.rbegin();l!=rl.rend();l++) {
1119 gint minpos;1092 gint minpos;
1120 SPObject *pp, *pc;1093 SPObject *pp, *pc;
1121 Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data);1094 Inkscape::XML::Node *repr = (*l);
1122 pp = document->getObjectByRepr(repr->parent());1095 pp = document->getObjectByRepr(repr->parent());
1123 minpos = 0;1096 minpos = 0;
1124 g_assert(dynamic_cast<SPGroup *>(pp));1097 g_assert(dynamic_cast<SPGroup *>(pp));
@@ -1130,8 +1103,6 @@
1130 repr->setPosition(minpos);1103 repr->setPosition(minpos);
1131 }1104 }
11321105
1133 g_slist_free(rl);
1134
1135 DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK,1106 DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK,
1136 _("Lower to bottom"));1107 _("Lower to bottom"));
1137}1108}
@@ -1269,9 +1240,9 @@
1269 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from."));1240 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from."));
1270 return;1241 return;
1271 }1242 }
12721243 std::vector<SPItem*> list=selection->itemList();
1273 for ( GSList const *itemlist = selection->itemList(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) {1244 for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) {
1274 SPItem *item = reinterpret_cast<SPItem*>(itemlist->data);1245 SPItem *item = *itemlist;
12751246
1276 sp_selection_remove_livepatheffect_impl(item);1247 sp_selection_remove_livepatheffect_impl(item);
12771248
@@ -1325,10 +1296,10 @@
1325 * Ensures that the clones of objects are not modified when moving objects between layers.1296 * Ensures that the clones of objects are not modified when moving objects between layers.
1326 * Calls the same function as ungroup1297 * Calls the same function as ungroup
1327 */1298 */
1328void sp_selection_change_layer_maintain_clones(GSList const *items,SPObject *where)1299void sp_selection_change_layer_maintain_clones(std::vector<SPItem*> const &items,SPObject *where)
1329{1300{
1330 for (const GSList *i = items; i != NULL; i = i->next) {1301 for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) {
1331 SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(i->data));1302 SPItem *item = *i;
1332 if (item) {1303 if (item) {
1333 SPItem *oldparent = dynamic_cast<SPItem *>(item->parent);1304 SPItem *oldparent = dynamic_cast<SPItem *>(item->parent);
1334 SPItem *newparent = dynamic_cast<SPItem *>(where);1305 SPItem *newparent = dynamic_cast<SPItem *>(where);
@@ -1350,26 +1321,24 @@
1350 return;1321 return;
1351 }1322 }
13521323
1353 GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));1324 std::vector<SPItem*> items(selection->itemList());
13541325
1355 bool no_more = false; // Set to true, if no more layers above1326 bool no_more = false; // Set to true, if no more layers above
1356 SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());1327 SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
1357 if (next) {1328 if (next) {
1358 sp_selection_change_layer_maintain_clones(items,next);1329 sp_selection_change_layer_maintain_clones(items,next);
1359 GSList *temp_clip = NULL;1330 std::vector<Inkscape::XML::Node*> temp_clip;
1360 sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc());1331 sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc());
1361 sp_selection_delete_impl(items, false, false);1332 sp_selection_delete_impl(items, false, false);
1362 next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers1333 next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
1363 GSList *copied;1334 std::vector<Inkscape::XML::Node*> copied;
1364 if (next) {1335 if (next) {
1365 copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip);1336 copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip);
1366 } else {1337 } else {
1367 copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip);1338 copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip);
1368 no_more = true;1339 no_more = true;
1369 }1340 }
1370 selection->setReprList((GSList const *) copied);1341 selection->setReprList(copied);
1371 g_slist_free(copied);
1372 if (temp_clip) g_slist_free(temp_clip);
1373 if (next) dt->setCurrentLayer(next);1342 if (next) dt->setCurrentLayer(next);
1374 if ( !suppressDone ) {1343 if ( !suppressDone ) {
1375 DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT,1344 DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT,
@@ -1383,7 +1352,6 @@
1383 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above."));1352 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above."));
1384 }1353 }
13851354
1386 g_slist_free(const_cast<GSList *>(items));
1387}1355}
13881356
1389void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)1357void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
@@ -1396,26 +1364,24 @@
1396 return;1364 return;
1397 }1365 }
13981366
1399 GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));1367 const std::vector<SPItem*> items(selection->itemList());
14001368
1401 bool no_more = false; // Set to true, if no more layers below1369 bool no_more = false; // Set to true, if no more layers below
1402 SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());1370 SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
1403 if (next) {1371 if (next) {
1404 sp_selection_change_layer_maintain_clones(items,next);1372 sp_selection_change_layer_maintain_clones(items,next);
1405 GSList *temp_clip = NULL;1373 std::vector<Inkscape::XML::Node*> temp_clip;
1406 sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs1374 sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
1407 sp_selection_delete_impl(items, false, false);1375 sp_selection_delete_impl(items, false, false);
1408 next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers1376 next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
1409 GSList *copied;1377 std::vector<Inkscape::XML::Node*> copied;
1410 if (next) {1378 if (next) {
1411 copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip);1379 copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip);
1412 } else {1380 } else {
1413 copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip);1381 copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip);
1414 no_more = true;1382 no_more = true;
1415 }1383 }
1416 selection->setReprList((GSList const *) copied);1384 selection->setReprList( copied);
1417 g_slist_free(copied);
1418 if (temp_clip) g_slist_free(temp_clip);
1419 if (next) dt->setCurrentLayer(next);1385 if (next) dt->setCurrentLayer(next);
1420 if ( !suppressDone ) {1386 if ( !suppressDone ) {
1421 DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV,1387 DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV,
@@ -1428,8 +1394,6 @@
1428 if (no_more) {1394 if (no_more) {
1429 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers below."));1395 dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers below."));
1430 }1396 }
1431
1432 g_slist_free(const_cast<GSList *>(items));
1433}1397}
14341398
1435void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone)1399void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone)
@@ -1442,25 +1406,22 @@
1442 return;1406 return;
1443 }1407 }
14441408
1445 GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));1409 std::vector<SPItem*> items(selection->itemList());
14461410
1447 if (moveto) {1411 if (moveto) {
1448 sp_selection_change_layer_maintain_clones(items,moveto);1412 sp_selection_change_layer_maintain_clones(items,moveto);
1449 GSList *temp_clip = NULL;1413 std::vector<Inkscape::XML::Node*> temp_clip;
1450 sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs1414 sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
1451 sp_selection_delete_impl(items, false, false);1415 sp_selection_delete_impl(items, false, false);
1452 GSList *copied = sp_selection_paste_impl(dt->getDocument(), moveto, &temp_clip);1416 std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip);
1453 selection->setReprList((GSList const *) copied);1417 selection->setReprList(copied);
1454 g_slist_free(copied);1418 if (!temp_clip.empty()) temp_clip.clear();
1455 if (temp_clip) g_slist_free(temp_clip);
1456 if (moveto) dt->setCurrentLayer(moveto);1419 if (moveto) dt->setCurrentLayer(moveto);
1457 if ( !suppressDone ) {1420 if ( !suppressDone ) {
1458 DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO,1421 DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO,
1459 _("Move selection to layer"));1422 _("Move selection to layer"));
1460 }1423 }
1461 }1424 }
1462
1463 g_slist_free(const_cast<GSList *>(items));
1464}1425}
14651426
1466static bool1427static bool
@@ -1495,8 +1456,9 @@
1495selection_contains_both_clone_and_original(Inkscape::Selection *selection)1456selection_contains_both_clone_and_original(Inkscape::Selection *selection)
1496{1457{
1497 bool clone_with_original = false;1458 bool clone_with_original = false;
1498 for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {1459 std::vector<SPItem*> items = selection->itemList();
1499 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data));1460 for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1461 SPItem *item = *l;
1500 if (item) {1462 if (item) {
1501 clone_with_original |= selection_contains_original(item, selection);1463 clone_with_original |= selection_contains_original(item, selection);
1502 if (clone_with_original)1464 if (clone_with_original)
@@ -1539,9 +1501,9 @@
15391501
1540 persp3d_apply_affine_transformation(transf_persp, affine);1502 persp3d_apply_affine_transformation(transf_persp, affine);
1541 }1503 }
15421504 std::vector<SPItem*> items = selection->itemList();
1543 for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {1505 for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1544 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data));1506 SPItem *item = *l;
15451507
1546 if( dynamic_cast<SPRoot *>(item) ) {1508 if( dynamic_cast<SPRoot *>(item) ) {
1547 // An SVG element cannot have a transform. We could change 'x' and 'y' in response1509 // An SVG element cannot have a transform. We could change 'x' and 'y' in response
@@ -1710,10 +1672,9 @@
17101672
1711 Inkscape::Selection *selection = desktop->getSelection();1673 Inkscape::Selection *selection = desktop->getSelection();
17121674
1713 GSList const *l = const_cast<GSList *>(selection->reprList());1675 std::vector<Inkscape::XML::Node*> items = selection->reprList();
1714 while (l != NULL) {1676 for (std::vector<Inkscape::XML::Node*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1715 ((Inkscape::XML::Node*)l->data)->setAttribute("transform", NULL, false);1677 (*l)->setAttribute("transform", NULL, false);
1716 l = l->next;
1717 }1678 }
17181679
1719 DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN,1680 DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN,
@@ -1811,10 +1772,10 @@
1811 if (selection->isEmpty())1772 if (selection->isEmpty())
1812 return;1773 return;
18131774
1814 GSList const *l = selection->itemList();1775 std::vector<SPItem*> items = selection->itemList();
1815 Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw1776 Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw
1816 for (GSList const *l2 = l ; l2 != NULL ; l2 = l2->next) {1777 for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) {
1817 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l2->data));1778 SPItem *item = *l;
1818 if (item) {1779 if (item) {
1819 sp_item_rotate_rel(item, rot_90);1780 sp_item_rotate_rel(item, rot_90);
1820 } else {1781 } else {
@@ -1870,15 +1831,15 @@
1870 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);1831 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
1871 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);1832 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
1872 bool ingroups = TRUE;1833 bool ingroups = TRUE;
18731834 std::vector<SPItem*> x,y;
1874 GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL);1835 std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
1875 GSList *all_matches = NULL;1836 std::vector<SPItem*> all_matches;
18761837
1877 Inkscape::Selection *selection = desktop->getSelection();1838 Inkscape::Selection *selection = desktop->getSelection();
18781839 std::vector<SPItem*> items = selection->itemList();
1879 for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) {1840 for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) {
1880 SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data));1841 SPItem *sel = *sel_iter;
1881 GSList *matches = all_list;1842 std::vector<SPItem*> matches = all_list;
1882 if (fill && stroke && style) {1843 if (fill && stroke && style) {
1883 matches = sp_get_same_style(sel, matches);1844 matches = sp_get_same_style(sel, matches);
1884 }1845 }
@@ -1891,19 +1852,12 @@
1891 else if (style) {1852 else if (style) {
1892 matches = sp_get_same_style(sel, matches,SP_STROKE_STYLE_ALL);1853 matches = sp_get_same_style(sel, matches,SP_STROKE_STYLE_ALL);
1893 }1854 }
1894 all_matches = g_slist_concat (all_matches, matches);1855 all_matches.insert(all_matches.end(), matches.begin(),matches.end());
1895 }1856 }
18961857
1897 selection->clear();1858 selection->clear();
1898 selection->setList(all_matches);1859 selection->setList(all_matches);
18991860
1900 if (all_matches) {
1901 g_slist_free(all_matches);
1902 }
1903 if (all_list) {
1904 g_slist_free(all_list);
1905 }
1906
1907}1861}
19081862
19091863
@@ -1924,14 +1878,15 @@
1924 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);1878 bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true);
1925 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);1879 bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true);
1926 bool ingroups = TRUE;1880 bool ingroups = TRUE;
19271881 std::vector<SPItem*> x,y;
1928 GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL);1882 std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y);
1929 GSList *matches = all_list;1883 std::vector<SPItem*> matches = all_list;
19301884
1931 Inkscape::Selection *selection = desktop->getSelection();1885 Inkscape::Selection *selection = desktop->getSelection();
19321886
1933 for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) {1887 std::vector<SPItem*> items=selection->itemList();
1934 SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data));1888 for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) {
1889 SPItem *sel = *sel_iter;
1935 if (sel) {1890 if (sel) {
1936 matches = sp_get_same_object_type(sel, matches);1891 matches = sp_get_same_object_type(sel, matches);
1937 } else {1892 } else {
@@ -1942,12 +1897,6 @@
1942 selection->clear();1897 selection->clear();
1943 selection->setList(matches);1898 selection->setList(matches);
19441899
1945 if (matches) {
1946 g_slist_free(matches);
1947 }
1948 if (all_list) {
1949 g_slist_free(all_list);
1950 }
1951}1900}
19521901
19531902
@@ -1956,15 +1905,15 @@
1956 * Find all items in src list that have the same fill or stroke style as sel1905 * Find all items in src list that have the same fill or stroke style as sel
1957 * Return the list of matching items1906 * Return the list of matching items
1958 */1907 */
1959GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type)1908std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type)
1960{1909{
1961 GSList *matches = NULL;1910 std::vector<SPItem*> matches ;
1962 gboolean match = false;1911 gboolean match = false;
19631912
1964 SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke);1913 SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke);
19651914
1966 for (GSList *i = src; i != NULL; i = i->next) {1915 for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) {
1967 SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));1916 SPItem *iter = *i;
1968 if (iter) {1917 if (iter) {
1969 SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke);1918 SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke);
1970 match = false;1919 match = false;
@@ -2003,7 +1952,7 @@
2003 }1952 }
20041953
2005 if (match) {1954 if (match) {
2006 matches = g_slist_prepend(matches, iter);1955 matches.push_back(iter);
2007 }1956 }
2008 } else {1957 } else {
2009 g_assert_not_reached();1958 g_assert_not_reached();
@@ -2054,17 +2003,16 @@
2054 * Find all items in src list that have the same object type as sel by type2003 * Find all items in src list that have the same object type as sel by type
2055 * Return the list of matching items2004 * Return the list of matching items
2056 */2005 */
2057GSList *sp_get_same_object_type(SPItem *sel, GSList *src)2006std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src)
2058{2007{
2059 GSList *matches = NULL;2008 std::vector<SPItem*> matches;
20602009
2061 for (GSList *i = src; i != NULL; i = i->next) {2010 for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) {
2062 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));2011 SPItem *item = *i;
2063 if (item && item_type_match(sel, item) && !item->cloned) {2012 if (item && item_type_match(sel, item) && !item->cloned) {
2064 matches = g_slist_prepend (matches, item);2013 matches.push_back(item);
2065 }2014 }
2066 }2015 }
2067
2068 return matches;2016 return matches;
2069}2017}
20702018
@@ -2074,9 +2022,9 @@
2074 * Find all items in src list that have the same stroke style as sel by type2022 * Find all items in src list that have the same stroke style as sel by type
2075 * Return the list of matching items2023 * Return the list of matching items
2076 */2024 */
2077GSList *sp_get_same_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type)2025std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type)
2078{2026{
2079 GSList *matches = NULL;2027 std::vector<SPItem*> matches;
2080 bool match = false;2028 bool match = false;
20812029
2082 SPStyle *sel_style = sel->style;2030 SPStyle *sel_style = sel->style;
@@ -2092,16 +2040,16 @@
2092 * Stroke width needs to handle transformations, so call this function2040 * Stroke width needs to handle transformations, so call this function
2093 * to get the transformed stroke width2041 * to get the transformed stroke width
2094 */2042 */
2095 GSList *objects = NULL;2043 std::vector<SPItem*> objects;
2096 SPStyle *sel_style_for_width = NULL;2044 SPStyle *sel_style_for_width = NULL;
2097 if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL ) {2045 if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL ) {
2098 objects = g_slist_prepend(objects, sel);2046 objects.push_back(sel);
2099 sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT);2047 sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT);
2100 objects_query_strokewidth (objects, sel_style_for_width);2048 objects_query_strokewidth (objects, sel_style_for_width);
2101 }2049 }
2102 bool match_g;2050 bool match_g;
2103 for (GSList *i = src; i != NULL; i = i->next) {2051 for (std::vector<SPItem*>::const_iterator i=src.begin();i!=src.end();i++) {
2104 SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));2052 SPItem *iter = *i;
2105 if (iter) {2053 if (iter) {
2106 match_g=true;2054 match_g=true;
2107 SPStyle *iter_style = iter->style;2055 SPStyle *iter_style = iter->style;
@@ -2110,15 +2058,14 @@
2110 if (type == SP_STROKE_STYLE_WIDTH|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) {2058 if (type == SP_STROKE_STYLE_WIDTH|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) {
2111 match = (sel_style->stroke_width.set == iter_style->stroke_width.set);2059 match = (sel_style->stroke_width.set == iter_style->stroke_width.set);
2112 if (sel_style->stroke_width.set && iter_style->stroke_width.set) {2060 if (sel_style->stroke_width.set && iter_style->stroke_width.set) {
2113 GSList *objects = NULL;2061 std::vector<SPItem*> objects;
2114 objects = g_slist_prepend(objects, iter);2062 objects.insert(objects.begin(),iter);
2115 SPStyle tmp_style(SP_ACTIVE_DOCUMENT);2063 SPStyle tmp_style(SP_ACTIVE_DOCUMENT);
2116 objects_query_strokewidth (objects, &tmp_style);2064 objects_query_strokewidth (objects, &tmp_style);
21172065
2118 if (sel_style_for_width) {2066 if (sel_style_for_width) {
2119 match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed);2067 match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed);
2120 }2068 }
2121 g_slist_free(objects);
2122 }2069 }
2123 }2070 }
2124 match_g = match_g && match;2071 match_g = match_g && match;
@@ -2141,10 +2088,10 @@
2141 }2088 }
2142 }2089 }
2143 }2090 }
2144 match_g = match_g && match;2091 match_g = match_g && match;
2145 if (match_g) {2092 if (match_g) {
2146 while (iter->cloned) iter=dynamic_cast<SPItem *>(iter->parent);2093 while (iter->cloned) iter=dynamic_cast<SPItem *>(iter->parent);
2147 matches = g_slist_prepend(matches, iter);2094 matches.insert(matches.begin(),iter);
2148 }2095 }
2149 } else {2096 } else {
2150 g_assert_not_reached();2097 g_assert_not_reached();
@@ -2152,8 +2099,6 @@
2152 }2099 }
21532100
2154 if( sel_style_for_width != NULL ) delete sel_style_for_width;2101 if( sel_style_for_width != NULL ) delete sel_style_for_width;
2155 g_slist_free(objects);
2156
2157 return matches;2102 return matches;
2158}2103}
21592104
@@ -2307,17 +2252,9 @@
2307 }2252 }
2308}2253}
23092254
2310namespace {2255
23112256
2312template <typename D>2257typedef struct Forward {
2313SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
2314 bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive);
2315
2316template <typename D>
2317SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, SPObject *root,
2318 bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive);
2319
2320struct Forward {
2321 typedef SPObject *Iterator;2258 typedef SPObject *Iterator;
23222259
2323 static Iterator children(SPObject *o) { return o->firstChild(); }2260 static Iterator children(SPObject *o) { return o->firstChild(); }
@@ -2326,9 +2263,9 @@
23262263
2327 static SPObject *object(Iterator i) { return i; }2264 static SPObject *object(Iterator i) { return i; }
2328 static Iterator next(Iterator i) { return i->getNext(); }2265 static Iterator next(Iterator i) { return i->getNext(); }
2329};2266} Forward;
23302267
2331struct ListReverse {2268typedef struct ListReverse {
2332 typedef GSList *Iterator;2269 typedef GSList *Iterator;
23332270
2334 static Iterator children(SPObject *o) {2271 static Iterator children(SPObject *o) {
@@ -2359,8 +2296,87 @@
2359 }2296 }
2360 return list;2297 return list;
2361 }2298 }
2362};2299} ListReverse;
23632300
2301
2302
2303template <typename D>
2304SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
2305 bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2306{
2307 typename D::Iterator children;
2308 typename D::Iterator iter;
2309
2310 SPItem *found=NULL;
2311
2312 if (path) {
2313 SPObject *object=reinterpret_cast<SPObject *>(path->data);
2314 g_assert(object->parent == root);
2315 if (desktop->isLayer(object)) {
2316 found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2317 }
2318 iter = children = D::siblings_after(object);
2319 } else {
2320 iter = children = D::children(root);
2321 }
2322
2323 while ( iter && !found ) {
2324 SPObject *object=D::object(iter);
2325 if (desktop->isLayer(object)) {
2326 if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers
2327 found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2328 }
2329 } else {
2330 SPItem *item = dynamic_cast<SPItem *>(object);
2331 if ( item &&
2332 ( !only_in_viewport || desktop->isWithinViewport(item) ) &&
2333 ( !onlyvisible || !desktop->itemIsHidden(item)) &&
2334 ( !onlysensitive || !item->isLocked()) &&
2335 !desktop->isLayer(item) )
2336 {
2337 found = item;
2338 }
2339 }
2340 iter = D::next(iter);
2341 }
2342
2343 D::dispose(children);
2344
2345 return found;
2346}
2347
2348
2349template <typename D>
2350SPItem *next_item_from_list(SPDesktop *desktop, std::vector<SPItem*> const items,
2351 SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2352{
2353 SPObject *current=root;
2354 for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) {
2355 SPItem *item = *i;
2356 if ( root->isAncestorOf(item) &&
2357 ( !only_in_viewport || desktop->isWithinViewport(item) ) )
2358 {
2359 current = item;
2360 break;
2361 }
2362 }
2363
2364 GSList *path=NULL;
2365 while ( current != root ) {
2366 path = g_slist_prepend(path, current);
2367 current = current->parent;
2368 }
2369
2370 SPItem *next;
2371 // first, try from the current object
2372 next = next_item<D>(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2373 g_slist_free(path);
2374
2375 if (!next) { // if we ran out of objects, start over at the root
2376 next = next_item<D>(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2377 }
2378
2379 return next;
2364}2380}
23652381
2366void2382void
@@ -2487,88 +2503,8 @@
2487}2503}
24882504
24892505
2490namespace {2506
24912507
2492template <typename D>
2493SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items,
2494 SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2495{
2496 SPObject *current=root;
2497 while (items) {
2498 SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data));
2499 if ( root->isAncestorOf(item) &&
2500 ( !only_in_viewport || desktop->isWithinViewport(item) ) )
2501 {
2502 current = item;
2503 break;
2504 }
2505 items = items->next;
2506 }
2507
2508 GSList *path=NULL;
2509 while ( current != root ) {
2510 path = g_slist_prepend(path, current);
2511 current = current->parent;
2512 }
2513
2514 SPItem *next;
2515 // first, try from the current object
2516 next = next_item<D>(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2517 g_slist_free(path);
2518
2519 if (!next) { // if we ran out of objects, start over at the root
2520 next = next_item<D>(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2521 }
2522
2523 return next;
2524}
2525
2526template <typename D>
2527SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root,
2528 bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive)
2529{
2530 typename D::Iterator children;
2531 typename D::Iterator iter;
2532
2533 SPItem *found=NULL;
2534
2535 if (path) {
2536 SPObject *object=reinterpret_cast<SPObject *>(path->data);
2537 g_assert(object->parent == root);
2538 if (desktop->isLayer(object)) {
2539 found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2540 }
2541 iter = children = D::siblings_after(object);
2542 } else {
2543 iter = children = D::children(root);
2544 }
2545
2546 while ( iter && !found ) {
2547 SPObject *object=D::object(iter);
2548 if (desktop->isLayer(object)) {
2549 if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers
2550 found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive);
2551 }
2552 } else {
2553 SPItem *item = dynamic_cast<SPItem *>(object);
2554 if ( item &&
2555 ( !only_in_viewport || desktop->isWithinViewport(item) ) &&
2556 ( !onlyvisible || !desktop->itemIsHidden(item)) &&
2557 ( !onlysensitive || !item->isLocked()) &&
2558 !desktop->isLayer(item) )
2559 {
2560 found = item;
2561 }
2562 }
2563 iter = D::next(iter);
2564 }
2565
2566 D::dispose(children);
2567
2568 return found;
2569}
2570
2571}
25722508
2573/**2509/**
2574 * If \a item is not entirely visible then adjust visible area to centre on the centre on of2510 * If \a item is not entirely visible then adjust visible area to centre on the centre on of
@@ -2608,17 +2544,17 @@
2608 return;2544 return;
2609 }2545 }
26102546
2611 GSList *reprs = g_slist_copy(const_cast<GSList *>(selection->reprList()));2547 std::vector<Inkscape::XML::Node*> reprs (selection->reprList());
26122548
2613 selection->clear();2549 selection->clear();
26142550
2615 // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need2551 // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need
2616 reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position);2552 sort(reprs.begin(),reprs.end(),sp_repr_compare_position);
26172553
2618 GSList *newsel = NULL;2554 std::vector<Inkscape::XML::Node*> newsel;
26192555
2620 while (reprs) {2556 for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){
2621 Inkscape::XML::Node *sel_repr = static_cast<Inkscape::XML::Node *>(reprs->data);2557 Inkscape::XML::Node *sel_repr = *i;
2622 Inkscape::XML::Node *parent = sel_repr->parent();2558 Inkscape::XML::Node *parent = sel_repr->parent();
26232559
2624 Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");2560 Inkscape::XML::Node *clone = xml_doc->createElement("svg:use");
@@ -2634,8 +2570,7 @@
2634 // add the new clone to the top of the original's parent2570 // add the new clone to the top of the original's parent
2635 parent->appendChild(clone);2571 parent->appendChild(clone);
26362572
2637 newsel = g_slist_prepend(newsel, clone);2573 newsel.push_back(clone);
2638 reprs = g_slist_remove(reprs, sel_repr);
2639 Inkscape::GC::release(clone);2574 Inkscape::GC::release(clone);
2640 }2575 }
26412576
@@ -2643,8 +2578,6 @@
2643 C_("Action", "Clone"));2578 C_("Action", "Clone"));
26442579
2645 selection->setReprList(newsel);2580 selection->setReprList(newsel);
2646
2647 g_slist_free(newsel);
2648}2581}
26492582
2650void2583void
@@ -2670,11 +2603,9 @@
26702603
2671 // Get a copy of current selection.2604 // Get a copy of current selection.
2672 bool relinked = false;2605 bool relinked = false;
2673 for (GSList *items = const_cast<GSList *>(selection->itemList());2606 std::vector<SPItem*> items=selection->itemList();
2674 items != NULL;2607 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2675 items = items->next)2608 SPItem *item = *i;
2676 {
2677 SPItem *item = static_cast<SPItem *>(items->data);
26782609
2679 if (dynamic_cast<SPUse *>(item)) {2610 if (dynamic_cast<SPUse *>(item)) {
2680 item->getRepr()->setAttribute("xlink:href", newref);2611 item->getRepr()->setAttribute("xlink:href", newref);
@@ -2708,13 +2639,11 @@
2708 }2639 }
27092640
2710 // Get a copy of current selection.2641 // Get a copy of current selection.
2711 GSList *new_select = NULL;2642 std::vector<SPItem*> new_select;
2712 bool unlinked = false;2643 bool unlinked = false;
2713 for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));2644 std::vector<SPItem*> items=selection->itemList();
2714 items != NULL;2645 for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){
2715 items = items->next)2646 SPItem *item = *i;
2716 {
2717 SPItem *item = static_cast<SPItem *>(items->data);
27182647
2719 if (dynamic_cast<SPText *>(item)) {2648 if (dynamic_cast<SPText *>(item)) {
2720 SPObject *tspan = sp_tref_convert_to_tspan(item);2649 SPObject *tspan = sp_tref_convert_to_tspan(item);
@@ -2730,7 +2659,7 @@
27302659
2731 if (!(dynamic_cast<SPUse *>(item) || dynamic_cast<SPTRef *>(item))) {2660 if (!(dynamic_cast<SPUse *>(item) || dynamic_cast<SPTRef *>(item))) {
2732 // keep the non-use item in the new selection2661 // keep the non-use item in the new selection
2733 new_select = g_slist_prepend(new_select, item);2662 new_select.push_back(item);
2734 continue;2663 continue;
2735 }2664 }
27362665
@@ -2740,7 +2669,7 @@
2740 unlink = use->unlink();2669 unlink = use->unlink();
2741 // Unable to unlink use (external or invalid href?)2670 // Unable to unlink use (external or invalid href?)
2742 if (!unlink) {2671 if (!unlink) {
2743 new_select = g_slist_prepend(new_select, item);2672 new_select.push_back(item);
2744 continue;2673 continue;
2745 }2674 }
2746 } else /*if (SP_IS_TREF(use))*/ {2675 } else /*if (SP_IS_TREF(use))*/ {
@@ -2750,13 +2679,12 @@
27502679
2751 unlinked = true;2680 unlinked = true;
2752 // Add ungrouped items to the new selection.2681 // Add ungrouped items to the new selection.
2753 new_select = g_slist_prepend(new_select, unlink);2682 new_select.push_back(unlink);
2754 }2683 }
27552684
2756 if (new_select) { // set new selection2685 if (!new_select.empty()) { // set new selection
2757 selection->clear();2686 selection->clear();
2758 selection->setList(new_select);2687 selection->setList(new_select);
2759 g_slist_free(new_select);
2760 }2688 }
2761 if (!unlinked) {2689 if (!unlinked) {
2762 desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));2690 desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));
@@ -2779,7 +2707,9 @@
2779 gchar const *error = _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a <b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame.");2707 gchar const *error = _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a <b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame.");
27802708
2781 // Check if other than two objects are selected2709 // Check if other than two objects are selected
2782 if (g_slist_length(const_cast<GSList *>(selection->itemList())) != 1 || !item) {2710
2711 std::vector<SPItem*> items=selection->itemList();
2712 if (items.size() != 1 || !item) {
2783 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error);2713 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error);
2784 return;2714 return;
2785 }2715 }
@@ -2876,14 +2806,15 @@
28762806
2877 Inkscape::SVGOStringStream os;2807 Inkscape::SVGOStringStream os;
2878 SPObject * firstItem = NULL;2808 SPObject * firstItem = NULL;
2879 for (const GSList * item = selection->itemList(); item != NULL; item = item->next) {2809 std::vector<SPItem*> items=selection->itemList();
2880 if (SP_IS_SHAPE(item->data) || SP_IS_TEXT(item->data)) {2810 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2811 if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) {
2881 if (firstItem) {2812 if (firstItem) {
2882 os << "|";2813 os << "|";
2883 } else {2814 } else {
2884 firstItem = SP_ITEM(item->data);2815 firstItem = SP_ITEM(*i);
2885 }2816 }
2886 os << '#' << SP_ITEM(item->data)->getId() << ",0";2817 os << '#' << SP_ITEM(*i)->getId() << ",0";
2887 }2818 }
2888 }2819 }
2889 if (firstItem) {2820 if (firstItem) {
@@ -2960,12 +2891,12 @@
2960 Geom::Point center( *c - corner ); // As defined by rotation center2891 Geom::Point center( *c - corner ); // As defined by rotation center
2961 center[Geom::Y] = -center[Geom::Y];2892 center[Geom::Y] = -center[Geom::Y];
29622893
2963 GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));2894 std::vector<SPItem*> items(selection->itemList());
29642895
2965 //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed?2896 //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed?
29662897
2967 // bottommost object, after sorting2898 // bottommost object, after sorting
2968 SPObject *parent = SP_OBJECT(items->data)->parent;2899 SPObject *parent = items[0]->parent;
29692900
2970 Geom::Affine parent_transform;2901 Geom::Affine parent_transform;
2971 {2902 {
@@ -2978,10 +2909,10 @@
2978 }2909 }
29792910
2980 // Create a list of duplicates, to be pasted inside marker element.2911 // Create a list of duplicates, to be pasted inside marker element.
2981 GSList *repr_copies = NULL;2912 std::vector<Inkscape::XML::Node*> repr_copies;
2982 for (GSList *i = items; i != NULL; i = i->next) {2913 for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){
2983 Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);2914 Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
2984 repr_copies = g_slist_prepend(repr_copies, dup);2915 repr_copies.push_back(dup);
2985 }2916 }
29862917
2987 Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));2918 Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
@@ -2989,8 +2920,8 @@
2989 if (apply) {2920 if (apply) {
2990 // Delete objects so that their clones don't get alerted;2921 // Delete objects so that their clones don't get alerted;
2991 // the objects will be restored inside the marker element.2922 // the objects will be restored inside the marker element.
2992 for (GSList *i = items; i != NULL; i = i->next) {2923 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2993 SPObject *item = reinterpret_cast<SPObject*>(i->data);2924 SPObject *item = *i;
2994 item->deleteObject(false);2925 item->deleteObject(false);
2995 }2926 }
2996 }2927 }
@@ -3009,7 +2940,6 @@
3009 prefs->setInt("/options/clonecompensation/value", saved_compensation);2940 prefs->setInt("/options/clonecompensation/value", saved_compensation);
30102941
30112942
3012 g_slist_free(items);
30132943
3014 DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER,2944 DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER,
3015 _("Objects to marker"));2945 _("Objects to marker"));
@@ -3018,8 +2948,9 @@
3018static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) {2948static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) {
3019 SPGroup *group = dynamic_cast<SPGroup *>(item);2949 SPGroup *group = dynamic_cast<SPGroup *>(item);
3020 if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) {2950 if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) {
3021 for (GSList *i = sp_item_group_item_list(group); i != NULL; i = i->next) {2951 std::vector<SPItem*> items=sp_item_group_item_list(group);
3022 sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups);2952 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
2953 sp_selection_to_guides_recursive(*i, wholegroups);
3023 }2954 }
3024 } else {2955 } else {
3025 item->convert_to_guides();2956 item->convert_to_guides();
@@ -3034,9 +2965,9 @@
3034 SPDocument *doc = desktop->getDocument();2965 SPDocument *doc = desktop->getDocument();
3035 Inkscape::Selection *selection = desktop->getSelection();2966 Inkscape::Selection *selection = desktop->getSelection();
3036 // we need to copy the list because it gets reset when objects are deleted2967 // we need to copy the list because it gets reset when objects are deleted
3037 GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));2968 std::vector<SPItem*> items(selection->itemList());
30382969
3039 if (!items) {2970 if (items.empty()) {
3040 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));2971 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));
3041 return;2972 return;
3042 }2973 }
@@ -3049,8 +2980,8 @@
3049 // and its entry in the selection list is invalid (crash).2980 // and its entry in the selection list is invalid (crash).
3050 // Therefore: first convert all, then delete all.2981 // Therefore: first convert all, then delete all.
30512982
3052 for (GSList const *i = items; i != NULL; i = i->next) {2983 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
3053 sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups);2984 sp_selection_to_guides_recursive(*i, wholegroups);
3054 }2985 }
30552986
3056 if (deleteitems) {2987 if (deleteitems) {
@@ -3058,8 +2989,6 @@
3058 sp_selection_delete_impl(items);2989 sp_selection_delete_impl(items);
3059 }2990 }
30602991
3061 g_slist_free(items);
3062
3063 DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides"));2992 DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides"));
3064}2993}
30652994
@@ -3102,18 +3031,18 @@
31023031
3103 doc->ensureUpToDate();3032 doc->ensureUpToDate();
31043033
3105 GSList *items = g_slist_copy(const_cast<GSList *>(selection->list()));3034 std::vector<SPObject*> items(selection->list());
31063035
3107 // Keep track of parent, this is where <use> will be inserted.3036 // Keep track of parent, this is where <use> will be inserted.
3108 Inkscape::XML::Node *the_first_repr = reinterpret_cast<SPObject *>( items->data )->getRepr();3037 Inkscape::XML::Node *the_first_repr = items[0]->getRepr();
3109 Inkscape::XML::Node *the_parent_repr = the_first_repr->parent();3038 Inkscape::XML::Node *the_parent_repr = the_first_repr->parent();
31103039
3111 // Find out if we have a single group3040 // Find out if we have a single group
3112 bool single_group = false;3041 bool single_group = false;
3113 SPGroup *the_group = NULL;3042 SPGroup *the_group = NULL;
3114 Geom::Affine transform;3043 Geom::Affine transform;
3115 if( g_slist_length( items ) == 1 ) {3044 if( items.size() == 1 ) {
3116 SPObject *object = reinterpret_cast<SPObject *>( items->data );3045 SPObject *object = items[0];
3117 the_group = dynamic_cast<SPGroup *>(object);3046 the_group = dynamic_cast<SPGroup *>(object);
3118 if ( the_group ) {3047 if ( the_group ) {
3119 single_group = true;3048 single_group = true;
@@ -3124,7 +3053,6 @@
3124 if( transform.isTranslation() ) {3053 if( transform.isTranslation() ) {
31253054
3126 // Create new list from group children.3055 // Create new list from group children.
3127 g_slist_free(items);
3128 items = object->childList(false);3056 items = object->childList(false);
31293057
3130 // Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals3058 // Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals
@@ -3170,8 +3098,8 @@
3170 }3098 }
31713099
3172 // Move selected items to new <symbol>3100 // Move selected items to new <symbol>
3173 for (GSList *i = items; i != NULL; i = i->next) {3101 for (std::vector<SPObject*>::const_iterator i=items.begin();i!=items.end();i++){
3174 Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr();3102 Inkscape::XML::Node *repr = (*i)->getRepr();
3175 repr->parent()->removeChild(repr);3103 repr->parent()->removeChild(repr);
3176 symbol_repr->addChild(repr,NULL);3104 symbol_repr->addChild(repr,NULL);
3177 }3105 }
@@ -3197,7 +3125,6 @@
31973125
3198 // Clean up3126 // Clean up
3199 Inkscape::GC::release(symbol_repr);3127 Inkscape::GC::release(symbol_repr);
3200 g_slist_free(items);
32013128
3202 DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol"));3129 DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol"));
3203}3130}
@@ -3238,26 +3165,25 @@
3238 desktop->currentLayer()->getRepr()->appendChild(group);3165 desktop->currentLayer()->getRepr()->appendChild(group);
32393166
3240 // Move all children of symbol to group3167 // Move all children of symbol to group
3241 GSList* children = symbol->childList(false);3168 std::vector<SPObject*> children = symbol->childList(false);
32423169
3243 // Converting a group to a symbol inserts a group for non-translational transform.3170 // Converting a group to a symbol inserts a group for non-translational transform.
3244 // In converting a symbol back to a group we strip out the inserted group (or any other3171 // In converting a symbol back to a group we strip out the inserted group (or any other
3245 // group that only adds a transform to the symbol content).3172 // group that only adds a transform to the symbol content).
3246 if( g_slist_length( children ) == 1 ) {3173 if( children.size() == 1 ) {
3247 SPObject *object = reinterpret_cast<SPObject *>( children->data );3174 SPObject *object = children[0];
3248 if ( dynamic_cast<SPGroup *>( object ) ) {3175 if ( dynamic_cast<SPGroup *>( object ) ) {
3249 if( object->getAttribute("style") == NULL ||3176 if( object->getAttribute("style") == NULL ||
3250 object->getAttribute("class") == NULL ) {3177 object->getAttribute("class") == NULL ) {
32513178
3252 group->setAttribute("transform", object->getAttribute("transform"));3179 group->setAttribute("transform", object->getAttribute("transform"));
3253 g_slist_free(children);
3254 children = object->childList(false);3180 children = object->childList(false);
3255 }3181 }
3256 }3182 }
3257 }3183 }
3258 3184
3259 for (GSList* i = children; i != NULL; i = i->next ) {3185 for (std::vector<SPObject*>::const_reverse_iterator i=children.rbegin();i!=children.rend();i++){
3260 Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr();3186 Inkscape::XML::Node *repr = (*i)->getRepr();
3261 repr->parent()->removeChild(repr);3187 repr->parent()->removeChild(repr);
3262 group->addChild(repr,NULL);3188 group->addChild(repr,NULL);
3263 }3189 }
@@ -3283,7 +3209,6 @@
32833209
3284 // Clean up3210 // Clean up
3285 Inkscape::GC::release(group);3211 Inkscape::GC::release(group);
3286 g_slist_free(children);
32873212
3288 DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol"));3213 DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol"));
3289}3214}
@@ -3318,12 +3243,12 @@
3318 move_p[Geom::Y] = -move_p[Geom::Y];3243 move_p[Geom::Y] = -move_p[Geom::Y];
3319 Geom::Affine move = Geom::Affine(Geom::Translate(move_p));3244 Geom::Affine move = Geom::Affine(Geom::Translate(move_p));
33203245
3321 GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));3246 std::vector<SPItem*> items (selection->itemList());
33223247
3323 items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position);3248 sort(items.begin(),items.end(),sp_object_compare_position);
33243249
3325 // bottommost object, after sorting3250 // bottommost object, after sorting
3326 SPObject *parent = SP_OBJECT(items->data)->parent;3251 SPObject *parent = items[0]->parent;
3327 3252
33283253
3329 Geom::Affine parent_transform;3254 Geom::Affine parent_transform;
@@ -3337,23 +3262,21 @@
3337 }3262 }
33383263
3339 // remember the position of the first item3264 // remember the position of the first item
3340 gint pos = SP_OBJECT(items->data)->getRepr()->position();3265 gint pos = items[0]->getRepr()->position();
33413266
3342 // create a list of duplicates3267 // create a list of duplicates
3343 GSList *repr_copies = NULL;3268 std::vector<Inkscape::XML::Node*> repr_copies;
3344 for (GSList *i = items; i != NULL; i = i->next) {3269 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
3345 Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);3270 Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
3346 repr_copies = g_slist_prepend(repr_copies, dup);3271 repr_copies.push_back(dup);
3347 }3272 }
3348 // restore the z-order after prepends
3349 repr_copies = g_slist_reverse(repr_copies);
33503273
3351 Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));3274 Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
33523275
3353 if (apply) {3276 if (apply) {
3354 // delete objects so that their clones don't get alerted; this object will be restored shortly3277 // delete objects so that their clones don't get alerted; this object will be restored shortly
3355 for (GSList *i = items; i != NULL; i = i->next) {3278 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
3356 SPObject *item = reinterpret_cast<SPObject*>(i->data);3279 SPObject *item = *i;
3357 item->deleteObject(false);3280 item->deleteObject(false);
3358 }3281 }
3359 }3282 }
@@ -3399,7 +3322,6 @@
3399 selection->set(rectangle);3322 selection->set(rectangle);
3400 }3323 }
34013324
3402 g_slist_free(items);
34033325
3404 DocumentUndo::done(doc, SP_VERB_EDIT_TILE,3326 DocumentUndo::done(doc, SP_VERB_EDIT_TILE,
3405 _("Objects to pattern"));3327 _("Objects to pattern"));
@@ -3422,15 +3344,13 @@
3422 return;3344 return;
3423 }3345 }
34243346
3425 GSList *new_select = NULL;3347 std::vector<SPItem*> new_select;
34263348
3427 bool did = false;3349 bool did = false;
34283350
3429 for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));3351 std::vector<SPItem*> items(selection->itemList());
3430 items != NULL;3352 for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){
3431 items = items->next) {3353 SPItem *item = *i;
3432
3433 SPItem *item = static_cast<SPItem *>(items->data);
34343354
3435 SPStyle *style = item->style;3355 SPStyle *style = item->style;
34363356
@@ -3466,7 +3386,7 @@
3466 Geom::Affine transform( i->transform * pat_transform );3386 Geom::Affine transform( i->transform * pat_transform );
3467 i->doWriteTransform(i->getRepr(), transform);3387 i->doWriteTransform(i->getRepr(), transform);
34683388
3469 new_select = g_slist_prepend(new_select, i);3389 new_select.push_back(i);
3470 } else {3390 } else {
3471 g_assert_not_reached();3391 g_assert_not_reached();
3472 }3392 }
@@ -3493,18 +3413,14 @@
3493 return;3413 return;
3494 }3414 }
34953415
3496 GSList const *reprlst = selection->reprList();3416 std::vector<Inkscape::XML::Node*> const reprlst = selection->reprList();
3497 bool filename_search = TRUE;3417 bool filename_search = TRUE;
3498 bool xdpi_search = TRUE;3418 bool xdpi_search = TRUE;
3499 bool ydpi_search = TRUE;3419 bool ydpi_search = TRUE;
35003420
3501 for (; reprlst != NULL &&3421 for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){
3502 filename_search &&
3503 xdpi_search &&
3504 ydpi_search;
3505 reprlst = reprlst->next) {
3506 gchar const *dpi_string;3422 gchar const *dpi_string;
3507 Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data);3423 Inkscape::XML::Node *repr = *i;
35083424
3509 if (filename_search) {3425 if (filename_search) {
3510 const gchar* tmp = repr->attribute("inkscape:export-filename");3426 const gchar* tmp = repr->attribute("inkscape:export-filename");
@@ -3590,10 +3506,10 @@
3590 }3506 }
35913507
3592 // List of the items to show; all others will be hidden3508 // List of the items to show; all others will be hidden
3593 GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));3509 std::vector<SPItem*> items(selection->itemList());
35943510
3595 // Sort items so that the topmost comes last3511 // Sort items so that the topmost comes last
3596 items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position);3512 sort(items.begin(),items.end(),sp_item_repr_compare_position);
35973513
3598 // Generate a random value from the current time (you may create bitmap from the same object(s)3514 // Generate a random value from the current time (you may create bitmap from the same object(s)
3599 // multiple times, and this is done so that they don't clash)3515 // multiple times, and this is done so that they don't clash)
@@ -3604,7 +3520,7 @@
3604 // Create the filename.3520 // Create the filename.
3605 gchar *const basename = g_strdup_printf("%s-%s-%u.png",3521 gchar *const basename = g_strdup_printf("%s-%s-%u.png",
3606 document->getName(),3522 document->getName(),
3607 SP_OBJECT(items->data)->getRepr()->attribute("id"),3523 items[0]->getRepr()->attribute("id"),
3608 current);3524 current);
3609 // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters,3525 // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters,
3610 // digits, and a few other chars, with "_"3526 // digits, and a few other chars, with "_"
@@ -3624,8 +3540,8 @@
3624 //g_print("%s\n", filepath);3540 //g_print("%s\n", filepath);
36253541
3626 // Remember parent and z-order of the topmost one3542 // Remember parent and z-order of the topmost one
3627 gint pos = SP_OBJECT(g_slist_last(items)->data)->getRepr()->position();3543 gint pos = items.back()->getRepr()->position();
3628 SPObject *parent_object = SP_OBJECT(g_slist_last(items)->data)->parent;3544 SPObject *parent_object = items.back()->parent;
3629 Inkscape::XML::Node *parent = parent_object->getRepr();3545 Inkscape::XML::Node *parent = parent_object->getRepr();
36303546
3631 // Calculate resolution3547 // Calculate resolution
@@ -3717,8 +3633,6 @@
3717 true, /*bool force_overwrite,*/3633 true, /*bool force_overwrite,*/
3718 items);3634 items);
37193635
3720 g_slist_free(items);
3721
3722 // Run filter, if any3636 // Run filter, if any
3723 if (run) {3637 if (run) {
3724 g_print("Running external filter: %s\n", run);3638 g_print("Running external filter: %s\n", run);
@@ -3793,22 +3707,20 @@
3793 return;3707 return;
3794 }3708 }
3795 3709
3796 GSList const *l = const_cast<GSList *>(selection->reprList());3710 std::vector<Inkscape::XML::Node*> p(selection->reprList());
3797
3798 GSList *p = g_slist_copy(const_cast<GSList *>(l));
3799 3711
3800 p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position);3712 sort(p.begin(),p.end(),sp_repr_compare_position);
38013713
3802 selection->clear();3714 selection->clear();
38033715
3804 gint topmost = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->position();3716 int topmost = (p.back())->position();
3805 Inkscape::XML::Node *topmost_parent = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->parent();3717 Inkscape::XML::Node *topmost_parent = (p.back())->parent();
38063718
3807 Inkscape::XML::Node *inner = xml_doc->createElement("svg:g");3719 Inkscape::XML::Node *inner = xml_doc->createElement("svg:g");
3808 inner->setAttribute("inkscape:label", "Clip");3720 inner->setAttribute("inkscape:label", "Clip");
3809 3721
3810 while (p) {3722 for(std::vector<Inkscape::XML::Node*>::const_iterator i=p.begin();i!=p.end();i++){
3811 Inkscape::XML::Node *current = static_cast<Inkscape::XML::Node *>(p->data);3723 Inkscape::XML::Node *current = *i;
38123724
3813 if (current->parent() == topmost_parent) {3725 if (current->parent() == topmost_parent) {
3814 Inkscape::XML::Node *spnew = current->duplicate(xml_doc);3726 Inkscape::XML::Node *spnew = current->duplicate(xml_doc);
@@ -3817,7 +3729,7 @@
3817 Inkscape::GC::release(spnew);3729 Inkscape::GC::release(spnew);
3818 topmost --; // only reduce count for those items deleted from topmost_parent3730 topmost --; // only reduce count for those items deleted from topmost_parent
3819 } else { // move it to topmost_parent first3731 } else { // move it to topmost_parent first
3820 GSList *temp_clip = NULL;3732 std::vector<Inkscape::XML::Node*> temp_clip;
38213733
3822 // At this point, current may already have no item, due to its being a clone whose original is already moved away3734 // At this point, current may already have no item, due to its being a clone whose original is already moved away
3823 // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform3735 // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform
@@ -3833,15 +3745,14 @@
3833 // then, if this is clone, looking up its original in that array and pre-multiplying3745 // then, if this is clone, looking up its original in that array and pre-multiplying
3834 // it by the inverse of that original's transform diff.3746 // it by the inverse of that original's transform diff.
38353747
3836 sp_selection_copy_one(current, item_t, &temp_clip, xml_doc);3748 sp_selection_copy_one(current, item_t, temp_clip, xml_doc);
3837 sp_repr_unparent(current);3749 sp_repr_unparent(current);
38383750
3839 // paste into topmost_parent (temporarily)3751 // paste into topmost_parent (temporarily)
3840 GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip);3752 std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip);
3841 if (temp_clip) g_slist_free(temp_clip);3753 if (!copied.empty()) { // if success,
3842 if (copied) { // if success,
3843 // take pasted object (now in topmost_parent)3754 // take pasted object (now in topmost_parent)
3844 Inkscape::XML::Node *in_topmost = static_cast<Inkscape::XML::Node *>(copied->data);3755 Inkscape::XML::Node *in_topmost = copied.back();
3845 // make a copy3756 // make a copy
3846 Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc);3757 Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc);
3847 // remove pasted3758 // remove pasted
@@ -3849,10 +3760,8 @@
3849 // put its copy into group3760 // put its copy into group
3850 inner->appendChild(spnew);3761 inner->appendChild(spnew);
3851 Inkscape::GC::release(spnew);3762 Inkscape::GC::release(spnew);
3852 g_slist_free(copied);
3853 }3763 }
3854 }3764 }
3855 p = g_slist_remove(p, current);
3856 }3765 }
3857 3766
3858 Inkscape::XML::Node *outer = xml_doc->createElement("svg:g");3767 Inkscape::XML::Node *outer = xml_doc->createElement("svg:g");
@@ -3910,7 +3819,7 @@
3910 if ( apply_to_layer && is_empty) {3819 if ( apply_to_layer && is_empty) {
3911 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));3820 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
3912 return;3821 return;
3913 } else if (!apply_to_layer && ( is_empty || NULL == selection->itemList()->next )) {3822 } else if (!apply_to_layer && ( is_empty || selection->itemList().size()==1 )) {
3914 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to."));3823 desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to."));
3915 return;3824 return;
3916 }3825 }
@@ -3925,9 +3834,9 @@
39253834
3926 doc->ensureUpToDate();3835 doc->ensureUpToDate();
39273836
3928 GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));3837 std::vector<SPItem*> items(selection->itemList());
39293838
3930 items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position);3839 sort(items.begin(),items.end(),sp_object_compare_position);
39313840
3932 // See lp bug #5420043841 // See lp bug #542004
3933 selection->clear();3842 selection->clear();
@@ -3936,7 +3845,7 @@
3936 GSList *mask_items = NULL;3845 GSList *mask_items = NULL;
3937 GSList *apply_to_items = NULL;3846 GSList *apply_to_items = NULL;
3938 GSList *items_to_delete = NULL;3847 GSList *items_to_delete = NULL;
3939 GSList *items_to_select = NULL;3848 std::vector<SPItem*> items_to_select;
39403849
3941 Inkscape::Preferences *prefs = Inkscape::Preferences::get();3850 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
3942 bool topmost = prefs->getBool("/options/maskobject/topmost", true);3851 bool topmost = prefs->getBool("/options/maskobject/topmost", true);
@@ -3947,38 +3856,38 @@
3947 // all selected items are used for mask, which is applied to a layer3856 // all selected items are used for mask, which is applied to a layer
3948 apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer());3857 apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer());
39493858
3950 for (GSList *i = items; i != NULL; i = i->next) {3859 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) {
3951 Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);3860 Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
3952 mask_items = g_slist_prepend(mask_items, dup);3861 mask_items = g_slist_prepend(mask_items, dup);
39533862
3954 SPObject *item = reinterpret_cast<SPObject*>(i->data);3863 SPObject *item = *i;
3955 if (remove_original) {3864 if (remove_original) {
3956 items_to_delete = g_slist_prepend(items_to_delete, item);3865 items_to_delete = g_slist_prepend(items_to_delete, item);
3957 }3866 }
3958 else {3867 else {
3959 items_to_select = g_slist_prepend(items_to_select, item);3868 items_to_select.push_back((SPItem*)item);
3960 }3869 }
3961 }3870 }
3962 } else if (!topmost) {3871 } else if (!topmost) {
3963 // topmost item is used as a mask, which is applied to other items in a selection3872 // topmost item is used as a mask, which is applied to other items in a selection
3964 GSList *i = items;3873 Inkscape::XML::Node *dup = items[0]->getRepr()->duplicate(xml_doc);
3965 Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
3966 mask_items = g_slist_prepend(mask_items, dup);3874 mask_items = g_slist_prepend(mask_items, dup);
39673875
3968 if (remove_original) {3876 if (remove_original) {
3969 SPObject *item = reinterpret_cast<SPObject*>(i->data);3877 SPObject *item = items.front();
3970 items_to_delete = g_slist_prepend(items_to_delete, item);3878 items_to_delete = g_slist_prepend(items_to_delete, item);
3971 }3879 }
39723880
3973 for (i = i->next; i != NULL; i = i->next) {3881 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) {
3974 apply_to_items = g_slist_prepend(apply_to_items, i->data);3882 if(i==items.begin())continue;
3975 items_to_select = g_slist_prepend(items_to_select, i->data);3883 apply_to_items = g_slist_prepend(apply_to_items, *i);
3884 items_to_select.push_back(*i);
3976 }3885 }
3977 } else {3886 } else {
3978 GSList *i = NULL;3887 GSList *i = NULL;
3979 for (i = items; NULL != i->next; i = i->next) {3888 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) {
3980 apply_to_items = g_slist_prepend(apply_to_items, i->data);3889 apply_to_items = g_slist_prepend(apply_to_items, *i);
3981 items_to_select = g_slist_prepend(items_to_select, i->data);3890 items_to_select.push_back(*i);
3982 }3891 }
39833892
3984 Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);3893 Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc);
@@ -3989,9 +3898,7 @@
3989 items_to_delete = g_slist_prepend(items_to_delete, item);3898 items_to_delete = g_slist_prepend(items_to_delete, item);
3990 }3899 }
3991 }3900 }
39923901 items.clear();
3993 g_slist_free(items);
3994 items = NULL;
39953902
3996 if (apply_to_items && grouping == PREFS_MASKOBJECT_GROUPING_ALL) {3903 if (apply_to_items && grouping == PREFS_MASKOBJECT_GROUPING_ALL) {
3997 // group all those objects into one group3904 // group all those objects into one group
@@ -4001,24 +3908,21 @@
4001 // make a note we should ungroup this when unsetting mask3908 // make a note we should ungroup this when unsetting mask
4002 group->setAttribute("inkscape:groupmode", "maskhelper");3909 group->setAttribute("inkscape:groupmode", "maskhelper");
40033910
4004 GSList *reprs_to_group = NULL;3911 std::vector<Inkscape::XML::Node*> reprs_to_group;
40053912
4006 for (GSList *i = apply_to_items ; NULL != i ; i = i->next) {3913 for (GSList *i = apply_to_items ; NULL != i ; i = i->next) {
4007 reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT(i->data)->getRepr());3914 reprs_to_group.push_back(static_cast<SPObject*>(i->data)->getRepr());
4008 items_to_select = g_slist_remove(items_to_select, i->data);3915 items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),static_cast<SPObject*>(i->data)));
4009 }3916 }
4010 reprs_to_group = g_slist_reverse(reprs_to_group);
40113917
4012 sp_selection_group_impl(reprs_to_group, group, xml_doc, doc);3918 sp_selection_group_impl(reprs_to_group, group, xml_doc, doc);
40133919
4014 reprs_to_group = NULL;
4015
4016 // apply clip/mask only to newly created group3920 // apply clip/mask only to newly created group
4017 g_slist_free(apply_to_items);3921 g_slist_free(apply_to_items);
4018 apply_to_items = NULL;3922 apply_to_items = NULL;
4019 apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group));3923 apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group));
40203924
4021 items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group));3925 items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group)));
40223926
4023 Inkscape::GC::release(group);3927 Inkscape::GC::release(group);
4024 }3928 }
@@ -4058,7 +3962,7 @@
40583962
4059 Inkscape::XML::Node *spnew = current->duplicate(xml_doc);3963 Inkscape::XML::Node *spnew = current->duplicate(xml_doc);
4060 gint position = current->position();3964 gint position = current->position();
4061 items_to_select = g_slist_remove(items_to_select, item);3965 items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item));
4062 current->parent()->appendChild(group);3966 current->parent()->appendChild(group);
4063 sp_repr_unparent(current);3967 sp_repr_unparent(current);
4064 group->appendChild(spnew);3968 group->appendChild(spnew);
@@ -4067,7 +3971,7 @@
4067 // Apply clip/mask to group instead3971 // Apply clip/mask to group instead
4068 apply_mask_to = group;3972 apply_mask_to = group;
40693973
4070 items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group));3974 items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group)));
4071 Inkscape::GC::release(spnew);3975 Inkscape::GC::release(spnew);
4072 Inkscape::GC::release(group);3976 Inkscape::GC::release(group);
4073 }3977 }
@@ -4082,14 +3986,11 @@
4082 for (GSList *i = items_to_delete; NULL != i; i = i->next) {3986 for (GSList *i = items_to_delete; NULL != i; i = i->next) {
4083 SPObject *item = reinterpret_cast<SPObject*>(i->data);3987 SPObject *item = reinterpret_cast<SPObject*>(i->data);
4084 item->deleteObject(false);3988 item->deleteObject(false);
4085 items_to_select = g_slist_remove(items_to_select, item);3989 items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item));
4086 }3990 }
4087 g_slist_free(items_to_delete);3991 g_slist_free(items_to_delete);
40883992
4089 items_to_select = g_slist_reverse(items_to_select);
4090
4091 selection->addList(items_to_select);3993 selection->addList(items_to_select);
4092 g_slist_free(items_to_select);
40933994
4094 if (apply_clip_path) {3995 if (apply_clip_path) {
4095 DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path"));3996 DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path"));
@@ -4121,20 +4022,19 @@
4121 gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";4022 gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
4122 std::map<SPObject*,SPItem*> referenced_objects;4023 std::map<SPObject*,SPItem*> referenced_objects;
41234024
4124 GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));4025 std::vector<SPItem*> items(selection->itemList());
4125 selection->clear();4026 selection->clear();
41264027
4127 GSList *items_to_ungroup = NULL;4028 GSList *items_to_ungroup = NULL;
4128 GSList *items_to_select = g_slist_copy(items);4029 std::vector<SPItem*> items_to_select(items);
4129 items_to_select = g_slist_reverse(items_to_select);
41304030
41314031
4132 // SPObject* refers to a group containing the clipped path or mask itself,4032 // SPObject* refers to a group containing the clipped path or mask itself,
4133 // whereas SPItem* refers to the item being clipped or masked4033 // whereas SPItem* refers to the item being clipped or masked
4134 for (GSList const *i = items; NULL != i; i = i->next) {4034 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){
4135 if (remove_original) {4035 if (remove_original) {
4136 // remember referenced mask/clippath, so orphaned masks can be moved back to document4036 // remember referenced mask/clippath, so orphaned masks can be moved back to document
4137 SPItem *item = reinterpret_cast<SPItem *>(i->data);4037 SPItem *item = *i;
4138 Inkscape::URIReference *uri_ref = NULL;4038 Inkscape::URIReference *uri_ref = NULL;
41394039
4140 if (apply_clip_path) {4040 if (apply_clip_path) {
@@ -4149,9 +4049,9 @@
4149 }4049 }
4150 }4050 }
41514051
4152 SP_OBJECT(i->data)->getRepr()->setAttribute(attributeName, "none");4052 (*i)->getRepr()->setAttribute(attributeName, "none");
41534053
4154 SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data));4054 SPGroup *group = dynamic_cast<SPGroup *>(*i);
4155 if (ungroup_masked && group) {4055 if (ungroup_masked && group) {
4156 // if we had previously enclosed masked object in group,4056 // if we had previously enclosed masked object in group,
4157 // add it to list so we can ungroup it later4057 // add it to list so we can ungroup it later
@@ -4163,7 +4063,6 @@
41634063
4164 }4064 }
4165 }4065 }
4166 g_slist_free(items);
41674066
4168 // restore mask objects into a document4067 // restore mask objects into a document
4169 for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) {4068 for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) {
@@ -4171,7 +4070,7 @@
4171 GSList *items_to_move = NULL;4070 GSList *items_to_move = NULL;
4172 for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {4071 for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) {
4173 // Collect all clipped paths and masks within a single group4072 // Collect all clipped paths and masks within a single group
4174 Inkscape::XML::Node *copy = SP_OBJECT(child)->getRepr()->duplicate(xml_doc);4073 Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc);
4175 if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect"))4074 if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect"))
4176 {4075 {
4177 copy->setAttribute("d", copy->attribute("inkscape:original-d"));4076 copy->setAttribute("d", copy->attribute("inkscape:original-d"));
@@ -4197,7 +4096,7 @@
4197 repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0);4096 repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0);
41984097
4199 SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr));4098 SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr));
4200 items_to_select = g_slist_prepend(items_to_select, mask_item);4099 items_to_select.push_back(mask_item);
42014100
4202 // transform mask, so it is moved the same spot where mask was applied4101 // transform mask, so it is moved the same spot where mask was applied
4203 Geom::Affine transform(mask_item->transform);4102 Geom::Affine transform(mask_item->transform);
@@ -4212,10 +4111,10 @@
4212 for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) {4111 for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) {
4213 SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data));4112 SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data));
4214 if (group) {4113 if (group) {
4215 items_to_select = g_slist_remove(items_to_select, group);4114 items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),group));
4216 GSList *children = NULL;4115 std::vector<SPItem*> children;
4217 sp_item_group_ungroup(group, &children, false);4116 sp_item_group_ungroup(group, children, false);
4218 items_to_select = g_slist_concat(children, items_to_select);4117 items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend());
4219 } else {4118 } else {
4220 g_assert_not_reached();4119 g_assert_not_reached();
4221 }4120 }
@@ -4224,9 +4123,7 @@
4224 g_slist_free(items_to_ungroup);4123 g_slist_free(items_to_ungroup);
42254124
4226 // rebuild selection4125 // rebuild selection
4227 items_to_select = g_slist_reverse(items_to_select);
4228 selection->addList(items_to_select);4126 selection->addList(items_to_select);
4229 g_slist_free(items_to_select);
42304127
4231 if (apply_clip_path) {4128 if (apply_clip_path) {
4232 DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path"));4129 DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path"));
42334130
=== modified file 'src/selection-chemistry.h'
--- src/selection-chemistry.h 2015-02-20 15:50:51 +0000
+++ src/selection-chemistry.h 2015-04-29 21:03:59 +0000
@@ -143,8 +143,9 @@
143143
144void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style);144void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style);
145void sp_select_same_object_type(SPDesktop *desktop);145void sp_select_same_object_type(SPDesktop *desktop);
146GSList *sp_get_same_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type=SP_STYLE_ALL);146
147GSList *sp_get_same_object_type(SPItem *sel, GSList *src);147std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type=SP_STYLE_ALL);
148std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src);
148149
149void scroll_to_show_item(SPDesktop *desktop, SPItem *item);150void scroll_to_show_item(SPDesktop *desktop, SPItem *item);
150151
@@ -171,9 +172,9 @@
171void unhide_all(SPDesktop *dt);172void unhide_all(SPDesktop *dt);
172void unhide_all_in_all_layers(SPDesktop *dt);173void unhide_all_in_all_layers(SPDesktop *dt);
173174
174GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude);175std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude);
175176
176GSList *sp_degroup_list (GSList *items);177std::vector<SPItem*> sp_degroup_list (std::vector<SPItem*> &items);
177178
178/* selection cycling */179/* selection cycling */
179typedef enum180typedef enum
180181
=== modified file 'src/selection-describer.cpp'
--- src/selection-describer.cpp 2015-03-06 08:51:53 +0000
+++ src/selection-describer.cpp 2015-04-29 21:03:59 +0000
@@ -40,14 +40,14 @@
40#include "sp-spiral.h"40#include "sp-spiral.h"
4141
42// Returns a list of terms for the items to be used in the statusbar42// Returns a list of terms for the items to be used in the statusbar
43char* collect_terms (GSList *items)43char* collect_terms (const std::vector<SPItem*> &items)
44{44{
45 GSList *check = NULL;45 GSList *check = NULL;
46 std::stringstream ss;46 std::stringstream ss;
47 bool first = true;47 bool first = true;
4848
49 for (GSList *i = (GSList *)items; i != NULL; i = i->next) {49 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
50 SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data));50 SPItem *item = *iter;
51 if (item) {51 if (item) {
52 const char *term = item->displayName();52 const char *term = item->displayName();
53 if (term != NULL && g_slist_find (check, term) == NULL) {53 if (term != NULL && g_slist_find (check, term) == NULL) {
@@ -61,12 +61,12 @@
61}61}
6262
63// Returns the number of terms in the list63// Returns the number of terms in the list
64static int count_terms (GSList *items)64static int count_terms (const std::vector<SPItem*> &items)
65{65{
66 GSList *check = NULL;66 GSList *check = NULL;
67 int count=0;67 int count=0;
68 for (GSList *i = (GSList *)items; i != NULL; i = i->next) {68 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
69 SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data));69 SPItem *item = *iter;
70 if (item) {70 if (item) {
71 const char *term = item->displayName();71 const char *term = item->displayName();
72 if (term != NULL && g_slist_find (check, term) == NULL) {72 if (term != NULL && g_slist_find (check, term) == NULL) {
@@ -79,11 +79,11 @@
79}79}
8080
81// Returns the number of filtered items in the list81// Returns the number of filtered items in the list
82static int count_filtered (GSList *items)82static int count_filtered (const std::vector<SPItem*> &items)
83{83{
84 int count=0;84 int count=0;
85 for (GSList *i = items; i != NULL; i = i->next) {85 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
86 SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>((i->data)));86 SPItem *item = *iter;
87 if (item) {87 if (item) {
88 count += item->isFiltered();88 count += item->isFiltered();
89 }89 }
@@ -122,12 +122,12 @@
122}122}
123123
124void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) {124void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) {
125 GSList const *items = selection->itemList();125 std::vector<SPItem*> const items = selection->itemList();
126126
127 if (!items) { // no items127 if (items.empty()) { // no items
128 _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing);128 _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing);
129 } else {129 } else {
130 SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(items->data));130 SPItem *item = items[0];
131 g_assert(item != NULL);131 g_assert(item != NULL);
132 SPObject *layer = selection->layers()->layerForObject(item);132 SPObject *layer = selection->layers()->layerForObject(item);
133 SPObject *root = selection->layers()->currentRoot();133 SPObject *root = selection->layers()->currentRoot();
@@ -188,7 +188,7 @@
188 g_free (layer_name);188 g_free (layer_name);
189 g_free (parent_name);189 g_free (parent_name);
190190
191 if (!items->next) { // one item191 if (items.size()==1) { // one item
192 char *item_desc = item->detailedDescription();192 char *item_desc = item->detailedDescription();
193193
194 bool isUse = dynamic_cast<SPUse *>(item) != NULL;194 bool isUse = dynamic_cast<SPUse *>(item) != NULL;
@@ -228,9 +228,9 @@
228228
229 g_free(item_desc);229 g_free(item_desc);
230 } else { // multiple items230 } else { // multiple items
231 int objcount = g_slist_length((GSList *)items);231 int objcount = items.size();
232 char *terms = collect_terms ((GSList *)items);232 char *terms = collect_terms (items);
233 int n_terms = count_terms((GSList *)items);233 int n_terms = count_terms(items);
234 234
235 gchar *objects_str = g_strdup_printf(ngettext(235 gchar *objects_str = g_strdup_printf(ngettext(
236 "<b>%1$i</b> objects selected of type %2$s",236 "<b>%1$i</b> objects selected of type %2$s",
@@ -241,7 +241,7 @@
241241
242 // indicate all, some, or none filtered242 // indicate all, some, or none filtered
243 gchar *filt_str = NULL;243 gchar *filt_str = NULL;
244 int n_filt = count_filtered((GSList *)items); //all filtered244 int n_filt = count_filtered(items); //all filtered
245 if (n_filt) {245 if (n_filt) {
246 filt_str = g_strdup_printf(ngettext("; <i>%d filtered object</i> ",246 filt_str = g_strdup_printf(ngettext("; <i>%d filtered object</i> ",
247 "; <i>%d filtered objects</i> ", n_filt), n_filt);247 "; <i>%d filtered objects</i> ", n_filt), n_filt);
248248
=== modified file 'src/selection.cpp'
--- src/selection.cpp 2014-06-27 19:23:06 +0000
+++ src/selection.cpp 2015-04-29 21:03:59 +0000
@@ -42,9 +42,11 @@
42namespace Inkscape {42namespace Inkscape {
4343
44Selection::Selection(LayerModel *layers, SPDesktop *desktop) :44Selection::Selection(LayerModel *layers, SPDesktop *desktop) :
45 _objs(NULL),45 _objs(std::list<SPObject*>()),
46 _reprs(NULL),46 _objs_vector(std::vector<SPObject*>()),
47 _items(NULL),47 _objs_set(std::set<SPObject*>()),
48 _reprs(std::vector<XML::Node*>()),
49 _items(std::vector<SPItem*>()),
48 _layers(layers),50 _layers(layers),
49 _desktop(desktop),51 _desktop(desktop),
50 _selection_context(NULL),52 _selection_context(NULL),
@@ -121,17 +123,14 @@
121}123}
122124
123void Selection::_invalidateCachedLists() {125void Selection::_invalidateCachedLists() {
124 g_slist_free(_items);126 _items.clear();
125 _items = NULL;127 _reprs.clear();
126
127 g_slist_free(_reprs);
128 _reprs = NULL;
129}128}
130129
131void Selection::_clear() {130void Selection::_clear() {
132 _invalidateCachedLists();131 _invalidateCachedLists();
133 while (_objs) {132 while (!_objs.empty()) {
134 SPObject *obj=reinterpret_cast<SPObject *>(_objs->data);133 SPObject *obj=_objs.front();
135 _remove(obj);134 _remove(obj);
136 }135 }
137}136}
@@ -148,7 +147,7 @@
148147
149 g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE);148 g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE);
150149
151 return ( g_slist_find(_objs, obj) != NULL );150 return ( _objs_set.find(obj)!=_objs_set.end() );
152}151}
153152
154void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) {153void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) {
@@ -180,7 +179,8 @@
180 _removeObjectDescendants(obj);179 _removeObjectDescendants(obj);
181 _removeObjectAncestors(obj);180 _removeObjectAncestors(obj);
182181
183 _objs = g_slist_prepend(_objs, obj);182 _objs.push_front(obj);
183 _objs_set.insert(obj);
184184
185 add_3D_boxes_recursively(obj);185 add_3D_boxes_recursively(obj);
186186
@@ -234,26 +234,27 @@
234234
235 remove_3D_boxes_recursively(obj);235 remove_3D_boxes_recursively(obj);
236236
237 _objs = g_slist_remove(_objs, obj);237 _objs.remove(obj);
238 _objs_set.erase(obj);
238}239}
239240
240void Selection::setList(GSList const *list) {241void Selection::setList(std::vector<SPItem*> const &list) {
241 // Clear and add, or just clear with emit.242 // Clear and add, or just clear with emit.
242 if (list != NULL) {243 if (!list.empty()) {
243 _clear();244 _clear();
244 addList(list);245 addList(list);
245 } else clear();246 } else clear();
246}247}
247248
248void Selection::addList(GSList const *list) {249void Selection::addList(std::vector<SPItem*> const &list) {
249250
250 if (list == NULL)251 if (list.empty())
251 return;252 return;
252253
253 _invalidateCachedLists();254 _invalidateCachedLists();
254255
255 for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) {256 for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) {
256 SPObject *obj = reinterpret_cast<SPObject *>(iter->data);257 SPObject *obj = *iter;
257 if (includes(obj)) continue;258 if (includes(obj)) continue;
258 _add (obj);259 _add (obj);
259 }260 }
@@ -261,11 +262,11 @@
261 _emitChanged();262 _emitChanged();
262}263}
263264
264void Selection::setReprList(GSList const *list) {265void Selection::setReprList(std::vector<XML::Node*> const &list) {
265 _clear();266 _clear();
266267
267 for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) {268 for ( std::vector<XML::Node*>::const_reverse_iterator iter=list.rbegin();iter!=list.rend();iter++ ) {
268 SPObject *obj=_objectForXMLNode(reinterpret_cast<Inkscape::XML::Node *>(iter->data));269 SPObject *obj=_objectForXMLNode(*iter);
269 if (obj) {270 if (obj) {
270 _add(obj);271 _add(obj);
271 }272 }
@@ -279,35 +280,38 @@
279 _emitChanged();280 _emitChanged();
280}281}
281282
282GSList const *Selection::list() {283std::vector<SPObject*> const &Selection::list() {
283 return _objs;284 if(!_objs_vector.empty())
285 return _objs_vector;
286
287 for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) {
288 _objs_vector.push_back(*iter);
289 }
290 return _objs_vector;
291
284}292}
285293
286GSList const *Selection::itemList() {294std::vector<SPItem*> const &Selection::itemList() {
287 if (_items) {295 if (!_items.empty()) {
288 return _items;296 return _items;
289 }297 }
290298
291 for ( GSList const *iter=_objs ; iter != NULL ; iter = iter->next ) {299 for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) {
292 SPObject *obj=reinterpret_cast<SPObject *>(iter->data);300 SPObject *obj=*iter;
293 if (SP_IS_ITEM(obj)) {301 if (SP_IS_ITEM(obj)) {
294 _items = g_slist_prepend(_items, SP_ITEM(obj));302 _items.push_back(SP_ITEM(obj));
295 }303 }
296 }304 }
297 _items = g_slist_reverse(_items);
298
299 return _items;305 return _items;
300}306}
301307
302GSList const *Selection::reprList() {308std::vector<XML::Node*> const &Selection::reprList() {
303 if (_reprs) { return _reprs; }309 if (!_reprs.empty()) { return _reprs; }
304310 std::vector<SPItem*> list = itemList();
305 for ( GSList const *iter=itemList() ; iter != NULL ; iter = iter->next ) {311 for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) {
306 SPObject *obj=reinterpret_cast<SPObject *>(iter->data);312 SPObject *obj = *iter;
307 _reprs = g_slist_prepend(_reprs, obj->getRepr());313 _reprs.push_back(obj->getRepr());
308 }314 }
309 _reprs = g_slist_reverse(_reprs);
310
311 return _reprs;315 return _reprs;
312}316}
313317
@@ -337,17 +341,17 @@
337}341}
338342
339SPObject *Selection::single() {343SPObject *Selection::single() {
340 if ( _objs != NULL && _objs->next == NULL ) {344 if ( _objs.size() == 1 ) {
341 return reinterpret_cast<SPObject *>(_objs->data);345 return _objs.front();
342 } else {346 } else {
343 return NULL;347 return NULL;
344 }348 }
345}349}
346350
347SPItem *Selection::singleItem() {351SPItem *Selection::singleItem() {
348 GSList const *items=itemList();352 std::vector<SPItem*> const items=itemList();
349 if ( items != NULL && items->next == NULL ) {353 if ( items.size()==1) {
350 return reinterpret_cast<SPItem *>(items->data);354 return items[0];
351 } else {355 } else {
352 return NULL;356 return NULL;
353 }357 }
@@ -362,12 +366,12 @@
362}366}
363367
364SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) {368SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) {
365 GSList const *items = const_cast<Selection *>(this)->itemList();369 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
366 gdouble max = sml ? 1e18 : 0;370 gdouble max = sml ? 1e18 : 0;
367 SPItem *ist = NULL;371 SPItem *ist = NULL;
368372
369 for ( GSList const *i = items; i != NULL ; i = i->next ) {373 for ( std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++ ) {
370 Geom::OptRect obox = SP_ITEM(i->data)->desktopPreferredBounds();374 Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds();
371 if (!obox || obox.isEmpty()) continue;375 if (!obox || obox.isEmpty()) continue;
372 Geom::Rect bbox = *obox;376 Geom::Rect bbox = *obox;
373377
@@ -376,7 +380,7 @@
376 size = sml ? size : size * -1;380 size = sml ? size : size * -1;
377 if (size < max) {381 if (size < max) {
378 max = size;382 max = size;
379 ist = SP_ITEM(i->data);383 ist = SP_ITEM(*i);
380 }384 }
381 }385 }
382 return ist;386 return ist;
@@ -395,22 +399,22 @@
395399
396Geom::OptRect Selection::geometricBounds() const400Geom::OptRect Selection::geometricBounds() const
397{401{
398 GSList const *items = const_cast<Selection *>(this)->itemList();402 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
399403
400 Geom::OptRect bbox;404 Geom::OptRect bbox;
401 for ( GSList const *i = items ; i != NULL ; i = i->next ) {405 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
402 bbox.unionWith(SP_ITEM(i->data)->desktopGeometricBounds());406 bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds());
403 }407 }
404 return bbox;408 return bbox;
405}409}
406410
407Geom::OptRect Selection::visualBounds() const411Geom::OptRect Selection::visualBounds() const
408{412{
409 GSList const *items = const_cast<Selection *>(this)->itemList();413 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
410414
411 Geom::OptRect bbox;415 Geom::OptRect bbox;
412 for ( GSList const *i = items ; i != NULL ; i = i->next ) {416 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
413 bbox.unionWith(SP_ITEM(i->data)->desktopVisualBounds());417 bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds());
414 }418 }
415 return bbox;419 return bbox;
416}420}
@@ -427,11 +431,11 @@
427Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const431Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const
428{432{
429 Geom::OptRect bbox;433 Geom::OptRect bbox;
430 GSList const *items = const_cast<Selection *>(this)->itemList();434 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
431 if (!items) return bbox;435 if (items.empty()) return bbox;
432436
433 for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) {437 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
434 SPItem *item = SP_ITEM(iter->data);438 SPItem *item = SP_ITEM(*iter);
435 bbox |= item->documentBounds(type);439 bbox |= item->documentBounds(type);
436 }440 }
437441
@@ -441,9 +445,9 @@
441// If we have a selection of multiple items, then the center of the first item445// If we have a selection of multiple items, then the center of the first item
442// will be returned; this is also the case in SelTrans::centerRequest()446// will be returned; this is also the case in SelTrans::centerRequest()
443boost::optional<Geom::Point> Selection::center() const {447boost::optional<Geom::Point> Selection::center() const {
444 GSList *items = (GSList *) const_cast<Selection *>(this)->itemList();448 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
445 if (items) {449 if (!items.empty()) {
446 SPItem *first = reinterpret_cast<SPItem*>(g_slist_last(items)->data); // from the first item in selection450 SPItem *first = items.back(); // from the first item in selection
447 if (first->isCenterSet()) { // only if set explicitly451 if (first->isCenterSet()) { // only if set explicitly
448 return first->getCenter();452 return first->getCenter();
449 }453 }
@@ -457,13 +461,13 @@
457}461}
458462
459std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const {463std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const {
460 GSList const *items = const_cast<Selection *>(this)->itemList();464 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
461465
462 SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs466 SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs
463 snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center467 snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center
464 std::vector<Inkscape::SnapCandidatePoint> p;468 std::vector<Inkscape::SnapCandidatePoint> p;
465 for (GSList const *iter = items; iter != NULL; iter = iter->next) {469 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
466 SPItem *this_item = SP_ITEM(iter->data);470 SPItem *this_item = *iter;
467 this_item->getSnappoints(p, &snapprefs_dummy);471 this_item->getSnappoints(p, &snapprefs_dummy);
468472
469 //Include the transformation origin for snapping473 //Include the transformation origin for snapping
@@ -477,10 +481,8 @@
477}481}
478482
479void Selection::_removeObjectDescendants(SPObject *obj) {483void Selection::_removeObjectDescendants(SPObject *obj) {
480 GSList *iter, *next;484 for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) {
481 for ( iter = _objs ; iter ; iter = next ) {485 SPObject *sel_obj= *iter;
482 next = iter->next;
483 SPObject *sel_obj=reinterpret_cast<SPObject *>(iter->data);
484 SPObject *parent = sel_obj->parent;486 SPObject *parent = sel_obj->parent;
485 while (parent) {487 while (parent) {
486 if ( parent == obj ) {488 if ( parent == obj ) {
@@ -511,32 +513,24 @@
511 return object;513 return object;
512}514}
513515
514guint Selection::numberOfLayers() {516uint Selection::numberOfLayers() {
515 GSList const *items = const_cast<Selection *>(this)->itemList();517 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
516 GSList *layers = NULL;518 std::set<SPObject*> layers;
517 for (GSList const *iter = items; iter != NULL; iter = iter->next) {519 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
518 SPObject *layer = _layers->layerForObject(SP_OBJECT(iter->data));520 SPObject *layer = _layers->layerForObject(*iter);
519 if (g_slist_find (layers, layer) == NULL) {521 layers.insert(layer);
520 layers = g_slist_prepend (layers, layer);
521 }
522 }522 }
523 guint ret = g_slist_length (layers);523 return layers.size();
524 g_slist_free (layers);
525 return ret;
526}524}
527525
528guint Selection::numberOfParents() {526guint Selection::numberOfParents() {
529 GSList const *items = const_cast<Selection *>(this)->itemList();527 std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList();
530 GSList *parents = NULL;528 std::set<SPObject*> parents;
531 for (GSList const *iter = items; iter != NULL; iter = iter->next) {529 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
532 SPObject *parent = SP_OBJECT(iter->data)->parent;530 SPObject *parent = (*iter)->parent;
533 if (g_slist_find (parents, parent) == NULL) {531 parents.insert(parent);
534 parents = g_slist_prepend (parents, parent);
535 }
536 }532 }
537 guint ret = g_slist_length (parents);533 return parents.size();
538 g_slist_free (parents);
539 return ret;
540}534}
541535
542}536}
543537
=== modified file 'src/selection.h'
--- src/selection.h 2015-02-26 02:49:35 +0000
+++ src/selection.h 2015-04-29 21:03:59 +0000
@@ -16,6 +16,7 @@
16#include <vector>16#include <vector>
17#include <map>17#include <map>
18#include <list>18#include <list>
19#include <set>
19#include <stddef.h>20#include <stddef.h>
20#include <sigc++/sigc++.h>21#include <sigc++/sigc++.h>
2122
@@ -26,11 +27,11 @@
26#include "sp-item.h"27#include "sp-item.h"
2728
2829
30
29class SPDesktop;31class SPDesktop;
30class SPItem;32class SPItem;
31class SPBox3D;33class SPBox3D;
32class Persp3D;34class Persp3D;
33typedef struct _GSList GSList;
3435
35namespace Inkscape {36namespace Inkscape {
36class LayerModel;37class LayerModel;
@@ -39,6 +40,7 @@
39}40}
40}41}
4142
43
42namespace Inkscape {44namespace Inkscape {
4345
44/**46/**
@@ -154,21 +156,21 @@
154 *156 *
155 * @param objs the objects to select157 * @param objs the objects to select
156 */158 */
157 void setList(GSList const *objs);159 void setList(std::vector<SPItem*> const &objs);
158160
159 /**161 /**
160 * Adds the specified objects to selection, without deselecting first.162 * Adds the specified objects to selection, without deselecting first.
161 *163 *
162 * @param objs the objects to select164 * @param objs the objects to select
163 */165 */
164 void addList(GSList const *objs);166 void addList(std::vector<SPItem*> const &objs);
165167
166 /**168 /**
167 * Clears the selection and selects the specified objects.169 * Clears the selection and selects the specified objects.
168 *170 *
169 * @param repr a list of xml nodes for the items to select171 * @param repr a list of xml nodes for the items to select
170 */172 */
171 void setReprList(GSList const *reprs);173 void setReprList(std::vector<XML::Node*> const &reprs);
172174
173 /** Add items from an STL iterator range to the selection.175 /** Add items from an STL iterator range to the selection.
174 * \param from the begin iterator176 * \param from the begin iterator
@@ -192,7 +194,7 @@
192 /**194 /**
193 * Returns true if no items are selected.195 * Returns true if no items are selected.
194 */196 */
195 bool isEmpty() const { return _objs == NULL; }197 bool isEmpty() const { return _objs.empty(); }
196198
197 /**199 /**
198 * Returns true if the given object is selected.200 * Returns true if the given object is selected.
@@ -238,13 +240,13 @@
238 XML::Node *singleRepr();240 XML::Node *singleRepr();
239241
240 /** Returns the list of selected objects. */242 /** Returns the list of selected objects. */
241 GSList const *list();243 std::vector<SPObject*> const &list();
242 /** Returns the list of selected SPItems. */244 /** Returns the list of selected SPItems. */
243 GSList const *itemList();245 std::vector<SPItem*> const &itemList();
244 /** Returns a list of the xml nodes of all selected objects. */246 /** Returns a list of the xml nodes of all selected objects. */
245 /// \todo only returns reprs of SPItems currently; need a separate247 /// \todo only returns reprs of SPItems currently; need a separate
246 /// method for that248 /// method for that
247 GSList const *reprList();249 std::vector<XML::Node*> const &reprList();
248250
249 /** Returns a list of all perspectives which have a 3D box in the current selection.251 /** Returns a list of all perspectives which have a 3D box in the current selection.
250 (these may also be nested in groups) */252 (these may also be nested in groups) */
@@ -360,9 +362,11 @@
360 /** Releases an active layer object that is being removed. */362 /** Releases an active layer object that is being removed. */
361 void _releaseContext(SPObject *obj);363 void _releaseContext(SPObject *obj);
362364
363 mutable GSList *_objs;365 mutable std::list<SPObject*> _objs; //to more efficiently remove arbitrary elements
364 mutable GSList *_reprs;366 mutable std::vector<SPObject*> _objs_vector; // to be returned by list();
365 mutable GSList *_items;367 mutable std::set<SPObject*> _objs_set; //to efficiently test if object is selected
368 mutable std::vector<XML::Node*> _reprs;
369 mutable std::vector<SPItem*> _items;
366370
367 void add_box_perspective(SPBox3D *box);371 void add_box_perspective(SPBox3D *box);
368 void add_3D_boxes_recursively(SPObject *obj);372 void add_3D_boxes_recursively(SPObject *obj);
369373
=== modified file 'src/seltrans.cpp'
--- src/seltrans.cpp 2014-12-21 21:58:32 +0000
+++ src/seltrans.cpp 2015-04-29 21:03:59 +0000
@@ -112,7 +112,7 @@
112 _opposite_for_bboxpoints(Geom::Point(0,0)),112 _opposite_for_bboxpoints(Geom::Point(0,0)),
113 _origin_for_specpoints(Geom::Point(0,0)),113 _origin_for_specpoints(Geom::Point(0,0)),
114 _origin_for_bboxpoints(Geom::Point(0,0)),114 _origin_for_bboxpoints(Geom::Point(0,0)),
115 _stamp_cache(NULL),115 _stamp_cache(std::vector<SPItem*>()),
116 _message_context(desktop->messageStack()),116 _message_context(desktop->messageStack()),
117 _bounding_box_prefs_observer(*this)117 _bounding_box_prefs_observer(*this)
118{118{
@@ -239,8 +239,9 @@
239 _center_is_set = true;239 _center_is_set = true;
240240
241 // Write the new center position into all selected items241 // Write the new center position into all selected items
242 for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) {242 std::vector<SPItem*> items=_desktop->selection->itemList();
243 SPItem *it = SP_ITEM(l->data);243 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
244 SPItem *it = SP_ITEM(*iter);
244 it->setCenter(p);245 it->setCenter(p);
245 // only set the value; updating repr and document_done will be done once, on ungrab246 // only set the value; updating repr and document_done will be done once, on ungrab
246 }247 }
@@ -268,8 +269,9 @@
268 return;269 return;
269 }270 }
270271
271 for (GSList const *l = selection->itemList(); l; l = l->next) {272 std::vector<SPItem*> items=_desktop->selection->itemList();
272 SPItem *it = reinterpret_cast<SPItem*>(sp_object_ref(SP_ITEM(l->data), NULL));273 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
274 SPItem *it = static_cast<SPItem*>(sp_object_ref(*iter, NULL));
273 _items.push_back(it);275 _items.push_back(it);
274 _items_const.push_back(it);276 _items_const.push_back(it);
275 _items_affines.push_back(it->i2dt_affine());277 _items_affines.push_back(it->i2dt_affine());
@@ -370,7 +372,7 @@
370 }372 }
371373
372 _updateHandles();374 _updateHandles();
373 g_return_if_fail(_stamp_cache == NULL);375 g_return_if_fail(_stamp_cache.empty());
374}376}
375377
376void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point const &norm)378void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point const &norm)
@@ -432,10 +434,8 @@
432 for (int i = 0; i < 4; i++)434 for (int i = 0; i < 4; i++)
433 sp_canvas_item_hide(_l[i]);435 sp_canvas_item_hide(_l[i]);
434 }436 }
435437 if(!_stamp_cache.empty()){
436 if (_stamp_cache) {438 _stamp_cache.clear();
437 g_slist_free(_stamp_cache);
438 _stamp_cache = NULL;
439 }439 }
440440
441 _message_context.clear();441 _message_context.clear();
@@ -491,8 +491,9 @@
491491
492 if (_center_is_set) {492 if (_center_is_set) {
493 // we were dragging center; update reprs and commit undoable action493 // we were dragging center; update reprs and commit undoable action
494 for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) {494 std::vector<SPItem*> items=_desktop->selection->itemList();
495 SPItem *it = SP_ITEM(l->data);495 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
496 SPItem *it = *iter;
496 it->updateRepr();497 it->updateRepr();
497 }498 }
498 DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT,499 DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT,
@@ -515,26 +516,25 @@
515 Inkscape::Selection *selection = _desktop->getSelection();516 Inkscape::Selection *selection = _desktop->getSelection();
516517
517 bool fixup = !_grabbed;518 bool fixup = !_grabbed;
518 if ( fixup && _stamp_cache ) {519 if ( fixup && !_stamp_cache.empty() ) {
519 // TODO - give a proper fix. Simple temporary work-around for the grab() issue520 // TODO - give a proper fix. Simple temporary work-around for the grab() issue
520 g_slist_free(_stamp_cache);521 _stamp_cache.clear();
521 _stamp_cache = NULL;
522 }522 }
523523
524 /* stamping mode */524 /* stamping mode */
525 if (!_empty) {525 if (!_empty) {
526 GSList *l;526 std::vector<SPItem*> l;
527 if (_stamp_cache) {527 if (!_stamp_cache.empty()) {
528 l = _stamp_cache;528 l = _stamp_cache;
529 } else {529 } else {
530 /* Build cache */530 /* Build cache */
531 l = g_slist_copy((GSList *) selection->itemList());531 l = selection->itemList();
532 l = g_slist_sort(l, (GCompareFunc) sp_object_compare_position);532 sort(l.begin(),l.end(),sp_object_compare_position);
533 _stamp_cache = l;533 _stamp_cache = l;
534 }534 }
535535
536 while (l) {536 for(std::vector<SPItem*>::const_iterator x=l.begin();x!=l.end();x++) {
537 SPItem *original_item = SP_ITEM(l->data);537 SPItem *original_item = *x;
538 Inkscape::XML::Node *original_repr = original_item->getRepr();538 Inkscape::XML::Node *original_repr = original_item->getRepr();
539539
540 // remember the position of the item540 // remember the position of the item
@@ -568,16 +568,14 @@
568 }568 }
569569
570 Inkscape::GC::release(copy_repr);570 Inkscape::GC::release(copy_repr);
571 l = l->next;
572 }571 }
573 DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT,572 DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT,
574 _("Stamp"));573 _("Stamp"));
575 }574 }
576575
577 if ( fixup && _stamp_cache ) {576 if ( fixup && !_stamp_cache.empty() ) {
578 // TODO - give a proper fix. Simple temporary work-around for the grab() issue577 // TODO - give a proper fix. Simple temporary work-around for the grab() issue
579 g_slist_free(_stamp_cache);578 _stamp_cache.clear();
580 _stamp_cache = NULL;
581 }579 }
582}580}
583581
@@ -712,8 +710,9 @@
712 case HANDLE_CENTER:710 case HANDLE_CENTER:
713 if (state & GDK_SHIFT_MASK) {711 if (state & GDK_SHIFT_MASK) {
714 // Unset the center position for all selected items712 // Unset the center position for all selected items
715 for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) {713 std::vector<SPItem*> items=_desktop->selection->itemList();
716 SPItem *it = SP_ITEM(l->data);714 for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) {
715 SPItem *it = *iter;
717 it->unsetCenter();716 it->unsetCenter();
718 it->updateRepr();717 it->updateRepr();
719 _center_is_set = false; // center has changed718 _center_is_set = false; // center has changed
@@ -1283,7 +1282,7 @@
1283 // items will share a single center. While dragging that single center, it should never snap to the1282 // items will share a single center. While dragging that single center, it should never snap to the
1284 // centers of any of the selected objects. Therefore we will have to pass the list of selected items1283 // centers of any of the selected objects. Therefore we will have to pass the list of selected items
1285 // to the snapper, to avoid self-snapping of the rotation center1284 // to the snapper, to avoid self-snapping of the rotation center
1286 GSList *items = (GSList *) const_cast<Selection *>(_selection)->itemList();1285 std::vector<SPItem*> items = const_cast<Selection *>(_selection)->itemList();
1287 SnapManager &m = _desktop->namedview->snap_manager;1286 SnapManager &m = _desktop->namedview->snap_manager;
1288 m.setup(_desktop);1287 m.setup(_desktop);
1289 m.setRotationCenterSource(items);1288 m.setRotationCenterSource(items);
12901289
=== modified file 'src/seltrans.h'
--- src/seltrans.h 2014-10-08 02:22:03 +0000
+++ src/seltrans.h 2015-04-29 21:03:59 +0000
@@ -187,7 +187,7 @@
187 SPCtrlLine *_l[4];187 SPCtrlLine *_l[4];
188 unsigned int _sel_changed_id;188 unsigned int _sel_changed_id;
189 unsigned int _sel_modified_id;189 unsigned int _sel_modified_id;
190 GSList *_stamp_cache;190 std::vector<SPItem*> _stamp_cache;
191191
192 Geom::Point _origin; ///< position of origin for transforms192 Geom::Point _origin; ///< position of origin for transforms
193 Geom::Point _point; ///< original position of the knot being used for the current transform193 Geom::Point _point; ///< original position of the knot being used for the current transform
194194
=== modified file 'src/snap.cpp'
--- src/snap.cpp 2015-02-25 23:08:51 +0000
+++ src/snap.cpp 2015-04-29 21:03:59 +0000
@@ -43,7 +43,7 @@
43 object(this, 0),43 object(this, 0),
44 snapprefs(),44 snapprefs(),
45 _named_view(v),45 _named_view(v),
46 _rotation_center_source_items(NULL),46 _rotation_center_source_items(std::vector<SPItem*>()),
47 _guide_to_ignore(NULL),47 _guide_to_ignore(NULL),
48 _desktop(NULL),48 _desktop(NULL),
49 _snapindicator(true),49 _snapindicator(true),
@@ -1013,7 +1013,7 @@
1013 _snapindicator = snapindicator;1013 _snapindicator = snapindicator;
1014 _unselected_nodes = unselected_nodes;1014 _unselected_nodes = unselected_nodes;
1015 _guide_to_ignore = guide_to_ignore;1015 _guide_to_ignore = guide_to_ignore;
1016 _rotation_center_source_items = NULL;1016 _rotation_center_source_items.clear();
1017}1017}
10181018
1019void SnapManager::setup(SPDesktop const *desktop,1019void SnapManager::setup(SPDesktop const *desktop,
@@ -1031,7 +1031,7 @@
1031 _snapindicator = snapindicator;1031 _snapindicator = snapindicator;
1032 _unselected_nodes = unselected_nodes;1032 _unselected_nodes = unselected_nodes;
1033 _guide_to_ignore = guide_to_ignore;1033 _guide_to_ignore = guide_to_ignore;
1034 _rotation_center_source_items = NULL;1034 _rotation_center_source_items.clear();
1035}1035}
10361036
1037/// Setup, taking the list of items to ignore from the desktop's selection.1037/// Setup, taking the list of items to ignore from the desktop's selection.
@@ -1049,13 +1049,13 @@
1049 _snapindicator = snapindicator;1049 _snapindicator = snapindicator;
1050 _unselected_nodes = unselected_nodes;1050 _unselected_nodes = unselected_nodes;
1051 _guide_to_ignore = guide_to_ignore;1051 _guide_to_ignore = guide_to_ignore;
1052 _rotation_center_source_items = NULL;1052 _rotation_center_source_items.clear();
1053 _items_to_ignore.clear();1053 _items_to_ignore.clear();
10541054
1055 Inkscape::Selection *sel = _desktop->selection;1055 Inkscape::Selection *sel = _desktop->selection;
1056 GSList const *items = sel->itemList();1056 std::vector<SPItem*> const items = sel->itemList();
1057 for (GSList *i = const_cast<GSList*>(items); i; i = i->next) {1057 for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) {
1058 _items_to_ignore.push_back(static_cast<SPItem const *>(i->data));1058 _items_to_ignore.push_back(*i);
1059 }1059 }
1060}1060}
10611061
10621062
=== modified file 'src/snap.h'
--- src/snap.h 2014-10-08 02:22:03 +0000
+++ src/snap.h 2015-04-29 21:03:59 +0000
@@ -136,7 +136,7 @@
136 std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes = NULL,136 std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes = NULL,
137 SPGuide *guide_to_ignore = NULL);137 SPGuide *guide_to_ignore = NULL);
138138
139 void unSetup() {_rotation_center_source_items = NULL;139 void unSetup() {_rotation_center_source_items.clear();
140 _guide_to_ignore = NULL;140 _guide_to_ignore = NULL;
141 _desktop = NULL;141 _desktop = NULL;
142 _unselected_nodes = NULL;}142 _unselected_nodes = NULL;}
@@ -145,8 +145,8 @@
145 // of this rotation center; this reference is used to make sure that we do not snap a rotation145 // of this rotation center; this reference is used to make sure that we do not snap a rotation
146 // center to itself146 // center to itself
147 // NOTE: Must be called after calling setup(), not before!147 // NOTE: Must be called after calling setup(), not before!
148 void setRotationCenterSource(GSList *items) {_rotation_center_source_items = items;}148 void setRotationCenterSource(const std::vector<SPItem*> &items) {_rotation_center_source_items = items;}
149 GSList const *getRotationCenterSource() {return _rotation_center_source_items;}149 const std::vector<SPItem*> &getRotationCenterSource() {return _rotation_center_source_items;}
150150
151 // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a151 // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a
152 // point if snapping has occurred (by overwriting p); otherwise p is untouched152 // point if snapping has occurred (by overwriting p); otherwise p is untouched
@@ -490,7 +490,7 @@
490490
491private:491private:
492 std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method492 std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method
493 GSList *_rotation_center_source_items; // to avoid snapping a rotation center to itself493 std::vector<SPItem*> _rotation_center_source_items; // to avoid snapping a rotation center to itself
494 SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged494 SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged
495 SPDesktop const *_desktop;495 SPDesktop const *_desktop;
496 bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to496 bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to
497497
=== modified file 'src/sp-conn-end.cpp'
--- src/sp-conn-end.cpp 2014-03-30 22:01:25 +0000
+++ src/sp-conn-end.cpp 2015-04-29 21:03:59 +0000
@@ -50,8 +50,9 @@
5050
51 // consider all first-order children51 // consider all first-order children
52 double child_pos = 0.0;52 double child_pos = 0.0;
53 for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) {53 std::vector<SPItem*> g = sp_item_group_item_list(group);
54 SPItem* child_item = SP_ITEM(i->data);54 for (std::vector<SPItem*>::const_iterator i = g.begin();i!=g.end();i++) {
55 SPItem* child_item = *i;
55 try_get_intersect_point_with_item_recursive(conn_pv, child_item,56 try_get_intersect_point_with_item_recursive(conn_pv, child_item,
56 item_transform * child_item->transform, child_pos);57 item_transform * child_item->transform, child_pos);
57 if (intersect_pos < child_pos)58 if (intersect_pos < child_pos)
5859
=== modified file 'src/sp-defs.cpp'
--- src/sp-defs.cpp 2015-02-25 00:22:08 +0000
+++ src/sp-defs.cpp 2015-04-29 21:03:59 +0000
@@ -36,11 +36,9 @@
36 }36 }
3737
38 flags &= SP_OBJECT_MODIFIED_CASCADE;38 flags &= SP_OBJECT_MODIFIED_CASCADE;
3939 std::vector<SPObject*> l(this->childList(true));
40 GSList *l = g_slist_reverse(this->childList(true));40 for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){
41 while (l) {41 SPObject *child = *i;
42 SPObject *child = SP_OBJECT(l->data);
43 l = g_slist_remove(l, child);
44 if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {42 if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
45 child->updateDisplay(ctx, flags);43 child->updateDisplay(ctx, flags);
46 }44 }
4745
=== modified file 'src/sp-filter.cpp'
--- src/sp-filter.cpp 2015-02-25 00:22:08 +0000
+++ src/sp-filter.cpp 2015-04-29 21:03:59 +0000
@@ -235,11 +235,9 @@
235 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;235 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
236 }236 }
237 childflags &= SP_OBJECT_MODIFIED_CASCADE;237 childflags &= SP_OBJECT_MODIFIED_CASCADE;
238238 std::vector<SPObject*> l(this->childList(true, SPObject::ActionUpdate));
239 GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate));239 for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){
240 while (l) {240 SPObject *child = *i;
241 SPObject *child = SP_OBJECT (l->data);
242 l = g_slist_remove (l, child);
243 if( SP_IS_FILTER_PRIMITIVE( child ) ) {241 if( SP_IS_FILTER_PRIMITIVE( child ) ) {
244 child->updateDisplay(ctx, childflags);242 child->updateDisplay(ctx, childflags);
245 }243 }
246244
=== modified file 'src/sp-item-group.cpp'
--- src/sp-item-group.cpp 2015-03-12 08:19:08 +0000
+++ src/sp-item-group.cpp 2015-04-29 21:03:59 +0000
@@ -161,11 +161,9 @@
161 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;161 childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
162 }162 }
163 childflags &= SP_OBJECT_MODIFIED_CASCADE;163 childflags &= SP_OBJECT_MODIFIED_CASCADE;
164164 std::vector<SPObject*> l=this->childList(true, SPObject::ActionUpdate);
165 GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate));165 for(std::vector<SPObject*> ::const_iterator i=l.begin();i!=l.end();i++){
166 while (l) {166 SPObject *child = *i;
167 SPObject *child = SP_OBJECT (l->data);
168 l = g_slist_remove (l, child);
169167
170 if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {168 if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
171 SPItem *item = dynamic_cast<SPItem *>(child);169 SPItem *item = dynamic_cast<SPItem *>(child);
@@ -201,20 +199,15 @@
201void SPGroup::modified(guint flags) {199void SPGroup::modified(guint flags) {
202 // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl;200 // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl;
203 SPLPEItem::modified(flags);201 SPLPEItem::modified(flags);
204
205 SPObject *child;
206
207 if (flags & SP_OBJECT_MODIFIED_FLAG) {202 if (flags & SP_OBJECT_MODIFIED_FLAG) {
208 flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;203 flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
209 }204 }
210205
211 flags &= SP_OBJECT_MODIFIED_CASCADE;206 flags &= SP_OBJECT_MODIFIED_CASCADE;
212207
213 GSList *l = g_slist_reverse(this->childList(true));208 std::vector<SPObject*> l=this->childList(true);
214209 for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){
215 while (l) {210 SPObject *child = *i;
216 child = SP_OBJECT (l->data);
217 l = g_slist_remove (l, child);
218211
219 if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {212 if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
220 child->emitModified(flags);213 child->emitModified(flags);
@@ -286,35 +279,27 @@
286 Geom::OptRect bbox;279 Geom::OptRect bbox;
287280
288 // TODO CPPIFY: replace this const_cast later281 // TODO CPPIFY: replace this const_cast later
289 GSList *l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox);282 std::vector<SPObject*> l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox);
290283 for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){
291 while (l) {284 SPObject *o = *i;
292 SPObject *o = SP_OBJECT (l->data);
293
294 SPItem *item = dynamic_cast<SPItem *>(o);285 SPItem *item = dynamic_cast<SPItem *>(o);
295 if (item && !item->isHidden()) {286 if (item && !item->isHidden()) {
296 Geom::Affine const ct(item->transform * transform);287 Geom::Affine const ct(item->transform * transform);
297 bbox |= item->bounds(bboxtype, ct);288 bbox |= item->bounds(bboxtype, ct);
298 }289 }
299
300 l = g_slist_remove (l, o);
301 }290 }
302291
303 return bbox;292 return bbox;
304}293}
305294
306void SPGroup::print(SPPrintContext *ctx) {295void SPGroup::print(SPPrintContext *ctx) {
307 GSList *l = g_slist_reverse(this->childList(false));296 std::vector<SPObject*> l=this->childList(false);
308297 for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){
309 while (l) {298 SPObject *o = *i;
310 SPObject *o = SP_OBJECT (l->data);
311
312 SPItem *item = dynamic_cast<SPItem *>(o);299 SPItem *item = dynamic_cast<SPItem *>(o);
313 if (item) {300 if (item) {
314 item->invoke_print(ctx);301 item->invoke_print(ctx);
315 }302 }
316
317 l = g_slist_remove (l, o);
318 }303 }
319}304}
320305
@@ -362,17 +347,14 @@
362}347}
363348
364void SPGroup::hide (unsigned int key) {349void SPGroup::hide (unsigned int key) {
365 GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow));350 std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow);
366351 for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){
367 while (l) {352 SPObject *o = *i;
368 SPObject *o = SP_OBJECT (l->data);
369353
370 SPItem *item = dynamic_cast<SPItem *>(o);354 SPItem *item = dynamic_cast<SPItem *>(o);
371 if (item) {355 if (item) {
372 item->invoke_hide(key);356 item->invoke_hide(key);
373 }357 }
374
375 l = g_slist_remove (l, o);
376 }358 }
377359
378// SPLPEItem::onHide(key);360// SPLPEItem::onHide(key);
@@ -407,7 +389,7 @@
407}389}
408390
409void391void
410sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)392sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done)
411{393{
412 g_return_if_fail (group != NULL);394 g_return_if_fail (group != NULL);
413395
@@ -564,8 +546,8 @@
564 }546 }
565547
566 Inkscape::GC::release(repr);548 Inkscape::GC::release(repr);
567 if (children && item) {549 if (!children.empty() && item) {
568 *children = g_slist_prepend(*children, item);550 children.insert(children.begin(),item);
569 }551 }
570552
571 items = g_slist_remove (items, items->data);553 items = g_slist_remove (items, items->data);
@@ -580,19 +562,17 @@
580 * some API for list aspect of SPGroup562 * some API for list aspect of SPGroup
581 */563 */
582564
583GSList *sp_item_group_item_list(SPGroup * group)565std::vector<SPItem*> sp_item_group_item_list(SPGroup * group)
584{566{
585 g_return_val_if_fail(group != NULL, NULL);567 std::vector<SPItem*> s;
586568 g_return_val_if_fail(group != NULL, s);
587 GSList *s = NULL;
588569
589 for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {570 for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
590 if ( dynamic_cast<SPItem *>(o) ) {571 if ( dynamic_cast<SPItem *>(o) ) {
591 s = g_slist_prepend(s, o);572 s.push_back((SPItem*)o);
592 }573 }
593 }574 }
594575 return s;
595 return g_slist_reverse (s);
596}576}
597577
598SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name)578SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name)
@@ -807,9 +787,9 @@
807787
808void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) {788void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) {
809 Inkscape::DrawingItem *ac = NULL;789 Inkscape::DrawingItem *ac = NULL;
810 GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow));790 std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow);
811 while (l) {791 for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){
812 SPObject *o = SP_OBJECT (l->data);792 SPObject *o = *i;
813 SPItem * child = dynamic_cast<SPItem *>(o);793 SPItem * child = dynamic_cast<SPItem *>(o);
814 if (child) {794 if (child) {
815 ac = child->invoke_show (drawing, key, flags);795 ac = child->invoke_show (drawing, key, flags);
@@ -817,7 +797,6 @@
817 ai->appendChild(ac);797 ai->appendChild(ac);
818 }798 }
819 }799 }
820 l = g_slist_remove (l, o);
821 }800 }
822}801}
823802
@@ -826,10 +805,10 @@
826 g_message("sp_group_update_patheffect: %p\n", lpeitem);805 g_message("sp_group_update_patheffect: %p\n", lpeitem);
827#endif806#endif
828807
829 GSList const *item_list = sp_item_group_item_list(this);808 std::vector<SPItem*> const item_list = sp_item_group_item_list(this);
830809
831 for ( GSList const *iter = item_list; iter; iter = iter->next ) {810 for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
832 SPObject *subitem = static_cast<SPObject *>(iter->data);811 SPObject *subitem = *iter;
833812
834 SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(subitem);813 SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(subitem);
835 if (lpeItem) {814 if (lpeItem) {
@@ -854,10 +833,10 @@
854static void833static void
855sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)834sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
856{835{
857 GSList const *item_list = sp_item_group_item_list(group);836 std::vector<SPItem*> const item_list = sp_item_group_item_list(group);
858837
859 for ( GSList const *iter = item_list; iter; iter = iter->next ) {838 for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
860 SPObject *subitem = static_cast<SPObject *>(iter->data);839 SPObject *subitem = *iter;
861840
862 SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem);841 SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem);
863 if (subGroup) {842 if (subGroup) {
864843
=== modified file 'src/sp-item-group.h'
--- src/sp-item-group.h 2015-02-21 16:23:30 +0000
+++ src/sp-item-group.h 2015-04-29 21:03:59 +0000
@@ -95,6 +95,7 @@
95 virtual void update_patheffect(bool write);95 virtual void update_patheffect(bool write);
96};96};
9797
98
98/**99/**
99 * finds clones of a child of the group going out of the group; and inverse the group transform on its clones100 * finds clones of a child of the group going out of the group; and inverse the group transform on its clones
100 * Also called when moving objects between different layers101 * Also called when moving objects between different layers
@@ -104,10 +105,11 @@
104 */105 */
105void sp_item_group_ungroup_handle_clones(SPItem *parent, Geom::Affine const g);106void sp_item_group_ungroup_handle_clones(SPItem *parent, Geom::Affine const g);
106107
107void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true);108void sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done = true);
108109
109110
110GSList *sp_item_group_item_list (SPGroup *group);111std::vector<SPItem*> sp_item_group_item_list (SPGroup *group);
112
111SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name);113SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name);
112114
113#endif115#endif
114116
=== modified file 'src/sp-lpe-item.cpp'
--- src/sp-lpe-item.cpp 2015-03-12 08:19:08 +0000
+++ src/sp-lpe-item.cpp 2015-04-29 21:03:59 +0000
@@ -353,9 +353,9 @@
353 sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild()));353 sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild()));
354 }354 }
355 if (SP_IS_GROUP(lpeitem)) {355 if (SP_IS_GROUP(lpeitem)) {
356 GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem));356 std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem));
357 for ( GSList const *iter = item_list; iter; iter = iter->next ) {357 for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
358 SPObject *subitem = static_cast<SPObject *>(iter->data);358 SPObject *subitem = *iter;
359 if (SP_IS_LPE_ITEM(subitem)) {359 if (SP_IS_LPE_ITEM(subitem)) {
360 sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem));360 sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem));
361 }361 }
@@ -387,9 +387,9 @@
387 sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild()));387 sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild()));
388 }388 }
389 }389 }
390 GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem));390 std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem));
391 for ( GSList const *iter = item_list; iter; iter = iter->next ) {391 for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
392 SPObject *subitem = static_cast<SPObject *>(iter->data);392 SPObject *subitem = *iter;
393 if (SP_IS_LPE_ITEM(subitem)) {393 if (SP_IS_LPE_ITEM(subitem)) {
394 sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem));394 sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem));
395 }395 }
@@ -680,9 +680,9 @@
680 }680 }
681 }681 }
682 if(SP_IS_GROUP(item)){682 if(SP_IS_GROUP(item)){
683 GSList const *item_list = sp_item_group_item_list(SP_GROUP(item));683 std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item));
684 for ( GSList const *iter = item_list; iter; iter = iter->next ) {684 for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
685 SPObject *subitem = static_cast<SPObject *>(iter->data);685 SPObject *subitem = *iter;
686 apply_to_clippath(SP_ITEM(subitem));686 apply_to_clippath(SP_ITEM(subitem));
687 }687 }
688 }688 }
@@ -732,9 +732,9 @@
732 }732 }
733 }733 }
734 if(SP_IS_GROUP(item)){734 if(SP_IS_GROUP(item)){
735 GSList const *item_list = sp_item_group_item_list(SP_GROUP(item));735 std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item));
736 for ( GSList const *iter = item_list; iter; iter = iter->next ) {736 for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
737 SPObject *subitem = static_cast<SPObject *>(iter->data);737 SPObject *subitem = *iter;
738 apply_to_mask(SP_ITEM(subitem));738 apply_to_mask(SP_ITEM(subitem));
739 }739 }
740 }740 }
@@ -746,9 +746,9 @@
746 if (!SP_IS_GROUP(group)) {746 if (!SP_IS_GROUP(group)) {
747 return;747 return;
748 }748 }
749 GSList *item_list = sp_item_group_item_list(SP_GROUP(group));749 std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(group));
750 for ( GSList *iter = item_list; iter; iter = iter->next ) {750 for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
751 SPObject *subitem = static_cast<SPObject *>(iter->data);751 SPObject *subitem = *iter;
752 if (SP_IS_GROUP(subitem)) {752 if (SP_IS_GROUP(subitem)) {
753 apply_to_clip_or_mask_group(SP_ITEM(subitem), item);753 apply_to_clip_or_mask_group(SP_ITEM(subitem), item);
754 } else if (SP_IS_SHAPE(subitem)) {754 } else if (SP_IS_SHAPE(subitem)) {
755755
=== modified file 'src/sp-marker.cpp'
--- src/sp-marker.cpp 2015-02-25 00:22:08 +0000
+++ src/sp-marker.cpp 2015-04-29 21:03:59 +0000
@@ -419,7 +419,7 @@
419}419}
420420
421421
422const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move)422const gchar *generate_marker(std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move)
423{423{
424 Inkscape::XML::Document *xml_doc = document->getReprDoc();424 Inkscape::XML::Document *xml_doc = document->getReprDoc();
425 Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr();425 Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr();
@@ -442,8 +442,8 @@
442 const gchar *mark_id = repr->attribute("id");442 const gchar *mark_id = repr->attribute("id");
443 SPObject *mark_object = document->getObjectById(mark_id);443 SPObject *mark_object = document->getObjectById(mark_id);
444444
445 for (GSList *i = reprs; i != NULL; i = i->next) {445 for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){
446 Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data);446 Inkscape::XML::Node *node = *i;
447 SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node));447 SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node));
448448
449 Geom::Affine dup_transform;449 Geom::Affine dup_transform;
450450
=== modified file 'src/sp-marker.h'
--- src/sp-marker.h 2014-12-21 14:29:02 +0000
+++ src/sp-marker.h 2015-04-29 21:03:59 +0000
@@ -101,7 +101,7 @@
101 unsigned int key, unsigned int pos,101 unsigned int key, unsigned int pos,
102 Geom::Affine const &base, float linewidth);102 Geom::Affine const &base, float linewidth);
103void sp_marker_hide (SPMarker *marker, unsigned int key);103void sp_marker_hide (SPMarker *marker, unsigned int key);
104const char *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move);104const char *generate_marker (std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move);
105SPObject *sp_marker_fork_if_necessary(SPObject *marker);105SPObject *sp_marker_fork_if_necessary(SPObject *marker);
106106
107#endif107#endif
108108
=== modified file 'src/sp-object.cpp'
--- src/sp-object.cpp 2015-02-25 00:22:08 +0000
+++ src/sp-object.cpp 2015-04-29 21:03:59 +0000
@@ -380,14 +380,14 @@
380 sp_repr_css_change(this->getRepr(), css, attr);380 sp_repr_css_change(this->getRepr(), css, attr);
381}381}
382382
383GSList *SPObject::childList(bool add_ref, Action) {383std::vector<SPObject*> SPObject::childList(bool add_ref, Action) {
384 GSList *l = NULL;384 std::vector<SPObject*> l;
385 for ( SPObject *child = firstChild() ; child; child = child->getNext() ) {385 for ( SPObject *child = firstChild() ; child; child = child->getNext() ) {
386 if (add_ref) {386 if (add_ref) {
387 sp_object_ref (child);387 sp_object_ref (child);
388 }388 }
389389
390 l = g_slist_prepend (l, child);390 l.push_back(child);
391 }391 }
392 return l;392 return l;
393393
394394
=== modified file 'src/sp-object.h'
--- src/sp-object.h 2015-02-21 16:23:30 +0000
+++ src/sp-object.h 2015-04-29 21:03:59 +0000
@@ -52,6 +52,7 @@
52#include <sigc++/connection.h>52#include <sigc++/connection.h>
53#include <sigc++/functors/slot.h>53#include <sigc++/functors/slot.h>
54#include <sigc++/signal.h>54#include <sigc++/signal.h>
55#include <vector>
5556
56#include "version.h"57#include "version.h"
57#include "util/forward-pointer-iterator.h"58#include "util/forward-pointer-iterator.h"
@@ -328,10 +329,10 @@
328 enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };329 enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };
329330
330 /**331 /**
331 * Retrieves the children as a GSList object, optionally ref'ing the children332 * Retrieves the children as a std vector object, optionally ref'ing the children
332 * in the process, if add_ref is specified.333 * in the process, if add_ref is specified.
333 */334 */
334 GSList *childList(bool add_ref, Action action = ActionGeneral);335 std::vector<SPObject*> childList(bool add_ref, Action action = ActionGeneral);
335336
336 /**337 /**
337 * Append repr as child of this object.338 * Append repr as child of this object.
338339
=== modified file 'src/sp-pattern.cpp'
--- src/sp-pattern.cpp 2015-02-25 00:22:08 +0000
+++ src/sp-pattern.cpp 2015-04-29 21:03:59 +0000
@@ -398,7 +398,7 @@
398 g_free(c);398 g_free(c);
399}399}
400400
401const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move)401const gchar *pattern_tile(const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move)
402{402{
403 Inkscape::XML::Document *xml_doc = document->getReprDoc();403 Inkscape::XML::Document *xml_doc = document->getReprDoc();
404 Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr();404 Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr();
@@ -416,8 +416,8 @@
416 const gchar *pat_id = repr->attribute("id");416 const gchar *pat_id = repr->attribute("id");
417 SPObject *pat_object = document->getObjectById(pat_id);417 SPObject *pat_object = document->getObjectById(pat_id);
418418
419 for (GSList *i = reprs; i != NULL; i = i->next) {419 for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){
420 Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data);420 Inkscape::XML::Node *node = *i;
421 SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node));421 SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node));
422422
423 Geom::Affine dup_transform;423 Geom::Affine dup_transform;
424424
=== modified file 'src/sp-pattern.h'
--- src/sp-pattern.h 2014-10-08 02:22:03 +0000
+++ src/sp-pattern.h 2015-04-29 21:03:59 +0000
@@ -89,7 +89,7 @@
89SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property);89SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property);
90void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set);90void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set);
9191
92const char *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move);92const char *pattern_tile (const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move);
9393
94SPPattern *pattern_getroot (SPPattern *pat);94SPPattern *pattern_getroot (SPPattern *pat);
9595
9696
=== modified file 'src/sp-switch.cpp'
--- src/sp-switch.cpp 2015-02-25 00:22:08 +0000
+++ src/sp-switch.cpp 2015-04-29 21:03:59 +0000
@@ -41,21 +41,22 @@
41 return first;41 return first;
42}42}
4343
44GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) {44std::vector<SPObject*> SPSwitch::_childList(bool add_ref, SPObject::Action action) {
45 if ( action != SPObject::ActionGeneral ) {45 if ( action != SPObject::ActionGeneral ) {
46 return this->childList(add_ref, action);46 return this->childList(add_ref, action);
47 }47 }
4848
49 SPObject *child = _evaluateFirst();49 SPObject *child = _evaluateFirst();
50 std::vector<SPObject*> x;
50 if (NULL == child)51 if (NULL == child)
51 return NULL;52 return x;
5253
53 if (add_ref) {54 if (add_ref) {
54 //g_object_ref (G_OBJECT (child));55 //g_object_ref (G_OBJECT (child));
55 sp_object_ref(child);56 sp_object_ref(child);
56 }57 }
5758 x.push_back(child);
58 return g_slist_prepend (NULL, child);59 return x;
59}60}
6061
61const char *SPSwitch::displayName() const {62const char *SPSwitch::displayName() const {
@@ -95,10 +96,9 @@
9596
96 _releaseLastItem(_cached_item);97 _releaseLastItem(_cached_item);
9798
98 for ( GSList *l = _childList(false, SPObject::ActionShow);99 std::vector<SPObject*> item_list = _childList(false, SPObject::ActionShow);
99 NULL != l ; l = g_slist_remove (l, l->data))100 for ( std::vector<SPObject*>::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) {
100 {101 SPObject *o = *iter;
101 SPObject *o = SP_OBJECT (l->data);
102 if ( !SP_IS_ITEM (o) ) {102 if ( !SP_IS_ITEM (o) ) {
103 continue;103 continue;
104 }104 }
@@ -130,10 +130,10 @@
130void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) {130void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) {
131 SPObject *evaluated_child = this->_evaluateFirst();131 SPObject *evaluated_child = this->_evaluateFirst();
132132
133 GSList *l = this->_childList(false, SPObject::ActionShow);133 std::vector<SPObject*> l = this->_childList(false, SPObject::ActionShow);
134134
The diff has been truncated for viewing.