1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX 29 #define INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX 30 31 #include "animationactivity.hxx" 32 #include "activityparameters.hxx" 33 #include "animatableshape.hxx" 34 #include "shapeattributelayer.hxx" 35 36 namespace slideshow { 37 namespace internal { 38 39 /** Base class for animation activities. 40 41 This whole class hierarchy is only for code sharing 42 between the various specializations (with or without 43 key times, fully discrete, etc.). 44 */ 45 class ActivityBase : public AnimationActivity 46 { 47 public: 48 ActivityBase( const ActivityParameters& rParms ); 49 50 /// From Disposable interface 51 virtual void dispose(); 52 53 protected: 54 /** From Activity interface 55 56 Derived classes should override, call this first 57 and then perform their work. 58 */ 59 virtual bool perform(); 60 virtual double calcTimeLag() const; 61 virtual bool isActive() const; 62 63 private: 64 virtual void dequeued(); 65 66 // From AnimationActivity interface 67 virtual void setTargets( 68 const AnimatableShapeSharedPtr& rShape, 69 const ShapeAttributeLayerSharedPtr& rAttrLayer ); 70 71 private: 72 /** Hook for derived classes 73 74 This method will be called from the first 75 perform() invocation, to signal the start of the 76 activity. 77 */ 78 virtual void startAnimation() = 0; 79 80 /** Hook for derived classes 81 82 This method will be called after the last perform() 83 invocation, and after the potential changes of that 84 perform() call are committed to screen. That is, in 85 endAnimation(), the animation objects (sprites, 86 animation) can safely be destroyed, without causing 87 visible artifacts on screen. 88 */ 89 virtual void endAnimation() = 0; 90 91 protected: 92 93 /** End this activity, in a regular way. 94 95 This method is for derived classes needing to signal a 96 regular activity end (i.e. because the regular 97 duration is over) 98 */ 99 void endActivity(); 100 101 /** Modify fractional time. 102 103 This method modifies the fractional time (total 104 duration mapped to the [0,1] range) to the 105 effective simple time, but only according to 106 acceleration/deceleration. 107 */ 108 double calcAcceleratedTime( double nT ) const; 109 110 bool isDisposed() const { 111 return (!mbIsActive && !mpEndEvent && !mpShape && 112 !mpAttributeLayer); 113 } 114 115 EventQueue& getEventQueue() const { return mrEventQueue; } 116 117 AnimatableShapeSharedPtr getShape() const { return mpShape; } 118 119 ShapeAttributeLayerSharedPtr getShapeAttributeLayer() const 120 { return mpAttributeLayer; } 121 122 bool isRepeatCountValid() const { return maRepeats; } 123 double getRepeatCount() const { return *maRepeats; } 124 bool isAutoReverse() const { return mbAutoReverse; } 125 126 private: 127 /// Activity: 128 virtual void end(); 129 virtual void performEnd() = 0; 130 131 private: 132 EventSharedPtr mpEndEvent; 133 EventQueue& mrEventQueue; 134 AnimatableShapeSharedPtr mpShape; // only to pass on to animation 135 ShapeAttributeLayerSharedPtr mpAttributeLayer; // only to pass on to anim 136 137 ::boost::optional<double> const maRepeats; 138 const double mnAccelerationFraction; 139 const double mnDecelerationFraction; 140 141 const bool mbAutoReverse; 142 143 // true, if perform() has not yet been called: 144 mutable bool mbFirstPerformCall; 145 bool mbIsActive; 146 }; 147 148 } // namespace internal 149 } // namespace presentation 150 151 #endif /* INCLUDED_SLIDESHOW_ACTIVITYBASE_HXX */ 152 153