1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "precompiled_slideshow.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "effectrewinder.hxx"
31*cdf0e10cSrcweir #include "eventqueue.hxx"
32*cdf0e10cSrcweir #include "usereventqueue.hxx"
33*cdf0e10cSrcweir #include "mouseeventhandler.hxx"
34*cdf0e10cSrcweir #include "animationnodes/basecontainernode.hxx"
35*cdf0e10cSrcweir #include "delayevent.hxx"
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir #include <com/sun/star/awt/MouseEvent.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/animations/Event.hpp>
39*cdf0e10cSrcweir #include <com/sun/star/animations/EventTrigger.hpp>
40*cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
41*cdf0e10cSrcweir #include <boost/function.hpp>
42*cdf0e10cSrcweir #include <boost/bind.hpp>
43*cdf0e10cSrcweir #include <boost/enable_shared_from_this.hpp>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir using ::com::sun::star::uno::Reference;
46*cdf0e10cSrcweir using namespace ::com::sun::star;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir namespace slideshow { namespace internal {
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir namespace {
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir class RewinderEventHandler : public EventHandler
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir public:
56*cdf0e10cSrcweir     typedef ::boost::function<bool(void)> Action;
57*cdf0e10cSrcweir     RewinderEventHandler (const Action& rAction) : maAction(rAction) {}
58*cdf0e10cSrcweir     virtual ~RewinderEventHandler (void) {}
59*cdf0e10cSrcweir private:
60*cdf0e10cSrcweir     const Action maAction;
61*cdf0e10cSrcweir     virtual bool handleEvent (void) { return maAction(); }
62*cdf0e10cSrcweir };
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir class RewinderAnimationEventHandler : public AnimationEventHandler
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir public:
69*cdf0e10cSrcweir     typedef ::boost::function<bool(const AnimationNodeSharedPtr& rpNode)> Action;
70*cdf0e10cSrcweir     RewinderAnimationEventHandler (const Action& rAction) : maAction(rAction) {}
71*cdf0e10cSrcweir     virtual ~RewinderAnimationEventHandler (void) {}
72*cdf0e10cSrcweir private:
73*cdf0e10cSrcweir     const Action maAction;
74*cdf0e10cSrcweir     virtual bool handleAnimationEvent (const AnimationNodeSharedPtr& rpNode)
75*cdf0e10cSrcweir         { return maAction(rpNode); }
76*cdf0e10cSrcweir };
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir } // end of anonymous namespace
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir //----- EffectRewinder --------------------------------------------------------------
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir EffectRewinder::EffectRewinder (
86*cdf0e10cSrcweir     EventMultiplexer& rEventMultiplexer,
87*cdf0e10cSrcweir     EventQueue& rEventQueue,
88*cdf0e10cSrcweir     UserEventQueue& rUserEventQueue)
89*cdf0e10cSrcweir     : mrEventMultiplexer(rEventMultiplexer),
90*cdf0e10cSrcweir       mrEventQueue(rEventQueue),
91*cdf0e10cSrcweir       mrUserEventQueue(rUserEventQueue),
92*cdf0e10cSrcweir       mpSlideStartHandler(),
93*cdf0e10cSrcweir       mpSlideEndHandler(),
94*cdf0e10cSrcweir       mpAnimationStartHandler(),
95*cdf0e10cSrcweir       mnMainSequenceEffectCount(0),
96*cdf0e10cSrcweir       mpAsynchronousRewindEvent(),
97*cdf0e10cSrcweir       mxCurrentAnimationRootNode(),
98*cdf0e10cSrcweir       mbNonUserTriggeredMainSequenceEffectSeen(false)
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir     initialize();
101*cdf0e10cSrcweir }
102*cdf0e10cSrcweir 
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir void EffectRewinder::initialize (void)
107*cdf0e10cSrcweir {
108*cdf0e10cSrcweir     // Add some event handlers so that we are informed when
109*cdf0e10cSrcweir     // a) an animation is started (we then check whether that belongs to a
110*cdf0e10cSrcweir     // main sequence effect and if so, increase the respective counter),
111*cdf0e10cSrcweir     // b,c) a slide was started or ended (in which case the effect counter
112*cdf0e10cSrcweir     // is reset.
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir     mpAnimationStartHandler.reset(
115*cdf0e10cSrcweir         new RewinderAnimationEventHandler(
116*cdf0e10cSrcweir             ::boost::bind(&EffectRewinder::notifyAnimationStart, this, _1)));
117*cdf0e10cSrcweir     mrEventMultiplexer.addAnimationStartHandler(mpAnimationStartHandler);
118*cdf0e10cSrcweir 
119*cdf0e10cSrcweir     mpSlideStartHandler.reset(
120*cdf0e10cSrcweir         new RewinderEventHandler(
121*cdf0e10cSrcweir             ::boost::bind(&EffectRewinder::resetEffectCount, this)));
122*cdf0e10cSrcweir     mrEventMultiplexer.addSlideStartHandler(mpSlideStartHandler);
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir     mpSlideEndHandler.reset(
125*cdf0e10cSrcweir         new RewinderEventHandler(
126*cdf0e10cSrcweir             ::boost::bind(&EffectRewinder::resetEffectCount, this)));
127*cdf0e10cSrcweir     mrEventMultiplexer.addSlideEndHandler(mpSlideEndHandler);
128*cdf0e10cSrcweir }
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir EffectRewinder::~EffectRewinder (void)
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir     dispose();
136*cdf0e10cSrcweir }
137*cdf0e10cSrcweir 
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir void EffectRewinder::dispose (void)
142*cdf0e10cSrcweir {
143*cdf0e10cSrcweir     if (mpAsynchronousRewindEvent)
144*cdf0e10cSrcweir     {
145*cdf0e10cSrcweir         mpAsynchronousRewindEvent->dispose();
146*cdf0e10cSrcweir         mpAsynchronousRewindEvent.reset();
147*cdf0e10cSrcweir     }
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir     if (mpAnimationStartHandler)
150*cdf0e10cSrcweir     {
151*cdf0e10cSrcweir         mrEventMultiplexer.removeAnimationStartHandler(mpAnimationStartHandler);
152*cdf0e10cSrcweir         mpAnimationStartHandler.reset();
153*cdf0e10cSrcweir     }
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     if (mpSlideStartHandler)
156*cdf0e10cSrcweir     {
157*cdf0e10cSrcweir         mrEventMultiplexer.removeSlideStartHandler(mpSlideStartHandler);
158*cdf0e10cSrcweir         mpSlideStartHandler.reset();
159*cdf0e10cSrcweir     }
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     if (mpSlideEndHandler)
162*cdf0e10cSrcweir     {
163*cdf0e10cSrcweir         mrEventMultiplexer.removeSlideEndHandler(mpSlideEndHandler);
164*cdf0e10cSrcweir         mpSlideEndHandler.reset();
165*cdf0e10cSrcweir     }
166*cdf0e10cSrcweir }
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir void EffectRewinder::setRootAnimationNode (
172*cdf0e10cSrcweir     const uno::Reference<animations::XAnimationNode>& xRootNode)
173*cdf0e10cSrcweir {
174*cdf0e10cSrcweir     mxCurrentAnimationRootNode = xRootNode;
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir bool EffectRewinder::rewind (
181*cdf0e10cSrcweir     const ::boost::shared_ptr<ScreenUpdater::UpdateLock>& rpPaintLock,
182*cdf0e10cSrcweir     const ::boost::function<void(void)>& rSlideRewindFunctor,
183*cdf0e10cSrcweir     const ::boost::function<void(void)>& rPreviousSlideFunctor)
184*cdf0e10cSrcweir {
185*cdf0e10cSrcweir     mpPaintLock = rpPaintLock;
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     // Do not allow nested rewinds.
188*cdf0e10cSrcweir     if (mpAsynchronousRewindEvent)
189*cdf0e10cSrcweir     {
190*cdf0e10cSrcweir         OSL_ASSERT( ! mpAsynchronousRewindEvent);
191*cdf0e10cSrcweir         return false;
192*cdf0e10cSrcweir     }
193*cdf0e10cSrcweir 
194*cdf0e10cSrcweir     // Abort (and skip over the rest of) any currently active animation.
195*cdf0e10cSrcweir     mrUserEventQueue.callSkipEffectEventHandler();
196*cdf0e10cSrcweir     mrEventQueue.forceEmpty();
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir     const int nSkipCount (mnMainSequenceEffectCount - 1);
199*cdf0e10cSrcweir     if (nSkipCount < 0)
200*cdf0e10cSrcweir     {
201*cdf0e10cSrcweir         if ( ! rPreviousSlideFunctor)
202*cdf0e10cSrcweir         {
203*cdf0e10cSrcweir             OSL_ASSERT(rPreviousSlideFunctor);
204*cdf0e10cSrcweir             return false;
205*cdf0e10cSrcweir         }
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir         // No main sequence effects to rewind on the current slide.
208*cdf0e10cSrcweir         // Go back to the previous slide.
209*cdf0e10cSrcweir         mpAsynchronousRewindEvent = makeEvent(
210*cdf0e10cSrcweir             ::boost::bind(
211*cdf0e10cSrcweir                 &EffectRewinder::asynchronousRewindToPreviousSlide,
212*cdf0e10cSrcweir                 this,
213*cdf0e10cSrcweir                 rPreviousSlideFunctor),
214*cdf0e10cSrcweir             "EffectRewinder::asynchronousRewindToPreviousSlide");
215*cdf0e10cSrcweir     }
216*cdf0e10cSrcweir     else
217*cdf0e10cSrcweir     {
218*cdf0e10cSrcweir         // The actual rewinding is done asynchronously so that we can safely
219*cdf0e10cSrcweir         // call other methods.
220*cdf0e10cSrcweir         mpAsynchronousRewindEvent = makeEvent(
221*cdf0e10cSrcweir             ::boost::bind(
222*cdf0e10cSrcweir                 &EffectRewinder::asynchronousRewind,
223*cdf0e10cSrcweir                 this,
224*cdf0e10cSrcweir                 nSkipCount,
225*cdf0e10cSrcweir                 true,
226*cdf0e10cSrcweir                 rSlideRewindFunctor),
227*cdf0e10cSrcweir             "EffectRewinder::asynchronousRewind");
228*cdf0e10cSrcweir     }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     if (mpAsynchronousRewindEvent)
231*cdf0e10cSrcweir         mrEventQueue.addEvent(mpAsynchronousRewindEvent);
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     return mpAsynchronousRewindEvent.get()!=NULL;
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir 
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir void EffectRewinder::skipAllMainSequenceEffects (void)
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir     // Do not allow nested rewinds.
242*cdf0e10cSrcweir     if (mpAsynchronousRewindEvent)
243*cdf0e10cSrcweir     {
244*cdf0e10cSrcweir         OSL_ASSERT(!mpAsynchronousRewindEvent);
245*cdf0e10cSrcweir         return;
246*cdf0e10cSrcweir     }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir     const int nTotalMainSequenceEffectCount (countMainSequenceEffects());
249*cdf0e10cSrcweir     mpAsynchronousRewindEvent = makeEvent(
250*cdf0e10cSrcweir         ::boost::bind(
251*cdf0e10cSrcweir             &EffectRewinder::asynchronousRewind,
252*cdf0e10cSrcweir             this,
253*cdf0e10cSrcweir             nTotalMainSequenceEffectCount,
254*cdf0e10cSrcweir             false,
255*cdf0e10cSrcweir             ::boost::function<void(void)>()),
256*cdf0e10cSrcweir         "EffectRewinder::asynchronousRewind");
257*cdf0e10cSrcweir     mrEventQueue.addEvent(mpAsynchronousRewindEvent);
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir sal_Int32 EffectRewinder::countMainSequenceEffects (void)
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     // Determine the number of main sequence effects.
266*cdf0e10cSrcweir     sal_Int32 nMainSequenceNodeCount (0);
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir     ::std::queue<uno::Reference<animations::XAnimationNode> > aNodeQueue;
269*cdf0e10cSrcweir     aNodeQueue.push(mxCurrentAnimationRootNode);
270*cdf0e10cSrcweir     while ( ! aNodeQueue.empty())
271*cdf0e10cSrcweir     {
272*cdf0e10cSrcweir         const uno::Reference<animations::XAnimationNode> xNode (aNodeQueue.front());
273*cdf0e10cSrcweir         aNodeQueue.pop();
274*cdf0e10cSrcweir 
275*cdf0e10cSrcweir         // Does the current node belong to the main sequence?
276*cdf0e10cSrcweir         if (xNode.is())
277*cdf0e10cSrcweir         {
278*cdf0e10cSrcweir             animations::Event aEvent;
279*cdf0e10cSrcweir             if (xNode->getBegin() >>= aEvent)
280*cdf0e10cSrcweir                 if (aEvent.Trigger == animations::EventTrigger::ON_NEXT)
281*cdf0e10cSrcweir                     ++nMainSequenceNodeCount;
282*cdf0e10cSrcweir         }
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir         // If the current node is a container then prepare its children for investigation.
285*cdf0e10cSrcweir         uno::Reference<container::XEnumerationAccess> xEnumerationAccess (xNode, uno::UNO_QUERY);
286*cdf0e10cSrcweir         if (xEnumerationAccess.is())
287*cdf0e10cSrcweir         {
288*cdf0e10cSrcweir             uno::Reference<container::XEnumeration> xEnumeration (
289*cdf0e10cSrcweir                 xEnumerationAccess->createEnumeration());
290*cdf0e10cSrcweir             if (xEnumeration.is())
291*cdf0e10cSrcweir                 while (xEnumeration->hasMoreElements())
292*cdf0e10cSrcweir                 {
293*cdf0e10cSrcweir                     aNodeQueue.push(
294*cdf0e10cSrcweir                         uno::Reference<animations::XAnimationNode>(
295*cdf0e10cSrcweir                             xEnumeration->nextElement(), uno::UNO_QUERY));
296*cdf0e10cSrcweir                 }
297*cdf0e10cSrcweir         }
298*cdf0e10cSrcweir     }
299*cdf0e10cSrcweir 
300*cdf0e10cSrcweir     return nMainSequenceNodeCount;
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     //    // Skip all main sequence nodes.
303*cdf0e10cSrcweir     //    SkipSomeMainSequenceEffects(nMainSequenceNodeCount);
304*cdf0e10cSrcweir }
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir 
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir void EffectRewinder::skipSomeMainSequenceEffects (sal_Int32 nSkipCount)
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir     while (--nSkipCount >= 0)
312*cdf0e10cSrcweir         skipSingleMainSequenceEffects();
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir void EffectRewinder::skipSingleMainSequenceEffects (void)
319*cdf0e10cSrcweir {
320*cdf0e10cSrcweir     // This basically just starts the next effect and then skips over its
321*cdf0e10cSrcweir     // animation.
322*cdf0e10cSrcweir     mrEventMultiplexer.notifyNextEffect();
323*cdf0e10cSrcweir     mrEventQueue.forceEmpty();
324*cdf0e10cSrcweir     mrUserEventQueue.callSkipEffectEventHandler();
325*cdf0e10cSrcweir     mrEventQueue.forceEmpty();
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir 
331*cdf0e10cSrcweir bool EffectRewinder::resetEffectCount (void)
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     mnMainSequenceEffectCount = 0;
334*cdf0e10cSrcweir     return false;
335*cdf0e10cSrcweir }
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir bool EffectRewinder::notifyAnimationStart (const AnimationNodeSharedPtr& rpNode)
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir     // This notification is only relevant for us when the rpNode belongs to
343*cdf0e10cSrcweir     // the main sequence.
344*cdf0e10cSrcweir     BaseNodeSharedPtr pBaseNode (::boost::dynamic_pointer_cast<BaseNode>(rpNode));
345*cdf0e10cSrcweir     if ( ! pBaseNode)
346*cdf0e10cSrcweir         return false;
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir     BaseContainerNodeSharedPtr pParent (pBaseNode->getParentNode());
349*cdf0e10cSrcweir     if ( ! (pParent && pParent->isMainSequenceRootNode()))
350*cdf0e10cSrcweir         return false;
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     // This notification is only relevant for us when the effect is user
353*cdf0e10cSrcweir     // triggered.
354*cdf0e10cSrcweir     bool bIsUserTriggered (false);
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir     Reference<animations::XAnimationNode> xNode (rpNode->getXAnimationNode());
357*cdf0e10cSrcweir     if (xNode.is())
358*cdf0e10cSrcweir     {
359*cdf0e10cSrcweir         animations::Event aEvent;
360*cdf0e10cSrcweir         if ((xNode->getBegin() >>= aEvent))
361*cdf0e10cSrcweir             bIsUserTriggered = (aEvent.Trigger == animations::EventTrigger::ON_NEXT);
362*cdf0e10cSrcweir     }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     if (bIsUserTriggered)
365*cdf0e10cSrcweir         ++mnMainSequenceEffectCount;
366*cdf0e10cSrcweir     else
367*cdf0e10cSrcweir         mbNonUserTriggeredMainSequenceEffectSeen = true;
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir     return false;
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir void EffectRewinder::asynchronousRewind (
376*cdf0e10cSrcweir     sal_Int32 nEffectCount,
377*cdf0e10cSrcweir     const bool bRedisplayCurrentSlide,
378*cdf0e10cSrcweir     const boost::function<void(void)>& rSlideRewindFunctor)
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir     OSL_ASSERT(mpAsynchronousRewindEvent);
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir     if (bRedisplayCurrentSlide)
383*cdf0e10cSrcweir     {
384*cdf0e10cSrcweir         mpPaintLock->Activate();
385*cdf0e10cSrcweir         // Re-display the current slide.
386*cdf0e10cSrcweir         if (rSlideRewindFunctor)
387*cdf0e10cSrcweir             rSlideRewindFunctor();
388*cdf0e10cSrcweir         mpAsynchronousRewindEvent = makeEvent(
389*cdf0e10cSrcweir             ::boost::bind(
390*cdf0e10cSrcweir                 &EffectRewinder::asynchronousRewind,
391*cdf0e10cSrcweir                 this,
392*cdf0e10cSrcweir                 nEffectCount,
393*cdf0e10cSrcweir                 false,
394*cdf0e10cSrcweir                 rSlideRewindFunctor),
395*cdf0e10cSrcweir             "EffectRewinder::asynchronousRewind");
396*cdf0e10cSrcweir         mrEventQueue.addEvent(mpAsynchronousRewindEvent);
397*cdf0e10cSrcweir     }
398*cdf0e10cSrcweir     else
399*cdf0e10cSrcweir     {
400*cdf0e10cSrcweir         // Process initial events and skip any animations that are started
401*cdf0e10cSrcweir         // when the slide is shown.
402*cdf0e10cSrcweir         mbNonUserTriggeredMainSequenceEffectSeen = false;
403*cdf0e10cSrcweir         mrEventQueue.forceEmpty();
404*cdf0e10cSrcweir         if (mbNonUserTriggeredMainSequenceEffectSeen)
405*cdf0e10cSrcweir         {
406*cdf0e10cSrcweir             mrUserEventQueue.callSkipEffectEventHandler();
407*cdf0e10cSrcweir             mrEventQueue.forceEmpty();
408*cdf0e10cSrcweir         }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir         while (--nEffectCount >= 0)
411*cdf0e10cSrcweir             skipSingleMainSequenceEffects();
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir         mpAsynchronousRewindEvent.reset();
414*cdf0e10cSrcweir         mpPaintLock.reset();
415*cdf0e10cSrcweir     }
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 
421*cdf0e10cSrcweir void EffectRewinder::asynchronousRewindToPreviousSlide (
422*cdf0e10cSrcweir     const ::boost::function<void(void)>& rSlideRewindFunctor)
423*cdf0e10cSrcweir {
424*cdf0e10cSrcweir     OSL_ASSERT(mpAsynchronousRewindEvent);
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir     mpAsynchronousRewindEvent.reset();
427*cdf0e10cSrcweir     rSlideRewindFunctor();
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir 
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir } } // end of namespace ::slideshow::internal
434