diff options
author | Mark Hung <marklh9@gmail.com> | 2019-11-18 00:49:03 +0800 |
---|---|---|
committer | Mark Hung <marklh9@gmail.com> | 2019-11-30 15:00:09 +0100 |
commit | d86cfcaf709638d73fcb0de5067b902dab7a7f2f (patch) | |
tree | 9306bca1007d5888e76c608f2fd1103704761623 | |
parent | aeed331f7307612fbc4ebac4764cd39f6f2352e9 (diff) |
tdf#94947 Set preset-id for user defined motion paths.
User defined motion paths ( curve, polygon, freeform line )
did not have preset-id. Set the preset-id so that the
preset type will be highlighted in the custom animation
pane after editing.
"libo-motionpath-curve", "libo-motionpath-polygon",
and "libo-motionpath-freeform-line" are used for the three
user defined motion paths.
This patch is related to tdf#94947, though it doesn't
make the original document display correctly by guessing
the missing preset-id, but it prevent empty preset-id
to be generated when creating those three motion path
animation.
Change-Id: I50c0133bea32e022b07e5d8c0a024810844f124d
Reviewed-on: https://gerrit.libreoffice.org/83079
Tested-by: Jenkins
Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r-- | officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu | 15 | ||||
-rw-r--r-- | sd/inc/CustomAnimationEffect.hxx | 4 | ||||
-rw-r--r-- | sd/source/core/CustomAnimationEffect.cxx | 32 | ||||
-rw-r--r-- | sd/source/core/EffectMigration.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationPane.cxx | 11 | ||||
-rw-r--r-- | sd/source/ui/func/fuconbez.cxx | 17 |
6 files changed, 70 insertions, 11 deletions
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu index c635e0387517..1f385b61c540 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/Effects.xcu @@ -700,6 +700,21 @@ <value xml:lang="en-US">Whip</value> </prop> </node> + <node oor:name="libo-motionpath-curve" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Curve</value> + </prop> + </node> + <node oor:name="libo-motionpath-polygon" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Polygon</value> + </prop> + </node> + <node oor:name="libo-motionpath-freeform-line" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Freeform Line</value> + </prop> + </node> <node oor:name="ooo-motionpath-4-point-star" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">4 Point Star</value> diff --git a/sd/inc/CustomAnimationEffect.hxx b/sd/inc/CustomAnimationEffect.hxx index cf2cfe7cb7a4..962ce9b995d9 100644 --- a/sd/inc/CustomAnimationEffect.hxx +++ b/sd/inc/CustomAnimationEffect.hxx @@ -71,7 +71,7 @@ public: SAL_DLLPRIVATE const OUString& getProperty() const { return maProperty; } SAL_DLLPRIVATE sal_Int16 getPresetClass() const { return mnPresetClass; } - SAL_DLLPRIVATE void setPresetClass( sal_Int16 nPresetClass ); + SAL_DLLPRIVATE void setPresetClassAndId( sal_Int16 nPresetClass, const OUString& rPresetId ); SAL_DLLPRIVATE sal_Int16 getNodeType() const { return mnNodeType; } void setNodeType( sal_Int16 nNodeType ); @@ -271,7 +271,7 @@ public: SAL_DLLPRIVATE virtual css::uno::Reference< css::animations::XAnimationNode > getRootNode(); SAL_DLLPRIVATE CustomAnimationEffectPtr append( const CustomAnimationPresetPtr& pDescriptor, const css::uno::Any& rTarget, double fDuration ); - SAL_DLLPRIVATE CustomAnimationEffectPtr append( const SdrPathObj& rPathObj, const css::uno::Any& rTarget, double fDuration ); + SAL_DLLPRIVATE CustomAnimationEffectPtr append( const SdrPathObj& rPathObj, const css::uno::Any& rTarget, double fDuration, const OUString& rPresetId ); void append( const CustomAnimationEffectPtr& pEffect ); SAL_DLLPRIVATE void replace( const CustomAnimationEffectPtr& pEffect, const CustomAnimationPresetPtr& pDescriptor, double fDuration ); SAL_DLLPRIVATE void replace( const CustomAnimationEffectPtr& pEffect, const CustomAnimationPresetPtr& pDescriptor, const OUString& rPresetSubType, double fDuration ); diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx index f940e44645ae..a4b1d647f3dc 100644 --- a/sd/source/core/CustomAnimationEffect.cxx +++ b/sd/source/core/CustomAnimationEffect.cxx @@ -397,12 +397,13 @@ sal_Int32 CustomAnimationEffect::get_node_type( const Reference< XAnimationNode return nNodeType; } -void CustomAnimationEffect::setPresetClass( sal_Int16 nPresetClass ) +void CustomAnimationEffect::setPresetClassAndId( sal_Int16 nPresetClass, const OUString& rPresetId ) { - if( mnPresetClass == nPresetClass ) + if( mnPresetClass == nPresetClass && maPresetId == rPresetId ) return; mnPresetClass = nPresetClass; + maPresetId = rPresetId; if( !mxNode.is() ) return; @@ -410,7 +411,8 @@ void CustomAnimationEffect::setPresetClass( sal_Int16 nPresetClass ) // and change it Sequence< NamedValue > aUserData( mxNode->getUserData() ); sal_Int32 nLength = aUserData.getLength(); - bool bFound = false; + bool bFoundPresetClass = false; + bool bFoundPresetId = false; if( nLength ) { NamedValue* pProp = std::find_if(aUserData.begin(), aUserData.end(), @@ -418,16 +420,32 @@ void CustomAnimationEffect::setPresetClass( sal_Int16 nPresetClass ) if (pProp != aUserData.end()) { pProp->Value <<= mnPresetClass; - bFound = true; + bFoundPresetClass = true; + } + + pProp = std::find_if(aUserData.begin(), aUserData.end(), + [](const NamedValue& rProp) { return rProp.Name == "preset-id"; }); + if (pProp != aUserData.end()) + { + pProp->Value <<= mnPresetClass; + bFoundPresetId = true; } } // no "preset-class" entry inside user data, so add it - if( !bFound ) + if( !bFoundPresetClass ) { aUserData.realloc( nLength + 1); aUserData[nLength].Name = "preset-class"; aUserData[nLength].Value <<= mnPresetClass; + ++nLength; + } + + if( !bFoundPresetId && maPresetId.getLength() > 0 ) + { + aUserData.realloc( nLength + 1); + aUserData[nLength].Name = "preset-id"; + aUserData[nLength].Value <<= maPresetId; } mxNode->setUserData( aUserData ); @@ -1687,7 +1705,7 @@ CustomAnimationEffectPtr EffectSequenceHelper::append( const CustomAnimationPres return pEffect; } -CustomAnimationEffectPtr EffectSequenceHelper::append( const SdrPathObj& rPathObj, const Any& rTarget, double fDuration /* = -1.0 */ ) +CustomAnimationEffectPtr EffectSequenceHelper::append( const SdrPathObj& rPathObj, const Any& rTarget, double fDuration /* = -1.0 */, const OUString& rPresetId ) { CustomAnimationEffectPtr pEffect; @@ -1713,7 +1731,7 @@ CustomAnimationEffectPtr EffectSequenceHelper::append( const SdrPathObj& rPathOb pEffect->setTarget( rTarget ); pEffect->setTargetSubItem( nSubItem ); pEffect->setNodeType( css::presentation::EffectNodeType::ON_CLICK ); - pEffect->setPresetClass( css::presentation::EffectPresetClass::MOTIONPATH ); + pEffect->setPresetClassAndId( css::presentation::EffectPresetClass::MOTIONPATH, rPresetId ); pEffect->setAcceleration( 0.5 ); pEffect->setDecelerate( 0.5 ); pEffect->setFill( AnimationFill::HOLD ); diff --git a/sd/source/core/EffectMigration.cxx b/sd/source/core/EffectMigration.cxx index cac5a8896fd0..5bc0809fc6a6 100644 --- a/sd/source/core/EffectMigration.cxx +++ b/sd/source/core/EffectMigration.cxx @@ -1281,7 +1281,7 @@ void EffectMigration::SetAnimationPath( SvxShape* pShape, SdrPathObj const * pPa { std::shared_ptr< sd::MainSequence > pMainSequence( pPage->getMainSequence() ); if( pMainSequence.get() ) - CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, makeAny( xShape ), -1.0 ) ); + CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, makeAny( xShape ), -1.0, "" ) ); } } } diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index c63e4d0e8712..42b5055b0e5a 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -637,6 +637,17 @@ void CustomAnimationPane::updateControls() } } + // If preset id is missing and category is motion path. + if (nAnimationPos < 0 && nCategoryPos == 3) + { + if (rsPresetId == "libo-motionpath-curve") + mpLBAnimation->SelectEntryPos(mnCurvePathPos); + else if (rsPresetId == "libo-motionpath-polygon") + mpLBAnimation->SelectEntryPos(mnPolygonPathPos); + else if (rsPresetId == "libo-motionpath-freeform-line") + mpLBAnimation->SelectEntryPos(mnFreeformPathPos); + } + sal_uInt16 nPos = 0xffff; sal_Int16 nNodeType = pEffect->getNodeType(); diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx index 072d743fb843..7630ea02304e 100644 --- a/sd/source/ui/func/fuconbez.cxx +++ b/sd/source/ui/func/fuconbez.cxx @@ -242,9 +242,24 @@ bool FuConstructBezierPolygon::MouseButtonUp(const MouseEvent& rMEvt ) double fDuration = 0.0; *pTarget++ >>= fDuration; bool bFirst = true; + + OUString sPresetId; + switch(nSlotId) + { + case SID_DRAW_BEZIER_NOFILL: + sPresetId = "libo-motionpath-curve"; + break; + case SID_DRAW_POLYGON_NOFILL: + sPresetId = "libo-motionpath-polygon"; + break; + case SID_DRAW_FREELINE_NOFILL: + sPresetId = "libo-motionpath-freeform-line"; + break; + } + while( --nTCount ) { - CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, *pTarget++, fDuration ) ); + CustomAnimationEffectPtr pCreated( pMainSequence->append( *pPathObj, *pTarget++, fDuration, sPresetId) ); if( bFirst ) bFirst = false; else |