sw/source/core/edit/eddel.cxx    |    7 +++----
 sw/source/core/edit/edfcol.cxx   |    4 ++--
 sw/source/core/edit/edfld.cxx    |    6 +++---
 sw/source/core/edit/edglbldc.cxx |   29 +++++++++++------------------
 4 files changed, 19 insertions(+), 27 deletions(-)

New commits:
commit ada3cf7a8392c59932fc339357cda9c3dda5c33f
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Sep 27 20:47:42 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Sep 28 08:43:16 2022 +0200

    use more SwPosition::Assign
    
    part of the process of hiding the internals of SwPosition
    
    Change-Id: I1157df373fd1462dc44b3828ec4de667fcdc02bb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140672
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx
index d4fce54b3fa3..36a09afc3b25 100644
--- a/sw/source/core/edit/eddel.cxx
+++ b/sw/source/core/edit/eddel.cxx
@@ -71,7 +71,7 @@ void SwEditShell::DeleteSel(SwPaM& rPam, bool const 
isArtificialSelection, bool
             else
             {
                 // then go to the end of the selection
-                aDelPam.GetPoint()->nNode = rEndNd;
+                aDelPam.GetPoint()->Assign(rEndNd);
                 aDelPam.Move( fnMoveBackward, GoInContent );
             }
             // skip protected boxes
@@ -102,15 +102,14 @@ void SwEditShell::DeleteSel(SwPaM& rPam, bool const 
isArtificialSelection, bool
             while (SwTableNode const* pTableNode =
                 
pNewPam->Start()->GetNode().StartOfSectionNode()->FindTableNode())
             {
-                pNewPam->Start()->nNode = *pTableNode;
+                pNewPam->Start()->Assign(*pTableNode);
             }
             // tdf#133990 ensure section is included in SwUndoDelete
             while (SwSectionNode const* pSectionNode =
                 
pNewPam->Start()->GetNode().StartOfSectionNode()->FindSectionNode())
             {
-                pNewPam->Start()->nNode = *pSectionNode;
+                pNewPam->Start()->Assign(*pSectionNode);
             }
-            pNewPam->Start()->nContent.Assign(nullptr, 0);
             pPam = &*pNewPam;
         }
         // delete everything
diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx
index d4f1c84dc76d..02efb6b4433e 100644
--- a/sw/source/core/edit/edfcol.cxx
+++ b/sw/source/core/edit/edfcol.cxx
@@ -2223,8 +2223,8 @@ void SwEditShell::SetTextFormatColl(SwTextFormatColl 
*pFormat,
             SwPaM aPaM(*rPaM.Start(), *rPaM.End());
             if (SwTextNode* pEndTextNode = aPaM.End()->GetNode().GetTextNode())
             {
-                aPaM.Start()->nContent = 0;
-                aPaM.End()->nContent = pEndTextNode->GetText().getLength();
+                aPaM.Start()->SetContent(0);
+                aPaM.End()->SetContent(pEndTextNode->GetText().getLength());
             }
             GetDoc()->RstTextAttrs(aPaM, /*bInclRefToxMark=*/false, 
/*bExactRange=*/true, GetLayout());
 
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index 19a8a690b50b..79d9aedfc0a8 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -251,13 +251,13 @@ void SwEditShell::UpdateOneField(SwField &rField)
 
                 // Search for SwTextField ...
                 while(  bOkay
-                     && pCurStt->nContent != pCurEnd->nContent
+                     && pCurStt->GetContentIndex() != 
pCurEnd->GetContentIndex()
                      && (sw::FindAttrImpl(aPam, aFieldHint, fnMoveForward, 
aCurPam, true, GetLayout())
                           || sw::FindAttrImpl(aPam, aAnnotationFieldHint, 
fnMoveForward, aCurPam, false, GetLayout())
                           || sw::FindAttrImpl(aPam, aInputFieldHint, 
fnMoveForward, aCurPam, false, GetLayout())))
                 {
                     // if only one PaM has more than one field  ...
-                    if( aPam.Start()->nContent != pCurStt->nContent )
+                    if( aPam.Start()->GetContentIndex() != 
pCurStt->GetContentIndex() )
                         bOkay = false;
 
                     pTextField = GetTextFieldAtPos(pCurStt, 
::sw::GetTextAttrMode::Default);
@@ -275,7 +275,7 @@ void SwEditShell::UpdateOneField(SwField &rField)
                                                            pMsgHint, false);
                     }
                     // The search area is reduced by the found area:
-                    ++pCurStt->nContent;
+                    pCurStt->AdjustContent(+1);
                 }
             }
 
diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx
index c538a97b6a96..e7772379a8aa 100644
--- a/sw/source/core/edit/edglbldc.cxx
+++ b/sw/source/core/edit/edglbldc.cxx
@@ -142,18 +142,16 @@ void SwEditShell::InsertGlobalDocContent( const 
SwGlblDocContent& rInsPos,
         ClearMark();
 
     SwPosition& rPos = *pCursor->GetPoint();
-    rPos.nNode = rInsPos.GetDocPos();
+    rPos.Assign( rInsPos.GetDocPos() );
 
     bool bEndUndo = false;
     SwDoc* pMyDoc = GetDoc();
     SwTextNode *const pTextNd = rPos.GetNode().GetTextNode();
-    if( pTextNd )
-        rPos.nContent.Assign( pTextNd, 0 );
-    else
+    if( !pTextNd )
     {
         bEndUndo = true;
         pMyDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
-        --rPos.nNode;
+        rPos.Adjust(SwNodeOffset(-1));
         pMyDoc->getIDocumentContentOperations().AppendTextNode( rPos );
         pCursor->SetMark();
     }
@@ -181,19 +179,17 @@ bool SwEditShell::InsertGlobalDocContent( const 
SwGlblDocContent& rInsPos,
         ClearMark();
 
     SwPosition& rPos = *pCursor->GetPoint();
-    rPos.nNode = rInsPos.GetDocPos();
+    rPos.Assign(rInsPos.GetDocPos());
 
     bool bEndUndo = false;
     SwDoc* pMyDoc = GetDoc();
     SwTextNode* pTextNd = rPos.GetNode().GetTextNode();
-    if (pTextNd && pTextNd->GetText().getLength() && rPos.GetNodeIndex() + 1 !=
+    if (!pTextNd || !pTextNd->GetText().getLength() || rPos.GetNodeIndex() + 1 
==
         pMyDoc->GetNodes().GetEndOfContent().GetIndex() )
-        rPos.nContent.Assign( pTextNd, 0 );
-    else
     {
         bEndUndo = true;
         pMyDoc->GetIDocumentUndoRedo().StartUndo( SwUndoId::START, nullptr );
-        --rPos.nNode;
+        rPos.Adjust(SwNodeOffset(-1));
         pMyDoc->getIDocumentContentOperations().AppendTextNode( rPos );
     }
 
@@ -221,8 +217,7 @@ bool SwEditShell::InsertGlobalDocContent( const 
SwGlblDocContent& rInsPos )
         ClearMark();
 
     SwPosition& rPos = *pCursor->GetPoint();
-    rPos.nNode = rInsPos.GetDocPos() - 1;
-    rPos.nContent.Assign( nullptr, 0 );
+    rPos.Assign(rInsPos.GetDocPos() - 1);
 
     SwDoc* pMyDoc = GetDoc();
     pMyDoc->getIDocumentContentOperations().AppendTextNode( rPos );
@@ -252,8 +247,7 @@ void SwEditShell::DeleteGlobalDocContent( const 
SwGlblDocContents& rArr ,
     if( 1 == rArr.size() )
     {
         // we need at least one node!
-        rPos.nNode = nDelIdx - 1;
-        rPos.nContent.Assign( nullptr, 0 );
+        rPos.Assign(nDelIdx - 1);
 
         pMyDoc->getIDocumentContentOperations().AppendTextNode( rPos );
         ++nDelIdx;
@@ -263,13 +257,12 @@ void SwEditShell::DeleteGlobalDocContent( const 
SwGlblDocContents& rArr ,
     {
     case GLBLDOC_UNKNOWN:
         {
-            rPos.nNode = nDelIdx;
+            rPos.Assign(nDelIdx);
             pCursor->SetMark();
             if( ++nDelPos < rArr.size() )
-                rPos.nNode = rArr[ nDelPos ]->GetDocPos();
+                rPos.Assign(rArr[ nDelPos ]->GetDocPos(), -1);
             else
-                rPos.nNode = pMyDoc->GetNodes().GetEndOfContent();
-            --rPos.nNode;
+                rPos.Assign(pMyDoc->GetNodes().GetEndOfContent(), -1);
             if( !pMyDoc->getIDocumentContentOperations().DelFullPara( *pCursor 
) )
                 Delete(false);
         }

Reply via email to