Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / animations / source / animcore / animcore.cxx
blob03c815021c93176d98a562e655f9254e792c80a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <com/sun/star/util/XCloneable.hpp>
21 #include <com/sun/star/lang/IllegalArgumentException.hpp>
22 #include <com/sun/star/lang/XServiceInfo.hpp>
23 #include <com/sun/star/lang/XTypeProvider.hpp>
24 #include <com/sun/star/animations/XAnimateColor.hpp>
25 #include <com/sun/star/animations/XAnimateSet.hpp>
26 #include <com/sun/star/animations/XAnimateMotion.hpp>
27 #include <com/sun/star/animations/XAnimatePhysics.hpp>
28 #include <com/sun/star/animations/XAnimateTransform.hpp>
29 #include <com/sun/star/animations/XParallelTimeContainer.hpp>
30 #include <com/sun/star/animations/XTransitionFilter.hpp>
31 #include <com/sun/star/animations/XTimeContainer.hpp>
32 #include <com/sun/star/animations/XIterateContainer.hpp>
33 #include <com/sun/star/animations/XAudio.hpp>
34 #include <com/sun/star/animations/XCommand.hpp>
35 #include <com/sun/star/animations/AnimationNodeType.hpp>
36 #include <com/sun/star/animations/AnimationCalcMode.hpp>
37 #include <com/sun/star/animations/AnimationFill.hpp>
38 #include <com/sun/star/animations/AnimationRestart.hpp>
39 #include <com/sun/star/animations/AnimationColorSpace.hpp>
40 #include <com/sun/star/animations/AnimationAdditiveMode.hpp>
41 #include <com/sun/star/animations/AnimationTransformType.hpp>
42 #include <com/sun/star/animations/TransitionType.hpp>
43 #include <com/sun/star/animations/TransitionSubType.hpp>
44 #include <com/sun/star/presentation/ShapeAnimationSubType.hpp>
45 #include <com/sun/star/container/ElementExistException.hpp>
46 #include <com/sun/star/container/XEnumerationAccess.hpp>
47 #include <com/sun/star/util/XChangesNotifier.hpp>
48 #include <comphelper/servicehelper.hxx>
49 #include <cppuhelper/basemutex.hxx>
50 #include <cppuhelper/queryinterface.hxx>
51 #include <comphelper/interfacecontainer4.hxx>
52 #include <cppuhelper/supportsservice.hxx>
53 #include <cppuhelper/weakref.hxx>
55 #include <cppuhelper/implbase.hxx>
57 #include <o3tl/safeint.hxx>
58 #include <sal/log.hxx>
59 #include <unotools/weakref.hxx>
60 #include <array>
61 #include <mutex>
62 #include <vector>
63 #include <algorithm>
65 namespace com::sun::star::uno { class XComponentContext; }
66 namespace com::sun::star::beans { struct NamedValue; }
68 using ::comphelper::OInterfaceContainerHelper4;
69 using ::comphelper::OInterfaceIteratorHelper4;
70 using ::com::sun::star::uno::Any;
71 using ::com::sun::star::uno::UNO_QUERY;
72 using ::com::sun::star::uno::XInterface;
73 using ::com::sun::star::uno::Sequence;
74 using ::com::sun::star::uno::Reference;
75 using ::com::sun::star::uno::XComponentContext;
76 using ::com::sun::star::uno::Exception;
77 using ::com::sun::star::uno::XWeak;
78 using ::com::sun::star::uno::Type;
79 using ::com::sun::star::uno::Any;
80 using ::com::sun::star::lang::IllegalArgumentException;
81 using ::com::sun::star::lang::XServiceInfo;
82 using ::com::sun::star::lang::XTypeProvider;
83 using ::com::sun::star::container::NoSuchElementException;
84 using ::com::sun::star::container::ElementExistException;
85 using ::com::sun::star::container::XEnumeration;
86 using ::com::sun::star::container::XEnumerationAccess;
87 using ::com::sun::star::beans::NamedValue;
88 using ::com::sun::star::util::XCloneable;
89 using ::com::sun::star::util::XChangesNotifier;
90 using ::com::sun::star::util::XChangesListener;
91 using ::com::sun::star::util::ElementChange;
92 using ::com::sun::star::util::ChangesEvent;
94 using ::cppu::OWeakObject;
96 using namespace ::com::sun::star::animations;
97 using namespace ::com::sun::star::animations::AnimationNodeType;
99 namespace animcore
102 namespace {
103 class AnimationNodeBase : public XAnimateMotion,
104 public XAnimatePhysics,
105 public XAnimateColor,
106 public XTransitionFilter,
107 public XAnimateSet,
108 public XAnimateTransform,
109 public XParallelTimeContainer,
110 public XIterateContainer,
111 public XServiceInfo,
112 public XTypeProvider,
113 public XAudio,
114 public XCommand,
115 public XCloneable,
116 public XChangesNotifier,
117 public OWeakObject
122 class AnimationNode final: public AnimationNodeBase
124 public:
125 explicit AnimationNode(sal_Int16 nNodeType);
126 explicit AnimationNode(const AnimationNode& rNode);
128 // XInterface
129 virtual Any SAL_CALL queryInterface( const Type& aType ) override;
130 virtual void SAL_CALL acquire() noexcept override;
131 virtual void SAL_CALL release() noexcept override;
133 // XTypeProvider
134 virtual Sequence< Type > SAL_CALL getTypes() override;
135 virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
137 // XServiceInfo
138 OUString SAL_CALL getImplementationName() override;
139 Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
140 sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
142 // XChild
143 virtual Reference< XInterface > SAL_CALL getParent() override;
144 virtual void SAL_CALL setParent( const Reference< XInterface >& Parent ) override;
146 // XCloneable
147 virtual Reference< XCloneable > SAL_CALL createClone() override;
149 // XAnimationNode
150 virtual sal_Int16 SAL_CALL getType() override;
151 virtual Any SAL_CALL getBegin() override;
152 virtual void SAL_CALL setBegin( const Any& _begin ) override;
153 virtual Any SAL_CALL getDuration() override;
154 virtual void SAL_CALL setDuration( const Any& _duration ) override;
155 virtual Any SAL_CALL getEnd() override;
156 virtual void SAL_CALL setEnd( const Any& _end ) override;
157 virtual Any SAL_CALL getEndSync() override;
158 virtual void SAL_CALL setEndSync( const Any& _endsync ) override;
159 virtual Any SAL_CALL getRepeatCount() override;
160 virtual void SAL_CALL setRepeatCount( const Any& _repeatcount ) override;
161 virtual Any SAL_CALL getRepeatDuration() override;
162 virtual void SAL_CALL setRepeatDuration( const Any& _repeatduration ) override;
163 virtual sal_Int16 SAL_CALL getFill() override;
164 virtual void SAL_CALL setFill( sal_Int16 _fill ) override;
165 virtual sal_Int16 SAL_CALL getFillDefault() override;
166 virtual void SAL_CALL setFillDefault( sal_Int16 _filldefault ) override;
167 virtual sal_Int16 SAL_CALL getRestart() override;
168 virtual void SAL_CALL setRestart( sal_Int16 _restart ) override;
169 virtual sal_Int16 SAL_CALL getRestartDefault() override;
170 virtual void SAL_CALL setRestartDefault( sal_Int16 _restartdefault ) override;
171 virtual double SAL_CALL getAcceleration() override;
172 virtual void SAL_CALL setAcceleration( double _acceleration ) override;
173 virtual double SAL_CALL getDecelerate() override;
174 virtual void SAL_CALL setDecelerate( double _decelerate ) override;
175 virtual sal_Bool SAL_CALL getAutoReverse() override;
176 virtual void SAL_CALL setAutoReverse( sal_Bool _autoreverse ) override;
177 virtual Sequence< NamedValue > SAL_CALL getUserData() override;
178 virtual void SAL_CALL setUserData( const Sequence< NamedValue >& _userdata ) override;
180 // XAnimate
181 virtual Any SAL_CALL getTarget() override;
182 virtual void SAL_CALL setTarget( const Any& _target ) override;
183 virtual sal_Int16 SAL_CALL getSubItem() override;
184 virtual void SAL_CALL setSubItem( sal_Int16 _subitem ) override;
185 virtual OUString SAL_CALL getAttributeName() override;
186 virtual void SAL_CALL setAttributeName( const OUString& _attribute ) override;
187 virtual Sequence< Any > SAL_CALL getValues() override;
188 virtual void SAL_CALL setValues( const Sequence< Any >& _values ) override;
189 virtual Sequence< double > SAL_CALL getKeyTimes() override;
190 virtual void SAL_CALL setKeyTimes( const Sequence< double >& _keytimes ) override;
191 virtual sal_Int16 SAL_CALL getValueType() override;
192 virtual void SAL_CALL setValueType( sal_Int16 _valuetype ) override;
193 virtual sal_Int16 SAL_CALL getCalcMode() override;
194 virtual void SAL_CALL setCalcMode( sal_Int16 _calcmode ) override;
195 virtual sal_Bool SAL_CALL getAccumulate() override;
196 virtual void SAL_CALL setAccumulate( sal_Bool _accumulate ) override;
197 virtual sal_Int16 SAL_CALL getAdditive() override;
198 virtual void SAL_CALL setAdditive( sal_Int16 _additive ) override;
199 virtual Any SAL_CALL getFrom() override;
200 virtual void SAL_CALL setFrom( const Any& _from ) override;
201 virtual Any SAL_CALL getTo() override;
202 virtual void SAL_CALL setTo( const Any& _to ) override;
203 virtual Any SAL_CALL getBy() override;
204 virtual void SAL_CALL setBy( const Any& _by ) override;
205 virtual Sequence< TimeFilterPair > SAL_CALL getTimeFilter() override;
206 virtual void SAL_CALL setTimeFilter( const Sequence< TimeFilterPair >& _timefilter ) override;
207 virtual OUString SAL_CALL getFormula() override;
208 virtual void SAL_CALL setFormula( const OUString& _formula ) override;
210 // XAnimateColor
211 virtual sal_Int16 SAL_CALL getColorInterpolation() override;
212 virtual void SAL_CALL setColorInterpolation( sal_Int16 _colorspace ) override;
213 virtual sal_Bool SAL_CALL getDirection() override;
214 virtual void SAL_CALL setDirection( sal_Bool _direction ) override;
216 // XAnimateMotion
217 virtual Any SAL_CALL getPath() override;
218 virtual void SAL_CALL setPath( const Any& _path ) override;
219 virtual Any SAL_CALL getOrigin() override;
220 virtual void SAL_CALL setOrigin( const Any& _origin ) override;
222 // XAnimatePhysics
223 virtual Any SAL_CALL getStartVelocityX() override;
224 virtual void SAL_CALL setStartVelocityX( const Any& _startvelocityx ) override;
225 virtual Any SAL_CALL getStartVelocityY() override;
226 virtual void SAL_CALL setStartVelocityY( const Any& _startvelocityy ) override;
227 virtual Any SAL_CALL getDensity() override;
228 virtual void SAL_CALL setDensity( const Any& _density ) override;
229 virtual Any SAL_CALL getBounciness() override;
230 virtual void SAL_CALL setBounciness( const Any& _bounciness ) override;
232 // XAnimateTransform
233 virtual sal_Int16 SAL_CALL getTransformType() override;
234 virtual void SAL_CALL setTransformType( sal_Int16 _transformtype ) override;
236 // XTransitionFilter
237 virtual sal_Int16 SAL_CALL getTransition() override;
238 virtual void SAL_CALL setTransition( sal_Int16 _transition ) override;
239 virtual sal_Int16 SAL_CALL getSubtype() override;
240 virtual void SAL_CALL setSubtype( sal_Int16 _subtype ) override;
241 virtual sal_Bool SAL_CALL getMode() override;
242 virtual void SAL_CALL setMode( sal_Bool _mode ) override;
243 virtual sal_Int32 SAL_CALL getFadeColor() override;
244 virtual void SAL_CALL setFadeColor( sal_Int32 _fadecolor ) override;
246 // XAudio
247 virtual Any SAL_CALL getSource() override;
248 virtual void SAL_CALL setSource( const Any& _source ) override;
249 virtual double SAL_CALL getVolume() override;
250 virtual void SAL_CALL setVolume( double _volume ) override;
251 sal_Bool SAL_CALL getHideDuringShow() override;
252 void SAL_CALL setHideDuringShow(sal_Bool bHideDuringShow) override;
253 sal_Bool SAL_CALL getNarration() override;
254 void SAL_CALL setNarration(sal_Bool bNarration) override;
257 // XCommand - the following two shadowed by animate, unfortunately
258 // virtual Any SAL_CALL getTarget() throw (RuntimeException);
259 // virtual void SAL_CALL setTarget( const Any& _target ) throw (RuntimeException);
260 virtual sal_Int16 SAL_CALL getCommand() override;
261 virtual void SAL_CALL setCommand( sal_Int16 _command ) override;
262 virtual Any SAL_CALL getParameter() override;
263 virtual void SAL_CALL setParameter( const Any& _parameter ) override;
265 // XElementAccess
266 virtual Type SAL_CALL getElementType() override;
267 virtual sal_Bool SAL_CALL hasElements() override;
269 // XEnumerationAccess
270 virtual Reference< XEnumeration > SAL_CALL createEnumeration() override;
272 // XTimeContainer
273 virtual Reference< XAnimationNode > SAL_CALL insertBefore( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) override;
274 virtual Reference< XAnimationNode > SAL_CALL insertAfter( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) override;
275 virtual Reference< XAnimationNode > SAL_CALL replaceChild( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& oldChild ) override;
276 virtual Reference< XAnimationNode > SAL_CALL removeChild( const Reference< XAnimationNode >& oldChild ) override;
277 virtual Reference< XAnimationNode > SAL_CALL appendChild( const Reference< XAnimationNode >& newChild ) override;
279 // XIterateContainer
280 virtual sal_Int16 SAL_CALL getIterateType() override;
281 virtual void SAL_CALL setIterateType( sal_Int16 _iteratetype ) override;
282 virtual double SAL_CALL getIterateInterval() override;
283 virtual void SAL_CALL setIterateInterval( double _iterateinterval ) override;
285 // XChangesNotifier
286 virtual void SAL_CALL addChangesListener( const Reference< XChangesListener >& aListener ) override;
287 virtual void SAL_CALL removeChangesListener( const Reference< XChangesListener >& aListener ) override;
289 void fireChangeListener(std::unique_lock<std::mutex>&);
291 private:
292 std::mutex m_aMutex;
293 OInterfaceContainerHelper4<XChangesListener> maChangeListener;
295 static void initTypeProvider( sal_Int16 nNodeType ) noexcept;
297 const sal_Int16 mnNodeType;
299 // for XTypeProvider
300 static std::array<Sequence< Type >*, 13> mpTypes;
302 // attributes for the XAnimationNode interface implementation
303 Any maBegin, maDuration, maEnd, maEndSync, maRepeatCount, maRepeatDuration;
304 sal_Int16 mnFill, mnFillDefault, mnRestart, mnRestartDefault;
305 double mfAcceleration, mfDecelerate;
306 bool mbAutoReverse;
307 Sequence< NamedValue > maUserData;
309 // parent interface for XChild interface implementation
310 unotools::WeakReference<AnimationNode> mxParent;
312 // attributes for XAnimate
313 Any maTarget;
314 OUString maAttributeName, maFormula;
315 Sequence< Any > maValues;
316 Sequence< double > maKeyTimes;
317 sal_Int16 mnValueType, mnSubItem;
318 sal_Int16 mnCalcMode, mnAdditive;
319 bool mbAccumulate;
320 Any maFrom, maTo, maBy;
321 Sequence< TimeFilterPair > maTimeFilter;
323 // attributes for XAnimateColor
324 sal_Int16 mnColorSpace;
325 bool mbDirection;
327 // attributes for XAnimateMotion
328 Any maPath, maOrigin;
330 // attributes for XAnimatePhysics
331 Any maStartVelocityX, maStartVelocityY, maDensity, maBounciness;
333 // attributes for XAnimateTransform
334 sal_Int16 mnTransformType;
336 // attributes for XTransitionFilter
337 sal_Int16 mnTransition;
338 sal_Int16 mnSubtype;
339 bool mbMode;
340 sal_Int32 mnFadeColor;
342 // XAudio
343 double mfVolume;
344 bool mbHideDuringShow;
345 bool mbNarration;
347 // XCommand
348 sal_Int16 mnCommand;
349 Any maParameter;
351 // XIterateContainer
352 sal_Int16 mnIterateType;
353 double mfIterateInterval;
355 /** sorted list of child nodes for XTimeContainer*/
356 std::vector< Reference< XAnimationNode > > maChildren;
360 class TimeContainerEnumeration : public ::cppu::WeakImplHelper< XEnumeration >
362 public:
363 explicit TimeContainerEnumeration( std::vector< Reference< XAnimationNode > >&& rChildren );
365 // Methods
366 virtual sal_Bool SAL_CALL hasMoreElements() override;
367 virtual Any SAL_CALL nextElement( ) override;
369 private:
370 std::mutex m_aMutex;
372 /** sorted list of child nodes */
373 std::vector< Reference< XAnimationNode > > maChildren;
375 /** current iteration position */
376 std::vector< Reference< XAnimationNode > >::iterator maIter;
381 TimeContainerEnumeration::TimeContainerEnumeration( std::vector< Reference< XAnimationNode > >&& rChildren )
382 : maChildren( std::move(rChildren) )
384 maIter = maChildren.begin();
387 // Methods
388 sal_Bool SAL_CALL TimeContainerEnumeration::hasMoreElements()
390 std::unique_lock aGuard( m_aMutex );
392 return maIter != maChildren.end();
395 Any SAL_CALL TimeContainerEnumeration::nextElement()
397 std::unique_lock aGuard( m_aMutex );
399 if( maIter == maChildren.end() )
400 throw NoSuchElementException();
402 return Any( *maIter++ );
406 std::array<Sequence< Type >*, 13> AnimationNode::mpTypes = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr };
408 AnimationNode::AnimationNode( sal_Int16 nNodeType )
409 : AnimationNodeBase(),
410 mnNodeType( nNodeType ),
411 mnFill( AnimationFill::DEFAULT ),
412 mnFillDefault( AnimationFill::INHERIT ),
413 mnRestart( AnimationRestart:: DEFAULT ),
414 mnRestartDefault( AnimationRestart:: INHERIT ),
415 mfAcceleration( 0.0 ),
416 mfDecelerate( 0.0 ),
417 mbAutoReverse( false ),
418 mnValueType( 0 ),
419 mnSubItem( 0 ),
420 mnCalcMode( (nNodeType == AnimationNodeType::ANIMATEMOTION) ? AnimationCalcMode::PACED : AnimationCalcMode::LINEAR),
421 mnAdditive(AnimationAdditiveMode::REPLACE),
422 mbAccumulate(false),
423 mnColorSpace( AnimationColorSpace::RGB ),
424 mbDirection( true ),
425 mnTransformType( AnimationTransformType::TRANSLATE ),
426 mnTransition(TransitionType::BARWIPE),
427 mnSubtype(TransitionSubType::DEFAULT),
428 mbMode(true),
429 mnFadeColor(0),
430 mfVolume(1.0),
431 mbHideDuringShow(false),
432 mbNarration(false),
433 mnCommand(0),
434 mnIterateType( css::presentation::ShapeAnimationSubType::AS_WHOLE ),
435 mfIterateInterval(0.0)
437 assert(nNodeType >= 0 && o3tl::make_unsigned(nNodeType) < mpTypes.size());
440 AnimationNode::AnimationNode( const AnimationNode& rNode )
441 : AnimationNodeBase(),
442 mnNodeType( rNode.mnNodeType ),
444 // attributes for the XAnimationNode interface implementation
445 maBegin( rNode.maBegin ),
446 maDuration( rNode.maDuration ),
447 maEnd( rNode.maEnd ),
448 maEndSync( rNode.maEndSync ),
449 maRepeatCount( rNode.maRepeatCount ),
450 maRepeatDuration( rNode.maRepeatDuration ),
451 mnFill( rNode.mnFill ),
452 mnFillDefault( rNode.mnFillDefault ),
453 mnRestart( rNode.mnRestart ),
454 mnRestartDefault( rNode.mnRestartDefault ),
455 mfAcceleration( rNode.mfAcceleration ),
456 mfDecelerate( rNode.mfDecelerate ),
457 mbAutoReverse( rNode.mbAutoReverse ),
458 maUserData( rNode.maUserData ),
460 // attributes for XAnimate
461 maTarget( rNode.maTarget ),
462 maAttributeName( rNode.maAttributeName ),
463 maFormula( rNode.maFormula ),
464 maValues( rNode.maValues ),
465 maKeyTimes( rNode.maKeyTimes ),
466 mnValueType( rNode.mnValueType ),
467 mnSubItem( rNode.mnSubItem ),
468 mnCalcMode( rNode.mnCalcMode ),
469 mnAdditive( rNode.mnAdditive ),
470 mbAccumulate( rNode.mbAccumulate ),
471 maFrom( rNode.maFrom ),
472 maTo( rNode.maTo ),
473 maBy( rNode.maBy ),
474 maTimeFilter( rNode.maTimeFilter ),
476 // attributes for XAnimateColor
477 mnColorSpace( rNode.mnColorSpace ),
478 mbDirection( rNode.mbDirection ),
480 // attributes for XAnimateMotion
481 maPath( rNode.maPath ),
482 maOrigin( rNode.maOrigin ),
484 // attributes for XAnimatePhysics
485 maStartVelocityX( rNode.maStartVelocityX ),
486 maStartVelocityY( rNode.maStartVelocityY ),
487 maDensity( rNode.maDensity ),
488 maBounciness( rNode.maBounciness ),
490 // attributes for XAnimateTransform
491 mnTransformType( rNode.mnTransformType ),
493 // attributes for XTransitionFilter
494 mnTransition( rNode.mnTransition ),
495 mnSubtype( rNode.mnSubtype ),
496 mbMode( rNode.mbMode ),
497 mnFadeColor( rNode.mnFadeColor ),
499 // XAudio
500 mfVolume( rNode.mfVolume ),
501 mbHideDuringShow(rNode.mbHideDuringShow),
502 mbNarration(rNode.mbNarration),
504 // XCommand
505 mnCommand( rNode.mnCommand ),
506 maParameter( rNode.maParameter ),
508 // XIterateContainer
509 mnIterateType( rNode.mnIterateType ),
510 mfIterateInterval( rNode.mfIterateInterval )
514 static Sequence<OUString> getSupportedServiceNames_PAR()
516 return { "com.sun.star.animations.ParallelTimeContainer" };
519 static OUString getImplementationName_PAR()
521 return "animcore::ParallelTimeContainer";
524 static Sequence<OUString> getSupportedServiceNames_SEQ()
526 return { "com.sun.star.animations.SequenceTimeContainer" };
529 static OUString getImplementationName_SEQ()
531 return "animcore::SequenceTimeContainer";
534 static Sequence<OUString> getSupportedServiceNames_ITERATE()
536 return { "com.sun.star.animations.IterateContainer" };
539 static OUString getImplementationName_ITERATE()
541 return "animcore::IterateContainer";
544 static Sequence<OUString> getSupportedServiceNames_ANIMATE()
546 return { "com.sun.star.animations.Animate" };
549 static OUString getImplementationName_ANIMATE()
551 return "animcore::Animate";
554 static Sequence<OUString> getSupportedServiceNames_SET()
556 return { "com.sun.star.animations.AnimateSet" };
559 static OUString getImplementationName_SET()
561 return "animcore::AnimateSet";
564 static Sequence<OUString> getSupportedServiceNames_ANIMATECOLOR()
566 return { "com.sun.star.animations.AnimateColor" };
569 static OUString getImplementationName_ANIMATECOLOR()
571 return "animcore::AnimateColor";
574 static Sequence<OUString> getSupportedServiceNames_ANIMATEMOTION()
576 return { "com.sun.star.animations.AnimateMotion" };
579 static OUString getImplementationName_ANIMATEMOTION()
581 return "animcore::AnimateMotion";
584 static Sequence<OUString> getSupportedServiceNames_ANIMATEPHYSICS()
586 return { "com.sun.star.animations.AnimatePhysics" };
589 static OUString getImplementationName_ANIMATEPHYSICS()
591 return "animcore::AnimatePhysics";
594 static Sequence<OUString> getSupportedServiceNames_ANIMATETRANSFORM()
596 return { "com.sun.star.animations.AnimateTransform" };
599 static OUString getImplementationName_ANIMATETRANSFORM()
601 return "animcore::AnimateTransform";
604 static Sequence<OUString> getSupportedServiceNames_TRANSITIONFILTER()
606 return { "com.sun.star.animations.TransitionFilter" };
609 static OUString getImplementationName_TRANSITIONFILTER()
611 return "animcore::TransitionFilter";
614 static Sequence<OUString> getSupportedServiceNames_AUDIO()
616 return { "com.sun.star.animations.Audio" };
619 static OUString getImplementationName_AUDIO()
621 return "animcore::Audio";
624 static Sequence<OUString> getSupportedServiceNames_COMMAND()
626 return { "com.sun.star.animations.Command" };
629 static OUString getImplementationName_COMMAND()
631 return "animcore::Command";
634 // XInterface
635 Any SAL_CALL AnimationNode::queryInterface( const Type& aType )
637 Any aRet( ::cppu::queryInterface(
638 aType,
639 static_cast< XServiceInfo * >( this ),
640 static_cast< XTypeProvider * >( this ),
641 static_cast< XChild * >( static_cast< XTimeContainer * >( static_cast< XIterateContainer * >(this) ) ),
642 static_cast< XCloneable* >( this ),
643 static_cast< XAnimationNode* >( static_cast< XTimeContainer * >( static_cast< XIterateContainer * >(this) ) ),
644 static_cast< XInterface* >(static_cast< OWeakObject * >(this)),
645 static_cast< XWeak* >(static_cast< OWeakObject * >(this)),
646 static_cast< XChangesNotifier* >( this ) ) );
648 if(!aRet.hasValue())
650 switch( mnNodeType )
652 case AnimationNodeType::PAR:
653 aRet = ::cppu::queryInterface(
654 aType,
655 static_cast< XParallelTimeContainer * >( this ),
656 static_cast< XTimeContainer * >( static_cast< XIterateContainer * >(this) ),
657 static_cast< XEnumerationAccess * >( this ),
658 static_cast< XElementAccess * >( this ) );
659 break;
660 case AnimationNodeType::SEQ:
661 aRet = ::cppu::queryInterface(
662 aType,
663 static_cast< XTimeContainer * >( static_cast< XIterateContainer * >(this) ),
664 static_cast< XEnumerationAccess * >( this ),
665 static_cast< XElementAccess * >( this ) );
666 break;
667 case AnimationNodeType::ITERATE:
668 aRet = ::cppu::queryInterface(
669 aType,
670 static_cast< XTimeContainer * >( static_cast< XIterateContainer * >(this) ),
671 static_cast< XIterateContainer * >( this ),
672 static_cast< XEnumerationAccess * >( this ),
673 static_cast< XElementAccess * >( this ) );
674 break;
675 case AnimationNodeType::ANIMATE:
676 aRet = ::cppu::queryInterface(
677 aType,
678 static_cast< XAnimate * >( static_cast< XAnimateMotion * >(this) ) );
679 break;
680 case AnimationNodeType::ANIMATEMOTION:
681 aRet = ::cppu::queryInterface(
682 aType,
683 static_cast< XAnimate * >( static_cast< XAnimateMotion * >(this) ),
684 static_cast< XAnimateMotion * >( this ) );
685 break;
686 case AnimationNodeType::ANIMATEPHYSICS:
687 aRet = ::cppu::queryInterface(
688 aType,
689 static_cast< XAnimate * >( static_cast< XAnimatePhysics * >(this) ),
690 static_cast< XAnimatePhysics * >( this ) );
691 break;
692 case AnimationNodeType::ANIMATECOLOR:
693 aRet = ::cppu::queryInterface(
694 aType,
695 static_cast< XAnimate * >( static_cast< XAnimateColor * >(this) ),
696 static_cast< XAnimateColor * >( this ) );
697 break;
698 case AnimationNodeType::SET:
699 aRet = ::cppu::queryInterface(
700 aType,
701 static_cast< XAnimate * >( static_cast< XAnimateSet * >(this) ),
702 static_cast< XAnimateSet * >( this ) );
703 break;
704 case AnimationNodeType::ANIMATETRANSFORM:
705 aRet = ::cppu::queryInterface(
706 aType,
707 static_cast< XAnimate * >( static_cast< XAnimateTransform * >(this) ),
708 static_cast< XAnimateTransform * >( this ) );
709 break;
710 case AnimationNodeType::AUDIO:
711 aRet = ::cppu::queryInterface(aType, static_cast< XAudio * >(this) );
712 break;
713 case AnimationNodeType::COMMAND:
714 aRet = ::cppu::queryInterface(
715 aType, static_cast< XCommand * >(this) );
716 break;
717 case AnimationNodeType::TRANSITIONFILTER:
718 aRet = ::cppu::queryInterface(
719 aType,
720 static_cast< XAnimate * >( static_cast< XTransitionFilter * >(this) ),
721 static_cast< XTransitionFilter * >( this ) );
722 break;
726 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( aType );
730 void AnimationNode::initTypeProvider( sal_Int16 nNodeType ) noexcept
732 static std::mutex aMutex;
734 std::scoped_lock aGuard(aMutex);
736 if( mpTypes[nNodeType] )
737 return;
739 static constexpr std::array<sal_Int32, mpTypes.size()> type_numbers =
741 6, // CUSTOM
742 8, // PAR
743 8, // SEQ
744 8, // ITERATE
745 7, // ANIMATE
746 7, // SET
747 7, // ANIMATEMOTION
748 7, // ANIMATECOLOR
749 7, // ANIMATETRANSFORM
750 7, // TRANSITIONFILTER
751 7, // AUDIO
752 7, // COMMAND
753 7, // ANIMATEPHYSICS
756 // collect types
757 Sequence< Type > * types = new Sequence< Type >( type_numbers[nNodeType] );
758 Type * pTypeAr = types->getArray();
759 sal_Int32 nPos = 0;
761 pTypeAr[nPos++] = cppu::UnoType<XWeak>::get();
762 pTypeAr[nPos++] = cppu::UnoType<XChild>::get();
763 pTypeAr[nPos++] = cppu::UnoType<XCloneable>::get();
764 pTypeAr[nPos++] = cppu::UnoType<XTypeProvider>::get();
765 pTypeAr[nPos++] = cppu::UnoType<XServiceInfo>::get();
766 pTypeAr[nPos++] = cppu::UnoType<XChangesNotifier>::get();
768 switch( nNodeType )
770 case AnimationNodeType::PAR:
771 case AnimationNodeType::SEQ:
772 pTypeAr[nPos++] = cppu::UnoType<XTimeContainer>::get();
773 pTypeAr[nPos++] = cppu::UnoType<XEnumerationAccess>::get();
774 break;
775 case AnimationNodeType::ITERATE:
776 pTypeAr[nPos++] = cppu::UnoType<XIterateContainer>::get();
777 pTypeAr[nPos++] = cppu::UnoType<XEnumerationAccess>::get();
778 break;
779 case AnimationNodeType::ANIMATE:
780 pTypeAr[nPos++] = cppu::UnoType<XAnimate>::get();
781 break;
782 case AnimationNodeType::ANIMATEMOTION:
783 pTypeAr[nPos++] = cppu::UnoType<XAnimateMotion>::get();
784 break;
785 case AnimationNodeType::ANIMATEPHYSICS:
786 pTypeAr[nPos++] = cppu::UnoType<XAnimatePhysics>::get();
787 break;
788 case AnimationNodeType::ANIMATECOLOR:
789 pTypeAr[nPos++] = cppu::UnoType<XAnimateColor>::get();
790 break;
791 case AnimationNodeType::ANIMATETRANSFORM:
792 pTypeAr[nPos++] = cppu::UnoType<XAnimateTransform>::get();
793 break;
794 case AnimationNodeType::SET:
795 pTypeAr[nPos++] = cppu::UnoType<XAnimateSet>::get();
796 break;
797 case AnimationNodeType::TRANSITIONFILTER:
798 pTypeAr[nPos++] = cppu::UnoType<XTransitionFilter>::get();
799 break;
800 case AnimationNodeType::AUDIO:
801 pTypeAr[nPos++] = cppu::UnoType<XAudio>::get();
802 break;
803 case AnimationNodeType::COMMAND:
804 pTypeAr[nPos++] = cppu::UnoType<XCommand>::get();
805 break;
807 mpTypes[nNodeType] = types;
811 Sequence< Type > AnimationNode::getTypes()
813 if (! mpTypes[mnNodeType])
814 initTypeProvider(mnNodeType);
815 return *mpTypes[mnNodeType];
819 Sequence< sal_Int8 > AnimationNode::getImplementationId()
821 return css::uno::Sequence<sal_Int8>();
825 // XInterface
826 void SAL_CALL AnimationNode::acquire( ) noexcept
828 OWeakObject::acquire();
832 // XInterface
833 void SAL_CALL AnimationNode::release( ) noexcept
835 OWeakObject::release();
839 // XServiceInfo
840 OUString AnimationNode::getImplementationName()
842 switch( mnNodeType )
844 case AnimationNodeType::PAR:
845 return getImplementationName_PAR();
846 case AnimationNodeType::SEQ:
847 return getImplementationName_SEQ();
848 case AnimationNodeType::ITERATE:
849 return getImplementationName_ITERATE();
850 case AnimationNodeType::SET:
851 return getImplementationName_SET();
852 case AnimationNodeType::ANIMATECOLOR:
853 return getImplementationName_ANIMATECOLOR();
854 case AnimationNodeType::ANIMATEMOTION:
855 return getImplementationName_ANIMATEMOTION();
856 case AnimationNodeType::ANIMATEPHYSICS:
857 return getImplementationName_ANIMATEPHYSICS();
858 case AnimationNodeType::TRANSITIONFILTER:
859 return getImplementationName_TRANSITIONFILTER();
860 case AnimationNodeType::ANIMATETRANSFORM:
861 return getImplementationName_ANIMATETRANSFORM();
862 case AnimationNodeType::AUDIO:
863 return getImplementationName_AUDIO();
864 case AnimationNodeType::COMMAND:
865 return getImplementationName_COMMAND();
866 case AnimationNodeType::ANIMATE:
867 default:
868 return getImplementationName_ANIMATE();
872 // XServiceInfo
873 sal_Bool AnimationNode::supportsService(const OUString& ServiceName)
875 return cppu::supportsService(this, ServiceName);
878 // XServiceInfo
879 Sequence< OUString > AnimationNode::getSupportedServiceNames()
881 switch( mnNodeType )
883 case AnimationNodeType::PAR:
884 return getSupportedServiceNames_PAR();
885 case AnimationNodeType::SEQ:
886 return getSupportedServiceNames_SEQ();
887 case AnimationNodeType::ITERATE:
888 return getSupportedServiceNames_ITERATE();
889 case AnimationNodeType::SET:
890 return getSupportedServiceNames_SET();
891 case AnimationNodeType::ANIMATECOLOR:
892 return getSupportedServiceNames_ANIMATECOLOR();
893 case AnimationNodeType::ANIMATEMOTION:
894 return getSupportedServiceNames_ANIMATEMOTION();
895 case AnimationNodeType::ANIMATEPHYSICS:
896 return getSupportedServiceNames_ANIMATEPHYSICS();
897 case AnimationNodeType::TRANSITIONFILTER:
898 return getSupportedServiceNames_TRANSITIONFILTER();
899 case AnimationNodeType::ANIMATETRANSFORM:
900 return getSupportedServiceNames_ANIMATETRANSFORM();
901 case AnimationNodeType::AUDIO:
902 return getSupportedServiceNames_AUDIO();
903 case AnimationNodeType::COMMAND:
904 return getSupportedServiceNames_COMMAND();
905 case AnimationNodeType::ANIMATE:
906 default:
907 return getSupportedServiceNames_ANIMATE();
912 // XAnimationNode
913 sal_Int16 SAL_CALL AnimationNode::getType()
915 std::unique_lock aGuard( m_aMutex );
916 return mnNodeType;
920 // XAnimationNode
921 Any SAL_CALL AnimationNode::getBegin()
923 std::unique_lock aGuard( m_aMutex );
924 return maBegin;
928 // XAnimationNode
929 void SAL_CALL AnimationNode::setBegin( const Any& _begin )
931 std::unique_lock aGuard( m_aMutex );
932 if( _begin != maBegin )
934 maBegin = _begin;
935 fireChangeListener(aGuard);
940 // XAnimationNode
941 Any SAL_CALL AnimationNode::getDuration()
943 std::unique_lock aGuard( m_aMutex );
944 return maDuration;
948 // XAnimationNode
949 void SAL_CALL AnimationNode::setDuration( const Any& _duration )
951 std::unique_lock aGuard( m_aMutex );
952 if( _duration != maDuration )
954 maDuration = _duration;
955 fireChangeListener(aGuard);
960 // XAnimationNode
961 Any SAL_CALL AnimationNode::getEnd()
963 std::unique_lock aGuard( m_aMutex );
964 return maEnd;
968 // XAnimationNode
969 void SAL_CALL AnimationNode::setEnd( const Any& _end )
971 std::unique_lock aGuard( m_aMutex );
972 if( _end != maEnd )
974 maEnd = _end;
975 fireChangeListener(aGuard);
980 // XAnimationNode
981 Any SAL_CALL AnimationNode::getEndSync()
983 std::unique_lock aGuard( m_aMutex );
984 return maEndSync;
988 // XAnimationNode
989 void SAL_CALL AnimationNode::setEndSync( const Any& _endsync )
991 std::unique_lock l( m_aMutex );
992 if( _endsync != maEndSync )
994 maEndSync = _endsync;
995 fireChangeListener(l);
1000 // XAnimationNode
1001 Any SAL_CALL AnimationNode::getRepeatCount()
1003 std::unique_lock aGuard( m_aMutex );
1004 return maRepeatCount;
1008 // XAnimationNode
1009 void SAL_CALL AnimationNode::setRepeatCount( const Any& _repeatcount )
1011 std::unique_lock l( m_aMutex );
1012 if( _repeatcount != maRepeatCount )
1014 maRepeatCount = _repeatcount;
1015 fireChangeListener(l);
1020 // XAnimationNode
1021 Any SAL_CALL AnimationNode::getRepeatDuration()
1023 std::unique_lock aGuard( m_aMutex );
1024 return maRepeatDuration;
1028 // XAnimationNode
1029 void SAL_CALL AnimationNode::setRepeatDuration( const Any& _repeatduration )
1031 std::unique_lock l( m_aMutex );
1032 if( _repeatduration != maRepeatDuration )
1034 maRepeatDuration = _repeatduration;
1035 fireChangeListener(l);
1040 // XAnimationNode
1041 sal_Int16 SAL_CALL AnimationNode::getFill()
1043 std::unique_lock aGuard( m_aMutex );
1044 return mnFill;
1048 // XAnimationNode
1049 void SAL_CALL AnimationNode::setFill( sal_Int16 _fill )
1051 std::unique_lock l( m_aMutex );
1052 if( _fill != mnFill )
1054 mnFill = _fill;
1055 fireChangeListener(l);
1060 // XAnimationNode
1061 sal_Int16 SAL_CALL AnimationNode::getFillDefault()
1063 std::unique_lock aGuard( m_aMutex );
1064 return mnFillDefault;
1068 // XAnimationNode
1069 void SAL_CALL AnimationNode::setFillDefault( sal_Int16 _filldefault )
1071 std::unique_lock l( m_aMutex );
1072 if( _filldefault != mnFillDefault )
1074 mnFillDefault = _filldefault;
1075 fireChangeListener(l);
1080 // XAnimationNode
1081 sal_Int16 SAL_CALL AnimationNode::getRestart()
1083 std::unique_lock aGuard( m_aMutex );
1084 return mnRestart;
1088 // XAnimationNode
1089 void SAL_CALL AnimationNode::setRestart( sal_Int16 _restart )
1091 std::unique_lock l( m_aMutex );
1092 if( _restart != mnRestart )
1094 mnRestart = _restart;
1095 fireChangeListener(l);
1100 // XAnimationNode
1101 sal_Int16 SAL_CALL AnimationNode::getRestartDefault()
1103 std::unique_lock aGuard( m_aMutex );
1104 return mnRestartDefault;
1108 // XAnimationNode
1109 void SAL_CALL AnimationNode::setRestartDefault( sal_Int16 _restartdefault )
1111 std::unique_lock l( m_aMutex );
1112 if( _restartdefault != mnRestartDefault )
1114 mnRestartDefault = _restartdefault;
1115 fireChangeListener(l);
1120 // XAnimationNode
1121 double SAL_CALL AnimationNode::getAcceleration()
1123 std::unique_lock aGuard( m_aMutex );
1124 return mfAcceleration;
1128 // XAnimationNode
1129 void SAL_CALL AnimationNode::setAcceleration( double _acceleration )
1131 std::unique_lock l( m_aMutex );
1132 if( _acceleration != mfAcceleration )
1134 mfAcceleration = _acceleration;
1135 fireChangeListener(l);
1140 // XAnimationNode
1141 double SAL_CALL AnimationNode::getDecelerate()
1143 std::unique_lock aGuard( m_aMutex );
1144 return mfDecelerate;
1148 // XAnimationNode
1149 void SAL_CALL AnimationNode::setDecelerate( double _decelerate )
1151 std::unique_lock l( m_aMutex );
1152 if( _decelerate != mfDecelerate )
1154 mfDecelerate = _decelerate;
1155 fireChangeListener(l);
1160 // XAnimationNode
1161 sal_Bool SAL_CALL AnimationNode::getAutoReverse()
1163 std::unique_lock aGuard( m_aMutex );
1164 return mbAutoReverse;
1168 // XAnimationNode
1169 void SAL_CALL AnimationNode::setAutoReverse( sal_Bool _autoreverse )
1171 std::unique_lock l( m_aMutex );
1172 if( bool(_autoreverse) != mbAutoReverse )
1174 mbAutoReverse = _autoreverse;
1175 fireChangeListener(l);
1180 Sequence< NamedValue > SAL_CALL AnimationNode::getUserData()
1182 std::unique_lock aGuard( m_aMutex );
1183 return maUserData;
1187 void SAL_CALL AnimationNode::setUserData( const Sequence< NamedValue >& _userdata )
1189 std::unique_lock l( m_aMutex );
1190 maUserData = _userdata;
1191 fireChangeListener(l);
1195 // XChild
1196 Reference< XInterface > SAL_CALL AnimationNode::getParent()
1198 std::unique_lock aGuard( m_aMutex );
1199 return static_cast<cppu::OWeakObject*>(mxParent.get().get());
1203 // XChild
1204 void SAL_CALL AnimationNode::setParent( const Reference< XInterface >& Parent )
1206 std::unique_lock l( m_aMutex );
1207 if( Parent.get() != static_cast<cppu::OWeakObject*>(mxParent.get().get()) )
1209 rtl::Reference<AnimationNode> xParent = dynamic_cast<AnimationNode*>(Parent.get());
1210 mxParent = xParent.get();
1211 assert(bool(xParent) == bool(Parent) && "only support AnimationNode subtypes");
1213 fireChangeListener(l);
1218 // XCloneable
1219 Reference< XCloneable > SAL_CALL AnimationNode::createClone()
1221 std::unique_lock aGuard( m_aMutex );
1223 Reference< XCloneable > xNewNode;
1226 xNewNode = new AnimationNode( *this );
1228 if( !maChildren.empty() )
1230 Reference< XTimeContainer > xContainer( xNewNode, UNO_QUERY );
1231 if( xContainer.is() )
1233 for (auto const& child : maChildren)
1235 Reference< XCloneable > xCloneable(child, UNO_QUERY );
1236 if( xCloneable.is() ) try
1238 Reference< XAnimationNode > xNewChildNode( xCloneable->createClone(), UNO_QUERY );
1239 if( xNewChildNode.is() )
1240 xContainer->appendChild( xNewChildNode );
1242 catch(const Exception&)
1244 SAL_INFO("animations", "animations::AnimationNode::createClone(), exception caught!");
1250 catch(const Exception&)
1252 SAL_INFO("animations", "animations::AnimationNode::createClone(), exception caught!");
1255 return xNewNode;
1259 // XAnimate
1260 Any SAL_CALL AnimationNode::getTarget()
1262 std::unique_lock aGuard( m_aMutex );
1263 return maTarget;
1267 // XAnimate
1268 void SAL_CALL AnimationNode::setTarget( const Any& _target )
1270 std::unique_lock l( m_aMutex );
1271 if( _target != maTarget )
1273 maTarget= _target;
1274 fireChangeListener(l);
1279 // XAnimate
1280 OUString SAL_CALL AnimationNode::getAttributeName()
1282 std::unique_lock aGuard( m_aMutex );
1283 return maAttributeName;
1287 // XAnimate
1288 void SAL_CALL AnimationNode::setAttributeName( const OUString& _attribute )
1290 std::unique_lock l( m_aMutex );
1291 if( _attribute != maAttributeName )
1293 maAttributeName = _attribute;
1294 fireChangeListener(l);
1299 // XAnimate
1300 Sequence< Any > SAL_CALL AnimationNode::getValues()
1302 std::unique_lock aGuard( m_aMutex );
1303 return maValues;
1307 // XAnimate
1308 void SAL_CALL AnimationNode::setValues( const Sequence< Any >& _values )
1310 std::unique_lock l( m_aMutex );
1311 maValues = _values;
1312 fireChangeListener(l);
1316 // XAnimate
1317 sal_Int16 SAL_CALL AnimationNode::getSubItem()
1319 std::unique_lock aGuard( m_aMutex );
1320 return mnSubItem;
1324 // XAnimate
1325 void SAL_CALL AnimationNode::setSubItem( sal_Int16 _subitem )
1327 std::unique_lock l( m_aMutex );
1328 if( _subitem != mnSubItem )
1330 mnSubItem = _subitem;
1331 fireChangeListener(l);
1336 // XAnimate
1337 Sequence< double > SAL_CALL AnimationNode::getKeyTimes()
1339 std::unique_lock aGuard( m_aMutex );
1340 return maKeyTimes;
1344 // XAnimate
1345 void SAL_CALL AnimationNode::setKeyTimes( const Sequence< double >& _keytimes )
1347 std::unique_lock l( m_aMutex );
1348 maKeyTimes = _keytimes;
1349 fireChangeListener(l);
1353 // XAnimate
1354 sal_Int16 SAL_CALL AnimationNode::getValueType()
1356 std::unique_lock aGuard( m_aMutex );
1357 return mnValueType;
1361 void SAL_CALL AnimationNode::setValueType( sal_Int16 _valuetype )
1363 std::unique_lock l( m_aMutex );
1364 if( _valuetype != mnValueType )
1366 mnValueType = _valuetype;
1367 fireChangeListener(l);
1372 // XAnimate
1373 sal_Int16 SAL_CALL AnimationNode::getCalcMode()
1375 std::unique_lock aGuard( m_aMutex );
1376 return mnCalcMode;
1380 // XAnimate
1381 void SAL_CALL AnimationNode::setCalcMode( sal_Int16 _calcmode )
1383 std::unique_lock l( m_aMutex );
1384 if( _calcmode != mnCalcMode )
1386 mnCalcMode = _calcmode;
1387 fireChangeListener(l);
1392 // XAnimate
1393 sal_Bool SAL_CALL AnimationNode::getAccumulate()
1395 std::unique_lock aGuard( m_aMutex );
1396 return mbAccumulate;
1400 // XAnimate
1401 void SAL_CALL AnimationNode::setAccumulate( sal_Bool _accumulate )
1403 std::unique_lock l( m_aMutex );
1404 if( bool(_accumulate) != mbAccumulate )
1406 mbAccumulate = _accumulate;
1407 fireChangeListener(l);
1412 // XAnimate
1413 sal_Int16 SAL_CALL AnimationNode::getAdditive()
1415 std::unique_lock aGuard( m_aMutex );
1416 return mnAdditive;
1420 // XAnimate
1421 void SAL_CALL AnimationNode::setAdditive( sal_Int16 _additive )
1423 std::unique_lock l( m_aMutex );
1424 if( _additive != mnAdditive )
1426 mnAdditive = _additive;
1427 fireChangeListener(l);
1432 // XAnimate
1433 Any SAL_CALL AnimationNode::getFrom()
1435 std::unique_lock aGuard( m_aMutex );
1436 return maFrom;
1440 // XAnimate
1441 void SAL_CALL AnimationNode::setFrom( const Any& _from )
1443 std::unique_lock l( m_aMutex );
1444 if( _from != maFrom )
1446 maFrom = _from;
1447 fireChangeListener(l);
1452 // XAnimate
1453 Any SAL_CALL AnimationNode::getTo()
1455 std::unique_lock aGuard( m_aMutex );
1456 return maTo;
1460 // XAnimate
1461 void SAL_CALL AnimationNode::setTo( const Any& _to )
1463 std::unique_lock l( m_aMutex );
1464 if( _to != maTo )
1466 maTo = _to;
1467 fireChangeListener(l);
1472 // XAnimate
1473 Any SAL_CALL AnimationNode::getBy()
1475 std::unique_lock aGuard( m_aMutex );
1476 return maBy;
1480 // XAnimate
1481 void SAL_CALL AnimationNode::setBy( const Any& _by )
1483 std::unique_lock l( m_aMutex );
1484 if( _by != maBy )
1486 maBy = _by;
1487 fireChangeListener(l);
1492 // XAnimate
1493 Sequence< TimeFilterPair > SAL_CALL AnimationNode::getTimeFilter()
1495 std::unique_lock aGuard( m_aMutex );
1496 return maTimeFilter;
1500 // XAnimate
1501 void SAL_CALL AnimationNode::setTimeFilter( const Sequence< TimeFilterPair >& _timefilter )
1503 std::unique_lock l( m_aMutex );
1504 maTimeFilter = _timefilter;
1505 fireChangeListener(l);
1509 OUString SAL_CALL AnimationNode::getFormula()
1511 std::unique_lock aGuard( m_aMutex );
1512 return maFormula;
1516 void SAL_CALL AnimationNode::setFormula( const OUString& _formula )
1518 std::unique_lock l( m_aMutex );
1519 if( _formula != maFormula )
1521 maFormula = _formula;
1522 fireChangeListener(l);
1527 // XAnimateColor
1528 sal_Int16 SAL_CALL AnimationNode::getColorInterpolation()
1530 std::unique_lock aGuard( m_aMutex );
1531 return mnColorSpace;
1535 // XAnimateColor
1536 void SAL_CALL AnimationNode::setColorInterpolation( sal_Int16 _colorspace )
1538 std::unique_lock l( m_aMutex );
1539 if( _colorspace != mnColorSpace )
1541 mnColorSpace = _colorspace;
1542 fireChangeListener(l);
1547 // XAnimateColor
1548 sal_Bool SAL_CALL AnimationNode::getDirection()
1550 std::unique_lock aGuard( m_aMutex );
1551 return mbDirection;
1555 // XAnimateColor
1556 void SAL_CALL AnimationNode::setDirection( sal_Bool _direction )
1558 std::unique_lock l( m_aMutex );
1559 if( bool(_direction) != mbDirection )
1561 mbDirection = _direction;
1562 fireChangeListener(l);
1567 // XAnimateMotion
1568 Any SAL_CALL AnimationNode::getPath()
1570 std::unique_lock aGuard( m_aMutex );
1571 return maPath;
1575 // XAnimateMotion
1576 void SAL_CALL AnimationNode::setPath( const Any& _path )
1578 std::unique_lock l( m_aMutex );
1579 maPath = _path;
1580 fireChangeListener(l);
1584 // XAnimateMotion
1585 Any SAL_CALL AnimationNode::getOrigin()
1587 std::unique_lock aGuard( m_aMutex );
1588 return maOrigin;
1592 // XAnimateMotion
1593 void SAL_CALL AnimationNode::setOrigin( const Any& _origin )
1595 std::unique_lock l( m_aMutex );
1596 maOrigin = _origin;
1597 fireChangeListener(l);
1600 // XAnimatePhysics
1601 Any SAL_CALL AnimationNode::getStartVelocityX()
1603 std::unique_lock aGuard( m_aMutex );
1604 return maStartVelocityX;
1608 // XAnimatePhysics
1609 void SAL_CALL AnimationNode::setStartVelocityX( const Any& _startvelocityx )
1611 std::unique_lock l( m_aMutex );
1612 maStartVelocityX = _startvelocityx;
1613 fireChangeListener(l);
1616 // XAnimatePhysics
1617 Any SAL_CALL AnimationNode::getStartVelocityY()
1619 std::unique_lock aGuard( m_aMutex );
1620 return maStartVelocityY;
1624 // XAnimatePhysics
1625 void SAL_CALL AnimationNode::setStartVelocityY( const Any& _startvelocityy )
1627 std::unique_lock l( m_aMutex );
1628 maStartVelocityY = _startvelocityy;
1629 fireChangeListener(l);
1633 // XAnimatePhysics
1634 Any SAL_CALL AnimationNode::getDensity()
1636 std::unique_lock aGuard( m_aMutex );
1637 return maDensity;
1641 // XAnimatePhysics
1642 void SAL_CALL AnimationNode::setDensity( const Any& _density )
1644 std::unique_lock l( m_aMutex );
1645 maDensity = _density;
1646 fireChangeListener(l);
1650 // XAnimatePhysics
1651 Any SAL_CALL AnimationNode::getBounciness()
1653 std::unique_lock aGuard( m_aMutex );
1654 return maBounciness;
1658 // XAnimatePhysics
1659 void SAL_CALL AnimationNode::setBounciness( const Any& _bounciness )
1661 std::unique_lock l( m_aMutex );
1662 maBounciness = _bounciness;
1663 fireChangeListener(l);
1667 // XAnimateTransform
1668 sal_Int16 SAL_CALL AnimationNode::getTransformType()
1670 std::unique_lock aGuard( m_aMutex );
1671 return mnTransformType;
1675 // XAnimateTransform
1676 void SAL_CALL AnimationNode::setTransformType( sal_Int16 _transformtype )
1678 std::unique_lock l( m_aMutex );
1679 if( _transformtype != mnTransformType )
1681 mnTransformType = _transformtype;
1682 fireChangeListener(l);
1687 // XTransitionFilter
1688 sal_Int16 SAL_CALL AnimationNode::getTransition()
1690 std::unique_lock aGuard( m_aMutex );
1691 return mnTransition;
1695 // XTransitionFilter
1696 void SAL_CALL AnimationNode::setTransition( sal_Int16 _transition )
1698 std::unique_lock l( m_aMutex );
1699 if( _transition != mnTransition )
1701 mnTransition = _transition;
1702 fireChangeListener(l);
1707 // XTransitionFilter
1708 sal_Int16 SAL_CALL AnimationNode::getSubtype()
1710 std::unique_lock aGuard( m_aMutex );
1711 return mnSubtype;
1715 // XTransitionFilter
1716 void SAL_CALL AnimationNode::setSubtype( sal_Int16 _subtype )
1718 std::unique_lock l( m_aMutex );
1719 if( _subtype != mnSubtype )
1721 mnSubtype = _subtype;
1722 fireChangeListener(l);
1727 // XTransitionFilter
1728 sal_Bool SAL_CALL AnimationNode::getMode()
1730 std::unique_lock aGuard( m_aMutex );
1731 return mbMode;
1735 // XTransitionFilter
1736 void SAL_CALL AnimationNode::setMode( sal_Bool _mode )
1738 std::unique_lock l( m_aMutex );
1739 if( bool(_mode) != mbMode )
1741 mbMode = _mode;
1742 fireChangeListener(l);
1747 // XTransitionFilter
1748 sal_Int32 SAL_CALL AnimationNode::getFadeColor()
1750 std::unique_lock aGuard( m_aMutex );
1751 return mnFadeColor;
1755 // XTransitionFilter
1756 void SAL_CALL AnimationNode::setFadeColor( sal_Int32 _fadecolor )
1758 std::unique_lock l( m_aMutex );
1759 if( _fadecolor != mnFadeColor )
1761 mnFadeColor = _fadecolor;
1762 fireChangeListener(l);
1767 // XAudio
1768 Any SAL_CALL AnimationNode::getSource()
1770 std::unique_lock aGuard( m_aMutex );
1771 return maTarget;
1775 // XAudio
1776 void SAL_CALL AnimationNode::setSource( const Any& _source )
1778 std::unique_lock l( m_aMutex );
1779 maTarget = _source;
1780 fireChangeListener(l);
1784 // XAudio
1785 double SAL_CALL AnimationNode::getVolume()
1787 std::unique_lock aGuard( m_aMutex );
1788 return mfVolume;
1792 // XAudio
1793 void SAL_CALL AnimationNode::setVolume( double _volume )
1795 std::unique_lock l( m_aMutex );
1796 if( _volume != mfVolume )
1798 mfVolume = _volume;
1799 fireChangeListener(l);
1803 sal_Bool SAL_CALL AnimationNode::getHideDuringShow()
1805 std::unique_lock aGuard(m_aMutex);
1806 return mbHideDuringShow;
1809 void SAL_CALL AnimationNode::setHideDuringShow(sal_Bool bHideDuringShow)
1811 std::unique_lock l(m_aMutex);
1812 if (static_cast<bool>(bHideDuringShow) != mbHideDuringShow)
1814 mbHideDuringShow = bHideDuringShow;
1815 fireChangeListener(l);
1819 sal_Bool SAL_CALL AnimationNode::getNarration()
1821 std::unique_lock aGuard(m_aMutex);
1822 return mbNarration;
1825 void SAL_CALL AnimationNode::setNarration(sal_Bool bNarration)
1827 std::unique_lock l(m_aMutex);
1828 if (static_cast<bool>(bNarration) != mbNarration)
1830 mbNarration = bNarration;
1831 fireChangeListener(l);
1835 // XCommand
1836 sal_Int16 SAL_CALL AnimationNode::getCommand()
1838 std::unique_lock aGuard( m_aMutex );
1839 return mnCommand;
1843 // XCommand
1844 void SAL_CALL AnimationNode::setCommand( sal_Int16 _command )
1846 std::unique_lock l( m_aMutex );
1847 if( _command != mnCommand )
1849 mnCommand = _command;
1850 fireChangeListener(l);
1855 // XCommand
1856 Any SAL_CALL AnimationNode::getParameter()
1858 std::unique_lock aGuard( m_aMutex );
1859 return maParameter;
1863 // XCommand
1864 void SAL_CALL AnimationNode::setParameter( const Any& _parameter )
1866 std::unique_lock l( m_aMutex );
1867 maParameter = _parameter;
1868 fireChangeListener(l);
1872 // XElementAccess
1873 Type SAL_CALL AnimationNode::getElementType()
1875 return cppu::UnoType<XAnimationNode>::get();
1879 // XElementAccess
1880 sal_Bool SAL_CALL AnimationNode::hasElements()
1882 std::unique_lock aGuard( m_aMutex );
1883 return !maChildren.empty();
1887 // XEnumerationAccess
1888 Reference< XEnumeration > SAL_CALL AnimationNode::createEnumeration()
1890 std::unique_lock aGuard( m_aMutex );
1892 return new TimeContainerEnumeration(std::vector(maChildren));
1896 // XTimeContainer
1897 Reference< XAnimationNode > SAL_CALL AnimationNode::insertBefore( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild )
1899 std::unique_lock l( m_aMutex );
1901 if( !newChild.is() || !refChild.is() )
1902 throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), -1);
1904 if( std::find(maChildren.begin(), maChildren.end(), newChild) != maChildren.end() )
1905 throw ElementExistException();
1907 auto before = std::find(maChildren.begin(), maChildren.end(), refChild);
1908 if( before == maChildren.end() )
1909 throw NoSuchElementException();
1911 maChildren.insert( before, newChild );
1913 Reference< XInterface > xThis( static_cast< OWeakObject * >(this) );
1914 l.unlock();
1915 newChild->setParent( xThis );
1917 return newChild;
1921 // XTimeContainer
1922 Reference< XAnimationNode > SAL_CALL AnimationNode::insertAfter( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild )
1924 std::unique_lock l( m_aMutex );
1926 if( !newChild.is() || !refChild.is() )
1927 throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), -1);
1929 if( std::find(maChildren.begin(), maChildren.end(), newChild) != maChildren.end() )
1930 throw ElementExistException();
1932 auto before = std::find(maChildren.begin(), maChildren.end(), refChild);
1933 if( before == maChildren.end() )
1934 throw NoSuchElementException();
1936 ++before;
1937 if( before != maChildren.end() )
1938 maChildren.insert( before, newChild );
1939 else
1940 maChildren.push_back( newChild );
1942 Reference< XInterface > xThis( static_cast< OWeakObject * >(this) );
1943 l.unlock();
1944 newChild->setParent( xThis );
1946 return newChild;
1950 // XTimeContainer
1951 Reference< XAnimationNode > SAL_CALL AnimationNode::replaceChild( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& oldChild )
1953 std::unique_lock l( m_aMutex );
1955 if( !newChild.is() || !oldChild.is() )
1956 throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), -1);
1958 if( std::find(maChildren.begin(), maChildren.end(), newChild) != maChildren.end() )
1959 throw ElementExistException();
1961 auto replace = std::find(maChildren.begin(), maChildren.end(), oldChild);
1962 if( replace == maChildren.end() )
1963 throw NoSuchElementException();
1965 (*replace) = newChild;
1967 Reference< XInterface > xThis( static_cast< OWeakObject * >(this) );
1968 l.unlock();
1969 oldChild->setParent( Reference< XInterface >() );
1970 newChild->setParent( xThis );
1972 return newChild;
1976 // XTimeContainer
1977 Reference< XAnimationNode > SAL_CALL AnimationNode::removeChild( const Reference< XAnimationNode >& oldChild )
1979 std::unique_lock l( m_aMutex );
1981 if( !oldChild.is() )
1982 throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), 1);
1984 auto old = std::find(maChildren.begin(), maChildren.end(), oldChild);
1985 if( old == maChildren.end() )
1986 throw NoSuchElementException();
1988 maChildren.erase( old );
1990 l.unlock();
1991 oldChild->setParent( Reference< XInterface >() );
1993 return oldChild;
1997 // XTimeContainer
1998 Reference< XAnimationNode > SAL_CALL AnimationNode::appendChild( const Reference< XAnimationNode >& newChild )
2000 Reference< XInterface > xThis( static_cast< OWeakObject * >(this) );
2002 std::unique_lock aGuard( m_aMutex );
2004 if( !newChild.is() )
2005 throw IllegalArgumentException("no child", xThis, 1);
2007 if( std::find(maChildren.begin(), maChildren.end(), newChild) != maChildren.end() )
2008 throw ElementExistException({}, xThis);
2010 if( xThis == newChild )
2011 throw IllegalArgumentException("cannot append self", xThis, -1);
2013 maChildren.push_back( newChild );
2015 newChild->setParent( xThis );
2017 return newChild;
2021 // XIterateContainer
2022 sal_Int16 SAL_CALL AnimationNode::getIterateType()
2024 std::unique_lock aGuard( m_aMutex );
2025 return mnIterateType;
2029 // XIterateContainer
2030 void SAL_CALL AnimationNode::setIterateType( sal_Int16 _iteratetype )
2032 std::unique_lock l( m_aMutex );
2033 if( _iteratetype != mnIterateType )
2035 mnIterateType = _iteratetype;
2036 fireChangeListener(l);
2041 // XIterateContainer
2042 double SAL_CALL AnimationNode::getIterateInterval()
2044 std::unique_lock aGuard( m_aMutex );
2045 return mfIterateInterval;
2049 // XIterateContainer
2050 void SAL_CALL AnimationNode::setIterateInterval( double _iterateinterval )
2052 std::unique_lock l( m_aMutex );
2053 if( _iterateinterval != mfIterateInterval )
2055 mfIterateInterval = _iterateinterval;
2056 fireChangeListener(l);
2061 // XChangesNotifier
2062 void SAL_CALL AnimationNode::addChangesListener( const Reference< XChangesListener >& aListener )
2064 std::unique_lock l( m_aMutex );
2065 maChangeListener.addInterface( l, aListener );
2069 // XChangesNotifier
2070 void SAL_CALL AnimationNode::removeChangesListener( const Reference< XChangesListener >& aListener )
2072 std::unique_lock l( m_aMutex );
2073 maChangeListener.removeInterface(l, aListener);
2077 void AnimationNode::fireChangeListener(std::unique_lock<std::mutex>& l)
2079 if( maChangeListener.getLength(l) != 0 )
2081 Reference< XInterface > xSource( static_cast<OWeakObject*>(this), UNO_QUERY );
2082 Sequence< ElementChange > aChanges;
2083 const ChangesEvent aEvent( xSource, Any( css::uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(mxParent.get().get())) ), aChanges );
2084 OInterfaceIteratorHelper4 aIterator( l, maChangeListener );
2085 l.unlock();
2086 while( aIterator.hasMoreElements() )
2087 aIterator.next()->changesOccurred( aEvent );
2088 l.lock();
2091 //fdo#69645 use WeakReference of mxParent to test if mpParent is still valid
2092 rtl::Reference<AnimationNode> xGuard(mxParent);
2093 if (xGuard.is())
2095 l.unlock();
2096 std::unique_lock l2(xGuard->m_aMutex);
2097 xGuard->fireChangeListener(l2);
2102 } // namespace animcore
2105 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2106 com_sun_star_animations_ParallelTimeContainer_get_implementation(css::uno::XComponentContext*,
2107 css::uno::Sequence<css::uno::Any> const &)
2109 return cppu::acquire(new animcore::AnimationNode(PAR));
2112 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2113 com_sun_star_animations_SequenceTimeContainer_get_implementation(css::uno::XComponentContext*,
2114 css::uno::Sequence<css::uno::Any> const &)
2116 return cppu::acquire(new animcore::AnimationNode(SEQ));
2119 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2120 com_sun_star_animations_IterateContainer_get_implementation(css::uno::XComponentContext*,
2121 css::uno::Sequence<css::uno::Any> const &)
2123 return cppu::acquire(new animcore::AnimationNode(ITERATE));
2126 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2127 com_sun_star_animations_Animate_get_implementation(css::uno::XComponentContext*,
2128 css::uno::Sequence<css::uno::Any> const &)
2130 return cppu::acquire(new animcore::AnimationNode(ANIMATE));
2133 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2134 com_sun_star_animations_AnimateSet_get_implementation(css::uno::XComponentContext*,
2135 css::uno::Sequence<css::uno::Any> const &)
2137 return cppu::acquire(new animcore::AnimationNode(SET));
2140 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2141 com_sun_star_animations_AnimateColor_get_implementation(css::uno::XComponentContext*,
2142 css::uno::Sequence<css::uno::Any> const &)
2144 return cppu::acquire(new animcore::AnimationNode(ANIMATECOLOR));
2147 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2148 com_sun_star_animations_AnimateMotion_get_implementation(css::uno::XComponentContext*,
2149 css::uno::Sequence<css::uno::Any> const &)
2151 return cppu::acquire(new animcore::AnimationNode(ANIMATEMOTION));
2154 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2155 com_sun_star_animations_AnimatePhysics_get_implementation(css::uno::XComponentContext*,
2156 css::uno::Sequence<css::uno::Any> const &)
2158 return cppu::acquire(new animcore::AnimationNode(ANIMATEPHYSICS));
2161 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2162 com_sun_star_animations_AnimateTransform_get_implementation(css::uno::XComponentContext*,
2163 css::uno::Sequence<css::uno::Any> const &)
2165 return cppu::acquire(new animcore::AnimationNode(ANIMATETRANSFORM));
2168 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2169 com_sun_star_animations_TransitionFilter_get_implementation(css::uno::XComponentContext*,
2170 css::uno::Sequence<css::uno::Any> const &)
2172 return cppu::acquire(new animcore::AnimationNode(TRANSITIONFILTER));
2175 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2176 com_sun_star_animations_Audio_get_implementation(css::uno::XComponentContext*,
2177 css::uno::Sequence<css::uno::Any> const &)
2179 return cppu::acquire(new animcore::AnimationNode(AUDIO));
2182 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
2183 com_sun_star_animations_Command_get_implementation(css::uno::XComponentContext*,
2184 css::uno::Sequence<css::uno::Any> const &)
2186 return cppu::acquire(new animcore::AnimationNode(COMMAND));
2189 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */