1*aaef562fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*aaef562fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*aaef562fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*aaef562fSAndrew Rist * distributed with this work for additional information 6*aaef562fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*aaef562fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*aaef562fSAndrew Rist * "License"); you may not use this file except in compliance 9*aaef562fSAndrew Rist * with the License. You may obtain a copy of the License at 10*aaef562fSAndrew Rist * 11*aaef562fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*aaef562fSAndrew Rist * 13*aaef562fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*aaef562fSAndrew Rist * software distributed under the License is distributed on an 15*aaef562fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*aaef562fSAndrew Rist * KIND, either express or implied. See the License for the 17*aaef562fSAndrew Rist * specific language governing permissions and limitations 18*aaef562fSAndrew Rist * under the License. 19*aaef562fSAndrew Rist * 20*aaef562fSAndrew Rist *************************************************************/ 21*aaef562fSAndrew Rist 22*aaef562fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_SLIDESHOW_EFFECT_REWINDER_HXX 25cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_EFFECT_REWINDER_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "animationnode.hxx" 28cdf0e10cSrcweir #include "eventhandler.hxx" 29cdf0e10cSrcweir #include "animationeventhandler.hxx" 30cdf0e10cSrcweir #include "event.hxx" 31cdf0e10cSrcweir #include "screenupdater.hxx" 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <com/sun/star/presentation/XSlideShow.hpp> 34cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 35cdf0e10cSrcweir #include <boost/function.hpp> 36cdf0e10cSrcweir #include <vector> 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace css = ::com::sun::star; 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace slideshow { namespace internal { 41cdf0e10cSrcweir 42cdf0e10cSrcweir class EventMultiplexer; 43cdf0e10cSrcweir class EventQueue; 44cdf0e10cSrcweir class UserEventQueue; 45cdf0e10cSrcweir 46cdf0e10cSrcweir /** Rewind single effects of the main effect sequence. A rewind is 47cdf0e10cSrcweir initiated by calling the Rewind() method. Part of the processing is 48cdf0e10cSrcweir done asynchronously. Multiple EventQueue::update() calls may be 49cdf0e10cSrcweir necessary to finish a rewind. 50cdf0e10cSrcweir 51cdf0e10cSrcweir Remember to call SetRootAnimationNode() when switching to a different 52cdf0e10cSrcweir slide so that the EffectRewinder can determine the number of main 53cdf0e10cSrcweir sequence effects. 54cdf0e10cSrcweir */ 55cdf0e10cSrcweir class EffectRewinder 56cdf0e10cSrcweir { 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir EffectRewinder ( 59cdf0e10cSrcweir EventMultiplexer& rEventMultiplexer, 60cdf0e10cSrcweir EventQueue& rEventQueue, 61cdf0e10cSrcweir UserEventQueue& rUserEventQueue); 62cdf0e10cSrcweir ~EffectRewinder (void); 63cdf0e10cSrcweir 64cdf0e10cSrcweir /** Call Dispose() before the ownder of an EffectRewinder object dies so 65cdf0e10cSrcweir that the EffectRewinder can release all references to the owner. 66cdf0e10cSrcweir 67cdf0e10cSrcweir */ 68cdf0e10cSrcweir void dispose (void); 69cdf0e10cSrcweir 70cdf0e10cSrcweir /** Store the root node of the animation tree. It is used in 71cdf0e10cSrcweir CountMainSequenceEffects() to count the number of main sequence 72cdf0e10cSrcweir effects (or effect groups.) 73cdf0e10cSrcweir */ 74cdf0e10cSrcweir void setRootAnimationNode ( 75cdf0e10cSrcweir const css::uno::Reference<css::animations::XAnimationNode>& xRootNode); 76cdf0e10cSrcweir 77cdf0e10cSrcweir /** Rewind one effect of the main effect sequence. When the current 78cdf0e10cSrcweir slide has not effects or no main sequence effect has yet been played 79cdf0e10cSrcweir then switch to the previous slide and replay all of its main 80cdf0e10cSrcweir sequence effects. 81cdf0e10cSrcweir The caller has to pass two functors that redisplay the current slide 82cdf0e10cSrcweir or switch to the previous slide so that it does not have to expose 83cdf0e10cSrcweir its internals to us. Only one of the two functors is called. 84cdf0e10cSrcweir @param rpPaintLock 85cdf0e10cSrcweir This paint lock is released after the whole asynchronous 86cdf0e10cSrcweir procoess of rewinding the current effect is completed. It 87cdf0e10cSrcweir prevents intermediate repaints that would show partial replay 88cdf0e10cSrcweir of effects. 89cdf0e10cSrcweir @param rSlideRewindFunctor 90cdf0e10cSrcweir This functor is called when the current slide is to be 91cdf0e10cSrcweir redisplayed. When it is called then the other functor is not 92cdf0e10cSrcweir called. 93cdf0e10cSrcweir @param rPreviousSlideFunctor 94cdf0e10cSrcweir This functor is called to switch to the previous slide. When it 95cdf0e10cSrcweir is called then the other functor is not called. 96cdf0e10cSrcweir */ 97cdf0e10cSrcweir bool rewind ( 98cdf0e10cSrcweir const ::boost::shared_ptr<ScreenUpdater::UpdateLock>& rpPaintLock, 99cdf0e10cSrcweir const ::boost::function<void(void)>& rSlideRewindFunctor, 100cdf0e10cSrcweir const ::boost::function<void(void)>& rPreviousSlideFunctor); 101cdf0e10cSrcweir 102cdf0e10cSrcweir /** Call this method after gotoPreviousEffect() triggered a slide change 103cdf0e10cSrcweir to the previous slide. 104cdf0e10cSrcweir */ 105cdf0e10cSrcweir void skipAllMainSequenceEffects (void); 106cdf0e10cSrcweir 107cdf0e10cSrcweir private: 108cdf0e10cSrcweir EventMultiplexer& mrEventMultiplexer; 109cdf0e10cSrcweir EventQueue& mrEventQueue; 110cdf0e10cSrcweir UserEventQueue& mrUserEventQueue; 111cdf0e10cSrcweir 112cdf0e10cSrcweir EventHandlerSharedPtr mpSlideStartHandler; 113cdf0e10cSrcweir EventHandlerSharedPtr mpSlideEndHandler; 114cdf0e10cSrcweir AnimationEventHandlerSharedPtr mpAnimationStartHandler; 115cdf0e10cSrcweir 116cdf0e10cSrcweir /** The number off main sequence effects so far. 117cdf0e10cSrcweir */ 118cdf0e10cSrcweir sal_Int32 mnMainSequenceEffectCount; 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** This is the currently scheduled event that executes the asynchronous 121cdf0e10cSrcweir part of the effect rewinding. It is also used as flag that prevents 122cdf0e10cSrcweir nested rewinds. 123cdf0e10cSrcweir */ 124cdf0e10cSrcweir EventSharedPtr mpAsynchronousRewindEvent; 125cdf0e10cSrcweir 126cdf0e10cSrcweir css::uno::Reference<css::animations::XAnimationNode> mxCurrentAnimationRootNode; 127cdf0e10cSrcweir ::boost::shared_ptr<ScreenUpdater::UpdateLock> mpPaintLock; 128cdf0e10cSrcweir 129cdf0e10cSrcweir bool mbNonUserTriggeredMainSequenceEffectSeen; 130cdf0e10cSrcweir 131cdf0e10cSrcweir void initialize (void); 132cdf0e10cSrcweir 133cdf0e10cSrcweir bool resetEffectCount (void); 134cdf0e10cSrcweir /** Called by listeners when an animation (not necessarily of a main 135cdf0e10cSrcweir sequence effect) starts. 136cdf0e10cSrcweir */ 137cdf0e10cSrcweir bool notifyAnimationStart (const AnimationNodeSharedPtr& rpNode); 138cdf0e10cSrcweir 139cdf0e10cSrcweir /** Count the number of effects (or effect groups) in the main effect 140cdf0e10cSrcweir sequence. 141cdf0e10cSrcweir */ 142cdf0e10cSrcweir sal_Int32 countMainSequenceEffects (void); 143cdf0e10cSrcweir 144cdf0e10cSrcweir /** Skip the next main sequence effect. 145cdf0e10cSrcweir */ 146cdf0e10cSrcweir void skipSingleMainSequenceEffects (void); 147cdf0e10cSrcweir 148cdf0e10cSrcweir /** Skip the specified number of main sequence effects. 149cdf0e10cSrcweir */ 150cdf0e10cSrcweir void skipSomeMainSequenceEffects (const sal_Int32 nSkipCount); 151cdf0e10cSrcweir 152cdf0e10cSrcweir /** Rewind the last effect of the main effect sequence by replaying all 153cdf0e10cSrcweir previous effects. 154cdf0e10cSrcweir @param nEffectCount 155cdf0e10cSrcweir The number of main sequence effects to replay. 156cdf0e10cSrcweir @param bRedisplayCurrentSlide 157cdf0e10cSrcweir When <TRUE/> then the current slide is redisplayed before the 158cdf0e10cSrcweir effects are replayed. 159cdf0e10cSrcweir @param rSlideRewindFunctor 160cdf0e10cSrcweir This functor is used to redisplay the current slide. 161cdf0e10cSrcweir */ 162cdf0e10cSrcweir void asynchronousRewind ( 163cdf0e10cSrcweir sal_Int32 nEffectCount, 164cdf0e10cSrcweir const bool bRedisplayCurrentSlide, 165cdf0e10cSrcweir const boost::function<void(void)>& rSlideRewindFunctor); 166cdf0e10cSrcweir 167cdf0e10cSrcweir /** Go to the previous slide and replay all of its main sequence effects 168cdf0e10cSrcweir (or effect groups). 169cdf0e10cSrcweir @param rPreviousSlideFunctor 170cdf0e10cSrcweir This functor is used to go to the previous slide. 171cdf0e10cSrcweir */ 172cdf0e10cSrcweir void asynchronousRewindToPreviousSlide ( 173cdf0e10cSrcweir const ::boost::function<void(void)>& rPreviousSlideFunctor); 174cdf0e10cSrcweir }; 175cdf0e10cSrcweir 176cdf0e10cSrcweir } } // end of namespace ::slideshow::internal 177cdf0e10cSrcweir 178cdf0e10cSrcweir #endif 179