summaryrefslogtreecommitdiffstats
path: root/src/sp-item-group.cpp
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2016-08-12 04:11:03 +0000
committerTed Gould <ted@gould.cx>2016-08-12 04:11:03 +0000
commitff848ebc9919d158c3ec3d7420e72b6aca99a3ea (patch)
tree030ab171865d0ed7f6bae3ef68315639cdb2622b /src/sp-item-group.cpp
parentMerging 0.92.x branch (diff)
parentCloneTiler: Further C++ification (diff)
downloadinkscape-ff848ebc9919d158c3ec3d7420e72b6aca99a3ea.tar.gz
inkscape-ff848ebc9919d158c3ec3d7420e72b6aca99a3ea.zip
Merge trunk
(bzr r14950.1.20)
Diffstat (limited to 'src/sp-item-group.cpp')
-rw-r--r--src/sp-item-group.cpp75
1 files changed, 35 insertions, 40 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 70d2bc732..097026057 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -15,7 +15,7 @@
*/
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include <config.h>
#endif
#include <glibmm/i18n.h>
@@ -32,16 +32,13 @@
#include "attributes.h"
#include "sp-item-transform.h"
#include "sp-root.h"
-#include "sp-use.h"
#include "sp-offset.h"
#include "sp-clippath.h"
#include "sp-mask.h"
#include "sp-path.h"
#include "box3d.h"
#include "persp3d.h"
-#include "inkscape.h"
-#include "selection.h"
#include "live_effects/effect.h"
#include "live_effects/lpeobject.h"
#include "live_effects/lpeobject-reference.h"
@@ -50,10 +47,8 @@
#include "sp-switch.h"
#include "sp-defs.h"
#include "verbs.h"
-#include "layer-model.h"
#include "sp-textpath.h"
#include "sp-flowtext.h"
-#include "sp-tspan.h"
#include "selection-chemistry.h"
#include "xml/sp-css-attr.h"
#include "svg/css-ostringstream.h"
@@ -235,9 +230,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape::
l = NULL;
- for (SPObject *child = firstChild(); child; child = child->getNext() ) {
- if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) {
- Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags);
+ for (auto& child: children) {
+ if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) {
+ Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags);
if (crepr) {
l = g_slist_prepend (l, crepr);
@@ -251,9 +246,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape::
l = g_slist_remove (l, l->data);
}
} else {
- for (SPObject *child = firstChild() ; child ; child = child->getNext() ) {
- if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) {
- child->updateRepr(flags);
+ for (auto& child: children) {
+ if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) {
+ child.updateRepr(flags);
}
}
}
@@ -297,9 +292,8 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
}
void SPGroup::print(SPPrintContext *ctx) {
- std::vector<SPObject*> l=this->childList(false);
- for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();++i){
- SPObject *o = *i;
+ for(auto& child: children){
+ SPObject *o = &child;
SPItem *item = dynamic_cast<SPItem *>(o);
if (item) {
item->invoke_print(ctx);
@@ -366,9 +360,9 @@ void SPGroup::hide (unsigned int key) {
void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const {
- for ( SPObject const *o = this->firstChild(); o; o = o->getNext() )
+ for (auto& o: children)
{
- SPItem const *item = dynamic_cast<SPItem const *>(o);
+ SPItem const *item = dynamic_cast<SPItem const *>(&o);
if (item) {
item->getSnappoints(p, snapprefs);
}
@@ -512,20 +506,21 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d
GSList *objects = NULL;
Geom::Affine const g(group->transform);
- for (SPObject *child = group->firstChild() ; child; child = child->getNext() )
- if (SPItem *citem = dynamic_cast<SPItem *>(child))
- sp_item_group_ungroup_handle_clones(citem,g);
-
+ for (auto& child: group->children) {
+ if (SPItem *citem = dynamic_cast<SPItem *>(&child)) {
+ sp_item_group_ungroup_handle_clones(citem, g);
+ }
+ }
- for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) {
- SPItem *citem = dynamic_cast<SPItem *>(child);
+ for (auto& child: group->children) {
+ SPItem *citem = dynamic_cast<SPItem *>(&child);
if (citem) {
/* Merging of style */
// this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
// it here _before_ the new transform is set, so as to use the pre-transform bbox
citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false);
- child->style->merge( group->style );
+ child.style->merge( group->style );
/*
* fixme: We currently make no allowance for the case where child is cloned
* and the group has any style settings.
@@ -547,9 +542,9 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d
* extra complication & maintenance burden and this case is rare.
*/
- child->updateRepr();
+ child.updateRepr();
- Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document());
+ Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document());
// Merging transform
Geom::Affine ctrans = citem->transform * g;
@@ -583,7 +578,7 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d
if (text) {
//this causes a change in text-on-path appearance when there is a non-conformal transform, see bug #1594565
double scale = (ctrans.expansionX() + ctrans.expansionY()) / 2.0;
- SPTextPath * text_path = dynamic_cast<SPTextPath *>(text->children);
+ SPTextPath * text_path = dynamic_cast<SPTextPath *>(text->firstChild());
if (!text_path) {
nrepr->setAttribute("transform", affinestr);
} else {
@@ -600,7 +595,7 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d
items = g_slist_prepend (items, nrepr);
} else {
- Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document());
+ Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document());
objects = g_slist_prepend (objects, nrepr);
}
}
@@ -662,9 +657,9 @@ std::vector<SPItem*> sp_item_group_item_list(SPGroup * group)
std::vector<SPItem*> s;
g_return_val_if_fail(group != NULL, s);
- for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
- if ( dynamic_cast<SPItem *>(o) ) {
- s.push_back((SPItem*)o);
+ for (auto& o: group->children) {
+ if ( dynamic_cast<SPItem *>(&o) ) {
+ s.push_back((SPItem*)&o);
}
}
return s;
@@ -735,8 +730,8 @@ void SPGroup::_updateLayerMode(unsigned int display_key) {
void SPGroup::translateChildItems(Geom::Translate const &tr)
{
if ( hasChildren() ) {
- for (SPObject *o = firstChild() ; o ; o = o->getNext() ) {
- SPItem *item = dynamic_cast<SPItem *>(o);
+ for (auto& o: children) {
+ SPItem *item = dynamic_cast<SPItem *>(&o);
if ( item ) {
sp_item_move_rel(item, tr);
}
@@ -748,14 +743,14 @@ void SPGroup::translateChildItems(Geom::Translate const &tr)
void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse)
{
if ( hasChildren() ) {
- for (SPObject *o = firstChild() ; o ; o = o->getNext() ) {
- if ( SPDefs *defs = dynamic_cast<SPDefs *>(o) ) { // select symbols from defs, ignore clips, masks, patterns
- for (SPObject *defschild = defs->firstChild() ; defschild ; defschild = defschild->getNext() ) {
- SPGroup *defsgroup = dynamic_cast<SPGroup *>(defschild);
+ for (auto& o: children) {
+ if ( SPDefs *defs = dynamic_cast<SPDefs *>(&o) ) { // select symbols from defs, ignore clips, masks, patterns
+ for (auto& defschild: defs->children) {
+ SPGroup *defsgroup = dynamic_cast<SPGroup *>(&defschild);
if (defsgroup)
defsgroup->scaleChildItemsRec(sc, p, false);
}
- } else if ( SPItem *item = dynamic_cast<SPItem *>(o) ) {
+ } else if ( SPItem *item = dynamic_cast<SPItem *>(&o) ) {
SPGroup *group = dynamic_cast<SPGroup *>(item);
if (group && !dynamic_cast<SPBox3D *>(item)) {
/* Using recursion breaks clipping because transforms are applied
@@ -871,8 +866,8 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo
gint SPGroup::getItemCount() const {
gint len = 0;
- for (SPObject const *o = this->firstChild() ; o ; o = o->getNext() ) {
- if (dynamic_cast<SPItem const *>(o)) {
+ for (auto& child: children) {
+ if (dynamic_cast<SPItem const *>(&child)) {
len++;
}
}