sw/source/core/docnode/ndsect.cxx  |   15 +++++++--------
 sw/source/core/inc/UndoSection.hxx |    2 +-
 sw/source/core/undo/unsect.cxx     |    6 +++---
 3 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 2dff7ca92cb785eb3b60556219aead77b066a780
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Feb 16 14:13:53 2024 +0600
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Fri Feb 16 17:13:18 2024 +0100

    Drop some unneeded const_cast
    
    Change-Id: I33fb2d74a0cacbf1781e670a23bd451e6ba02027
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163476
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index bd58372d38ac..31f67cfc75f6 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -300,10 +300,9 @@ SwDoc::InsertSwSection(SwPaM const& rRange, SwSectionData 
& rNewData,
         }
         else
         {
-            if( pUndoInsSect && pCNd->IsTextNode() )
-            {
-                pUndoInsSect->SaveSplitNode( 
const_cast<SwTextNode*>(static_cast<const SwTextNode*>(pCNd)), true );
-            }
+            if (pUndoInsSect)
+                if (const SwTextNode* pTextNode = pCNd->GetTextNode())
+                    pUndoInsSect->SaveSplitNode(pTextNode, true);
             getIDocumentContentOperations().SplitNode( *pPos, false );
             pNewSectNode = GetNodes().InsertTextSection(
                 pPos->GetNode(), *pFormat, rNewData, pTOXBase, nullptr);
@@ -489,9 +488,9 @@ sal_uInt16 SwDoc::IsInsRegionAvailable( const SwPaM& rRange,
 
 SwSection* SwDoc::GetCurrSection( const SwPosition& rPos )
 {
-    const SwSectionNode* pSectNd = rPos.GetNode().FindSectionNode();
+    SwSectionNode* pSectNd = rPos.GetNode().FindSectionNode();
     if( pSectNd )
-        return const_cast<SwSection*>(&pSectNd->GetSection());
+        return &pSectNd->GetSection();
     return nullptr;
 }
 
@@ -516,7 +515,7 @@ void SwDoc::DelSectionFormat( SwSectionFormat *pFormat, 
bool bDelNodes )
         if( !pFootnoteEndAtTextEnd )
             pFootnoteEndAtTextEnd = pFormat->GetItemIfSet(RES_END_AT_TXTEND);
 
-        const SwSectionNode* pSectNd;
+        SwSectionNode* pSectNd;
 
         if( GetIDocumentUndoRedo().DoesUndo() )
         {
@@ -539,7 +538,7 @@ void SwDoc::DelSectionFormat( SwSectionFormat *pFormat, 
bool bDelNodes )
                 nullptr != (pSectNd = pIdx->GetNode().GetSectionNode() ))
         {
             SwNodeIndex aUpdIdx( *pIdx );
-            getIDocumentContentOperations().DeleteSection( 
const_cast<SwNode*>(static_cast<SwNode const *>(pSectNd)) );
+            getIDocumentContentOperations().DeleteSection(pSectNd);
             if( pFootnoteEndAtTextEnd )
                 GetFootnoteIdxs().UpdateFootnote( aUpdIdx.GetNode() );
             getIDocumentState().SetModified();
diff --git a/sw/source/core/inc/UndoSection.hxx 
b/sw/source/core/inc/UndoSection.hxx
index 5be018a2e14d..fe9f22d0f82b 100644
--- a/sw/source/core/inc/UndoSection.hxx
+++ b/sw/source/core/inc/UndoSection.hxx
@@ -66,7 +66,7 @@ public:
     virtual void RepeatImpl( ::sw::RepeatContext & ) override;
 
     void SetSectNdPos(SwNodeOffset const nPos)     { m_nSectionNodePos = nPos; 
}
-    void SaveSplitNode(SwTextNode *const pTextNd, bool const bAtStart);
+    void SaveSplitNode(SwTextNode const* pTextNd, bool bAtStart);
     void SetUpdateFootnoteFlag(bool const bFlag)   { m_bUpdateFootnote = 
bFlag; }
 };
 
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index 4e75aa9adb5f..f3d6f108e20b 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -182,7 +182,7 @@ void SwUndoInsSection::RedoImpl(::sw::UndoRedoContext & 
rContext)
     SwDoc & rDoc = rContext.GetDoc();
     SwPaM & rPam( AddUndoRedoPaM(rContext) );
 
-    const SwTOXBaseSection* pUpdateTOX = nullptr;
+    SwTOXBaseSection* pUpdateTOX = nullptr;
     if (m_xTOXBase)
     {
         SwRootFrame const* pLayout(nullptr);
@@ -257,7 +257,7 @@ void SwUndoInsSection::RedoImpl(::sw::UndoRedoContext & 
rContext)
             pESh->CalcLayout();
 
         // insert page numbers
-        const_cast<SwTOXBaseSection*>(pUpdateTOX)->UpdatePageNum();
+        pUpdateTOX->UpdatePageNum();
     }
 }
 
@@ -295,7 +295,7 @@ void SwUndoInsSection::Join( SwDoc& rDoc, SwNodeOffset 
nNode )
 }
 
 void
-SwUndoInsSection::SaveSplitNode(SwTextNode *const pTextNd, bool const bAtStart)
+SwUndoInsSection::SaveSplitNode(SwTextNode const* pTextNd, bool const bAtStart)
 {
     if( pTextNd->GetpSwpHints() )
     {

Reply via email to