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