sw/source/core/access/accmap.cxx |   59 +++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

New commits:
commit 3089a2c9f688d32c651f9fe211c18f704a1160e2
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 14:50:05 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:31:41 2025 +0200

    sw a11y: Directly use SwFrame instead of SwAccessibleChild
    
    See
    
        Change-Id: I66cf2433f0d73ffab34e2a8a49f3903be77d6fdc
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Thu Apr 24 14:09:28 2025 +0200
    
            sw a11y: Don't use SwAccessibleChild when it's known to be a frame
    
    for background, which is a similar change elsewhere.
    
    Change-Id: Ibb7c8b508a2cdff8ee83daa8daa1be43c9853c47
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184583
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 96a53cf26e60..d5139bbed74a 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -2534,12 +2534,11 @@ void SwAccessibleMap::InvalidateRelationSet_( const 
SwFrame* pFrame,
     DBG_TESTSOLARMUTEX();
 
     // first, see if this frame is accessible, and if so, get the respective
-    SwAccessibleChild aFrameOrObj( pFrame );
-    if (!aFrameOrObj.IsAccessible(GetShell().IsPreview()))
+    if (!pFrame || !SwAccessibleChild::IsFrameAccessible(*pFrame, 
GetShell().IsPreview()))
         return;
 
     rtl::Reference < SwAccessibleContext > xAcc;
-    SwAccessibleContextMap::iterator aIter = 
maFrameMap.find(aFrameOrObj.GetSwFrame());
+    SwAccessibleContextMap::iterator aIter = maFrameMap.find(pFrame);
     if (aIter != maFrameMap.end())
     {
         xAcc = (*aIter).second;
@@ -2587,12 +2586,11 @@ void SwAccessibleMap::InvalidateParaTextSelection( 
const SwTextFrame& _rTextFram
     DBG_TESTSOLARMUTEX();
 
     // first, see if this frame is accessible, and if so, get the respective
-    SwAccessibleChild aFrameOrObj( &_rTextFrame );
-    if (!aFrameOrObj.IsAccessible(GetShell().IsPreview()))
+    if (!SwAccessibleChild::IsFrameAccessible(_rTextFrame, 
GetShell().IsPreview()))
         return;
 
     rtl::Reference < SwAccessibleContext > xAcc;
-    SwAccessibleContextMap::iterator aIter = 
maFrameMap.find(aFrameOrObj.GetSwFrame());
+    SwAccessibleContextMap::iterator aIter = maFrameMap.find(&_rTextFrame);
     if (aIter != maFrameMap.end())
     {
         xAcc = (*aIter).second;
@@ -2625,10 +2623,9 @@ sal_Int32 SwAccessibleMap::GetChildIndex( const SwFrame& 
rParentFrame,
 
     sal_Int32 nIndex( -1 );
 
-    SwAccessibleChild aFrameOrObj( &rParentFrame );
-    if (aFrameOrObj.IsAccessible(GetShell().IsPreview()))
+    if (SwAccessibleChild::IsFrameAccessible(rParentFrame, 
GetShell().IsPreview()))
     {
-        SwAccessibleContextMap::const_iterator aIter = 
maFrameMap.find(aFrameOrObj.GetSwFrame());
+        SwAccessibleContextMap::const_iterator aIter = 
maFrameMap.find(&rParentFrame);
         if (aIter != maFrameMap.end())
         {
             rtl::Reference<SwAccessibleContext> xAcc = (*aIter).second;
commit e06c771f610c5f5bac983df3ebf5e9700f74bf08
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 14:39:43 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:31:34 2025 +0200

    sw a11y: Use SwFrame directly in SwAccessibleMap::InvalidateEditableStates
    
    See
    
        Change-Id: I66cf2433f0d73ffab34e2a8a49f3903be77d6fdc
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Thu Apr 24 14:09:28 2025 +0200
    
            sw a11y: Don't use SwAccessibleChild when it's known to be a frame
    
    for background, which is a similar change elsewhere.
    
    Change-Id: I3c5293189cb82bd285e96b227abc2a1824a250cc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184582
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 24945ed5096f..96a53cf26e60 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -2507,14 +2507,13 @@ void SwAccessibleMap::SetCursorContext(
 void SwAccessibleMap::InvalidateEditableStates( const SwFrame* _pFrame )
 {
     // Start with the frame or the first upper that is accessible
-    SwAccessibleChild aFrameOrObj( _pFrame );
-    while( aFrameOrObj.GetSwFrame() &&
-            !aFrameOrObj.IsAccessible(GetShell().IsPreview()))
-        aFrameOrObj = aFrameOrObj.GetSwFrame()->GetUpper();
-    if( !aFrameOrObj.GetSwFrame() )
-        aFrameOrObj = GetShell().GetLayout();
-
-    rtl::Reference<SwAccessibleContext> xAccImpl = 
GetContextImpl(aFrameOrObj.GetSwFrame());
+    const SwFrame* pAccFrame = _pFrame;
+    while (pAccFrame && !SwAccessibleChild::IsFrameAccessible(*pAccFrame, 
GetShell().IsPreview()))
+        pAccFrame->GetUpper();
+    if (!pAccFrame)
+        pAccFrame = GetShell().GetLayout();
+
+    rtl::Reference<SwAccessibleContext> xAccImpl = GetContextImpl(pAccFrame);
     if (GetShell().ActionPend())
     {
         SwAccessibleEvent_Impl aEvent(SwAccessibleEvent_Impl::CARET_OR_STATES, 
xAccImpl.get(),
commit 87eae332940837f21698d61de98776625c6d6016
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Apr 24 14:09:28 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Fri Apr 25 07:31:27 2025 +0200

    sw a11y: Don't use SwAccessibleChild when it's known to be a frame
    
    SwAccessibleChild provides some abstraction from
    whether the underlying object of interest is an
    SwFrame, an SdrObject or a vcl::Window.
    
    However, here in SwAccessibleMap::InvalidateCursorPosition,
    the `SwAccessibleChild aFrameOrObj` is only ever used to
    "wrap" SwFrame objects, and then SwAccessibleChild::GetSwFrame
    gets called to get the underlying SwFrame from it again.
    
    As far as SwAccessibleMap::InvalidateCursorPosition
    is concerned, the only relevant thing that both,
    the SwAccessibleChild ctor and
    SwAccessibleChild::operator=(const SwFrame* pFrame)
    effectively do is to assign SwAccessibleChild::mpFrame
    that then gets returned in SwAccessibleChild::GetSwFrame.
    
    The only other SwAccessibleChild method that gets called
    is SwAccessibleChild::IsAccessible (for an OSL_ENSURE),
    but that can now be replaced by call to the static
    helper method SwAccessibleChild::IsFrameAccessible
    introduced in previous commit
    
        Change-Id: Ic5c39cd7f7cb27a027adc6eeb7c77b1b6c4b5cba
        Author: Michael Weghorn <m.wegh...@posteo.de>
        Date:   Thu Apr 24 13:58:45 2025 +0200
    
            sw a11y: Extract static helper SwAccessibleChild::IsFrameAccessible
    
    Avoid the extra level of indirection and simply use
    a pointer to SwFrame directly instead of SwAccessibleChild.
    
    This makes much more obvious that only the SwFrame* itself
    is actually of interest.
    
    Change-Id: I66cf2433f0d73ffab34e2a8a49f3903be77d6fdc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184581
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index b3a873e9b2d9..24945ed5096f 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -2281,15 +2281,15 @@ void SwAccessibleMap::InvalidateCursorPosition( const 
SwFrame *pFrame )
 {
     DBG_TESTSOLARMUTEX();
 
-    SwAccessibleChild aFrameOrObj( pFrame );
+    const SwFrame* pAccFrame = pFrame;
     bool bShapeSelected = false;
     const SwViewShell& rVSh = GetShell();
     if( auto pCSh = dynamic_cast<const SwCursorShell*>(&rVSh) )
     {
         if( pCSh->IsTableMode() )
         {
-            while( aFrameOrObj.GetSwFrame() && 
!aFrameOrObj.GetSwFrame()->IsCellFrame() )
-                aFrameOrObj = aFrameOrObj.GetSwFrame()->GetUpper();
+            while (pAccFrame && !pAccFrame->IsCellFrame())
+                pAccFrame = pAccFrame->GetUpper();
         }
         else if( auto pFESh = dynamic_cast<const SwFEShell*>(&rVSh) )
         {
@@ -2298,17 +2298,17 @@ void SwAccessibleMap::InvalidateCursorPosition( const 
SwFrame *pFrame )
             {
                 OSL_ENSURE( !pFrame || pFrame->FindFlyFrame() == pFlyFrame,
                         "cursor is not contained in fly frame" );
-                aFrameOrObj = pFlyFrame;
+                pAccFrame = pFlyFrame;
             }
             else if( pFESh->GetSelectedObjCount() > 0 )
             {
                 bShapeSelected = true;
-                aFrameOrObj = static_cast<const SwFrame *>( nullptr );
+                pAccFrame = nullptr;
             }
         }
     }
 
-    OSL_ENSURE(bShapeSelected || 
aFrameOrObj.IsAccessible(GetShell().IsPreview()),
+    OSL_ENSURE(bShapeSelected || (pAccFrame && 
SwAccessibleChild::IsFrameAccessible(*pAccFrame, GetShell().IsPreview())),
             "frame is not accessible" );
 
     rtl::Reference <SwAccessibleContext> xOldAcc = mxCursorContext;
@@ -2318,25 +2318,25 @@ void SwAccessibleMap::InvalidateCursorPosition( const 
SwFrame *pFrame )
     mbShapeSelected = bShapeSelected;
 
     rtl::Reference <SwAccessibleContext> xAcc;
-    if (aFrameOrObj.GetSwFrame())
+    if (pAccFrame)
     {
-        SwAccessibleContextMap::iterator aIter = 
maFrameMap.find(aFrameOrObj.GetSwFrame());
+        SwAccessibleContextMap::iterator aIter = maFrameMap.find(pAccFrame);
         if (aIter != maFrameMap.end())
             xAcc = (*aIter).second;
         else
         {
             SwRect rcEmpty;
-            const SwTabFrame* pTabFrame = 
aFrameOrObj.GetSwFrame()->FindTabFrame();
+            const SwTabFrame* pTabFrame = pAccFrame->FindTabFrame();
             if (pTabFrame)
             {
                 InvalidatePosOrSize(pTabFrame, nullptr, nullptr, rcEmpty);
             }
             else
             {
-                InvalidatePosOrSize(aFrameOrObj.GetSwFrame(), nullptr, 
nullptr, rcEmpty);
+                InvalidatePosOrSize(pAccFrame, nullptr, nullptr, rcEmpty);
             }
 
-            aIter = maFrameMap.find(aFrameOrObj.GetSwFrame());
+            aIter = maFrameMap.find(pAccFrame);
             if (aIter != maFrameMap.end())
             {
                 xAcc = (*aIter).second;
@@ -2356,10 +2356,9 @@ void SwAccessibleMap::InvalidateCursorPosition( const 
SwFrame *pFrame )
         // table, it's the best choice, because using it avoids
         // an unnecessary cursor invalidation cycle when creating
         // a new object for the current cell.
-        if( aFrameOrObj.GetSwFrame()->IsCellFrame() )
+        if (pAccFrame->IsCellFrame())
         {
-            if( xOldAcc.is() &&
-                AreInSameTable( xOldAcc, aFrameOrObj.GetSwFrame() ) )
+            if (xOldAcc.is() && AreInSameTable(xOldAcc, pAccFrame))
             {
                 if( xAcc.is() )
                     xOldAcc = xAcc; // avoid extra invalidation
@@ -2367,7 +2366,7 @@ void SwAccessibleMap::InvalidateCursorPosition( const 
SwFrame *pFrame )
                     xAcc = xOldAcc; // make sure at least one
             }
             if( !xAcc.is() )
-                xAcc = GetContextImpl( aFrameOrObj.GetSwFrame() );
+                xAcc = GetContextImpl(pAccFrame);
         }
     }
     else if (bShapeSelected)

Reply via email to