accessibility/source/helper/acc_factory.cxx | 81 +++++++++---------- comphelper/source/misc/accessiblecomponenthelper.cxx | 42 ++++----- toolkit/inc/controls/accessiblecontrolcontext.hxx | 6 - toolkit/source/controls/accessiblecontrolcontext.cxx | 4 4 files changed, 64 insertions(+), 69 deletions(-)
New commits: commit e5065e23d9ecc27fa12207cc9e0fd00eea91188b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Dec 11 16:34:08 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Dec 12 08:05:14 2024 +0100 a11y: Flatten OCommonAccessibleComponent::getAccessibleIndexInParent Return early if `xParentContext` or `xCreator` are empty. Change-Id: I4b0aa1679658cf6dfb47c1c0bc21ca7a0d2e9c24 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178324 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 3922812b92af..678e87e17cae 100644 --- a/comphelper/source/misc/accessiblecomponenthelper.cxx +++ b/comphelper/source/misc/accessiblecomponenthelper.cxx @@ -179,32 +179,30 @@ namespace comphelper try { - Reference< XAccessibleContext > xParentContext( implGetParentContext() ); + if (!xParentContext.is()) + return -1; // iterate over parent's children and search for this object - if ( xParentContext.is() ) + + // our own XAccessible for comparing with the children of our parent + Reference< XAccessible > xCreator( m_aCreator); + + OSL_ENSURE( xCreator.is(), "OCommonAccessibleComponent::getAccessibleIndexInParent: invalid creator!" ); + // two ideas why this could be NULL: + // * nobody called our late ctor (init), so we never had a creator at all -> bad + // * the creator is already dead. In this case, we should have been disposed, and + // never survived the above OContextEntryGuard. + // in all other situations the creator should be non-NULL + if (!xCreator.is()) + return -1; + + sal_Int64 nChildCount = xParentContext->getAccessibleChildCount(); + for ( sal_Int64 nChild = 0; ( nChild < nChildCount ) && ( -1 == nRet ); ++nChild ) { - // our own XAccessible for comparing with the children of our parent - Reference< XAccessible > xCreator( m_aCreator); - - OSL_ENSURE( xCreator.is(), "OCommonAccessibleComponent::getAccessibleIndexInParent: invalid creator!" ); - // two ideas why this could be NULL: - // * nobody called our late ctor (init), so we never had a creator at all -> bad - // * the creator is already dead. In this case, we should have been disposed, and - // never survived the above OContextEntryGuard. - // in all other situations the creator should be non-NULL - - if ( xCreator.is() ) - { - sal_Int64 nChildCount = xParentContext->getAccessibleChildCount(); - for ( sal_Int64 nChild = 0; ( nChild < nChildCount ) && ( -1 == nRet ); ++nChild ) - { - Reference< XAccessible > xChild( xParentContext->getAccessibleChild( nChild ) ); - if ( xChild.get() == xCreator.get() ) - nRet = nChild; - } - } + Reference< XAccessible > xChild( xParentContext->getAccessibleChild( nChild ) ); + if ( xChild.get() == xCreator.get() ) + nRet = nChild; } } catch( const Exception& ) commit 9d9a83acf2238aec2f33a51db2b4bf6086ec4d17 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Dec 11 16:11:34 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Dec 12 08:05:08 2024 +0100 a11y: Drop OAccessibleControlContext_Base typedef Change-Id: I999bdea008b5aa5c98e099232bdf18b9e156c851 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178323 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/toolkit/inc/controls/accessiblecontrolcontext.hxx b/toolkit/inc/controls/accessiblecontrolcontext.hxx index 92c3fdf81870..31d5cf132a66 100644 --- a/toolkit/inc/controls/accessiblecontrolcontext.hxx +++ b/toolkit/inc/controls/accessiblecontrolcontext.hxx @@ -35,9 +35,6 @@ namespace toolkit //= OAccessibleControlContext - - typedef ::comphelper::OAccessibleComponentHelper OAccessibleControlContext_Base; - /** class implementing the AccessibleContext for a UNO control - to be used in design mode of the control. <p><b>life time control<b/><br/> This control should be held weak by the creator (a UNO control), it itself holds a hard reference to the @@ -45,8 +42,7 @@ namespace toolkit is being disposed.</p> */ class OAccessibleControlContext final - :public cppu::ImplInheritanceHelper< - OAccessibleControlContext_Base, css::lang::XEventListener> + : public cppu::ImplInheritanceHelper<comphelper::OAccessibleComponentHelper, css::lang::XEventListener> { public: /** creates an accessible context for a uno control diff --git a/toolkit/source/controls/accessiblecontrolcontext.cxx b/toolkit/source/controls/accessiblecontrolcontext.cxx index e3a81d3a954e..9a070da4e9e7 100644 --- a/toolkit/source/controls/accessiblecontrolcontext.cxx +++ b/toolkit/source/controls/accessiblecontrolcontext.cxx @@ -76,7 +76,7 @@ namespace toolkit startModelListening(); // announce the XAccessible to our base class - OAccessibleControlContext_Base::lateInit( _rxCreator ); + comphelper::OAccessibleComponentHelper::lateInit( _rxCreator ); } @@ -187,7 +187,7 @@ namespace toolkit m_xControlModel.clear(); m_xModelPropsInfo.clear(); - OAccessibleControlContext_Base::disposing(); + comphelper::OAccessibleComponentHelper::disposing(); } commit c8a370c81f6dd0417b2bf5dbba574901571bcd3f Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Dec 11 15:38:12 2024 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Dec 12 08:05:02 2024 +0100 a11y: Return early in AccessibleFactory::createAccessibleContext ... if `pWindow` is null. (`git show --ignore-space-change` shows the "actual change" more clearly.) Change-Id: I39685d0a51ee9a5a280d302c940b2cdbc21c2b6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178322 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/accessibility/source/helper/acc_factory.cxx b/accessibility/source/helper/acc_factory.cxx index 191cc7528703..9bfdd1f2948e 100644 --- a/accessibility/source/helper/acc_factory.cxx +++ b/accessibility/source/helper/acc_factory.cxx @@ -289,58 +289,59 @@ Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLX Reference< XAccessibleContext > AccessibleFactory::createAccessibleContext( VCLXWindow* _pXWindow ) { VclPtr<vcl::Window> pWindow = _pXWindow->GetWindow(); - if ( pWindow ) - { - WindowType nType = pWindow->GetType(); + if (!pWindow) + return nullptr; + + WindowType nType = pWindow->GetType(); - if ( nType == WindowType::MENUBARWINDOW || pWindow->IsMenuFloatingWindow() || pWindow->IsToolbarFloatingWindow() ) + if ( nType == WindowType::MENUBARWINDOW || pWindow->IsMenuFloatingWindow() || pWindow->IsToolbarFloatingWindow() ) + { + Reference< XAccessible > xAcc( pWindow->GetAccessible() ); + if ( xAcc.is() ) { - Reference< XAccessible > xAcc( pWindow->GetAccessible() ); - if ( xAcc.is() ) + Reference<XAccessibleContext > xContext(xAcc->getAccessibleContext()); + if ( pWindow->GetType() == WindowType::MENUBARWINDOW || + ( xContext.is() && xContext->getAccessibleRole() == AccessibleRole::POPUP_MENU ) ) { - Reference<XAccessibleContext > xContext(xAcc->getAccessibleContext()); - if ( pWindow->GetType() == WindowType::MENUBARWINDOW || - ( xContext.is() && xContext->getAccessibleRole() == AccessibleRole::POPUP_MENU ) ) - { - return xContext; - } + return xContext; } } + } - else if ( nType == WindowType::STATUSBAR ) - { - return new VCLXAccessibleStatusBar(_pXWindow); - } + else if ( nType == WindowType::STATUSBAR ) + { + return new VCLXAccessibleStatusBar(_pXWindow); + } - else if ( nType == WindowType::TABCONTROL ) - { - return new VCLXAccessibleTabControl(_pXWindow); - } + else if ( nType == WindowType::TABCONTROL ) + { + return new VCLXAccessibleTabControl(_pXWindow); + } - else if ( nType == WindowType::TABPAGE && pWindow->GetAccessibleParentWindow() && pWindow->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL ) - { - return new VCLXAccessibleTabPageWindow(_pXWindow); - } + else if ( nType == WindowType::TABPAGE && pWindow->GetAccessibleParentWindow() && pWindow->GetAccessibleParentWindow()->GetType() == WindowType::TABCONTROL ) + { + return new VCLXAccessibleTabPageWindow(_pXWindow); + } - else if ( nType == WindowType::FLOATINGWINDOW ) - { - return new FloatingWindowAccessible(_pXWindow); - } + else if ( nType == WindowType::FLOATINGWINDOW ) + { + return new FloatingWindowAccessible(_pXWindow); + } - else if ( nType == WindowType::BORDERWINDOW && hasFloatingChild( pWindow ) ) - { - return new FloatingWindowAccessible(_pXWindow); - } + else if ( nType == WindowType::BORDERWINDOW && hasFloatingChild( pWindow ) ) + { + return new FloatingWindowAccessible(_pXWindow); + } - else if ( ( nType == WindowType::HELPTEXTWINDOW ) || ( nType == WindowType::FIXEDLINE ) ) - { - return new VCLXAccessibleFixedText(_pXWindow); - } - else - { - return new VCLXAccessibleComponent(_pXWindow); - } + else if ( ( nType == WindowType::HELPTEXTWINDOW ) || ( nType == WindowType::FIXEDLINE ) ) + { + return new VCLXAccessibleFixedText(_pXWindow); } + else + { + return new VCLXAccessibleComponent(_pXWindow); + } + return nullptr; }