Code

fix 1520018: sync up the embed/not embed transform logic when ungrouping with that...
authorbuliabyak <buliabyak@users.sourceforge.net>
Tue, 24 Oct 2006 05:13:40 +0000 (05:13 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Tue, 24 Oct 2006 05:13:40 +0000 (05:13 +0000)
src/sp-item-group.cpp

index 422d033ca3fb117839435fc2f093b4a5032d329c..d9f0e6f3ded9230e04bb95c054e18addef9d4c51 100644 (file)
 #include "style.h"
 #include "attributes.h"
 #include "sp-item-transform.h"
-
 #include "sp-root.h"
 #include "sp-use.h"
 #include "prefs-utils.h"
+#include "sp-clippath.h"
+#include "sp-mask.h"
 
 static void sp_group_class_init (SPGroupClass *klass);
 static void sp_group_init (SPGroup *group);
@@ -425,21 +426,27 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
                repr->setPosition(pos > 0 ? pos : 0);
 
                // fill in the children list if non-null
-               SPItem *nitem = (SPItem *) doc->getObjectByRepr(repr);
-
-               /* Optimize the transform matrix if requested. */
-               // No compensations are required because this is supposed to be a non-transformation visually.
-               if (!preserve) {
-                       NR::Matrix (*set_transform)(SPItem *, NR::Matrix const &) = ((SPItemClass *) G_OBJECT_GET_CLASS(nitem))->set_transform;
-                       if (set_transform) {
-                               sp_item_set_item_transform(nitem, set_transform(nitem, nitem->transform));
-                               nitem->updateRepr();
-                       }
-               }
+               SPItem *item = (SPItem *) doc->getObjectByRepr(repr);
+
+      /* Optimize the transform matrix if requested. */
+      // No compensations are required because this is supposed to be a non-transformation visually.
+      // FIXME: this if is wholly lifted from sp_item_write_transform and should stay in sync
+      NR::Matrix transform_attr (item->transform);
+      if ( // run the object's set_transform (i.e. embed transform) only if:
+          ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform && // it does have a set_transform method
+          !preserve && // user did not chose to preserve all transforms
+          !item->clip_ref->getObject() && // the object does not have a clippath
+          !item->mask_ref->getObject() && // the object does not have a mask
+          !(!transform_attr.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.filter) 
+          // the object does not have a filter, or the transform is translation (which is supposed to not affect filters)
+          ) {
+          transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, item->transform);
+      }
+      sp_item_set_item_transform(item, transform_attr);
 
                Inkscape::GC::release(repr);
-               if (children && SP_IS_ITEM (nitem))
-                       *children = g_slist_prepend (*children, nitem);
+               if (children && SP_IS_ITEM (item))
+                       *children = g_slist_prepend (*children, item);
 
                items = g_slist_remove (items, items->data);
        }
@@ -761,3 +768,14 @@ void CGroup::onOrderChanged (Inkscape::XML::Node *child, Inkscape::XML::Node *,
 
     _group->requestModified(SP_OBJECT_MODIFIED_FLAG);
 }
+
+/*
+  Local Variables:
+  mode:c++
+  c-file-style:"stroustrup"
+  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+  indent-tabs-mode:nil
+  fill-column:99
+  End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :