LibreOffice Module slideshow (master) 1
activitiesfactory.cxx
Go to the documentation of this file.
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
22
23#include <com/sun/star/animations/AnimationCalcMode.hpp>
25
26#include <activitiesfactory.hxx>
29#include "accumulation.hxx"
31#include "interpolation.hxx"
32#include <tools.hxx>
37
38#include <optional>
39
40#include <memory>
41#include <utility>
42#include <vector>
43#include <algorithm>
44
45using namespace com::sun::star;
46
47namespace slideshow::internal {
48
49namespace {
50
53template<typename ValueType> struct FormulaTraits
54{
55 static ValueType getPresentationValue(
56 const ValueType& rVal, const std::shared_ptr<ExpressionNode>& )
57 {
58 return rVal;
59 }
60};
61
63template<> struct FormulaTraits<double>
64{
65 static double getPresentationValue(
66 double const& rVal, std::shared_ptr<ExpressionNode> const& rFormula )
67 {
68 return rFormula ? (*rFormula)(rVal) : rVal;
69 }
70};
71
72// Various ActivityBase specializations for different animator types
73// =================================================================
74
100template<class BaseType, typename AnimationType>
101class FromToByActivity : public BaseType
102{
103public:
104 typedef typename AnimationType::ValueType ValueType;
105 typedef std::optional<ValueType> OptionalValueType;
106
107private:
108 // some compilers don't inline whose definition they haven't
109 // seen before the call site...
110 ValueType getPresentationValue( const ValueType& rVal ) const
111 {
112 return FormulaTraits<ValueType>::getPresentationValue( rVal, mpFormula);
113 }
114
115public:
143 FromToByActivity(
144 OptionalValueType aFrom,
145 const OptionalValueType& rTo,
146 const OptionalValueType& rBy,
147 const ActivityParameters& rParms,
148 ::std::shared_ptr< AnimationType > xAnim,
149 const Interpolator< ValueType >& rInterpolator,
150 bool bCumulative )
151 : BaseType( rParms ),
152 maFrom(std::move( aFrom )),
153 maTo( rTo ),
154 maBy( rBy ),
155 mpFormula( rParms.mpFormula ),
156 maStartValue(),
157 maEndValue(),
160 mnIteration( 0 ),
161 mpAnim(std::move( xAnim )),
162 maInterpolator( rInterpolator ),
163 mbDynamicStartValue( false ),
164 mbCumulative( bCumulative )
165 {
166 ENSURE_OR_THROW( mpAnim, "Invalid animation object" );
167
169 rTo || rBy,
170 "From and one of To or By, or To or By alone must be valid" );
171 }
172
173 virtual void startAnimation()
174 {
175 if (this->isDisposed() || !mpAnim)
176 return;
177 BaseType::startAnimation();
178
179 // start animation
180 mpAnim->start( BaseType::getShape(),
181 BaseType::getShapeAttributeLayer() );
182
183 // setup start and end value. Determine animation
184 // start value only when animation actually
185 // started up (this order is part of the Animation
186 // interface contract)
187 const ValueType aAnimationStartValue( mpAnim->getUnderlyingValue() );
188
189 // first of all, determine general type of
190 // animation, by inspecting which of the FromToBy values
191 // are actually valid.
192 // See http://www.w3.org/TR/smil20/animation.html#AnimationNS-FromToBy
193 // for a definition
194 if( maFrom )
195 {
196 // From-to or From-by animation. According to
197 // SMIL spec, the To value takes precedence
198 // over the By value, if both are specified
199 if( maTo )
200 {
201 // From-To animation
203 maEndValue = *maTo;
204 }
205 else if( maBy )
206 {
207 // From-By animation
210 }
212 }
213 else
214 {
215 maStartValue = aAnimationStartValue;
217
218 // By or To animation. According to SMIL spec,
219 // the To value takes precedence over the By
220 // value, if both are specified
221 if( maTo )
222 {
223 // To animation
224
225 // According to the SMIL spec
226 // (http://www.w3.org/TR/smil20/animation.html#animationNS-ToAnimation),
227 // the to animation interpolates between
228 // the _running_ underlying value and the to value (as the end value)
229 mbDynamicStartValue = true;
231 maEndValue = *maTo;
232 }
233 else if( maBy )
234 {
235 // By animation
236 maStartValue = aAnimationStartValue;
238 }
239 }
240 }
241
242 virtual void endAnimation()
243 {
244 // end animation
245 if (mpAnim)
246 mpAnim->end();
247 }
248
250 void perform( double nModifiedTime, sal_uInt32 nRepeatCount ) const
251 {
252 if (this->isDisposed() || !mpAnim)
253 return;
254
255 // According to SMIL 3.0 spec 'to' animation if no other (lower priority)
256 // animations are active or frozen then a simple interpolation is performed.
257 // That is, the start interpolation value is constant while the animation
258 // is running, and is equal to the underlying value retrieved when
259 // the animation start.
260 // However if another animation is manipulating the underlying value,
261 // the 'to' animation will initially add to the effect of the lower priority
262 // animation, and increasingly dominate it as it nears the end of the
263 // simple duration, eventually overriding it completely.
264 // That is, each time the underlying value is changed between two
265 // computations of the animation function the new underlying value is used
266 // as start value for the interpolation.
267 // See:
268 // http://www.w3.org/TR/SMIL3/smil-animation.html#animationNS-ToAnimation
269 // (Figure 6 - Effect of Additive to animation example)
270 // Moreover when a 'to' animation is repeated, at each new iteration
271 // the start interpolation value is reset to the underlying value
272 // of the animated property when the animation started,
273 // as it is shown in the example provided by the SMIL 3.0 spec.
274 // This is exactly as Firefox performs SVG 'to' animations.
276 {
277 if( mnIteration != nRepeatCount )
278 {
279 mnIteration = nRepeatCount;
281 }
282 else
283 {
284 ValueType aActualValue = mpAnim->getUnderlyingValue();
285 if( aActualValue != maPreviousValue )
286 maStartInterpolationValue = aActualValue;
287 }
288 }
289
291 maEndValue, nModifiedTime );
292
293 // According to the SMIL spec:
294 // Because 'to' animation is defined in terms of absolute values of
295 // the target attribute, cumulative animation is not defined.
297 {
298 // aValue = this.aEndValue * nRepeatCount + aValue;
299 aValue = accumulate( maEndValue, nRepeatCount, aValue );
300 }
301
302 (*mpAnim)( getPresentationValue( aValue ) );
303
305 {
306 maPreviousValue = mpAnim->getUnderlyingValue();
307 }
308
309 }
310
311 using BaseType::perform;
312
314 void perform( sal_uInt32 nFrame, sal_uInt32 nRepeatCount ) const
315 {
316 if (this->isDisposed() || !mpAnim)
317 return;
318 (*mpAnim)(
319 getPresentationValue(
320 accumulate( maEndValue, mbCumulative ? nRepeatCount : 0,
323 ? mpAnim->getUnderlyingValue()
324 : maStartValue),
326 nFrame,
327 BaseType::getNumberOfKeyTimes() ) ) ) );
328 }
329
330 using BaseType::isAutoReverse;
331
332 virtual void performEnd()
333 {
334 // xxx todo: good guess
335 if (mpAnim)
336 {
337 if (isAutoReverse())
338 (*mpAnim)( getPresentationValue( maStartValue ) );
339 else
340 (*mpAnim)( getPresentationValue( maEndValue ) );
341 }
342 }
343
345 virtual void dispose()
346 {
347 mpAnim.reset();
348 BaseType::dispose();
349 }
350
351private:
352 const OptionalValueType maFrom;
353 const OptionalValueType maTo;
354 const OptionalValueType maBy;
355
356 std::shared_ptr<ExpressionNode> mpFormula;
357
360
363 mutable sal_uInt32 mnIteration;
364
365 ::std::shared_ptr< AnimationType > mpAnim;
366 Interpolator< ValueType > maInterpolator;
369};
370
371
380template<class BaseType, typename AnimationType>
381AnimationActivitySharedPtr createFromToByActivity(
382 const uno::Any& rFromAny,
383 const uno::Any& rToAny,
384 const uno::Any& rByAny,
385 const ActivityParameters& rParms,
386 const ::std::shared_ptr< AnimationType >& rAnim,
387 const Interpolator< typename AnimationType::ValueType >& rInterpolator,
388 bool bCumulative,
389 const ShapeSharedPtr& rShape,
390 const ::basegfx::B2DVector& rSlideBounds )
391{
392 typedef typename AnimationType::ValueType ValueType;
393 typedef std::optional<ValueType> OptionalValueType;
394
395 OptionalValueType aFrom;
396 OptionalValueType aTo;
397 OptionalValueType aBy;
398
399 ValueType aTmpValue;
400
401 if( rFromAny.hasValue() )
402 {
404 extractValue( aTmpValue, rFromAny, rShape, rSlideBounds ),
405 "createFromToByActivity(): Could not extract from value" );
406 aFrom = aTmpValue;
407 }
408 if( rToAny.hasValue() )
409 {
411 extractValue( aTmpValue, rToAny, rShape, rSlideBounds ),
412 "createFromToByActivity(): Could not extract to value" );
413 aTo = aTmpValue;
414 }
415 if( rByAny.hasValue() )
416 {
418 extractValue( aTmpValue, rByAny, rShape, rSlideBounds ),
419 "createFromToByActivity(): Could not extract by value" );
420 aBy = aTmpValue;
421 }
422
423 return std::make_shared<FromToByActivity<BaseType, AnimationType>>(
424 aFrom,
425 aTo,
426 aBy,
427 rParms,
428 rAnim,
429 rInterpolator,
430 bCumulative );
431}
432
433/* The following table shows which animator combines with
434 which Activity type:
435
436 NumberAnimator: all
437 PairAnimation: all
438 ColorAnimation: all
439 StringAnimation: DiscreteActivityBase
440 BoolAnimation: DiscreteActivityBase
441*/
442
471template<class BaseType, typename AnimationType>
472class ValuesActivity : public BaseType
473{
474public:
475 typedef typename AnimationType::ValueType ValueType;
476 typedef std::vector<ValueType> ValueVectorType;
477
478private:
479 // some compilers don't inline methods whose definition they haven't
480 // seen before the call site...
481 ValueType getPresentationValue( const ValueType& rVal ) const
482 {
483 return FormulaTraits<ValueType>::getPresentationValue(
484 rVal, mpFormula );
485 }
486
487public:
509 ValuesActivity(
510 const ValueVectorType& rValues,
511 const ActivityParameters& rParms,
512 std::shared_ptr<AnimationType> xAnim,
513 const Interpolator< ValueType >& rInterpolator,
514 bool bCumulative )
515 : BaseType( rParms ),
516 maValues( rValues ),
517 mpFormula( rParms.mpFormula ),
518 mpAnim(std::move( xAnim )),
519 maInterpolator( rInterpolator ),
520 mbCumulative( bCumulative )
521 {
522 ENSURE_OR_THROW( mpAnim, "Invalid animation object" );
523 ENSURE_OR_THROW( !rValues.empty(), "Empty value vector" );
524 }
525
526 virtual void startAnimation()
527 {
528 if (this->isDisposed() || !mpAnim)
529 return;
530 BaseType::startAnimation();
531
532 // start animation
533 mpAnim->start( BaseType::getShape(),
534 BaseType::getShapeAttributeLayer() );
535 }
536
537 virtual void endAnimation()
538 {
539 // end animation
540 if (mpAnim)
541 mpAnim->end();
542 }
543
545 void perform( sal_uInt32 nIndex,
546 double nFractionalIndex,
547 sal_uInt32 nRepeatCount ) const
548 {
549 if (this->isDisposed() || !mpAnim)
550 return;
551 ENSURE_OR_THROW( nIndex+1 < maValues.size(),
552 "ValuesActivity::perform(): index out of range" );
553
554 // interpolate between nIndex and nIndex+1 values
555 (*mpAnim)(
556 getPresentationValue(
557 accumulate<ValueType>( maValues.back(),
558 mbCumulative ? nRepeatCount : 0,
559 maInterpolator( maValues[ nIndex ],
560 maValues[ nIndex+1 ],
561 nFractionalIndex ) ) ) );
562 }
563
564 using BaseType::perform;
565
567 void perform( sal_uInt32 nFrame, sal_uInt32 nRepeatCount ) const
568 {
569 if (this->isDisposed() || !mpAnim)
570 return;
571 ENSURE_OR_THROW( nFrame < maValues.size(),
572 "ValuesActivity::perform(): index out of range" );
573
574 // this is discrete, thus no lerp here.
575 (*mpAnim)(
576 getPresentationValue(
577 slideshow::internal::accumulate<ValueType>( maValues.back(),
578 mbCumulative ? nRepeatCount : 0,
579 maValues[ nFrame ] ) ) );
580 }
581
582 virtual void performEnd()
583 {
584 // xxx todo: good guess
585 if (mpAnim)
586 (*mpAnim)( getPresentationValue( maValues.back() ) );
587 }
588
589private:
590 ValueVectorType maValues;
591
592 std::shared_ptr<ExpressionNode> mpFormula;
593
594 std::shared_ptr<AnimationType> mpAnim;
595 Interpolator< ValueType > maInterpolator;
596 bool mbCumulative;
597};
598
607template<class BaseType, typename AnimationType>
608AnimationActivitySharedPtr createValueListActivity(
609 const uno::Sequence<uno::Any>& rValues,
610 const ActivityParameters& rParms,
611 const std::shared_ptr<AnimationType>& rAnim,
612 const Interpolator<typename AnimationType::ValueType>& rInterpolator,
613 bool bCumulative,
614 const ShapeSharedPtr& rShape,
615 const ::basegfx::B2DVector& rSlideBounds )
616{
617 typedef typename AnimationType::ValueType ValueType;
618 typedef std::vector<ValueType> ValueVectorType;
619
620 ValueVectorType aValueVector;
621 aValueVector.reserve( rValues.getLength() );
622
623 for( const auto& rValue : rValues )
624 {
625 ValueType aValue;
627 extractValue( aValue, rValue, rShape, rSlideBounds ),
628 "createValueListActivity(): Could not extract values" );
629 aValueVector.push_back( aValue );
630 }
631
632 return std::make_shared<ValuesActivity<BaseType, AnimationType>>(
633 aValueVector,
634 rParms,
635 rAnim,
636 rInterpolator,
637 bCumulative );
638}
639
661template<typename AnimationType>
662AnimationActivitySharedPtr createActivity(
663 const ActivitiesFactory::CommonParameters& rParms,
664 const uno::Reference< animations::XAnimate >& xNode,
665 const ::std::shared_ptr< AnimationType >& rAnim,
666 const Interpolator< typename AnimationType::ValueType >& rInterpolator
667 = Interpolator< typename AnimationType::ValueType >() )
668{
669 // setup common parameters
670 // =======================
671
672 ActivityParameters aActivityParms( rParms.mpEndEvent,
673 rParms.mrEventQueue,
674 rParms.mrActivitiesQueue,
675 rParms.mnMinDuration,
676 rParms.maRepeats,
677 rParms.mnAcceleration,
678 rParms.mnDeceleration,
679 rParms.mnMinNumberOfFrames,
680 rParms.mbAutoReverse );
681
682 // is a formula given?
683 const OUString& rFormulaString( xNode->getFormula() );
684 if( !rFormulaString.isEmpty() )
685 {
686 // yep, parse and pass to ActivityParameters
687 try
688 {
689 aActivityParms.mpFormula =
691 rFormulaString,
693 rParms.maSlideBounds,
694 rParms.mpShape->getBounds() ) );
695 }
696 catch( ParseError& )
697 {
698 // parse error, thus no formula
699 OSL_FAIL( "createActivity(): Error parsing formula string" );
700 }
701 }
702
703 // are key times given?
704 const uno::Sequence< double >& aKeyTimes( xNode->getKeyTimes() );
705 if( aKeyTimes.hasElements() )
706 {
707 // yes, convert them from Sequence< double >
708 aActivityParms.maDiscreteTimes.resize( aKeyTimes.getLength() );
710 aActivityParms.maDiscreteTimes.data(),
711 aKeyTimes ); // saves us some temporary vectors
712 }
713
714 // values sequence given?
715 const sal_Int32 nValueLen( xNode->getValues().getLength() );
716 if( nValueLen )
717 {
718 // Value list activity
719 // ===================
720
721 // fake keytimes, if necessary
722 if( !aKeyTimes.hasElements() )
723 {
724 // create a dummy vector of key times,
725 // with aValues.getLength equally spaced entries.
726 for( sal_Int32 i=0; i<nValueLen; ++i )
727 aActivityParms.maDiscreteTimes.push_back( double(i)/nValueLen );
728 }
729
730 // determine type of animation needed here:
731 // Value list activities are possible with
732 // ContinuousKeyTimeActivityBase and DiscreteActivityBase
733 // specializations
734 const sal_Int16 nCalcMode( xNode->getCalcMode() );
735
736 switch( nCalcMode )
737 {
738 case animations::AnimationCalcMode::DISCRETE:
739 {
740 // since DiscreteActivityBase suspends itself
741 // between the frames, create a WakeupEvent for it.
742 aActivityParms.mpWakeupEvent =
743 std::make_shared<WakeupEvent>(
744 rParms.mrEventQueue.getTimer(),
745 rParms.mrActivitiesQueue );
746
748 createValueListActivity< DiscreteActivityBase >(
749 xNode->getValues(),
750 aActivityParms,
751 rAnim,
752 rInterpolator,
753 xNode->getAccumulate(),
754 rParms.mpShape,
755 rParms.maSlideBounds ) );
756
757 // WakeupEvent and DiscreteActivityBase need circular
758 // references to the corresponding other object.
759 aActivityParms.mpWakeupEvent->setActivity( pActivity );
760
761 return pActivity;
762 }
763
764 default:
765 OSL_FAIL( "createActivity(): unexpected case" );
766 [[fallthrough]];
767 case animations::AnimationCalcMode::PACED:
768 case animations::AnimationCalcMode::SPLINE:
769 case animations::AnimationCalcMode::LINEAR:
770 return createValueListActivity< ContinuousKeyTimeActivityBase >(
771 xNode->getValues(),
772 aActivityParms,
773 rAnim,
774 rInterpolator,
775 xNode->getAccumulate(),
776 rParms.mpShape,
777 rParms.maSlideBounds );
778 }
779 }
780 else
781 {
782 // FromToBy activity
783 // =================
784
785 // determine type of animation needed here:
786 // FromToBy activities are possible with
787 // ContinuousActivityBase and DiscreteActivityBase
788 // specializations
789 const sal_Int16 nCalcMode( xNode->getCalcMode() );
790
791 switch( nCalcMode )
792 {
793 case animations::AnimationCalcMode::DISCRETE:
794 {
795 // fake keytimes, if necessary
796 if( !aKeyTimes.hasElements() )
797 {
798 // create a dummy vector of 2 key times
799 const ::std::size_t nLen( 2 );
800 for( ::std::size_t i=0; i<nLen; ++i )
801 aActivityParms.maDiscreteTimes.push_back( double(i)/nLen );
802 }
803
804 // since DiscreteActivityBase suspends itself
805 // between the frames, create a WakeupEvent for it.
806 aActivityParms.mpWakeupEvent =
807 std::make_shared<WakeupEvent>(
808 rParms.mrEventQueue.getTimer(),
809 rParms.mrActivitiesQueue );
810
812 createFromToByActivity< DiscreteActivityBase >(
813 xNode->getFrom(),
814 xNode->getTo(),
815 xNode->getBy(),
816 aActivityParms,
817 rAnim,
818 rInterpolator,
819 xNode->getAccumulate(),
820 rParms.mpShape,
821 rParms.maSlideBounds ) );
822
823 // WakeupEvent and DiscreteActivityBase need circular
824 // references to the corresponding other object.
825 aActivityParms.mpWakeupEvent->setActivity( pActivity );
826
827 return pActivity;
828 }
829
830 default:
831 OSL_FAIL( "createActivity(): unexpected case" );
832 [[fallthrough]];
833 case animations::AnimationCalcMode::PACED:
834 case animations::AnimationCalcMode::SPLINE:
835 case animations::AnimationCalcMode::LINEAR:
836 return createFromToByActivity< ContinuousActivityBase >(
837 xNode->getFrom(),
838 xNode->getTo(),
839 xNode->getBy(),
840 aActivityParms,
841 rAnim,
842 rInterpolator,
843 xNode->getAccumulate(),
844 rParms.mpShape,
845 rParms.maSlideBounds );
846 }
847 }
848}
849
858template<int Direction>
859class SimpleActivity : public ContinuousActivityBase
860{
861public:
867 SimpleActivity( const ActivityParameters& rParms,
869 ContinuousActivityBase( rParms ),
870 mpAnim(std::move( xAnim ))
871 {
872 ENSURE_OR_THROW( mpAnim, "Invalid animation object" );
873 }
874
875 virtual void startAnimation() override
876 {
877 if (this->isDisposed() || !mpAnim)
878 return;
880
881 // start animation
882 mpAnim->start( getShape(),
883 getShapeAttributeLayer() );
884 }
885
886 virtual void endAnimation() override
887 {
888 // end animation
889 if (mpAnim)
890 mpAnim->end();
891 }
892
894
896 virtual void perform( double nModifiedTime, sal_uInt32 ) const override
897 {
898 if (this->isDisposed() || !mpAnim)
899 return;
900 // no cumulation, simple [0,1] range
901 (*mpAnim)( 1.0 - Direction + nModifiedTime*(2.0*Direction - 1.0) );
902 }
903
904 virtual void performEnd() override
905 {
906 // xxx todo: review
907 if (mpAnim)
908 (*mpAnim)( 1.0*Direction );
909 }
910
912 virtual void dispose() override
913 {
914 mpAnim.reset();
916 }
917
918private:
920};
921
922} // anon namespace
923
924
926 const CommonParameters& rParms,
927 const NumberAnimationSharedPtr& rAnim,
928 const uno::Reference< animations::XAnimate >& xNode )
929{
930 // forward to appropriate template instantiation
931 return createActivity( rParms, xNode, rAnim );
932}
933
935 const CommonParameters& rParms,
936 const EnumAnimationSharedPtr& rAnim,
937 const uno::Reference< animations::XAnimate >& xNode )
938{
939 // forward to appropriate template instantiation
940 return createActivity( rParms, xNode, rAnim );
941}
942
944 const CommonParameters& rParms,
945 const ColorAnimationSharedPtr& rAnim,
946 const uno::Reference< animations::XAnimate >& xNode )
947{
948 // forward to appropriate template instantiation
949 return createActivity( rParms, xNode, rAnim );
950}
951
953 const CommonParameters& rParms,
954 const HSLColorAnimationSharedPtr& rAnim,
955 const uno::Reference< animations::XAnimateColor >& xNode )
956{
957 // forward to appropriate template instantiation
958 return createActivity( rParms,
959 uno::Reference< animations::XAnimate >(
960 xNode, uno::UNO_QUERY_THROW ),
961 rAnim,
962 // Direction==true means clockwise in SMIL API
963 Interpolator< HSLColor >( !xNode->getDirection() ) );
964}
965
967 const CommonParameters& rParms,
968 const PairAnimationSharedPtr& rAnim,
969 const uno::Reference< animations::XAnimate >& xNode )
970{
971 // forward to appropriate template instantiation
972 return createActivity( rParms, xNode, rAnim );
973}
974
976 const CommonParameters& rParms,
977 const StringAnimationSharedPtr& rAnim,
978 const uno::Reference< animations::XAnimate >& xNode )
979{
980 // forward to appropriate template instantiation
981 return createActivity( rParms, xNode, rAnim );
982}
983
985 const CommonParameters& rParms,
986 const BoolAnimationSharedPtr& rAnim,
987 const uno::Reference< animations::XAnimate >& xNode )
988{
989 // forward to appropriate template instantiation
990 return createActivity( rParms, xNode, rAnim );
991}
992
994 const CommonParameters& rParms,
995 const NumberAnimationSharedPtr& rAnim,
996 bool bDirectionForward )
997{
998 ActivityParameters aActivityParms( rParms.mpEndEvent,
999 rParms.mrEventQueue,
1000 rParms.mrActivitiesQueue,
1001 rParms.mnMinDuration,
1002 rParms.maRepeats,
1003 rParms.mnAcceleration,
1004 rParms.mnDeceleration,
1005 rParms.mnMinNumberOfFrames,
1006 rParms.mbAutoReverse );
1007
1008 if( bDirectionForward )
1009 return std::make_shared<SimpleActivity<1>>( aActivityParms, rAnim );
1010 else
1011 return std::make_shared<SimpleActivity<0>>( aActivityParms, rAnim );
1012}
1013
1014} // namespace presentation
1015
1016/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ValueVectorType maValues
ValueType maPreviousValue
Interpolator< ValueType > maInterpolator
ValueType maStartInterpolationValue
sal_uInt32 mnIteration
std::shared_ptr< ExpressionNode > mpFormula
ValueType maEndValue
const OptionalValueType maBy
const OptionalValueType maFrom
bool mbDynamicStartValue
::std::shared_ptr< AnimationType > mpAnim
bool mbCumulative
ValueType maStartValue
const OptionalValueType maTo
virtual void dispose() override
From Disposable interface.
virtual void startAnimation() override
Hook for derived classes.
virtual bool perform() override
From Activity interface.
static std::shared_ptr< ExpressionNode > const & parseSmilFunction(const OUString &rSmilFunction, const ::basegfx::B2DRectangle &rRelativeShapeBounds)
Parse a string containing a SMIL function.
#define ENSURE_OR_THROW(c, m)
Environment aTo
Environment aFrom
DstType * sequenceToArray(DstType *io_pArray, const css::uno::Sequence< SrcType > &i_Sequence)
int i
ValueType
AnimationActivitySharedPtr createAnimateActivity(const CommonParameters &rParms, const NumberAnimationSharedPtr &rAnimator, const css::uno::Reference< css::animations::XAnimate > &xNode)
Create an activity from an XAnimate node.
AnimationActivitySharedPtr createSimpleActivity(const CommonParameters &rParms, const NumberAnimationSharedPtr &rAnimator, bool bDirectionForward)
Create a simple activity for the given animator.
::std::shared_ptr< NumberAnimation > NumberAnimationSharedPtr
::std::shared_ptr< AnimationActivity > AnimationActivitySharedPtr
::std::shared_ptr< HSLColorAnimation > HSLColorAnimationSharedPtr
::std::shared_ptr< PairAnimation > PairAnimationSharedPtr
::std::shared_ptr< BoolAnimation > BoolAnimationSharedPtr
::std::shared_ptr< EnumAnimation > EnumAnimationSharedPtr
::std::shared_ptr< StringAnimation > StringAnimationSharedPtr
::std::shared_ptr< Shape > ShapeSharedPtr
::std::shared_ptr< ColorAnimation > ColorAnimationSharedPtr
bool extractValue(double &o_rValue, const uno::Any &rSourceAny, const ShapeSharedPtr &rShape, const ::basegfx::B2DVector &rSlideBounds)
extract unary double value from Any
Definition: tools.cxx:137
ValueType accumulate(const ValueType &rEndValue, sal_uInt32 nRepeatCount, const ValueType &rCurrValue)
Generic accumulation.
basegfx::B2DRange calcRelativeShapeBounds(const basegfx::B2DVector &rPageSize, const basegfx::B2DRange &rShapeBounds)
Definition: tools.cxx:440
ValueType lerp(const Interpolator< ValueType > &rInterpolator, const ValueType &rFrom, const ValueType &rTo, sal_uInt32 nFrame, ::std::size_t nTotalFrames)
Generic linear interpolator.
void dispose()
EventQueue & mrEventQueue
Event queue to insert the end event into.
bool mbAutoReverse
When true, activity is played reversed after mnDuration.
::std::optional< double > const maRepeats
Number of repeats for the simple duration.
sal_uInt32 mnMinNumberOfFrames
Minimal number of frames for this activity.
ActivitiesQueue & mrActivitiesQueue
Event queue to insert the end event into.
EventSharedPtr mpEndEvent
End event to fire when animation is over.
double mnDeceleration
Fraction of simple time to decelerate animation.
double mnAcceleration
Fraction of simple time to accelerate animation.
double mnMinDuration
Simple duration of the activity.
Parameter struct for animation activities.
bool hasValue()