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 .
22 #include <canvas/debug.hxx>
23 #include <tools/diagnose_ex.h>
24 #include <canvas/verbosetrace.hxx>
26 #include <com/sun/star/animations/AnimationCalcMode.hpp>
27 #include <comphelper/sequence.hxx>
29 #include "activitiesfactory.hxx"
30 #include "smilfunctionparser.hxx"
31 #include "accumulation.hxx"
32 #include "activityparameters.hxx"
33 #include "interpolation.hxx"
35 #include "simplecontinuousactivitybase.hxx"
36 #include "discreteactivitybase.hxx"
37 #include "continuousactivitybase.hxx"
38 #include "continuouskeytimeactivitybase.hxx"
40 #include <boost/optional.hpp>
41 #include <boost/shared_ptr.hpp>
47 using namespace com::sun::star
;
54 /** Traits template, to take formula application only for ValueType = double
56 template<typename ValueType
> struct FormulaTraits
58 static ValueType
getPresentationValue(
59 const ValueType
& rVal
, const ExpressionNodeSharedPtr
& )
65 /// Specialization for ValueType = double
66 template<> struct FormulaTraits
<double>
68 static double getPresentationValue(
69 double const& rVal
, ExpressionNodeSharedPtr
const& rFormula
)
71 return rFormula
? (*rFormula
)(rVal
) : rVal
;
75 // Various ActivityBase specializations for different animator types
76 // =================================================================
80 Provides the Activity specializations for FromToBy
81 animations (e.g. those without a values list).
83 This template makes heavy use of SFINAE, only one of
84 the perform*() methods will compile for each of the
87 Note that we omit the virtual keyword on the perform()
88 overrides on purpose; those that actually do override
89 baseclass virtual methods inherit the property, and
90 the others won't increase our vtable. What's more,
91 having all perform() method in the vtable actually
92 creates POIs for them, which breaks the whole SFINAE
93 concept (IOW, this template won't compile any longer).
96 Base class to use for this activity. Only
97 ContinuousActivityBase and DiscreteActivityBase are
101 Type of the Animation to call.
103 template<class BaseType
, typename AnimationType
>
104 class FromToByActivity
: public BaseType
107 typedef typename
AnimationType::ValueType ValueType
;
108 typedef boost::optional
<ValueType
> OptionalValueType
;
111 // some compilers don't inline whose definition they haven't
112 // seen before the call site...
113 ValueType
getPresentationValue( const ValueType
& rVal
) const
115 return FormulaTraits
<ValueType
>::getPresentationValue( rVal
, mpFormula
);
119 /** Create FromToByActivity.
122 From this value, the animation starts
125 With this value, the animation ends
128 With this value, the animation increments the start value
131 Standard Activity parameter struct
134 Shared ptr to AnimationType
137 Interpolator object to be used for lerping between
138 start and end value (need to be passed, since it
139 might contain state, e.g. interpolation direction
140 for HSL color space).
143 Whether repeated animations should cumulate the
144 value, or start fresh each time.
147 const OptionalValueType
& rFrom
,
148 const OptionalValueType
& rTo
,
149 const OptionalValueType
& rBy
,
150 const ActivityParameters
& rParms
,
151 const ::boost::shared_ptr
< AnimationType
>& rAnim
,
152 const Interpolator
< ValueType
>& rInterpolator
,
154 : BaseType( rParms
),
158 mpFormula( rParms
.mpFormula
),
162 maStartInterpolationValue(),
165 maInterpolator( rInterpolator
),
166 mbDynamicStartValue( false ),
167 mbCumulative( bCumulative
)
169 ENSURE_OR_THROW( mpAnim
, "Invalid animation object" );
173 "From and one of To or By, or To or By alone must be valid" );
176 virtual void startAnimation()
178 if (this->isDisposed() || !mpAnim
)
180 BaseType::startAnimation();
183 mpAnim
->start( BaseType::getShape(),
184 BaseType::getShapeAttributeLayer() );
186 // setup start and end value. Determine animation
187 // start value only when animation actually
188 // started up (this order is part of the Animation
189 // interface contract)
190 const ValueType
aAnimationStartValue( mpAnim
->getUnderlyingValue() );
192 // first of all, determine general type of
193 // animation, by inspecting which of the FromToBy values
194 // are actually valid.
195 // See http://www.w3.org/TR/smil20/animation.html#AnimationNS-FromToBy
199 // From-to or From-by animation. According to
200 // SMIL spec, the To value takes precedence
201 // over the By value, if both are specified
205 maStartValue
= *maFrom
;
211 maStartValue
= *maFrom
;
212 maEndValue
= maStartValue
+ *maBy
;
217 maStartValue
= aAnimationStartValue
;
218 maStartInterpolationValue
= maStartValue
;
220 // By or To animation. According to SMIL spec,
221 // the To value takes precedence over the By
222 // value, if both are specified
227 // According to the SMIL spec
228 // (http://www.w3.org/TR/smil20/animation.html#animationNS-ToAnimation),
229 // the to animation interpolates between
230 // the _running_ underlying value and the to value (as the end value)
231 mbDynamicStartValue
= true;
232 maPreviousValue
= maStartValue
;
238 maStartValue
= aAnimationStartValue
;
239 maEndValue
= maStartValue
+ *maBy
;
244 virtual void endAnimation()
251 /// perform override for ContinuousActivityBase
252 void perform( double nModifiedTime
, sal_uInt32 nRepeatCount
) const
254 if (this->isDisposed() || !mpAnim
)
257 // According to SMIL 3.0 spec 'to' animation if no other (lower priority)
258 // animations are active or frozen then a simple interpolation is performed.
259 // That is, the start interpolation value is constant while the animation
260 // is running, and is equal to the underlying value retrieved when
261 // the animation start.
262 // However if another animation is manipulating the underlying value,
263 // the 'to' animation will initially add to the effect of the lower priority
264 // animation, and increasingly dominate it as it nears the end of the
265 // simple duration, eventually overriding it completely.
266 // That is, each time the underlying value is changed between two
267 // computations of the animation function the new underlying value is used
268 // as start value for the interpolation.
270 // http://www.w3.org/TR/SMIL3/smil-animation.html#animationNS-ToAnimation
271 // (Figure 6 - Effect of Additive to animation example)
272 // Moreover when a 'to' animation is repeated, at each new iteration
273 // the start interpolation value is reset to the underlying value
274 // of the animated property when the animation started,
275 // as it is shown in the example provided by the SMIL 3.0 spec.
276 // This is exactly as Firefox performs SVG 'to' animations.
277 if( mbDynamicStartValue
)
279 if( mnIteration
!= nRepeatCount
)
281 mnIteration
= nRepeatCount
;
282 maStartInterpolationValue
= maStartValue
;
286 ValueType aActualValue
= mpAnim
->getUnderlyingValue();
287 if( aActualValue
!= maPreviousValue
)
288 maStartInterpolationValue
= aActualValue
;
292 ValueType aValue
= maInterpolator( maStartInterpolationValue
,
293 maEndValue
, nModifiedTime
);
295 // According to the SMIL spec:
296 // Because 'to' animation is defined in terms of absolute values of
297 // the target attribute, cumulative animation is not defined.
298 if( mbCumulative
&& !mbDynamicStartValue
)
300 // aValue = this.aEndValue * nRepeatCount + aValue;
301 aValue
= accumulate( maEndValue
, nRepeatCount
, aValue
);
304 (*mpAnim
)( getPresentationValue( aValue
) );
306 if( mbDynamicStartValue
)
308 maPreviousValue
= mpAnim
->getUnderlyingValue();
313 using BaseType::perform
;
315 /// perform override for DiscreteActivityBase base
316 void perform( sal_uInt32 nFrame
, sal_uInt32 nRepeatCount
) const
318 if (this->isDisposed() || !mpAnim
)
321 getPresentationValue(
322 accumulate( maEndValue
, mbCumulative
? nRepeatCount
: 0,
323 lerp( maInterpolator
,
325 ? mpAnim
->getUnderlyingValue()
329 BaseType::getNumberOfKeyTimes() ) ) ) );
332 using BaseType::isAutoReverse
;
334 virtual void performEnd()
336 // xxx todo: good guess
340 (*mpAnim
)( getPresentationValue( maStartValue
) );
342 (*mpAnim
)( getPresentationValue( maEndValue
) );
347 virtual void dispose()
354 const OptionalValueType maFrom
;
355 const OptionalValueType maTo
;
356 const OptionalValueType maBy
;
358 ExpressionNodeSharedPtr mpFormula
;
360 ValueType maStartValue
;
361 ValueType maEndValue
;
363 mutable ValueType maPreviousValue
;
364 mutable ValueType maStartInterpolationValue
;
365 mutable sal_uInt32 mnIteration
;
367 ::boost::shared_ptr
< AnimationType
> mpAnim
;
368 Interpolator
< ValueType
> maInterpolator
;
369 bool mbDynamicStartValue
;
374 /** Generate Activity corresponding to given FromToBy values
377 BaseType to use for deriving the Activity from
380 Subtype of the Animation object (e.g. NumberAnimation)
382 template<class BaseType
, typename AnimationType
>
383 AnimationActivitySharedPtr
createFromToByActivity(
384 const uno::Any
& rFromAny
,
385 const uno::Any
& rToAny
,
386 const uno::Any
& rByAny
,
387 const ActivityParameters
& rParms
,
388 const ::boost::shared_ptr
< AnimationType
>& rAnim
,
389 const Interpolator
< typename
AnimationType::ValueType
>& rInterpolator
,
391 const ShapeSharedPtr
& rShape
,
392 const ::basegfx::B2DVector
& rSlideBounds
)
394 typedef typename
AnimationType::ValueType ValueType
;
395 typedef boost::optional
<ValueType
> OptionalValueType
;
397 OptionalValueType aFrom
;
398 OptionalValueType aTo
;
399 OptionalValueType aBy
;
403 if( rFromAny
.hasValue() )
406 extractValue( aTmpValue
, rFromAny
, rShape
, rSlideBounds
),
407 "createFromToByActivity(): Could not extract from value" );
408 aFrom
.reset(aTmpValue
);
410 if( rToAny
.hasValue() )
413 extractValue( aTmpValue
, rToAny
, rShape
, rSlideBounds
),
414 "createFromToByActivity(): Could not extract to value" );
415 aTo
.reset(aTmpValue
);
417 if( rByAny
.hasValue() )
420 extractValue( aTmpValue
, rByAny
, rShape
, rSlideBounds
),
421 "createFromToByActivity(): Could not extract by value" );
422 aBy
.reset(aTmpValue
);
425 return AnimationActivitySharedPtr(
426 new FromToByActivity
<BaseType
, AnimationType
>(
436 /* The following table shows which animator combines with
442 StringAnimation: DiscreteActivityBase
443 BoolAnimation: DiscreteActivityBase
448 Provides the Activity specializations for value lists
451 This template makes heavy use of SFINAE, only one of
452 the perform*() methods will compile for each of the
455 Note that we omit the virtual keyword on the perform()
456 overrides on purpose; those that actually do override
457 baseclass virtual methods inherit the property, and
458 the others won't increase our vtable. What's more,
459 having all perform() method in the vtable actually
460 creates POIs for them, which breaks the whole SFINAE
461 concept (IOW, this template won't compile any longer).
464 Base class to use for this activity. Only
465 ContinuousKeyTimeActivityBase and DiscreteActivityBase
466 are supported here. For values animation without key
467 times, the client must emulate key times by providing
468 a vector of equally spaced values between 0 and 1,
469 with the same number of entries as the values vector.
472 Type of the Animation to call.
474 template<class BaseType
, typename AnimationType
>
475 class ValuesActivity
: public BaseType
478 typedef typename
AnimationType::ValueType ValueType
;
479 typedef std::vector
<ValueType
> ValueVectorType
;
482 // some compilers don't inline methods whose definition they haven't
483 // seen before the call site...
484 ValueType
getPresentationValue( const ValueType
& rVal
) const
486 return FormulaTraits
<ValueType
>::getPresentationValue(
491 /** Create ValuesActivity.
494 Value vector to cycle animation through
497 Standard Activity parameter struct
500 Shared ptr to AnimationType
503 Interpolator object to be used for lerping between
504 start and end value (need to be passed, since it
505 might contain state, e.g. interpolation direction
506 for HSL color space).
509 Whether repeated animations should cumulate the
510 value, or start afresh each time.
513 const ValueVectorType
& rValues
,
514 const ActivityParameters
& rParms
,
515 const boost::shared_ptr
<AnimationType
>& rAnim
,
516 const Interpolator
< ValueType
>& rInterpolator
,
518 : BaseType( rParms
),
520 mpFormula( rParms
.mpFormula
),
522 maInterpolator( rInterpolator
),
523 mbCumulative( bCumulative
)
525 ENSURE_OR_THROW( mpAnim
, "Invalid animation object" );
526 ENSURE_OR_THROW( !rValues
.empty(), "Empty value vector" );
529 virtual void startAnimation()
531 if (this->isDisposed() || !mpAnim
)
533 BaseType::startAnimation();
536 mpAnim
->start( BaseType::getShape(),
537 BaseType::getShapeAttributeLayer() );
540 virtual void endAnimation()
547 /// perform override for ContinuousKeyTimeActivityBase base
548 void perform( sal_uInt32 nIndex
,
549 double nFractionalIndex
,
550 sal_uInt32 nRepeatCount
) const
552 if (this->isDisposed() || !mpAnim
)
554 ENSURE_OR_THROW( nIndex
+1 < maValues
.size(),
555 "ValuesActivity::perform(): index out of range" );
557 // interpolate between nIndex and nIndex+1 values
559 getPresentationValue(
560 accumulate
<ValueType
>( maValues
.back(),
561 mbCumulative
? nRepeatCount
: 0,
562 maInterpolator( maValues
[ nIndex
],
563 maValues
[ nIndex
+1 ],
564 nFractionalIndex
) ) ) );
567 using BaseType::perform
;
569 /// perform override for DiscreteActivityBase base
570 void perform( sal_uInt32 nFrame
, sal_uInt32 nRepeatCount
) const
572 if (this->isDisposed() || !mpAnim
)
574 ENSURE_OR_THROW( nFrame
< maValues
.size(),
575 "ValuesActivity::perform(): index out of range" );
577 // this is discrete, thus no lerp here.
579 getPresentationValue(
580 accumulate
<ValueType
>( maValues
.back(),
581 mbCumulative
? nRepeatCount
: 0,
582 maValues
[ nFrame
] ) ) );
585 virtual void performEnd()
587 // xxx todo: good guess
589 (*mpAnim
)( getPresentationValue( maValues
.back() ) );
593 virtual void dispose()
600 ValueVectorType maValues
;
602 ExpressionNodeSharedPtr mpFormula
;
604 boost::shared_ptr
<AnimationType
> mpAnim
;
605 Interpolator
< ValueType
> maInterpolator
;
609 /** Generate Activity corresponding to given Value vector
612 BaseType to use for deriving the Activity from
615 Subtype of the Animation object (e.g. NumberAnimation)
617 template<class BaseType
, typename AnimationType
>
618 AnimationActivitySharedPtr
createValueListActivity(
619 const uno::Sequence
<uno::Any
>& rValues
,
620 const ActivityParameters
& rParms
,
621 const boost::shared_ptr
<AnimationType
>& rAnim
,
622 const Interpolator
<typename
AnimationType::ValueType
>& rInterpolator
,
624 const ShapeSharedPtr
& rShape
,
625 const ::basegfx::B2DVector
& rSlideBounds
)
627 typedef typename
AnimationType::ValueType ValueType
;
628 typedef std::vector
<ValueType
> ValueVectorType
;
630 ValueVectorType aValueVector
;
631 aValueVector
.reserve( rValues
.getLength() );
633 for( ::std::size_t i
=0, nLen
=rValues
.getLength(); i
<nLen
; ++i
)
637 extractValue( aValue
, rValues
[i
], rShape
, rSlideBounds
),
638 "createValueListActivity(): Could not extract values" );
639 aValueVector
.push_back( aValue
);
642 return AnimationActivitySharedPtr(
643 new ValuesActivity
<BaseType
, AnimationType
>(
651 /** Generate Activity for given XAnimate, corresponding to given Value vector
654 Subtype of the Animation object (e.g. NumberAnimation)
657 Common activity parameters
660 XAnimate node, to retrieve animation values from
663 Actual animation to operate with (gets called with the
664 time-dependent values)
667 Interpolator object to be used for lerping between
668 start and end values (need to be passed, since it
669 might contain state, e.g. interpolation direction
670 for HSL color space).
672 template<typename AnimationType
>
673 AnimationActivitySharedPtr
createActivity(
674 const ActivitiesFactory::CommonParameters
& rParms
,
675 const uno::Reference
< animations::XAnimate
>& xNode
,
676 const ::boost::shared_ptr
< AnimationType
>& rAnim
,
677 const Interpolator
< typename
AnimationType::ValueType
>& rInterpolator
678 = Interpolator
< typename
AnimationType::ValueType
>() )
680 // setup common parameters
681 // =======================
683 ActivityParameters
aActivityParms( rParms
.mpEndEvent
,
685 rParms
.mrActivitiesQueue
,
686 rParms
.mnMinDuration
,
688 rParms
.mnAcceleration
,
689 rParms
.mnDeceleration
,
690 rParms
.mnMinNumberOfFrames
,
691 rParms
.mbAutoReverse
);
693 // is a formula given?
694 const OUString
& rFormulaString( xNode
->getFormula() );
695 if( !rFormulaString
.isEmpty() )
697 // yep, parse and pass to ActivityParameters
700 aActivityParms
.mpFormula
=
701 SmilFunctionParser::parseSmilFunction(
703 calcRelativeShapeBounds(
704 rParms
.maSlideBounds
,
705 rParms
.mpShape
->getBounds() ) );
709 // parse error, thus no formula
710 OSL_FAIL( "createActivity(): Error parsing formula string" );
714 // are key times given?
715 const uno::Sequence
< double >& aKeyTimes( xNode
->getKeyTimes() );
716 if( aKeyTimes
.hasElements() )
718 // yes, convert them from Sequence< double >
719 aActivityParms
.maDiscreteTimes
.resize( aKeyTimes
.getLength() );
720 comphelper::sequenceToArray(
721 &aActivityParms
.maDiscreteTimes
[0],
722 aKeyTimes
); // saves us some temporary vectors
725 // values sequence given?
726 const sal_Int32
nValueLen( xNode
->getValues().getLength() );
729 // Value list activity
730 // ===================
732 // fake keytimes, if necessary
733 if( !aKeyTimes
.hasElements() )
735 // create a dummy vector of key times,
736 // with aValues.getLength equally spaced entries.
737 for( sal_Int32 i
=0; i
<nValueLen
; ++i
)
738 aActivityParms
.maDiscreteTimes
.push_back( double(i
)/nValueLen
);
741 // determine type of animation needed here:
742 // Value list activities are possible with
743 // ContinuousKeyTimeActivityBase and DiscreteActivityBase
745 const sal_Int16
nCalcMode( xNode
->getCalcMode() );
749 case animations::AnimationCalcMode::DISCRETE
:
751 // since DiscreteActivityBase suspends itself
752 // between the frames, create a WakeupEvent for it.
753 aActivityParms
.mpWakeupEvent
.reset(
755 rParms
.mrEventQueue
.getTimer(),
756 rParms
.mrActivitiesQueue
) );
758 AnimationActivitySharedPtr
pActivity(
759 createValueListActivity
< DiscreteActivityBase
>(
764 xNode
->getAccumulate(),
766 rParms
.maSlideBounds
) );
768 // WakeupEvent and DiscreteActivityBase need circular
769 // references to the corresponding other object.
770 aActivityParms
.mpWakeupEvent
->setActivity( pActivity
);
776 OSL_FAIL( "createActivity(): unexpected case" );
777 // FALLTHROUGH intended
778 case animations::AnimationCalcMode::PACED
:
779 // FALLTHROUGH intended
780 case animations::AnimationCalcMode::SPLINE
:
781 // FALLTHROUGH intended
782 case animations::AnimationCalcMode::LINEAR
:
783 return createValueListActivity
< ContinuousKeyTimeActivityBase
>(
788 xNode
->getAccumulate(),
790 rParms
.maSlideBounds
);
798 // determine type of animation needed here:
799 // FromToBy activities are possible with
800 // ContinuousActivityBase and DiscreteActivityBase
802 const sal_Int16
nCalcMode( xNode
->getCalcMode() );
806 case animations::AnimationCalcMode::DISCRETE
:
808 // fake keytimes, if necessary
809 if( !aKeyTimes
.hasElements() )
811 // create a dummy vector of 2 key times
812 const ::std::size_t nLen( 2 );
813 for( ::std::size_t i
=0; i
<nLen
; ++i
)
814 aActivityParms
.maDiscreteTimes
.push_back( double(i
)/nLen
);
817 // since DiscreteActivityBase suspends itself
818 // between the frames, create a WakeupEvent for it.
819 aActivityParms
.mpWakeupEvent
.reset(
821 rParms
.mrEventQueue
.getTimer(),
822 rParms
.mrActivitiesQueue
) );
824 AnimationActivitySharedPtr
pActivity(
825 createFromToByActivity
< DiscreteActivityBase
>(
832 xNode
->getAccumulate(),
834 rParms
.maSlideBounds
) );
836 // WakeupEvent and DiscreteActivityBase need circular
837 // references to the corresponding other object.
838 aActivityParms
.mpWakeupEvent
->setActivity( pActivity
);
844 OSL_FAIL( "createActivity(): unexpected case" );
845 // FALLTHROUGH intended
846 case animations::AnimationCalcMode::PACED
:
847 // FALLTHROUGH intended
848 case animations::AnimationCalcMode::SPLINE
:
849 // FALLTHROUGH intended
850 case animations::AnimationCalcMode::LINEAR
:
851 return createFromToByActivity
< ContinuousActivityBase
>(
858 xNode
->getAccumulate(),
860 rParms
.maSlideBounds
);
865 /** Simple activity for ActivitiesFactory::createSimpleActivity
868 Determines direction of value generator. A 1 yields a
869 forward direction, starting with 0.0 and ending with
870 1.0. A 0 yields a backward direction, starting with
871 1.0 and ending with 0.0
873 template<int Direction
>
874 class SimpleActivity
: public ContinuousActivityBase
877 /** Create SimpleActivity.
880 Standard Activity parameter struct
882 SimpleActivity( const ActivityParameters
& rParms
,
883 const NumberAnimationSharedPtr
& rAnim
) :
884 ContinuousActivityBase( rParms
),
887 ENSURE_OR_THROW( mpAnim
, "Invalid animation object" );
890 virtual void startAnimation() SAL_OVERRIDE
892 if (this->isDisposed() || !mpAnim
)
894 ContinuousActivityBase::startAnimation();
897 mpAnim
->start( getShape(),
898 getShapeAttributeLayer() );
901 virtual void endAnimation() SAL_OVERRIDE
908 using SimpleContinuousActivityBase::perform
;
910 /// perform override for ContinuousActivityBase
911 virtual void perform( double nModifiedTime
, sal_uInt32
) const SAL_OVERRIDE
913 if (this->isDisposed() || !mpAnim
)
915 // no cumulation, simple [0,1] range
916 (*mpAnim
)( 1.0 - Direction
+ nModifiedTime
*(2.0*Direction
- 1.0) );
919 virtual void performEnd() SAL_OVERRIDE
923 (*mpAnim
)( 1.0*Direction
);
927 virtual void dispose() SAL_OVERRIDE
930 ContinuousActivityBase::dispose();
934 NumberAnimationSharedPtr mpAnim
;
940 AnimationActivitySharedPtr
ActivitiesFactory::createAnimateActivity(
941 const CommonParameters
& rParms
,
942 const NumberAnimationSharedPtr
& rAnim
,
943 const uno::Reference
< animations::XAnimate
>& xNode
)
945 // forward to appropriate template instantiation
946 return createActivity( rParms
, xNode
, rAnim
);
949 AnimationActivitySharedPtr
ActivitiesFactory::createAnimateActivity(
950 const CommonParameters
& rParms
,
951 const EnumAnimationSharedPtr
& rAnim
,
952 const uno::Reference
< animations::XAnimate
>& xNode
)
954 // forward to appropriate template instantiation
955 return createActivity( rParms
, xNode
, rAnim
);
958 AnimationActivitySharedPtr
ActivitiesFactory::createAnimateActivity(
959 const CommonParameters
& rParms
,
960 const ColorAnimationSharedPtr
& rAnim
,
961 const uno::Reference
< animations::XAnimate
>& xNode
)
963 // forward to appropriate template instantiation
964 return createActivity( rParms
, xNode
, rAnim
);
967 AnimationActivitySharedPtr
ActivitiesFactory::createAnimateActivity(
968 const CommonParameters
& rParms
,
969 const HSLColorAnimationSharedPtr
& rAnim
,
970 const uno::Reference
< animations::XAnimateColor
>& xNode
)
972 // forward to appropriate template instantiation
973 return createActivity( rParms
,
974 uno::Reference
< animations::XAnimate
>(
975 xNode
, uno::UNO_QUERY_THROW
),
977 // Direction==true means clockwise in SMIL API
978 Interpolator
< HSLColor
>( !xNode
->getDirection() ) );
981 AnimationActivitySharedPtr
ActivitiesFactory::createAnimateActivity(
982 const CommonParameters
& rParms
,
983 const PairAnimationSharedPtr
& rAnim
,
984 const uno::Reference
< animations::XAnimate
>& xNode
)
986 // forward to appropriate template instantiation
987 return createActivity( rParms
, xNode
, rAnim
);
990 AnimationActivitySharedPtr
ActivitiesFactory::createAnimateActivity(
991 const CommonParameters
& rParms
,
992 const StringAnimationSharedPtr
& rAnim
,
993 const uno::Reference
< animations::XAnimate
>& xNode
)
995 // forward to appropriate template instantiation
996 return createActivity( rParms
, xNode
, rAnim
);
999 AnimationActivitySharedPtr
ActivitiesFactory::createAnimateActivity(
1000 const CommonParameters
& rParms
,
1001 const BoolAnimationSharedPtr
& rAnim
,
1002 const uno::Reference
< animations::XAnimate
>& xNode
)
1004 // forward to appropriate template instantiation
1005 return createActivity( rParms
, xNode
, rAnim
);
1008 AnimationActivitySharedPtr
ActivitiesFactory::createSimpleActivity(
1009 const CommonParameters
& rParms
,
1010 const NumberAnimationSharedPtr
& rAnim
,
1011 bool bDirectionForward
)
1013 ActivityParameters
aActivityParms( rParms
.mpEndEvent
,
1014 rParms
.mrEventQueue
,
1015 rParms
.mrActivitiesQueue
,
1016 rParms
.mnMinDuration
,
1018 rParms
.mnAcceleration
,
1019 rParms
.mnDeceleration
,
1020 rParms
.mnMinNumberOfFrames
,
1021 rParms
.mbAutoReverse
);
1023 if( bDirectionForward
)
1024 return AnimationActivitySharedPtr(
1025 new SimpleActivity
<1>( aActivityParms
, rAnim
) );
1027 return AnimationActivitySharedPtr(
1028 new SimpleActivity
<0>( aActivityParms
, rAnim
) );
1031 } // namespace internal
1032 } // namespace presentation
1034 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */