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_SOURCE_INC_ACTIVITIESFACTORY_HXX
21 #define INCLUDED_SLIDESHOW_SOURCE_INC_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"
42 /* Definition of ActivitiesFactory class */
44 namespace slideshow::internal::ActivitiesFactory
46 /// Collection of common factory parameters
47 struct CommonParameters
50 EventSharedPtr xEndEvent
,
51 EventQueue
& rEventQueue
,
52 ActivitiesQueue
& rActivitiesQueue
,
54 sal_uInt32 nMinNumberOfFrames
,
56 ::std::optional
<double> const& aRepeats
,
59 ShapeSharedPtr xShape
,
60 const ::basegfx::B2DVector
& rSlideBounds
)
61 : mpEndEvent(std::move( xEndEvent
)),
62 mrEventQueue( rEventQueue
),
63 mrActivitiesQueue( rActivitiesQueue
),
64 mnMinDuration( nMinDuration
),
65 mnMinNumberOfFrames( nMinNumberOfFrames
),
66 maRepeats( aRepeats
),
67 mnAcceleration( nAcceleration
),
68 mnDeceleration( nDeceleration
),
69 mpShape(std::move( xShape
)),
70 maSlideBounds( rSlideBounds
),
71 mbAutoReverse( bAutoReverse
) {}
73 /// End event to fire when animation is over
74 EventSharedPtr mpEndEvent
;
76 /// Event queue to insert the end event into.
77 EventQueue
& mrEventQueue
;
78 /// Event queue to insert the end event into.
79 ActivitiesQueue
& mrActivitiesQueue
;
81 /** Simple duration of the activity
83 Specifies the minimal simple duration of the
84 activity (minimal, because mnMinNumberOfFrames
85 might prolong the activity). According to SMIL,
86 this might also be indefinite, which for our
87 framework does not make much sense, though
88 (wouldn't have a clue, then, how to scale the
93 /** Minimal number of frames for this activity.
95 This specifies the minimal number of frames this
96 activity will display per simple duration. If less
97 than this number are displayed until mnMinDuration
98 is over, the activity will be prolonged until
99 mnMinNumberOfFrames are rendered.
101 sal_uInt32 mnMinNumberOfFrames
;
103 /** Number of repeats for the simple duration
105 This specified the number of repeats. The
106 mnMinDuration times maRepeats yields the total
107 duration of this activity. If this value is
108 unspecified, the activity will repeat
111 ::std::optional
<double> const maRepeats
;
113 /// Fraction of simple time to accelerate animation
114 double mnAcceleration
;
116 /// Fraction of simple time to decelerate animation
117 double mnDeceleration
;
119 /// Shape, to get bounds from
120 ShapeSharedPtr mpShape
;
122 /// LayerManager, to get page size from
123 ::basegfx::B2DVector maSlideBounds
;
125 /// When true, activity is played reversed after mnDuration.
129 /** Create an activity from an XAnimate node.
131 This method creates an animated activity from the
132 given XAnimate node, extracting all necessary
133 animation parameters from that. Note that due to the
134 animator parameter, the animation values must be
135 convertible to a double value.
138 Factory parameter structure
144 The SMIL animation node to animate
146 AnimationActivitySharedPtr
createAnimateActivity(
147 const CommonParameters
& rParms
,
148 const NumberAnimationSharedPtr
& rAnimator
,
149 const css::uno::Reference
< css::animations::XAnimate
>& xNode
);
151 /** Create an activity from an XAnimate node.
153 This method creates an animated activity from the
154 given XAnimate node, extracting all necessary
155 animation parameters from that. Note that due to the
156 animator parameter, the animation values must be
157 convertible to a double value.
160 Factory parameter structure
166 The SMIL animation node to animate
168 AnimationActivitySharedPtr
createAnimateActivity(
169 const CommonParameters
& rParms
,
170 const EnumAnimationSharedPtr
& rAnimator
,
171 const css::uno::Reference
< css::animations::XAnimate
>& xNode
);
173 /** Create an activity from an XAnimate node.
175 This method creates an animated activity from the
176 given XAnimate node, extracting all necessary
177 animation parameters from that. Note that due to the
178 animator parameter, the animation values must be
179 convertible to a color value.
182 Factory parameter structure
188 The SMIL animation node to animate
190 AnimationActivitySharedPtr
createAnimateActivity(
191 const CommonParameters
& rParms
,
192 const ColorAnimationSharedPtr
& rAnimator
,
193 const css::uno::Reference
< css::animations::XAnimate
>& xNode
);
195 /** Create an activity from an XAnimate node.
197 This method creates an animated activity from the
198 given XAnimate node, extracting all necessary
199 animation parameters from that. Note that due to the
200 animator parameter, the animation values must be
201 convertible to a color value.
204 Factory parameter structure
210 The SMIL animation node to animate
212 AnimationActivitySharedPtr
createAnimateActivity(
213 const CommonParameters
& rParms
,
214 const HSLColorAnimationSharedPtr
& rAnimator
,
215 const css::uno::Reference
< css::animations::XAnimateColor
>& xNode
);
217 /** Create an activity from an XAnimate node.
219 This method creates an animated activity from the
220 given XAnimate node, extracting all necessary
221 animation parameters from that. Note that due to the
222 animator parameter, the animation values must be
223 convertible to a pair of double values.
226 Factory parameter structure
232 The SMIL animation node to animate
234 AnimationActivitySharedPtr
createAnimateActivity(
235 const CommonParameters
& rParms
,
236 const PairAnimationSharedPtr
& rAnimator
,
237 const css::uno::Reference
< css::animations::XAnimate
>& xNode
);
239 /** Create an activity from an XAnimate node.
241 This method creates an animated activity from the
242 given XAnimate node, extracting all necessary
243 animation parameters from that. Note that due to the
244 animator parameter, the animation values must be
245 convertible to a string.
248 Factory parameter structure
254 The SMIL animation node to animate
256 AnimationActivitySharedPtr
createAnimateActivity(
257 const CommonParameters
& rParms
,
258 const StringAnimationSharedPtr
& rAnimator
,
259 const css::uno::Reference
< css::animations::XAnimate
>& xNode
);
261 /** Create an activity from an XAnimate node.
263 This method creates an animated activity from the
264 given XAnimate node, extracting all necessary
265 animation parameters from that. Note that due to the
266 animator parameter, the animation values must be
267 convertible to a bool value.
270 Factory parameter structure
276 The SMIL animation node to animate
278 AnimationActivitySharedPtr
createAnimateActivity(
279 const CommonParameters
& rParms
,
280 const BoolAnimationSharedPtr
& rAnimator
,
281 const css::uno::Reference
< css::animations::XAnimate
>& xNode
);
283 /** Create a simple activity for the given animator
285 This method is suited to create activities for custom
286 animations, which need a simple double value and lasts
287 a given timespan. This activity always generates values
288 from the [0,1] range.
291 Factory parameter structure
296 @param bDirectionForward
297 If true, the activity goes 'forward', i.e. from 0 to
298 1. With false, the direction is reversed.
300 AnimationActivitySharedPtr
createSimpleActivity(
301 const CommonParameters
& rParms
,
302 const NumberAnimationSharedPtr
& rAnimator
,
303 bool bDirectionForward
);
305 } // namespace presentation::internal
307 #endif // INCLUDED_SLIDESHOW_SOURCE_INC_ACTIVITIESFACTORY_HXX
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */