sw/inc/index.hxx                                        |   22 ++--
 sw/inc/node.hxx                                         |    6 +
 sw/qa/core/macros-test.cxx                              |    2 
 sw/source/core/bastyp/index.cxx                         |   72 ++++++++--------
 sw/source/core/crsr/crsrsh.cxx                          |    2 
 sw/source/core/crsr/pam.cxx                             |   16 +--
 sw/source/core/doc/DocumentContentOperationsManager.cxx |    4 
 sw/source/core/doc/DocumentRedlineManager.cxx           |    2 
 sw/source/core/doc/dbgoutsw.cxx                         |    2 
 sw/source/core/doc/doccorr.cxx                          |    2 
 sw/source/core/doc/docedt.cxx                           |   17 ++-
 sw/source/core/docnode/node.cxx                         |   20 ++++
 sw/source/core/edit/eddel.cxx                           |    4 
 sw/source/core/layout/fly.cxx                           |    2 
 sw/source/core/txtnode/ndtxt.cxx                        |   16 +++
 sw/source/core/undo/undobj.cxx                          |    2 
 sw/source/core/undo/unins.cxx                           |    4 
 sw/source/filter/xml/swxml.cxx                          |    4 
 18 files changed, 121 insertions(+), 78 deletions(-)

New commits:
commit 6cfa03bbfb7397c34fe2ea605a4ef573ae92e4ea
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Jul 25 11:24:37 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Jul 25 12:33:51 2022 +0200

    SwIndex/SwIndexReg is only used to deal with SwContentNodes
    
    so make that apparent in the type system and naming, instead of
    implicit.
    
    Which requires adding a small helper class for the one place we were
    instantiating an SwIndexReg by itselg
    
    Change-Id: I74db37239aed0005e5a2a01916635fa93de638f4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137403
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx
index 0e5e89125d92..22b9edf14e9d 100644
--- a/sw/inc/index.hxx
+++ b/sw/inc/index.hxx
@@ -24,19 +24,20 @@
 
 #include <iostream>
 
+class SwContentNode;
 class SwIndexReg;
 struct SwPosition;
 
 namespace sw::mark { class IMark; }
 
-/// Marks a character position inside a document model node.
+/// Marks a character position inside a document model content node 
(SwContentNode)
 class SAL_WARN_UNUSED SW_DLLPUBLIC SwIndex
 {
 private:
     friend class SwIndexReg;
 
     sal_Int32 m_nIndex;
-    SwIndexReg * m_pIndexReg;
+    SwContentNode * m_pContentNode;
     // doubly linked list of Indexes registered at m_pIndexReg
     SwIndex * m_pNext;
     SwIndex * m_pPrev;
@@ -49,7 +50,7 @@ private:
     void Remove();
 
 public:
-    explicit SwIndex(SwIndexReg *const pReg, sal_Int32 const nIdx = 0);
+    explicit SwIndex(SwContentNode *const pContentNode, sal_Int32 const nIdx = 
0);
     SwIndex( const SwIndex & );
     SwIndex( const SwIndex &, short nDiff );
     ~SwIndex() { Remove(); }
@@ -79,22 +80,22 @@ public:
     bool operator==( const SwIndex& rSwIndex ) const
     {
         return (m_nIndex    == rSwIndex.m_nIndex)
-            && (m_pIndexReg == rSwIndex.m_pIndexReg);
+            && (m_pContentNode == rSwIndex.m_pContentNode);
     }
 
     bool operator!=( const SwIndex& rSwIndex ) const
     {
         return (m_nIndex    != rSwIndex.m_nIndex)
-            || (m_pIndexReg != rSwIndex.m_pIndexReg);
+            || (m_pContentNode != rSwIndex.m_pContentNode);
     }
 
     sal_Int32 GetIndex() const { return m_nIndex; }
 
     // Assignments without creating a temporary object.
-    SwIndex &Assign(SwIndexReg *, sal_Int32);
+    SwIndex &Assign(SwContentNode *, sal_Int32);
 
-    // Returns pointer to IndexArray (for RTTI at SwIndexReg).
-    const SwIndexReg* GetIdxReg() const { return m_pIndexReg; }
+    // Returns pointer to SwContentNode (for RTTI at SwIndexReg).
+    const SwContentNode* GetContentNode() const { return m_pContentNode; }
     const SwIndex* GetNext() const { return m_pNext; }
 
     const sw::mark::IMark* GetMark() const { return m_pMark; }
@@ -103,6 +104,7 @@ public:
 
 SW_DLLPUBLIC std::ostream& operator <<(std::ostream& s, const SwIndex& index);
 
+/// Helper base class for SwContentNode to manage the list of attached SwIndex
 class SAL_WARN_UNUSED SwIndexReg
 {
     friend class SwIndex;
@@ -117,11 +119,11 @@ protected:
 
     bool HasAnyIndex() const { return nullptr != m_pFirst; }
 
-public:
     SwIndexReg();
+public:
     virtual ~SwIndexReg();
 
-    void MoveTo( SwIndexReg& rArr );
+    void MoveTo( SwContentNode& rArr );
     const SwIndex* GetFirstIndex() const { return m_pFirst; }
 };
 
diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index cf9ebc80bee7..e447c9132d99 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -113,6 +113,9 @@ private:
 protected:
     SwStartNode* m_pStartOfSection;
 
+    /// only used by SwContentNodeTmp in SwTextNode::Update
+    SwNode();
+
     SwNode( const SwNodeIndex &rWhere, const SwNodeType nNodeId );
 
     /// for the initial StartNode
@@ -365,6 +368,9 @@ class SW_DLLPUBLIC SwContentNode: public 
sw::BroadcastingModify, public SwNode,
     mutable bool mbSetModifyAtAttr;
 
 protected:
+    /// only used by SwContentNodeTmp in SwTextNode::Update
+    SwContentNode();
+
     SwContentNode( const SwNodeIndex &rWhere, const SwNodeType nNodeType,
                 SwFormatColl *pFormatColl );
     /** the = 0 forces the class to be an abstract base class, but the dtor 
can be still called
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 0bc278d8d688..ec151596e328 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -199,7 +199,7 @@ void SwMacrosTest::testBookmarkDeleteAndJoin()
     for (IDocumentMarkAccess::const_iterator_t i = rIDMA.getAllMarksBegin(); i 
!= rIDMA.getAllMarksEnd(); ++i)
     {
         // problem was that the nContent was pointing at deleted node
-        CPPUNIT_ASSERT_EQUAL(static_cast<const 
SwContentNode*>((*i)->GetMarkStart().nContent.GetIdxReg()),
+        CPPUNIT_ASSERT_EQUAL((*i)->GetMarkStart().nContent.GetContentNode(),
             static_cast<const 
SwContentNode*>((*i)->GetMarkStart().nNode.GetNode().GetContentNode()));
     }
 }
diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx
index 3fa1eaec186e..828e658dd6d7 100644
--- a/sw/source/core/bastyp/index.cxx
+++ b/sw/source/core/bastyp/index.cxx
@@ -24,9 +24,9 @@
 
 #include <crossrefbookmark.hxx>
 
-SwIndex::SwIndex(SwIndexReg *const pReg, sal_Int32 const nIdx)
+SwIndex::SwIndex(SwContentNode *const pContentNode, sal_Int32 const nIdx)
     : m_nIndex( nIdx )
-    , m_pIndexReg( pReg )
+    , m_pContentNode( pContentNode )
     , m_pNext( nullptr )
     , m_pPrev( nullptr )
     , m_pMark( nullptr )
@@ -35,7 +35,7 @@ SwIndex::SwIndex(SwIndexReg *const pReg, sal_Int32 const nIdx)
 }
 
 SwIndex::SwIndex( const SwIndex& rIdx, short nDiff )
-    : m_pIndexReg( rIdx.m_pIndexReg )
+    : m_pContentNode( rIdx.m_pContentNode )
     , m_pNext( nullptr )
     , m_pPrev( nullptr )
     , m_pMark( nullptr )
@@ -45,7 +45,7 @@ SwIndex::SwIndex( const SwIndex& rIdx, short nDiff )
 
 SwIndex::SwIndex( const SwIndex& rIdx )
     : m_nIndex( rIdx.m_nIndex )
-    , m_pIndexReg( rIdx.m_pIndexReg )
+    , m_pContentNode( rIdx.m_pContentNode )
     , m_pNext( nullptr )
     , m_pPrev( nullptr )
     , m_pMark( nullptr )
@@ -55,31 +55,31 @@ SwIndex::SwIndex( const SwIndex& rIdx )
 
 void SwIndex::Init(sal_Int32 const nIdx)
 {
-    if (!m_pIndexReg)
+    if (!m_pContentNode)
     {
         m_nIndex = 0; // always 0 if no IndexReg
     }
-    else if (!m_pIndexReg->m_pFirst) // first Index?
+    else if (!m_pContentNode->m_pFirst) // first Index?
     {
-        assert(!m_pIndexReg->m_pLast);
-        m_pIndexReg->m_pFirst = m_pIndexReg->m_pLast = this;
+        assert(!m_pContentNode->m_pLast);
+        m_pContentNode->m_pFirst = m_pContentNode->m_pLast = this;
         m_nIndex = nIdx;
     }
-    else if (nIdx > ((m_pIndexReg->m_pLast->m_nIndex
-                        - m_pIndexReg->m_pFirst->m_nIndex) / 2))
+    else if (nIdx > ((m_pContentNode->m_pLast->m_nIndex
+                        - m_pContentNode->m_pFirst->m_nIndex) / 2))
     {
-        ChgValue( *m_pIndexReg->m_pLast, nIdx );
+        ChgValue( *m_pContentNode->m_pLast, nIdx );
     }
     else
     {
-        ChgValue( *m_pIndexReg->m_pFirst, nIdx );
+        ChgValue( *m_pContentNode->m_pFirst, nIdx );
     }
 }
 
 SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, sal_Int32 nNewValue )
 {
-    assert(m_pIndexReg == rIdx.m_pIndexReg);
-    if (!m_pIndexReg)
+    assert(m_pContentNode == rIdx.m_pContentNode);
+    if (!m_pContentNode)
     {
         m_nIndex = 0;
         return *this; // no IndexReg => no list to sort into; m_nIndex is 0
@@ -105,7 +105,7 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, sal_Int32 
nNewValue )
             if (m_pPrev)
                 m_pPrev->m_pNext = this;
             else
-                m_pIndexReg->m_pFirst = this;
+                m_pContentNode->m_pFirst = this;
             pFnd->m_pPrev = this;
         }
     }
@@ -129,7 +129,7 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, sal_Int32 
nNewValue )
             if (m_pNext)
                 m_pNext->m_pPrev = this;
             else
-                m_pIndexReg->m_pLast = this;
+                m_pContentNode->m_pLast = this;
             pFnd->m_pNext = this;
         }
     }
@@ -143,15 +143,15 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, 
sal_Int32 nNewValue )
         m_pPrev->m_pNext = this;
 
         if (!m_pNext) // last in the list
-            m_pIndexReg->m_pLast = this;
+            m_pContentNode->m_pLast = this;
         else
             m_pNext->m_pPrev = this;
     }
 
-    if (m_pIndexReg->m_pFirst == m_pNext)
-        m_pIndexReg->m_pFirst = this;
-    if (m_pIndexReg->m_pLast == m_pPrev)
-        m_pIndexReg->m_pLast = this;
+    if (m_pContentNode->m_pFirst == m_pNext)
+        m_pContentNode->m_pFirst = this;
+    if (m_pContentNode->m_pLast == m_pPrev)
+        m_pContentNode->m_pLast = this;
 
     m_nIndex = nNewValue;
 
@@ -160,7 +160,7 @@ SwIndex& SwIndex::ChgValue( const SwIndex& rIdx, sal_Int32 
nNewValue )
 
 void SwIndex::Remove()
 {
-    if (!m_pIndexReg)
+    if (!m_pContentNode)
     {
         assert(!m_pPrev && !m_pNext);
         return;
@@ -170,28 +170,28 @@ void SwIndex::Remove()
     {
         m_pPrev->m_pNext = m_pNext;
     }
-    else if (m_pIndexReg->m_pFirst == this)
+    else if (m_pContentNode->m_pFirst == this)
     {
-        m_pIndexReg->m_pFirst = m_pNext;
+        m_pContentNode->m_pFirst = m_pNext;
     }
 
     if (m_pNext)
     {
         m_pNext->m_pPrev = m_pPrev;
     }
-    else if (m_pIndexReg->m_pLast == this)
+    else if (m_pContentNode->m_pLast == this)
     {
-        m_pIndexReg->m_pLast = m_pPrev;
+        m_pContentNode->m_pLast = m_pPrev;
     }
 }
 
 SwIndex& SwIndex::operator=( const SwIndex& rIdx )
 {
     bool bEqual;
-    if (rIdx.m_pIndexReg != m_pIndexReg) // unregister!
+    if (rIdx.m_pContentNode != m_pContentNode) // unregister!
     {
         Remove();
-        m_pIndexReg = rIdx.m_pIndexReg;
+        m_pContentNode = rIdx.m_pContentNode;
         m_pNext = m_pPrev = nullptr;
         bEqual = false;
     }
@@ -203,12 +203,12 @@ SwIndex& SwIndex::operator=( const SwIndex& rIdx )
     return *this;
 }
 
-SwIndex& SwIndex::Assign( SwIndexReg* pArr, sal_Int32 nIdx )
+SwIndex& SwIndex::Assign( SwContentNode* pArr, sal_Int32 nIdx )
 {
-    if (pArr != m_pIndexReg) // unregister!
+    if (pArr != m_pContentNode) // unregister!
     {
         Remove();
-        m_pIndexReg = pArr;
+        m_pContentNode = pArr;
         m_pNext = m_pPrev = nullptr;
         Init(nIdx);
     }
@@ -284,7 +284,7 @@ void SwIndexReg::Update(
     }
 }
 
-void SwIndexReg::MoveTo( SwIndexReg& rArr )
+void SwIndexReg::MoveTo( SwContentNode& rArr )
 {
     if (!(this != &rArr && m_pFirst))
         return;
@@ -348,28 +348,28 @@ sal_Int32 SwIndex::operator-=( sal_Int32 const nVal )
 bool SwIndex::operator< ( const SwIndex & rIndex ) const
 {
     // Attempt to compare indices into different arrays
-    assert(m_pIndexReg == rIndex.m_pIndexReg);
+    assert(m_pContentNode == rIndex.m_pContentNode);
     return m_nIndex < rIndex.m_nIndex;
 }
 
 bool SwIndex::operator<=( const SwIndex & rIndex ) const
 {
     // Attempt to compare indices into different arrays
-    assert(m_pIndexReg == rIndex.m_pIndexReg);
+    assert(m_pContentNode == rIndex.m_pContentNode);
     return m_nIndex <= rIndex.m_nIndex;
 }
 
 bool SwIndex::operator> ( const SwIndex & rIndex ) const
 {
     // Attempt to compare indices into different arrays
-    assert(m_pIndexReg == rIndex.m_pIndexReg);
+    assert(m_pContentNode == rIndex.m_pContentNode);
     return m_nIndex > rIndex.m_nIndex;
 }
 
 bool SwIndex::operator>=( const SwIndex & rIndex ) const
 {
     // Attempt to compare indices into different arrays
-    assert(m_pIndexReg == rIndex.m_pIndexReg);
+    assert(m_pContentNode == rIndex.m_pContentNode);
     return m_nIndex >= rIndex.m_nIndex;
 }
 
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index ebb15bec6107..3c008b87dea5 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -3593,7 +3593,7 @@ static const SwStartNode* lcl_NodeContext( const SwNode& 
rNode )
 bool sw_PosOk(const SwPosition & aPos)
 {
     return nullptr != aPos.nNode.GetNode().GetContentNode() &&
-           aPos.nContent.GetIdxReg();
+           aPos.nContent.GetContentNode();
 }
 
 /**
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 16c7e6ec21d8..cc21c71618c7 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -84,8 +84,8 @@ bool SwPosition::operator<(const SwPosition &rPos) const
     {
         // note that positions with text node but no SwIndex registered are
         // created for text frames anchored at para (see SwXFrame::getAnchor())
-        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
-        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        SwContentNode const*const pThisReg(nContent.GetContentNode());
+        SwContentNode const*const pOtherReg(rPos.nContent.GetContentNode());
         if (pThisReg && pOtherReg)
         {
             return (nContent < rPos.nContent);
@@ -105,8 +105,8 @@ bool SwPosition::operator>(const SwPosition &rPos) const
     {
         // note that positions with text node but no SwIndex registered are
         // created for text frames anchored at para (see SwXFrame::getAnchor())
-        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
-        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        SwContentNode const*const pThisReg(nContent.GetContentNode());
+        SwContentNode const*const pOtherReg(rPos.nContent.GetContentNode());
         if (pThisReg && pOtherReg)
         {
             return (nContent > rPos.nContent);
@@ -126,8 +126,8 @@ bool SwPosition::operator<=(const SwPosition &rPos) const
     {
         // note that positions with text node but no SwIndex registered are
         // created for text frames anchored at para (see SwXFrame::getAnchor())
-        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
-        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        SwContentNode const*const pThisReg(nContent.GetContentNode());
+        SwContentNode const*const pOtherReg(rPos.nContent.GetContentNode());
         if (pThisReg && pOtherReg)
         {
             return (nContent <= rPos.nContent);
@@ -147,8 +147,8 @@ bool SwPosition::operator>=(const SwPosition &rPos) const
     {
         // note that positions with text node but no SwIndex registered are
         // created for text frames anchored at para (see SwXFrame::getAnchor())
-        SwIndexReg const*const pThisReg(nContent.GetIdxReg());
-        SwIndexReg const*const pOtherReg(rPos.nContent.GetIdxReg());
+        SwContentNode const*const pThisReg(nContent.GetContentNode());
+        SwContentNode const*const pOtherReg(rPos.nContent.GetContentNode());
         if (pThisReg && pOtherReg)
         {
             return (nContent >= rPos.nContent);
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 962cea631e5f..5e23a6dc81f0 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2425,7 +2425,7 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& 
rPaM, SwPosition& rPos,
         SwTextNode * pOrigNode = pTNd;
         assert(*aSavePam.GetPoint() == *aSavePam.GetMark() &&
                *aSavePam.GetPoint() == rPos);
-        assert(aSavePam.GetPoint()->nContent.GetIdxReg() == pOrigNode);
+        assert(aSavePam.GetPoint()->nContent.GetContentNode() == pOrigNode);
         assert(aSavePam.GetPoint()->nNode == rPos.nNode.GetIndex());
         assert(rPos.nNode.GetIndex() == pOrigNode->GetIndex());
 
@@ -2451,7 +2451,7 @@ bool DocumentContentOperationsManager::MoveRange( SwPaM& 
rPaM, SwPosition& rPos,
         //truncated node
         assert(*aSavePam.GetPoint() == *aSavePam.GetMark() &&
                *aSavePam.GetPoint() == rPos);
-        assert(aSavePam.GetPoint()->nContent.GetIdxReg() == pOrigNode);
+        assert(aSavePam.GetPoint()->nContent.GetContentNode() == pOrigNode);
         assert(aSavePam.GetPoint()->nNode == rPos.nNode.GetIndex());
         assert(rPos.nNode.GetIndex() == pOrigNode->GetIndex());
         aSavePam.GetPoint()->nContent.Assign(pOrigNode, 0);
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index a50de37c9738..4a4a43088f0b 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -54,7 +54,7 @@ using namespace com::sun::star;
         void lcl_CheckPosition( const SwPosition* pPos )
         {
             assert(dynamic_cast<SwIndexReg*>(&pPos->nNode.GetNode())
-                    == pPos->nContent.GetIdxReg());
+                    == pPos->nContent.GetContentNode());
 
             SwTextNode* pTextNode = pPos->nNode.GetNode().GetTextNode();
             if( pTextNode == nullptr )
diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
index 20d6828f81a0..d8c870b24bb1 100644
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -321,7 +321,7 @@ static OUString lcl_dbg_out(const SwPosition & rPos)
         ", " +
         OUString::number(rPos.nContent.GetIndex()) +
         ": " +
-        
OUString::number(reinterpret_cast<sal_IntPtr>(rPos.nContent.GetIdxReg()), 16) +
+        
OUString::number(reinterpret_cast<sal_IntPtr>(rPos.nContent.GetContentNode()), 
16) +
         " )";
 
     return aStr;
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 0014bb814f93..b5b71ae6b9ae 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -77,7 +77,7 @@ namespace
             {
                 pPam->GetBound(bool(nb)).nNode = rNewPos.nNode;
                 pPam->GetBound(bool(nb)).nContent.Assign(
-                    const_cast<SwIndexReg*>(rNewPos.nContent.GetIdxReg()),
+                    rNewPos.nNode.GetNode().GetContentNode(),
                     nCntIdx + pPam->GetBound(bool(nb)).nContent.GetIndex());
             }
     }
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 3751ae034577..d5b0703cc44b 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -67,7 +67,8 @@ void RestFlyInRange( SaveFlyArr & rArr, const SwPosition& 
rStartPos,
                 if (aAnchor.GetAnchorId() == RndStdIds::FLY_AT_PARA)
                 {
                     aPos.nNode = *pInsertPos;
-                    
aPos.nContent.Assign(dynamic_cast<SwIndexReg*>(&aPos.nNode.GetNode()),
+                    assert(aPos.nNode.GetNode().GetContentNode());
+                    aPos.nContent.Assign(aPos.nNode.GetNode().GetContentNode(),
                         rSave.nContentIndex);
                 }
                 else
@@ -79,13 +80,15 @@ void RestFlyInRange( SaveFlyArr & rArr, const SwPosition& 
rStartPos,
             else
             {
                 aPos.nNode = rStartPos.nNode;
-                
aPos.nContent.Assign(dynamic_cast<SwIndexReg*>(&aPos.nNode.GetNode()), 0);
+                assert(aPos.nNode.GetNode().GetContentNode());
+                aPos.nContent.Assign(aPos.nNode.GetNode().GetContentNode(), 0);
             }
         }
         else
         {
             aPos.nNode = rStartPos.nNode.GetIndex() + rSave.nNdDiff;
-            
aPos.nContent.Assign(dynamic_cast<SwIndexReg*>(&aPos.nNode.GetNode()),
+            assert(aPos.nNode.GetNode().GetContentNode());
+            aPos.nContent.Assign(aPos.nNode.GetNode().GetContentNode(),
                 rSave.nNdDiff == SwNodeOffset(0)
                     ? rStartPos.nContent.GetIndex() + rSave.nContentIndex
                     : rSave.nContentIndex);
@@ -423,9 +426,9 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev )
 
                 // If the passed PaM is not in the Cursor ring,
                 // treat it separately (e.g. when it's being called from 
AutoFormat)
-                if( pOldTextNd == rPam.GetBound().nContent.GetIdxReg() )
+                if( pOldTextNd == rPam.GetBound().nContent.GetContentNode() )
                     rPam.GetBound() = aAlphaPos;
-                if( pOldTextNd == rPam.GetBound( false ).nContent.GetIdxReg() )
+                if( pOldTextNd == rPam.GetBound( false 
).nContent.GetContentNode() )
                     rPam.GetBound( false ) = aAlphaPos;
             }
             // delete the Node, at last!
@@ -474,11 +477,11 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev )
 
             rDoc.CorrRel( aIdx, *rPam.GetPoint(), 0, true );
             // #i100466# adjust given <rPam>, if it does not belong to the 
cursors
-            if ( pDelNd == rPam.GetBound().nContent.GetIdxReg() )
+            if ( pDelNd == rPam.GetBound().nContent.GetContentNode() )
             {
                 rPam.GetBound() = SwPosition( SwNodeIndex( *pTextNd ), 
SwIndex( pTextNd ) );
             }
-            if( pDelNd == rPam.GetBound( false ).nContent.GetIdxReg() )
+            if( pDelNd == rPam.GetBound( false ).nContent.GetContentNode() )
             {
                 rPam.GetBound( false ) = SwPosition( SwNodeIndex( *pTextNd ), 
SwIndex( pTextNd ) );
             }
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 444e6dda6613..589fd75f456f 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -285,6 +285,18 @@ sal_uInt16 SwNode::GetSectionLevel() const
 tools::Long SwNode::s_nSerial = 0;
 #endif
 
+/// only used by SwContentNodeTmp in SwTextNode::Update
+SwNode::SwNode()
+    : m_nNodeType( SwNodeType::Start )
+    , m_nAFormatNumLvl( 0 )
+    , m_bIgnoreDontExpand( false)
+    , m_eMerge(Merge::None)
+#ifdef DBG_UTIL
+    , m_nSerial( s_nSerial++)
+#endif
+    , m_pStartOfSection( nullptr )
+{}
+
 SwNode::SwNode( const SwNodeIndex &rWhere, const SwNodeType nNdType )
     : m_nNodeType( nNdType )
     , m_nAFormatNumLvl( 0 )
@@ -1060,6 +1072,14 @@ SwEndNode::SwEndNode( SwNodes& rNds, SwNodeOffset nPos, 
SwStartNode& rSttNd )
     m_pStartOfSection->m_pEndOfSection = this;
 }
 
+/// only used by SwContentNodeTmp in SwTextNode::Update
+SwContentNode::SwContentNode()
+    : SwNode()
+    , m_aCondCollListener( *this )
+    , m_pCondColl( nullptr )
+    , mbSetModifyAtAttr( false )
+{}
+
 SwContentNode::SwContentNode( const SwNodeIndex &rWhere, const SwNodeType 
nNdType,
                             SwFormatColl *pColl )
     : SwNode( rWhere, nNdType )
diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index 8b19e8c8b1e0..bc95e7ca1d84 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -288,9 +288,9 @@ bool SwEditShell::Copy( SwEditShell& rDestShell )
     {
         for(SwPaM& rCmp : rDestShell.GetCursor()->GetRingContainer())
         {
-            OSL_ENSURE( rCmp.GetPoint()->nContent.GetIdxReg()
+            OSL_ENSURE( rCmp.GetPoint()->nContent.GetContentNode()
                         == rCmp.GetContentNode(), "Point in wrong Node" );
-            OSL_ENSURE( rCmp.GetMark()->nContent.GetIdxReg()
+            OSL_ENSURE( rCmp.GetMark()->nContent.GetContentNode()
                         == rCmp.GetContentNode(false), "Mark in wrong Node" );
         }
     }
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index bc73c7463c37..5b4ba3238a6f 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -386,7 +386,7 @@ static SwPosition ResolveFlyAnchor(SwFrameFormat const& 
rFlyFrame)
         {
             return ResolveFlyAnchor(*pParent);
         }
-        else if (pPos->nContent.GetIdxReg())
+        else if (pPos->nContent.GetContentNode())
         {
             return *pPos;
         }
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 879faf170b09..414438b62b58 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1211,6 +1211,18 @@ void SwTextNode::NewAttrSet( SwAttrPool& rPool )
     mpAttrSet = GetDoc().GetIStyleAccess().getAutomaticStyle( aNewAttrSet, 
IStyleAccess::AUTO_STYLE_PARA, &sVal );
 }
 
+namespace
+{
+class SwContentNodeTmp : public SwContentNode
+{
+public:
+    SwContentNodeTmp() : SwContentNode() {}
+    virtual void NewAttrSet(SwAttrPool&) override {}
+    virtual SwContentFrame *MakeFrame(SwFrame*) override { return nullptr; }
+    virtual SwContentNode* MakeCopy(SwDoc&, const SwNodeIndex&, bool 
/*bNewFrames*/) const override { return nullptr; };
+};
+};
+
 // override SwIndexReg::Update => text hints do not need SwIndex for start/end!
 void SwTextNode::Update(
     SwIndex const & rPos,
@@ -1396,7 +1408,7 @@ void SwTextNode::Update(
     }
 
     bool bSortMarks = false;
-    SwIndexReg aTmpIdxReg;
+    SwContentNodeTmp aTmpIdxReg;
     if ( !bNegative && !bDelete )
     {
         const SwRedlineTable& rTable = 
GetDoc().getIDocumentRedlineAccess().GetRedlineTable();
@@ -1427,7 +1439,7 @@ void SwTextNode::Update(
                 // the unused position must not be on a SwTextNode
                 bool const isOneUsed(&pRedl->GetBound() == pRedl->GetPoint());
                 
assert(!pRedl->GetBound(!isOneUsed).nNode.GetNode().IsTextNode());
-                assert(!pRedl->GetBound(!isOneUsed).nContent.GetIdxReg()); 
(void)isOneUsed;
+                
assert(!pRedl->GetBound(!isOneUsed).nContent.GetContentNode()); (void)isOneUsed;
             }
         }
 
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index c23aeba3ba51..410dacca9037 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -1562,7 +1562,7 @@ static bool IsAtEndOfSection(SwPosition const& rAnchorPos)
     assert(rAnchorPos.nNode <= node); // last valid anchor pos is last content
     return node == rAnchorPos.nNode
         // at-para fly has no SwIndex!
-        && (rAnchorPos.nContent == pNode->Len() || 
rAnchorPos.nContent.GetIdxReg() == nullptr);
+        && (rAnchorPos.nContent == pNode->Len() || 
rAnchorPos.nContent.GetContentNode() == nullptr);
 }
 
 static bool IsAtStartOfSection(SwPosition const& rAnchorPos)
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 5c4c8c9474ad..37364401071e 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -162,11 +162,11 @@ bool SwUndoInsert::CanGrouping( const SwPosition& rPos )
             if( !rTable.empty() )
             {
                 SwRedlineData aRData( RedlineType::Insert, 
rDoc.getIDocumentRedlineAccess().GetRedlineAuthor() );
-                const SwIndexReg* pIReg = rPos.nContent.GetIdxReg();
+                const SwContentNode* pIReg = rPos.nContent.GetContentNode();
                 for(SwRangeRedline* pRedl : rTable)
                 {
                     SwIndex* pIdx = &pRedl->End()->nContent;
-                    if( pIReg == pIdx->GetIdxReg() &&
+                    if( pIReg == pIdx->GetContentNode() &&
                         m_nContent == pIdx->GetIndex() )
                     {
                         if( !pRedl->HasMark() || !m_pRedlData ||
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 7e8731086078..88dd11070e01 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -93,7 +93,7 @@ static void lcl_EnsureValidPam( SwPaM& rPam )
     if( rPam.GetContentNode() != nullptr )
     {
         // set proper point content
-        if( rPam.GetContentNode() != rPam.GetPoint()->nContent.GetIdxReg() )
+        if( rPam.GetContentNode() != 
rPam.GetPoint()->nContent.GetContentNode() )
         {
             rPam.GetPoint()->nContent.Assign( rPam.GetContentNode(), 0 );
         }
@@ -101,7 +101,7 @@ static void lcl_EnsureValidPam( SwPaM& rPam )
 
         // if mark is invalid, we delete it
         if( ( rPam.GetContentNode( false ) == nullptr ) ||
-            ( rPam.GetContentNode( false ) != 
rPam.GetMark()->nContent.GetIdxReg() ) )
+            ( rPam.GetContentNode( false ) != 
rPam.GetMark()->nContent.GetContentNode() ) )
         {
             rPam.DeleteMark();
         }

Reply via email to