sw/inc/pam.hxx                                          |   10 ++++++++
 sw/source/core/crsr/crsrsh.cxx                          |    4 +--
 sw/source/core/crsr/pam.cxx                             |   17 +++++++++++++++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   11 ++++-----
 sw/source/core/doc/docedt.cxx                           |    8 +++----
 sw/source/core/doc/docnew.cxx                           |    2 -
 sw/source/core/doc/docredln.cxx                         |    6 +----
 sw/source/core/doc/doctxm.cxx                           |    4 +--
 sw/source/core/docnode/ndtbl.cxx                        |    2 -
 sw/source/core/docnode/section.cxx                      |    5 +---
 sw/source/core/edit/edglss.cxx                          |    5 +---
 sw/source/core/frmedt/fecopy.cxx                        |    6 ++---
 sw/source/core/layout/ftnfrm.cxx                        |    2 -
 sw/source/core/layout/trvlfrm.cxx                       |    3 --
 sw/source/core/undo/unattr.cxx                          |    3 --
 sw/source/core/undo/unmove.cxx                          |   11 ++++-----
 sw/source/core/undo/unsect.cxx                          |    2 -
 sw/source/core/undo/untbl.cxx                           |    2 -
 sw/source/core/undo/untblk.cxx                          |    4 +--
 sw/source/filter/basflt/shellio.cxx                     |    2 -
 sw/source/filter/docx/swdocxreader.cxx                  |    2 -
 sw/source/filter/html/htmlsect.cxx                      |   18 ++++------------
 sw/source/filter/ww8/wrtw8nds.cxx                       |   10 ++++----
 sw/source/filter/ww8/ww8glsy.cxx                        |    2 -
 sw/source/uibase/dochdl/swdtflvr.cxx                    |    3 --
 sw/source/uibase/uno/unoatxt.cxx                        |    2 -
 26 files changed, 77 insertions(+), 69 deletions(-)

New commits:
commit 96844af26402e4ab26ff7ba02e52989c3b294095
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Jul 26 10:58:48 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Jul 26 18:54:47 2022 +0200

    elide some temporaries when constructing SwPosition
    
    because the resulting pointer manipulation is not free, the temporary
    has to be attached to a linked list and then immediately de-linked
    
    Also add some asserts to catch SwPosition being created with
    mis-matching nodes in the SwNodeIndex and SwContentIndex.
    
    Which flushes out some bugs in
        SwHTMLParser::NewDivision
        SwIntrnlSectRefLink::DataChanged
    where it was creating a SwPosition
    with the SwNodeIndex and the SwContentIndex pointing at
    different nodes.
    
    Change-Id: Iea69f5ffc5860eb654435e161bc544b412d4c245
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137411
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 8f72eb0452e3..dd91d355b7f6 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -42,10 +42,18 @@ struct SAL_WARN_UNUSED SW_DLLPUBLIC SwPosition
     explicit SwPosition( SwNodes& rNodes, SwNodeOffset nIndex = 
SwNodeOffset(0) );
     explicit SwPosition( const SwNodeIndex &rNode, SwNodeOffset nDiff = 
SwNodeOffset(0) );
     explicit SwPosition( const SwNode& rNode, SwNodeOffset nDiff = 
SwNodeOffset(0) );
-    explicit SwPosition( const SwContentNode& rNode, const sal_Int32 
nContentOffset = 0 );
+    explicit SwPosition( const SwContentNode& rNode, sal_Int32 nContentOffset 
= 0 );
+    SwPosition( const SwNodeIndex &rNode, const SwContentNode*, const 
sal_Int32 nContentOffset );
+    SwPosition( const SwNodeIndex &rNode, SwNodeOffset nDiff, const 
SwContentNode*, sal_Int32 nContentOffset );
+    SwPosition( const SwContentIndex &, short nDiff );
 
     // callers should be using one of the other constructors to avoid creating 
a temporary
     SwPosition( SwNodeIndex && ) = delete;
+    SwPosition( const SwNodeIndex &, SwContentIndex && ) = delete;
+    SwPosition( SwNodeIndex &&, SwContentIndex && ) = delete;
+    SwPosition( SwNodeIndex &&, const SwContentNode*, sal_Int32 ) = delete;
+    SwPosition( SwNodeIndex &&, SwNodeOffset ) = delete;
+    SwPosition( SwContentIndex &&, short ) = delete;
 
     /**
        Returns the document this position is in.
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 15f6484e5dac..9c46b041c047 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1543,7 +1543,7 @@ static void lcl_CheckHiddenPara( SwPosition& rPos )
     }
 
     if ( pTextNd )
-        rPos = SwPosition( aTmp, SwContentIndex( pTextNd, 0 ) );
+        rPos = SwPosition( *pTextNd, 0 );
 }
 
 #if !ENABLE_WASM_STRIP_ACCESSIBILITY
@@ -2998,7 +2998,7 @@ SwCursorShell::SwCursorShell( SwDoc& rDoc, vcl::Window 
*pInitWin,
     SwNodeIndex aNodeIdx( *rNds.GetEndOfContent().StartOfSectionNode() );
     SwContentNode* pCNd = rNds.GoNext( &aNodeIdx ); // go to the first 
ContentNode
 
-    m_pCurrentCursor = new SwShellCursor( *this, SwPosition( aNodeIdx, 
SwContentIndex( pCNd, 0 )));
+    m_pCurrentCursor = new SwShellCursor( *this, SwPosition( aNodeIdx, pCNd, 0 
) );
 
     // Register shell as dependent at current node. As a result all attribute
     // changes can be forwarded via the Link.
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index 157a859f1d0a..74aec4248cab 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -62,6 +62,18 @@ SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, 
const SwContentIndex & r
 {
 }
 
+SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, const SwContentNode* 
pContentNode, sal_Int32 nContentOffset )
+    : nNode( rNodeIndex ), nContent( pContentNode, nContentOffset )
+{
+    assert(!pContentNode || pContentNode == &rNodeIndex.GetNode());
+}
+
+SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, SwNodeOffset nDiff, 
const SwContentNode* pContentNode, sal_Int32 nContentOffset )
+    : nNode( rNodeIndex, nDiff ), nContent( pContentNode, nContentOffset )
+{
+    assert(!pContentNode || pContentNode == &rNodeIndex.GetNode());
+}
+
 SwPosition::SwPosition( const SwNodeIndex & rNodeIndex, SwNodeOffset nDiff )
     : nNode( rNodeIndex, nDiff ), nContent( nNode.GetNode().GetContentNode() )
 {
@@ -82,6 +94,11 @@ SwPosition::SwPosition( const SwContentNode & rNode, const 
sal_Int32 nContentOff
 {
 }
 
+SwPosition::SwPosition( const SwContentIndex & rContentIndex, short nDiff )
+    : nNode( *rContentIndex.GetContentNode() ), nContent( rContentIndex, nDiff 
)
+{
+}
+
 bool SwPosition::operator<(const SwPosition &rPos) const
 {
     // cheaper to check for == first
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 41ef175cd301..9be8e4b417c1 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2725,8 +2725,9 @@ void DocumentContentOperationsManager::MoveAndJoin( 
SwPaM& rPaM, SwPosition& rPo
     if( pTextNd && pTextNd->CanJoinNext( &aNxtIdx ) )
     {
         {   // Block so SwContentIndex into node is deleted before Join
-            m_rDoc.CorrRel( aNxtIdx, SwPosition( aIdx, SwContentIndex(pTextNd,
-                        pTextNd->GetText().getLength()) ), 0, true );
+            m_rDoc.CorrRel( aNxtIdx,
+                            SwPosition( *pTextNd, 
pTextNd->GetText().getLength() ),
+                            0, true );
         }
         pTextNd->JoinNext();
     }
@@ -5206,8 +5207,7 @@ bool 
DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
         }
 
         {
-            SwPosition startPos(SwNodeIndex(pCopyPam->GetPoint()->nNode, +1),
-                SwContentIndex(SwNodeIndex(pCopyPam->GetPoint()->nNode, 
+1).GetNode().GetContentNode()));
+            SwPosition startPos(pCopyPam->GetPoint()->nNode, SwNodeOffset(+1));
             if (bCanMoveBack)
             {   // pCopyPam is actually 1 before the copy range so move it fwd
                 SwPaM temp(*pCopyPam->GetPoint());
@@ -5239,8 +5239,7 @@ bool 
DocumentContentOperationsManager::CopyImplImpl(SwPaM& rPam, SwPosition& rPo
         if (pFlysAtInsPos)
         {
             // init *again* - because CopyWithFlyInFly moved startPos
-            SwPosition startPos(SwNodeIndex(pCopyPam->GetPoint()->nNode, +1),
-                SwContentIndex(SwNodeIndex(pCopyPam->GetPoint()->nNode, 
+1).GetNode().GetContentNode()));
+            SwPosition startPos(pCopyPam->GetPoint()->nNode, SwNodeOffset(+1));
             if (bCanMoveBack)
             {   // pCopyPam is actually 1 before the copy range so move it fwd
                 SwPaM temp(*pCopyPam->GetPoint());
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 6923cb9ab555..4f16b6042a8c 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -277,7 +277,7 @@ SaveRedlEndPosForRestore::SaveRedlEndPosForRestore( const 
SwNodeIndex& rInsIdx,
 
     SwRedlineTable::size_type nFndPos;
     const SwPosition* pEnd;
-    SwPosition aSrcPos( rInsIdx, SwContentIndex( rNd.GetContentNode(), nCnt ));
+    SwPosition aSrcPos( rInsIdx, rNd.GetContentNode(), nCnt );
     rDest.getIDocumentRedlineAccess().GetRedline( aSrcPos, &nFndPos );
     const SwRangeRedline* pRedl;
     while( nFndPos--
@@ -307,7 +307,7 @@ void SaveRedlEndPosForRestore::Restore()
     // This may happen if a table (or section?) will be inserted.
     if( pNode )
     {
-        SwPosition aPos( *mpSaveIndex, SwContentIndex( pNode, mnSaveContent ));
+        SwPosition aPos( *mpSaveIndex, pNode, mnSaveContent );
         for( auto n = mvSavArr.size(); n; )
             *mvSavArr[ --n ] = aPos;
     }
@@ -479,11 +479,11 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev )
             // #i100466# adjust given <rPam>, if it does not belong to the 
cursors
             if ( pDelNd == rPam.GetBound().nContent.GetContentNode() )
             {
-                rPam.GetBound() = SwPosition( SwNodeIndex( *pTextNd ), 
SwContentIndex( pTextNd ) );
+                rPam.GetBound() = SwPosition( *pTextNd );
             }
             if( pDelNd == rPam.GetBound( false ).nContent.GetContentNode() )
             {
-                rPam.GetBound( false ) = SwPosition( SwNodeIndex( *pTextNd ), 
SwContentIndex( pTextNd ) );
+                rPam.GetBound( false ) = SwPosition( *pTextNd );
             }
             pTextNd->JoinNext();
         }
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 462fba9d9979..a2230985d2f6 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -684,7 +684,7 @@ void SwDoc::ClearDoc()
         // set the layout to the dummy pagedesc
         pFirstNd->SetAttr( SwFormatPageDesc( pDummyPgDsc ));
 
-        SwPosition aPos( *pFirstNd, SwContentIndex( pFirstNd ));
+        SwPosition aPos( *pFirstNd );
         SwPaM const tmpPaM(aSttIdx, SwNodeIndex(GetNodes().GetEndOfContent()));
         ::PaMCorrAbs(tmpPaM, aPos);
     }
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index e460c0ce3a68..acf28394c840 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1532,7 +1532,7 @@ void SwRangeRedline::MoveToSection()
             SwTextNode* pTextNd = rNds[ pSttNd->GetIndex() + 1 
]->GetTextNode();
 
             SwNodeIndex aNdIdx( *pTextNd );
-            SwPosition aPos( aNdIdx, SwContentIndex( pTextNd ));
+            SwPosition aPos( *pTextNd );
             if( pCSttNd && pCEndNd )
             {
                 // tdf#140982 keep annotation ranges in deletions in margin 
mode
@@ -1599,9 +1599,7 @@ void SwRangeRedline::CopyToSection()
         pSttNd = rNds.MakeTextSection( SwNodeIndex( rNds.GetEndOfRedlines() ),
                                         SwNormalStartNode, pColl );
 
-        SwNodeIndex aNdIdx( *pSttNd, 1 );
-        SwTextNode* pTextNd = aNdIdx.GetNode().GetTextNode();
-        SwPosition aPos( aNdIdx, SwContentIndex( pTextNd ));
+        SwPosition aPos( *pSttNd, SwNodeOffset(1) );
 
         // tdf#115815 keep original start position of collapsed annotation 
ranges
         // as temporary bookmarks (removed after file saving and file loading)
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index c34bdea2233a..96107a634571 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -175,7 +175,7 @@ void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark )
         {
             // save attributes for Undo
             SwUndoResetAttr* pUndo = new SwUndoResetAttr(
-                SwPosition( rTextNd, SwContentIndex( &rTextNd, 
pTextTOXMark->GetStart() ) ),
+                SwPosition( rTextNd, pTextTOXMark->GetStart() ),
                 RES_TXTATR_TOXMARK );
             GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) 
);
 
@@ -1024,7 +1024,7 @@ void SwTOXBaseSection::Update(const SfxItemSet* pAttr,
         else
         {
             --aEndIdx;
-            SwPosition aPos( aEndIdx, SwContentIndex( pFirstEmptyNd, 0 ));
+            SwPosition aPos( aEndIdx, pFirstEmptyNd, 0 );
             SwDoc::CorrAbs( aSttIdx, aEndIdx, aPos, true );
 
             // delete flys in whole range including start node which requires
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index ebb7f41daf09..635476cf3f9a 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1061,7 +1061,7 @@ SwTableNode* SwNodes::TextToTable( const SwNodeRange& 
rRange, sal_Unicode cCh,
         rTable.GetTabLines().insert(rTable.GetTabLines().begin() + nLines, 
pLine);
 
         SwStartNode* pSttNd;
-        SwPosition aCntPos( aSttIdx, SwContentIndex( pTextNd ));
+        SwPosition aCntPos( aSttIdx, pTextNd, 0);
 
         const std::shared_ptr< sw::mark::ContentIdxStore> 
pContentStore(sw::mark::ContentIdxStore::Create());
         pContentStore->Save(rDoc, aSttIdx.GetIndex(), SAL_MAX_INT32);
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index 0ed682c5f91d..6306b1c33684 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1123,7 +1123,7 @@ static void lcl_UpdateLinksInSect( const SwBaseLink& 
rUpdLnk, SwSectionNode& rSe
         // Insert an empty TextNode at the Section's start
         SwNodeIndex aIdx( *pSectNd, +1 );
         SwNodeIndex aEndIdx( *pSectNd->EndOfSectionNode() );
-        SwTextNode* pNewNd = pDoc->GetNodes().MakeTextNode( aIdx,
+        pDoc->GetNodes().MakeTextNode( aIdx,
                         
pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_TEXT ) );
 
         if( pESh )
@@ -1131,8 +1131,7 @@ static void lcl_UpdateLinksInSect( const SwBaseLink& 
rUpdLnk, SwSectionNode& rSe
         else if( pVSh )
             pVSh->StartAction();
 
-        SwPosition aPos( aIdx, SwContentIndex( pNewNd, 0 ));
-        --aPos.nNode;
+        SwPosition aPos( aIdx, SwNodeOffset(-1) );
         SwDoc::CorrAbs( aIdx, aEndIdx, aPos, true );
 
         pPam = new SwPaM( aPos );
diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx
index 752c7e17365a..9e6e96da8435 100644
--- a/sw/source/core/edit/edglss.cxx
+++ b/sw/source/core/edit/edglss.cxx
@@ -140,7 +140,7 @@ sal_uInt16 SwEditShell::SaveGlossaryDoc( SwTextBlocks& 
rBlock,
 
             aStt = pGDoc->GetNodes().GetEndOfExtras();
             pContentNd = pGDoc->GetNodes().GoNext( &aStt );
-            SwPosition aInsPos( aStt, SwContentIndex( pContentNd ));
+            SwPosition aInsPos( aStt );
             pMyDoc->getIDocumentContentOperations().CopyRange(aCpyPam, 
aInsPos, SwCopyFlags::CheckPosInFly);
 
             nRet = rBlock.PutDoc();
@@ -157,8 +157,7 @@ bool SwEditShell::CopySelToDoc( SwDoc& rInsDoc )
 
     SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
     SwContentNode *const pContentNode = aIdx.GetNode().GetContentNode();
-    SwPosition aPos( aIdx,
-        SwContentIndex(pContentNode, pContentNode ? pContentNode->Len() : 0));
+    SwPosition aPos( aIdx, pContentNode, pContentNode ? pContentNode->Len() : 
0);
 
     bool bRet = false;
     CurrShell aCurr( this );
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index 895f5812d15a..6bd3a044b0de 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -173,7 +173,7 @@ void SwFEShell::Copy( SwDoc& rClpDoc, const OUString* 
pNewClpText )
     }
     else if ( IsObjSelected() )
     {
-        SwPosition aPos( aSttIdx, SwContentIndex( pTextNd, 0 ));
+        SwPosition aPos( aSttIdx, pTextNd, 0 );
         const SdrMarkList &rMrkList = 
Imp()->GetDrawView()->GetMarkedObjectList();
         for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
         {
@@ -1011,7 +1011,7 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable)
                     // exit first the complete table
                     // ???? what about only table in a frame ?????
                     SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx 
);
-                    SwPosition aPos( aNdIdx, SwContentIndex( pCNd, 0 ));
+                    SwPosition aPos( aNdIdx, pCNd, 0 );
                     // #i59539: Don't remove all redline
                     SwPaM const tmpPaM(*pDestNd, *pDestNd->EndOfSectionNode());
                     ::PaMCorrAbs(tmpPaM, aPos);
@@ -1026,7 +1026,7 @@ bool SwFEShell::Paste(SwDoc& rClpDoc, bool bNestedTable)
                     // return to the box
                     aNdIdx = *pSttNd;
                     SwContentNode* pCNd = GetDoc()->GetNodes().GoNext( &aNdIdx 
);
-                    SwPosition aPos( aNdIdx, SwContentIndex( pCNd, 0 ));
+                    SwPosition aPos( aNdIdx, pCNd, 0 );
                     // #i59539: Don't remove all redline
                     SwNode & rNode(rPaM.GetPoint()->nNode.GetNode());
                     SwContentNode *const pContentNode( rNode.GetContentNode() 
);
diff --git a/sw/source/core/layout/ftnfrm.cxx b/sw/source/core/layout/ftnfrm.cxx
index 55b0beab6794..a6204e4008fe 100644
--- a/sw/source/core/layout/ftnfrm.cxx
+++ b/sw/source/core/layout/ftnfrm.cxx
@@ -2934,7 +2934,7 @@ SwContentFrame* SwFootnoteFrame::GetRefFromAttr()
 {
     assert(mpAttribute && "invalid Attribute");
     SwTextNode& rTNd = const_cast<SwTextNode&>(mpAttribute->GetTextNode());
-    SwPosition aPos( rTNd, SwContentIndex( &rTNd, mpAttribute->GetStart() ));
+    SwPosition aPos( rTNd, mpAttribute->GetStart() );
     SwContentFrame* pCFrame = rTNd.getLayoutFrame(getRootFrame(), &aPos);
     return pCFrame;
 }
diff --git a/sw/source/core/layout/trvlfrm.cxx 
b/sw/source/core/layout/trvlfrm.cxx
index 4f060f005f16..2a424739a1b7 100644
--- a/sw/source/core/layout/trvlfrm.cxx
+++ b/sw/source/core/layout/trvlfrm.cxx
@@ -304,8 +304,7 @@ bool SwPageFrame::GetModelPositionForViewPoint( SwPosition 
*pPos, Point &rPoint,
                         // previous character; to get a better measure from
                         // lcl_getDistance, extend that to a rectangle over
                         // the entire character.
-                        SwPosition const nextTextPos(prevTextPos.nNode,
-                                             
SwContentIndex(prevTextPos.nContent, +1));
+                        SwPosition const nextTextPos(prevTextPos.nContent, +1);
                         SwRect nextTextRect;
                         pTextFrame->GetCharRect(nextTextRect, nextTextPos);
                         SwRectFnSet aRectFnSet(pTextFrame);
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 69a83488eaa1..99ddf6bbfbdf 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -600,8 +600,7 @@ void SwUndoResetAttr::RedoImpl(::sw::UndoRedoContext & 
rContext)
     {
         SwTOXMarks aArr;
         SwNodeIndex aIdx( rDoc.GetNodes(), m_nSttNode );
-        SwPosition aPos( aIdx, SwContentIndex( aIdx.GetNode().GetContentNode(),
-                                        m_nSttContent ));
+        SwPosition aPos( aIdx, aIdx.GetNode().GetContentNode(), m_nSttContent 
);
 
         sal_uInt16 nCnt = SwDoc::GetCurTOXMark( aPos, aArr );
         if( nCnt ) {
diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx
index 055b56932331..90dff3098d5f 100644
--- a/sw/source/core/undo/unmove.cxx
+++ b/sw/source/core/undo/unmove.cxx
@@ -211,8 +211,8 @@ void SwUndoMove::UndoImpl(::sw::UndoRedoContext & rContext)
         if( m_bJoinNext )
         {
             {
-                RemoveIdxRel( aIdx.GetIndex() + 1, SwPosition( aIdx,
-                        SwContentIndex(pTextNd, 
pTextNd->GetText().getLength())));
+                RemoveIdxRel( aIdx.GetIndex() + 1,
+                        SwPosition( aIdx, pTextNd, 
pTextNd->GetText().getLength()) );
             }
             // Are there any Pams in the next TextNode?
             pTextNd->JoinNext();
@@ -255,8 +255,7 @@ void SwUndoMove::RedoImpl(::sw::UndoRedoContext & rContext)
     {
         SwPaM aPam(*rPam.GetPoint());
         SetPaM( aPam );
-        SwPosition aMvPos( aIdx, SwContentIndex( 
aIdx.GetNode().GetContentNode(),
-                                        m_nMoveDestContent ));
+        SwPosition aMvPos( aIdx, aIdx.GetNode().GetContentNode(), 
m_nMoveDestContent );
 
         DelFootnote( aPam );
         RemoveIdxFromRange( aPam, false );
@@ -275,8 +274,8 @@ void SwUndoMove::RedoImpl(::sw::UndoRedoContext & rContext)
             if( pTextNd && pTextNd->CanJoinNext() )
             {
                 {
-                    RemoveIdxRel( aIdx.GetIndex() + 1, SwPosition( aIdx,
-                            SwContentIndex(pTextNd, 
pTextNd->GetText().getLength())));
+                    RemoveIdxRel( aIdx.GetIndex() + 1,
+                        SwPosition( *pTextNd, pTextNd->GetText().getLength()) 
);
                 }
                 pTextNd->JoinNext();
             }
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index 168a18a50c03..fcfda18576d4 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -283,7 +283,7 @@ void SwUndoInsSection::Join( SwDoc& rDoc, SwNodeOffset 
nNode )
     {
         RemoveIdxRel(
             nNode + 1,
-            SwPosition( aIdx, SwContentIndex( pTextNd, 
pTextNd->GetText().getLength() ) ) );
+            SwPosition( aIdx, pTextNd, pTextNd->GetText().getLength() ) );
     }
     pTextNd->JoinNext();
 
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index dce56d05f3df..0be28a79d970 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -1971,7 +1971,7 @@ void SwUndoTableMerge::UndoImpl(::sw::UndoRedoContext & 
rContext)
                 SwNodeIndex aTmpIdx( *pBox->GetSttNd() );
                 SwDoc::CorrAbs( SwNodeIndex( aTmpIdx, 1 ),
                             SwNodeIndex( *aTmpIdx.GetNode().EndOfSectionNode() 
),
-                            SwPosition( aTmpIdx, SwContentIndex( nullptr, 0 
)), true );
+                            SwPosition( aTmpIdx, nullptr, 0 ), true );
             }
 
             delete pBox;
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 3898b6bf7652..138e7224bd09 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -349,8 +349,8 @@ void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & 
rContext)
         if( bJoinNext && pTextNode->CanJoinNext())
         {
             {
-                RemoveIdxRel( rIdx.GetIndex()+1, SwPosition( rIdx,
-                    SwContentIndex( pTextNode, 
pTextNode->GetText().getLength() )));
+                RemoveIdxRel( rIdx.GetIndex()+1,
+                    SwPosition( rIdx, pTextNode, 
pTextNode->GetText().getLength() ) );
             }
             pTextNode->JoinNext();
         }
diff --git a/sw/source/filter/basflt/shellio.cxx 
b/sw/source/filter/basflt/shellio.cxx
index 7f4fc5d57012..67ba9d9e635e 100644
--- a/sw/source/filter/basflt/shellio.cxx
+++ b/sw/source/filter/basflt/shellio.cxx
@@ -755,7 +755,7 @@ ErrCode SwWriter::Write( WriterRef const & rxWriter, const 
OUString* pRealFileNa
         SwNodeIndex aIdx( xDoc->GetNodes().GetEndOfExtras(), 2 );
         SwContentNode *pNd = aIdx.GetNode().GetContentNode();
         OSL_ENSURE( pNd, "Node not found" );
-        SwPosition aPos( aIdx, SwContentIndex( pNd ) );
+        SwPosition aPos( aIdx, pNd, 0 );
         pTableNd->GetTable().MakeCopy( *xDoc, aPos, aBoxes );
     }
 
diff --git a/sw/source/filter/docx/swdocxreader.cxx 
b/sw/source/filter/docx/swdocxreader.cxx
index 335a0cd5d983..a02420a917f0 100644
--- a/sw/source/filter/docx/swdocxreader.cxx
+++ b/sw/source/filter/docx/swdocxreader.cxx
@@ -234,7 +234,7 @@ bool SwDOCXReader::MakeEntries( SwDoc *pD, SwTextBlocks 
&rBlocks )
                     SwDoc* pGlDoc = rBlocks.GetDoc();
                     SwNodeIndex aIdx( pGlDoc->GetNodes().GetEndOfContent(), -1 
);
                     pCNd = aIdx.GetNode().GetContentNode();
-                    SwPosition aPos( aIdx, SwContentIndex( pCNd, pCNd ? 
pCNd->Len() : 0 ) );
+                    SwPosition aPos( aIdx, pCNd, pCNd ? pCNd->Len() : 0 );
                     pD->getIDocumentContentOperations().CopyRange(aPam, aPos, 
SwCopyFlags::CheckPosInFly);
                     rBlocks.PutDoc();
                 }
diff --git a/sw/source/filter/html/htmlsect.cxx 
b/sw/source/filter/html/htmlsect.cxx
index a7d624a135cc..5ab311e4dc08 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -185,14 +185,8 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
 
         const SwFormatContent& rFlyContent = pHdFtFormat->GetContent();
         const SwNodeIndex& rContentStIdx = *rFlyContent.GetContentIdx();
-        SwContentNode *pCNd;
 
-        if( bNew )
-        {
-            pCNd = m_xDoc->GetNodes()[rContentStIdx.GetIndex()+1]
-                       ->GetContentNode();
-        }
-        else
+        if( !bNew )
         {
             // Our own html export only exports one "header" at most (and one 
"footer")
 
@@ -200,7 +194,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
             // and hide the original header/footers content by putting it into 
a hidden
             // document-level section
             SwNodeIndex aSttIdx( rContentStIdx, 1 );
-            pCNd = m_xDoc->GetNodes().MakeTextNode( aSttIdx,
+            m_xDoc->GetNodes().MakeTextNode( aSttIdx,
                             
m_pCSS1Parser->GetTextCollFromPool(RES_POOLCOLL_TEXT));
 
             // delete the current content of the section
@@ -226,7 +220,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
             }
         }
 
-        SwPosition aNewPos( SwNodeIndex( rContentStIdx, 1 ), SwContentIndex( 
pCNd, 0 ) );
+        SwPosition aNewPos( rContentStIdx, SwNodeOffset(1) );
         SaveDocContext(xCntxt.get(), nFlags, &aNewPos);
     }
     else if( !bPositioned && aId.getLength() > 9 &&
@@ -246,7 +240,7 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
                 SwContentNode *pCNd =
                     
m_xDoc->GetNodes()[pStartNdIdx->GetIndex()+1]->GetContentNode();
                 SwNodeIndex aTmpSwNodeIndex(*pCNd);
-                SwPosition aNewPos( aTmpSwNodeIndex, SwContentIndex( pCNd, 0 ) 
);
+                SwPosition aNewPos( aTmpSwNodeIndex, pCNd, 0 );
                 SaveDocContext(xCntxt.get(), HtmlContextFlags::MultiColMask, 
&aNewPos);
                 aId.clear();
                 aPropInfo.m_aId.clear();
@@ -779,10 +773,8 @@ void SwHTMLParser::InsertFlyFrame( const SfxItemSet& 
rItemSet,
 
     const SwFormatContent& rFlyContent = pFlyFormat->GetContent();
     const SwNodeIndex& rFlyCntIdx = *rFlyContent.GetContentIdx();
-    SwContentNode *pCNd = m_xDoc->GetNodes()[rFlyCntIdx.GetIndex()+1]
-                            ->GetContentNode();
 
-    SwPosition aNewPos( SwNodeIndex( rFlyCntIdx, 1 ), SwContentIndex( pCNd, 0 
) );
+    SwPosition aNewPos( rFlyCntIdx, SwNodeOffset(1) );
     const HtmlContextFlags nFlags = 
HtmlContextFlags::ProtectStack|HtmlContextFlags::StripPara;
     SaveDocContext( pCntxt, nFlags, &aNewPos );
 }
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index b7e9461e1574..7366750d894b 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( &m_rNode ) );
+        SwPosition aPosition( m_rNode );
         m_pCurRedline = 
m_rExport.m_rDoc.getIDocumentRedlineAccess().GetRedline( aPosition, 
&m_nCurRedlinePos );
     }
 
@@ -2489,7 +2489,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 IDocumentMarkAccess* const pMarkAccess = 
m_rDoc.getIDocumentMarkAccess();
                 if ( ch == CH_TXT_ATR_FIELDSTART )
                 {
-                    SwPosition aPosition( rNode, SwContentIndex( &rNode, 
nCurrentPos ) );
+                    SwPosition aPosition( rNode, nCurrentPos );
                     ::sw::mark::IFieldmark const*const pFieldmark = 
pMarkAccess->getFieldmarkAt(aPosition);
                     assert(pFieldmark);
 
@@ -2541,7 +2541,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 }
                 else if (ch == CH_TXT_ATR_FIELDSEP)
                 {
-                    SwPosition aPosition(rNode, SwContentIndex(&rNode, 
nCurrentPos));
+                    SwPosition aPosition(rNode, nCurrentPos);
                     // the innermost field is the correct one
                     ::sw::mark::IFieldmark const*const pFieldmark = 
pMarkAccess->getFieldmarkFor(aPosition);
                     assert(pFieldmark);
@@ -2567,7 +2567,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 }
                 else if ( ch == CH_TXT_ATR_FIELDEND )
                 {
-                    SwPosition aPosition( rNode, SwContentIndex( &rNode, 
nCurrentPos ) );
+                    SwPosition aPosition( rNode, nCurrentPos );
                     ::sw::mark::IFieldmark const*const pFieldmark = 
pMarkAccess->getFieldmarkAt(aPosition);
 
                     assert(pFieldmark);
@@ -2604,7 +2604,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
                 }
                 else if ( ch == CH_TXT_ATR_FORMELEMENT )
                 {
-                    SwPosition aPosition( rNode, SwContentIndex( &rNode, 
nCurrentPos ) );
+                    SwPosition aPosition( rNode, nCurrentPos );
                     ::sw::mark::IFieldmark const*const pFieldmark = 
pMarkAccess->getFieldmarkAt(aPosition);
                     assert(pFieldmark);
 
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index 759e3f5326fb..a9af15c46f92 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -169,7 +169,7 @@ bool WW8Glossary::MakeEntries(SwDoc *pD, SwTextBlocks 
&rBlocks,
                     SwNodeIndex aIdx( pGlDoc->GetNodes().GetEndOfContent(),
                         -1 );
                     pCNd = aIdx.GetNode().GetContentNode();
-                    SwPosition aPos(aIdx, SwContentIndex(pCNd, pCNd ? 
pCNd->Len() : 0));
+                    SwPosition aPos(aIdx, pCNd, pCNd ? pCNd->Len() : 0);
                     pD->getIDocumentContentOperations().CopyRange(aPam, aPos, 
SwCopyFlags::CheckPosInFly);
                     rBlocks.PutDoc();
                 }
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx 
b/sw/source/uibase/dochdl/swdtflvr.cxx
index 918fdd106bd5..f4b37ce7a634 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -925,8 +925,7 @@ void SwTransferable::PrepareForCopyTextRange(SwPaM & rPaM)
 
         SwNodeIndex const aIdx(rDest.GetNodes().GetEndOfContent(), -1);
         SwContentNode *const pContentNode(aIdx.GetNode().GetContentNode());
-        SwPosition aPos(aIdx,
-            SwContentIndex(pContentNode, pContentNode ? pContentNode->Len() : 
0));
+        SwPosition aPos(aIdx, pContentNode, pContentNode ? pContentNode->Len() 
: 0);
 
         rSrc.getIDocumentContentOperations().CopyRange(rPaM, aPos, 
SwCopyFlags::CheckPosInFly);
 
diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx
index 046c23afa926..7e783376d4a1 100644
--- a/sw/source/uibase/uno/unoatxt.cxx
+++ b/sw/source/uibase/uno/unoatxt.cxx
@@ -281,7 +281,7 @@ static bool lcl_CopySelToDoc(SwDoc& rInsDoc, 
OTextCursorHelper* pxCursor, SwXTex
 
     SwNodeIndex aIdx( rNds.GetEndOfContent(), -1 );
     SwContentNode * pNd = aIdx.GetNode().GetContentNode();
-    SwPosition aPos(aIdx, SwContentIndex(pNd, pNd ? pNd->Len() : 0));
+    SwPosition aPos(aIdx, pNd, pNd ? pNd->Len() : 0);
 
     bool bRet = false;
     rInsDoc.getIDocumentFieldsAccess().LockExpFields();

Reply via email to