Kaydet (Commit) 17495047 authored tarafından Katarina Behrens's avatar Katarina Behrens

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/37138Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
üst 34f7e618
...@@ -445,6 +445,7 @@ ...@@ -445,6 +445,7 @@
// Add companion for the SID_HIDE_SLIDE (that is defined in svx) // Add companion for the SID_HIDE_SLIDE (that is defined in svx)
#define SID_SHOW_SLIDE (SID_SD_START+441) #define SID_SHOW_SLIDE (SID_SD_START+441)
#define SID_ADD_MOTION_PATH (SID_SD_START+442)
// FREE // FREE
#define SID_ZOOM_MODE (SID_SD_START+447) #define SID_ZOOM_MODE (SID_SD_START+447)
......
...@@ -1988,6 +1988,63 @@ double CustomAnimationPane::getDuration() ...@@ -1988,6 +1988,63 @@ double CustomAnimationPane::getDuration()
return fDuration; 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 /// this link is called when the property box is modified by the user
IMPL_LINK_NOARG(CustomAnimationPane, implPropertyHdl, LinkParamNone*, void) IMPL_LINK_NOARG(CustomAnimationPane, implPropertyHdl, LinkParamNone*, void)
{ {
...@@ -2054,17 +2111,45 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void) ...@@ -2054,17 +2111,45 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void)
if( maListSelection.size() == 1 ) if( maListSelection.size() == 1 )
{ {
CustomAnimationPresetPtr* pPreset = static_cast< CustomAnimationPresetPtr* >(mpLBAnimation->GetSelectEntryData()); 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 // tdf#99137, the selected entry may also be a subcategory title, so not an effect
// just leave in this case // just leave in this case
if (!pPreset) if ( !pPreset && ( ePathKind == PathKind::NONE ) )
return; 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); CustomAnimationPresetPtr pDescriptor(*pPreset);
const double fDuration = (*pPreset)->getDuration();
MainSequenceRebuildGuard aGuard( mpMainSequence ); MainSequenceRebuildGuard aGuard( mpMainSequence );
// get selected effect // get selected effect
EffectSequence::iterator aIter( maListSelection.begin() );
const EffectSequence::iterator aEnd( maListSelection.end() );
while( aIter != aEnd ) while( aIter != aEnd )
{ {
CustomAnimationEffectPtr pEffect = (*aIter++); CustomAnimationEffectPtr pEffect = (*aIter++);
...@@ -2075,6 +2160,7 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void) ...@@ -2075,6 +2160,7 @@ IMPL_LINK_NOARG(CustomAnimationPane, AnimationSelectHdl, ListBox&, void)
pEffectSequence->replace( pEffect, pDescriptor, fDuration ); pEffectSequence->replace( pEffect, pDescriptor, fDuration );
} }
onPreview(false); onPreview(false);
} }
} }
...@@ -2115,18 +2201,19 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText ) ...@@ -2115,18 +2201,19 @@ sal_uInt32 CustomAnimationPane::fillAnimationLB( bool bHasText )
sal_uInt32 nFirstEffect = LISTBOX_ENTRY_NOTFOUND; 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 ) ); OUString sMotionPathLabel( SD_RESSTR( STR_CUSTOMANIMATION_USERPATH ) );
mpLBAnimation->InsertCategory( sMotionPathLabel ); mpLBAnimation->InsertCategory( sMotionPathLabel );
mnCurvePathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulCOMBLINE) ); mnCurvePathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulCOMBLINE) );
mnPolygonPathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulPOLY) ); mnPolygonPathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulPOLY) );
mnFreeformPathPos = mpLBAnimation->InsertEntry( sdr::GetResourceString(STR_ObjNameSingulFREELINE) ); 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) while(aCategoryIter != aCategoryEnd)
{ {
PresetCategoryPtr pCategory( *aCategoryIter++ ); PresetCategoryPtr pCategory( *aCategoryIter++ );
......
...@@ -117,6 +117,8 @@ private: ...@@ -117,6 +117,8 @@ private:
bool setProperty1Value( sal_Int32 nType, const CustomAnimationEffectPtr& pEffect, const css::uno::Any& rValue ); bool setProperty1Value( sal_Int32 nType, const CustomAnimationEffectPtr& pEffect, const css::uno::Any& rValue );
void UpdateLook(); void UpdateLook();
sal_uInt32 fillAnimationLB( bool bHasText ); 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( implControlListBoxHdl, ListBox&, void );
DECL_LINK( implClickHdl, Button*, void ); DECL_LINK( implClickHdl, Button*, void );
......
...@@ -70,6 +70,19 @@ rtl::Reference<FuPoor> FuConstructBezierPolygon::Create( ViewShell* pViewSh, ::s ...@@ -70,6 +70,19 @@ rtl::Reference<FuPoor> FuConstructBezierPolygon::Create( ViewShell* pViewSh, ::s
return xFunc; 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 FuConstructBezierPolygon::MouseButtonDown(const MouseEvent& rMEvt)
{ {
bool bReturn = FuConstruct::MouseButtonDown(rMEvt); bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
......
...@@ -33,6 +33,7 @@ class FuConstructBezierPolygon ...@@ -33,6 +33,7 @@ class FuConstructBezierPolygon
public: public:
static rtl::Reference<FuPoor> Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent ); 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 // Mouse- & Key-Events
virtual bool MouseButtonUp(const MouseEvent& rMEvt) override; virtual bool MouseButtonUp(const MouseEvent& rMEvt) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment