accessibility/inc/extended/accessibleiconchoicectrlentry.hxx | 25 +-- accessibility/source/extended/accessibleiconchoicectrl.cxx | 31 +--- accessibility/source/extended/accessibleiconchoicectrlentry.cxx | 69 ---------- 3 files changed, 22 insertions(+), 103 deletions(-)
New commits: commit 1c892a7729234202e6ce14e116e91786b248835a Author: Michael Weghorn <[email protected]> AuthorDate: Thu Jul 11 16:54:09 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Jul 12 07:03:45 2024 +0200 icon choice ctrl entry a11y: Use OAccessibleComponentHelper as base Let `AccessibleIconChoiceCtrlEntry` derive from `comphelper::OAccessibleComponentHelper` which allows simplifying the class. It just requires implementing the virtual `implGetBounds()` method and provides implementations for the the other location/size-related methods using that, so drop the custom implementations doing the same. This also makes it unnecessary to implement the `XAccessibleEventBroadcaster` methods ourselves, so drop the custom handling and `AccessibleIconChoiceCtrlEntry::m_nClientId` altogether as well. Change-Id: Iaa14293a911ea7b199a21baf8c5c3cfb5075efcf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170380 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/accessibility/inc/extended/accessibleiconchoicectrlentry.hxx b/accessibility/inc/extended/accessibleiconchoicectrlentry.hxx index b2430481e58c..c94672c877f2 100644 --- a/accessibility/inc/extended/accessibleiconchoicectrlentry.hxx +++ b/accessibility/inc/extended/accessibleiconchoicectrlentry.hxx @@ -27,8 +27,8 @@ #include <com/sun/star/accessibility/XAccessibleAction.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <cppuhelper/compbase.hxx> #include <cppuhelper/basemutex.hxx> +#include <cppuhelper/implbase.hxx> #include <comphelper/accessibletexthelper.hxx> #include <tools/gen.hxx> #include <vcl/vclptr.hxx> @@ -42,27 +42,21 @@ namespace accessibility { - typedef ::cppu::WeakComponentImplHelper< css::accessibility::XAccessible - , css::accessibility::XAccessibleContext - , css::accessibility::XAccessibleComponent - , css::accessibility::XAccessibleEventBroadcaster + typedef ::cppu::ImplInheritanceHelper< comphelper::OAccessibleComponentHelper + , css::accessibility::XAccessible , css::accessibility::XAccessibleText , css::accessibility::XAccessibleAction , css::lang::XServiceInfo , css::lang::XEventListener > AccessibleIconChoiceCtrlEntry_BASE; /** the class AccessibleListBoxEntry represents the class for an accessible object of a listbox entry */ - class AccessibleIconChoiceCtrlEntry final : public ::cppu::BaseMutex, - public AccessibleIconChoiceCtrlEntry_BASE, + class AccessibleIconChoiceCtrlEntry final : public AccessibleIconChoiceCtrlEntry_BASE, public ::comphelper::OCommonAccessibleText { /** The treelistbox control */ VclPtr<SvtIconChoiceCtrl> m_pIconCtrl; sal_Int32 m_nIndex; - /// client id in the AccessibleEventNotifier queue - sal_uInt32 m_nClientId; - css::uno::Reference< css::accessibility::XAccessible > m_xParent; tools::Rectangle GetBoundingBox_Impl() const; @@ -84,6 +78,9 @@ namespace accessibility */ virtual void SAL_CALL disposing() override; + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds() override; + // OCommonAccessibleText virtual OUString implGetText() override; virtual css::lang::Locale implGetLocale() override; @@ -129,12 +126,8 @@ namespace accessibility virtual css::lang::Locale SAL_CALL getLocale( ) override; // XAccessibleComponent - virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; - virtual css::awt::Rectangle SAL_CALL getBounds( ) override; - virtual css::awt::Point SAL_CALL getLocation( ) override; virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; - virtual css::awt::Size SAL_CALL getSize( ) override; virtual void SAL_CALL grabFocus( ) override; virtual sal_Int32 SAL_CALL getForeground( ) override; virtual sal_Int32 SAL_CALL getBackground( ) override; @@ -159,10 +152,6 @@ namespace accessibility virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; - // 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; - // XAccessibleAction virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex ) override; diff --git a/accessibility/source/extended/accessibleiconchoicectrlentry.cxx b/accessibility/source/extended/accessibleiconchoicectrlentry.cxx index ed43172a4753..1d6fe874c203 100644 --- a/accessibility/source/extended/accessibleiconchoicectrlentry.cxx +++ b/accessibility/source/extended/accessibleiconchoicectrlentry.cxx @@ -60,12 +60,8 @@ namespace accessibility AccessibleIconChoiceCtrlEntry::AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl, sal_Int32 _nPos, const Reference< XAccessible >& _xParent ) : - - AccessibleIconChoiceCtrlEntry_BASE ( m_aMutex ), - m_pIconCtrl ( &_rIconCtrl ), m_nIndex ( _nPos ), - m_nClientId ( 0 ), m_xParent ( _xParent ) { @@ -163,6 +159,11 @@ namespace accessibility throw lang::DisposedException(); } + css::awt::Rectangle AccessibleIconChoiceCtrlEntry::implGetBounds() + { + return VCLUnoHelper::ConvertToAWTRect(GetBoundingBox_Impl()); + } + OUString AccessibleIconChoiceCtrlEntry::implGetText() { SvxIconChoiceCtrlEntry* pEntry = m_pIconCtrl->GetEntry( m_nIndex ); @@ -195,13 +196,7 @@ namespace accessibility { ::osl::MutexGuard aGuard( m_aMutex ); - // Send a disposing to all listeners. - if ( m_nClientId ) - { - sal_uInt32 nId = m_nClientId; - m_nClientId = 0; - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nId, *this ); - } + comphelper::OAccessibleComponentHelper::disposing(); Reference< XComponent > xComp( m_xParent, UNO_QUERY ); if ( xComp.is() ) @@ -331,37 +326,16 @@ namespace accessibility // XAccessibleComponent - sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::containsPoint( const awt::Point& rPoint ) - { - return tools::Rectangle(Point(), GetBoundingBox().GetSize()) - .Contains(VCLUnoHelper::ConvertToVCLPoint(rPoint)); - } - Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrlEntry::getAccessibleAtPoint( const awt::Point& ) { return Reference< XAccessible >(); } - awt::Rectangle SAL_CALL AccessibleIconChoiceCtrlEntry::getBounds( ) - { - return VCLUnoHelper::ConvertToAWTRect(GetBoundingBox()); - } - - awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocation( ) - { - return VCLUnoHelper::ConvertToAWTPoint(GetBoundingBox().TopLeft()); - } - awt::Point SAL_CALL AccessibleIconChoiceCtrlEntry::getLocationOnScreen( ) { return VCLUnoHelper::ConvertToAWTPoint( GetBoundingBoxOnScreen().TopLeft() ); } - awt::Size SAL_CALL AccessibleIconChoiceCtrlEntry::getSize( ) - { - return VCLUnoHelper::ConvertToAWTSize(GetBoundingBox().GetSize()); - } - void SAL_CALL AccessibleIconChoiceCtrlEntry::grabFocus( ) { // do nothing, because no focus for each item @@ -477,37 +451,6 @@ namespace accessibility // XAccessibleEventBroadcaster - void SAL_CALL AccessibleIconChoiceCtrlEntry::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 AccessibleIconChoiceCtrlEntry::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 ); - } - } - sal_Int32 SAL_CALL AccessibleIconChoiceCtrlEntry::getCaretPosition( ) { return -1; commit a8314f77a4735d50b51dacddc810a3790faf35dc Author: Michael Weghorn <[email protected]> AuthorDate: Wed Jul 10 11:39:11 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Jul 12 07:03:35 2024 +0200 icon choice ctrl a11y: Drop extra check `AccessibleIconChoiceCtrl::getAccessibleChildCount` returns the the number of elements in the `SvxIconChoiceCtrl_Impl::maEntries` vector, and `SvtIconChoiceCtrl->GetEntry` returns the the element at the given index. Given the index check above, a valid entry should always be there, so drop the extra check that would throw a RuntimeException in `AccessibleIconChoiceCtrl::getAccessibleChild`. The `pEntry` isn't otherwise used right here anyway. Change-Id: I446b6d8d92780d484ebf5fc531bfa51a7c87cac7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170372 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/accessibility/source/extended/accessibleiconchoicectrl.cxx b/accessibility/source/extended/accessibleiconchoicectrl.cxx index 950e5aa62b7d..84283e20ee2c 100644 --- a/accessibility/source/extended/accessibleiconchoicectrl.cxx +++ b/accessibility/source/extended/accessibleiconchoicectrl.cxx @@ -160,12 +160,6 @@ namespace accessibility throw IndexOutOfBoundsException(); VclPtr<SvtIconChoiceCtrl> pCtrl = getCtrl(); - SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry(i); - if ( !pEntry ) - throw RuntimeException("getAccessibleChild: Entry " - + OUString::number(i) + " not found", - getXWeak()); - return new AccessibleIconChoiceCtrlEntry( *pCtrl, i, this ); } commit 705d64253357313ce9630e533fd6b6823fc50dfc Author: Michael Weghorn <[email protected]> AuthorDate: Wed Jul 10 11:28:26 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Jul 12 07:03:22 2024 +0200 icon choice ctrl a11y: Clean up/simplify selection handling As mentioned in Change-Id: I852b5bf7480daf18bfdf26c3105849c27624ad8c Author: Michael Weghorn <[email protected]> Date: Wed Jul 10 10:18:42 2024 +0200 icon choice ctrl a11y: Don't allow unselecting entry , only a single entry can be selected, and that one can be retrieved via `SvtIconChoiceCtrl::GetCursor` and set via `SvtIconChoiceCtrl::SetCursor`. Therefore, don't try to set multiple cursors in `AccessibleIconChoiceCtrl::selectAllAccessibleChildren` and don't loop over all entries in `AccessibleIconChoiceCtrl::getSelectedAccessibleChildCount`. Change-Id: I9b01c76a546b3d385a91e87d1a8e29e80a4aef17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170371 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/accessibility/source/extended/accessibleiconchoicectrl.cxx b/accessibility/source/extended/accessibleiconchoicectrl.cxx index a21d58ef3ce5..950e5aa62b7d 100644 --- a/accessibility/source/extended/accessibleiconchoicectrl.cxx +++ b/accessibility/source/extended/accessibleiconchoicectrl.cxx @@ -238,31 +238,25 @@ namespace accessibility { ::comphelper::OExternalLockGuard aGuard( this ); + // don't do anything if there are no or multiple entries, as only + // a single one can be selected VclPtr<SvtIconChoiceCtrl> pCtrl = getCtrl(); sal_Int32 nCount = pCtrl->GetEntryCount(); - for ( sal_Int32 i = 0; i < nCount; ++i ) - { - SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); - if ( pCtrl->GetCursor() != pEntry ) - pCtrl->SetCursor( pEntry ); - } + if (nCount != 1) + return; + + pCtrl->SetCursor(pCtrl->GetEntry(0)); } sal_Int64 SAL_CALL AccessibleIconChoiceCtrl::getSelectedAccessibleChildCount( ) { ::comphelper::OExternalLockGuard aGuard( this ); - sal_Int64 nSelCount = 0; VclPtr<SvtIconChoiceCtrl> pCtrl = getCtrl(); - sal_Int32 nCount = pCtrl->GetEntryCount(); - for ( sal_Int32 i = 0; i < nCount; ++i ) - { - SvxIconChoiceCtrlEntry* pEntry = pCtrl->GetEntry( i ); - if ( pCtrl->GetCursor() == pEntry ) - ++nSelCount; - } + if (pCtrl->GetCursor()) + return 1; - return nSelCount; + return 0; } Reference< XAccessible > SAL_CALL AccessibleIconChoiceCtrl::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) commit 8442163e22a271f19347f5584ef18a7e7a13b9af Author: Michael Weghorn <[email protected]> AuthorDate: Wed Jul 10 11:05:38 2024 +0200 Commit: Michael Weghorn <[email protected]> CommitDate: Fri Jul 12 07:03:15 2024 +0200 icon choice ctrl a11y: Don't report selectable state for list/tabbar While entries can be selected and the `SELECTABLE` and `SELECTED` states are reported accordingly for them in `AccessibleIconChoiceCtrlEntry::getAccessibleStateSet`, reporting the selectable state doesn't make sense for the `AccessibleIconChoiceCtrl` itself, so drop that. (The `SELECTED` state also was never reported, without which the `SELECTABLE` state doesn't make much sense.) Change-Id: I8e7e501b9052b47babc835b6e03266f2cbfcf699 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170370 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/accessibility/source/extended/accessibleiconchoicectrl.cxx b/accessibility/source/extended/accessibleiconchoicectrl.cxx index 061b7274e024..a21d58ef3ce5 100644 --- a/accessibility/source/extended/accessibleiconchoicectrl.cxx +++ b/accessibility/source/extended/accessibleiconchoicectrl.cxx @@ -309,7 +309,6 @@ namespace accessibility { rStateSet |= AccessibleStateType::FOCUSABLE; rStateSet |= AccessibleStateType::MANAGES_DESCENDANTS; - rStateSet |= AccessibleStateType::SELECTABLE; } }
