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