summaryrefslogtreecommitdiffstats
path: root/src/sp-item-group.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-18 18:17:44 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-18 18:17:44 +0000
commit71508f76c3ddc33c41664599f9c10bf84d994d62 (patch)
tree68f69fd8c5b36c4f5a288bb8b2521405724cf9ce /src/sp-item-group.cpp
parentupdate to trunk (diff)
parentLatvian translation update (diff)
downloadinkscape-71508f76c3ddc33c41664599f9c10bf84d994d62.tar.gz
inkscape-71508f76c3ddc33c41664599f9c10bf84d994d62.zip
update to trunk
(bzr r13879.1.11)
Diffstat (limited to 'src/sp-item-group.cpp')
-rw-r--r--src/sp-item-group.cpp58
1 files changed, 28 insertions, 30 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index b1ba37de2..55857dacf 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -58,16 +58,6 @@ using Inkscape::DocumentUndo;
static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write);
-#include "sp-factory.h"
-
-namespace {
- SPObject* createGroup() {
- return new SPGroup();
- }
-
- bool groupRegistered = SPFactory::instance().registerObject("svg:g", createGroup);
-}
-
SPGroup::SPGroup() : SPLPEItem() {
this->_layer_mode = SPGroup::GROUP;
}
@@ -399,6 +389,22 @@ void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape:
}
}
+void sp_item_group_ungroup_handle_clones(SPItem *parent, Geom::Affine const g)
+{
+ for(std::list<SPObject*>::const_iterator refd=parent->hrefList.begin();refd!=parent->hrefList.end();refd++){
+ SPItem *citem = dynamic_cast<SPItem *>(*refd);
+ if (citem) {
+ SPUse *useitem = dynamic_cast<SPUse *>(citem);
+ if (useitem && useitem->get_original() == parent) {
+ Geom::Affine ctrans;
+ ctrans = g.inverse() * citem->transform;
+ gchar *affinestr = sp_svg_transform_write(ctrans);
+ citem->setAttribute("transform", affinestr);
+ g_free(affinestr);
+ }
+ }
+ }
+}
void
sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
@@ -435,8 +441,14 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
/* Step 1 - generate lists of children objects */
GSList *items = NULL;
GSList *objects = NULL;
- for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) {
+ 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 (SPObject *child = group->firstChild() ; child; child = child->getNext() ) {
SPItem *citem = dynamic_cast<SPItem *>(child);
if (citem) {
/* Merging of style */
@@ -472,13 +484,6 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
// Merging transform
Geom::Affine ctrans;
- Geom::Affine const g(group->transform);
- SPUse *useitem = dynamic_cast<SPUse *>(citem);
- if (useitem && useitem->get_original() &&
- useitem->get_original()->parent == dynamic_cast<SPObject *>(group)) {
- // make sure a clone's effective transform is the same as was under group
- ctrans = g.inverse() * citem->transform * g;
- } else {
// We should not apply the group's transformation to both a linked offset AND to its source
if (dynamic_cast<SPOffset *>(citem)) { // Do we have an offset at hand (whether it's dynamic or linked)?
SPItem *source = sp_offset_get_source(dynamic_cast<SPOffset *>(citem));
@@ -497,7 +502,6 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
} else {
ctrans = citem->transform * g;
}
- }
// FIXME: constructing a transform that would fully preserve the appearance of a
// textpath if it is ungrouped with its path seems to be impossible in general
@@ -709,21 +713,16 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo
subItem = dynamic_cast<SPItem *>(item->clip_ref->getObject()->firstChild());
}
if (subItem != NULL) {
- Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt()
- Geom::Affine ti2doc = item->i2doc_affine();
- subItem->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt);
- subItem->doWriteTransform(subItem->getRepr(), subItem->transform, NULL, true);
+ subItem->doWriteTransform(subItem->getRepr(), subItem->transform*sc, NULL, true);
}
subItem = NULL;
if (item->mask_ref->getObject()) {
subItem = dynamic_cast<SPItem *>(item->mask_ref->getObject()->firstChild());
}
if (subItem != NULL) {
- Geom::Affine tdoc2dt = Geom::Scale(1, -1) * Geom::Translate(p); // re-create doc2dt()
- Geom::Affine ti2doc = item->i2doc_affine();
- subItem->set_i2d_affine(ti2doc * sc * ti2doc.inverse() * tdoc2dt);
- subItem->doWriteTransform(item->getRepr(), item->transform, NULL, true);
+ subItem->doWriteTransform(subItem->getRepr(), subItem->transform*sc, NULL, true);
}
+ item->doWriteTransform(item->getRepr(), sc.inverse()*item->transform*sc, NULL, true);
group->scaleChildItemsRec(sc, p, false);
}
} else {
@@ -777,8 +776,7 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo
Geom::Affine move = final.inverse() * item->transform * final;
item->doWriteTransform(item->getRepr(), move, &move, true);
} else {
- item->set_i2d_affine(item->i2dt_affine() * final);
- item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
+ item->doWriteTransform(item->getRepr(), item->transform*sc, NULL, true);
}
if (conn_type != NULL) {
@@ -845,7 +843,7 @@ void SPGroup::update_patheffect(bool write) {
LivePathEffectObject *lpeobj = (*it)->lpeobject;
if (lpeobj && lpeobj->get_lpe()) {
- lpeobj->get_lpe()->doBeforeEffect(this);
+ lpeobj->get_lpe()->doBeforeEffect_impl(this);
}
}