From 7e18b87566c55b38ca812c28b01ed346d45e94b8 Mon Sep 17 00:00:00 2001 From: Mark Hung Date: Sun, 24 Feb 2019 17:49:03 +0800 Subject: [PATCH] tdf#88969 restart interactive sequence. This patch allows the whole interactive sequence to restart automatically when it's done. User don't need to insert multiple pause toggle command to a media object just for toggling the media multiple times. Change-Id: I000a55f580917327ae438ea8e79e62f63275cce7 Reviewed-on: https://gerrit.libreoffice.org/68283 Tested-by: Jenkins Reviewed-by: Mark Hung --- sd/source/core/CustomAnimationEffect.cxx | 2 ++ .../animationnodes/basecontainernode.cxx | 23 ++++++++++++++++--- slideshow/source/inc/basecontainernode.hxx | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/sd/source/core/CustomAnimationEffect.cxx b/sd/source/core/CustomAnimationEffect.cxx index 418a52b35e05..04f4fed1e035 100644 --- a/sd/source/core/CustomAnimationEffect.cxx +++ b/sd/source/core/CustomAnimationEffect.cxx @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -3099,6 +3100,7 @@ InteractiveSequencePtr MainSequence::createInteractiveSequence( const css::uno:: uno::Sequence< css::beans::NamedValue > aUserData { { "node-type", css::uno::makeAny(css::presentation::EffectNodeType::INTERACTIVE_SEQUENCE) } }; xISRoot->setUserData( aUserData ); + xISRoot->setRestart( css::animations::AnimationRestart::WHEN_NOT_ACTIVE ); Reference< XChild > xChild( mxSequenceRoot, UNO_QUERY_THROW ); Reference< XTimeContainer > xParent( xChild->getParent(), UNO_QUERY_THROW ); diff --git a/slideshow/source/engine/animationnodes/basecontainernode.cxx b/slideshow/source/engine/animationnodes/basecontainernode.cxx index d48df81161cb..e8e5dfbd7f88 100644 --- a/slideshow/source/engine/animationnodes/basecontainernode.cxx +++ b/slideshow/source/engine/animationnodes/basecontainernode.cxx @@ -19,6 +19,7 @@ #include +#include #include #include #include "nodetools.hxx" @@ -32,6 +33,19 @@ using namespace com::sun::star; namespace slideshow { namespace internal { +namespace { +bool isRepeatIndefinite(const uno::Reference& xNode) +{ + return xNode->getRepeatCount().hasValue() && isIndefiniteTiming(xNode->getRepeatCount()); +} + +bool isRestart(const uno::Reference& xNode) +{ + sal_Int16 nRestart = xNode->getRestart(); + return nRestart == animations::AnimationRestart::WHEN_NOT_ACTIVE || + nRestart == animations::AnimationRestart::ALWAYS; +} +} BaseContainerNode::BaseContainerNode( const uno::Reference< animations::XAnimationNode >& xNode, @@ -41,7 +55,8 @@ BaseContainerNode::BaseContainerNode( maChildren(), mnFinishedChildren(0), mnLeftIterations(0), - mbRepeatIndefinite(xNode->getRepeatCount().hasValue() && isIndefiniteTiming(xNode->getRepeatCount())), + mbRepeatIndefinite(isRepeatIndefinite(xNode)), + mbRestart(isRestart(xNode)), mbDurationIndefinite( isIndefiniteTiming( xNode->getEnd() ) && isIndefiniteTiming( xNode->getDuration() ) ) { @@ -144,9 +159,11 @@ bool BaseContainerNode::notifyDeactivatedChild( { mnLeftIterations -= 1.0; } - if( mnLeftIterations >= 1.0 ) + if(mnLeftIterations >= 1.0 || mbRestart) { - bFinished = false; + if (mnLeftIterations >= 1.0) + bFinished = false; + EventSharedPtr aRepetitionEvent = makeDelay( [this] () { this->repeat(); }, 0.0, diff --git a/slideshow/source/inc/basecontainernode.hxx b/slideshow/source/inc/basecontainernode.hxx index ca07eff16687..a86f05f08186 100644 --- a/slideshow/source/inc/basecontainernode.hxx +++ b/slideshow/source/inc/basecontainernode.hxx @@ -86,6 +86,7 @@ protected: private: const bool mbRepeatIndefinite; + const bool mbRestart; const bool mbDurationIndefinite; };