From ce67a5f751e7dae96f135e9003a77665ef0f5e61 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Thu, 16 May 2019 11:18:40 +0200 Subject: Fork LPE if necesary also in LPEItem childs --- clang_format_diff | 40 ++++++++++++++++++++++++++++++++++++++++ src/object/sp-lpe-item.cpp | 12 +++++++++++- src/object/sp-lpe-item.h | 2 +- 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 clang_format_diff diff --git a/clang_format_diff b/clang_format_diff new file mode 100644 index 000000000..fa4e0bee3 --- /dev/null +++ b/clang_format_diff @@ -0,0 +1,40 @@ +--- src/live_effects/lpe-clone-original.cpp (before formatting) ++++ src/live_effects/lpe-clone-original.cpp (after formatting) +@@ -36,13 +36,16 @@ + }; + static const Util::EnumDataConverter CLMConverter(ClonelpemethodData, CLM_END); + +-LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) : +- Effect(lpeobject), +- linkeditem(_("Linked Item:"), _("Item from which to take the original data"), "linkeditem", &wr, this), +- method(_("Shape linked"), _("Shape linked"), "method", CLMConverter, &wr, this, CLM_D), +- attributes("Attributes linked", "Attributes linked, comma separated attributes like trasform, X, Y...", "attributes", &wr, this,""), +- style_attributes("Style attributes linked", "Style attributes linked, comma separated attributes like fill, filter, opacity...", "style_attributes", &wr, this,""), +- allow_transforms(_("Allow transforms"), _("Allow transforms"), "allow_transforms", &wr, this, true) ++LPECloneOriginal::LPECloneOriginal(LivePathEffectObject *lpeobject) ++ : Effect(lpeobject) ++ , linkeditem(_("Linked Item:"), _("Item from which to take the original data"), "linkeditem", &wr, this) ++ , method(_("Shape linked"), _("Shape linked"), "method", CLMConverter, &wr, this, CLM_D) ++ , attributes("Attributes linked", "Attributes linked, comma separated attributes like trasform, X, Y...", ++ "attributes", &wr, this, "") ++ , style_attributes("Style attributes linked", ++ "Style attributes linked, comma separated attributes like fill, filter, opacity...", ++ "style_attributes", &wr, this, "") ++ , allow_transforms(_("Allow transforms"), _("Allow transforms"), "allow_transforms", &wr, this, true) + { + //0.92 compatibility + const gchar * linkedpath = this->getRepr()->attribute("linkedpath"); +@@ -175,11 +178,8 @@ + dest->getRepr()->setAttribute(attribute, nullptr); + } + } else { +- if (!(SP_IS_GROUP(dest) && +- dest->getId() == sp_lpe_item->getId() && +- !strcmp(attribute, "transform") && +- allow_transforms)) +- { ++ if (!(SP_IS_GROUP(dest) && dest->getId() == sp_lpe_item->getId() && !strcmp(attribute, "transform") && ++ allow_transforms)) { + dest->getRepr()->setAttribute(attribute, origin->getRepr()->attribute(attribute)); + } + } diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp index f3dd5f05b..b43a0b926 100755 --- a/src/object/sp-lpe-item.cpp +++ b/src/object/sp-lpe-item.cpp @@ -1152,9 +1152,19 @@ void SPLPEItem::replacePathEffects( std::vector co * use this method instead. * Returns true if one or more effects were forked; returns false if nothing was done. */ -bool SPLPEItem::forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users) +bool SPLPEItem::forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users, bool recursive) { bool forked = false; + SPGroup * group = dynamic_cast(this); + if (group && recursive) { + std::vector item_list = sp_item_group_item_list(group); + for (auto child:item_list) { + SPLPEItem *lpeitem = dynamic_cast(child); + if (lpeitem && lpeitem->forkPathEffectsIfNecessary(nr_of_allowed_users, recursive)) { + forked = true; + } + } + } if ( this->hasPathEffect() ) { // If one of the path effects is used by 2 or more items, fork it diff --git a/src/object/sp-lpe-item.h b/src/object/sp-lpe-item.h index 55e32dad6..6ebd01fe3 100644 --- a/src/object/sp-lpe-item.h +++ b/src/object/sp-lpe-item.h @@ -99,7 +99,7 @@ public: void applyToMask(SPItem* to, Inkscape::LivePathEffect::Effect *lpe = nullptr); void applyToClipPath(SPItem* to, Inkscape::LivePathEffect::Effect *lpe = nullptr); void applyToClipPathOrMask(SPItem * clip_mask, SPItem* to, Inkscape::LivePathEffect::Effect *lpe = nullptr); - bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1); + bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1, bool recursive = true); void editNextParamOncanvas(SPDesktop *dt); }; -- cgit v1.2.3