comphelper/source/misc/accessiblecomponenthelper.cxx | 379 ++++++++--------- include/comphelper/accessiblecomponenthelper.hxx | 250 +++++------ svx/source/accessibility/GraphCtlAccessibleContext.cxx | 32 - svx/source/inc/GraphCtlAccessibleContext.hxx | 1 4 files changed, 314 insertions(+), 348 deletions(-)
New commits: commit 6c152f0934e23410dcd5a61dfff0800baf3eff17 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Apr 11 09:06:38 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Apr 11 10:40:46 2025 +0200 comphelper a11y: Drop extra indentation level Change-Id: I5e53e5d12d6f069d9e53b8247e4d39eeeada0a6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184004 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/comphelper/source/misc/accessiblecomponenthelper.cxx b/comphelper/source/misc/accessiblecomponenthelper.cxx index 91959d8eab74..4e490e40eb92 100644 --- a/comphelper/source/misc/accessiblecomponenthelper.cxx +++ b/comphelper/source/misc/accessiblecomponenthelper.cxx @@ -28,256 +28,255 @@ namespace comphelper { +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::accessibility; + +OAccessibleComponentHelper::OAccessibleComponentHelper() + :WeakComponentImplHelper( GetMutex() ) + ,m_nClientId( 0 ) +{ +} - using namespace ::com::sun::star; - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::lang; - using namespace ::com::sun::star::accessibility; - - OAccessibleComponentHelper::OAccessibleComponentHelper() - :WeakComponentImplHelper( GetMutex() ) - ,m_nClientId( 0 ) - { - } +OAccessibleComponentHelper::~OAccessibleComponentHelper() +{ + // this ensures that the lock, which may be already destroyed as part of the derivee, + // is not used anymore - OAccessibleComponentHelper::~OAccessibleComponentHelper() - { - // this ensures that the lock, which may be already destroyed as part of the derivee, - // is not used anymore + ensureDisposed(); +} - ensureDisposed(); - } +void SAL_CALL OAccessibleComponentHelper::disposing() +{ + // rhbz#1001768: de facto this class is locked by SolarMutex; + // do not lock m_Mutex because it may cause deadlock + osl::Guard<SolarMutex> aGuard(SolarMutex::get()); - void SAL_CALL OAccessibleComponentHelper::disposing() + if ( m_nClientId ) { - // rhbz#1001768: de facto this class is locked by SolarMutex; - // do not lock m_Mutex because it may cause deadlock - osl::Guard<SolarMutex> aGuard(SolarMutex::get()); - - if ( m_nClientId ) - { - AccessibleEventNotifier::revokeClientNotifyDisposing( m_nClientId, *this ); - m_nClientId=0; - } + AccessibleEventNotifier::revokeClientNotifyDisposing( m_nClientId, *this ); + m_nClientId=0; } +} - void SAL_CALL OAccessibleComponentHelper::addAccessibleEventListener(const Reference< XAccessibleEventListener >& _rxListener) - { - osl::Guard<SolarMutex> aGuard(SolarMutex::get()); - // don't use the OContextEntryGuard - it will throw an exception if we're not alive - // anymore, while the most recent specification for XComponent states that we should - // silently ignore the call in such a situation +void SAL_CALL OAccessibleComponentHelper::addAccessibleEventListener(const Reference< XAccessibleEventListener >& _rxListener) +{ + osl::Guard<SolarMutex> aGuard(SolarMutex::get()); + // don't use the OContextEntryGuard - it will throw an exception if we're not alive + // anymore, while the most recent specification for XComponent states that we should + // silently ignore the call in such a situation - if (!_rxListener.is()) - return; + if (!_rxListener.is()) + return; - if ( !isAlive() ) - { - _rxListener->disposing( EventObject( *this ) ); - return; - } + if ( !isAlive() ) + { + _rxListener->disposing( EventObject( *this ) ); + return; + } - if (!m_nClientId) - m_nClientId = AccessibleEventNotifier::registerClient(); + if (!m_nClientId) + m_nClientId = AccessibleEventNotifier::registerClient(); - AccessibleEventNotifier::addEventListener(m_nClientId, _rxListener); - } + AccessibleEventNotifier::addEventListener(m_nClientId, _rxListener); +} - void SAL_CALL OAccessibleComponentHelper::removeAccessibleEventListener(const Reference< XAccessibleEventListener >& _rxListener) +void SAL_CALL OAccessibleComponentHelper::removeAccessibleEventListener(const Reference< XAccessibleEventListener >& _rxListener) +{ + osl::Guard<SolarMutex> aGuard(SolarMutex::get()); + // don't use the OContextEntryGuard - it will throw an exception if we're not alive + // anymore, while the most recent specification for XComponent states that we should + // silently ignore the call in such a situation + if ( !isAlive() ) + return; + + if ( !(_rxListener.is() && m_nClientId) ) + return; + + sal_Int32 nListenerCount = AccessibleEventNotifier::removeEventListener( m_nClientId, _rxListener ); + if ( !nListenerCount ) { - osl::Guard<SolarMutex> aGuard(SolarMutex::get()); - // don't use the OContextEntryGuard - it will throw an exception if we're not alive - // anymore, while the most recent specification for XComponent states that we should - // silently ignore the call in such a situation - if ( !isAlive() ) - return; - - if ( !(_rxListener.is() && m_nClientId) ) - return; - - 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_nClientId ); - m_nClientId = 0; - } + // 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_nClientId ); + m_nClientId = 0; } +} - void OAccessibleComponentHelper::NotifyAccessibleEvent( const sal_Int16 _nEventId, - const Any& _rOldValue, const Any& _rNewValue, sal_Int32 nIndexHint ) - { - 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; +void OAccessibleComponentHelper::NotifyAccessibleEvent( const sal_Int16 _nEventId, + const Any& _rOldValue, const Any& _rNewValue, sal_Int32 nIndexHint ) +{ + 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; - // build an event object - AccessibleEventObject aEvent(*this, _nEventId, _rNewValue, _rOldValue, nIndexHint); + // build an event object + AccessibleEventObject aEvent(*this, _nEventId, _rNewValue, _rOldValue, nIndexHint); - // let the notifier handle this event - AccessibleEventNotifier::addEvent( m_nClientId, aEvent ); - } + // let the notifier handle this event + AccessibleEventNotifier::addEvent( m_nClientId, aEvent ); +} - bool OAccessibleComponentHelper::hasAccessibleListeners() const - { - return m_nClientId != 0; - } +bool OAccessibleComponentHelper::hasAccessibleListeners() const +{ + return m_nClientId != 0; +} - bool OAccessibleComponentHelper::isAlive() const - { - return !rBHelper.bDisposed && !rBHelper.bInDispose; - } +bool OAccessibleComponentHelper::isAlive() const +{ + return !rBHelper.bDisposed && !rBHelper.bInDispose; +} - void OAccessibleComponentHelper::ensureAlive() const - { - if( !isAlive() ) - throw DisposedException(); - } +void OAccessibleComponentHelper::ensureAlive() const +{ + if( !isAlive() ) + throw DisposedException(); +} - void OAccessibleComponentHelper::ensureDisposed( ) +void OAccessibleComponentHelper::ensureDisposed( ) +{ + if ( !rBHelper.bDisposed ) { - if ( !rBHelper.bDisposed ) - { - OSL_ENSURE( 0 == m_refCount, "OAccessibleComponentHelper::ensureDisposed: this method _has_ to be called from without your dtor only!" ); - acquire(); - dispose(); - } + OSL_ENSURE( 0 == m_refCount, "OAccessibleComponentHelper::ensureDisposed: this method _has_ to be called from without your dtor only!" ); + acquire(); + dispose(); } +} + +OUString SAL_CALL OAccessibleComponentHelper::getAccessibleId() +{ + return OUString(); +} - OUString SAL_CALL OAccessibleComponentHelper::getAccessibleId() - { - return OUString(); - } +sal_Int64 SAL_CALL OAccessibleComponentHelper::getAccessibleIndexInParent() +{ + OExternalLockGuard aGuard( this ); - sal_Int64 SAL_CALL OAccessibleComponentHelper::getAccessibleIndexInParent() + try { - OExternalLockGuard aGuard( this ); + Reference< XAccessibleContext > xParentContext( implGetParentContext() ); + if (!xParentContext.is()) + return -1; - try - { - Reference< XAccessibleContext > xParentContext( implGetParentContext() ); - if (!xParentContext.is()) - return -1; - - // iterate over parent's children and search for this object - sal_Int64 nChildCount = xParentContext->getAccessibleChildCount(); - for (sal_Int64 nChild = 0; nChild < nChildCount; ++nChild) - { - Reference< XAccessible > xChild( xParentContext->getAccessibleChild( nChild ) ); - if (xChild.is() && xChild->getAccessibleContext().get() == this) - return nChild; - } - } - catch( const Exception& ) + // iterate over parent's children and search for this object + sal_Int64 nChildCount = xParentContext->getAccessibleChildCount(); + for (sal_Int64 nChild = 0; nChild < nChildCount; ++nChild) { - OSL_FAIL("OAccessibleComponentHelper::getAccessibleIndexInParent: caught an exception!"); + Reference< XAccessible > xChild( xParentContext->getAccessibleChild( nChild ) ); + if (xChild.is() && xChild->getAccessibleContext().get() == this) + return nChild; } - - return -1; } - - - Locale SAL_CALL OAccessibleComponentHelper::getLocale() + catch( const Exception& ) { - // simply ask the parent - Reference< XAccessible > xParent = getAccessibleParent(); - Reference< XAccessibleContext > xParentContext; - if ( xParent.is() ) - xParentContext = xParent->getAccessibleContext(); + OSL_FAIL("OAccessibleComponentHelper::getAccessibleIndexInParent: caught an exception!"); + } - if ( !xParentContext.is() ) - throw IllegalAccessibleComponentStateException( OUString(), *this ); + return -1; +} - return xParentContext->getLocale(); - } +Locale SAL_CALL OAccessibleComponentHelper::getLocale() +{ + // simply ask the parent + Reference< XAccessible > xParent = getAccessibleParent(); + Reference< XAccessibleContext > xParentContext; + if ( xParent.is() ) + xParentContext = xParent->getAccessibleContext(); - Reference< XAccessibleContext > OAccessibleComponentHelper::implGetParentContext() - { - Reference< XAccessible > xParent = getAccessibleParent(); - Reference< XAccessibleContext > xParentContext; - if ( xParent.is() ) - xParentContext = xParent->getAccessibleContext(); - return xParentContext; - } + if ( !xParentContext.is() ) + throw IllegalAccessibleComponentStateException( OUString(), *this ); + return xParentContext->getLocale(); +} - sal_Bool SAL_CALL OAccessibleComponentHelper::containsPoint(const awt::Point& _rPoint) - { - OExternalLockGuard aGuard( this ); - awt::Rectangle aBounds( implGetBounds() ); - return ( _rPoint.X >= 0 ) - && ( _rPoint.Y >= 0 ) - && ( _rPoint.X < aBounds.Width ) - && ( _rPoint.Y < aBounds.Height ); - } +Reference< XAccessibleContext > OAccessibleComponentHelper::implGetParentContext() +{ + Reference< XAccessible > xParent = getAccessibleParent(); + Reference< XAccessibleContext > xParentContext; + if ( xParent.is() ) + xParentContext = xParent->getAccessibleContext(); + return xParentContext; +} - awt::Point SAL_CALL OAccessibleComponentHelper::getLocation() - { - OExternalLockGuard aGuard( this ); - awt::Rectangle aBounds( implGetBounds() ); - return awt::Point( aBounds.X, aBounds.Y ); - } +sal_Bool SAL_CALL OAccessibleComponentHelper::containsPoint(const awt::Point& _rPoint) +{ + OExternalLockGuard aGuard( this ); + awt::Rectangle aBounds( implGetBounds() ); + return ( _rPoint.X >= 0 ) + && ( _rPoint.Y >= 0 ) + && ( _rPoint.X < aBounds.Width ) + && ( _rPoint.Y < aBounds.Height ); +} - awt::Point SAL_CALL OAccessibleComponentHelper::getLocationOnScreen() - { - OExternalLockGuard aGuard( this ); - awt::Point aScreenLoc( 0, 0 ); +awt::Point SAL_CALL OAccessibleComponentHelper::getLocation() +{ + OExternalLockGuard aGuard( this ); + awt::Rectangle aBounds( implGetBounds() ); + return awt::Point( aBounds.X, aBounds.Y ); +} - Reference< XAccessibleComponent > xParentComponent( implGetParentContext(), UNO_QUERY ); - OSL_ENSURE(xParentComponent.is(), "OAccessibleComponentHelper::getLocationOnScreen: no parent component!"); - if ( xParentComponent.is() ) - { - awt::Point aParentScreenLoc( xParentComponent->getLocationOnScreen() ); - awt::Point aOwnRelativeLoc( getLocation() ); - aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X; - aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y; - } - return aScreenLoc; - } +awt::Point SAL_CALL OAccessibleComponentHelper::getLocationOnScreen() +{ + OExternalLockGuard aGuard( this ); + awt::Point aScreenLoc( 0, 0 ); - awt::Size SAL_CALL OAccessibleComponentHelper::getSize() + Reference< XAccessibleComponent > xParentComponent( implGetParentContext(), UNO_QUERY ); + OSL_ENSURE(xParentComponent.is(), "OAccessibleComponentHelper::getLocationOnScreen: no parent component!"); + if ( xParentComponent.is() ) { - OExternalLockGuard aGuard( this ); - awt::Rectangle aBounds( implGetBounds() ); - return awt::Size( aBounds.Width, aBounds.Height ); + awt::Point aParentScreenLoc( xParentComponent->getLocationOnScreen() ); + awt::Point aOwnRelativeLoc( getLocation() ); + aScreenLoc.X = aParentScreenLoc.X + aOwnRelativeLoc.X; + aScreenLoc.Y = aParentScreenLoc.Y + aOwnRelativeLoc.Y; } + return aScreenLoc; +} - awt::Rectangle SAL_CALL OAccessibleComponentHelper::getBounds() - { - OExternalLockGuard aGuard( this ); - return implGetBounds(); - } - OUString SAL_CALL OAccessibleComponentHelper::getTitledBorderText() - { - OExternalLockGuard aGuard(this); - return OUString(); - } +awt::Size SAL_CALL OAccessibleComponentHelper::getSize() +{ + OExternalLockGuard aGuard( this ); + awt::Rectangle aBounds( implGetBounds() ); + return awt::Size( aBounds.Width, aBounds.Height ); +} - OUString SAL_CALL OAccessibleComponentHelper::getToolTipText() - { - OExternalLockGuard aGuard(this); - return OUString(); - } + +awt::Rectangle SAL_CALL OAccessibleComponentHelper::getBounds() +{ + OExternalLockGuard aGuard( this ); + return implGetBounds(); +} + +OUString SAL_CALL OAccessibleComponentHelper::getTitledBorderText() +{ + OExternalLockGuard aGuard(this); + return OUString(); +} + +OUString SAL_CALL OAccessibleComponentHelper::getToolTipText() +{ + OExternalLockGuard aGuard(this); + return OUString(); +} } // namespace comphelper diff --git a/include/comphelper/accessiblecomponenthelper.hxx b/include/comphelper/accessiblecomponenthelper.hxx index 38ffce787a96..40992c15ab0f 100644 --- a/include/comphelper/accessiblecomponenthelper.hxx +++ b/include/comphelper/accessiblecomponenthelper.hxx @@ -34,133 +34,133 @@ namespace comphelper { - //= OAccessibleComponentHelper +//= OAccessibleComponentHelper + +/** a helper class for implementing an AccessibleContext which at the same time + supports an XAccessibleExtendedComponent interface. +*/ +class COMPHELPER_DLLPUBLIC OAccessibleComponentHelper + : public cppu::BaseMutex, + public cppu::WeakComponentImplHelper<css::accessibility::XAccessibleContext2, + css::accessibility::XAccessibleEventBroadcaster, + css::accessibility::XAccessibleExtendedComponent> +{ + friend class OContextEntryGuard; +private: + AccessibleEventNotifier::TClientId m_nClientId; + +protected: + virtual ~OAccessibleComponentHelper( ) override; + + OAccessibleComponentHelper( ); + +private: + OAccessibleComponentHelper(OAccessibleComponentHelper const &) = delete; + OAccessibleComponentHelper(OAccessibleComponentHelper &&) = delete; + void operator =(OAccessibleComponentHelper const &) = delete; + void operator =(OAccessibleComponentHelper &&) = delete; + +public: + // XAccessibleEventBroadcaster + virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; + virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; + + // XAccessibleContext - still waiting to be overwritten + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override = 0; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override = 0; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override = 0; + virtual OUString SAL_CALL getAccessibleDescription( ) override = 0; + virtual OUString SAL_CALL getAccessibleName( ) override = 0; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override = 0; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override = 0; + + // XAccessibleContext2 - default implementation + virtual OUString SAL_CALL getAccessibleId( ) override; + + // XAccessibleContext - default implementations + /** default implementation for retrieving the index of this object within the parent + <p>This basic implementation here returns the index <code>i</code> of the child for which + <code><parent>.getAccessibleChild(i).getAccessibleContext()</code> returns + a reference to this OAccessibleComponentHelper object.</p> + */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + /** default implementation for retrieving the locale + <p>This basic implementation returns the locale of the parent context, + as retrieved via getAccessibleParent()->getAccessibleContext.</p> + */ + virtual css::lang::Locale SAL_CALL getLocale( ) override; + +protected: + // OComponentHelper + virtual void SAL_CALL disposing() override; + +protected: + // helper + /** notifies all AccessibleEventListeners of a certain event + + @precond not to be called with our mutex locked + @param _nEventId + the id of the event. See AccessibleEventType + @param _rOldValue + the old value to be notified + @param _rNewValue + the new value to be notified + */ + void NotifyAccessibleEvent( + const sal_Int16 _nEventId, + const css::uno::Any& _rOldValue, + const css::uno::Any& _rNewValue, + sal_Int32 nIndexHint = -1 + ); + + /// returns whether any accessible listeners are registered + bool hasAccessibleListeners() const; + + // life time control + /// checks whether the object is alive (returns <TRUE/> then) or disposed + bool isAlive() const; + /// checks for being alive. If the object is already disposed (i.e. not alive), an exception is thrown. + void ensureAlive() const; + + /** ensures that the object is disposed. + @precond + to be called from within the destructor of your derived class only! + */ + void ensureDisposed( ); + + /** shortcut for retrieving the context of the parent (returned by getAccessibleParent) + */ + css::uno::Reference< css::accessibility::XAccessibleContext > + implGetParentContext(); + + // access to the base class' broadcast helper/mutex + ::osl::Mutex& GetMutex() { return m_aMutex; } + +protected: + /// implements the calculation of the bounding rectangle - still waiting to be overwritten + /// + /// @throws css::uno::RuntimeException + virtual css::awt::Rectangle implGetBounds( ) = 0; + + +public: + // XAccessibleComponent - default implementations which can be implemented using <method>implGetBounds</method> + virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override final; + virtual css::awt::Point SAL_CALL getLocation( ) override final; + /* note: getLocationOnScreen relies on a valid parent (XAccessibleContext::getParent()->getAccessibleContext()), + which itself implements XAccessibleComponent - /** a helper class for implementing an AccessibleContext which at the same time - supports an XAccessibleExtendedComponent interface. + @throws css::uno::RuntimeException */ - class COMPHELPER_DLLPUBLIC OAccessibleComponentHelper - : public cppu::BaseMutex, - public cppu::WeakComponentImplHelper<css::accessibility::XAccessibleContext2, - css::accessibility::XAccessibleEventBroadcaster, - css::accessibility::XAccessibleExtendedComponent> - { - friend class OContextEntryGuard; - private: - AccessibleEventNotifier::TClientId m_nClientId; - - protected: - virtual ~OAccessibleComponentHelper( ) override; - - OAccessibleComponentHelper( ); - - private: - OAccessibleComponentHelper(OAccessibleComponentHelper const &) = delete; - OAccessibleComponentHelper(OAccessibleComponentHelper &&) = delete; - void operator =(OAccessibleComponentHelper const &) = delete; - void operator =(OAccessibleComponentHelper &&) = delete; - - public: - // XAccessibleEventBroadcaster - virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - - // XAccessibleContext - still waiting to be overwritten - virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override = 0; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override = 0; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override = 0; - virtual sal_Int16 SAL_CALL getAccessibleRole( ) override = 0; - virtual OUString SAL_CALL getAccessibleDescription( ) override = 0; - virtual OUString SAL_CALL getAccessibleName( ) override = 0; - virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override = 0; - virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override = 0; - - // XAccessibleContext2 - default implementation - virtual OUString SAL_CALL getAccessibleId( ) override; - - // XAccessibleContext - default implementations - /** default implementation for retrieving the index of this object within the parent - <p>This basic implementation here returns the index <code>i</code> of the child for which - <code><parent>.getAccessibleChild(i).getAccessibleContext()</code> returns - a reference to this OAccessibleComponentHelper object.</p> - */ - virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; - /** default implementation for retrieving the locale - <p>This basic implementation returns the locale of the parent context, - as retrieved via getAccessibleParent()->getAccessibleContext.</p> - */ - virtual css::lang::Locale SAL_CALL getLocale( ) override; - - protected: - // OComponentHelper - virtual void SAL_CALL disposing() override; - - protected: - // helper - /** notifies all AccessibleEventListeners of a certain event - - @precond not to be called with our mutex locked - @param _nEventId - the id of the event. See AccessibleEventType - @param _rOldValue - the old value to be notified - @param _rNewValue - the new value to be notified - */ - void NotifyAccessibleEvent( - const sal_Int16 _nEventId, - const css::uno::Any& _rOldValue, - const css::uno::Any& _rNewValue, - sal_Int32 nIndexHint = -1 - ); - - /// returns whether any accessible listeners are registered - bool hasAccessibleListeners() const; - - // life time control - /// checks whether the object is alive (returns <TRUE/> then) or disposed - bool isAlive() const; - /// checks for being alive. If the object is already disposed (i.e. not alive), an exception is thrown. - void ensureAlive() const; - - /** ensures that the object is disposed. - @precond - to be called from within the destructor of your derived class only! - */ - void ensureDisposed( ); - - /** shortcut for retrieving the context of the parent (returned by getAccessibleParent) - */ - css::uno::Reference< css::accessibility::XAccessibleContext > - implGetParentContext(); - - // access to the base class' broadcast helper/mutex - ::osl::Mutex& GetMutex() { return m_aMutex; } - - protected: - /// implements the calculation of the bounding rectangle - still waiting to be overwritten - /// - /// @throws css::uno::RuntimeException - virtual css::awt::Rectangle implGetBounds( ) = 0; - - - public: - // XAccessibleComponent - default implementations which can be implemented using <method>implGetBounds</method> - virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override final; - virtual css::awt::Point SAL_CALL getLocation( ) override final; - /* note: getLocationOnScreen relies on a valid parent (XAccessibleContext::getParent()->getAccessibleContext()), - which itself implements XAccessibleComponent - - @throws css::uno::RuntimeException - */ - virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; - virtual css::awt::Size SAL_CALL getSize( ) override final; - virtual css::awt::Rectangle SAL_CALL getBounds( ) override final; - - // XAccessibleExtendedComponent - default implementations returning empty strings - virtual OUString SAL_CALL getTitledBorderText() override; - virtual OUString SAL_CALL getToolTipText() override; - }; + virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; + virtual css::awt::Size SAL_CALL getSize( ) override final; + virtual css::awt::Rectangle SAL_CALL getBounds( ) override final; + + // XAccessibleExtendedComponent - default implementations returning empty strings + virtual OUString SAL_CALL getTitledBorderText() override; + virtual OUString SAL_CALL getToolTipText() override; +}; } // namespace comphelper commit 09f70c8109f8091ca61ab7a0a7283c2a69b1a4d5 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Apr 11 09:04:00 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Apr 11 10:40:40 2025 +0200 svx a11y: Drop SvxGraphCtrlAccessibleContext::getAccessibleIndexInParent The base class implementation in OAccessibleComponentHelper::getAccessibleIndexInParent already implements the same logic. Change-Id: I90abb7a5507644d7ca1f421dbea995050556c1b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184003 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/svx/source/accessibility/GraphCtlAccessibleContext.cxx b/svx/source/accessibility/GraphCtlAccessibleContext.cxx index c60eefb66a7c..58576b31ad35 100644 --- a/svx/source/accessibility/GraphCtlAccessibleContext.cxx +++ b/svx/source/accessibility/GraphCtlAccessibleContext.cxx @@ -217,38 +217,6 @@ Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessiblePa return mpControl->GetDrawingArea()->get_accessible_parent(); } -sal_Int64 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleIndexInParent() -{ - ::SolarMutexGuard aGuard; - // Use a simple but slow solution for now. Optimize later. - - // Iterate over all the parent's children and search for this object. - css::uno::Reference<css::accessibility::XAccessible> xParent(getAccessibleParent()); - if (xParent.is()) - { - Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() ); - if( xParentContext.is() ) - { - sal_Int64 nChildCount = xParentContext->getAccessibleChildCount(); - for( sal_Int64 i = 0 ; i < nChildCount ; ++i ) - { - Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) ); - if( xChild.is() ) - { - Reference< XAccessibleContext > xChildContext = xChild->getAccessibleContext(); - if( xChildContext == static_cast<XAccessibleContext*>(this) ) - return i; - } - } - } - } - - // Return -1 to indicate that this object's parent does not know about the - // object. - return -1; -} - - sal_Int16 SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleRole() { return AccessibleRole::PANEL; diff --git a/svx/source/inc/GraphCtlAccessibleContext.hxx b/svx/source/inc/GraphCtlAccessibleContext.hxx index fca754663de2..be3c552fb02a 100644 --- a/svx/source/inc/GraphCtlAccessibleContext.hxx +++ b/svx/source/inc/GraphCtlAccessibleContext.hxx @@ -90,7 +90,6 @@ public: virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleChild (sal_Int64 nIndex) override; virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override; - virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; virtual sal_Int16 SAL_CALL getAccessibleRole() override; virtual OUString SAL_CALL getAccessibleDescription() override; virtual OUString SAL_CALL getAccessibleName() override;