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