diff options
author | Katarina Behrens <Katarina.Behrens@cib.de> | 2017-05-01 16:43:46 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-05-03 15:54:11 +0200 |
commit | fd2fe3b370abb38200da04602a28d9696ad12e12 (patch) | |
tree | 19bd05ea5027ff702d00a5f8af20811adcad0bd2 | |
parent | bb6d2d3476b0acfd92dc75ed26836ab2ff817378 (diff) |
tdf#105703: Restore user-defined motion paths for animations
Yet another fallback from Google Summer of Regressions.
The rest of the functionality has been removed by loplugin and
other hyperactive code cleaners, so I've restored it, mostly
unmodified.
Change-Id: If0576abe9ce86c6f939d54bcf8f872dfce131e68
Reviewed-on: https://gerrit.libreoffice.org/37138
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Katarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit 17495047e53885a224c2180c10ec7ecece35135d)
Reviewed-on: https://gerrit.libreoffice.org/37170
Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | sd/inc/app.hrc | 1 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationPane.cxx | 105 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationPane.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/fuconbez.cxx | 13 | ||||
-rw-r--r-- | sd/source/ui/inc/fuconbez.hxx | 1 |
5 files changed, 113 insertions, 9 deletions
diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc index 2bf78397a1b3..903028102940 100644 --- a/sd/inc/app.hrc +++ b/sd/inc/app.hrc @@ -449,6 +449,7 @@ // Add companion for the SID_HIDE_SLIDE (that is defined in svx) #define SID_SHOW_SLIDE (SID_SD_START+441) +#define SID_ADD_MOTION_PATH (SID_SD_START+442) #define SID_TABLE_TOOLBOX (SID_SD_START+443) // FREE diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index 319d9b45e6d2..26bd04829f50 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -1976,6 +1976,63 @@ double CustomAnimationPane::getDuration() return fDuration; } +PathKind CustomAnimationPane::getCreatePathKind() const +{ + PathKind eKind = PathKind::NONE; + + if( mpLBAnimation->GetSelectEntryCount() == 1 ) + { + const sal_Int32 nPos = mpLBAnimation->GetSelectEntryPos(); + if( nPos == mnCurvePathPos ) + { + eKind = PathKind::CURVE; + } + else if( nPos == mnPolygonPathPos ) + { + eKind = PathKind::POLYGON; + } + else if( nPos == mnFreeformPathPos ) + { + eKind = PathKind::FREEFORM; + } + } + + return eKind; +} + +void CustomAnimationPane::createPath( PathKind eKind, std::vector< Any >& rTargets, double fDuration) +{ + sal_uInt16 nSID = 0; + + switch( eKind ) + { + case PathKind::CURVE: nSID = SID_DRAW_BEZIER_NOFILL; break; + case PathKind::POLYGON: nSID = SID_DRAW_POLYGON_NOFILL; break; + case PathKind::FREEFORM: nSID = SID_DRAW_FREELINE_NOFILL; break; + default: break; + } + + if( nSID ) + { + DrawViewShell* pViewShell = dynamic_cast< DrawViewShell* >( + FrameworkHelper::Instance(mrBase)->GetViewShell(FrameworkHelper::msCenterPaneURL).get()); + + if( pViewShell ) + { + DrawView* pView = pViewShell->GetDrawView(); + if( pView ) + pView->UnmarkAllObj(); + + std::vector< Any > aTargets( 1, Any( fDuration ) ); + aTargets.insert( aTargets.end(), rTargets.begin(), rTargets.end() ); + Sequence< Any > aTargetSequence( comphelper::containerToSequence( aTargets ) ); + const SfxUnoAnyItem aItem( SID_ADD_MOTION_PATH, Any( aTargetSequence ) ); + pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList( nSID, SfxCallMode::ASYNCHRON, {&aItem} ); + } + } +} + + /// this link is called when the property box is modified by the user IMPL_LINK_NOARG(CustomAnimationPane, implPropertyHdl, LinkParamNone*, void) { @@ -2016,17 +2073,45 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void) if( maListSelection.size() == 1 ) { CustomAnimationPresetPtr* pPreset = static_cast< CustomAnimationPresetPtr* >(mpLBAnimation->GetSelectEntryData()); + PathKind ePathKind = getCreatePathKind(); + // tdf#99137, the selected entry may also be a subcategory title, so not an effect // just leave in this case - if (!pPreset) + if ( !pPreset && ( ePathKind == PathKind::NONE ) ) return; - const double fDuration = (*pPreset)->getDuration(); + + EffectSequence::iterator aIter( maListSelection.begin() ); + const EffectSequence::iterator aEnd( maListSelection.end() ); + + if ( ePathKind != PathKind::NONE ) + { + std::vector< Any > aTargets; + MainSequenceRebuildGuard aGuard( mpMainSequence ); + + while( aIter != aEnd ) + { + aTargets.push_back( (*aIter)->getTarget() ); + CustomAnimationEffectPtr pEffect = (*aIter++); + + EffectSequenceHelper* pEffectSequence = pEffect->getEffectSequence(); + if( !pEffectSequence ) + pEffectSequence = mpMainSequence.get(); + + // delete the old animation, new one will be appended + // by createPath and SID_ADD_MOTION_PATH therein + pEffectSequence->remove( pEffect ); + } + + createPath( ePathKind, aTargets, 0.0 ); + updateMotionPathTags(); + return; + } + CustomAnimationPresetPtr pDescriptor(*pPreset); + const double fDuration = (*pPreset)->getDuration(); MainSequenceRebuildGuard aGuard( mpMainSequence ); // get selected effect - EffectSequence::iterator aIter( maListSelection.begin() ); - const EffectSequence::iterator aEnd( maListSelection.end() ); while( aIter != aEnd ) { CustomAnimationEffectPtr pEffect = (*aIter++); @@ -2037,6 +2122,7 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void) pEffectSequence->replace( pEffect, pDescriptor, fDuration ); } + onPreview(false); } } @@ -2077,18 +2163,19 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText ) sal_uInt32 nFirstEffect = LISTBOX_ENTRY_NOTFOUND; - if(nPosition == 0) + PresetCategoryList::const_iterator aCategoryIter( rCategoryList.begin() ); + const PresetCategoryList::const_iterator aCategoryEnd( rCategoryList.end() ); + mpLBAnimation->Clear(); + + if(nPosition == 3) { OUString sMotionPathLabel( SD_RESSTR( STR_CUSTOMANIMATION_USERPATH ) ); mpLBAnimation->InsertCategory( sMotionPathLabel ); mnCurvePathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulCOMBLINE) ); mnPolygonPathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulPOLY) ); mnFreeformPathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulFREELINE) ); - } - PresetCategoryList::const_iterator aCategoryIter( rCategoryList.begin() ); - const PresetCategoryList::const_iterator aCategoryEnd( rCategoryList.end() ); - mpLBAnimation->Clear(); + while(aCategoryIter != aCategoryEnd) { PresetCategoryPtr pCategory( *aCategoryIter++ ); diff --git a/sd/source/ui/animations/CustomAnimationPane.hxx b/sd/source/ui/animations/CustomAnimationPane.hxx index 636fff1edcb0..e849d70876dd 100644 --- a/sd/source/ui/animations/CustomAnimationPane.hxx +++ b/sd/source/ui/animations/CustomAnimationPane.hxx @@ -118,6 +118,8 @@ private: bool setProperty1Value( sal_Int32 nType, const CustomAnimationEffectPtr& pEffect, const css::uno::Any& rValue ); void UpdateLook(); sal_uInt32 fillAnimationLB( bool bHasText ); + PathKind getCreatePathKind() const; + void createPath( PathKind eKind, std::vector< ::com::sun::star::uno::Any >& rTargets, double fDuration ); DECL_LINK( implControlListBoxHdl, ListBox&, void ); DECL_LINK( implClickHdl, Button*, void ); diff --git a/sd/source/ui/func/fuconbez.cxx b/sd/source/ui/func/fuconbez.cxx index a3e09bd49036..6212dc62af3f 100644 --- a/sd/source/ui/func/fuconbez.cxx +++ b/sd/source/ui/func/fuconbez.cxx @@ -70,6 +70,19 @@ rtl::Reference<FuPoor> FuConstructBezierPolygon::Create( ViewShell* pViewSh, ::s return xFunc; } +void FuConstructBezierPolygon::DoExecute( SfxRequest& rReq ) +{ + FuConstruct::DoExecute( rReq ); + + const SfxItemSet* pArgs = rReq.GetArgs(); + if( pArgs ) + { + const SfxPoolItem* pPoolItem = nullptr; + if( SfxItemState::SET == pArgs->GetItemState( SID_ADD_MOTION_PATH, true, &pPoolItem ) ) + maTargets = static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue(); + } +} + bool FuConstructBezierPolygon::MouseButtonDown(const MouseEvent& rMEvt) { bool bReturn = FuConstruct::MouseButtonDown(rMEvt); diff --git a/sd/source/ui/inc/fuconbez.hxx b/sd/source/ui/inc/fuconbez.hxx index f43069632ae0..68a922dd3a51 100644 --- a/sd/source/ui/inc/fuconbez.hxx +++ b/sd/source/ui/inc/fuconbez.hxx @@ -33,6 +33,7 @@ class FuConstructBezierPolygon public: static rtl::Reference<FuPoor> Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent ); + void DoExecute( SfxRequest& rReq ) override; // Mouse- & Key-Events virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; |