27#include <com/sun/star/animations/Event.hpp>
28#include <com/sun/star/animations/EventTrigger.hpp>
29#include <com/sun/star/container/XEnumerationAccess.hpp>
30#include <com/sun/star/beans/XPropertySet.hpp>
33using ::com::sun::star::uno::Reference;
41class RewinderEventHandler :
public EventHandler
44 typedef ::std::function<bool ()>
Action;
49 virtual bool handleEvent()
override {
return maAction(); }
53class RewinderAnimationEventHandler :
public AnimationEventHandler
57 explicit RewinderAnimationEventHandler (
Action aAction) :
maAction(
std::move(aAction)) {}
77 mrUserEventQueue(rUserEventQueue),
78 mpSlideStartHandler(),
80 mpAnimationStartHandler(),
81 mnMainSequenceEffectCount(0),
82 mpAsynchronousRewindEvent(),
83 mxCurrentAnimationRootNode(),
85 mbNonUserTriggeredMainSequenceEffectSeen(false),
86 mbHasAdvancedTimeSetting(false)
101 std::make_shared<RewinderAnimationEventHandler>(
107 std::make_shared<RewinderEventHandler>(
112 std::make_shared<RewinderEventHandler>(
165 sal_Int32 nChange(0);
174 const ::std::shared_ptr<ScreenUpdater::UpdateLock>& rpPaintLock,
175 const ::std::function<
void ()>& rSlideRewindFunctor,
176 const ::std::function<
void ()>& rPreviousSlideFunctor)
196 if ( ! rPreviousSlideFunctor)
198 OSL_ASSERT(rPreviousSlideFunctor);
208 rPreviousSlideFunctor),
209 "EffectRewinder::asynchronousRewindToPreviousSlide");
221 rSlideRewindFunctor),
222 "EffectRewinder::asynchronousRewind");
246 nTotalMainSequenceEffectCount,
248 ::std::function<
void ()>()),
249 "EffectRewinder::asynchronousRewind");
257 sal_Int32 nMainSequenceNodeCount (0);
259 ::std::queue<uno::Reference<animations::XAnimationNode> > aNodeQueue;
261 while ( ! aNodeQueue.empty())
270 if (xNode->getBegin() >>=
aEvent)
271 if (
aEvent.Trigger == animations::EventTrigger::ON_NEXT)
272 ++nMainSequenceNodeCount;
277 if (xEnumerationAccess.is())
280 xEnumerationAccess->createEnumeration());
281 if (xEnumeration.is())
282 while (xEnumeration->hasMoreElements())
286 xEnumeration->nextElement(), uno::UNO_QUERY));
291 return nMainSequenceNodeCount;
322 if ( ! (pParent && pParent->isMainSequenceRootNode()))
327 bool bIsUserTriggered (
false);
329 Reference<animations::XAnimationNode> xNode (rpNode->getXAnimationNode());
333 if (xNode->getBegin() >>=
aEvent)
334 bIsUserTriggered = (
aEvent.Trigger == animations::EventTrigger::ON_NEXT);
337 if (bIsUserTriggered)
347 sal_Int32 nEffectCount,
348 const bool bRedisplayCurrentSlide,
349 const std::function<
void ()>& rSlideRewindFunctor)
353 if (bRedisplayCurrentSlide)
357 if (rSlideRewindFunctor)
358 rSlideRewindFunctor();
365 rSlideRewindFunctor),
366 "EffectRewinder::asynchronousRewind");
384 while (--nEffectCount >= 0)
394 const ::std::function<
void ()>& rSlideRewindFunctor)
399 rSlideRewindFunctor();
void asynchronousRewindToPreviousSlide(const ::std::function< void()> &rPreviousSlideFunctor)
Go to the previous slide and replay all of its main sequence effects (or effect groups).
bool mbNonUserTriggeredMainSequenceEffectSeen
EventHandlerSharedPtr mpSlideEndHandler
sal_Int32 countMainSequenceEffects()
Count the number of effects (or effect groups) in the main effect sequence.
void skipSingleMainSequenceEffects()
Skip the next main sequence effect.
css::uno::Reference< css::animations::XAnimationNode > mxCurrentAnimationRootNode
void asynchronousRewind(sal_Int32 nEffectCount, const bool bRedisplayCurrentSlide, const ::std::function< void()> &rSlideRewindFunctor)
Rewind the last effect of the main effect sequence by replaying all previous effects.
bool mbHasAdvancedTimeSetting
EventQueue & mrEventQueue
void setRootAnimationNode(const css::uno::Reference< css::animations::XAnimationNode > &xRootNode)
Store the root node of the animation tree.
sal_Int32 mnMainSequenceEffectCount
The number off main sequence effects so far.
css::uno::Reference< css::drawing::XDrawPage > mxCurrentSlide
bool notifyAnimationStart(const AnimationNodeSharedPtr &rpNode)
Called by listeners when an animation (not necessarily of a main sequence effect) starts.
void dispose()
Call Dispose() before the owner of an EffectRewinder object dies so that the EffectRewinder can relea...
void skipAllMainSequenceEffects()
Call this method after gotoPreviousEffect() triggered a slide change to the previous slide.
EffectRewinder(EventMultiplexer &rEventMultiplexer, EventQueue &rEventQueue, UserEventQueue &rUserEventQueue)
AnimationEventHandlerSharedPtr mpAnimationStartHandler
void setCurrentSlide(const css::uno::Reference< css::drawing::XDrawPage > &xSlide)
Store the XDrawPage to reach specific slide properties.
UserEventQueue & mrUserEventQueue
EventMultiplexer & mrEventMultiplexer
EventHandlerSharedPtr mpSlideStartHandler
EventSharedPtr mpAsynchronousRewindEvent
This is the currently scheduled event that executes the asynchronous part of the effect rewinding.
bool rewind(const ::std::shared_ptr< ScreenUpdater::UpdateLock > &rpPaintLock, const ::std::function< void()> &rSlideRewindFunctor, const ::std::function< void()> &rPreviousSlideFunctor)
Rewind one effect of the main effect sequence.
::std::shared_ptr< ScreenUpdater::UpdateLock > mpPaintLock
This class multiplexes user-activated and slide-show global events.
void addAnimationStartHandler(const AnimationEventHandlerSharedPtr &rHandler)
Register an event handler that will be called when an XAnimationNode starts its active duration.
void removeSlideEndHandler(const EventHandlerSharedPtr &rHandler)
void addSlideEndHandler(const EventHandlerSharedPtr &rHandler)
Register an event handler that will be called when the slide is about to vanish.
void addSlideStartHandler(const EventHandlerSharedPtr &rHandler)
Register an event handler that will be called when the slide is just shown.
bool notifyNextEffect()
Notify that the user requested the next effect.
void removeSlideStartHandler(const EventHandlerSharedPtr &rHandler)
void removeAnimationStartHandler(const AnimationEventHandlerSharedPtr &rHandler)
This class handles events in a presentation.
void forceEmpty()
Forces an empty queue, firing all events immediately without minding any times.
bool addEvent(const EventSharedPtr &event)
Add the given event to the queue.
This class schedules user-activated events.
void callSkipEffectEventHandler()
Typically skipping the current effect is triggered by mouse clicks or key presses that trigger the ne...
::std::shared_ptr< BaseContainerNode > BaseContainerNodeSharedPtr
bool getPropertyValue(ValueType &rValue, css::uno::Reference< css::beans::XPropertySet > const &xPropSet, OUString const &propName)
::std::shared_ptr< AnimationNode > AnimationNodeSharedPtr
::std::shared_ptr< BaseNode > BaseNodeSharedPtr
EventMultiplexer & mrEventMultiplexer
EventQueue & mrEventQueue