sw/inc/contentindex.hxx              |    4 ++--
 sw/source/core/bastyp/index.cxx      |    8 ++++----
 sw/source/core/crsr/crstrvl.cxx      |    5 ++---
 sw/source/core/crsr/pam.cxx          |    2 +-
 sw/source/core/crsr/swcrsr.cxx       |    4 ++--
 sw/source/core/doc/CntntIdxStore.cxx |    4 ++--
 sw/source/core/doc/doccomp.cxx       |    2 +-
 sw/source/core/doc/docfld.cxx        |    2 +-
 sw/source/core/doc/docnum.cxx        |    4 ++--
 sw/source/core/txtnode/atrfld.cxx    |    2 +-
 sw/source/core/txtnode/atrflyin.cxx  |    2 +-
 sw/source/filter/ww8/wrtw8nds.cxx    |    2 +-
 12 files changed, 20 insertions(+), 21 deletions(-)

New commits:
commit bbda36c328ddb16d32bdc1c3443893076f09a307
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Jul 25 21:04:59 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jul 26 08:58:04 2022 +0200

    SwContentIndex: move the const_cast inside
    
    instead of doing it at the call sites
    
    Change-Id: I2ae8aafc14801894fa70c17b666b7d95849c7429
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137446
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/contentindex.hxx b/sw/inc/contentindex.hxx
index 4721abd56583..00337570ecb5 100644
--- a/sw/inc/contentindex.hxx
+++ b/sw/inc/contentindex.hxx
@@ -49,7 +49,7 @@ private:
     void Remove();
 
 public:
-    explicit SwContentIndex(SwContentNode *const pContentNode, sal_Int32 const 
nIdx = 0);
+    explicit SwContentIndex(const SwContentNode * pContentNode, sal_Int32 
const nIdx = 0);
     SwContentIndex( const SwContentIndex & );
     SwContentIndex( const SwContentIndex &, short nDiff );
     ~SwContentIndex() { Remove(); }
@@ -91,7 +91,7 @@ public:
     sal_Int32 GetIndex() const { return m_nIndex; }
 
     // Assignments without creating a temporary object.
-    SwContentIndex &Assign(SwContentNode *, sal_Int32);
+    SwContentIndex &Assign(const SwContentNode *, sal_Int32);
 
     // Returns pointer to SwContentNode (for RTTI at SwContentIndexReg).
     const SwContentNode* GetContentNode() const { return m_pContentNode; }
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index b508fc78009a..cb18fbcced85 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -24,9 +24,9 @@
 
 #include <crossrefbookmark.hxx>
 
-SwContentIndex::SwContentIndex(SwContentNode *const pContentNode, sal_Int32 
const nIdx)
+SwContentIndex::SwContentIndex(const SwContentNode * pContentNode, sal_Int32 
const nIdx)
     : m_nIndex( nIdx )
-    , m_pContentNode( pContentNode )
+    , m_pContentNode( const_cast<SwContentNode*>(pContentNode) )
     , m_pNext( nullptr )
     , m_pPrev( nullptr )
     , m_pMark( nullptr )
@@ -203,12 +203,12 @@ SwContentIndex& SwContentIndex::operator=( const 
SwContentIndex& rIdx )
     return *this;
 }
 
-SwContentIndex& SwContentIndex::Assign( SwContentNode* pArr, sal_Int32 nIdx )
+SwContentIndex& SwContentIndex::Assign( const SwContentNode* pArr, sal_Int32 
nIdx )
 {
     if (pArr != m_pContentNode) // unregister!
     {
         Remove();
-        m_pContentNode = pArr;
+        m_pContentNode = const_cast<SwContentNode*>(pArr);
         m_pNext = m_pPrev = nullptr;
         Init(nIdx);
     }
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 6fe04b9022ee..aad5d9a7ef42 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -845,7 +845,7 @@ bool SwCursorShell::GotoFootnoteAnchor(const 
SwTextFootnote& rTextFootnote)
     SwCursorSaveState aSaveState(*pCursor);
 
     pCursor->GetPoint()->nNode = rTextFootnote.GetTextNode();
-    
pCursor->GetPoint()->nContent.Assign(const_cast<SwTextNode*>(&rTextFootnote.GetTextNode()),
+    pCursor->GetPoint()->nContent.Assign(&rTextFootnote.GetTextNode(),
                                          rTextFootnote.GetStart());
     bRet = !pCursor->IsSelOvr();
     if (bRet)
@@ -2176,8 +2176,7 @@ bool SwCursorShell::GotoINetAttr( const SwTextINetFormat& 
rAttr )
         SwCursorSaveState aSaveState( *pCursor );
 
         pCursor->GetPoint()->nNode = *rAttr.GetpTextNode();
-        pCursor->GetPoint()->nContent.Assign( 
const_cast<SwTextNode*>(rAttr.GetpTextNode()),
-                                            rAttr.GetStart() );
+        pCursor->GetPoint()->nContent.Assign( rAttr.GetpTextNode(), 
rAttr.GetStart() );
         bRet = !pCursor->IsSelOvr();
         if( bRet )
             
UpdateCursor(SwCursorShell::SCROLLWIN|SwCursorShell::CHKRANGE|SwCursorShell::READONLY);
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 4bd4ee78f839..157a859f1d0a 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -78,7 +78,7 @@ SwPosition::SwPosition( SwNodes& rNodes, SwNodeOffset nIndex )
 }
 
 SwPosition::SwPosition( const SwContentNode & rNode, const sal_Int32 
nContentOffset )
-    : nNode( rNode ), nContent( const_cast<SwContentNode*>(&rNode), 
nContentOffset )
+    : nNode( rNode ), nContent( &rNode, nContentOffset )
 {
 }
 
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index e9fd48b65fc4..528a9b89755f 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -2453,7 +2453,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* 
pCurrentCursor )
                 SwPosition* pPos = pCur->GetMark();
                 if( pNd != &pPos->nNode.GetNode() )
                     pPos->nNode = *pNd;
-                pPos->nContent.Assign( 
const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd)), 0 );
+                pPos->nContent.Assign( static_cast<const SwContentNode*>(pNd), 
0 );
 
                 aIdx.Assign( *pSttNd->EndOfSectionNode(), - 1 );
                 pNd = &aIdx.GetNode();
@@ -2463,7 +2463,7 @@ SwCursor* SwTableCursor::MakeBoxSels( SwCursor* 
pCurrentCursor )
                 pPos = pCur->GetPoint();
                 if (pNd && pNd != &pPos->nNode.GetNode())
                     pPos->nNode = *pNd;
-                
pPos->nContent.Assign(const_cast<SwContentNode*>(static_cast<const 
SwContentNode*>(pNd)), pNd ? static_cast<const SwContentNode*>(pNd)->Len() : 0);
+                pPos->nContent.Assign( static_cast<const SwContentNode*>(pNd), 
pNd ? static_cast<const SwContentNode*>(pNd)->Len() : 0);
 
                 aTmp.erase( aTmp.begin() + nPos );
             }
diff --git a/sw/source/core/doc/CntntIdxStore.cxx 
b/sw/source/core/doc/CntntIdxStore.cxx
index a2ff362cee03..84225d8a5f76 100644
--- a/sw/source/core/doc/CntntIdxStore.cxx
+++ b/sw/source/core/doc/CntntIdxStore.cxx
@@ -97,7 +97,7 @@ namespace
         void operator()(SwPosition& rPos, sal_Int32 nContent) const
         {
             rPos.nNode = *m_pNewContentNode;
-            
rPos.nContent.Assign(const_cast<SwContentNode*>(m_pNewContentNode), nContent + 
m_nOffset);
+            rPos.nContent.Assign(m_pNewContentNode, nContent + m_nOffset);
         };
     };
     struct LimitUpdater
@@ -112,7 +112,7 @@ namespace
             rPos.nNode = *m_pNewContentNode;
             if( nContent < m_nCorrLen )
             {
-                
rPos.nContent.Assign(const_cast<SwContentNode*>(m_pNewContentNode), std::min( 
nContent, static_cast<sal_Int32>(m_nLen) ) );
+                rPos.nContent.Assign(m_pNewContentNode, std::min( nContent, 
static_cast<sal_Int32>(m_nLen) ) );
             }
             else
             {
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index bc6e3fc0c78b..5b443e1895f2 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1921,7 +1921,7 @@ SaveMergeRedline::SaveMergeRedline( const SwNode& rDstNd,
 
     const SwPosition* pStt = rSrcRedl.Start();
     if( rDstNd.IsContentNode() )
-        aPos.nContent.Assign( const_cast<SwContentNode*>(static_cast<const 
SwContentNode*>(&rDstNd)), pStt->nContent.GetIndex() );
+        aPos.nContent.Assign( static_cast<const SwContentNode*>(&rDstNd), 
pStt->nContent.GetIndex() );
     pDestRedl = new SwRangeRedline( rSrcRedl.GetRedlineData(), aPos );
 
     if( RedlineType::Delete != pDestRedl->GetType() )
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index b32e3e05e59d..2d076f541864 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -193,7 +193,7 @@ void SetGetExpField::GetPosOfContent( SwPosition& rPos ) 
const
     if( pNd )
     {
         rPos.nNode = *pNd;
-        rPos.nContent.Assign( const_cast<SwContentNode*>(static_cast<const 
SwContentNode*>(pNd)), GetCntPosFromContent() );
+        rPos.nContent.Assign( static_cast<const SwContentNode*>(pNd), 
GetCntPosFromContent() );
     }
     else
     {
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index f9df32cd233b..45c62c2db860 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -1569,7 +1569,7 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool 
bNext,
                                     
static_cast<sal_uInt8>(pNd->GetActualListLevel()) ))
                 {
                     rPos.nNode = aIdx;
-                    rPos.nContent.Assign( const_cast<SwTextNode*>(pNd), 0 );
+                    rPos.nContent.Assign( pNd, 0 );
                     bRet = true;
                     break;
                 }
@@ -1599,7 +1599,7 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool 
bNext,
         else
         {
             rPos.nNode.Assign( *pLast );
-            rPos.nContent.Assign( const_cast<SwTextNode*>(pLast), 0 );
+            rPos.nContent.Assign( pLast, 0 );
         }
         bRet = true;
     }
diff --git a/sw/source/core/txtnode/atrfld.cxx 
b/sw/source/core/txtnode/atrfld.cxx
index de7047d19049..d07c9d6b32d2 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -236,7 +236,7 @@ void SwFormatField::SwClientNotify( const SwModify& 
rModify, const SfxHint& rHin
         SwDoc& rDoc = pPaM->GetDoc();
         const SwTextNode& rTextNode = mpTextField->GetTextNode();
         pPaM->GetPoint()->nNode = rTextNode;
-        pPaM->GetPoint()->nContent.Assign( 
const_cast<SwTextNode*>(&rTextNode), mpTextField->GetStart() );
+        pPaM->GetPoint()->nContent.Assign( &rTextNode, mpTextField->GetStart() 
);
 
         OUString const aEntry(mpField->ExpandField(rDoc.IsClipBoard(), 
pFieldHint->m_pLayout));
         pPaM->SetMark();
diff --git a/sw/source/core/txtnode/atrflyin.cxx 
b/sw/source/core/txtnode/atrflyin.cxx
index 044bbd8c0c1c..d337c5f48e81 100644
--- a/sw/source/core/txtnode/atrflyin.cxx
+++ b/sw/source/core/txtnode/atrflyin.cxx
@@ -139,7 +139,7 @@ void SwTextFlyCnt::SetAnchor( const SwTextNode *pNode )
 
     SwDoc& rDoc = const_cast<SwDoc&>(pNode->GetDoc());
 
-    SwContentIndex aIdx( const_cast<SwTextNode*>(pNode), GetStart() );
+    SwContentIndex aIdx( pNode, GetStart() );
     SwPosition aPos( *pNode->StartOfSectionNode(), aIdx );
     SwFrameFormat* pFormat = GetFlyCnt().GetFrameFormat();
     SwFormatAnchor aAnchor( pFormat->GetAnchor() );
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 328356966937..b7e9461e1574 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -238,7 +238,7 @@ SwWW8AttrIter::SwWW8AttrIter(MSWordExportBase& rWr, const 
SwTextNode& rTextNd) :
 
     if ( 
!m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() )
     {
-        SwPosition aPosition( m_rNode, SwContentIndex( 
const_cast<SwTextNode*>(&m_rNode) ) );
+        SwPosition aPosition( m_rNode, SwContentIndex( &m_rNode ) );
         m_pCurRedline = 
m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedline( aPosition, 
&m_nCurRedlinePos );
     }
 

Reply via email to