1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SLIDESHOW_ACTIVITIESFACTORY_HXX
21 #define INCLUDED_SLIDESHOW_ACTIVITIESFACTORY_HXX
23 #include <com/sun/star/animations/XAnimate.hpp>
24 #include <com/sun/star/animations/XAnimateColor.hpp>
26 #include "animationactivity.hxx"
27 #include "activitiesqueue.hxx"
29 #include "eventqueue.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"
39 #include <boost/optional.hpp>
40 #include <boost/utility.hpp>
42 /* Definition of ActivitiesFactory class */
47 class ActivitiesFactory
: private ::boost::noncopyable
50 /// Collection of common factory parameters
51 struct CommonParameters
54 const EventSharedPtr
& rEndEvent
,
55 EventQueue
& rEventQueue
,
56 ActivitiesQueue
& rActivitiesQueue
,
58 sal_uInt32 nMinNumberOfFrames
,
60 ::boost::optional
<double> const& aRepeats
,
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
),
74 maSlideBounds( rSlideBounds
),
75 mbAutoReverse( bAutoReverse
) {}
77 /// End event to fire when animation is over
78 EventSharedPtr mpEndEvent
;
80 /// Event queue to insert the end event into.
81 EventQueue
& mrEventQueue
;
82 /// Event queue to insert the end event into.
83 ActivitiesQueue
& mrActivitiesQueue
;
85 /** Simple duration of the activity
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
97 /** Minimal number of frames for this activity.
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.
105 sal_uInt32 mnMinNumberOfFrames
;
107 /** Number of repeats for the simple duration
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
115 ::boost::optional
<double> const maRepeats
;
117 /// Fraction of simple time to accelerate animation
118 double mnAcceleration
;
120 /// Fraction of simple time to decelerate animation
121 double mnDeceleration
;
123 /// Shape, to get bounds from
124 ShapeSharedPtr mpShape
;
126 /// LayerManager, to get page size from
127 ::basegfx::B2DVector maSlideBounds
;
129 /// When true, activity is played reversed after mnDuration.
133 /** Create an activity from an XAnimate node.
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.
142 Factory parameter structure
148 The SMIL animation node to animate
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
);
156 /** Create an activity from an XAnimate node.
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.
165 Factory parameter structure
171 The SMIL animation node to animate
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
);
179 /** Create an activity from an XAnimate node.
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.
188 Factory parameter structure
194 The SMIL animation node to animate
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
);
202 /** Create an activity from an XAnimate node.
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.
211 Factory parameter structure
217 The SMIL animation node to animate
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
);
225 /** Create an activity from an XAnimate node.
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.
234 Factory parameter structure
240 The SMIL animation node to animate
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
);
248 /** Create an activity from an XAnimate node.
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.
257 Factory parameter structure
263 The SMIL animation node to animate
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
);
271 /** Create an activity from an XAnimate node.
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.
280 Factory parameter structure
286 The SMIL animation node to animate
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
);
294 /** Create a simple activity for the given animator
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.
302 Factory parameter structure
307 @param bDirectionForward
308 If true, the activity goes 'forward', i.e. from 0 to
309 1. With false, the direction is reversed.
311 static AnimationActivitySharedPtr
createSimpleActivity(
312 const CommonParameters
& rParms
,
313 const NumberAnimationSharedPtr
& rAnimator
,
314 bool bDirectionForward
);
317 // default: constructor/destructor disabed
319 ~ActivitiesFactory();
322 } // namespace internal
323 } // namespace presentation
325 #endif /* INCLUDED_SLIDESHOW_ACTIVITIESFACTORY_HXX */
327 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */