diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-07-10 11:28:26 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-07-12 07:03:22 +0200 |
commit | 705d64253357313ce9630e533fd6b6823fc50dfc (patch) | |
tree | 7e352e9edf5a9971000eac438604f111bb28aa52 /accessibility/source/extended | |
parent | 8442163e22a271f19347f5584ef18a7e7a13b9af (diff) |
icon choice ctrl a11y: Clean up/simplify selection handling
As mentioned in
Change-Id: I852b5bf7480daf18bfdf26c3105849c27624ad8c
Author: Michael Weghorn <m.weghorn@posteo.de>
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 <m.weghorn@posteo.de>
Tested-by: Jenkins
Diffstat (limited to 'accessibility/source/extended')
-rw-r--r-- | accessibility/source/extended/accessibleiconchoicectrl.cxx | 24 |
1 files changed, 9 insertions, 15 deletions
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 ) |