sc/source/ui/Accessibility/AccessibleContextBase.cxx         |  140 -----------
 sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx |   18 +
 sc/source/ui/inc/AccessibleContextBase.hxx                   |   55 ----
 3 files changed, 29 insertions(+), 184 deletions(-)

New commits:
commit 564f62e56e065a36628d9ac3a73c3b4749b034dd
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Apr 9 15:37:37 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Apr 10 19:44:07 2025 +0200

    sc a11y: Use OAccessibleComponentHelper
    
    Let ScAccessibleContextBase 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 ScAccessibleContextBase::GetBoundingBox provides
    necessary logic to implement OAccessibleComponentHelper::implGetBounds,
    so simply call it.
    
    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 Calc using Orca and Accerciser with the gtk3
    and qt6 VCL plugins on Linux.
    
    Change-Id: I3d6db0e8c3b7c165dbbf9399e9b7c5b789cbfac5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183938
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx 
b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
index 07fec4fbd637..1b5dcbb00dec 100644
--- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx
+++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
@@ -40,9 +40,7 @@ ScAccessibleContextBase::ScAccessibleContextBase(
                                                  uno::Reference<XAccessible> 
xParent,
                                                  const sal_Int16 aRole)
                                                  :
-    ScAccessibleContextBaseWeakImpl(m_aMutex),
     mxParent(std::move(xParent)),
-    mnClientId(0),
     maRole(aRole)
 {
 }
@@ -75,12 +73,7 @@ void SAL_CALL ScAccessibleContextBase::disposing()
     // hold reference to make sure that the destructor is not called
     uno::Reference< XAccessibleContext > xKeepAlive(this);
 
-    if ( mnClientId )
-    {
-        sal_Int32 nTemClientId(mnClientId);
-        mnClientId =  0;
-        comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( 
nTemClientId, *this );
-    }
+    OAccessibleComponentHelper::disposing();
 
     mxParent.clear();
 }
@@ -105,29 +98,14 @@ uno::Reference< XAccessibleContext> SAL_CALL
     return this;
 }
 
-//=====  XAccessibleComponent  ================================================
-
-sal_Bool SAL_CALL ScAccessibleContextBase::containsPoint(const awt::Point& 
rPoint )
-{
-    SolarMutexGuard aGuard;
-    IsObjectValid();
-    return tools::Rectangle(Point(), GetBoundingBox().GetSize())
-        .Contains(vcl::unohelper::ConvertToVCLPoint(rPoint));
-}
+// OAccessibleComponentHelper
 
-awt::Rectangle SAL_CALL ScAccessibleContextBase::getBounds(  )
+awt::Rectangle ScAccessibleContextBase::implGetBounds(  )
 {
-    SolarMutexGuard aGuard;
-    IsObjectValid();
     return vcl::unohelper::ConvertToAWTRect(GetBoundingBox());
 }
 
-awt::Point SAL_CALL ScAccessibleContextBase::getLocation(  )
-{
-    SolarMutexGuard aGuard;
-    IsObjectValid();
-    return vcl::unohelper::ConvertToAWTPoint(GetBoundingBox().TopLeft());
-}
+//=====  XAccessibleComponent  ================================================
 
 awt::Point SAL_CALL ScAccessibleContextBase::getLocationOnScreen(  )
 {
@@ -136,13 +114,6 @@ awt::Point SAL_CALL 
ScAccessibleContextBase::getLocationOnScreen(  )
     return 
vcl::unohelper::ConvertToAWTPoint(GetBoundingBoxOnScreen().TopLeft());
 }
 
-awt::Size SAL_CALL ScAccessibleContextBase::getSize(  )
-{
-    SolarMutexGuard aGuard;
-    IsObjectValid();
-    return vcl::unohelper::ConvertToAWTSize(GetBoundingBox().GetSize());
-}
-
 bool ScAccessibleContextBase::isShowing(  )
 {
     SolarMutexGuard aGuard;
@@ -297,48 +268,6 @@ lang::Locale SAL_CALL
     throw IllegalAccessibleComponentStateException ();
 }
 
-    //=====  XAccessibleEventBroadcaster  =====================================
-
-void SAL_CALL
-       ScAccessibleContextBase::addAccessibleEventListener(
-           const uno::Reference<XAccessibleEventListener>& xListener)
-{
-    if (xListener.is())
-    {
-        SolarMutexGuard aGuard;
-        IsObjectValid();
-        if (!IsDefunc())
-        {
-            if (!mnClientId)
-                mnClientId = 
comphelper::AccessibleEventNotifier::registerClient( );
-            comphelper::AccessibleEventNotifier::addEventListener( mnClientId, 
xListener );
-        }
-    }
-}
-
-void SAL_CALL
-       ScAccessibleContextBase::removeAccessibleEventListener(
-        const uno::Reference<XAccessibleEventListener>& xListener)
-{
-    if (!xListener.is())
-        return;
-
-    SolarMutexGuard aGuard;
-    if (IsDefunc() || !mnClientId)
-        return;
-
-    sal_Int32 nListenerCount = 
comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, 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::revokeClient( mnClientId );
-        mnClientId = 0;
-    }
-}
-
 // XServiceInfo
 OUString SAL_CALL ScAccessibleContextBase::getImplementationName()
 {
@@ -375,17 +304,7 @@ OUString ScAccessibleContextBase::createAccessibleName()
 void ScAccessibleContextBase::CommitChange(const sal_Int16 nEventId, const 
css::uno::Any& rOldValue,
                                            const css::uno::Any& rNewValue, 
sal_Int32 nIndexHint)
 {
-    if (!mnClientId)
-        return;
-
-    AccessibleEventObject aEvent;
-    aEvent.Source = uno::Reference<XAccessibleContext>(this);
-    aEvent.EventId = nEventId;
-    aEvent.OldValue = rOldValue;
-    aEvent.NewValue = rNewValue;
-    aEvent.IndexHint = nIndexHint;
-
-    comphelper::AccessibleEventNotifier::addEvent(mnClientId, aEvent);
+    NotifyAccessibleEvent(nEventId, rOldValue, rNewValue, nIndexHint);
 }
 
 void ScAccessibleContextBase::CommitFocusGained()
diff --git a/sc/source/ui/inc/AccessibleContextBase.hxx 
b/sc/source/ui/inc/AccessibleContextBase.hxx
index 9486ec678922..50cc376e0203 100644
--- a/sc/source/ui/inc/AccessibleContextBase.hxx
+++ b/sc/source/ui/inc/AccessibleContextBase.hxx
@@ -25,33 +25,20 @@
 #include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp>
 #include <com/sun/star/uno/Reference.hxx>
 #include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/accessiblecomponenthelper.hxx>
+#include <cppuhelper/implbase.hxx>
 #include <cppuhelper/interfacecontainer.h>
 
 #include <svl/lstner.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <cppuhelper/compbase.hxx>
-#include <cppuhelper/implbase1.hxx>
 #include <rtl/ref.hxx>
 
 namespace tools { class Rectangle; }
 class AbsoluteScreenPixelRectangle;
 
-/** @descr
-        This base class provides an implementation of the
-        <code>AccessibleContext</code> service.
-*/
-typedef cppu::WeakComponentImplHelper<
-                css::accessibility::XAccessible,
-                css::accessibility::XAccessibleComponent,
-                css::accessibility::XAccessibleContext,
-                css::accessibility::XAccessibleEventBroadcaster,
-                css::lang::XServiceInfo
-                > ScAccessibleContextBaseWeakImpl;
-
 class ScAccessibleContextBase
-    :   public cppu::BaseMutex,
-        public ScAccessibleContextBaseWeakImpl,
-        public SfxListener
+    : public 
cppu::ImplInheritanceHelper<comphelper::OAccessibleComponentHelper,
+                                         css::accessibility::XAccessible, 
css::lang::XServiceInfo>,
+      public SfxListener
 {
 
 public:
@@ -82,19 +69,13 @@ public:
     virtual css::uno::Reference< css::accessibility::XAccessibleContext> 
SAL_CALL
         getAccessibleContext() override;
 
-    ///=====  XAccessibleComponent  
============================================
-
-    virtual sal_Bool SAL_CALL containsPoint(
-        const css::awt::Point& rPoint ) override;
+    // OAccessibleComponentHelper
+    virtual css::awt::Rectangle implGetBounds() override;
 
-    virtual css::awt::Rectangle SAL_CALL getBounds(  ) override;
-
-    virtual css::awt::Point SAL_CALL getLocation(  ) override;
+    ///=====  XAccessibleComponent  
============================================
 
     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;
@@ -136,20 +117,6 @@ public:
     virtual css::lang::Locale SAL_CALL
         getLocale() override;
 
-    ///=====  XAccessibleEventBroadcaster  
=====================================
-
-    /** Add listener that is informed of future changes of name,
-          description and so on events.
-    */
-    virtual void SAL_CALL
-        addAccessibleEventListener(
-            const 
css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) 
override;
-
-    //  Remove an existing event listener.
-    virtual void SAL_CALL
-        removeAccessibleEventListener(
-            const 
css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) 
override;
-
     ///=====  XServiceInfo  
====================================================
 
     /** Returns an identifier for the implementation of this object.
@@ -231,9 +198,6 @@ private:
     */
     OUString msName;
 
-    /// client id in the AccessibleEventNotifier queue
-    sal_uInt32 mnClientId;
-
     /** This is the role of this object.
     */
     sal_Int16 maRole;
commit 79a8c883a5791e2b3a99472e0fa1db3a68a1c789
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 10 13:14:14 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Apr 10 19:43:59 2025 +0200

    sc a11y: Dispose children in ScAccessibleDocumentPagePreview::disposing
    
    ScAccessibleDocumentPagePreview is their parent
    and owns them, so is responsible for disposing
    them again.
    
    See also commit message of
    
        Change-Id: I867ed2203d824bcffe86eb320cc3c009c265f4b4
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Thu Apr 10 13:12:56 2025 +0200
    
            sc a11y: No longer listen to parent disposal
    
    for some potentially relevant background.
    
    Change-Id: Ida4520a59c472d9f20c0e2df3fd61e37a0df0515
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183972
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx 
b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
index 7d3d76f4862c..1e60087df40f 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -1141,9 +1141,21 @@ 
ScAccessibleDocumentPagePreview::~ScAccessibleDocumentPagePreview()
 void SAL_CALL ScAccessibleDocumentPagePreview::disposing()
 {
     SolarMutexGuard aGuard;
-    mpTable.clear();
-    mpHeader.clear();
-    mpFooter.clear();
+    if (mpTable.is())
+    {
+        mpTable->dispose();
+        mpTable.clear();
+    }
+    if (mpHeader)
+    {
+        mpHeader->dispose();
+        mpHeader.clear();
+    }
+    if (mpFooter)
+    {
+        mpFooter->dispose();
+        mpFooter.clear();
+    }
 
     if (mpViewShell)
     {
commit d2a4d90c670f4ae453e652429c5502f229bb0edb
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 10 13:12:56 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Apr 10 19:43:52 2025 +0200

    sc a11y: No longer listen to parent disposal
    
    Commit
    
        commit 8e886993f32b7db11a99bdecf06451e6de6c3842
        Date:   Sat Oct 7 11:42:40 2023 +0200
    
            tdf#157568 After deleting the content of a cell by pressing the 
delete..
    
            .. key, Orca still speaks the content.
    
            this reverts
                commit f22cb3dfab413a2917cd810b8e1b8f644a016327
                Author: Noel Grandin <noelgran...@gmail.com>
                Date:   Mon Jun 12 20:02:19 2023 +0200
                tdf#155376 weakly cache ScAccessibleCell
    
            which was a nice idea, but means that we would need to have
            some way of updating the ScAccessibleCell when the associated
            cell data changes. Which is likely to be complicated.
    
            So return to creating new ScAccessibleCell objects all the time,
            but fix them to not leak.
    
            Change-Id: Ie17ee5c950c9809d4c7281f93761584f75256121
    
    split the XAccessibleEventListener logic from
    ScAccessibleContextBase into an inner helper class
    ScAccessibleContextBase::ScAccessibleContextBaseEventListener whose
    lifecycle is decoupled from its ScAccessibleContextBase
    object.
    As the code comment says:
    
        /**
         The listener is an internal class to prevent reference-counting cycles 
and therefore memory leaks.
        */
    
    Since that commit, the XAccessibleEventListener::disposing
    implementation however also no longer disposes the
    ScAccessibleContextBase object when being notified about
    the parent disposal, but only disposes the itself,
    which - if I understand correctly - doesn't seem to match the
    original purpose.
    
    This would be needed to dispose the ScAccessibleContextBase
    instead:
    
        diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx 
b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
        index 99707cdd4517..1918b67b55b3 100644
        --- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx
        +++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
        @@ -56,7 +56,7 @@ public:
             {
                 SolarMutexGuard aGuard;
                 if (rSource.Source == mrBase.mxParent)
        -            dispose();
        +            mrBase.dispose();
             }
    
             virtual void SAL_CALL
        stash@{4}: WIP on master: 8ace7409d57f sw a11y: Pass shell by ref
    
    With pending Gerrit change [1] ("sc a11y: Use OAccessibleComponentHelper"),
    that separation of lifecycle also was seen triggering a crash for
    JunitTest_sc_unoapi_1 (s. backtrace below). At the point that
    ScAccessibleContextBase::ScAccessibleContextBaseEventListener::disposing
    gets called (frame #5), the ScAccessibleContextBase object (`mrBase`) has
    apparently already been deleted (when pending change [1] is applied).
    
    Drop the listener altogether.
    Instead, consider it the responsibility of the owner/parent to
    dispose its a11y children as needed, as it is done elsewhere.
    If that disposal is currently missing anywhere, it should be added
    separately. This change shouldn't have any effect in that regard due
    to the listener not disposing the ScAccessibleContextBase object any
    more anyway.
    (There is also existing logic to dispose the object
    in ScAccessibleContextBase::Notify and in the dtor,
    which remains unchanged.)
    
    Backtrace:
    
        Thread 1 (Thread 0x7eff157ff6c0 (LWP 330592)):
        #0  0x00007eff285bcc0c in com::sun::star::uno::BaseReference::iquery 
(pInterface=0x9999999999999999, rType=invalid uno::Type) at 
include/com/sun/star/uno/Reference.hxx:59
                aRet = <error reading variable: Cannot access memory at address 
0x99999999999999a1>
        #1  0x00007eff286edc79 in 
com::sun::star::uno::Reference<com::sun::star::uno::XInterface>::iquery 
(pInterface=0x9999999999999999) at include/com/sun/star/uno/Reference.hxx:74
        #2  0x00007eff28ae8254 in 
com::sun::star::uno::Reference<com::sun::star::uno::XInterface>::Reference 
(this=0x7eff157fa2f8, pInterface=0x9999999999999999) at 
include/com/sun/star/uno/Reference.hxx:185
        #3  0x00007eff28ae817a in 
com::sun::star::uno::BaseReference::operator== (this=0x7eff157fa470, 
pInterface=0x9999999999999999) at include/com/sun/star/uno/Reference.hxx:426
                x1 = uno::Reference to (ScAccessibleDocumentPagePreview *) 
0x7eff08005ca0
                x2 = uno::Reference to (com::sun::star::uno::XInterface *) 
0x7eff289b62c8 
<osl::Guard<comphelper::SolarMutex>::Guard(comphelper::SolarMutex&)+40>
        #4  0x00007eff28ae3ba0 in 
com::sun::star::uno::BaseReference::operator== (this=0x7eff157fa470, rRef=...) 
at include/com/sun/star/uno/Reference.hxx:462
        #5  0x00007eff291683b6 in 
ScAccessibleContextBase::ScAccessibleContextBaseEventListener::disposing 
(this=0x565180088c00, rSource=...) at 
/home/michi/development/git/libreoffice/sc/source/ui/Accessibility/AccessibleContextBase.cxx:58
                aGuard = {<osl::Guard<comphelper::SolarMutex>> = {pT = 
0x56517ce99aa0}, <No data fields>}
        #6  0x00007eff7f4ea1b6 in 
comphelper::OInterfaceContainerHelper4<com::sun::star::accessibility::XAccessibleEventListener>::disposeAndClear
 (this=0x7eff157fa4c8, rGuard=..., rEvt=...) at 
include/comphelper/interfacecontainer4.hxx:492
                aIt = {rCont = @0x7eff157fa4c8, maData = {m_pimpl = 
0x7eff08009e50}, nRemain = 0}
        #7  0x00007eff7f4e930e in 
comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing (_nClient=3, 
_rxEventSource=uno::Reference to (ScAccessibleDocumentPagePreview *) 
0x7eff08005ca0) at 
/home/michi/development/git/libreoffice/comphelper/source/misc/accessibleeventnotifier.cxx:204
                aGuard = {_M_device = 0x7eff7f70e4f8 <(anonymous 
namespace)::GetLocalMutex()::MUTEX>, _M_owns = false}
                aClientPos = invalid iterator
                aListeners = {maData = {m_pimpl = 0x5651800f8950}}
                aDisposalEvent = {Source = uno::Reference to 
(ScAccessibleDocumentPagePreview *) 0x7eff08005ca0}
        #8  0x00007eff7f4e5e8d in 
comphelper::OAccessibleComponentHelper::disposing (this=0x7eff08005ca0) at 
/home/michi/development/git/libreoffice/comphelper/source/misc/accessiblecomponenthelper.cxx:61
                aGuard = {pT = 0x56517ce99aa0}
        #9  0x00007eff29165d79 in ScAccessibleContextBase::disposing 
(this=0x7eff08005ca0) at 
/home/michi/development/git/libreoffice/sc/source/ui/Accessibility/AccessibleContextBase.cxx:110
                aGuard = {<osl::Guard<comphelper::SolarMutex>> = {pT = 
0x56517ce99aa0}, <No data fields>}
                xKeepAlive = uno::Reference to (ScAccessibleDocumentPagePreview 
*) 0x7eff08005cf0
        #10 0x00007eff291a2824 in ScAccessibleDocumentPagePreview::disposing 
(this=0x7eff08005ca0) at 
/home/michi/development/git/libreoffice/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx:1160
                aGuard = {<osl::Guard<comphelper::SolarMutex>> = {pT = 
0x56517ce99aa0}, <No data fields>}
        #11 0x00007eff7ef3dc40 in cppu::WeakComponentImplHelperBase::dispose 
(this=0x7eff08005ca0) at 
/home/michi/development/git/libreoffice/cppuhelper/source/implbase.cxx:104
                aEvt = {Source = uno::Reference to 
(ScAccessibleDocumentPagePreview *) 0x7eff08005ca0}
                aGuard2 = {pT = 0x7eff157fa730}
                aGuard = {pT = 0x0}
                exc = <error reading variable: Cannot access memory at address 
0x100000004>
        #12 0x00007eff29156eb5 in 
cppu::PartialWeakComponentImplHelper<com::sun::star::accessibility::XAccessibleContext2,
 com::sun::star::accessibility::XAccessibleEventBroadcaster, 
com::sun::star::accessibility::XAccessibleExtendedComponent>::dispose 
(this=0x7eff08005ca0) at include/cppuhelper/compbase.hxx:90
        #13 0x00007eff29165f84 in ScAccessibleContextBase::Notify 
(this=0x7eff08005ca0, rHint=...) at 
/home/michi/development/git/libreoffice/sc/source/ui/Accessibility/AccessibleContextBase.cxx:129
        #14 0x00007eff291a2f38 in ScAccessibleDocumentPagePreview::Notify 
(this=0x7eff08005ca0, rBC=..., rHint=...) at 
/home/michi/development/git/libreoffice/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx:1232
        #15 0x00007eff7c549b8c in SfxBroadcaster::Broadcast 
(this=0x7eff3400cf00, rHint=...) at 
/home/michi/development/git/libreoffice/svl/source/notify/SfxBroadcaster.cxx:43
                pListener = 0x7eff08005d28
                i = 0
                nSize = 5
        #16 0x00007eff29b546f6 in ScPreviewShell::BroadcastAccessibility 
(this=0x565180199c00, rHint=...) at 
/home/michi/development/git/libreoffice/sc/source/ui/view/prevwsh.cxx:1159
        #17 0x00007eff29b5451a in ScPreviewShell::~ScPreviewShell 
(this=0x565180199c00) at 
/home/michi/development/git/libreoffice/sc/source/ui/view/prevwsh.cxx:185
                pDrawBC = 0x565180365360
        #18 0x00007eff29b54759 in ScPreviewShell::~ScPreviewShell 
(this=0x565180199c00) at 
/home/michi/development/git/libreoffice/sc/source/ui/view/prevwsh.cxx:180
        #19 0x00007eff7d62efff in SfxViewFrame::ReleaseObjectShell_Impl 
(this=0x7eff1c234340) at 
/home/michi/development/git/libreoffice/sfx2/source/view/viewfrm.cxx:1142
                pDyingViewSh = 0x565180199c00
        #20 0x00007eff7d63626c in SfxViewFrame::~SfxViewFrame 
(this=0x7eff1c234340) at 
/home/michi/development/git/libreoffice/sfx2/source/view/viewfrm.cxx:2067
                pSfxApp = 0x7eff1c232340
        #21 0x00007eff7d631832 in SfxViewFrame::Close (this=0x7eff1c234340) at 
/home/michi/development/git/libreoffice/sfx2/source/view/viewfrm.cxx:1194
        #22 0x00007eff7d5ba93c in SfxFrame::DoClose_Impl (this=0x7eff1c22dac0) 
at /home/michi/development/git/libreoffice/sfx2/source/view/frame.cxx:138
                pBindings = 0x7eff1c22e0e0
        #23 0x00007eff7d60358a in SfxBaseController::dispose 
(this=0x565183247040) at 
/home/michi/development/git/libreoffice/sfx2/source/view/sfxbasecontroller.cxx:929
                aGuard = {<osl::Guard<comphelper::SolarMutex>> = {pT = 
0x56517ce99aa0}, <No data fields>}
                xKeepAlive = uno::Reference to (ScPreviewObj *) 0x565183247068
                aEventObject = {Source = uno::Reference to (ScPreviewObj *) 
0x565183247040}
    
    [1] https://gerrit.libreoffice.org/c/core/+/183938/1
    
    Change-Id: I867ed2203d824bcffe86eb320cc3c009c265f4b4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183971
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sc/source/ui/Accessibility/AccessibleContextBase.cxx 
b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
index 99707cdd4517..07fec4fbd637 100644
--- a/sc/source/ui/Accessibility/AccessibleContextBase.cxx
+++ b/sc/source/ui/Accessibility/AccessibleContextBase.cxx
@@ -36,37 +36,6 @@
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::accessibility;
 
-/**
- The listener is an internal class to prevent reference-counting cycles and 
therefore memory leaks.
-*/
-typedef cppu::WeakComponentImplHelper<
-                css::accessibility::XAccessibleEventListener
-                > ScAccessibleContextBaseEventListenerWeakImpl;
-class ScAccessibleContextBase::ScAccessibleContextBaseEventListener : public 
cppu::BaseMutex, public ScAccessibleContextBaseEventListenerWeakImpl
-{
-public:
-    ScAccessibleContextBaseEventListener(ScAccessibleContextBase& rBase)
-        : ScAccessibleContextBaseEventListenerWeakImpl(m_aMutex), 
mrBase(rBase) {}
-
-    using WeakComponentImplHelperBase::disposing;
-
-    ///=====  XAccessibleEventListener  
========================================
-
-    virtual void SAL_CALL disposing( const lang::EventObject& rSource ) 
override
-    {
-        SolarMutexGuard aGuard;
-        if (rSource.Source == mrBase.mxParent)
-            dispose();
-    }
-
-    virtual void SAL_CALL
-        notifyEvent(
-        const css::accessibility::AccessibleEventObject& /*aEvent*/ ) override 
{}
-private:
-    ScAccessibleContextBase& mrBase;
-};
-
-
 ScAccessibleContextBase::ScAccessibleContextBase(
                                                  uno::Reference<XAccessible> 
xParent,
                                                  const sal_Int16 aRole)
@@ -94,16 +63,6 @@ void ScAccessibleContextBase::Init()
     // hold reference to make sure that the destructor is not called
     uno::Reference< XAccessibleContext > xKeepAlive(this);
 
-    if (mxParent.is())
-    {
-        uno::Reference< XAccessibleEventBroadcaster > xBroadcaster 
(mxParent->getAccessibleContext(), uno::UNO_QUERY);
-        if (xBroadcaster.is())
-        {
-            if (!mxEventListener)
-                mxEventListener = new 
ScAccessibleContextBaseEventListener(*this);
-            xBroadcaster->addAccessibleEventListener(mxEventListener);
-        }
-    }
     msName = createAccessibleName();
     msDescription = createAccessibleDescription();
 }
@@ -123,13 +82,7 @@ void SAL_CALL ScAccessibleContextBase::disposing()
         comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( 
nTemClientId, *this );
     }
 
-    if (mxParent.is())
-    {
-        uno::Reference< XAccessibleEventBroadcaster > xBroadcaster 
(mxParent->getAccessibleContext(), uno::UNO_QUERY);
-        if (xBroadcaster && mxEventListener)
-            xBroadcaster->removeAccessibleEventListener(mxEventListener);
-        mxParent = nullptr;
-    }
+    mxParent.clear();
 }
 
 
diff --git a/sc/source/ui/inc/AccessibleContextBase.hxx 
b/sc/source/ui/inc/AccessibleContextBase.hxx
index ed6bee6b3277..9486ec678922 100644
--- a/sc/source/ui/inc/AccessibleContextBase.hxx
+++ b/sc/source/ui/inc/AccessibleContextBase.hxx
@@ -53,7 +53,6 @@ class ScAccessibleContextBase
         public ScAccessibleContextBaseWeakImpl,
         public SfxListener
 {
-class ScAccessibleContextBaseEventListener;
 
 public:
     //=====  internal  ========================================================
@@ -238,8 +237,6 @@ private:
     /** This is the role of this object.
     */
     sal_Int16 maRole;
-
-    rtl::Reference<ScAccessibleContextBaseEventListener> mxEventListener;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to