sw/inc/ndarr.hxx                             |    2 +-
 sw/source/core/doc/DocumentLayoutManager.cxx |    5 ++---
 sw/source/core/doc/docdesc.cxx               |   10 ++++------
 sw/source/core/doc/docfmt.cxx                |    5 ++---
 sw/source/core/doc/docredln.cxx              |    4 ++--
 sw/source/core/docnode/nodes.cxx             |    6 +++---
 sw/source/core/undo/undobj.cxx               |    2 +-
 7 files changed, 15 insertions(+), 19 deletions(-)

New commits:
commit 235d12c5f051b9c40f3e007b3b1e49e8753b5c19
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Aug 13 15:40:35 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Aug 13 17:05:16 2022 +0200

    pass SwNode instead of SwNodeIndex to MakeEmptySection
    
    part of the process of hiding the internals of SwPosition
    
    Change-Id: Ic24e646571eec0ff764d307e20e784d39d8411e4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138230
    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 ebf7696a7707..d2a58d988074 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -202,7 +202,7 @@ public:
     /** Create an empty section of Start- and EndNote. It may be called
        only if a new section with content is to be created,
        e.g. at filters/Undo/... */
-    static SwStartNode* MakeEmptySection( const SwNodeIndex& rIdx,
+    static SwStartNode* MakeEmptySection( SwNode& rWhere,
                                     SwStartNodeType = SwNormalStartNode );
 
     /// Implementations of "Make...Node" are in the given .cxx-files.
diff --git a/sw/source/core/doc/DocumentLayoutManager.cxx 
b/sw/source/core/doc/DocumentLayoutManager.cxx
index c56bda3e01a9..17cf60cde4aa 100644
--- a/sw/source/core/doc/DocumentLayoutManager.cxx
+++ b/sw/source/core/doc/DocumentLayoutManager.cxx
@@ -382,12 +382,11 @@ SwFrameFormat *DocumentLayoutManager::CopyLayoutFormat(
         const SwNode& rCSttNd = 
rSource.GetContent().GetContentIdx()->GetNode();
         SwNodeRange aRg( rCSttNd, SwNodeOffset(1), *rCSttNd.EndOfSectionNode() 
);
 
-        SwNodeIndex aIdx( m_rDoc.GetNodes().GetEndOfAutotext() );
-        SwStartNode* pSttNd = SwNodes::MakeEmptySection( aIdx, SwFlyStartNode 
);
+        SwStartNode* pSttNd = SwNodes::MakeEmptySection( 
m_rDoc.GetNodes().GetEndOfAutotext(), SwFlyStartNode );
 
         // Set the Anchor/ContentIndex first.
         // Within the copying part, we can access the values (DrawFormat in 
Headers and Footers)
-        aIdx = *pSttNd;
+        SwNodeIndex aIdx( *pSttNd );
         SwFormatContent aAttr( rSource.GetContent() );
         aAttr.SetNewContentIdx( &aIdx );
         pDest->SetFormatAttr( aAttr );
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 0098be0331f3..2060332d9d6a 100644
--- a/sw/source/core/doc/docdesc.cxx
+++ b/sw/source/core/doc/docdesc.cxx
@@ -295,12 +295,11 @@ void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, 
const SwFormatHeader &rHe
                     // The section which the right header attribute is pointing
                     // is copied, and the Index to the StartNode is set to
                     // the left or first header attribute.
-                    SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
-                    SwStartNode* pSttNd = SwNodes::MakeEmptySection( aTmp, 
SwHeaderStartNode );
+                    SwStartNode* pSttNd = SwNodes::MakeEmptySection( 
GetNodes().GetEndOfAutotext(), SwHeaderStartNode );
                     SwNodeRange aRange( aRCnt.GetContentIdx()->GetNode(), 
SwNodeOffset(0),
                                 
*aRCnt.GetContentIdx()->GetNode().EndOfSectionNode() );
                     GetNodes().Copy_( aRange, *pSttNd->EndOfSectionNode(), 
false );
-                    aTmp = *pSttNd;
+                    SwNodeIndex aTmp( *pSttNd );
                     
GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRange, nullptr, aTmp);
                     SwPaM const source(aRange.aStart, aRange.aEnd);
                     SwPosition dest(aTmp);
@@ -374,12 +373,11 @@ void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, 
const SwFormatFooter &rFo
                     // The section to which the right footer attribute is 
pointing
                     // is copied, and the Index to the StartNode is set to
                     // the left footer attribute.
-                    SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
-                    SwStartNode* pSttNd = SwNodes::MakeEmptySection( aTmp, 
SwFooterStartNode );
+                    SwStartNode* pSttNd = SwNodes::MakeEmptySection( 
GetNodes().GetEndOfAutotext(), SwFooterStartNode );
                     SwNodeRange aRange( aRCnt.GetContentIdx()->GetNode(), 
SwNodeOffset(0),
                                 
*aRCnt.GetContentIdx()->GetNode().EndOfSectionNode() );
                     GetNodes().Copy_( aRange, *pSttNd->EndOfSectionNode(), 
false );
-                    aTmp = *pSttNd;
+                    SwNodeIndex aTmp( *pSttNd );
                     
GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRange, nullptr, aTmp);
                     SwPaM const source(aRange.aStart, aRange.aEnd);
                     SwPosition dest(aTmp);
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index fa48318b1163..dfa71cf341df 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1394,16 +1394,15 @@ void SwDoc::CopyPageDescHeaderFooterImpl( bool 
bCpyHeader,
     {
         if( pContent->GetContentIdx() )
         {
-            SwNodeIndex aTmpIdx( GetNodes().GetEndOfAutotext() );
             const SwNodes& rSrcNds = rSrcFormat.GetDoc()->GetNodes();
-            SwStartNode* pSttNd = SwNodes::MakeEmptySection( aTmpIdx,
+            SwStartNode* pSttNd = SwNodes::MakeEmptySection( 
GetNodes().GetEndOfAutotext(),
                                             bCpyHeader
                                                 ? SwHeaderStartNode
                                                 : SwFooterStartNode );
             const SwNode& rCSttNd = pContent->GetContentIdx()->GetNode();
             SwNodeRange aRg( rCSttNd, SwNodeOffset(0), 
*rCSttNd.EndOfSectionNode() );
             rSrcNds.Copy_( aRg, *pSttNd->EndOfSectionNode() );
-            aTmpIdx = *pSttNd;
+            SwNodeIndex aTmpIdx( *pSttNd );
             
rSrcFormat.GetDoc()->GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRg,
 nullptr, aTmpIdx);
             // TODO: investigate calling CopyWithFlyInFly?
             SwPaM const source(aRg.aStart, aRg.aEnd);
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 4213ae9019a0..2e545622bd6e 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1549,7 +1549,7 @@ void SwRangeRedline::MoveToSection()
         }
         else
         {
-            pSttNd = SwNodes::MakeEmptySection( SwNodeIndex( 
rNds.GetEndOfRedlines() ) );
+            pSttNd = SwNodes::MakeEmptySection( rNds.GetEndOfRedlines() );
 
             SwPosition aPos( *pSttNd->EndOfSectionNode() );
             rDoc.getIDocumentContentOperations().MoveRange( aPam, aPos,
@@ -1621,7 +1621,7 @@ void SwRangeRedline::CopyToSection()
     }
     else
     {
-        pSttNd = SwNodes::MakeEmptySection( SwNodeIndex( 
rNds.GetEndOfRedlines() ) );
+        pSttNd = SwNodes::MakeEmptySection( rNds.GetEndOfRedlines() );
 
         if( pCEndNd )
         {
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index c01cbf7ee8c9..891d2f7017c0 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -1916,11 +1916,11 @@ void SwNodes::DelDummyNodes( const SwNodeRange& rRg )
     }
 }
 
-SwStartNode* SwNodes::MakeEmptySection( const SwNodeIndex& rIdx,
+SwStartNode* SwNodes::MakeEmptySection( SwNode& rWhere,
                                         SwStartNodeType eSttNdTyp )
 {
-    SwStartNode* pSttNd = new SwStartNode( rIdx.GetNode(), SwNodeType::Start, 
eSttNdTyp );
-    new SwEndNode( rIdx.GetNode(), *pSttNd );
+    SwStartNode* pSttNd = new SwStartNode( rWhere, SwNodeType::Start, 
eSttNdTyp );
+    new SwEndNode( rWhere, *pSttNd );
     return pSttNd;
 }
 
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 3fc087bfc443..8e0152e43f63 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -1287,7 +1287,7 @@ void SwUndoSaveSection::RestoreSection( SwDoc* pDoc, 
SwNodeIndex* pIdx,
     SwNodeIndex aSttIdx( pDoc->GetNodes(), m_nStartPos );
 
     // move the content from UndoNodes array into Fly
-    SwStartNode* pSttNd = SwNodes::MakeEmptySection( aSttIdx,
+    SwStartNode* pSttNd = SwNodes::MakeEmptySection( aSttIdx.GetNode(),
                                             
static_cast<SwStartNodeType>(nSectType) );
 
     RestoreSection( pDoc, *pSttNd->EndOfSectionNode() );

Reply via email to