comphelper/source/misc/accessiblewrapper.cxx |   17 +++++++++--------
 include/comphelper/accessiblewrapper.hxx     |    5 +++--
 include/comphelper/proxyaggregation.hxx      |    6 +++---
 3 files changed, 15 insertions(+), 13 deletions(-)

New commits:
commit dd4e3131a72073ceb856258898876170999e13a9
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed May 21 21:04:29 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu May 22 05:53:31 2025 +0200

    comphelper a11y: Use concrete OAccessibleContextWrapper
    
    ... for OAccessibleWrapper::m_aContext instead of
    XAccessibleContext.
    
    This requires adjusting the visibility of
    OComponentProxyAggregationHelper to match that of
    OAccessibleWrapper.
    
    Otherwise loplugin:dyncastvisibility would fail like
    this:
    
        In file included from 
/home/michi/development/git/libreoffice/comphelper/source/misc/accessiblewrapper.cxx:20:
        In file included from 
/home/michi/development/git/libreoffice/include/comphelper/accessiblewrapper.hxx:42:
        
/home/michi/development/git/libreoffice/include/unotools/weakref.hxx:127:20: 
error: dynamic_cast from 'com::sun::star::uno::XInterface' with default type 
visibility to 'comphelper::OAccessibleContextWrapper' with default type 
visibility [loplugin:dyncastvisibility]
          127 |             return 
dynamic_cast<interface_type*>(xInterface.get());
              |                    
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        
/home/michi/development/git/libreoffice/workdir/UnoApiHeadersTarget/udkapi/normal/com/sun/star/uno/XInterface.hdl:15:40:
 note: base class 'com::sun::star::uno::XInterface' with default type 
visibility defined here [loplugin:dyncastvisibility]
        [...]
        
/home/michi/development/git/libreoffice/include/comphelper/proxyaggregation.hxx:130:11:
 note: intermediary class 'OComponentProxyAggregationHelper' with hidden type 
visibility defined here [loplugin:dyncastvisibility]
          130 |     class OComponentProxyAggregationHelper :public 
::cppu::ImplHelper1 <   css::lang::XEventListener
              |     
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          131 |                                                                 
        >
    
        [...]
        
/home/michi/development/git/libreoffice/include/comphelper/accessiblewrapper.hxx:219:51:
 note: derived class 'comphelper::OAccessibleContextWrapper' with default type 
visibility defined here [loplugin:dyncastvisibility]
          219 | class UNLESS_MERGELIBS_MORE(COMPHELPER_DLLPUBLIC) 
OAccessibleContextWrapper final
        [...]
    
    Change-Id: Ic20872d1b1778dc97dc8d2dfc1833bbe31e3eea0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185633
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/comphelper/source/misc/accessiblewrapper.cxx 
b/comphelper/source/misc/accessiblewrapper.cxx
index b1afd77d80f7..32e1c23b1bd0 100644
--- a/comphelper/source/misc/accessiblewrapper.cxx
+++ b/comphelper/source/misc/accessiblewrapper.cxx
@@ -290,13 +290,13 @@ Any OAccessibleWrapper::queryInterface( const Type& 
_rType )
 
 Reference< XAccessibleContext > OAccessibleWrapper::getContextNoCreate( ) const
 {
-    return m_aContext;
+    return m_aContext.get();
 }
 
 Reference< XAccessibleContext > SAL_CALL 
OAccessibleWrapper::getAccessibleContext(  )
 {
     // see if the context is still alive (we cache it)
-    Reference< XAccessibleContext > xContext = m_aContext;
+    rtl::Reference<OAccessibleContextWrapper> xContext = m_aContext.get();
     if ( !xContext.is() )
     {
         // create a new context
@@ -305,7 +305,7 @@ Reference< XAccessibleContext > SAL_CALL 
OAccessibleWrapper::getAccessibleContex
         {
             xContext = new OAccessibleContextWrapper(getComponentContext(), 
xInnerContext, this, m_xParentAccessible);
             // cache it
-            m_aContext = WeakReference< XAccessibleContext >( xContext );
+            m_aContext = 
unotools::WeakReference<OAccessibleContextWrapper>(xContext);
         }
     }
 
diff --git a/include/comphelper/accessiblewrapper.hxx 
b/include/comphelper/accessiblewrapper.hxx
index 60522f09642d..82d04fa1e2b9 100644
--- a/include/comphelper/accessiblewrapper.hxx
+++ b/include/comphelper/accessiblewrapper.hxx
@@ -39,6 +39,7 @@
 #include <comphelper/accessibleeventnotifier.hxx>
 #include <comphelper/comphelperdllapi.h>
 #include <rtl/ref.hxx>
+#include <unotools/weakref.hxx>
 
 namespace com::sun::star::uno { class XComponentContext; }
 
@@ -47,6 +48,7 @@ namespace comphelper
 
 //= OAccessibleWrapper
 
+class OAccessibleContextWrapper;
 class OWrappedAccessibleChildrenManager;
 
 using OAccessibleWrapper_Base = 
cppu::ImplHelper1<css::accessibility::XAccessible>;
@@ -61,8 +63,7 @@ class UNLESS_MERGELIBS_MORE(COMPHELPER_DLLPUBLIC) 
OAccessibleWrapper final : pub
 private:
     css::uno::Reference< css::accessibility::XAccessible >
             m_xParentAccessible;
-    css::uno::WeakReference< css::accessibility::XAccessibleContext >
-            m_aContext;
+    unotools::WeakReference<OAccessibleContextWrapper> m_aContext;
     css::uno::Reference< css::accessibility::XAccessible >
             m_xInnerAccessible;
 
diff --git a/include/comphelper/proxyaggregation.hxx 
b/include/comphelper/proxyaggregation.hxx
index a9b13004d7f1..0cbce20d3d02 100644
--- a/include/comphelper/proxyaggregation.hxx
+++ b/include/comphelper/proxyaggregation.hxx
@@ -127,9 +127,9 @@ namespace comphelper
         calls which your derived class gets to the dispose method of this 
class.</p>
     */
 
-    class OComponentProxyAggregationHelper :public ::cppu::ImplHelper1 <   
css::lang::XEventListener
-                                                                        >
-                                            ,private OProxyAggregation
+    class UNLESS_MERGELIBS_MORE(COMPHELPER_DLLPUBLIC) 
OComponentProxyAggregationHelper
+        : public ::cppu::ImplHelper1<css::lang::XEventListener>,
+          private OProxyAggregation
     {
     private:
         typedef ::cppu::ImplHelper1 <   css::lang::XEventListener
commit d9e74b7ef4486355c7875d353fdc53bbe5ab5e4d
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed May 21 20:37:20 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu May 22 05:53:20 2025 +0200

    a11y: Slightly simplify OWrappedAccessibleChildrenManager::dispose
    
    Change-Id: Id7bb729b5518452294c6daa7428c333f4f2e1e92
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185632
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/comphelper/source/misc/accessiblewrapper.cxx 
b/comphelper/source/misc/accessiblewrapper.cxx
index d5d95dda6532..b1afd77d80f7 100644
--- a/comphelper/source/misc/accessiblewrapper.cxx
+++ b/comphelper/source/misc/accessiblewrapper.cxx
@@ -125,12 +125,13 @@ void OWrappedAccessibleChildrenManager::dispose()
         if( xComp.is() )
             xComp->removeEventListener( this );
 
-        Reference< XComponent > xContextComponent;
         if( rChild.second.is() )
-            xContextComponent.set( rChild.second->getContextNoCreate(),
-                                   ::css::uno::UNO_QUERY );
-        if( xContextComponent.is() )
-            xContextComponent->dispose();
+        {
+            Reference<XComponent> 
xContextComponent(rChild.second->getContextNoCreate(),
+                                                    css::uno::UNO_QUERY);
+            if (xContextComponent.is())
+                xContextComponent->dispose();
+        }
     }
 
     // clear our children

Reply via email to