sw/inc/ndarr.hxx | 2 - sw/source/core/doc/DocumentContentOperationsManager.cxx | 2 - sw/source/core/doc/docglbl.cxx | 5 +--- sw/source/core/doc/tblrwcl.cxx | 2 - sw/source/core/docnode/nodes.cxx | 19 ++++++---------- sw/source/core/undo/undel.cxx | 14 +++++------ sw/source/core/undo/undobj.cxx | 4 +-- sw/source/core/undo/untbl.cxx | 2 - 8 files changed, 23 insertions(+), 27 deletions(-)
New commits: commit 78fb8fe0c5a58bc4d5074de66e77c20c3a441fd3 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Aug 16 10:04:10 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 17 09:16:36 2022 +0200 pass sal_Int32 to MoveNodes instead of SwContentIndex Part of the process of hiding the implementation of SwPosition. Change-Id: I22858f1be5315141e3efd28db7b7cc2c9fdc5c68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138400 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 41180ed19ee1..478e135bdcb4 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -169,7 +169,7 @@ public: static sal_uInt16 GetSectionLevel(const SwNode &rIndex); void Delete(const SwNodeIndex &rPos, SwNodeOffset nNodes = SwNodeOffset(1)); - bool MoveNodes( const SwNodeRange&, SwNodes& rNodes, const SwNodeIndex&, + bool MoveNodes( const SwNodeRange&, SwNodes& rNodes, SwNode& rPos, bool bNewFrames = true ); void MoveRange( SwPaM&, SwPosition&, SwNodes& rNodes ); diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 9e6d8ab0ad46..5ccdfde50394 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -2624,7 +2624,7 @@ bool DocumentContentOperationsManager::MoveNodeRange( SwNodeRange& rRange, SwNod // move the Nodes bool bNoDelFrames = bool(SwMoveFlags::NO_DELFRMS & eMvFlags); - if( m_rDoc.GetNodes().MoveNodes( rRange, m_rDoc.GetNodes(), rPos, !bNoDelFrames ) ) + if( m_rDoc.GetNodes().MoveNodes( rRange, m_rDoc.GetNodes(), rPos.GetNode(), !bNoDelFrames ) ) { ++aIdx; // again back to old position if( oSaveInsPos ) diff --git a/sw/source/core/doc/docglbl.cxx b/sw/source/core/doc/docglbl.cxx index 7148942f1d45..79dc2c885f82 100644 --- a/sw/source/core/doc/docglbl.cxx +++ b/sw/source/core/doc/docglbl.cxx @@ -435,7 +435,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, { SwNodeRange aRg( *pStartNd, *pSectEnd ); SwNodeIndex aIdx( *pSectEnd, 1 ); - GetNodes().MoveNodes( aRg, GetNodes(), aIdx ); + GetNodes().MoveNodes( aRg, GetNodes(), aIdx.GetNode() ); } pSectNd = pStartNd->FindSectionNode(); } @@ -449,8 +449,7 @@ bool SwDoc::SplitDoc( sal_uInt16 eDocType, const OUString& rPath, bool bOutline, if( aEndIdx < pSectNd->EndOfSectionIndex() ) { SwNodeRange aRg( *pSectNd, SwNodeOffset(1), aEndIdx.GetNode(), SwNodeOffset(1) ); - SwNodeIndex aIdx( *pSectNd ); - GetNodes().MoveNodes( aRg, GetNodes(), aIdx ); + GetNodes().MoveNodes( aRg, GetNodes(), *pSectNd ); } pSectNd = pStartNd->FindSectionNode(); diff --git a/sw/source/core/doc/tblrwcl.cxx b/sw/source/core/doc/tblrwcl.cxx index 89aec4b6a8ab..a2032e0f3291 100644 --- a/sw/source/core/doc/tblrwcl.cxx +++ b/sw/source/core/doc/tblrwcl.cxx @@ -1140,7 +1140,7 @@ bool SwTable::OldSplitRow( SwDoc& rDoc, const SwSelBoxes& rBoxes, sal_uInt16 nCn SwNodeRange aRg( *pLastBox->GetSttNd(), SwNodeOffset(+2), *pEndNd ); pLastBox = pNewLine->GetTabBoxes()[0]; // reset SwNodeIndex aInsPos( *pLastBox->GetSttNd(), 1 ); - rDoc.GetNodes().MoveNodes(aRg, rDoc.GetNodes(), aInsPos, false); + rDoc.GetNodes().MoveNodes(aRg, rDoc.GetNodes(), aInsPos.GetNode(), false); rDoc.GetNodes().Delete( aInsPos ); // delete the empty one } } diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 98e1ac29de2a..36f753487fe0 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -401,17 +401,14 @@ void SwNodes::ChgNode( SwNodeIndex const & rDelPos, SwNodeOffset nSz, * position, nothing happens. * * @param aRange range to move (excluding end node) - * @param rNodes - * @param aIndex - * @param bNewFrames * @return */ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, - const SwNodeIndex& aIndex, bool bNewFrames ) + SwNode& rPos, bool bNewFrames ) { SwNode * pCurrentNode; - if( aIndex == SwNodeOffset(0) || - ( (pCurrentNode = &aIndex.GetNode())->GetStartNode() && + if( rPos.GetIndex() == SwNodeOffset(0) || + ( (pCurrentNode = &rPos)->GetStartNode() && !pCurrentNode->StartOfSectionIndex() )) return false; @@ -439,9 +436,9 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, if( this == &rNodes ) { - if( ( aIndex.GetIndex()-SwNodeOffset(1) >= aRg.aStart.GetIndex() && - aIndex.GetIndex()-SwNodeOffset(1) < aRg.aEnd.GetIndex()) || - ( aIndex.GetIndex()-SwNodeOffset(1) == aRg.aEnd.GetIndex() ) ) + if( ( rPos.GetIndex()-SwNodeOffset(1) >= aRg.aStart.GetIndex() && + rPos.GetIndex()-SwNodeOffset(1) < aRg.aEnd.GetIndex()) || + ( rPos.GetIndex()-SwNodeOffset(1) == aRg.aEnd.GetIndex() ) ) return false; } @@ -452,7 +449,7 @@ bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, SwStartNodePointers::size_type nLevel = 0; // level counter // set start index - SwNodeIndex aIdx( aIndex ); + SwNodeIndex aIdx( rPos ); SwStartNode* pStartNode = aIdx.GetNode().m_pStartOfSection; aSttNdStack.insert( aSttNdStack.begin(), pStartNode ); @@ -1665,7 +1662,7 @@ void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes ) // move the nodes into the NodesArray const SwNodeOffset nSttDiff = aSttIdx.GetIndex() - pStt->GetNodeIndex(); SwNodeRange aRg( aSttIdx, aEndIdx ); - MoveNodes( aRg, rNodes, rPos.nNode ); + MoveNodes( aRg, rNodes, rPos.GetNode() ); // if in the same node array, all indices are now at new positions (so correct them) if( &rNodes == this ) diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index fd73708de12d..14b7b020f26b 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -339,7 +339,7 @@ SwUndoDelete::SwUndoDelete( SwPosition aSplitPos( *pEndTextNd ); ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo()); rDoc.getIDocumentContentOperations().SplitNode( aSplitPos, false ); - rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aEnd ); + rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aEnd.GetNode() ); --aRg.aEnd; } else @@ -363,7 +363,7 @@ SwUndoDelete::SwUndoDelete( SwPosition aSplitPos( *pSttTextNd ); ::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo()); rDoc.getIDocumentContentOperations().SplitNode( aSplitPos, false ); - rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aStart ); + rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aStart.GetNode() ); --aRg.aStart; } } @@ -384,7 +384,7 @@ SwUndoDelete::SwUndoDelete( // Step 3: Moving into UndoArray... m_nNode = rNds.GetEndOfContent().GetIndex(); - rDocNds.MoveNodes( aRg, rNds, SwNodeIndex( rNds.GetEndOfContent() )); + rDocNds.MoveNodes( aRg, rNds, rNds.GetEndOfContent() ); m_oMvStt.emplace( rNds, m_nNode ); // remember difference! m_nNode = rNds.GetEndOfContent().GetIndex() - m_nNode; @@ -401,12 +401,12 @@ SwUndoDelete::SwUndoDelete( if( m_bJoinNext ) { SwNodeRange aMvRg( *pEndTextNd, SwNodeOffset(0), *pEndTextNd, SwNodeOffset(1) ); - rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aStart ); + rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aStart.GetNode() ); } else { SwNodeRange aMvRg( *pSttTextNd, SwNodeOffset(0), *pSttTextNd, SwNodeOffset(1) ); - rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aEnd ); + rDocNds.MoveNodes( aMvRg, rDocNds, aRg.aEnd.GetNode() ); } } } @@ -963,7 +963,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) --aPos.nNode; if( !m_bJoinNext ) pMovedNode = &aPos.GetNode(); - rDoc.GetNodes().MoveNodes(aRg, rDoc.GetNodes(), aMvIdx); + rDoc.GetNodes().MoveNodes(aRg, rDoc.GetNodes(), aMvIdx.GetNode()); ++aPos.nNode; } @@ -994,7 +994,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) SwNodeRange aRg( aPos.nNode, SwNodeOffset(0), aPos.nNode, SwNodeOffset(1) ); pMovedNode = &aPos.GetNode(); // tdf#131684 without deleting frames - rDoc.GetNodes().MoveNodes(aRg, rDoc.GetNodes(), aMvIdx, false); + rDoc.GetNodes().MoveNodes(aRg, rDoc.GetNodes(), aMvIdx.GetNode(), false); rDoc.GetNodes().Delete( aMvIdx); } } diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx index 2487a02efdea..8a110d013039 100644 --- a/sw/source/core/undo/undobj.cxx +++ b/sw/source/core/undo/undobj.cxx @@ -747,7 +747,7 @@ void SwUndoSaveContent::MoveToUndoNds( SwPaM& rPaM, SwNodeIndex* pNodeIdx, if( pCpyNd || pEndNdIdx ) { SwNodeRange aRg( pStt->nNode, SwNodeOffset(0), pEnd->nNode, SwNodeOffset(1) ); - rDoc.GetNodes().MoveNodes( aRg, rNds, aPos.nNode, true ); + rDoc.GetNodes().MoveNodes( aRg, rNds, aPos.GetNode(), true ); aPos.nContent = 0; --aPos.nNode; } @@ -813,7 +813,7 @@ void SwUndoSaveContent::MoveFromUndoNds( SwDoc& rDoc, SwNodeOffset nNodeIdx, SwNodeRange aRg( rNds, nNodeIdx, (pEndNdIdx ? ((*pEndNdIdx) + 1) : rNds.GetEndOfExtras().GetIndex() ) ); - rNds.MoveNodes(aRg, rDoc.GetNodes(), rInsPos.nNode, nullptr == pEndNdIdx || bForceCreateFrames); + rNds.MoveNodes(aRg, rDoc.GetNodes(), rInsPos.GetNode(), nullptr == pEndNdIdx || bForceCreateFrames); } } diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 7ca506fcb8fb..70b84bbe6248 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -1733,7 +1733,7 @@ void SwUndoTableNdsChg::UndoImpl(::sw::UndoRedoContext & rContext) // first delete box delete pBox; // than move nodes - rDoc.GetNodes().MoveNodes( aRg, rDoc.GetNodes(), aInsPos, false ); + rDoc.GetNodes().MoveNodes( aRg, rDoc.GetNodes(), aInsPos.GetNode(), false ); } else {