thumbnailview a11y: Use OAccessibleComponentHelper for ThumbnailViewItemAcc
Similar to how
commit e7dc7ebc9e
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Tue Feb 25 12:14:24 2025 +0100
valueset a11y: Use OAccessibleComponentHelper for ValueItemAcc
did for ValueItemAcc, also derive
from OAccessibleComponentHelper for ThumbnailViewItemAcc
to make use of the logic already implemented there
instead of having to implement all the XAccessibleComponent
and XAccessibleEventBroadcaster methods manually.
ThumbnailViewItemAcc::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.
No change in behavior intended or observed initially
when testing this with the ThumbnailView for "Recent Documents"
in the LO Start Center with Accerciser and Orca and the qt6
VCL plugin.
However, when closing LO, this now triggers an assertion:
soffice.bin: /home/michi/development/git/libreoffice/comphelper/source/misc/accessibleeventnotifier.cxx:142: bool (anonymous namespace)::implLookupClient(const AccessibleEventNotifier::TClientId, ClientMap::iterator &): Assertion `rClients.end() != rPos && "AccessibleEventNotifier::implLookupClient: invalid client id " "(did you register your client?)!"' failed.
This is the same preexisting issue as already described
in more detail for ValueItemAcc in the above-mentioned
commit (items don't get disposed) and will be addressed
in an upcoming commit.
Change-Id: Ie4e5c300ff6bdb160e756e7173c45c0f143fac69
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182225
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -192,58 +192,13 @@ lang::Locale SAL_CALL ThumbnailViewItemAcc::getLocale()
|
|||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAL_CALL ThumbnailViewItemAcc::addAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
|
|
||||||
{
|
|
||||||
std::scoped_lock aGuard( maMutex );
|
|
||||||
|
|
||||||
if( !rxListener.is() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
bool bFound = false;
|
|
||||||
|
|
||||||
for (auto const& eventListener : mxEventListeners)
|
|
||||||
{
|
|
||||||
if( eventListener == rxListener )
|
|
||||||
{
|
|
||||||
bFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bFound)
|
|
||||||
mxEventListeners.push_back( rxListener );
|
|
||||||
}
|
|
||||||
|
|
||||||
void SAL_CALL ThumbnailViewItemAcc::removeAccessibleEventListener( const uno::Reference< accessibility::XAccessibleEventListener >& rxListener )
|
|
||||||
{
|
|
||||||
std::scoped_lock aGuard( maMutex );
|
|
||||||
|
|
||||||
if( rxListener.is() )
|
|
||||||
{
|
|
||||||
std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::iterator aIter =
|
|
||||||
std::find(mxEventListeners.begin(), mxEventListeners.end(), rxListener);
|
|
||||||
|
|
||||||
if (aIter != mxEventListeners.end())
|
|
||||||
mxEventListeners.erase( aIter );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sal_Bool SAL_CALL ThumbnailViewItemAcc::containsPoint( const awt::Point& aPoint )
|
|
||||||
{
|
|
||||||
const awt::Rectangle aRect( getBounds() );
|
|
||||||
const Point aSize( aRect.Width, aRect.Height );
|
|
||||||
const Point aNullPoint, aTestPoint( aPoint.X, aPoint.Y );
|
|
||||||
|
|
||||||
return tools::Rectangle( aNullPoint, aSize ).Contains( aTestPoint );
|
|
||||||
}
|
|
||||||
|
|
||||||
uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleAtPoint( const awt::Point& )
|
uno::Reference< accessibility::XAccessible > SAL_CALL ThumbnailViewItemAcc::getAccessibleAtPoint( const awt::Point& )
|
||||||
{
|
{
|
||||||
uno::Reference< accessibility::XAccessible > xRet;
|
uno::Reference< accessibility::XAccessible > xRet;
|
||||||
return xRet;
|
return xRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
awt::Rectangle SAL_CALL ThumbnailViewItemAcc::getBounds()
|
awt::Rectangle ThumbnailViewItemAcc::implGetBounds()
|
||||||
{
|
{
|
||||||
const SolarMutexGuard aSolarGuard;
|
const SolarMutexGuard aSolarGuard;
|
||||||
awt::Rectangle aRet;
|
awt::Rectangle aRet;
|
||||||
@@ -276,46 +231,6 @@ awt::Rectangle SAL_CALL ThumbnailViewItemAcc::getBounds()
|
|||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
awt::Point SAL_CALL ThumbnailViewItemAcc::getLocation()
|
|
||||||
{
|
|
||||||
const awt::Rectangle aRect( getBounds() );
|
|
||||||
awt::Point aRet;
|
|
||||||
|
|
||||||
aRet.X = aRect.X;
|
|
||||||
aRet.Y = aRect.Y;
|
|
||||||
|
|
||||||
return aRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
awt::Point SAL_CALL ThumbnailViewItemAcc::getLocationOnScreen()
|
|
||||||
{
|
|
||||||
const SolarMutexGuard aSolarGuard;
|
|
||||||
awt::Point aRet;
|
|
||||||
|
|
||||||
if (mpThumbnailViewItem)
|
|
||||||
{
|
|
||||||
const Point aPos = mpThumbnailViewItem->getDrawArea().TopLeft();
|
|
||||||
const Point aScreenPos(
|
|
||||||
mpThumbnailViewItem->mrParent.GetDrawingArea()->get_accessible_location_on_screen());
|
|
||||||
|
|
||||||
aRet.X = aPos.X() + aScreenPos.X();
|
|
||||||
aRet.Y = aPos.Y() + aScreenPos.Y();
|
|
||||||
}
|
|
||||||
|
|
||||||
return aRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
awt::Size SAL_CALL ThumbnailViewItemAcc::getSize()
|
|
||||||
{
|
|
||||||
const awt::Rectangle aRect( getBounds() );
|
|
||||||
awt::Size aRet;
|
|
||||||
|
|
||||||
aRet.Width = aRect.Width;
|
|
||||||
aRet.Height = aRect.Height;
|
|
||||||
|
|
||||||
return aRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SAL_CALL ThumbnailViewItemAcc::grabFocus()
|
void SAL_CALL ThumbnailViewItemAcc::grabFocus()
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
|
@@ -19,25 +19,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <comphelper/accessiblecomponenthelper.hxx>
|
||||||
#include <cppuhelper/implbase.hxx>
|
#include <cppuhelper/implbase.hxx>
|
||||||
|
|
||||||
#include <com/sun/star/accessibility/XAccessible.hpp>
|
#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 <vector>
|
|
||||||
|
|
||||||
class ThumbnailViewItem;
|
class ThumbnailViewItem;
|
||||||
class ThumbnailViewItemAcc : public ::cppu::WeakImplHelper< css::accessibility::XAccessible,
|
class ThumbnailViewItemAcc
|
||||||
css::accessibility::XAccessibleEventBroadcaster,
|
: public cppu::ImplInheritanceHelper<comphelper::OAccessibleComponentHelper,
|
||||||
css::accessibility::XAccessibleContext,
|
css::accessibility::XAccessible>
|
||||||
css::accessibility::XAccessibleComponent>
|
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
::std::vector< css::uno::Reference< css::accessibility::XAccessibleEventListener > >
|
|
||||||
mxEventListeners;
|
|
||||||
std::mutex maMutex;
|
std::mutex maMutex;
|
||||||
ThumbnailViewItem* mpThumbnailViewItem;
|
ThumbnailViewItem* mpThumbnailViewItem;
|
||||||
|
|
||||||
@@ -52,10 +44,6 @@ public:
|
|||||||
// XAccessible
|
// XAccessible
|
||||||
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
|
virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override;
|
||||||
|
|
||||||
// XAccessibleEventBroadcaster
|
|
||||||
virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
|
|
||||||
virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override;
|
|
||||||
|
|
||||||
// XAccessibleContext
|
// XAccessibleContext
|
||||||
virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override;
|
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 getAccessibleChild( sal_Int64 i ) override;
|
||||||
@@ -68,13 +56,12 @@ public:
|
|||||||
virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
|
virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override;
|
||||||
virtual css::lang::Locale SAL_CALL getLocale( ) override;
|
virtual css::lang::Locale SAL_CALL getLocale( ) override;
|
||||||
|
|
||||||
|
// OCommonAccessibleComponent
|
||||||
|
virtual css::awt::Rectangle implGetBounds() override;
|
||||||
|
|
||||||
// XAccessibleComponent
|
// XAccessibleComponent
|
||||||
virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
|
|
||||||
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
|
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 void SAL_CALL grabFocus( ) override;
|
||||||
virtual sal_Int32 SAL_CALL getForeground( ) override;
|
virtual sal_Int32 SAL_CALL getForeground( ) override;
|
||||||
virtual sal_Int32 SAL_CALL getBackground( ) override;
|
virtual sal_Int32 SAL_CALL getBackground( ) override;
|
||||||
|
Reference in New Issue
Block a user