sw/source/core/inc/frmtool.hxx    |    8 ++++----
 sw/source/core/layout/frmtool.cxx |    8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 07059f3336f0daea15c0574a67bd99986eccedd3
Author:     Adam Seskunas <adamsesku...@gmail.com>
AuthorDate: Sat Dec 30 18:45:28 2023 -0800
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Wed Jan 17 14:33:51 2024 +0100

    tdf#90341 Clean up excessive const_cast'ing
    
    Make SwBorderAttrs::CalcJoinedWithNext and 
SwBorderAttrs::CalcJoinedWithPrev member
    functions const, and make m_bJoinedWithNext and m_bJoinedWithPrev mutable 
since they are cached
    values, in order to remove a const_cast in CalcJoinedWithNext and 
CalcJoinedWithPrev.
    
    Change-Id: I8d75bde49646540cfa0af09c2d6f5461c5ace6d0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161459
    Tested-by: Jenkins
    Reviewed-by: Hossein <hoss...@libreoffice.org>

diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index ffc218b5504e..f56b298938b3 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -339,8 +339,8 @@ class SwBorderAttrs final : public SwCacheObj
     mutable bool m_bCachedJoinedWithPrev : 1;
     mutable bool m_bCachedJoinedWithNext : 1;
     // Booleans indicate that borders are joined with previous/next frame.
-    bool m_bJoinedWithPrev :1;
-    bool m_bJoinedWithNext :1;
+    mutable bool m_bJoinedWithPrev :1;
+    mutable bool m_bJoinedWithNext :1;
 
     // The cached values (un-defined until calculated for the first time)
     sal_uInt16 m_nTopLine,
@@ -375,8 +375,8 @@ class SwBorderAttrs final : public SwCacheObj
     // #i25029# - If <_pPrevFrame> is set, its value is taken for testing, if
     // borders/shadow have to be joined with previous frame.
     void CalcJoinedWithPrev( const SwFrame& _rFrame,
-                              const SwFrame* _pPrevFrame );
-    void CalcJoinedWithNext( const SwFrame& _rFrame );
+                              const SwFrame* _pPrevFrame ) const;
+    void CalcJoinedWithNext( const SwFrame& _rFrame ) const;
 
     // internal helper method for CalcJoinedWithPrev and CalcJoinedWithNext
     bool JoinWithCmp( const SwFrame& _rCallerFrame,
diff --git a/sw/source/core/layout/frmtool.cxx 
b/sw/source/core/layout/frmtool.cxx
index e8fa815776e2..45bf3597674b 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -2510,7 +2510,7 @@ bool SwBorderAttrs::JoinWithCmp( const SwFrame& 
_rCallerFrame,
 // previous frame. Calculated value saved in cached value <m_bJoinedWithPrev>
 // OD 2004-02-26 #i25029# - add 2nd parameter <_pPrevFrame>
 void SwBorderAttrs::CalcJoinedWithPrev( const SwFrame& _rFrame,
-                                         const SwFrame* _pPrevFrame )
+                                         const SwFrame* _pPrevFrame ) const
 {
     // set default
     m_bJoinedWithPrev = false;
@@ -2544,7 +2544,7 @@ void SwBorderAttrs::CalcJoinedWithPrev( const SwFrame& 
_rFrame,
 
 // OD 21.05.2003 #108789# - method to determine, if borders are joined with
 // next frame. Calculated value saved in cached value <m_bJoinedWithNext>
-void SwBorderAttrs::CalcJoinedWithNext( const SwFrame& _rFrame )
+void SwBorderAttrs::CalcJoinedWithNext( const SwFrame& _rFrame ) const
 {
     // set default
     m_bJoinedWithNext = false;
@@ -2581,7 +2581,7 @@ bool SwBorderAttrs::JoinedWithPrev( const SwFrame& 
_rFrame,
     if ( !m_bCachedJoinedWithPrev || _pPrevFrame )
     {
         // OD 2004-02-26 #i25029# - pass <_pPrevFrame> as 2nd parameter
-        const_cast<SwBorderAttrs*>(this)->CalcJoinedWithPrev( _rFrame, 
_pPrevFrame );
+        CalcJoinedWithPrev( _rFrame, _pPrevFrame );
     }
 
     return m_bJoinedWithPrev;
@@ -2591,7 +2591,7 @@ bool SwBorderAttrs::JoinedWithNext( const SwFrame& 
_rFrame ) const
 {
     if ( !m_bCachedJoinedWithNext )
     {
-        const_cast<SwBorderAttrs*>(this)->CalcJoinedWithNext( _rFrame );
+        CalcJoinedWithNext( _rFrame );
     }
 
     return m_bJoinedWithNext;

Reply via email to