diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2025-01-28 12:40:14 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2025-01-29 08:26:19 +0100 |
commit | 735b2109f0cfb7f8f5fe2188a8e3ed6a71aa123d (patch) | |
tree | f6f20305bc6f05eb61ba45644b7418d4555634de /vcl/source | |
parent | cc8d33cb4da053e4f7738ddf42660e60c0965e79 (diff) |
a11y: Use OAccessibleComponentHelper for AccessibleListBoxEntry
Similar to how
commit 7107db3fe773629cc511eb5922bc9c28c9c5c60a
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Fri Jan 24 18:57:58 2025 +0100
toolkit a11y: Use OAccessibleComponentHelper for grid control
did for AccessibleGridControlBase, also derive
from OAccessibleComponentHelper for AccessibleListBoxEntry,
to make use of the logic already implemented there
instead of having to implement all the XAccessibleComponent
and XAccessibleEventBroadcaster methods manually
AccessibleListBoxEntry::GetBoundingBox_Impl already
provides what is needed to implement
AccessibleListBoxEntry::implGetBounds, just needs
to convert to awt::Rectangle.
Drop all of the other overrides that are no longer
needed as the implementation is now provided by
the OAccessibleComponentHelper base class.
No change in behavior intended or observed when
testing this with Accerciser and Orca and the qt6
VCL plugin with the "Tools" -> "AutoText" dialog
in Writer, where this code path is used for
items in the treeview.
Change-Id: I5c95bc6135db92a6e9d736a134af2cbcc35a5e06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180840
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/accessibility/accessiblelistboxentry.cxx | 122 |
1 files changed, 7 insertions, 115 deletions
diff --git a/vcl/source/accessibility/accessiblelistboxentry.cxx b/vcl/source/accessibility/accessiblelistboxentry.cxx index 25ba2632137d..e6b690026635 100644 --- a/vcl/source/accessibility/accessiblelistboxentry.cxx +++ b/vcl/source/accessibility/accessiblelistboxentry.cxx @@ -55,27 +55,16 @@ namespace accessibility AccessibleListBoxEntry::AccessibleListBoxEntry( SvTreeListBox& _rListBox, SvTreeListEntry& rEntry, AccessibleListBox & rListBox) - : AccessibleListBoxEntry_BASE( m_aMutex ) + : AccessibleListBoxEntry_BASE() , m_pTreeListBox( &_rListBox ) , m_pSvLBoxEntry(&rEntry) - , m_nClientId( 0 ) , m_wListBox(&rListBox) { m_pTreeListBox->AddEventListener( LINK( this, AccessibleListBoxEntry, WindowEventListener ) ); _rListBox.FillEntryPath( m_pSvLBoxEntry, m_aEntryPath ); } - AccessibleListBoxEntry::~AccessibleListBoxEntry() - { - if ( IsAlive_Impl() ) - { - // increment ref count to prevent double call of Dtor - osl_atomic_increment( &m_refCount ); - dispose(); - } - } - IMPL_LINK( AccessibleListBoxEntry, WindowEventListener, VclWindowEvent&, rEvent, void ) { OSL_ENSURE( rEvent.GetWindow() , "AccessibleListBoxEntry::WindowEventListener: no event window!" ); @@ -114,18 +103,6 @@ namespace accessibility } } - void AccessibleListBoxEntry::NotifyAccessibleEvent( sal_Int16 _nEventId, - const css::uno::Any& _aOldValue, - const css::uno::Any& _aNewValue ) - { - Reference< uno::XInterface > xSource( *this ); - AccessibleEventObject aEventObj( xSource, _nEventId, _aNewValue, _aOldValue, -1 ); - - if (m_nClientId) - comphelper::AccessibleEventNotifier::addEvent( m_nClientId, aEventObj ); - } - - tools::Rectangle AccessibleListBoxEntry::GetBoundingBox_Impl() const { tools::Rectangle aRect; @@ -146,21 +123,6 @@ namespace accessibility return aRect; } - tools::Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen_Impl() const - { - tools::Rectangle aRect; - SvTreeListEntry* pEntry = m_pTreeListBox->GetEntryFromPath( m_aEntryPath ); - if ( pEntry ) - { - aRect = m_pTreeListBox->GetBoundingRect( pEntry ); - Point aTopLeft = aRect.TopLeft(); - aTopLeft += Point(m_pTreeListBox->GetWindowExtentsAbsolute().TopLeft()); - aRect = tools::Rectangle( aTopLeft, aRect.GetSize() ); - } - - return aRect; - } - bool AccessibleListBoxEntry::IsAlive_Impl() const { return !rBHelper.bDisposed && !rBHelper.bInDispose && (m_pTreeListBox != nullptr); @@ -193,15 +155,6 @@ namespace accessibility return GetBoundingBox_Impl(); } - tools::Rectangle AccessibleListBoxEntry::GetBoundingBoxOnScreen() - { - SolarMutexGuard aSolarGuard; - ::osl::MutexGuard aGuard( m_aMutex ); - - EnsureIsAlive(); - return GetBoundingBoxOnScreen_Impl(); - } - void AccessibleListBoxEntry::CheckActionIndex(sal_Int32 nIndex) { if (nIndex < 0 || nIndex >= getAccessibleActionCount()) @@ -232,6 +185,11 @@ namespace accessibility nEndIndex = 0; } + css::awt::Rectangle AccessibleListBoxEntry::implGetBounds() + { + return vcl::unohelper::ConvertToAWTRect(GetBoundingBox_Impl()); + } + // XTypeProvider Sequence< sal_Int8 > AccessibleListBoxEntry::getImplementationId() { @@ -248,13 +206,7 @@ namespace accessibility Reference< XAccessible > xKeepAlive( this ); - // Send a disposing to all listeners. - if ( m_nClientId ) - { - ::comphelper::AccessibleEventNotifier::TClientId nId = m_nClientId; - m_nClientId = 0; - ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); - } + OAccessibleComponentHelper::disposing(); // clean up m_wListBox.clear(); @@ -520,12 +472,6 @@ namespace accessibility // XAccessibleComponent - sal_Bool SAL_CALL AccessibleListBoxEntry::containsPoint( const awt::Point& rPoint ) - { - return tools::Rectangle(Point(), GetBoundingBox().GetSize()) - .Contains(vcl::unohelper::ConvertToVCLPoint(rPoint)); - } - Reference< XAccessible > SAL_CALL AccessibleListBoxEntry::getAccessibleAtPoint( const awt::Point& _aPoint ) { SolarMutexGuard aSolarGuard; @@ -547,26 +493,6 @@ namespace accessibility return xAcc; } - awt::Rectangle SAL_CALL AccessibleListBoxEntry::getBounds( ) - { - return vcl::unohelper::ConvertToAWTRect(GetBoundingBox()); - } - - awt::Point SAL_CALL AccessibleListBoxEntry::getLocation( ) - { - return vcl::unohelper::ConvertToAWTPoint(GetBoundingBox().TopLeft()); - } - - awt::Point SAL_CALL AccessibleListBoxEntry::getLocationOnScreen( ) - { - return vcl::unohelper::ConvertToAWTPoint(GetBoundingBoxOnScreen().TopLeft()); - } - - awt::Size SAL_CALL AccessibleListBoxEntry::getSize( ) - { - return vcl::unohelper::ConvertToAWTSize(GetBoundingBox().GetSize()); - } - void SAL_CALL AccessibleListBoxEntry::grabFocus( ) { // do nothing, because no focus for each item @@ -682,40 +608,6 @@ namespace accessibility return false; } - // XAccessibleEventBroadcaster - - void SAL_CALL AccessibleListBoxEntry::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) - { - if (xListener.is()) - { - ::osl::MutexGuard aGuard( m_aMutex ); - if (!m_nClientId) - m_nClientId = comphelper::AccessibleEventNotifier::registerClient( ); - comphelper::AccessibleEventNotifier::addEventListener( m_nClientId, xListener ); - } - } - - void SAL_CALL AccessibleListBoxEntry::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) - { - if (!xListener.is()) - return; - - ::osl::MutexGuard aGuard( m_aMutex ); - - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( m_nClientId, xListener ); - 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 - sal_Int32 nId = m_nClientId; - m_nClientId = 0; - comphelper::AccessibleEventNotifier::revokeClient( nId ); - - } - } - // XAccessibleAction sal_Int32 SAL_CALL AccessibleListBoxEntry::getAccessibleActionCount( ) |