basctl/source/accessibility/accessibledialogcontrolshape.cxx | 32 - basctl/source/inc/accessibledialogcontrolshape.hxx | 1 comphelper/source/misc/accessibleselectionhelper.cxx | 204 +++++------ include/comphelper/accessibleselectionhelper.hxx | 170 ++++----- solenv/clang-format/excludelist | 2 5 files changed, 174 insertions(+), 235 deletions(-)
New commits: commit e3ea19d05db432ee41f0bac87197ddefe96265f0 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon May 26 22:00:03 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed May 28 18:03:21 2025 +0200 comphelper a11y: clang-format accessibleselectionhelper.h,c}xx ... which in particular gets rid of one extra indentation level. Change-Id: I01e07f8cb7baf1f1f6dc407e6a8eba64cef9fe39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185946 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/comphelper/source/misc/accessibleselectionhelper.cxx b/comphelper/source/misc/accessibleselectionhelper.cxx index ff880a76ee98..3847c9e4310d 100644 --- a/comphelper/source/misc/accessibleselectionhelper.cxx +++ b/comphelper/source/misc/accessibleselectionhelper.cxx @@ -20,147 +20,129 @@ #include <comphelper/accessiblecontexthelper.hxx> #include <comphelper/accessibleselectionhelper.hxx> - namespace comphelper { +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::accessibility; +OCommonAccessibleSelection::OCommonAccessibleSelection() {} - using namespace ::com::sun::star::uno; - using namespace ::com::sun::star::accessibility; - - OCommonAccessibleSelection::OCommonAccessibleSelection( ) - { - } - - OCommonAccessibleSelection::~OCommonAccessibleSelection() {} - - - void OCommonAccessibleSelection::selectAccessibleChild( sal_Int64 nChildIndex ) - { - implSelect( nChildIndex, true ); - } - - - bool OCommonAccessibleSelection::isAccessibleChildSelected( sal_Int64 nChildIndex ) - { - return implIsSelected( nChildIndex ); - } - - - void OCommonAccessibleSelection::clearAccessibleSelection( ) - { - implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, false ); - } +OCommonAccessibleSelection::~OCommonAccessibleSelection() {} +void OCommonAccessibleSelection::selectAccessibleChild(sal_Int64 nChildIndex) +{ + implSelect(nChildIndex, true); +} - void OCommonAccessibleSelection::selectAllAccessibleChildren( ) - { - implSelect( ACCESSIBLE_SELECTION_CHILD_ALL, true ); - } - - - sal_Int64 OCommonAccessibleSelection::getSelectedAccessibleChildCount( ) - { - sal_Int64 nRet = 0; - Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); - - OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); - - if( xParentContext.is() ) - { - for( sal_Int64 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); i < nChildCount; i++ ) - if( implIsSelected( i ) ) - ++nRet; - } - - return nRet; - } - - - Reference< XAccessible > OCommonAccessibleSelection::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) - { - Reference< XAccessible > xRet; - Reference< XAccessibleContext > xParentContext( implGetAccessibleContext() ); - - OSL_ENSURE( xParentContext.is(), "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!" ); - - if( xParentContext.is() ) - { - for( sal_Int64 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; ( i < nChildCount ) && !xRet.is(); i++ ) - if( implIsSelected( i ) && ( nPos++ == nSelectedChildIndex ) ) - xRet = xParentContext->getAccessibleChild( i ); - } - - return xRet; - } +bool OCommonAccessibleSelection::isAccessibleChildSelected(sal_Int64 nChildIndex) +{ + return implIsSelected(nChildIndex); +} +void OCommonAccessibleSelection::clearAccessibleSelection() +{ + implSelect(ACCESSIBLE_SELECTION_CHILD_ALL, false); +} - void OCommonAccessibleSelection::deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) - { - implSelect( nSelectedChildIndex, false ); - } +void OCommonAccessibleSelection::selectAllAccessibleChildren() +{ + implSelect(ACCESSIBLE_SELECTION_CHILD_ALL, true); +} - OAccessibleSelectionHelper::OAccessibleSelectionHelper() - { - } +sal_Int64 OCommonAccessibleSelection::getSelectedAccessibleChildCount() +{ + sal_Int64 nRet = 0; + Reference<XAccessibleContext> xParentContext(implGetAccessibleContext()); + OSL_ENSURE(xParentContext.is(), + "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!"); - Reference< XAccessibleContext > OAccessibleSelectionHelper::implGetAccessibleContext() + if (xParentContext.is()) { - return this; + for (sal_Int64 i = 0, nChildCount = xParentContext->getAccessibleChildCount(); + i < nChildCount; i++) + if (implIsSelected(i)) + ++nRet; } + return nRet; +} - void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild( sal_Int64 nChildIndex ) - { - OExternalLockGuard aGuard( this ); - OCommonAccessibleSelection::selectAccessibleChild( nChildIndex ); - } +Reference<XAccessible> +OCommonAccessibleSelection::getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) +{ + Reference<XAccessible> xRet; + Reference<XAccessibleContext> xParentContext(implGetAccessibleContext()); + OSL_ENSURE(xParentContext.is(), + "OCommonAccessibleSelection::getSelectedAccessibleChildCount: no parent context!"); - sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected( sal_Int64 nChildIndex ) + if (xParentContext.is()) { - OExternalLockGuard aGuard( this ); - return OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex ); + for (sal_Int64 i = 0, nChildCount = xParentContext->getAccessibleChildCount(), nPos = 0; + (i < nChildCount) && !xRet.is(); i++) + if (implIsSelected(i) && (nPos++ == nSelectedChildIndex)) + xRet = xParentContext->getAccessibleChild(i); } + return xRet; +} - void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection( ) - { - OExternalLockGuard aGuard( this ); - OCommonAccessibleSelection::clearAccessibleSelection(); - } - +void OCommonAccessibleSelection::deselectAccessibleChild(sal_Int64 nSelectedChildIndex) +{ + implSelect(nSelectedChildIndex, false); +} - void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren( ) - { - OExternalLockGuard aGuard( this ); - OCommonAccessibleSelection::selectAllAccessibleChildren(); - } +OAccessibleSelectionHelper::OAccessibleSelectionHelper() {} +Reference<XAccessibleContext> OAccessibleSelectionHelper::implGetAccessibleContext() +{ + return this; +} - sal_Int64 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount( ) - { - OExternalLockGuard aGuard( this ); - return OCommonAccessibleSelection::getSelectedAccessibleChildCount(); - } +void SAL_CALL OAccessibleSelectionHelper::selectAccessibleChild(sal_Int64 nChildIndex) +{ + OExternalLockGuard aGuard(this); + OCommonAccessibleSelection::selectAccessibleChild(nChildIndex); +} +sal_Bool SAL_CALL OAccessibleSelectionHelper::isAccessibleChildSelected(sal_Int64 nChildIndex) +{ + OExternalLockGuard aGuard(this); + return OCommonAccessibleSelection::isAccessibleChildSelected(nChildIndex); +} - Reference< XAccessible > SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) - { - OExternalLockGuard aGuard( this ); - return OCommonAccessibleSelection::getSelectedAccessibleChild( nSelectedChildIndex ); - } +void SAL_CALL OAccessibleSelectionHelper::clearAccessibleSelection() +{ + OExternalLockGuard aGuard(this); + OCommonAccessibleSelection::clearAccessibleSelection(); +} +void SAL_CALL OAccessibleSelectionHelper::selectAllAccessibleChildren() +{ + OExternalLockGuard aGuard(this); + OCommonAccessibleSelection::selectAllAccessibleChildren(); +} - void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) - { - OExternalLockGuard aGuard( this ); - OCommonAccessibleSelection::deselectAccessibleChild( nSelectedChildIndex ); - } +sal_Int64 SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChildCount() +{ + OExternalLockGuard aGuard(this); + return OCommonAccessibleSelection::getSelectedAccessibleChildCount(); +} +Reference<XAccessible> + SAL_CALL OAccessibleSelectionHelper::getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) +{ + OExternalLockGuard aGuard(this); + return OCommonAccessibleSelection::getSelectedAccessibleChild(nSelectedChildIndex); +} -} // namespace comphelper +void SAL_CALL OAccessibleSelectionHelper::deselectAccessibleChild(sal_Int64 nSelectedChildIndex) +{ + OExternalLockGuard aGuard(this); + OCommonAccessibleSelection::deselectAccessibleChild(nSelectedChildIndex); +} +} // namespace comphelper /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/comphelper/accessibleselectionhelper.hxx b/include/comphelper/accessibleselectionhelper.hxx index 78bdabcae611..0c749ac0b682 100644 --- a/include/comphelper/accessibleselectionhelper.hxx +++ b/include/comphelper/accessibleselectionhelper.hxx @@ -26,105 +26,97 @@ #include <com/sun/star/accessibility/XAccessibleSelection.hpp> #include <comphelper/comphelperdllapi.h> -#define ACCESSIBLE_SELECTION_CHILD_ALL (sal_Int32(-1)) +#define ACCESSIBLE_SELECTION_CHILD_ALL (sal_Int32(-1)) namespace comphelper { +//= OCommonAccessibleSelection +/** base class encapsulating common functionality for the helper classes implementing + the XAccessibleSelection +*/ +class COMPHELPER_DLLPUBLIC OCommonAccessibleSelection +{ +protected: + OCommonAccessibleSelection(); - //= OCommonAccessibleSelection - - /** base class encapsulating common functionality for the helper classes implementing - the XAccessibleSelection - */ - class COMPHELPER_DLLPUBLIC OCommonAccessibleSelection - { - protected: - - OCommonAccessibleSelection(); - - ~OCommonAccessibleSelection(); - - protected: - - // access to context - still waiting to be overwritten - /// @throws css::uno::RuntimeException - virtual css::uno::Reference< css::accessibility::XAccessibleContext > - implGetAccessibleContext() = 0; - - // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) - /// @throws css::uno::RuntimeException - virtual bool - implIsSelected( sal_Int64 nAccessibleChildIndex ) = 0; - - // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) - /// @throws css::uno::RuntimeException - virtual void - implSelect( sal_Int64 nAccessibleChildIndex, bool bSelect ) = 0; - - protected: - - /** non-virtual versions of the methods which can be implemented using <method>implIsSelected</method> and <method>implSelect</method> - - @throws css::lang::IndexOutOfBoundsException - @throws css::uno::RuntimeException - */ - void selectAccessibleChild( sal_Int64 nChildIndex ); - /// @throws css::lang::IndexOutOfBoundsException - /// @throws css::uno::RuntimeException - bool isAccessibleChildSelected( sal_Int64 nChildIndex ); - /// @throws css::uno::RuntimeException - void clearAccessibleSelection( ); - /// @throws css::uno::RuntimeException - void selectAllAccessibleChildren( ); - /// @throws css::uno::RuntimeException - sal_Int64 getSelectedAccessibleChildCount( ); - /// @throws css::lang::IndexOutOfBoundsException - /// @throws css::uno::RuntimeException - css::uno::Reference< css::accessibility::XAccessible > getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ); - /// @throws css::lang::IndexOutOfBoundsException - /// @throws css::uno::RuntimeException - void deselectAccessibleChild( sal_Int64 nSelectedChildIndex ); - }; - - - //= OAccessibleSelectionHelper - - - /** a helper class for implementing an AccessibleSelection which at the same time - supports an XAccessibleSelection interface. - */ - class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OAccessibleSelectionHelper : public cppu::ImplInheritanceHelper<OAccessibleComponentHelper, css::accessibility::XAccessibleSelection>, - public OCommonAccessibleSelection - { - private: - OAccessibleSelectionHelper(OAccessibleSelectionHelper const &) = delete; - OAccessibleSelectionHelper(OAccessibleSelectionHelper &&) = delete; - void operator =(OAccessibleSelectionHelper const &) = delete; - void operator =(OAccessibleSelectionHelper &&) = delete; - - protected: - - OAccessibleSelectionHelper(); - - // return ourself here by default - virtual css::uno::Reference< css::accessibility::XAccessibleContext > implGetAccessibleContext() override final; + ~OCommonAccessibleSelection(); - public: +protected: + // access to context - still waiting to be overwritten + /// @throws css::uno::RuntimeException + virtual css::uno::Reference<css::accessibility::XAccessibleContext> implGetAccessibleContext() + = 0; - // XAccessibleSelection - default implementations - virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override final; - virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override final; - virtual void SAL_CALL clearAccessibleSelection( ) override final; - virtual void SAL_CALL selectAllAccessibleChildren( ) override final; - virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override final; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override final; - virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override final; - }; + // return if the specified child is visible => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + /// @throws css::uno::RuntimeException + virtual bool implIsSelected(sal_Int64 nAccessibleChildIndex) = 0; + // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) + /// @throws css::uno::RuntimeException + virtual void implSelect(sal_Int64 nAccessibleChildIndex, bool bSelect) = 0; -} // namespace comphelper +protected: + /** non-virtual versions of the methods which can be implemented using <method>implIsSelected</method> and <method>implSelect</method> + @throws css::lang::IndexOutOfBoundsException + @throws css::uno::RuntimeException + */ + void selectAccessibleChild(sal_Int64 nChildIndex); + /// @throws css::lang::IndexOutOfBoundsException + /// @throws css::uno::RuntimeException + bool isAccessibleChildSelected(sal_Int64 nChildIndex); + /// @throws css::uno::RuntimeException + void clearAccessibleSelection(); + /// @throws css::uno::RuntimeException + void selectAllAccessibleChildren(); + /// @throws css::uno::RuntimeException + sal_Int64 getSelectedAccessibleChildCount(); + /// @throws css::lang::IndexOutOfBoundsException + /// @throws css::uno::RuntimeException + css::uno::Reference<css::accessibility::XAccessible> + getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex); + /// @throws css::lang::IndexOutOfBoundsException + /// @throws css::uno::RuntimeException + void deselectAccessibleChild(sal_Int64 nSelectedChildIndex); +}; + +//= OAccessibleSelectionHelper + +/** a helper class for implementing an AccessibleSelection which at the same time + supports an XAccessibleSelection interface. +*/ +class UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OAccessibleSelectionHelper + : public cppu::ImplInheritanceHelper<OAccessibleComponentHelper, + css::accessibility::XAccessibleSelection>, + public OCommonAccessibleSelection +{ +private: + OAccessibleSelectionHelper(OAccessibleSelectionHelper const&) = delete; + OAccessibleSelectionHelper(OAccessibleSelectionHelper&&) = delete; + void operator=(OAccessibleSelectionHelper const&) = delete; + void operator=(OAccessibleSelectionHelper&&) = delete; + +protected: + OAccessibleSelectionHelper(); + + // return ourself here by default + virtual css::uno::Reference<css::accessibility::XAccessibleContext> + implGetAccessibleContext() override final; + +public: + // XAccessibleSelection - default implementations + virtual void SAL_CALL selectAccessibleChild(sal_Int64 nChildIndex) override final; + virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int64 nChildIndex) override final; + virtual void SAL_CALL clearAccessibleSelection() override final; + virtual void SAL_CALL selectAllAccessibleChildren() override final; + virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override final; + virtual css::uno::Reference<css::accessibility::XAccessible> + SAL_CALL getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) override final; + virtual void SAL_CALL deselectAccessibleChild(sal_Int64 nSelectedChildIndex) override final; +}; + +} // namespace comphelper #endif // INCLUDED_COMPHELPER_ACCESSIBLESELECTIONHELPER_HXX diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 105fa08a8a60..5f636621b9a5 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -1235,7 +1235,6 @@ comphelper/source/misc/SelectionMultiplex.cxx comphelper/source/misc/accessiblecomponenthelper.cxx comphelper/source/misc/accessibleeventnotifier.cxx comphelper/source/misc/accessiblekeybindinghelper.cxx -comphelper/source/misc/accessibleselectionhelper.cxx comphelper/source/misc/accessibletexthelper.cxx comphelper/source/misc/anycompare.cxx comphelper/source/misc/anytohash.cxx @@ -4720,7 +4719,6 @@ include/comphelper/accessiblecomponenthelper.hxx include/comphelper/accessiblecontexthelper.hxx include/comphelper/accessibleeventnotifier.hxx include/comphelper/accessiblekeybindinghelper.hxx -include/comphelper/accessibleselectionhelper.hxx include/comphelper/accessibletexthelper.hxx include/comphelper/anycompare.hxx include/comphelper/asyncnotification.hxx commit e6e6554e5edf6aaf12a589d310ffb68544b8d9df Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon May 26 21:56:46 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed May 28 18:03:15 2025 +0200 basctl a11y: Drop AccessibleDialogControlShape::getAccessibleIndexInParent The base class implementation in OAccessibleComponentHelper::getAccessibleIndexInParent already implements the same logic. Change-Id: I42634213177d4c34ca9330db58a01a4f687a66f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185945 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/basctl/source/accessibility/accessibledialogcontrolshape.cxx b/basctl/source/accessibility/accessibledialogcontrolshape.cxx index cee0ed688bad..3c848fcb0f5f 100644 --- a/basctl/source/accessibility/accessibledialogcontrolshape.cxx +++ b/basctl/source/accessibility/accessibledialogcontrolshape.cxx @@ -328,38 +328,6 @@ Reference< XAccessible > AccessibleDialogControlShape::getAccessibleParent( ) return xParent; } - -sal_Int64 AccessibleDialogControlShape::getAccessibleIndexInParent( ) -{ - OExternalLockGuard aGuard( this ); - - sal_Int64 nIndexInParent = -1; - Reference< XAccessible > xParent( getAccessibleParent() ); - if ( xParent.is() ) - { - Reference< XAccessibleContext > xParentContext( xParent->getAccessibleContext() ); - if ( xParentContext.is() ) - { - for ( sal_Int64 i = 0, nCount = xParentContext->getAccessibleChildCount(); i < nCount; ++i ) - { - Reference< XAccessible > xChild( xParentContext->getAccessibleChild( i ) ); - if ( xChild.is() ) - { - Reference< XAccessibleContext > xChildContext = xChild->getAccessibleContext(); - if ( xChildContext == static_cast<XAccessibleContext*>(this) ) - { - nIndexInParent = i; - break; - } - } - } - } - } - - return nIndexInParent; -} - - sal_Int16 AccessibleDialogControlShape::getAccessibleRole( ) { OExternalLockGuard aGuard( this ); diff --git a/basctl/source/inc/accessibledialogcontrolshape.hxx b/basctl/source/inc/accessibledialogcontrolshape.hxx index e4423b34b7ed..482dc8360073 100644 --- a/basctl/source/inc/accessibledialogcontrolshape.hxx +++ b/basctl/source/inc/accessibledialogcontrolshape.hxx @@ -95,7 +95,6 @@ public: virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) 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;