accessibility/inc/extended/accessiblelistbox.hxx | 8 +++++--- accessibility/source/extended/accessiblelistbox.cxx | 6 ++++-- include/toolkit/awt/vclxaccessiblecomponent.hxx | 10 +++++++--- toolkit/source/awt/vclxaccessiblecomponent.cxx | 14 ++++++++++++-- winaccessibility/source/service/AccTopWindowListener.cxx | 4 +++- 5 files changed, 31 insertions(+), 11 deletions(-)
New commits: commit c0c4519e0d5b555f59bbc04cc616454edfd1f4ce Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Thu Dec 1 10:30:16 2022 +0100 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Fri Dec 23 14:19:32 2022 +0000 loplugin:unocast (VCLXAccessibleComponent) (See the upcoming commit introducing that loplugin:unocast on why such dynamic_casts from UNO types are dangerous.) Change-Id: I11496cc1d37e89ce8f11991f86c7b60bb1b93106 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144748 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/accessibility/inc/extended/accessiblelistbox.hxx b/accessibility/inc/extended/accessiblelistbox.hxx index 339e32f3b0b7..7138820123ad 100644 --- a/accessibility/inc/extended/accessiblelistbox.hxx +++ b/accessibility/inc/extended/accessiblelistbox.hxx @@ -35,12 +35,14 @@ namespace accessibility { class AccessibleListBoxEntry; + using AccessibleListBox_Base = cppu::ImplHelper2< + css::accessibility::XAccessible, + css::accessibility::XAccessibleSelection>; + /** the class OAccessibleListBoxEntry represents the base class for an accessible object of a listbox entry */ class AccessibleListBox : - public cppu::ImplHelper2< - css::accessibility::XAccessible, - css::accessibility::XAccessibleSelection>, + public AccessibleListBox_Base, public VCLXAccessibleComponent { diff --git a/accessibility/source/extended/accessiblelistbox.cxx b/accessibility/source/extended/accessiblelistbox.cxx index df4a9a759c0f..bb1131d0ab4f 100644 --- a/accessibility/source/extended/accessiblelistbox.cxx +++ b/accessibility/source/extended/accessiblelistbox.cxx @@ -58,8 +58,10 @@ namespace accessibility dispose(); } } - IMPLEMENT_FORWARD_XINTERFACE2(AccessibleListBox, VCLXAccessibleComponent, ImplHelper2) - IMPLEMENT_FORWARD_XTYPEPROVIDER2(AccessibleListBox, VCLXAccessibleComponent, ImplHelper2) + IMPLEMENT_FORWARD_XINTERFACE2( + AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_Base); + IMPLEMENT_FORWARD_XTYPEPROVIDER2( + AccessibleListBox, VCLXAccessibleComponent, AccessibleListBox_Base); void AccessibleListBox::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) { diff --git a/include/toolkit/awt/vclxaccessiblecomponent.hxx b/include/toolkit/awt/vclxaccessiblecomponent.hxx index 7c299edf6d65..dd25c76c2c2d 100644 --- a/include/toolkit/awt/vclxaccessiblecomponent.hxx +++ b/include/toolkit/awt/vclxaccessiblecomponent.hxx @@ -22,7 +22,8 @@ #include <toolkit/dllapi.h> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <cppuhelper/implbase2.hxx> #include <comphelper/accimplaccess.hxx> #include <comphelper/accessiblecomponenthelper.hxx> @@ -42,8 +43,8 @@ class AccessibleRelationSetHelper; -typedef ::cppu::ImplHelper1< - css::lang::XServiceInfo > VCLXAccessibleComponent_BASE; +typedef ::cppu::ImplHelper2< + css::lang::XServiceInfo, css::lang::XUnoTunnel > VCLXAccessibleComponent_BASE; class TOOLKIT_DLLPUBLIC VCLXAccessibleComponent :public comphelper::OAccessibleExtendedComponentHelper @@ -89,6 +90,9 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + sal_Int64 SAL_CALL getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) override; + static css::uno::Sequence<sal_Int8> const & getUnoTunnelId(); + // css::accessibility::XAccessibleContext sal_Int64 SAL_CALL getAccessibleChildCount( ) override; css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; diff --git a/toolkit/source/awt/vclxaccessiblecomponent.cxx b/toolkit/source/awt/vclxaccessiblecomponent.cxx index 7fbb1ea1ccd6..6d0798bda590 100644 --- a/toolkit/source/awt/vclxaccessiblecomponent.cxx +++ b/toolkit/source/awt/vclxaccessiblecomponent.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <i18nlangtag/languagetag.hxx> #include <toolkit/awt/vclxaccessiblecomponent.hxx> @@ -105,6 +106,15 @@ uno::Sequence< OUString > VCLXAccessibleComponent::getSupportedServiceNames() return aNames; } +sal_Int64 VCLXAccessibleComponent::getSomething(css::uno::Sequence<sal_Int8> const & aIdentifier) { + return comphelper::getSomethingImpl(aIdentifier, this); +} + +css::uno::Sequence<sal_Int8> const & VCLXAccessibleComponent::getUnoTunnelId() { + static comphelper::UnoIdInit const id; + return id.getSeq(); +} + IMPL_LINK( VCLXAccessibleComponent, WindowEventListener, VclWindowEvent&, rEvent, void ) { /* Ignore VclEventId::WindowEndPopupMode, because the UNO accessibility wrapper @@ -169,7 +179,7 @@ void VCLXAccessibleComponent::ProcessWindowChildEvent( const VclWindowEvent& rVc uno::Reference<XAccessibleContext> xChildContext = xAcc->getAccessibleContext(); if (xChildContext.is()) { - VCLXAccessibleComponent* pChildComponent = dynamic_cast<VCLXAccessibleComponent*>(xChildContext.get()); + VCLXAccessibleComponent* pChildComponent = comphelper::getFromUnoTunnel<VCLXAccessibleComponent>(xChildContext); if (pChildComponent) { css::uno::Any aNewStateValue; @@ -190,7 +200,7 @@ void VCLXAccessibleComponent::ProcessWindowChildEvent( const VclWindowEvent& rVc uno::Reference<XAccessibleContext> xChildContext = xAcc->getAccessibleContext(); if (xChildContext.is()) { - VCLXAccessibleComponent* pChildComponent = dynamic_cast<VCLXAccessibleComponent*>(xChildContext.get()); + VCLXAccessibleComponent* pChildComponent = comphelper::getFromUnoTunnel<VCLXAccessibleComponent>(xChildContext); if (pChildComponent) { css::uno::Any aOldStateValue; diff --git a/winaccessibility/source/service/AccTopWindowListener.cxx b/winaccessibility/source/service/AccTopWindowListener.cxx index a6b935d55798..70c2429f71e2 100644 --- a/winaccessibility/source/service/AccTopWindowListener.cxx +++ b/winaccessibility/source/service/AccTopWindowListener.cxx @@ -18,6 +18,7 @@ */ +#include <comphelper/servicehelper.hxx> #include <sal/log.hxx> #include <vcl/window.hxx> #include <toolkit/awt/vclxaccessiblecomponent.hxx> @@ -44,7 +45,8 @@ void AccTopWindowListener::HandleWindowOpened( css::accessibility::XAccessible* VclPtr<vcl::Window> window; if (auto pvclwindow = dynamic_cast<VCLXWindow*>(pAccessible)) window = pvclwindow->GetWindow(); - else if (auto pvclxcomponent = dynamic_cast<VCLXAccessibleComponent*>(pAccessible)) + else if (auto pvclxcomponent + = comphelper::getFromUnoTunnel<VCLXAccessibleComponent>(pAccessible)) window = pvclxcomponent->GetWindow(); assert(window); // The SalFrame of window may be destructed at this time