diff options
author | Arnaud Versini <arnaud.versini@libreoffice.org> | 2021-08-22 14:24:38 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-23 21:54:40 +0200 |
commit | 0ce90e777721f11048d366b58e760b60aabf2eaa (patch) | |
tree | 21157f938ebc689bb41b77eb4e8f2b4dc6ee51e4 | |
parent | 6d276cd03089219c3ad099d4683ecc0c85bd0468 (diff) |
comphelper : remove useless OContextHelper_Impl
Change-Id: I41fc571695a64b432d6abf4979b99ef141a12b28
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120842
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | comphelper/source/misc/accessiblecontexthelper.cxx | 63 | ||||
-rw-r--r-- | include/comphelper/accessiblecontexthelper.hxx | 6 |
2 files changed, 19 insertions, 50 deletions
diff --git a/comphelper/source/misc/accessiblecontexthelper.cxx b/comphelper/source/misc/accessiblecontexthelper.cxx index a4d11cb59c1a..ad2c63b1a1c0 100644 --- a/comphelper/source/misc/accessiblecontexthelper.cxx +++ b/comphelper/source/misc/accessiblecontexthelper.cxx @@ -31,40 +31,9 @@ namespace comphelper using namespace ::com::sun::star::lang; using namespace ::com::sun::star::accessibility; - /** implementation class for OAccessibleContextHelper. No own thread safety! - */ - class OContextHelper_Impl - { - private: - WeakReference< XAccessible > m_aCreator; // the XAccessible which created our XAccessibleContext - - AccessibleEventNotifier::TClientId m_nClientId; - - public: - Reference< XAccessible > getCreator( ) const { return m_aCreator; } - inline void setCreator( const Reference< XAccessible >& _rAcc ); - - AccessibleEventNotifier::TClientId - getClientId() const { return m_nClientId; } - void setClientId( const AccessibleEventNotifier::TClientId _nId ) - { m_nClientId = _nId; } - - public: - OContextHelper_Impl() - :m_nClientId( 0 ) - { - } - }; - - - inline void OContextHelper_Impl::setCreator( const Reference< XAccessible >& _rAcc ) - { - m_aCreator = _rAcc; - } - OAccessibleContextHelper::OAccessibleContextHelper( ) :OAccessibleContextHelper_Base( GetMutex() ) - ,m_pImpl(new OContextHelper_Impl) + ,m_nClientId( 0 ) { } @@ -84,10 +53,10 @@ namespace comphelper // do not lock m_Mutex because it may cause deadlock osl::Guard<SolarMutex> aGuard(SolarMutex::get()); - if ( m_pImpl->getClientId( ) ) + if ( m_nClientId ) { - AccessibleEventNotifier::revokeClientNotifyDisposing( m_pImpl->getClientId( ), *this ); - m_pImpl->setClientId( 0 ); + AccessibleEventNotifier::revokeClientNotifyDisposing( m_nClientId, *this ); + m_nClientId=0; } } @@ -107,10 +76,10 @@ namespace comphelper if ( _rxListener.is() ) { - if ( !m_pImpl->getClientId( ) ) - m_pImpl->setClientId( AccessibleEventNotifier::registerClient( ) ); + if ( !m_nClientId ) + m_nClientId = AccessibleEventNotifier::registerClient( ); - AccessibleEventNotifier::addEventListener( m_pImpl->getClientId( ), _rxListener ); + AccessibleEventNotifier::addEventListener( m_nClientId, _rxListener ); } } @@ -124,18 +93,18 @@ namespace comphelper if ( !isAlive() ) return; - if ( !(_rxListener.is() && m_pImpl->getClientId()) ) + if ( !(_rxListener.is() && m_nClientId) ) return; - sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( m_pImpl->getClientId( ), _rxListener ); + sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( m_nClientId, _rxListener ); if ( !nListenerCount ) { // no listeners anymore // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client), // and at least to us not firing any events anymore, in case somebody calls // NotifyAccessibleEvent, again - AccessibleEventNotifier::revokeClient( m_pImpl->getClientId( ) ); - m_pImpl->setClientId( 0 ); + AccessibleEventNotifier::revokeClient( m_nClientId ); + m_nClientId = 0; } } @@ -143,7 +112,7 @@ namespace comphelper void OAccessibleContextHelper::NotifyAccessibleEvent( const sal_Int16 _nEventId, const Any& _rOldValue, const Any& _rNewValue ) { - if ( !m_pImpl->getClientId( ) ) + if ( !m_nClientId ) // if we don't have a client id for the notifier, then we don't have listeners, then // we don't need to notify anything return; @@ -156,7 +125,7 @@ namespace comphelper aEvent.NewValue = _rNewValue; // let the notifier handle this event - AccessibleEventNotifier::addEvent( m_pImpl->getClientId( ), aEvent ); + AccessibleEventNotifier::addEvent( m_nClientId, aEvent ); } @@ -186,13 +155,13 @@ namespace comphelper void OAccessibleContextHelper::lateInit( const Reference< XAccessible >& _rxAccessible ) { - m_pImpl->setCreator( _rxAccessible ); + m_aCreator = _rxAccessible; } Reference< XAccessible > OAccessibleContextHelper::getAccessibleCreator( ) const { - return m_pImpl->getCreator(); + return m_aCreator; } @@ -218,7 +187,7 @@ namespace comphelper if ( xParentContext.is() ) { // our own XAccessible for comparing with the children of our parent - Reference< XAccessible > xCreator( m_pImpl->getCreator() ); + Reference< XAccessible > xCreator( m_aCreator); OSL_ENSURE( xCreator.is(), "OAccessibleContextHelper::getAccessibleIndexInParent: invalid creator!" ); // two ideas why this could be NULL: diff --git a/include/comphelper/accessiblecontexthelper.hxx b/include/comphelper/accessiblecontexthelper.hxx index e22dacbe6411..dc367fbe1703 100644 --- a/include/comphelper/accessiblecontexthelper.hxx +++ b/include/comphelper/accessiblecontexthelper.hxx @@ -24,9 +24,9 @@ #include <cppuhelper/basemutex.hxx> #include <com/sun/star/accessibility/XAccessibleContext2.hpp> #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/comphelperdllapi.h> #include <comphelper/solarmutex.hxx> -#include <memory> namespace comphelper @@ -36,7 +36,6 @@ namespace comphelper //= OAccessibleContextHelper - class OContextHelper_Impl; typedef ::cppu::WeakAggComponentImplHelper2 < css::accessibility::XAccessibleContext2, css::accessibility::XAccessibleEventBroadcaster > OAccessibleContextHelper_Base; @@ -49,7 +48,8 @@ namespace comphelper { friend class OContextEntryGuard; private: - std::unique_ptr<OContextHelper_Impl> m_pImpl; + css::uno::WeakReference< css::accessibility::XAccessible > m_aCreator; // the XAccessible which created our XAccessibleContext + AccessibleEventNotifier::TClientId m_nClientId; protected: virtual ~OAccessibleContextHelper( ) override; |