diff options
Diffstat (limited to 'animations/source/animcore/animcore.cxx')
-rw-r--r-- | animations/source/animcore/animcore.cxx | 533 |
1 files changed, 253 insertions, 280 deletions
diff --git a/animations/source/animcore/animcore.cxx b/animations/source/animcore/animcore.cxx index 5f20fa16139b..9e097ec98733 100644 --- a/animations/source/animcore/animcore.cxx +++ b/animations/source/animcore/animcore.cxx @@ -45,35 +45,29 @@ #include <com/sun/star/container/ElementExistException.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/util/XChangesNotifier.hpp> -#include <com/sun/star/lang/XUnoTunnel.hpp> -#include <comphelper/servicehelper.hxx> #include <cppuhelper/queryinterface.hxx> -#include <comphelper/interfacecontainer3.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <cppuhelper/supportsservice.hxx> -#include <cppuhelper/weakref.hxx> #include <cppuhelper/implbase.hxx> -#include <osl/mutex.hxx> #include <sal/log.hxx> +#include <unotools/weakref.hxx> #include <array> +#include <mutex> #include <vector> #include <algorithm> namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::beans { struct NamedValue; } -using ::osl::Mutex; -using ::osl::Guard; -using ::comphelper::OInterfaceContainerHelper3; -using ::comphelper::OInterfaceIteratorHelper3; +using ::comphelper::OInterfaceContainerHelper4; +using ::comphelper::OInterfaceIteratorHelper4; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::WeakReference; -using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::XWeak; using ::com::sun::star::uno::Type; @@ -87,7 +81,6 @@ using ::com::sun::star::container::XEnumeration; using ::com::sun::star::container::XEnumerationAccess; using ::com::sun::star::beans::NamedValue; using ::com::sun::star::util::XCloneable; -using ::com::sun::star::lang::XUnoTunnel; using ::com::sun::star::util::XChangesNotifier; using ::com::sun::star::util::XChangesListener; using ::com::sun::star::util::ElementChange; @@ -102,7 +95,6 @@ namespace animcore { namespace { - class AnimationNodeBase : public XAnimateMotion, public XAnimatePhysics, public XAnimateColor, @@ -117,15 +109,12 @@ class AnimationNodeBase : public XAnimateMotion, public XCommand, public XCloneable, public XChangesNotifier, - public XUnoTunnel, public OWeakObject { -public: - // our first, last and only protection from multi-threads! - Mutex maMutex; + }; -class AnimationNode final : public AnimationNodeBase +class AnimationNode final: public AnimationNodeBase { public: explicit AnimationNode(sal_Int16 nNodeType); @@ -292,14 +281,11 @@ public: virtual void SAL_CALL addChangesListener( const Reference< XChangesListener >& aListener ) override; virtual void SAL_CALL removeChangesListener( const Reference< XChangesListener >& aListener ) override; - // XUnoTunnel - virtual ::sal_Int64 SAL_CALL getSomething( const Sequence< ::sal_Int8 >& aIdentifier ) override; - - static const Sequence< sal_Int8 > & getUnoTunnelId(); - void fireChangeListener(); + void fireChangeListener(std::unique_lock<std::mutex>&); private: - OInterfaceContainerHelper3<XChangesListener> maChangeListener; + std::mutex m_aMutex; + OInterfaceContainerHelper4<XChangesListener> maChangeListener; static void initTypeProvider( sal_Int16 nNodeType ) noexcept; @@ -316,8 +302,7 @@ private: Sequence< NamedValue > maUserData; // parent interface for XChild interface implementation - WeakReference<XInterface> mxParent; - AnimationNode* mpParent; + unotools::WeakReference<AnimationNode> mxParent; // attributes for XAnimate Any maTarget; @@ -377,14 +362,13 @@ public: virtual Any SAL_CALL nextElement( ) override; private: + std::mutex m_aMutex; + /** sorted list of child nodes */ std::vector< Reference< XAnimationNode > > maChildren; /** current iteration position */ std::vector< Reference< XAnimationNode > >::iterator maIter; - - /** our first, last and only protection from multi-threads! */ - Mutex maMutex; }; } @@ -398,14 +382,14 @@ TimeContainerEnumeration::TimeContainerEnumeration( std::vector< Reference< XAni // Methods sal_Bool SAL_CALL TimeContainerEnumeration::hasMoreElements() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maIter != maChildren.end(); } Any SAL_CALL TimeContainerEnumeration::nextElement() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); if( maIter == maChildren.end() ) throw NoSuchElementException(); @@ -417,7 +401,7 @@ Any SAL_CALL TimeContainerEnumeration::nextElement() std::array<Sequence< Type >*, 13> AnimationNode::mpTypes = { nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr }; AnimationNode::AnimationNode( sal_Int16 nNodeType ) -: maChangeListener(maMutex), +: AnimationNodeBase(), mnNodeType( nNodeType ), mnFill( AnimationFill::DEFAULT ), mnFillDefault( AnimationFill::INHERIT ), @@ -426,7 +410,6 @@ AnimationNode::AnimationNode( sal_Int16 nNodeType ) mfAcceleration( 0.0 ), mfDecelerate( 0.0 ), mbAutoReverse( false ), - mpParent(nullptr), mnValueType( 0 ), mnSubItem( 0 ), mnCalcMode( (nNodeType == AnimationNodeType::ANIMATEMOTION) ? AnimationCalcMode::PACED : AnimationCalcMode::LINEAR), @@ -446,12 +429,11 @@ AnimationNode::AnimationNode( sal_Int16 nNodeType ) mnIterateType( css::presentation::ShapeAnimationSubType::AS_WHOLE ), mfIterateInterval(0.0) { - assert(nNodeType < int(mpTypes.size())); + assert(nNodeType >= 0 && o3tl::make_unsigned(nNodeType) < mpTypes.size()); } AnimationNode::AnimationNode( const AnimationNode& rNode ) : AnimationNodeBase(), - maChangeListener(maMutex), mnNodeType( rNode.mnNodeType ), // attributes for the XAnimationNode interface implementation @@ -469,7 +451,6 @@ AnimationNode::AnimationNode( const AnimationNode& rNode ) mfDecelerate( rNode.mfDecelerate ), mbAutoReverse( rNode.mbAutoReverse ), maUserData( rNode.maUserData ), - mpParent(nullptr), // attributes for XAnimate maTarget( rNode.maTarget ), @@ -527,122 +508,122 @@ AnimationNode::AnimationNode( const AnimationNode& rNode ) static Sequence<OUString> getSupportedServiceNames_PAR() { - return { "com.sun.star.animations.ParallelTimeContainer" }; + return { u"com.sun.star.animations.ParallelTimeContainer"_ustr }; } static OUString getImplementationName_PAR() { - return "animcore::ParallelTimeContainer"; + return u"animcore::ParallelTimeContainer"_ustr; } static Sequence<OUString> getSupportedServiceNames_SEQ() { - return { "com.sun.star.animations.SequenceTimeContainer" }; + return { u"com.sun.star.animations.SequenceTimeContainer"_ustr }; } static OUString getImplementationName_SEQ() { - return "animcore::SequenceTimeContainer"; + return u"animcore::SequenceTimeContainer"_ustr; } static Sequence<OUString> getSupportedServiceNames_ITERATE() { - return { "com.sun.star.animations.IterateContainer" }; + return { u"com.sun.star.animations.IterateContainer"_ustr }; } static OUString getImplementationName_ITERATE() { - return "animcore::IterateContainer"; + return u"animcore::IterateContainer"_ustr; } static Sequence<OUString> getSupportedServiceNames_ANIMATE() { - return { "com.sun.star.animations.Animate" }; + return { u"com.sun.star.animations.Animate"_ustr }; } static OUString getImplementationName_ANIMATE() { - return "animcore::Animate"; + return u"animcore::Animate"_ustr; } static Sequence<OUString> getSupportedServiceNames_SET() { - return { "com.sun.star.animations.AnimateSet" }; + return { u"com.sun.star.animations.AnimateSet"_ustr }; } static OUString getImplementationName_SET() { - return "animcore::AnimateSet"; + return u"animcore::AnimateSet"_ustr; } static Sequence<OUString> getSupportedServiceNames_ANIMATECOLOR() { - return { "com.sun.star.animations.AnimateColor" }; + return { u"com.sun.star.animations.AnimateColor"_ustr }; } static OUString getImplementationName_ANIMATECOLOR() { - return "animcore::AnimateColor"; + return u"animcore::AnimateColor"_ustr; } static Sequence<OUString> getSupportedServiceNames_ANIMATEMOTION() { - return { "com.sun.star.animations.AnimateMotion" }; + return { u"com.sun.star.animations.AnimateMotion"_ustr }; } static OUString getImplementationName_ANIMATEMOTION() { - return "animcore::AnimateMotion"; + return u"animcore::AnimateMotion"_ustr; } static Sequence<OUString> getSupportedServiceNames_ANIMATEPHYSICS() { - return { "com.sun.star.animations.AnimatePhysics" }; + return { u"com.sun.star.animations.AnimatePhysics"_ustr }; } static OUString getImplementationName_ANIMATEPHYSICS() { - return "animcore::AnimatePhysics"; + return u"animcore::AnimatePhysics"_ustr; } static Sequence<OUString> getSupportedServiceNames_ANIMATETRANSFORM() { - return { "com.sun.star.animations.AnimateTransform" }; + return { u"com.sun.star.animations.AnimateTransform"_ustr }; } static OUString getImplementationName_ANIMATETRANSFORM() { - return "animcore::AnimateTransform"; + return u"animcore::AnimateTransform"_ustr; } static Sequence<OUString> getSupportedServiceNames_TRANSITIONFILTER() { - return { "com.sun.star.animations.TransitionFilter" }; + return { u"com.sun.star.animations.TransitionFilter"_ustr }; } static OUString getImplementationName_TRANSITIONFILTER() { - return "animcore::TransitionFilter"; + return u"animcore::TransitionFilter"_ustr; } static Sequence<OUString> getSupportedServiceNames_AUDIO() { - return { "com.sun.star.animations.Audio" }; + return { u"com.sun.star.animations.Audio"_ustr }; } static OUString getImplementationName_AUDIO() { - return "animcore::Audio"; + return u"animcore::Audio"_ustr; } static Sequence<OUString> getSupportedServiceNames_COMMAND() { - return { "com.sun.star.animations.Command" }; + return { u"com.sun.star.animations.Command"_ustr }; } static OUString getImplementationName_COMMAND() { - return "animcore::Command"; + return u"animcore::Command"_ustr; } // XInterface @@ -657,8 +638,7 @@ Any SAL_CALL AnimationNode::queryInterface( const Type& aType ) static_cast< XAnimationNode* >( static_cast< XTimeContainer * >( static_cast< XIterateContainer * >(this) ) ), static_cast< XInterface* >(static_cast< OWeakObject * >(this)), static_cast< XWeak* >(static_cast< OWeakObject * >(this)), - static_cast< XChangesNotifier* >( this ), - static_cast< XUnoTunnel* >( this ) ) ); + static_cast< XChangesNotifier* >( this ) ) ); if(!aRet.hasValue()) { @@ -744,26 +724,28 @@ Any SAL_CALL AnimationNode::queryInterface( const Type& aType ) void AnimationNode::initTypeProvider( sal_Int16 nNodeType ) noexcept { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + static std::mutex aMutex; + + std::scoped_lock aGuard(aMutex); if( mpTypes[nNodeType] ) return; static constexpr std::array<sal_Int32, mpTypes.size()> type_numbers = { - 7, // CUSTOM - 9, // PAR - 9, // SEQ - 9, // ITERATE - 8, // ANIMATE - 8, // SET - 8, // ANIMATEMOTION - 8, // ANIMATECOLOR - 8, // ANIMATETRANSFORM - 8, // TRANSITIONFILTER - 8, // AUDIO - 8, // COMMAND - 8, // ANIMATEPHYSICS + 6, // CUSTOM + 8, // PAR + 8, // SEQ + 8, // ITERATE + 7, // ANIMATE + 7, // SET + 7, // ANIMATEMOTION + 7, // ANIMATECOLOR + 7, // ANIMATETRANSFORM + 7, // TRANSITIONFILTER + 7, // AUDIO + 7, // COMMAND + 7, // ANIMATEPHYSICS }; // collect types @@ -776,7 +758,6 @@ void AnimationNode::initTypeProvider( sal_Int16 nNodeType ) noexcept pTypeAr[nPos++] = cppu::UnoType<XCloneable>::get(); pTypeAr[nPos++] = cppu::UnoType<XTypeProvider>::get(); pTypeAr[nPos++] = cppu::UnoType<XServiceInfo>::get(); - pTypeAr[nPos++] = cppu::UnoType<XUnoTunnel>::get(); pTypeAr[nPos++] = cppu::UnoType<XChangesNotifier>::get(); switch( nNodeType ) @@ -926,7 +907,6 @@ Sequence< OUString > AnimationNode::getSupportedServiceNames() // XAnimationNode sal_Int16 SAL_CALL AnimationNode::getType() { - Guard< Mutex > aGuard( maMutex ); return mnNodeType; } @@ -934,7 +914,7 @@ sal_Int16 SAL_CALL AnimationNode::getType() // XAnimationNode Any SAL_CALL AnimationNode::getBegin() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maBegin; } @@ -942,11 +922,11 @@ Any SAL_CALL AnimationNode::getBegin() // XAnimationNode void SAL_CALL AnimationNode::setBegin( const Any& _begin ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); if( _begin != maBegin ) { maBegin = _begin; - fireChangeListener(); + fireChangeListener(aGuard); } } @@ -954,7 +934,7 @@ void SAL_CALL AnimationNode::setBegin( const Any& _begin ) // XAnimationNode Any SAL_CALL AnimationNode::getDuration() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maDuration; } @@ -962,11 +942,11 @@ Any SAL_CALL AnimationNode::getDuration() // XAnimationNode void SAL_CALL AnimationNode::setDuration( const Any& _duration ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); if( _duration != maDuration ) { maDuration = _duration; - fireChangeListener(); + fireChangeListener(aGuard); } } @@ -974,7 +954,7 @@ void SAL_CALL AnimationNode::setDuration( const Any& _duration ) // XAnimationNode Any SAL_CALL AnimationNode::getEnd() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maEnd; } @@ -982,11 +962,11 @@ Any SAL_CALL AnimationNode::getEnd() // XAnimationNode void SAL_CALL AnimationNode::setEnd( const Any& _end ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); if( _end != maEnd ) { maEnd = _end; - fireChangeListener(); + fireChangeListener(aGuard); } } @@ -994,7 +974,7 @@ void SAL_CALL AnimationNode::setEnd( const Any& _end ) // XAnimationNode Any SAL_CALL AnimationNode::getEndSync() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maEndSync; } @@ -1002,11 +982,11 @@ Any SAL_CALL AnimationNode::getEndSync() // XAnimationNode void SAL_CALL AnimationNode::setEndSync( const Any& _endsync ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _endsync != maEndSync ) { maEndSync = _endsync; - fireChangeListener(); + fireChangeListener(l); } } @@ -1014,7 +994,7 @@ void SAL_CALL AnimationNode::setEndSync( const Any& _endsync ) // XAnimationNode Any SAL_CALL AnimationNode::getRepeatCount() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maRepeatCount; } @@ -1022,11 +1002,11 @@ Any SAL_CALL AnimationNode::getRepeatCount() // XAnimationNode void SAL_CALL AnimationNode::setRepeatCount( const Any& _repeatcount ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _repeatcount != maRepeatCount ) { maRepeatCount = _repeatcount; - fireChangeListener(); + fireChangeListener(l); } } @@ -1034,7 +1014,7 @@ void SAL_CALL AnimationNode::setRepeatCount( const Any& _repeatcount ) // XAnimationNode Any SAL_CALL AnimationNode::getRepeatDuration() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maRepeatDuration; } @@ -1042,11 +1022,11 @@ Any SAL_CALL AnimationNode::getRepeatDuration() // XAnimationNode void SAL_CALL AnimationNode::setRepeatDuration( const Any& _repeatduration ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _repeatduration != maRepeatDuration ) { maRepeatDuration = _repeatduration; - fireChangeListener(); + fireChangeListener(l); } } @@ -1054,7 +1034,7 @@ void SAL_CALL AnimationNode::setRepeatDuration( const Any& _repeatduration ) // XAnimationNode sal_Int16 SAL_CALL AnimationNode::getFill() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnFill; } @@ -1062,11 +1042,11 @@ sal_Int16 SAL_CALL AnimationNode::getFill() // XAnimationNode void SAL_CALL AnimationNode::setFill( sal_Int16 _fill ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _fill != mnFill ) { mnFill = _fill; - fireChangeListener(); + fireChangeListener(l); } } @@ -1074,7 +1054,7 @@ void SAL_CALL AnimationNode::setFill( sal_Int16 _fill ) // XAnimationNode sal_Int16 SAL_CALL AnimationNode::getFillDefault() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnFillDefault; } @@ -1082,11 +1062,11 @@ sal_Int16 SAL_CALL AnimationNode::getFillDefault() // XAnimationNode void SAL_CALL AnimationNode::setFillDefault( sal_Int16 _filldefault ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _filldefault != mnFillDefault ) { mnFillDefault = _filldefault; - fireChangeListener(); + fireChangeListener(l); } } @@ -1094,7 +1074,7 @@ void SAL_CALL AnimationNode::setFillDefault( sal_Int16 _filldefault ) // XAnimationNode sal_Int16 SAL_CALL AnimationNode::getRestart() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnRestart; } @@ -1102,11 +1082,11 @@ sal_Int16 SAL_CALL AnimationNode::getRestart() // XAnimationNode void SAL_CALL AnimationNode::setRestart( sal_Int16 _restart ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _restart != mnRestart ) { mnRestart = _restart; - fireChangeListener(); + fireChangeListener(l); } } @@ -1114,7 +1094,7 @@ void SAL_CALL AnimationNode::setRestart( sal_Int16 _restart ) // XAnimationNode sal_Int16 SAL_CALL AnimationNode::getRestartDefault() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnRestartDefault; } @@ -1122,11 +1102,11 @@ sal_Int16 SAL_CALL AnimationNode::getRestartDefault() // XAnimationNode void SAL_CALL AnimationNode::setRestartDefault( sal_Int16 _restartdefault ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _restartdefault != mnRestartDefault ) { mnRestartDefault = _restartdefault; - fireChangeListener(); + fireChangeListener(l); } } @@ -1134,7 +1114,7 @@ void SAL_CALL AnimationNode::setRestartDefault( sal_Int16 _restartdefault ) // XAnimationNode double SAL_CALL AnimationNode::getAcceleration() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mfAcceleration; } @@ -1142,11 +1122,11 @@ double SAL_CALL AnimationNode::getAcceleration() // XAnimationNode void SAL_CALL AnimationNode::setAcceleration( double _acceleration ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _acceleration != mfAcceleration ) { mfAcceleration = _acceleration; - fireChangeListener(); + fireChangeListener(l); } } @@ -1154,7 +1134,7 @@ void SAL_CALL AnimationNode::setAcceleration( double _acceleration ) // XAnimationNode double SAL_CALL AnimationNode::getDecelerate() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mfDecelerate; } @@ -1162,11 +1142,11 @@ double SAL_CALL AnimationNode::getDecelerate() // XAnimationNode void SAL_CALL AnimationNode::setDecelerate( double _decelerate ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _decelerate != mfDecelerate ) { mfDecelerate = _decelerate; - fireChangeListener(); + fireChangeListener(l); } } @@ -1174,7 +1154,7 @@ void SAL_CALL AnimationNode::setDecelerate( double _decelerate ) // XAnimationNode sal_Bool SAL_CALL AnimationNode::getAutoReverse() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mbAutoReverse; } @@ -1182,48 +1162,49 @@ sal_Bool SAL_CALL AnimationNode::getAutoReverse() // XAnimationNode void SAL_CALL AnimationNode::setAutoReverse( sal_Bool _autoreverse ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( bool(_autoreverse) != mbAutoReverse ) { mbAutoReverse = _autoreverse; - fireChangeListener(); + fireChangeListener(l); } } Sequence< NamedValue > SAL_CALL AnimationNode::getUserData() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maUserData; } void SAL_CALL AnimationNode::setUserData( const Sequence< NamedValue >& _userdata ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maUserData = _userdata; - fireChangeListener(); + fireChangeListener(l); } // XChild Reference< XInterface > SAL_CALL AnimationNode::getParent() { - Guard< Mutex > aGuard( maMutex ); - return mxParent.get(); + std::unique_lock aGuard( m_aMutex ); + return static_cast<cppu::OWeakObject*>(mxParent.get().get()); } // XChild void SAL_CALL AnimationNode::setParent( const Reference< XInterface >& Parent ) { - Guard< Mutex > aGuard( maMutex ); - if( Parent != mxParent.get() ) + std::unique_lock l( m_aMutex ); + if( Parent.get() != static_cast<cppu::OWeakObject*>(mxParent.get().get()) ) { - mxParent = Parent; - mpParent = comphelper::getFromUnoTunnel<AnimationNode>(mxParent.get()); + rtl::Reference<AnimationNode> xParent = dynamic_cast<AnimationNode*>(Parent.get()); + mxParent = xParent.get(); + assert(bool(xParent) == bool(Parent) && "only support AnimationNode subtypes"); - fireChangeListener(); + fireChangeListener(l); } } @@ -1231,7 +1212,7 @@ void SAL_CALL AnimationNode::setParent( const Reference< XInterface >& Parent ) // XCloneable Reference< XCloneable > SAL_CALL AnimationNode::createClone() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); Reference< XCloneable > xNewNode; try @@ -1272,7 +1253,7 @@ Reference< XCloneable > SAL_CALL AnimationNode::createClone() // XAnimate Any SAL_CALL AnimationNode::getTarget() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maTarget; } @@ -1280,11 +1261,11 @@ Any SAL_CALL AnimationNode::getTarget() // XAnimate void SAL_CALL AnimationNode::setTarget( const Any& _target ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _target != maTarget ) { maTarget= _target; - fireChangeListener(); + fireChangeListener(l); } } @@ -1292,7 +1273,7 @@ void SAL_CALL AnimationNode::setTarget( const Any& _target ) // XAnimate OUString SAL_CALL AnimationNode::getAttributeName() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maAttributeName; } @@ -1300,11 +1281,11 @@ OUString SAL_CALL AnimationNode::getAttributeName() // XAnimate void SAL_CALL AnimationNode::setAttributeName( const OUString& _attribute ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _attribute != maAttributeName ) { maAttributeName = _attribute; - fireChangeListener(); + fireChangeListener(l); } } @@ -1312,7 +1293,7 @@ void SAL_CALL AnimationNode::setAttributeName( const OUString& _attribute ) // XAnimate Sequence< Any > SAL_CALL AnimationNode::getValues() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maValues; } @@ -1320,16 +1301,16 @@ Sequence< Any > SAL_CALL AnimationNode::getValues() // XAnimate void SAL_CALL AnimationNode::setValues( const Sequence< Any >& _values ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maValues = _values; - fireChangeListener(); + fireChangeListener(l); } // XAnimate sal_Int16 SAL_CALL AnimationNode::getSubItem() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnSubItem; } @@ -1337,11 +1318,11 @@ sal_Int16 SAL_CALL AnimationNode::getSubItem() // XAnimate void SAL_CALL AnimationNode::setSubItem( sal_Int16 _subitem ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _subitem != mnSubItem ) { mnSubItem = _subitem; - fireChangeListener(); + fireChangeListener(l); } } @@ -1349,7 +1330,7 @@ void SAL_CALL AnimationNode::setSubItem( sal_Int16 _subitem ) // XAnimate Sequence< double > SAL_CALL AnimationNode::getKeyTimes() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maKeyTimes; } @@ -1357,27 +1338,27 @@ Sequence< double > SAL_CALL AnimationNode::getKeyTimes() // XAnimate void SAL_CALL AnimationNode::setKeyTimes( const Sequence< double >& _keytimes ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maKeyTimes = _keytimes; - fireChangeListener(); + fireChangeListener(l); } // XAnimate sal_Int16 SAL_CALL AnimationNode::getValueType() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnValueType; } void SAL_CALL AnimationNode::setValueType( sal_Int16 _valuetype ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _valuetype != mnValueType ) { mnValueType = _valuetype; - fireChangeListener(); + fireChangeListener(l); } } @@ -1385,7 +1366,7 @@ void SAL_CALL AnimationNode::setValueType( sal_Int16 _valuetype ) // XAnimate sal_Int16 SAL_CALL AnimationNode::getCalcMode() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnCalcMode; } @@ -1393,11 +1374,11 @@ sal_Int16 SAL_CALL AnimationNode::getCalcMode() // XAnimate void SAL_CALL AnimationNode::setCalcMode( sal_Int16 _calcmode ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _calcmode != mnCalcMode ) { mnCalcMode = _calcmode; - fireChangeListener(); + fireChangeListener(l); } } @@ -1405,7 +1386,7 @@ void SAL_CALL AnimationNode::setCalcMode( sal_Int16 _calcmode ) // XAnimate sal_Bool SAL_CALL AnimationNode::getAccumulate() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mbAccumulate; } @@ -1413,11 +1394,11 @@ sal_Bool SAL_CALL AnimationNode::getAccumulate() // XAnimate void SAL_CALL AnimationNode::setAccumulate( sal_Bool _accumulate ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( bool(_accumulate) != mbAccumulate ) { mbAccumulate = _accumulate; - fireChangeListener(); + fireChangeListener(l); } } @@ -1425,7 +1406,7 @@ void SAL_CALL AnimationNode::setAccumulate( sal_Bool _accumulate ) // XAnimate sal_Int16 SAL_CALL AnimationNode::getAdditive() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnAdditive; } @@ -1433,11 +1414,11 @@ sal_Int16 SAL_CALL AnimationNode::getAdditive() // XAnimate void SAL_CALL AnimationNode::setAdditive( sal_Int16 _additive ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _additive != mnAdditive ) { mnAdditive = _additive; - fireChangeListener(); + fireChangeListener(l); } } @@ -1445,7 +1426,7 @@ void SAL_CALL AnimationNode::setAdditive( sal_Int16 _additive ) // XAnimate Any SAL_CALL AnimationNode::getFrom() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maFrom; } @@ -1453,11 +1434,11 @@ Any SAL_CALL AnimationNode::getFrom() // XAnimate void SAL_CALL AnimationNode::setFrom( const Any& _from ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _from != maFrom ) { maFrom = _from; - fireChangeListener(); + fireChangeListener(l); } } @@ -1465,7 +1446,7 @@ void SAL_CALL AnimationNode::setFrom( const Any& _from ) // XAnimate Any SAL_CALL AnimationNode::getTo() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maTo; } @@ -1473,11 +1454,11 @@ Any SAL_CALL AnimationNode::getTo() // XAnimate void SAL_CALL AnimationNode::setTo( const Any& _to ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _to != maTo ) { maTo = _to; - fireChangeListener(); + fireChangeListener(l); } } @@ -1485,7 +1466,7 @@ void SAL_CALL AnimationNode::setTo( const Any& _to ) // XAnimate Any SAL_CALL AnimationNode::getBy() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maBy; } @@ -1493,11 +1474,11 @@ Any SAL_CALL AnimationNode::getBy() // XAnimate void SAL_CALL AnimationNode::setBy( const Any& _by ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _by != maBy ) { maBy = _by; - fireChangeListener(); + fireChangeListener(l); } } @@ -1505,7 +1486,7 @@ void SAL_CALL AnimationNode::setBy( const Any& _by ) // XAnimate Sequence< TimeFilterPair > SAL_CALL AnimationNode::getTimeFilter() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maTimeFilter; } @@ -1513,26 +1494,26 @@ Sequence< TimeFilterPair > SAL_CALL AnimationNode::getTimeFilter() // XAnimate void SAL_CALL AnimationNode::setTimeFilter( const Sequence< TimeFilterPair >& _timefilter ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maTimeFilter = _timefilter; - fireChangeListener(); + fireChangeListener(l); } OUString SAL_CALL AnimationNode::getFormula() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maFormula; } void SAL_CALL AnimationNode::setFormula( const OUString& _formula ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _formula != maFormula ) { maFormula = _formula; - fireChangeListener(); + fireChangeListener(l); } } @@ -1540,7 +1521,7 @@ void SAL_CALL AnimationNode::setFormula( const OUString& _formula ) // XAnimateColor sal_Int16 SAL_CALL AnimationNode::getColorInterpolation() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnColorSpace; } @@ -1548,11 +1529,11 @@ sal_Int16 SAL_CALL AnimationNode::getColorInterpolation() // XAnimateColor void SAL_CALL AnimationNode::setColorInterpolation( sal_Int16 _colorspace ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _colorspace != mnColorSpace ) { mnColorSpace = _colorspace; - fireChangeListener(); + fireChangeListener(l); } } @@ -1560,7 +1541,7 @@ void SAL_CALL AnimationNode::setColorInterpolation( sal_Int16 _colorspace ) // XAnimateColor sal_Bool SAL_CALL AnimationNode::getDirection() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mbDirection; } @@ -1568,11 +1549,11 @@ sal_Bool SAL_CALL AnimationNode::getDirection() // XAnimateColor void SAL_CALL AnimationNode::setDirection( sal_Bool _direction ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( bool(_direction) != mbDirection ) { mbDirection = _direction; - fireChangeListener(); + fireChangeListener(l); } } @@ -1580,7 +1561,7 @@ void SAL_CALL AnimationNode::setDirection( sal_Bool _direction ) // XAnimateMotion Any SAL_CALL AnimationNode::getPath() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maPath; } @@ -1588,16 +1569,16 @@ Any SAL_CALL AnimationNode::getPath() // XAnimateMotion void SAL_CALL AnimationNode::setPath( const Any& _path ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maPath = _path; - fireChangeListener(); + fireChangeListener(l); } // XAnimateMotion Any SAL_CALL AnimationNode::getOrigin() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maOrigin; } @@ -1605,15 +1586,15 @@ Any SAL_CALL AnimationNode::getOrigin() // XAnimateMotion void SAL_CALL AnimationNode::setOrigin( const Any& _origin ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maOrigin = _origin; - fireChangeListener(); + fireChangeListener(l); } // XAnimatePhysics Any SAL_CALL AnimationNode::getStartVelocityX() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maStartVelocityX; } @@ -1621,15 +1602,15 @@ Any SAL_CALL AnimationNode::getStartVelocityX() // XAnimatePhysics void SAL_CALL AnimationNode::setStartVelocityX( const Any& _startvelocityx ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maStartVelocityX = _startvelocityx; - fireChangeListener(); + fireChangeListener(l); } // XAnimatePhysics Any SAL_CALL AnimationNode::getStartVelocityY() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maStartVelocityY; } @@ -1637,16 +1618,16 @@ Any SAL_CALL AnimationNode::getStartVelocityY() // XAnimatePhysics void SAL_CALL AnimationNode::setStartVelocityY( const Any& _startvelocityy ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maStartVelocityY = _startvelocityy; - fireChangeListener(); + fireChangeListener(l); } // XAnimatePhysics Any SAL_CALL AnimationNode::getDensity() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maDensity; } @@ -1654,16 +1635,16 @@ Any SAL_CALL AnimationNode::getDensity() // XAnimatePhysics void SAL_CALL AnimationNode::setDensity( const Any& _density ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maDensity = _density; - fireChangeListener(); + fireChangeListener(l); } // XAnimatePhysics Any SAL_CALL AnimationNode::getBounciness() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maBounciness; } @@ -1671,16 +1652,16 @@ Any SAL_CALL AnimationNode::getBounciness() // XAnimatePhysics void SAL_CALL AnimationNode::setBounciness( const Any& _bounciness ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maBounciness = _bounciness; - fireChangeListener(); + fireChangeListener(l); } // XAnimateTransform sal_Int16 SAL_CALL AnimationNode::getTransformType() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnTransformType; } @@ -1688,11 +1669,11 @@ sal_Int16 SAL_CALL AnimationNode::getTransformType() // XAnimateTransform void SAL_CALL AnimationNode::setTransformType( sal_Int16 _transformtype ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _transformtype != mnTransformType ) { mnTransformType = _transformtype; - fireChangeListener(); + fireChangeListener(l); } } @@ -1700,7 +1681,7 @@ void SAL_CALL AnimationNode::setTransformType( sal_Int16 _transformtype ) // XTransitionFilter sal_Int16 SAL_CALL AnimationNode::getTransition() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnTransition; } @@ -1708,11 +1689,11 @@ sal_Int16 SAL_CALL AnimationNode::getTransition() // XTransitionFilter void SAL_CALL AnimationNode::setTransition( sal_Int16 _transition ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _transition != mnTransition ) { mnTransition = _transition; - fireChangeListener(); + fireChangeListener(l); } } @@ -1720,7 +1701,7 @@ void SAL_CALL AnimationNode::setTransition( sal_Int16 _transition ) // XTransitionFilter sal_Int16 SAL_CALL AnimationNode::getSubtype() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnSubtype; } @@ -1728,11 +1709,11 @@ sal_Int16 SAL_CALL AnimationNode::getSubtype() // XTransitionFilter void SAL_CALL AnimationNode::setSubtype( sal_Int16 _subtype ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _subtype != mnSubtype ) { mnSubtype = _subtype; - fireChangeListener(); + fireChangeListener(l); } } @@ -1740,7 +1721,7 @@ void SAL_CALL AnimationNode::setSubtype( sal_Int16 _subtype ) // XTransitionFilter sal_Bool SAL_CALL AnimationNode::getMode() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mbMode; } @@ -1748,11 +1729,11 @@ sal_Bool SAL_CALL AnimationNode::getMode() // XTransitionFilter void SAL_CALL AnimationNode::setMode( sal_Bool _mode ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( bool(_mode) != mbMode ) { mbMode = _mode; - fireChangeListener(); + fireChangeListener(l); } } @@ -1760,7 +1741,7 @@ void SAL_CALL AnimationNode::setMode( sal_Bool _mode ) // XTransitionFilter sal_Int32 SAL_CALL AnimationNode::getFadeColor() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnFadeColor; } @@ -1768,11 +1749,11 @@ sal_Int32 SAL_CALL AnimationNode::getFadeColor() // XTransitionFilter void SAL_CALL AnimationNode::setFadeColor( sal_Int32 _fadecolor ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _fadecolor != mnFadeColor ) { mnFadeColor = _fadecolor; - fireChangeListener(); + fireChangeListener(l); } } @@ -1780,7 +1761,7 @@ void SAL_CALL AnimationNode::setFadeColor( sal_Int32 _fadecolor ) // XAudio Any SAL_CALL AnimationNode::getSource() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maTarget; } @@ -1788,16 +1769,16 @@ Any SAL_CALL AnimationNode::getSource() // XAudio void SAL_CALL AnimationNode::setSource( const Any& _source ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maTarget = _source; - fireChangeListener(); + fireChangeListener(l); } // XAudio double SAL_CALL AnimationNode::getVolume() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mfVolume; } @@ -1805,50 +1786,50 @@ double SAL_CALL AnimationNode::getVolume() // XAudio void SAL_CALL AnimationNode::setVolume( double _volume ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _volume != mfVolume ) { mfVolume = _volume; - fireChangeListener(); + fireChangeListener(l); } } sal_Bool SAL_CALL AnimationNode::getHideDuringShow() { - osl::Guard<osl::Mutex> aGuard(maMutex); + std::unique_lock aGuard(m_aMutex); return mbHideDuringShow; } void SAL_CALL AnimationNode::setHideDuringShow(sal_Bool bHideDuringShow) { - osl::Guard<osl::Mutex> aGuard(maMutex); + std::unique_lock l(m_aMutex); if (static_cast<bool>(bHideDuringShow) != mbHideDuringShow) { mbHideDuringShow = bHideDuringShow; - fireChangeListener(); + fireChangeListener(l); } } sal_Bool SAL_CALL AnimationNode::getNarration() { - osl::Guard<osl::Mutex> aGuard(maMutex); + std::unique_lock aGuard(m_aMutex); return mbNarration; } void SAL_CALL AnimationNode::setNarration(sal_Bool bNarration) { - osl::Guard<osl::Mutex> aGuard(maMutex); + std::unique_lock l(m_aMutex); if (static_cast<bool>(bNarration) != mbNarration) { mbNarration = bNarration; - fireChangeListener(); + fireChangeListener(l); } } // XCommand sal_Int16 SAL_CALL AnimationNode::getCommand() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnCommand; } @@ -1856,11 +1837,11 @@ sal_Int16 SAL_CALL AnimationNode::getCommand() // XCommand void SAL_CALL AnimationNode::setCommand( sal_Int16 _command ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _command != mnCommand ) { mnCommand = _command; - fireChangeListener(); + fireChangeListener(l); } } @@ -1868,7 +1849,7 @@ void SAL_CALL AnimationNode::setCommand( sal_Int16 _command ) // XCommand Any SAL_CALL AnimationNode::getParameter() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return maParameter; } @@ -1876,9 +1857,9 @@ Any SAL_CALL AnimationNode::getParameter() // XCommand void SAL_CALL AnimationNode::setParameter( const Any& _parameter ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); maParameter = _parameter; - fireChangeListener(); + fireChangeListener(l); } @@ -1892,7 +1873,7 @@ Type SAL_CALL AnimationNode::getElementType() // XElementAccess sal_Bool SAL_CALL AnimationNode::hasElements() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return !maChildren.empty(); } @@ -1900,7 +1881,7 @@ sal_Bool SAL_CALL AnimationNode::hasElements() // XEnumerationAccess Reference< XEnumeration > SAL_CALL AnimationNode::createEnumeration() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return new TimeContainerEnumeration(std::vector(maChildren)); } @@ -1909,7 +1890,7 @@ Reference< XEnumeration > SAL_CALL AnimationNode::createEnumeration() // XTimeContainer Reference< XAnimationNode > SAL_CALL AnimationNode::insertBefore( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( !newChild.is() || !refChild.is() ) throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), -1); @@ -1924,6 +1905,7 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::insertBefore( const Referenc maChildren.insert( before, newChild ); Reference< XInterface > xThis( static_cast< OWeakObject * >(this) ); + l.unlock(); newChild->setParent( xThis ); return newChild; @@ -1933,7 +1915,7 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::insertBefore( const Referenc // XTimeContainer Reference< XAnimationNode > SAL_CALL AnimationNode::insertAfter( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& refChild ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( !newChild.is() || !refChild.is() ) throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), -1); @@ -1952,6 +1934,7 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::insertAfter( const Reference maChildren.push_back( newChild ); Reference< XInterface > xThis( static_cast< OWeakObject * >(this) ); + l.unlock(); newChild->setParent( xThis ); return newChild; @@ -1961,7 +1944,7 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::insertAfter( const Reference // XTimeContainer Reference< XAnimationNode > SAL_CALL AnimationNode::replaceChild( const Reference< XAnimationNode >& newChild, const Reference< XAnimationNode >& oldChild ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( !newChild.is() || !oldChild.is() ) throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), -1); @@ -1973,11 +1956,11 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::replaceChild( const Referenc if( replace == maChildren.end() ) throw NoSuchElementException(); - oldChild->setParent( Reference< XInterface >() ); - (*replace) = newChild; Reference< XInterface > xThis( static_cast< OWeakObject * >(this) ); + l.unlock(); + oldChild->setParent( Reference< XInterface >() ); newChild->setParent( xThis ); return newChild; @@ -1987,7 +1970,7 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::replaceChild( const Referenc // XTimeContainer Reference< XAnimationNode > SAL_CALL AnimationNode::removeChild( const Reference< XAnimationNode >& oldChild ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( !oldChild.is() ) throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), 1); @@ -1996,10 +1979,11 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::removeChild( const Reference if( old == maChildren.end() ) throw NoSuchElementException(); - oldChild->setParent( Reference< XInterface >() ); - maChildren.erase( old ); + l.unlock(); + oldChild->setParent( Reference< XInterface >() ); + return oldChild; } @@ -2007,22 +1991,21 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::removeChild( const Reference // XTimeContainer Reference< XAnimationNode > SAL_CALL AnimationNode::appendChild( const Reference< XAnimationNode >& newChild ) { - Guard< Mutex > aGuard( maMutex ); - - if( !newChild.is() ) - throw IllegalArgumentException("no child", static_cast<cppu::OWeakObject*>(this), 1); - - if( std::find(maChildren.begin(), maChildren.end(), newChild) != maChildren.end() ) - throw ElementExistException(); - Reference< XInterface > xThis( static_cast< OWeakObject * >(this) ); - Reference< XInterface > xChild( newChild ); + { + std::unique_lock aGuard( m_aMutex ); + + if( !newChild.is() ) + throw IllegalArgumentException("no child", xThis, 1); - if( xThis == xChild ) - throw IllegalArgumentException("cannot append self", static_cast<cppu::OWeakObject*>(this), -1); + if( std::find(maChildren.begin(), maChildren.end(), newChild) != maChildren.end() ) + throw ElementExistException({}, xThis); - maChildren.push_back( newChild ); + if( xThis == newChild ) + throw IllegalArgumentException("cannot append self", xThis, -1); + maChildren.push_back( newChild ); + } newChild->setParent( xThis ); return newChild; @@ -2032,7 +2015,7 @@ Reference< XAnimationNode > SAL_CALL AnimationNode::appendChild( const Reference // XIterateContainer sal_Int16 SAL_CALL AnimationNode::getIterateType() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mnIterateType; } @@ -2040,11 +2023,11 @@ sal_Int16 SAL_CALL AnimationNode::getIterateType() // XIterateContainer void SAL_CALL AnimationNode::setIterateType( sal_Int16 _iteratetype ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _iteratetype != mnIterateType ) { mnIterateType = _iteratetype; - fireChangeListener(); + fireChangeListener(l); } } @@ -2052,7 +2035,7 @@ void SAL_CALL AnimationNode::setIterateType( sal_Int16 _iteratetype ) // XIterateContainer double SAL_CALL AnimationNode::getIterateInterval() { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock aGuard( m_aMutex ); return mfIterateInterval; } @@ -2060,11 +2043,11 @@ double SAL_CALL AnimationNode::getIterateInterval() // XIterateContainer void SAL_CALL AnimationNode::setIterateInterval( double _iterateinterval ) { - Guard< Mutex > aGuard( maMutex ); + std::unique_lock l( m_aMutex ); if( _iterateinterval != mfIterateInterval ) { mfIterateInterval = _iterateinterval; - fireChangeListener(); + fireChangeListener(l); } } @@ -2072,50 +2055,40 @@ void SAL_CALL AnimationNode::setIterateInterval( double _iterateinterval ) // XChangesNotifier void SAL_CALL AnimationNode::addChangesListener( const Reference< XChangesListener >& aListener ) { - maChangeListener.addInterface( aListener ); + std::unique_lock l( m_aMutex ); + maChangeListener.addInterface( l, aListener ); } // XChangesNotifier void SAL_CALL AnimationNode::removeChangesListener( const Reference< XChangesListener >& aListener ) { - maChangeListener.removeInterface(aListener); + std::unique_lock l( m_aMutex ); + maChangeListener.removeInterface(l, aListener); } -// XUnoTunnel -::sal_Int64 SAL_CALL AnimationNode::getSomething( const Sequence< ::sal_Int8 >& rId ) +void AnimationNode::fireChangeListener(std::unique_lock<std::mutex>& l) { - return comphelper::getSomethingImpl(rId, this); -} - -const css::uno::Sequence< sal_Int8 > & AnimationNode::getUnoTunnelId() -{ - static const comphelper::UnoIdInit theAnimationNodeUnoTunnelId; - return theAnimationNodeUnoTunnelId.getSeq(); -} - - -void AnimationNode::fireChangeListener() -{ - Guard< Mutex > aGuard( maMutex ); - - OInterfaceIteratorHelper3 aIterator( maChangeListener ); - if( aIterator.hasMoreElements() ) + if( maChangeListener.getLength(l) != 0 ) { Reference< XInterface > xSource( static_cast<OWeakObject*>(this), UNO_QUERY ); Sequence< ElementChange > aChanges; - const ChangesEvent aEvent( xSource, Any( mxParent.get() ), aChanges ); + const ChangesEvent aEvent( xSource, Any( css::uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(mxParent.get().get())) ), aChanges ); + OInterfaceIteratorHelper4 aIterator( l, maChangeListener ); + l.unlock(); while( aIterator.hasMoreElements() ) aIterator.next()->changesOccurred( aEvent ); + l.lock(); } //fdo#69645 use WeakReference of mxParent to test if mpParent is still valid - if (mpParent) + rtl::Reference<AnimationNode> xGuard(mxParent); + if (xGuard.is()) { - Reference<XInterface> xGuard(mxParent); - if (xGuard.is()) - mpParent->fireChangeListener(); + l.unlock(); + std::unique_lock l2(xGuard->m_aMutex); + xGuard->fireChangeListener(l2); } } |