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