sw/source/core/doc/DocumentContentOperationsManager.cxx |   28 +++++-----
 sw/source/core/doc/docbm.cxx                            |   42 ++++++----------
 sw/source/core/doc/doccorr.cxx                          |    8 +--
 sw/source/core/docnode/section.cxx                      |    2 
 sw/source/core/inc/mvsave.hxx                           |    8 +--
 sw/source/core/undo/undel.cxx                           |    8 +--
 6 files changed, 44 insertions(+), 52 deletions(-)

New commits:
commit 59785c0237f2bc5eaf9e9742bdf30136f3b3d2ba
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Mon Aug 15 15:24:32 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Aug 16 09:51:56 2022 +0200

    pass SwNode and sal_Int32 to delBookmarks
    
    instead of SwNodeIndex and SwContentIndex. Part of the process
    of hiding the implementation of SwPosition.
    
    Change-Id: Ic70cbf9bd72f7544bcc24a2ebc2f588d5efd9231
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138316
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 91534b7e6863..4987959d84f9 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2090,7 +2090,7 @@ void DocumentContentOperationsManager::DeleteSection( 
SwNode *pNode )
     // delete all Flys, Bookmarks, ...
     DelFlyInRange( aSttIdx.GetNode(), aEndIdx.GetNode() );
     m_rDoc.getIDocumentRedlineAccess().DeleteRedline( *pSttNd, true, 
RedlineType::Any );
-    DelBookmarks(aSttIdx, aEndIdx);
+    DelBookmarks(aSttIdx.GetNode(), aEndIdx.GetNode());
 
     {
         // move all Cursor/StackCursor/UnoCursor out of the to-be-deleted area
@@ -2356,11 +2356,11 @@ bool DocumentContentOperationsManager::MoveRange( 
SwPaM& rPaM, SwPosition& rPos,
         //          here without undo.
         ::sw::UndoGuard const undoGuard(m_rDoc.GetIDocumentUndoRedo());
         DelBookmarks(
-            pStt->nNode,
-            pEnd->nNode,
+            pStt->GetNode(),
+            pEnd->GetNode(),
             nullptr,
-            &pStt->nContent,
-            &pEnd->nContent);
+            pStt->GetContentIndex(),
+            pEnd->GetContentIndex());
     }
 
     bool bUpdateFootnote = false;
@@ -2468,11 +2468,11 @@ bool DocumentContentOperationsManager::MoveRange( 
SwPaM& rPaM, SwPosition& rPos,
     // that saves the position as an offset.
     std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
     DelBookmarks(
-        pStt->nNode,
-        pEnd->nNode,
+        pStt->GetNode(),
+        pEnd->GetNode(),
         &aSaveBkmks,
-        &pStt->nContent,
-        &pEnd->nContent);
+        pStt->GetContentIndex(),
+        pEnd->GetContentIndex());
 
     // If there is no range anymore due to the above deletions (e.g. the
     // footnotes got deleted), it's still a valid Move!
@@ -2608,7 +2608,7 @@ bool DocumentContentOperationsManager::MoveNodeRange( 
SwNodeRange& rRange, SwNod
     // that stores all references to positions as an offset.
     // The final mapping happens after the Move.
     std::vector< ::sw::mark::SaveBookmark> aSaveBkmks;
-    DelBookmarks(rRange.aStart, rRange.aEnd, &aSaveBkmks);
+    DelBookmarks(rRange.aStart.GetNode(), rRange.aEnd.GetNode(), &aSaveBkmks);
 
     // Save the paragraph-bound Flys, so that they can be moved.
     SaveFlyArr aSaveFlyArr;
@@ -4345,11 +4345,11 @@ bool 
DocumentContentOperationsManager::DeleteRangeImplImpl(SwPaM & rPam, SwDelet
             &rPam.GetMark()->nContent, &rPam.GetPoint()->nContent);
     }
     DelBookmarks(
-        pStt->nNode,
-        pEnd->nNode,
+        pStt->GetNode(),
+        pEnd->GetNode(),
         nullptr,
-        &pStt->nContent,
-        &pEnd->nContent);
+        pStt->GetContentIndex(),
+        pEnd->GetContentIndex());
 
     SwNodeIndex aSttIdx( pStt->GetNode() );
     SwContentNode * pCNd = aSttIdx.GetNode().GetContentNode();
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 512c139b41fe..9fdb39fc595c 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -194,14 +194,6 @@ namespace
                : rPos.nNode >= rNdIdx;
     }
 
-    bool lcl_Lower( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const 
SwContentIndex* pIdx )
-    {
-        return rPos.nNode < rNdIdx
-               || ( pIdx != nullptr
-                    && rPos.nNode == rNdIdx
-                    && rPos.nContent < pIdx->GetIndex() );
-    }
-
     bool lcl_Lower( const SwPosition& rPos, const SwNode& rNdIdx, 
std::optional<sal_Int32> oContentIdx )
     {
         return rPos.nNode < rNdIdx
@@ -1788,9 +1780,9 @@ void MarkManager::dumpAsXml(xmlTextWriterPtr pWriter) 
const
 
 namespace
 {
-    bool lcl_Greater( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const 
SwContentIndex* pIdx )
+    bool lcl_Greater( const SwPosition& rPos, const SwNode& rNdIdx, 
std::optional<sal_Int32> oContentIdx )
     {
-        return rPos.nNode > rNdIdx || ( pIdx && rPos.nNode == rNdIdx && 
rPos.nContent > pIdx->GetIndex() );
+        return rPos.nNode > rNdIdx || ( oContentIdx && rPos.nNode == rNdIdx && 
rPos.nContent > *oContentIdx );
     }
 }
 
@@ -1904,21 +1896,21 @@ void SaveBookmark::SetInDoc(
 // DelBookmarks
 
 void DelBookmarks(
-    const SwNodeIndex& rStt,
-    const SwNodeIndex& rEnd,
+    SwNode& rStt,
+    const SwNode& rEnd,
     std::vector<SaveBookmark> * pSaveBkmk,
-    const SwContentIndex* pSttIdx,
-    const SwContentIndex* pEndIdx)
+    std::optional<sal_Int32> oStartContentIdx,
+    std::optional<sal_Int32> oEndContentIdx)
 {
     // illegal range ??
     if(rStt.GetIndex() > rEnd.GetIndex()
-        || (rStt == rEnd && (!pSttIdx || !pEndIdx || pSttIdx->GetIndex() >= 
pEndIdx->GetIndex())))
+        || (&rStt == &rEnd && (!oStartContentIdx || !oEndContentIdx || 
*oStartContentIdx >= *oEndContentIdx)))
         return;
-    SwDoc& rDoc = rStt.GetNode().GetDoc();
+    SwDoc& rDoc = rStt.GetDoc();
 
-    rDoc.getIDocumentMarkAccess()->deleteMarks(rStt.GetNode(), rEnd.GetNode(), 
pSaveBkmk,
-        pSttIdx ? std::optional{pSttIdx->GetIndex()} : std::nullopt,
-        pEndIdx ? std::optional{pEndIdx->GetIndex()} : std::nullopt);
+    rDoc.getIDocumentMarkAccess()->deleteMarks(rStt, rEnd, pSaveBkmk,
+        oStartContentIdx,
+        oEndContentIdx);
 
     // Copy all Redlines which are in the move area into an array
     // which holds all position information as offset.
@@ -1929,11 +1921,11 @@ void DelBookmarks(
         // Is at position?
         auto [pRStt, pREnd] = pRedl->StartEnd();
 
-        if( lcl_Greater( *pRStt, rStt, pSttIdx ) && lcl_Lower( *pRStt, rEnd, 
pEndIdx ))
+        if( lcl_Greater( *pRStt, rStt, oStartContentIdx ) && lcl_Lower( 
*pRStt, rEnd, oEndContentIdx ))
         {
             pRStt->nNode = rEnd;
-            if( pEndIdx )
-                pRStt->nContent = *pEndIdx;
+            if( oEndContentIdx )
+                pRStt->nContent = *oEndContentIdx;
             else
             {
                 bool bStt = true;
@@ -1955,11 +1947,11 @@ void DelBookmarks(
                     pRStt->AssignEndIndex( *pCNd );
             }
         }
-        if( lcl_Greater( *pREnd, rStt, pSttIdx ) && lcl_Lower( *pREnd, rEnd, 
pEndIdx ))
+        if( lcl_Greater( *pREnd, rStt, oStartContentIdx ) && lcl_Lower( 
*pREnd, rEnd, oEndContentIdx ))
         {
             pREnd->nNode = rStt;
-            if( pSttIdx )
-                pREnd->nContent = *pSttIdx;
+            if( oStartContentIdx )
+                pREnd->nContent = *oStartContentIdx;
             else
             {
                 bool bStt = false;
diff --git a/sw/source/core/doc/doccorr.cxx b/sw/source/core/doc/doccorr.cxx
index 1d2d625e3203..fea2385108d3 100644
--- a/sw/source/core/doc/doccorr.cxx
+++ b/sw/source/core/doc/doccorr.cxx
@@ -212,10 +212,10 @@ void SwDoc::CorrAbs(
     const SwPosition& rNewPos,
     bool bMoveCursor )
 {
-    SwPosition aStart(*rRange.Start());
-    SwPosition aEnd(*rRange.End());
+    const SwPosition& aStart(*rRange.Start());
+    const SwPosition& aEnd(*rRange.End());
 
-    DelBookmarks( aStart.nNode, aEnd.nNode, nullptr, &aStart.nContent, 
&aEnd.nContent );
+    DelBookmarks( aStart.GetNode(), aEnd.GetNode(), nullptr, 
aStart.GetContentIndex(), aEnd.GetContentIndex() );
 
     if(bMoveCursor)
         ::PaMCorrAbs(rRange, rNewPos);
@@ -227,7 +227,7 @@ void SwDoc::CorrAbs(
     const SwPosition& rNewPos,
     bool bMoveCursor )
 {
-    DelBookmarks( rStartNode, rEndNode );
+    DelBookmarks( rStartNode.GetNode(), rEndNode.GetNode() );
 
     if(bMoveCursor)
     {
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index 4329a5633088..0ac078f1d3ba 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1140,7 +1140,7 @@ static void lcl_UpdateLinksInSect( const SwBaseLink& 
rUpdLnk, SwSectionNode& rSe
         // Delete everything succeeding it
         --aIdx;
         DelFlyInRange( aIdx.GetNode(), aEndIdx.GetNode() );
-        DelBookmarks(aIdx, aEndIdx);
+        DelBookmarks(aIdx.GetNode(), aEndIdx.GetNode());
         ++aIdx;
 
         pDoc->GetNodes().Delete( aIdx, aEndIdx.GetIndex() - aIdx.GetIndex() );
diff --git a/sw/source/core/inc/mvsave.hxx b/sw/source/core/inc/mvsave.hxx
index 6ef3f92edfb1..4b553d270c8f 100644
--- a/sw/source/core/inc/mvsave.hxx
+++ b/sw/source/core/inc/mvsave.hxx
@@ -91,11 +91,11 @@ namespace o3tl {
     template<> struct typed_flags<sw::mark::RestoreMode> : 
is_typed_flags<sw::mark::RestoreMode, 3> {};
 }
 
-void DelBookmarks(const SwNodeIndex& rStt,
-    const SwNodeIndex& rEnd,
+void DelBookmarks(SwNode& rStt,
+    const SwNode& rEnd,
     std::vector< ::sw::mark::SaveBookmark> * SaveBkmk =nullptr,
-    const SwContentIndex* pSttIdx =nullptr,
-    const SwContentIndex* pEndIdx =nullptr);
+    std::optional<sal_Int32> oStartContentIdx = std::nullopt,
+    std::optional<sal_Int32> oEndContentIdx = std::nullopt);
 
 /** data structure to temporarily hold fly anchor positions relative to some
  *  location. */
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index 56bb84119571..42e60dd60302 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -225,7 +225,7 @@ SwUndoDelete::SwUndoDelete(
                         DelContentType(DelContentType::AllMask | 
DelContentType::CheckNoCntnt) );
 
         ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
-        DelBookmarks(pStt->nNode, pEnd->nNode);
+        DelBookmarks(pStt->GetNode(), pEnd->GetNode());
     }
     else
     {
@@ -236,7 +236,7 @@ SwUndoDelete::SwUndoDelete(
         if (m_nEndNode - m_nSttNode > SwNodeOffset(1)) // check for fully 
selected nodes
         {
             SwNodeIndex const start(pStt->GetNode(), +1);
-            DelBookmarks(start, pEnd->nNode);
+            DelBookmarks(start.GetNode(), pEnd->GetNode());
         }
     }
 
@@ -1202,7 +1202,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & 
rContext)
             DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
                             DelContentType(DelContentType::AllMask | 
DelContentType::CheckNoCntnt) );
 
-            DelBookmarks(rPam.GetMark()->nNode, rPam.GetPoint()->nNode);
+            DelBookmarks(rPam.GetMark()->GetNode(), 
rPam.GetPoint()->GetNode());
         }
         else
         {
@@ -1222,7 +1222,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & 
rContext)
             DelContentIndex( *rPam.GetMark(), *rPam.GetPoint(),
                             DelContentType(DelContentType::AllMask | 
DelContentType::CheckNoCntnt) );
 
-            DelBookmarks( rPam.GetMark()->nNode, rPam.GetPoint()->nNode );
+            DelBookmarks( rPam.GetMark()->GetNode(), 
rPam.GetPoint()->GetNode() );
         }
         else
         {

Reply via email to