solenv/clang-format/excludelist          |    2 
 sw/source/uibase/docvw/SidebarWinAcc.cxx |   64 ++++++++++---------------------
 sw/source/uibase/docvw/SidebarWinAcc.hxx |   43 +++++++-------------
 3 files changed, 36 insertions(+), 73 deletions(-)

New commits:
commit 33b2abf2cd31ef75b9d8a17e021489159b4cfa3c
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 12 19:01:19 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 12 23:02:45 2024 +0100

    sw a11y: clang-format SidebarWinAccessible code
    
    Change-Id: I623d7ce9520236dcca7322c808e89328c26cb70c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178387
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 9e53e862a91f..7a6c09e66031 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -13075,8 +13075,6 @@ sw/source/uibase/docvw/ShadowOverlayObject.cxx
 sw/source/uibase/docvw/ShadowOverlayObject.hxx
 sw/source/uibase/docvw/SidebarTxtControl.cxx
 sw/source/uibase/docvw/SidebarTxtControl.hxx
-sw/source/uibase/docvw/SidebarWinAcc.cxx
-sw/source/uibase/docvw/SidebarWinAcc.hxx
 sw/source/uibase/docvw/edtdd.cxx
 sw/source/uibase/docvw/edtwin.cxx
 sw/source/uibase/docvw/edtwin2.cxx
diff --git a/sw/source/uibase/docvw/SidebarWinAcc.cxx 
b/sw/source/uibase/docvw/SidebarWinAcc.cxx
index 41842f25ee97..646abbb782d6 100644
--- a/sw/source/uibase/docvw/SidebarWinAcc.cxx
+++ b/sw/source/uibase/docvw/SidebarWinAcc.cxx
@@ -26,8 +26,8 @@
 
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 
-namespace sw::sidebarwindows {
-
+namespace sw::sidebarwindows
+{
 SidebarWinAccessible::SidebarWinAccessible(sw::annotation::SwAnnotationWin& 
rSidebarWin,
                                            SwViewShell& rViewShell,
                                            const SwSidebarItem& rSidebarItem)
diff --git a/sw/source/uibase/docvw/SidebarWinAcc.hxx 
b/sw/source/uibase/docvw/SidebarWinAcc.hxx
index 89ea901936d2..8dc4463e5824 100644
--- a/sw/source/uibase/docvw/SidebarWinAcc.hxx
+++ b/sw/source/uibase/docvw/SidebarWinAcc.hxx
@@ -25,31 +25,33 @@
 class SwViewShell;
 class SwSidebarItem;
 class SwFrame;
-namespace sw::annotation { class SwAnnotationWin; }
-
-namespace sw::sidebarwindows {
+namespace sw::annotation
+{
+class SwAnnotationWin;
+}
 
+namespace sw::sidebarwindows
+{
 class SidebarWinAccessible
     : public cppu::ImplInheritanceHelper<VCLXAccessibleComponent, 
css::accessibility::XAccessible>
 {
-    public:
-        explicit SidebarWinAccessible( sw::annotation::SwAnnotationWin& 
rSidebarWin,
-                                       SwViewShell& rViewShell,
-                                       const SwSidebarItem& rSidebarItem );
-        virtual ~SidebarWinAccessible() override;
+public:
+    explicit SidebarWinAccessible(sw::annotation::SwAnnotationWin& rSidebarWin,
+                                  SwViewShell& rViewShell, const 
SwSidebarItem& rSidebarItem);
+    virtual ~SidebarWinAccessible() override;
 
-        virtual css::uno::Reference<css::accessibility::XAccessibleContext>
-            SAL_CALL getAccessibleContext() override;
+    virtual css::uno::Reference<css::accessibility::XAccessibleContext>
+        SAL_CALL getAccessibleContext() override;
 
-        virtual css::uno::Reference<css::accessibility::XAccessible>
-            SAL_CALL getAccessibleParent() override;
-        virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override;
+    virtual css::uno::Reference<css::accessibility::XAccessible>
+        SAL_CALL getAccessibleParent() override;
+    virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override;
 
-        void ChangeSidebarItem( const SwSidebarItem& rSidebarItem );
+    void ChangeSidebarItem(const SwSidebarItem& rSidebarItem);
 
-    private:
-        SwViewShell& mrViewShell;
-        const SwFrame* mpAnchorFrame;
+private:
+    SwViewShell& mrViewShell;
+    const SwFrame* mpAnchorFrame;
 };
 
 } // end of namespace sw::sidebarwindows
commit 12dd2f6b3c1b42e099f9ea599887346cd3516c99
Author:     Michael Weghorn <[email protected]>
AuthorDate: Thu Dec 12 18:50:14 2024 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Thu Dec 12 23:02:39 2024 +0100

    sw a11y: Merge SidebarWinAccessible and SidebarWinAccessibleContext
    
    Instead of having two separate classes to implement
    the XAccessible and the XAccessibleContext interfaces,
    let SidebarWinAccessible implement both and
    merge the corresponding logic from SidebarWinAccessibleContext
    into SidebarWinAccessible.
    
    This also reduces duplication.
    
    In SidebarWinAccessible::getAccessibleContext,
    simply return a reference to the object itself
    (after checking that the object is still alive).
    
    After
    
        Change-Id: If0894e733273eecad268c6a932ecee7c2e34b4c2
        Author: Michael Weghorn <[email protected]>
        Date:   Thu Dec 12 18:06:13 2024 +0100
    
            a11y: Stop using VCLXWindow in vcl a11y classes
    
    , there's also no more need for SidebarWinAccessible to
    subclass VCLXWindow, so drop that inheritance.
    
    Change-Id: I5688ced4f83a0291de49741dc1b9df8c8f256099
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178386
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/sw/source/uibase/docvw/SidebarWinAcc.cxx 
b/sw/source/uibase/docvw/SidebarWinAcc.cxx
index b289c0ea9959..41842f25ee97 100644
--- a/sw/source/uibase/docvw/SidebarWinAcc.cxx
+++ b/sw/source/uibase/docvw/SidebarWinAcc.cxx
@@ -28,26 +28,34 @@
 
 namespace sw::sidebarwindows {
 
-// implementation of accessible context for <SidebarWinAccessible> instance
-SidebarWinAccessibleContext::SidebarWinAccessibleContext(
-    sw::annotation::SwAnnotationWin& rSidebarWin, SwViewShell& rViewShell,
-    const SwFrame* pAnchorFrame)
-    : VCLXAccessibleComponent(&rSidebarWin)
+SidebarWinAccessible::SidebarWinAccessible(sw::annotation::SwAnnotationWin& 
rSidebarWin,
+                                           SwViewShell& rViewShell,
+                                           const SwSidebarItem& rSidebarItem)
+    : ImplInheritanceHelper(&rSidebarWin)
     , mrViewShell(rViewShell)
-    , mpAnchorFrame(pAnchorFrame)
+    , mpAnchorFrame(rSidebarItem.maLayoutInfo.mpAnchorFrame)
 {
     rSidebarWin.SetAccessibleRole(css::accessibility::AccessibleRole::COMMENT);
 }
 
-void SidebarWinAccessibleContext::ChangeAnchor(const SwFrame* pAnchorFrame)
+SidebarWinAccessible::~SidebarWinAccessible() {}
+
+void SidebarWinAccessible::ChangeSidebarItem(const SwSidebarItem& rSidebarItem)
 {
     SolarMutexGuard aGuard;
 
-    mpAnchorFrame = pAnchorFrame;
+    mpAnchorFrame = rSidebarItem.maLayoutInfo.mpAnchorFrame;
 }
 
-css::uno::Reference<css::accessibility::XAccessible>
-SidebarWinAccessibleContext::getAccessibleParent()
+css::uno::Reference<css::accessibility::XAccessibleContext>
+SidebarWinAccessible::getAccessibleContext()
+{
+    ensureAlive();
+
+    return this;
+}
+
+css::uno::Reference<css::accessibility::XAccessible> 
SidebarWinAccessible::getAccessibleParent()
 {
     SolarMutexGuard aGuard;
 
@@ -61,7 +69,7 @@ SidebarWinAccessibleContext::getAccessibleParent()
     return xAccParent;
 }
 
-sal_Int64 SAL_CALL SidebarWinAccessibleContext::getAccessibleIndexInParent()
+sal_Int64 SAL_CALL SidebarWinAccessible::getAccessibleIndexInParent()
 {
     SolarMutexGuard aGuard;
 
@@ -75,36 +83,6 @@ sal_Int64 SAL_CALL 
SidebarWinAccessibleContext::getAccessibleIndexInParent()
     return nIndex;
 }
 
-// implementation of accessible for <SwAnnotationWin> instance
-SidebarWinAccessible::SidebarWinAccessible( sw::annotation::SwAnnotationWin& 
rSidebarWin,
-                                            SwViewShell& rViewShell,
-                                            const SwSidebarItem& rSidebarItem )
-    : mrSidebarWin( rSidebarWin )
-    , mrViewShell( rViewShell )
-    , mpAnchorFrame( rSidebarItem.maLayoutInfo.mpAnchorFrame )
-{
-    SetWindow( &mrSidebarWin );
-}
-
-SidebarWinAccessible::~SidebarWinAccessible()
-{
-}
-
-void SidebarWinAccessible::ChangeSidebarItem( const SwSidebarItem& 
rSidebarItem )
-{
-    if (m_xAccContext.is())
-        m_xAccContext->ChangeAnchor(rSidebarItem.maLayoutInfo.mpAnchorFrame);
-}
-
-css::uno::Reference<css::accessibility::XAccessibleContext>
-SidebarWinAccessible::getAccessibleContext()
-{
-    if (!m_xAccContext.is())
-        m_xAccContext = new SidebarWinAccessibleContext(mrSidebarWin, 
mrViewShell, mpAnchorFrame);
-
-    return m_xAccContext;
-}
-
 } // end of namespace sw::sidebarwindows
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/docvw/SidebarWinAcc.hxx 
b/sw/source/uibase/docvw/SidebarWinAcc.hxx
index f3597f3d509c..89ea901936d2 100644
--- a/sw/source/uibase/docvw/SidebarWinAcc.hxx
+++ b/sw/source/uibase/docvw/SidebarWinAcc.hxx
@@ -29,25 +29,8 @@ namespace sw::annotation { class SwAnnotationWin; }
 
 namespace sw::sidebarwindows {
 
-class SidebarWinAccessibleContext : public VCLXAccessibleComponent
-{
-public:
-    explicit SidebarWinAccessibleContext(sw::annotation::SwAnnotationWin& 
rSidebarWin,
-                                         SwViewShell& rViewShell, const 
SwFrame* pAnchorFrame);
-
-    void ChangeAnchor(const SwFrame* pAnchorFrame);
-
-    virtual css::uno::Reference<css::accessibility::XAccessible>
-        SAL_CALL getAccessibleParent() override;
-
-    virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override;
-
-private:
-    SwViewShell& mrViewShell;
-    const SwFrame* mpAnchorFrame;
-};
-
-class SidebarWinAccessible : public VCLXWindow
+class SidebarWinAccessible
+    : public cppu::ImplInheritanceHelper<VCLXAccessibleComponent, 
css::accessibility::XAccessible>
 {
     public:
         explicit SidebarWinAccessible( sw::annotation::SwAnnotationWin& 
rSidebarWin,
@@ -58,13 +41,15 @@ class SidebarWinAccessible : public VCLXWindow
         virtual css::uno::Reference<css::accessibility::XAccessibleContext>
             SAL_CALL getAccessibleContext() override;
 
+        virtual css::uno::Reference<css::accessibility::XAccessible>
+            SAL_CALL getAccessibleParent() override;
+        virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override;
+
         void ChangeSidebarItem( const SwSidebarItem& rSidebarItem );
 
     private:
-        sw::annotation::SwAnnotationWin& mrSidebarWin;
         SwViewShell& mrViewShell;
         const SwFrame* mpAnchorFrame;
-        rtl::Reference<SidebarWinAccessibleContext> m_xAccContext;
 };
 
 } // end of namespace sw::sidebarwindows

Reply via email to