editeng/source/accessibility/AccessibleEditableTextPara.cxx |    2 
 editeng/source/accessibility/AccessibleImageBullet.cxx      |  154 ------------
 editeng/source/accessibility/AccessibleImageBullet.hxx      |   40 ---
 3 files changed, 18 insertions(+), 178 deletions(-)

New commits:
commit 7bf384d048ff58bd3e2d6e706176bf3b8e0be7e8
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Apr 7 11:03:06 2025 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Tue Apr 8 17:12:49 2025 +0200

    editeng a11y: Use OAccessibleComponentHelper for bullet
    
    Let editeng's AccessibleImageBullet derive from
    OAccessibleComponentHelper to make use of the
    logic already implemented there instead of having to
    implement all the XAccessibleComponent
    and XAccessibleEventBroadcaster methods manually.
    
    The existing AccessibleImageBullet::implGetBounds
    implementations provide the necessary logic to implement
    OAccessibleComponentHelper::implGetBounds, so mark it
    as overriding the base class method.
    
    Drop all of the other overrides that are no longer
    needed as the implementation is now provided by
    the base class.
    
    No change in behavior intended or observed in a quick
    test with Impress and Accerciser and the gtk3 VCL plugin
    on Linux.
    
    Sample steps to add a bullet item that shows
    up in the a11y tree:
    
    1) start Impress
    2) Create a new slide (Ctrl+M)
    3) type text "Hello world" for the first list item
    4) right-click on paragraph to open context menu, select "Bullets and
       Numbering"
    5) For "Type", select "Graphics"
    6) select "Select image..." -> "Gallery" -> "bluearrow"
    7) close dialog with "OK" button
    
    Then, start Accerciser, and locate the "Image bullet"
    object within LibreOffice's a11y tree.
    
    Change-Id: Iba9d44288be96838e39d7cee2333f7a074deae8e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183783
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx 
b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index a627a09c5906..e30b364acc60 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -257,7 +257,7 @@ void SAL_CALL AccessibleEditableTextPara::dispose()
 {
     rtl::Reference<AccessibleImageBullet> xBullet = maImageBullet.get();
     if (xBullet.is())
-        xBullet->Dispose();
+        xBullet->dispose();
     maImageBullet.clear();
 
     mxParent = nullptr;
diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx 
b/editeng/source/accessibility/AccessibleImageBullet.cxx
index 31e60013e856..00db3b338d0c 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.cxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.cxx
@@ -54,13 +54,7 @@ AccessibleImageBullet::AccessibleImageBullet ( 
uno::Reference< XAccessible > xPa
     mnIndexInParent( 0 ),
     mpEditSource( nullptr ),
     maEEOffset( 0, 0 ),
-    mxParent(std::move( xParent )),
-    // well, that's strictly (UNO) exception safe, though not
-    // really robust. We rely on the fact that this member is
-    // constructed last, and that the constructor body catches
-    // exceptions, thus no chance for exceptions once the Id is
-    // fetched. Nevertheless, normally should employ RAII here...
-    mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient())
+    mxParent(std::move( xParent ))
 {
     // these are always on
     mnStateSet = AccessibleStateType::VISIBLE;
@@ -69,19 +63,6 @@ AccessibleImageBullet::AccessibleImageBullet ( 
uno::Reference< XAccessible > xPa
     mnStateSet |= AccessibleStateType::SENSITIVE;
 }
 
-AccessibleImageBullet::~AccessibleImageBullet()
-{
-    // sign off from event notifier
-    if( getNotifierClientId() != -1 )
-    {
-        try
-        {
-            ::comphelper::AccessibleEventNotifier::revokeClient( 
getNotifierClientId() );
-        }
-        catch( const uno::Exception& ) {}
-    }
-}
-
 uno::Reference< XAccessibleContext > SAL_CALL 
AccessibleImageBullet::getAccessibleContext(  )
 {
     // We implement the XAccessibleContext interface in the same object
@@ -152,56 +133,12 @@ lang::Locale SAL_CALL AccessibleImageBullet::getLocale()
     return LanguageTag(GetTextForwarder().GetLanguage( GetParagraphIndex(), 0 
)).getLocale();
 }
 
-void SAL_CALL AccessibleImageBullet::addAccessibleEventListener( const 
uno::Reference< XAccessibleEventListener >& xListener )
-{
-    if( getNotifierClientId() != -1 )
-        ::comphelper::AccessibleEventNotifier::addEventListener( 
getNotifierClientId(), xListener );
-}
-
-void SAL_CALL AccessibleImageBullet::removeAccessibleEventListener( const 
uno::Reference< XAccessibleEventListener >& xListener )
-{
-    if( getNotifierClientId() == -1 )
-        return;
-
-    const sal_Int32 nListenerCount = 
::comphelper::AccessibleEventNotifier::removeEventListener( 
getNotifierClientId(), xListener );
-    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::TClientId nId( 
getNotifierClientId() );
-        mnNotifierClientId = -1;
-        ::comphelper::AccessibleEventNotifier::revokeClient( nId );
-    }
-}
-
-sal_Bool SAL_CALL AccessibleImageBullet::containsPoint( const awt::Point& 
rPoint )
-{
-    SolarMutexGuard aGuard;
-
-    DBG_ASSERT(GetParagraphIndex() >= 0,
-               "AccessibleEditableTextPara::contains: index value overflow");
-
-    awt::Rectangle aTmpRect = implGetBounds();
-    tools::Rectangle aRect( Point(aTmpRect.X, aTmpRect.Y), 
Size(aTmpRect.Width, aTmpRect.Height) );
-    Point aPoint( rPoint.X, rPoint.Y );
-
-    return aRect.Contains( aPoint );
-}
-
 uno::Reference< XAccessible > SAL_CALL 
AccessibleImageBullet::getAccessibleAtPoint( const awt::Point& /*aPoint*/ )
 {
     // as we have no children, empty reference
     return uno::Reference< XAccessible >();
 }
 
-awt::Rectangle SAL_CALL AccessibleImageBullet::getBounds(  )
-{
-    SolarMutexGuard aGuard;
-
-    return implGetBounds();
-}
 awt::Rectangle AccessibleImageBullet::implGetBounds(  )
 {
     DBG_ASSERT(GetParagraphIndex() >= 0,
@@ -237,49 +174,6 @@ awt::Rectangle AccessibleImageBullet::implGetBounds(  )
     return awt::Rectangle();
 }
 
-awt::Point SAL_CALL AccessibleImageBullet::getLocation(  )
-{
-    SolarMutexGuard aGuard;
-
-    awt::Rectangle aRect = implGetBounds();
-
-    return awt::Point( aRect.X, aRect.Y );
-}
-
-awt::Point SAL_CALL AccessibleImageBullet::getLocationOnScreen(  )
-{
-    SolarMutexGuard aGuard;
-
-    // relate us to parent
-    uno::Reference< XAccessible > xParent = getAccessibleParent();
-    if( xParent.is() )
-    {
-        uno::Reference< XAccessibleComponent > xParentComponent( xParent, 
uno::UNO_QUERY );
-        if( xParentComponent.is() )
-        {
-            awt::Point aRefPoint = xParentComponent->getLocationOnScreen();
-            awt::Point aPoint = getLocation();
-            aPoint.X += aRefPoint.X;
-            aPoint.Y += aRefPoint.Y;
-
-            return aPoint;
-        }
-    }
-
-    throw uno::RuntimeException(u"Cannot access parent"_ustr,
-                                uno::Reference< uno::XInterface >
-                                ( static_cast< XAccessible* > (this) ) );   // 
disambiguate hierarchy
-}
-
-awt::Size SAL_CALL AccessibleImageBullet::getSize(  )
-{
-    SolarMutexGuard aGuard;
-
-    awt::Rectangle aRect = implGetBounds();
-
-    return awt::Size( aRect.Width, aRect.Height );
-}
-
 void SAL_CALL AccessibleImageBullet::grabFocus(  )
 {
     throw uno::RuntimeException(u"Not focusable"_ustr,
@@ -332,27 +226,12 @@ void AccessibleImageBullet::SetEEOffset( const Point& 
rOffset )
     maEEOffset = rOffset;
 }
 
-void AccessibleImageBullet::Dispose()
+void SAL_CALL AccessibleImageBullet::dispose()
 {
-    int nClientId( getNotifierClientId() );
-
-    // #108212# drop all references before notifying dispose
     mxParent = nullptr;
-    mnNotifierClientId = -1;
     mpEditSource = nullptr;
 
-    // notify listeners
-    if( nClientId != -1 )
-    {
-        try
-        {
-            uno::Reference < XAccessibleContext > xThis = 
getAccessibleContext();
-
-            // #106234# Delegate to EventNotifier
-            
::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, 
xThis );
-        }
-        catch( const uno::Exception& ) {}
-    }
+    OAccessibleComponentHelper::dispose();
 }
 
 void AccessibleImageBullet::SetEditSource( SvxEditSource* pEditSource )
@@ -371,13 +250,7 @@ void AccessibleImageBullet::SetEditSource( SvxEditSource* 
pEditSource )
 
 void AccessibleImageBullet::FireEvent(const sal_Int16 nEventId, const 
uno::Any& rNewValue, const uno::Any& rOldValue)
 {
-    uno::Reference <XAccessibleContext> xThis(this);
-
-    AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue, -1);
-
-    // #106234# Delegate to EventNotifier
-    ::comphelper::AccessibleEventNotifier::addEvent( getNotifierClientId(),
-                                                     aEvent );
+    NotifyAccessibleEvent(nEventId, rOldValue, rNewValue);
 }
 
 void AccessibleImageBullet::SetState( const sal_Int64 nStateId )
diff --git a/editeng/source/accessibility/AccessibleImageBullet.hxx 
b/editeng/source/accessibility/AccessibleImageBullet.hxx
index eb3f24be623b..cca3ea5ebf00 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.hxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.hxx
@@ -21,14 +21,12 @@
 
 #include <rtl/ref.hxx>
 #include <tools/gen.hxx>
+#include <comphelper/accessiblecomponenthelper.hxx>
 #include <cppuhelper/implbase.hxx>
 
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/lang/XServiceInfo.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>
 
 class SvxEditSource;
 class SvxTextForwarder;
@@ -37,23 +35,17 @@ class SvxViewForwarder;
 namespace accessibility
 {
 
-typedef ::cppu::WeakImplHelper< css::accessibility::XAccessible,
-                                 css::accessibility::XAccessibleContext,
-                                 css::accessibility::XAccessibleComponent,
-                                 
css::accessibility::XAccessibleEventBroadcaster,
-                                 css::lang::XServiceInfo >  
AccessibleImageBulletInterfaceBase;
-
 /** This class implements the image bullets for the EditEngine/Outliner UAA
  */
-class AccessibleImageBullet final : public AccessibleImageBulletInterfaceBase
+class AccessibleImageBullet final
+    : public 
cppu::ImplInheritanceHelper<comphelper::OAccessibleComponentHelper,
+                                         css::accessibility::XAccessible, 
css::lang::XServiceInfo>
 {
 
 public:
     /// Create accessible object for given parent
     AccessibleImageBullet ( css::uno::Reference< 
css::accessibility::XAccessible > xParent );
 
-    virtual ~AccessibleImageBullet  () override;
-
     // XAccessible
     virtual css::uno::Reference< css::accessibility::XAccessibleContext > 
SAL_CALL getAccessibleContext(  ) override;
 
@@ -69,17 +61,8 @@ public:
     virtual sal_Int64 SAL_CALL getAccessibleStateSet() override;
     virtual css::lang::Locale SAL_CALL getLocale() 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;
-
     // 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::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;
     virtual sal_Int32 SAL_CALL getBackground(  ) override;
@@ -116,11 +99,7 @@ public:
      */
     void SetEditSource( SvxEditSource* pEditSource );
 
-    /** Dispose this object
-
-        Notifies and deregisters the listeners, drops all references.
-     */
-    void Dispose();
+    void SAL_CALL dispose() override;
 
     /** Set the current paragraph number
 
@@ -153,8 +132,6 @@ private:
 
     SvxEditSource& GetEditSource() const;
 
-    int getNotifierClientId() const { return mnNotifierClientId; }
-
     /** Query the SvxTextForwarder for EditEngine access.
 
         @attention This method does not lock the SolarMutex,
@@ -173,7 +150,7 @@ private:
      */
     SvxViewForwarder&   GetViewForwarder() const;
 
-    css::awt::Rectangle implGetBounds();
+    css::awt::Rectangle implGetBounds() override;
 
     // the paragraph index in the edit engine (guarded by solar mutex)
     sal_Int32   mnParagraphIndex;
@@ -192,9 +169,6 @@ private:
 
     /// The shape we're the accessible for (unguarded)
     css::uno::Reference< css::accessibility::XAccessible > mxParent;
-
-    /// Our listeners (guarded by maMutex)
-    int mnNotifierClientId;
 };
 
 } // end of namespace accessibility
commit 785fc3e4975b4174253e2eb8ee03cfafa824a34e
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Apr 7 11:30:58 2025 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Tue Apr 8 17:12:42 2025 +0200

    editeng a11y: Drop unnecessary exception handling code
    
    Modifying a sal_Int64 value won't throw an exception.
    
    Change-Id: Ia5739ecebb839dfcd51c27f35309ad717b505c56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183782
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx 
b/editeng/source/accessibility/AccessibleImageBullet.cxx
index 204e8c641359..31e60013e856 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.cxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.cxx
@@ -62,18 +62,11 @@ AccessibleImageBullet::AccessibleImageBullet ( 
uno::Reference< XAccessible > xPa
     // fetched. Nevertheless, normally should employ RAII here...
     mnNotifierClientId(::comphelper::AccessibleEventNotifier::registerClient())
 {
-    try
-    {
-        // Create the state set.
-        mnStateSet = 0;
-
-        // these are always on
-        mnStateSet |= AccessibleStateType::VISIBLE;
-        mnStateSet |= AccessibleStateType::SHOWING;
-        mnStateSet |= AccessibleStateType::ENABLED;
-        mnStateSet |= AccessibleStateType::SENSITIVE;
-    }
-    catch( const uno::Exception& ) {}
+    // these are always on
+    mnStateSet = AccessibleStateType::VISIBLE;
+    mnStateSet |= AccessibleStateType::SHOWING;
+    mnStateSet |= AccessibleStateType::ENABLED;
+    mnStateSet |= AccessibleStateType::SENSITIVE;
 }
 
 AccessibleImageBullet::~AccessibleImageBullet()
commit 50190bec9963d07018c7fd490077dff7a1565143
Author:     Michael Weghorn <[email protected]>
AuthorDate: Mon Apr 7 11:23:18 2025 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Tue Apr 8 17:12:34 2025 +0200

    editeng a11y: Simplify AccessibleImageBullet::FireEvent
    
    * Drop const qualifier, which removes the need to const_cast.
    * Don't call AccessibleImageBullet::getAccessibleContext,
      but just use `this` directly.
    
    Change-Id: I4949ec624e44b6330a0ca5f71f898f1d17b4bd8d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183781
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx 
b/editeng/source/accessibility/AccessibleImageBullet.cxx
index 2dc9edbe76b0..204e8c641359 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.cxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.cxx
@@ -376,9 +376,9 @@ void AccessibleImageBullet::SetEditSource( SvxEditSource* 
pEditSource )
     }
 }
 
-void AccessibleImageBullet::FireEvent(const sal_Int16 nEventId, const 
uno::Any& rNewValue, const uno::Any& rOldValue ) const
+void AccessibleImageBullet::FireEvent(const sal_Int16 nEventId, const 
uno::Any& rNewValue, const uno::Any& rOldValue)
 {
-    uno::Reference < XAccessibleContext > xThis( const_cast< 
AccessibleImageBullet* > (this)->getAccessibleContext() );
+    uno::Reference <XAccessibleContext> xThis(this);
 
     AccessibleEventObject aEvent(xThis, nEventId, rNewValue, rOldValue, -1);
 
diff --git a/editeng/source/accessibility/AccessibleImageBullet.hxx 
b/editeng/source/accessibility/AccessibleImageBullet.hxx
index 7715ba9af77f..eb3f24be623b 100644
--- a/editeng/source/accessibility/AccessibleImageBullet.hxx
+++ b/editeng/source/accessibility/AccessibleImageBullet.hxx
@@ -141,7 +141,7 @@ public:
     sal_Int32 GetParagraphIndex() const { return mnParagraphIndex; }
 
     /// Calls all Listener objects to tell them the change. Don't hold locks 
when calling this!
-    void FireEvent(const sal_Int16 nEventId, const css::uno::Any& rNewValue, 
const css::uno::Any& rOldValue = css::uno::Any() ) const;
+    void FireEvent(const sal_Int16 nEventId, const css::uno::Any& rNewValue, 
const css::uno::Any& rOldValue = css::uno::Any());
 
 private:
     AccessibleImageBullet( const AccessibleImageBullet& ) = delete;

Reply via email to