Code

Patch by Johan to fix 391368
authorscislac <scislac@users.sourceforge.net>
Wed, 7 Oct 2009 21:09:58 +0000 (21:09 +0000)
committerscislac <scislac@users.sourceforge.net>
Wed, 7 Oct 2009 21:09:58 +0000 (21:09 +0000)
src/sp-item-group.cpp
src/sp-path.cpp

index 9c19ce75a1a9839509f4ad38c9cea83f39eabda4..54f62e0936a0b8b22406e15e75777c49947dec49 100644 (file)
@@ -72,7 +72,7 @@ static void sp_group_hide (SPItem * item, unsigned int key);
 static void sp_group_snappoints (SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const *snapprefs);
 
 static void sp_group_update_patheffect(SPLPEItem *lpeitem, bool write);
-static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup);
+static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write);
 
 static SPLPEItemClass * parent_class;
 
@@ -856,30 +856,36 @@ sp_group_update_patheffect (SPLPEItem *lpeitem, bool write)
             }
         }
 
-        sp_group_perform_patheffect(SP_GROUP(lpeitem), SP_GROUP(lpeitem));
+        sp_group_perform_patheffect(SP_GROUP(lpeitem), SP_GROUP(lpeitem), write);
     }
 }
 
 static void
-sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup)
+sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
 {
     GSList const *item_list = sp_item_group_item_list(SP_GROUP(group));
     for ( GSList const *iter = item_list; iter; iter = iter->next ) {
         SPObject *subitem = static_cast<SPObject *>(iter->data);
         if (SP_IS_GROUP(subitem)) {
-            sp_group_perform_patheffect(SP_GROUP(subitem), topgroup);
+            sp_group_perform_patheffect(SP_GROUP(subitem), topgroup, write);
         } else if (SP_IS_SHAPE(subitem)) {
-            SPCurve * c = sp_shape_get_curve(SP_SHAPE(subitem));
+            SPCurve * c = NULL;
+            if (SP_IS_PATH(subitem)) {
+                c = sp_path_get_curve_for_edit(SP_PATH(subitem));
+            } else {
+                c = sp_shape_get_curve(SP_SHAPE(subitem));
+            }
             // only run LPEs when the shape has a curve defined
             if (c) {
                 sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
                 sp_shape_set_curve(SP_SHAPE(subitem), c, TRUE);
 
-                Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
-
-                gchar *str = sp_svg_write_path(c->get_pathvector());
-                repr->setAttribute("d", str);
-                g_free(str);
+                if (write) {
+                    Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
+                    gchar *str = sp_svg_write_path(c->get_pathvector());
+                    repr->setAttribute("d", str);
+                    g_free(str);
+                }
 
                 c->unref();
             }
index a2f0f3169203539a2e08cf16f2a1716389427e2c..a863c12b4bdead0fc064932d886e28ee4497c85d 100644 (file)
@@ -379,7 +379,7 @@ sp_path_set_transform(SPItem *item, Geom::Matrix const &xform)
 
     // Transform the original-d path if this is a valid LPE item, other else the (ordinary) path
     if (path->original_curve && SP_IS_LPE_ITEM(item) && 
-                                sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) {
+                                sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(item))) {
         path->original_curve->transform(xform);
     } else {
         shape->curve->transform(xform);
@@ -427,7 +427,7 @@ sp_path_update_patheffect(SPLPEItem *lpeitem, bool write)
             } else {
                 repr->setAttribute("d", NULL);
             }
-        } else {
+        } else if (!success) {
             // LPE was unsuccesfull. Read the old 'd'-attribute.
             if (gchar const * value = repr->attribute("d")) {
                 Geom::PathVector pv = sp_svg_read_pathv(value);
@@ -489,7 +489,7 @@ SPCurve*
 sp_path_get_curve_for_edit (SPPath *path)
 {
     if (path->original_curve && SP_IS_LPE_ITEM(path) && 
-                                sp_lpe_item_has_path_effect(SP_LPE_ITEM(path))) {
+                                sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path))) {
         return sp_path_get_original_curve(path);
     } else {
         return sp_shape_get_curve( (SPShape *) path );
@@ -504,7 +504,7 @@ const SPCurve*
 sp_path_get_curve_reference (SPPath *path)
 {
     if (path->original_curve && SP_IS_LPE_ITEM(path) && 
-                                sp_lpe_item_has_path_effect(SP_LPE_ITEM(path))) {
+                                sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path))) {
         return path->original_curve;
     } else {
         return path->curve;