sw/source/core/access/acccontext.cxx |    8 ++++----
 sw/source/core/access/accframe.cxx   |   14 ++++----------
 sw/source/core/access/accframe.hxx   |    4 ++--
 3 files changed, 10 insertions(+), 16 deletions(-)

New commits:
commit 8ace7409d57f9ba724ea569524da9899a08b739e
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Apr 9 17:23:09 2025 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Apr 10 08:41:24 2025 +0200

    sw a11y: Pass shell by ref
    
    Pass the SwViewShell by const ref instead of pointer to
    SwAccessibleFrame::IsEditable and SwAccessibleFrame::IsOpaque.
    
    This makes clear that the param is non-null and allows to
    drop the corresponding `OSL_ENSURE`s inside the implementations.
    
    All callers are already checking for null.
    
    Change-Id: I7129febd9b8c20fef1b0772fe584ae46c9d65b01
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183946
    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 2d48a12f4067..5e4b24d10054 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -56,8 +56,8 @@ void SwAccessibleContext::InitStates()
     m_isShowingState = GetMap() && IsShowing( *(GetMap()) );
 
     SwViewShell *pVSh = GetMap()->GetShell();
-    m_isEditableState = pVSh && IsEditable( pVSh );
-    m_isOpaqueState = pVSh && IsOpaque( pVSh );
+    m_isEditableState = pVSh && IsEditable(*pVSh);
+    m_isOpaqueState = pVSh && IsOpaque(*pVSh);
     m_isDefuncState = false;
 }
 
@@ -1321,7 +1321,7 @@ void SwAccessibleContext::InvalidateStates( 
AccessibleStates _nStates )
         if( _nStates & AccessibleStates::EDITABLE )
         {
             bool bIsOldEditableState;
-            bool bIsNewEditableState = IsEditable( pVSh );
+            bool bIsNewEditableState = IsEditable(*pVSh);
             {
                 std::scoped_lock aGuard( m_Mutex );
                 bIsOldEditableState = m_isEditableState;
@@ -1335,7 +1335,7 @@ void SwAccessibleContext::InvalidateStates( 
AccessibleStates _nStates )
         if( _nStates & AccessibleStates::OPAQUE )
         {
             bool bIsOldOpaqueState;
-            bool bIsNewOpaqueState = IsOpaque( pVSh );
+            bool bIsNewOpaqueState = IsOpaque(*pVSh);
             {
                 std::scoped_lock aGuard( m_Mutex );
                 bIsOldOpaqueState = m_isOpaqueState;
diff --git a/sw/source/core/access/accframe.cxx 
b/sw/source/core/access/accframe.cxx
index 637c379825c5..cce478f09512 100644
--- a/sw/source/core/access/accframe.cxx
+++ b/sw/source/core/access/accframe.cxx
@@ -336,15 +336,13 @@ SwRect SwAccessibleFrame::GetBounds( const 
SwAccessibleMap& rAccMap,
     return aBounds;
 }
 
-bool SwAccessibleFrame::IsEditable( SwViewShell const *pVSh ) const
+bool SwAccessibleFrame::IsEditable(const SwViewShell& rViewShell) const
 {
     const SwFrame *pFrame = GetFrame();
     if( !pFrame )
         return false;
 
-    OSL_ENSURE( pVSh, "no view shell" );
-    if( pVSh && (pVSh->GetViewOptions()->IsReadonly() ||
-                 pVSh->IsPreview()) )
+    if (rViewShell.GetViewOptions()->IsReadonly() || rViewShell.IsPreview())
         return false;
 
     if( !pFrame->IsRootFrame() && pFrame->IsProtected() )
@@ -353,17 +351,13 @@ bool SwAccessibleFrame::IsEditable( SwViewShell const 
*pVSh ) const
     return true;
 }
 
-bool SwAccessibleFrame::IsOpaque( SwViewShell const *pVSh ) const
+bool SwAccessibleFrame::IsOpaque(const SwViewShell& rViewShell) const
 {
     SwAccessibleChild aFrame( GetFrame() );
     if( !aFrame.GetSwFrame() )
         return false;
 
-    OSL_ENSURE( pVSh, "no view shell" );
-    if( !pVSh )
-        return false;
-
-    const SwViewOption *pVOpt = pVSh->GetViewOptions();
+    const SwViewOption* pVOpt = rViewShell.GetViewOptions();
     do
     {
         const SwFrame *pFrame = aFrame.GetSwFrame();
diff --git a/sw/source/core/access/accframe.hxx 
b/sw/source/core/access/accframe.hxx
index c069292e11f3..4ab53cd7136a 100644
--- a/sw/source/core/access/accframe.hxx
+++ b/sw/source/core/access/accframe.hxx
@@ -72,9 +72,9 @@ protected:
                              std::list< sw::access::SwAccessibleChild >& 
rChildren,
                              bool bInPagePreview );
 
-    bool IsEditable( SwViewShell const *pVSh ) const;
+    bool IsEditable(const SwViewShell& rViewShell) const;
 
-    bool IsOpaque( SwViewShell const *pVSh ) const;
+    bool IsOpaque(const SwViewShell& rViewShell) const;
 
 public:
     bool IsShowing( const SwAccessibleMap& rAccMap,

Reply via email to