sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx | 51 +--- sd/source/ui/accessibility/AccessibleSlideSorterView.cxx | 152 ------------- sd/source/ui/inc/AccessibleSlideSorterObject.hxx | 7 sd/source/ui/inc/AccessibleSlideSorterView.hxx | 84 ------- 4 files changed, 35 insertions(+), 259 deletions(-)
New commits: commit 4a5c1d4e7394d099fb61853ca634e93200a53ee2 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Feb 26 13:15:30 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Feb 26 20:10:06 2025 +0100 sd slidesorter a11y: Use rtl::Reference to concrete class Use rtl::Reference<AccessibleSlideSorterView> for AccessibleSlideSorterObject::mxParent. This simplifies the code using it. Change-Id: I5e41738521c0a849ff864c9a57e539566a8dbeb5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182229 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx index fa1a804b6715..50b5a3e02226 100644 --- a/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx +++ b/sd/source/ui/accessibility/AccessibleSlideSorterObject.cxx @@ -50,7 +50,7 @@ using namespace ::com::sun::star::accessibility; namespace accessibility { AccessibleSlideSorterObject::AccessibleSlideSorterObject( - const Reference<XAccessible>& rxParent, + const rtl::Reference<AccessibleSlideSorterView>& rxParent, ::sd::slidesorter::SlideSorter& rSlideSorter, sal_uInt16 nPageNumber) : mxParent(rxParent), @@ -131,18 +131,13 @@ sal_Int64 SAL_CALL AccessibleSlideSorterObject::getAccessibleIndexInParent() if (mxParent.is()) { - Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext()); - if (xParentContext.is()) - { - sal_Int64 nChildCount (xParentContext->getAccessibleChildCount()); - for (sal_Int64 i=0; i<nChildCount; ++i) - if (xParentContext->getAccessibleChild(i).get() - == static_cast<XAccessible*>(this)) - { - nIndexInParent = i; - break; - } - } + sal_Int64 nChildCount (mxParent->getAccessibleChildCount()); + for (sal_Int64 i=0; i<nChildCount; ++i) + if (mxParent->getAccessibleChild(i).get() == static_cast<XAccessible*>(this)) + { + nIndexInParent = i; + break; + } } return nIndexInParent; @@ -214,9 +209,7 @@ lang::Locale SAL_CALL AccessibleSlideSorterObject::getLocale() // Delegate request to parent. if (mxParent.is()) { - Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext()); - if (xParentContext.is()) - return xParentContext->getLocale (); + return mxParent->getLocale (); } // No locale and no parent. Therefore throw exception to indicate this @@ -303,16 +296,12 @@ awt::Rectangle SAL_CALL AccessibleSlideSorterObject::getBounds() if (mxParent.is()) { - Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(), UNO_QUERY); - if (xParentComponent.is()) - { - awt::Rectangle aParentBBox (xParentComponent->getBounds()); - aBBox.Intersection(::tools::Rectangle( - aParentBBox.X, - aParentBBox.Y, - aParentBBox.Width, - aParentBBox.Height)); - } + awt::Rectangle aParentBBox (mxParent->getBounds()); + aBBox.Intersection(::tools::Rectangle( + aParentBBox.X, + aParentBBox.Y, + aParentBBox.Width, + aParentBBox.Height)); } return awt::Rectangle( @@ -339,13 +328,9 @@ awt::Point SAL_CALL AccessibleSlideSorterObject::getLocationOnScreen() if (mxParent.is()) { - Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(),UNO_QUERY); - if (xParentComponent.is()) - { - const awt::Point aParentLocationOnScreen(xParentComponent->getLocationOnScreen()); - aLocation.X += aParentLocationOnScreen.X; - aLocation.Y += aParentLocationOnScreen.Y; - } + const awt::Point aParentLocationOnScreen(mxParent->getLocationOnScreen()); + aLocation.X += aParentLocationOnScreen.X; + aLocation.Y += aParentLocationOnScreen.Y; } return aLocation; diff --git a/sd/source/ui/inc/AccessibleSlideSorterObject.hxx b/sd/source/ui/inc/AccessibleSlideSorterObject.hxx index 97bea8519768..a33b5db78894 100644 --- a/sd/source/ui/inc/AccessibleSlideSorterObject.hxx +++ b/sd/source/ui/inc/AccessibleSlideSorterObject.hxx @@ -19,12 +19,15 @@ #pragma once +#include "AccessibleSlideSorterView.hxx" + #include <comphelper/compbase.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessibleContext.hpp> #include <com/sun/star/accessibility/XAccessibleComponent.hpp> #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> +#include <rtl/ref.hxx> class SdPage; namespace sd::slidesorter { class SlideSorter; } @@ -54,7 +57,7 @@ public: The number of the page in the range [0,nPageCount). */ AccessibleSlideSorterObject( - const css::uno::Reference<css::accessibility::XAccessible >& rxParent, + const rtl::Reference<AccessibleSlideSorterView>& rxParent, ::sd::slidesorter::SlideSorter& rSlideSorter, sal_uInt16 nPageNumber); virtual ~AccessibleSlideSorterObject() override; @@ -161,7 +164,7 @@ public: getSupportedServiceNames() override; private: - css::uno::Reference<css::accessibility::XAccessible> mxParent; + rtl::Reference<AccessibleSlideSorterView> mxParent; sal_uInt16 mnPageNumber; ::sd::slidesorter::SlideSorter& mrSlideSorter; sal_uInt32 mnClientId; commit c242747b61988ed5d6dcabbfee29f6d176a9e29d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Feb 26 12:29:28 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Feb 26 20:09:57 2025 +0100 sd slidesorter a11y: Use OAccessibleComponentHelper Similar to how commit b5d197cf4b4fc5f4e6aca5e01e2cc9757293c63e Author: Michael Weghorn <m.wegh...@posteo.de> Date: Tue Feb 25 11:51:40 2025 +0100 valueset a11y: Use OAccessibleComponentHelper for ValueSetAcc did for ValueSetAcc, also derive from OAccessibleComponentHelper for AccessibleSlideSorterView to make use of the logic already implemented there instead of having to implement all the XAccessibleComponent and XAccessibleEventBroadcaster methods manually. AccessibleSlideSorterView::getBounds implements what is needed to implement OAccessibleComponentHelper::implGetBounds, so rename the method (and drop the mutex guard from that method, as callers of that method in the base class take care of that). Drop all of the other overrides that are no longer needed as the implementation is now provided by the OAccessibleComponentHelper base class. Calling AccessibleSlideSorterView::Destroyed from the dtor (which would notify listeners that the object is disposed is no more needed as the base class OCommonAccessibleComponent::disposing does that, and the OCommonAccessibleComponent dtor calls OCommonAccessibleComponent::ensureDisposed. No change in behavior intended or observed when testing this with Accerciser and Orca and the qt6 VCL plugin with the "Slides" pane in Impress. Change-Id: Ic7e6ff1450ced8fb88eca57d607dc27d6c0b9e01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182228 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx index ac5d06f9a1ee..34a3d9413c86 100644 --- a/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx +++ b/sd/source/ui/accessibility/AccessibleSlideSorterView.cxx @@ -113,9 +113,7 @@ private: AccessibleSlideSorterView::AccessibleSlideSorterView( ::sd::slidesorter::SlideSorter& rSlideSorter, vcl::Window* pContentWindow) - : AccessibleSlideSorterViewBase(m_aMutex), - mrSlideSorter(rSlideSorter), - mnClientId(0), + : mrSlideSorter(rSlideSorter), mpContentWindow(pContentWindow) { } @@ -127,7 +125,6 @@ void AccessibleSlideSorterView::Init() AccessibleSlideSorterView::~AccessibleSlideSorterView() { - Destroyed (); } void AccessibleSlideSorterView::FireAccessibleEvent ( @@ -135,27 +132,13 @@ void AccessibleSlideSorterView::FireAccessibleEvent ( const uno::Any& rOldValue, const uno::Any& rNewValue ) { - if (mnClientId != 0) - { - AccessibleEventObject aEventObject; - - aEventObject.Source = Reference<XWeak>(this); - aEventObject.EventId = nEventId; - aEventObject.NewValue = rNewValue; - aEventObject.OldValue = rOldValue; - aEventObject.IndexHint = -1; - - comphelper::AccessibleEventNotifier::addEvent (mnClientId, aEventObject); - } + NotifyAccessibleEvent(nEventId, rOldValue, rNewValue); } void SAL_CALL AccessibleSlideSorterView::disposing() { - if (mnClientId != 0) - { - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; - } + OAccessibleComponentHelper::disposing(); + mpImpl.reset(); } @@ -171,18 +154,6 @@ AccessibleSlideSorterObject* AccessibleSlideSorterView::GetAccessibleChildImplem return pResult; } -void AccessibleSlideSorterView::Destroyed() -{ - ::osl::MutexGuard aGuard (m_aMutex); - - // Send a disposing to all listeners. - if (mnClientId != 0) - { - comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this ); - mnClientId = 0; - } -} - //===== XAccessible ========================================================= Reference<XAccessibleContext > SAL_CALL @@ -318,64 +289,8 @@ lang::Locale SAL_CALL AccessibleSlideSorterView::getLocale() return Application::GetSettings().GetLanguageTag().getLocale(); } -void SAL_CALL AccessibleSlideSorterView::addAccessibleEventListener( - const Reference<XAccessibleEventListener >& rxListener) -{ - if (!rxListener.is()) - return; - - const osl::MutexGuard aGuard(m_aMutex); - - if (rBHelper.bDisposed || rBHelper.bInDispose) - { - uno::Reference<uno::XInterface> x (static_cast<lang::XComponent *>(this), uno::UNO_QUERY); - rxListener->disposing (lang::EventObject (x)); - } - else - { - if ( ! mnClientId) - mnClientId = comphelper::AccessibleEventNotifier::registerClient(); - comphelper::AccessibleEventNotifier::addEventListener(mnClientId, rxListener); - } -} - -void SAL_CALL AccessibleSlideSorterView::removeAccessibleEventListener( - const Reference<XAccessibleEventListener >& rxListener) -{ - ThrowIfDisposed(); - if (!rxListener.is()) - return; - - const osl::MutexGuard aGuard(m_aMutex); - - if (mnClientId == 0) - return; - - sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( - mnClientId, rxListener ); - 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 - comphelper::AccessibleEventNotifier::revokeClient( mnClientId ); - mnClientId = 0; - } -} - //===== XAccessibleComponent ================================================== -sal_Bool SAL_CALL AccessibleSlideSorterView::containsPoint (const awt::Point& aPoint) -{ - ThrowIfDisposed(); - const awt::Rectangle aBBox (getBounds()); - return (aPoint.X >= 0) - && (aPoint.X < aBBox.Width) - && (aPoint.Y >= 0) - && (aPoint.Y < aBBox.Height); -} - Reference<XAccessible> SAL_CALL AccessibleSlideSorterView::getAccessibleAtPoint (const awt::Point& aPoint) { @@ -393,10 +308,8 @@ Reference<XAccessible> SAL_CALL return xAccessible; } -awt::Rectangle SAL_CALL AccessibleSlideSorterView::getBounds() +awt::Rectangle AccessibleSlideSorterView::implGetBounds() { - ThrowIfDisposed(); - const SolarMutexGuard aSolarGuard; awt::Rectangle aBBox; if (mpContentWindow != nullptr) @@ -413,61 +326,6 @@ awt::Rectangle SAL_CALL AccessibleSlideSorterView::getBounds() return aBBox; } -awt::Point SAL_CALL AccessibleSlideSorterView::getLocation() -{ - ThrowIfDisposed(); - awt::Point aLocation; - - if (mpContentWindow != nullptr) - { - const Point aPosition (mpContentWindow->GetPosPixel()); - aLocation.X = aPosition.X(); - aLocation.Y = aPosition.Y(); - } - - return aLocation; -} - -/** Calculate the location on screen from the parent's location on screen - and our own relative location. -*/ -awt::Point SAL_CALL AccessibleSlideSorterView::getLocationOnScreen() -{ - ThrowIfDisposed(); - const SolarMutexGuard aSolarGuard; - awt::Point aParentLocationOnScreen; - - Reference<XAccessible> xParent (getAccessibleParent()); - if (xParent.is()) - { - Reference<XAccessibleComponent> xParentComponent ( - xParent->getAccessibleContext(), uno::UNO_QUERY); - if (xParentComponent.is()) - aParentLocationOnScreen = xParentComponent->getLocationOnScreen(); - } - - awt::Point aLocationOnScreen (getLocation()); - aLocationOnScreen.X += aParentLocationOnScreen.X; - aLocationOnScreen.Y += aParentLocationOnScreen.Y; - - return aLocationOnScreen; -} - -awt::Size SAL_CALL AccessibleSlideSorterView::getSize() -{ - ThrowIfDisposed(); - awt::Size aSize; - - if (mpContentWindow != nullptr) - { - const Size aOutputSize (mpContentWindow->GetOutputSizePixel()); - aSize.Width = aOutputSize.Width(); - aSize.Height = aOutputSize.Height(); - } - - return aSize; -} - void SAL_CALL AccessibleSlideSorterView::grabFocus() { ThrowIfDisposed(); diff --git a/sd/source/ui/inc/AccessibleSlideSorterView.hxx b/sd/source/ui/inc/AccessibleSlideSorterView.hxx index 6ee4ffbd8bcb..c25e8782a75e 100644 --- a/sd/source/ui/inc/AccessibleSlideSorterView.hxx +++ b/sd/source/ui/inc/AccessibleSlideSorterView.hxx @@ -19,13 +19,10 @@ #pragma once -#include <cppuhelper/basemutex.hxx> +#include <comphelper/accessiblecomponenthelper.hxx> #include <cppuhelper/compbase.hxx> #include <com/sun/star/accessibility/XAccessible.hpp> -#include <com/sun/star/accessibility/XAccessibleContext.hpp> -#include <com/sun/star/accessibility/XAccessibleComponent.hpp> #include <com/sun/star/accessibility/XAccessibleSelection.hpp> -#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <vcl/vclptr.hxx> #include <vcl/window.hxx> @@ -38,22 +35,14 @@ namespace accessibility { class AccessibleSlideSorterObject; -typedef ::cppu::WeakComponentImplHelper< - css::accessibility::XAccessible, - css::accessibility::XAccessibleEventBroadcaster, - css::accessibility::XAccessibleContext, - css::accessibility::XAccessibleComponent, - css::accessibility::XAccessibleSelection, - css::lang::XServiceInfo - > AccessibleSlideSorterViewBase; - /** This class makes the SlideSorterViewShell accessible. It uses objects of the AccessibleSlideSorterObject class to the make the page objects accessible. */ class AccessibleSlideSorterView - : public cppu::BaseMutex, - public AccessibleSlideSorterViewBase + : public cppu::ImplInheritanceHelper< + comphelper::OAccessibleComponentHelper, css::accessibility::XAccessible, + css::accessibility::XAccessibleSelection, css::lang::XServiceInfo> { public: AccessibleSlideSorterView( @@ -64,11 +53,6 @@ public: virtual ~AccessibleSlideSorterView() override; - /** This method acts like a dispose call. It sends a disposing to all - of its listeners. It may be called twice. - */ - void Destroyed(); - void FireAccessibleEvent ( short nEventId, const css::uno::Any& rOldValue, @@ -87,15 +71,6 @@ public: virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override; - //===== XAccessibleEventBroadcaster ======================================= - virtual void SAL_CALL - addAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& rxListener) override; - - virtual void SAL_CALL - removeAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& rxListener ) override; - //===== XAccessibleContext ============================================== /// Return the number of currently visible children. @@ -134,23 +109,15 @@ public: virtual css::lang::Locale SAL_CALL getLocale() override; - //===== XAccessibleComponent ================================================ + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds() override; - virtual sal_Bool SAL_CALL containsPoint ( - const css::awt::Point& aPoint) override; + //===== XAccessibleComponent ================================================ 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; @@ -199,8 +166,6 @@ private: ::sd::slidesorter::SlideSorter& mrSlideSorter; - sal_uInt32 mnClientId; - VclPtr<vcl::Window> mpContentWindow; /** Check whether or not the object has been disposed (or is in the commit 52cd46ca7f5d3b256fc1aec733d58a00c33ef6d1 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Feb 26 12:04:19 2025 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Feb 26 20:09:51 2025 +0100 sd slidesorter a11y: Drop redundant and misleading comments Some of the comments simply repeat what the documentation for the corresponding XAccessible* interface already states. Others seem incorrect or at least misleading/confusing, for example: /** The default implementation returns an empty rectangle. */ virtual css::awt::Rectangle SAL_CALL getBounds() override; It's unclear what "the default implementation" refers to here: The base class XAccessibleComponent::getBounds is purely virtual. The actual implementation in this class, AccessibleSlideSorterView::getBounds, does not return an empty rectangle, but actually calculates the bounds of the slide sorter view. The same repeats similarly for other comments. Drop that kind of AccessibleSlideSorterView comments to reduce confusion. Leave others that look more useful at first sight. Change-Id: I30e9c3c59cec932e8ade7ecd9afb707eb654c7a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182227 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sd/source/ui/inc/AccessibleSlideSorterView.hxx b/sd/source/ui/inc/AccessibleSlideSorterView.hxx index 0cbaf62ed586..6ee4ffbd8bcb 100644 --- a/sd/source/ui/inc/AccessibleSlideSorterView.hxx +++ b/sd/source/ui/inc/AccessibleSlideSorterView.hxx @@ -106,23 +106,18 @@ public: virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleChild (sal_Int64 nIndex) override; - /// Return a reference to the parent. virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL getAccessibleParent() override; - /// Return this objects index among the parents children. virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; - /// Return this object's role. virtual sal_Int16 SAL_CALL getAccessibleRole() override; - /// Return this object's description. virtual OUString SAL_CALL getAccessibleDescription() override; - /// Return the object's current name. virtual OUString SAL_CALL getAccessibleName() override; @@ -131,7 +126,6 @@ public: css::accessibility::XAccessibleRelationSet> SAL_CALL getAccessibleRelationSet() override; - /// Return the set of current states. virtual sal_Int64 SAL_CALL getAccessibleStateSet() override; /** Return the parents locale or throw exception if this object has no @@ -142,48 +136,25 @@ public: //===== XAccessibleComponent ================================================ - /** The default implementation uses the result of - <member>getBounds</member> to determine whether the given point lies - inside this object. - */ virtual sal_Bool SAL_CALL containsPoint ( const css::awt::Point& aPoint) override; - /** The default implementation returns an empty reference. - */ virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint ( const css::awt::Point& aPoint) override; - /** The default implementation returns an empty rectangle. - */ virtual css::awt::Rectangle SAL_CALL getBounds() override; - /** The default implementation uses the result of - <member>getBounds</member> to determine the location. - */ virtual css::awt::Point SAL_CALL getLocation() override; - /** The default implementation returns an empty position, i.e. the - * result of the default constructor of <type>css::awt::Point</type>. - */ virtual css::awt::Point SAL_CALL getLocationOnScreen() override; - /** The default implementation uses the result of - <member>getBounds</member> to determine the size. - */ virtual css::awt::Size SAL_CALL getSize() override; - /** The default implementation does nothing. - */ virtual void SAL_CALL grabFocus() override; - /** Returns black as the default foreground color. - */ virtual sal_Int32 SAL_CALL getForeground() override; - /** Returns white as the default background color. - */ virtual sal_Int32 SAL_CALL getBackground() override; //===== XAccessibleSelection ============================================== @@ -212,18 +183,12 @@ public: //===== XServiceInfo ==================================================== - /** Returns an identifier for the implementation of this object. - */ virtual OUString SAL_CALL getImplementationName() override; - /** Return whether the specified service is supported by this class. - */ virtual sal_Bool SAL_CALL supportsService (const OUString& sServiceName) override; - /** Returns a list of all supported services. - */ virtual css::uno::Sequence< OUString> SAL_CALL getSupportedServiceNames() override;