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