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 #ifndef INCLUDED_SLIDESHOW_EFFECT_REWINDER_HXX 29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_EFFECT_REWINDER_HXX 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "animationnode.hxx" 32*cdf0e10cSrcweir #include "eventhandler.hxx" 33*cdf0e10cSrcweir #include "animationeventhandler.hxx" 34*cdf0e10cSrcweir #include "event.hxx" 35*cdf0e10cSrcweir #include "screenupdater.hxx" 36*cdf0e10cSrcweir 37*cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShow.hpp> 38*cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 39*cdf0e10cSrcweir #include <boost/function.hpp> 40*cdf0e10cSrcweir #include <vector> 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir namespace css = ::com::sun::star; 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir namespace slideshow { namespace internal { 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir class EventMultiplexer; 47*cdf0e10cSrcweir class EventQueue; 48*cdf0e10cSrcweir class UserEventQueue; 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir /** Rewind single effects of the main effect sequence. A rewind is 51*cdf0e10cSrcweir initiated by calling the Rewind() method. Part of the processing is 52*cdf0e10cSrcweir done asynchronously. Multiple EventQueue::update() calls may be 53*cdf0e10cSrcweir necessary to finish a rewind. 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir Remember to call SetRootAnimationNode() when switching to a different 56*cdf0e10cSrcweir slide so that the EffectRewinder can determine the number of main 57*cdf0e10cSrcweir sequence effects. 58*cdf0e10cSrcweir */ 59*cdf0e10cSrcweir class EffectRewinder 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir public: 62*cdf0e10cSrcweir EffectRewinder ( 63*cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer, 64*cdf0e10cSrcweir EventQueue& rEventQueue, 65*cdf0e10cSrcweir UserEventQueue& rUserEventQueue); 66*cdf0e10cSrcweir ~EffectRewinder (void); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir /** Call Dispose() before the ownder of an EffectRewinder object dies so 69*cdf0e10cSrcweir that the EffectRewinder can release all references to the owner. 70*cdf0e10cSrcweir 71*cdf0e10cSrcweir */ 72*cdf0e10cSrcweir void dispose (void); 73*cdf0e10cSrcweir 74*cdf0e10cSrcweir /** Store the root node of the animation tree. It is used in 75*cdf0e10cSrcweir CountMainSequenceEffects() to count the number of main sequence 76*cdf0e10cSrcweir effects (or effect groups.) 77*cdf0e10cSrcweir */ 78*cdf0e10cSrcweir void setRootAnimationNode ( 79*cdf0e10cSrcweir const css::uno::Reference<css::animations::XAnimationNode>& xRootNode); 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir /** Rewind one effect of the main effect sequence. When the current 82*cdf0e10cSrcweir slide has not effects or no main sequence effect has yet been played 83*cdf0e10cSrcweir then switch to the previous slide and replay all of its main 84*cdf0e10cSrcweir sequence effects. 85*cdf0e10cSrcweir The caller has to pass two functors that redisplay the current slide 86*cdf0e10cSrcweir or switch to the previous slide so that it does not have to expose 87*cdf0e10cSrcweir its internals to us. Only one of the two functors is called. 88*cdf0e10cSrcweir @param rpPaintLock 89*cdf0e10cSrcweir This paint lock is released after the whole asynchronous 90*cdf0e10cSrcweir procoess of rewinding the current effect is completed. It 91*cdf0e10cSrcweir prevents intermediate repaints that would show partial replay 92*cdf0e10cSrcweir of effects. 93*cdf0e10cSrcweir @param rSlideRewindFunctor 94*cdf0e10cSrcweir This functor is called when the current slide is to be 95*cdf0e10cSrcweir redisplayed. When it is called then the other functor is not 96*cdf0e10cSrcweir called. 97*cdf0e10cSrcweir @param rPreviousSlideFunctor 98*cdf0e10cSrcweir This functor is called to switch to the previous slide. When it 99*cdf0e10cSrcweir is called then the other functor is not called. 100*cdf0e10cSrcweir */ 101*cdf0e10cSrcweir bool rewind ( 102*cdf0e10cSrcweir const ::boost::shared_ptr<ScreenUpdater::UpdateLock>& rpPaintLock, 103*cdf0e10cSrcweir const ::boost::function<void(void)>& rSlideRewindFunctor, 104*cdf0e10cSrcweir const ::boost::function<void(void)>& rPreviousSlideFunctor); 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir /** Call this method after gotoPreviousEffect() triggered a slide change 107*cdf0e10cSrcweir to the previous slide. 108*cdf0e10cSrcweir */ 109*cdf0e10cSrcweir void skipAllMainSequenceEffects (void); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir private: 112*cdf0e10cSrcweir EventMultiplexer& mrEventMultiplexer; 113*cdf0e10cSrcweir EventQueue& mrEventQueue; 114*cdf0e10cSrcweir UserEventQueue& mrUserEventQueue; 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir EventHandlerSharedPtr mpSlideStartHandler; 117*cdf0e10cSrcweir EventHandlerSharedPtr mpSlideEndHandler; 118*cdf0e10cSrcweir AnimationEventHandlerSharedPtr mpAnimationStartHandler; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir /** The number off main sequence effects so far. 121*cdf0e10cSrcweir */ 122*cdf0e10cSrcweir sal_Int32 mnMainSequenceEffectCount; 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir /** This is the currently scheduled event that executes the asynchronous 125*cdf0e10cSrcweir part of the effect rewinding. It is also used as flag that prevents 126*cdf0e10cSrcweir nested rewinds. 127*cdf0e10cSrcweir */ 128*cdf0e10cSrcweir EventSharedPtr mpAsynchronousRewindEvent; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir css::uno::Reference<css::animations::XAnimationNode> mxCurrentAnimationRootNode; 131*cdf0e10cSrcweir ::boost::shared_ptr<ScreenUpdater::UpdateLock> mpPaintLock; 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir bool mbNonUserTriggeredMainSequenceEffectSeen; 134*cdf0e10cSrcweir 135*cdf0e10cSrcweir void initialize (void); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir bool resetEffectCount (void); 138*cdf0e10cSrcweir /** Called by listeners when an animation (not necessarily of a main 139*cdf0e10cSrcweir sequence effect) starts. 140*cdf0e10cSrcweir */ 141*cdf0e10cSrcweir bool notifyAnimationStart (const AnimationNodeSharedPtr& rpNode); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir /** Count the number of effects (or effect groups) in the main effect 144*cdf0e10cSrcweir sequence. 145*cdf0e10cSrcweir */ 146*cdf0e10cSrcweir sal_Int32 countMainSequenceEffects (void); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir /** Skip the next main sequence effect. 149*cdf0e10cSrcweir */ 150*cdf0e10cSrcweir void skipSingleMainSequenceEffects (void); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir /** Skip the specified number of main sequence effects. 153*cdf0e10cSrcweir */ 154*cdf0e10cSrcweir void skipSomeMainSequenceEffects (const sal_Int32 nSkipCount); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir /** Rewind the last effect of the main effect sequence by replaying all 157*cdf0e10cSrcweir previous effects. 158*cdf0e10cSrcweir @param nEffectCount 159*cdf0e10cSrcweir The number of main sequence effects to replay. 160*cdf0e10cSrcweir @param bRedisplayCurrentSlide 161*cdf0e10cSrcweir When <TRUE/> then the current slide is redisplayed before the 162*cdf0e10cSrcweir effects are replayed. 163*cdf0e10cSrcweir @param rSlideRewindFunctor 164*cdf0e10cSrcweir This functor is used to redisplay the current slide. 165*cdf0e10cSrcweir */ 166*cdf0e10cSrcweir void asynchronousRewind ( 167*cdf0e10cSrcweir sal_Int32 nEffectCount, 168*cdf0e10cSrcweir const bool bRedisplayCurrentSlide, 169*cdf0e10cSrcweir const boost::function<void(void)>& rSlideRewindFunctor); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir /** Go to the previous slide and replay all of its main sequence effects 172*cdf0e10cSrcweir (or effect groups). 173*cdf0e10cSrcweir @param rPreviousSlideFunctor 174*cdf0e10cSrcweir This functor is used to go to the previous slide. 175*cdf0e10cSrcweir */ 176*cdf0e10cSrcweir void asynchronousRewindToPreviousSlide ( 177*cdf0e10cSrcweir const ::boost::function<void(void)>& rPreviousSlideFunctor); 178*cdf0e10cSrcweir }; 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir } } // end of namespace ::slideshow::internal 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir #endif 183