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