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_ACTIVITIESFACTORY_HXX
29*cdf0e10cSrcweir #define INCLUDED_SLIDESHOW_ACTIVITIESFACTORY_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimate.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/animations/XAnimateColor.hpp>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include "animationactivity.hxx"
35*cdf0e10cSrcweir #include "activitiesqueue.hxx"
36*cdf0e10cSrcweir #include "event.hxx"
37*cdf0e10cSrcweir #include "eventqueue.hxx"
38*cdf0e10cSrcweir #include "shape.hxx"
39*cdf0e10cSrcweir #include "numberanimation.hxx"
40*cdf0e10cSrcweir #include "enumanimation.hxx"
41*cdf0e10cSrcweir #include "coloranimation.hxx"
42*cdf0e10cSrcweir #include "hslcoloranimation.hxx"
43*cdf0e10cSrcweir #include "stringanimation.hxx"
44*cdf0e10cSrcweir #include "boolanimation.hxx"
45*cdf0e10cSrcweir #include "pairanimation.hxx"
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include <boost/optional.hpp>
48*cdf0e10cSrcweir #include <boost/utility.hpp>
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir /* Definition of ActivitiesFactory class */
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace slideshow {
53*cdf0e10cSrcweir namespace internal {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir class ActivitiesFactory : private ::boost::noncopyable
56*cdf0e10cSrcweir {
57*cdf0e10cSrcweir public:
58*cdf0e10cSrcweir     /// Collection of common factory parameters
59*cdf0e10cSrcweir     struct CommonParameters
60*cdf0e10cSrcweir     {
61*cdf0e10cSrcweir         CommonParameters(
62*cdf0e10cSrcweir             const EventSharedPtr&                 rEndEvent,
63*cdf0e10cSrcweir             EventQueue&                           rEventQueue,
64*cdf0e10cSrcweir             ActivitiesQueue&                      rActivitiesQueue,
65*cdf0e10cSrcweir             double                                nMinDuration,
66*cdf0e10cSrcweir             sal_uInt32                            nMinNumberOfFrames,
67*cdf0e10cSrcweir             bool                                  bAutoReverse,
68*cdf0e10cSrcweir             ::boost::optional<double> const&      aRepeats,
69*cdf0e10cSrcweir             double                                nAcceleration,
70*cdf0e10cSrcweir             double                                nDeceleration,
71*cdf0e10cSrcweir             const ShapeSharedPtr&                 rShape,
72*cdf0e10cSrcweir             const ::basegfx::B2DVector&           rSlideBounds )
73*cdf0e10cSrcweir             : mpEndEvent( rEndEvent ),
74*cdf0e10cSrcweir               mrEventQueue( rEventQueue ),
75*cdf0e10cSrcweir               mrActivitiesQueue( rActivitiesQueue ),
76*cdf0e10cSrcweir               mnMinDuration( nMinDuration ),
77*cdf0e10cSrcweir               mnMinNumberOfFrames( nMinNumberOfFrames ),
78*cdf0e10cSrcweir               maRepeats( aRepeats ),
79*cdf0e10cSrcweir               mnAcceleration( nAcceleration ),
80*cdf0e10cSrcweir               mnDeceleration( nDeceleration ),
81*cdf0e10cSrcweir               mpShape( rShape ),
82*cdf0e10cSrcweir               maSlideBounds( rSlideBounds ),
83*cdf0e10cSrcweir               mbAutoReverse( bAutoReverse ) {}
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir         /// End event to fire when animation is over
86*cdf0e10cSrcweir         EventSharedPtr                                  mpEndEvent;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir         /// Event queue to insert the end event into.
89*cdf0e10cSrcweir         EventQueue&                                     mrEventQueue;
90*cdf0e10cSrcweir         /// Event queue to insert the end event into.
91*cdf0e10cSrcweir         ActivitiesQueue&                                mrActivitiesQueue;
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir         /** Simple duration of the activity
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir             Specifies the minimal simple duration of the
96*cdf0e10cSrcweir             activity (minimal, because mnMinNumberOfFrames
97*cdf0e10cSrcweir             might prolongue the activity). According to SMIL,
98*cdf0e10cSrcweir             this might also be indefinite, which for our
99*cdf0e10cSrcweir             framework does not make much sense, though
100*cdf0e10cSrcweir             (wouldn't have a clue, then, how to scale the
101*cdf0e10cSrcweir             animation over time).
102*cdf0e10cSrcweir         */
103*cdf0e10cSrcweir         double                                          mnMinDuration;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir         /** Minimal number of frames for this activity.
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir             This specifies the minimal number of frames this
108*cdf0e10cSrcweir             activity will display per simple duration. If less
109*cdf0e10cSrcweir             than this number are displayed until mnMinDuration
110*cdf0e10cSrcweir             is over, the activity will be prolongued until
111*cdf0e10cSrcweir             mnMinNumberOfFrames are rendered.
112*cdf0e10cSrcweir         */
113*cdf0e10cSrcweir         sal_uInt32                                      mnMinNumberOfFrames;
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir         /** Number of repeats for the simple duration
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir             This specified the number of repeats. The
118*cdf0e10cSrcweir             mnMinDuration times maRepeats yields the total
119*cdf0e10cSrcweir             duration of this activity. If this value is
120*cdf0e10cSrcweir             unspecified, the activity will repeat
121*cdf0e10cSrcweir             indefinitely.
122*cdf0e10cSrcweir         */
123*cdf0e10cSrcweir         ::boost::optional<double> const                 maRepeats;
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir         /// Fraction of simple time to accelerate animation
126*cdf0e10cSrcweir         double                                          mnAcceleration;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         /// Fraction of simple time to decelerate animation
129*cdf0e10cSrcweir         double                                          mnDeceleration;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir         /// Shape, to get bounds from
132*cdf0e10cSrcweir         ShapeSharedPtr                                  mpShape;
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         /// LayerManager, to get page size from
135*cdf0e10cSrcweir         ::basegfx::B2DVector                            maSlideBounds;
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir         /// When true, activity is played reversed after mnDuration.
138*cdf0e10cSrcweir         bool                                            mbAutoReverse;
139*cdf0e10cSrcweir     };
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     /** Create an activity from an XAnimate node.
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir         This method creates an animated activity from the
144*cdf0e10cSrcweir         given XAnimate node, extracting all necessary
145*cdf0e10cSrcweir         animation parameters from that. Note that due to the
146*cdf0e10cSrcweir         animator parameter, the animation values must be
147*cdf0e10cSrcweir         convertible to a double value.
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir         @param rParms
150*cdf0e10cSrcweir         Factory parameter structure
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir         @param rAnimator
153*cdf0e10cSrcweir         Animator sub-object
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir         @param xNode
156*cdf0e10cSrcweir         The SMIL animation node to animate
157*cdf0e10cSrcweir     */
158*cdf0e10cSrcweir     static AnimationActivitySharedPtr createAnimateActivity(
159*cdf0e10cSrcweir         const CommonParameters&                        rParms,
160*cdf0e10cSrcweir         const NumberAnimationSharedPtr&                rAnimator,
161*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
162*cdf0e10cSrcweir         ::com::sun::star::animations::XAnimate >&   xNode );
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir     /** Create an activity from an XAnimate node.
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir         This method creates an animated activity from the
167*cdf0e10cSrcweir         given XAnimate node, extracting all necessary
168*cdf0e10cSrcweir         animation parameters from that. Note that due to the
169*cdf0e10cSrcweir         animator parameter, the animation values must be
170*cdf0e10cSrcweir         convertible to a double value.
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir         @param rParms
173*cdf0e10cSrcweir         Factory parameter structure
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir         @param rAnimator
176*cdf0e10cSrcweir         Animator sub-object
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir         @param xNode
179*cdf0e10cSrcweir         The SMIL animation node to animate
180*cdf0e10cSrcweir     */
181*cdf0e10cSrcweir     static AnimationActivitySharedPtr createAnimateActivity(
182*cdf0e10cSrcweir         const CommonParameters&                        rParms,
183*cdf0e10cSrcweir         const EnumAnimationSharedPtr&                  rAnimator,
184*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
185*cdf0e10cSrcweir         ::com::sun::star::animations::XAnimate >&      xNode );
186*cdf0e10cSrcweir 
187*cdf0e10cSrcweir     /** Create an activity from an XAnimate node.
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir         This method creates an animated activity from the
190*cdf0e10cSrcweir         given XAnimate node, extracting all necessary
191*cdf0e10cSrcweir         animation parameters from that. Note that due to the
192*cdf0e10cSrcweir         animator parameter, the animation values must be
193*cdf0e10cSrcweir         convertible to a color value.
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir         @param rParms
196*cdf0e10cSrcweir         Factory parameter structure
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir         @param rAnimator
199*cdf0e10cSrcweir         Animator sub-object
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir         @param xNode
202*cdf0e10cSrcweir         The SMIL animation node to animate
203*cdf0e10cSrcweir     */
204*cdf0e10cSrcweir     static AnimationActivitySharedPtr createAnimateActivity(
205*cdf0e10cSrcweir         const CommonParameters&                        rParms,
206*cdf0e10cSrcweir         const ColorAnimationSharedPtr&                 rAnimator,
207*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
208*cdf0e10cSrcweir         ::com::sun::star::animations::XAnimate >&      xNode );
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir     /** Create an activity from an XAnimate node.
211*cdf0e10cSrcweir 
212*cdf0e10cSrcweir         This method creates an animated activity from the
213*cdf0e10cSrcweir         given XAnimate node, extracting all necessary
214*cdf0e10cSrcweir         animation parameters from that. Note that due to the
215*cdf0e10cSrcweir         animator parameter, the animation values must be
216*cdf0e10cSrcweir         convertible to a color value.
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir         @param rParms
219*cdf0e10cSrcweir         Factory parameter structure
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir         @param rAnimator
222*cdf0e10cSrcweir         Animator sub-object
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir         @param xNode
225*cdf0e10cSrcweir         The SMIL animation node to animate
226*cdf0e10cSrcweir     */
227*cdf0e10cSrcweir     static AnimationActivitySharedPtr createAnimateActivity(
228*cdf0e10cSrcweir         const CommonParameters&                            rParms,
229*cdf0e10cSrcweir         const HSLColorAnimationSharedPtr&                  rAnimator,
230*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
231*cdf0e10cSrcweir         ::com::sun::star::animations::XAnimateColor >&     xNode );
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir     /** Create an activity from an XAnimate node.
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir         This method creates an animated activity from the
236*cdf0e10cSrcweir         given XAnimate node, extracting all necessary
237*cdf0e10cSrcweir         animation parameters from that. Note that due to the
238*cdf0e10cSrcweir         animator parameter, the animation values must be
239*cdf0e10cSrcweir         convertible to a pair of double values.
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir         @param rParms
242*cdf0e10cSrcweir         Factory parameter structure
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir         @param rAnimator
245*cdf0e10cSrcweir         Animator sub-object
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir         @param xNode
248*cdf0e10cSrcweir         The SMIL animation node to animate
249*cdf0e10cSrcweir     */
250*cdf0e10cSrcweir     static AnimationActivitySharedPtr createAnimateActivity(
251*cdf0e10cSrcweir         const CommonParameters&                        rParms,
252*cdf0e10cSrcweir         const PairAnimationSharedPtr&                  rAnimator,
253*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
254*cdf0e10cSrcweir         ::com::sun::star::animations::XAnimate >&   xNode );
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     /** Create an activity from an XAnimate node.
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir         This method creates an animated activity from the
259*cdf0e10cSrcweir         given XAnimate node, extracting all necessary
260*cdf0e10cSrcweir         animation parameters from that. Note that due to the
261*cdf0e10cSrcweir         animator parameter, the animation values must be
262*cdf0e10cSrcweir         convertible to a string.
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir         @param rParms
265*cdf0e10cSrcweir         Factory parameter structure
266*cdf0e10cSrcweir 
267*cdf0e10cSrcweir         @param rAnimator
268*cdf0e10cSrcweir         Animator sub-object
269*cdf0e10cSrcweir 
270*cdf0e10cSrcweir         @param xNode
271*cdf0e10cSrcweir         The SMIL animation node to animate
272*cdf0e10cSrcweir     */
273*cdf0e10cSrcweir     static AnimationActivitySharedPtr createAnimateActivity(
274*cdf0e10cSrcweir         const CommonParameters&                        rParms,
275*cdf0e10cSrcweir         const StringAnimationSharedPtr&                rAnimator,
276*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
277*cdf0e10cSrcweir         ::com::sun::star::animations::XAnimate >&      xNode );
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir     /** Create an activity from an XAnimate node.
280*cdf0e10cSrcweir 
281*cdf0e10cSrcweir         This method creates an animated activity from the
282*cdf0e10cSrcweir         given XAnimate node, extracting all necessary
283*cdf0e10cSrcweir         animation parameters from that. Note that due to the
284*cdf0e10cSrcweir         animator parameter, the animation values must be
285*cdf0e10cSrcweir         convertible to a bool value.
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir         @param rParms
288*cdf0e10cSrcweir         Factory parameter structure
289*cdf0e10cSrcweir 
290*cdf0e10cSrcweir         @param rAnimator
291*cdf0e10cSrcweir         Animator sub-object
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir         @param xNode
294*cdf0e10cSrcweir         The SMIL animation node to animate
295*cdf0e10cSrcweir     */
296*cdf0e10cSrcweir     static AnimationActivitySharedPtr createAnimateActivity(
297*cdf0e10cSrcweir         const CommonParameters&                        rParms,
298*cdf0e10cSrcweir         const BoolAnimationSharedPtr&                  rAnimator,
299*cdf0e10cSrcweir         const ::com::sun::star::uno::Reference<
300*cdf0e10cSrcweir         ::com::sun::star::animations::XAnimate >&      xNode );
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir     /** Create a simple activity for the given animator
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir         This method is suited to create activities for custom
305*cdf0e10cSrcweir         animations, which need a simple double value and lasts
306*cdf0e10cSrcweir         a given timespan. This activity always generates values
307*cdf0e10cSrcweir         from the [0,1] range.
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir         @param rParms
310*cdf0e10cSrcweir         Factory parameter structure
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir         @param rAnimator
313*cdf0e10cSrcweir         Animator sub-object
314*cdf0e10cSrcweir 
315*cdf0e10cSrcweir         @param bDirectionForward
316*cdf0e10cSrcweir         If true, the activity goes 'forward', i.e. from 0 to
317*cdf0e10cSrcweir         1. With false, the direction is reversed.
318*cdf0e10cSrcweir     */
319*cdf0e10cSrcweir     static AnimationActivitySharedPtr createSimpleActivity(
320*cdf0e10cSrcweir         const CommonParameters&         rParms,
321*cdf0e10cSrcweir         const NumberAnimationSharedPtr& rAnimator,
322*cdf0e10cSrcweir         bool                            bDirectionForward );
323*cdf0e10cSrcweir 
324*cdf0e10cSrcweir private:
325*cdf0e10cSrcweir     // default: constructor/destructor disabed
326*cdf0e10cSrcweir     ActivitiesFactory();
327*cdf0e10cSrcweir     ~ActivitiesFactory();
328*cdf0e10cSrcweir };
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir } // namespace internal
331*cdf0e10cSrcweir } // namespace presentation
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir #endif /* INCLUDED_SLIDESHOW_ACTIVITIESFACTORY_HXX */
334*cdf0e10cSrcweir 
335