sc/source/ui/Accessibility/AccessibleDocument.cxx |   38 +++++++++++-----------
 sw/inc/accmap.hxx                                 |    2 -
 sw/source/core/access/acccontext.cxx              |    8 +---
 sw/source/core/access/accmap.cxx                  |   20 ++++-------
 4 files changed, 31 insertions(+), 37 deletions(-)

New commits:
commit 9825c183c1a0afdb9800bbde78ee1cd0d3b78f17
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Apr 14 13:38:47 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Apr 15 08:07:23 2025 +0200

    sw a11y: Fire focus event for scrolled in shape
    
    Setting the AccessibleEventObject::Source to
    a Reference of the AccessibleShape after
    checking it has the focused state, but then
    sending the event using
    SwAccessibleContext::FireAccessibleEvent, i.e.
    to the accessible listeners of the SwAccessibleContext,
    not those of the shape, seems odd.
    
    Instead, notify the listeners of the AccessibleShape
    that has the FOCUSED state set.
    
    Change-Id: Ic9e828c79d0fd99dcf50ba57f9374c427ae2d39a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184149
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/source/core/access/acccontext.cxx 
b/sw/source/core/access/acccontext.cxx
index 5e4b24d10054..d33b6e786085 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -1052,12 +1052,8 @@ void SwAccessibleContext::ScrolledInShape( 
::accessibility::AccessibleShape *pAc
     vcl::Window *pWin = GetWindow();
     if( pWin && pWin->HasFocus() )
     {
-        AccessibleEventObject aStateChangedEvent;
-        aStateChangedEvent.EventId = AccessibleEventId::STATE_CHANGED;
-        aStateChangedEvent.NewValue <<= AccessibleStateType::FOCUSED;
-        aStateChangedEvent.Source = xAcc;
-
-        FireAccessibleEvent( aStateChangedEvent );
+        pAccImpl->CommitChange(AccessibleEventId::STATE_CHANGED,
+                               uno::Any(AccessibleStateType::FOCUSED), 
uno::Any(), -1);
     }
 }
 
commit 7d4da4426687a63b1b4ab2213a161bb0a47bda20
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Apr 14 13:26:56 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Apr 15 08:07:17 2025 +0200

    sc a11y: Use concrete rtl::Reference<AccessibleShape>
    
    ... for the return type of some ScAccessibleDocument methods
    and local vars instead of uno::Reference<XAccessible>.
    
    Drop a static_cast in ScAccessibleDocument::Notify
    that is no more necessary now that that type is part
    of the signature.
    
    Change-Id: Ic4e4857b6372581df80442b8669693af06d86a07
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184148
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx 
b/sc/source/ui/Accessibility/AccessibleDocument.cxx
index e58600ecfe8d..740df71d777d 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -226,8 +226,8 @@ public:
     void SetDrawBroadcaster();
 
     sal_Int32 GetCount() const;
-    uno::Reference< XAccessible > Get(const ScAccessibleShapeData* pData) 
const;
-    uno::Reference< XAccessible > Get(sal_Int32 nIndex) const;
+    rtl::Reference<::accessibility::AccessibleShape> Get(const 
ScAccessibleShapeData* pData) const;
+    rtl::Reference<::accessibility::AccessibleShape> Get(sal_Int32 nIndex) 
const;
     uno::Reference< XAccessible > GetAt(const awt::Point& rPoint) const;
 
     // gets the index of the shape starting on 0 (without the index of the 
table)
@@ -241,7 +241,8 @@ public:
     void DeselectAll(); // deselect also the table
     void SelectAll();
     sal_Int32 GetSelectedCount() const;
-    uno::Reference< XAccessible > GetSelected(sal_Int32 nSelectedChildIndex, 
bool bTabSelected) const;
+    rtl::Reference<::accessibility::AccessibleShape> GetSelected(sal_Int32 
nSelectedChildIndex,
+                                                                 bool 
bTabSelected) const;
     void Deselect(sal_Int32 nChildIndex);
 
     SdrPage* GetDrawPage() const;
@@ -502,7 +503,8 @@ sal_Int32 ScChildrenShapes::GetCount() const
     return maZOrderedShapes.size();
 }
 
-uno::Reference< XAccessible > ScChildrenShapes::Get(const 
ScAccessibleShapeData* pData) const
+rtl::Reference<::accessibility::AccessibleShape>
+ScChildrenShapes::Get(const ScAccessibleShapeData* pData) const
 {
     if (!pData)
         return nullptr;
@@ -526,7 +528,7 @@ uno::Reference< XAccessible > ScChildrenShapes::Get(const 
ScAccessibleShapeData*
     return pData->pAccShape;
  }
 
-uno::Reference< XAccessible > ScChildrenShapes::Get(sal_Int32 nIndex) const
+rtl::Reference<::accessibility::AccessibleShape> 
ScChildrenShapes::Get(sal_Int32 nIndex) const
 {
     if (maZOrderedShapes.size() <= 1)
         GetCount(); // fill list with filtered shapes (no internal shapes)
@@ -786,9 +788,10 @@ sal_Int32 ScChildrenShapes::GetSelectedCount() const
     return aShapes.size();
 }
 
-uno::Reference< XAccessible > ScChildrenShapes::GetSelected(sal_Int32 
nSelectedChildIndex, bool bTabSelected) const
+rtl::Reference<::accessibility::AccessibleShape>
+ScChildrenShapes::GetSelected(sal_Int32 nSelectedChildIndex, bool 
bTabSelected) const
 {
-    uno::Reference< XAccessible > xAccessible;
+    rtl::Reference<::accessibility::AccessibleShape> xAccessible;
 
     if (maZOrderedShapes.size() <= 1)
         GetCount(); // fill list with shapes
@@ -1203,7 +1206,7 @@ void ScChildrenShapes::AddShape(const 
uno::Reference<drawing::XShape>& xShape, b
     {
         // new child - event
         mpAccessibleDocument->CommitChange(AccessibleEventId::CHILD, 
uno::Any(),
-                                           uno::Any(Get(pShape)));
+                                           
uno::Any(uno::Reference<XAccessible>(Get(pShape))));
     }
 }
 
@@ -1219,15 +1222,16 @@ void ScChildrenShapes::RemoveShape(const 
uno::Reference<drawing::XShape>& xShape
     {
         if (mpAccessibleDocument)
         {
-            uno::Reference<XAccessible> xOldAccessible (Get(*aItr));
+            rtl::Reference<::accessibility::AccessibleShape> 
xOldAccessible(Get(*aItr));
 
             delete *aItr;
             maShapesMap.erase((*aItr)->xShape);
             maZOrderedShapes.erase(aItr);
 
             // child is gone - event
-            mpAccessibleDocument->CommitChange(AccessibleEventId::CHILD, 
uno::Any(xOldAccessible),
-                                               uno::Any());
+            mpAccessibleDocument->CommitChange(
+                AccessibleEventId::CHILD, 
uno::Any(uno::Reference<XAccessible>(xOldAccessible)),
+                uno::Any());
         }
         else
         {
@@ -1417,20 +1421,18 @@ void ScAccessibleDocument::Notify( SfxBroadcaster& rBC, 
const SfxHint& rHint )
         auto pFocusGotHint = static_cast<const 
ScAccGridWinFocusGotHint*>(&rHint);
         if (pFocusGotHint->GetNewGridWin() == meSplitPos)
         {
-            uno::Reference<XAccessible> xAccessible;
+            rtl::Reference<::accessibility::AccessibleShape> xAccShape;
             if (mpChildrenShapes)
             {
                 bool bTabMarked(IsTableSelected());
-                xAccessible = mpChildrenShapes->GetSelected(0, bTabMarked);
+                xAccShape = mpChildrenShapes->GetSelected(0, bTabMarked);
             }
-            if( xAccessible.is() )
+            if (xAccShape.is())
             {
                 uno::Any aNewValue;
                 aNewValue<<=AccessibleStateType::FOCUSED;
-                static_cast< ::accessibility::AccessibleShape* 
>(xAccessible.get())->
-                    CommitChange(AccessibleEventId::STATE_CHANGED,
-                                aNewValue,
-                                uno::Any(), -1 );
+                xAccShape->CommitChange(AccessibleEventId::STATE_CHANGED, 
aNewValue, uno::Any(),
+                                        -1);
             }
             else
             {
commit 7806538a33ac8da9c5027193b9a47d8a760f8044
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Mon Apr 14 11:59:14 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Apr 15 08:07:11 2025 +0200

    sw a11y: Pass concrete type to SwAccessibleMap::InvalidateCursorPosition
    
    ... instead of passing a Reference<XAccessible> and
    unconditionally casting that to SwAccessibleContext.
    
    Change-Id: I0a41ee0296b08870db241e1971919fe166aaaec8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184140
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/inc/accmap.hxx b/sw/inc/accmap.hxx
index bf9969e37461..e782acc2ba2b 100644
--- a/sw/inc/accmap.hxx
+++ b/sw/inc/accmap.hxx
@@ -115,7 +115,7 @@ class SwAccessibleMap final : public 
::accessibility::IAccessibleViewForwarder,
 
     void AppendEvent( const SwAccessibleEvent_Impl& rEvent );
 
-    void InvalidateCursorPosition( const 
css::uno::Reference<css::accessibility::XAccessible>& rAcc );
+    void InvalidateCursorPosition(const rtl::Reference<SwAccessibleContext>& 
rxAcc);
     void DoInvalidateShapeSelection(bool bInvalidateFocusMode = false);
 
     void InvalidateShapeSelection();
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 67f8f0681370..678e55c7f3d3 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1084,19 +1084,15 @@ void SwAccessibleMap::AppendEvent( const 
SwAccessibleEvent_Impl& rEvent )
     }
 }
 
-void SwAccessibleMap::InvalidateCursorPosition(
-        const uno::Reference< XAccessible >& rAcc )
+void SwAccessibleMap::InvalidateCursorPosition(const 
rtl::Reference<SwAccessibleContext>& rxAcc)
 {
-    SwAccessibleContext *pAccImpl =
-        static_cast< SwAccessibleContext *>( rAcc.get() );
-    assert(pAccImpl);
-    assert(pAccImpl->GetFrame());
+    assert(rxAcc.is());
+    assert(rxAcc->GetFrame());
     if( GetShell()->ActionPend() )
     {
-        SwAccessibleEvent_Impl aEvent( SwAccessibleEvent_Impl::CARET_OR_STATES,
-                                       pAccImpl,
-                                       SwAccessibleChild(pAccImpl->GetFrame()),
-                                       AccessibleStates::CARET );
+        SwAccessibleEvent_Impl aEvent(SwAccessibleEvent_Impl::CARET_OR_STATES, 
rxAcc.get(),
+                                      SwAccessibleChild(rxAcc->GetFrame()),
+                                      AccessibleStates::CARET);
         AppendEvent( aEvent );
     }
     else
@@ -1106,8 +1102,8 @@ void SwAccessibleMap::InvalidateCursorPosition(
         // been disposed because it moved out of the visible area.
         // Setting the cursor for such frames is useless and even
         // causes asserts.
-        if( pAccImpl->GetFrame() )
-            pAccImpl->InvalidateCursorPos();
+        if (rxAcc->GetFrame())
+            rxAcc->InvalidateCursorPos();
     }
 }
 

Reply via email to