sw/inc/ndarr.hxx                  |    2 +-
 sw/source/core/docnode/ndsect.cxx |   10 +++++-----
 sw/source/core/docnode/ndtbl.cxx  |   16 +++++++---------
 sw/source/core/undo/untbl.cxx     |    2 +-
 4 files changed, 14 insertions(+), 16 deletions(-)

New commits:
commit 8d99841e2c2884d3305d1643b95f88f460bb8b6e
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Aug 10 18:34:46 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Aug 13 10:13:00 2022 +0200

    pass SwNode instead of SwNodeIndex to SwNodes::MergeTable
    
    part of the process of hiding the internals of SwPosition
    
    Change-Id: Ia3b2563c23aaaf86f58b56bcdd60ded3c9d8404f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138219
    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 e95d5bf7e7dc..386b01aae663 100644
--- a/sw/inc/ndarr.hxx
+++ b/sw/inc/ndarr.hxx
@@ -293,7 +293,7 @@ public:
     SwTableNode* SplitTable( const SwNodeIndex& rPos, bool bAfter = true,
                                 bool bCalcNewSize = false );
     /// Two Tables that are following one another are merged.
-    bool MergeTable( const SwNodeIndex& rPos, bool bWithPrev = true,
+    bool MergeTable( SwNode& rPos, bool bWithPrev = true,
                     sal_uInt16 nMode = 0 );
 
     /// Insert a new SwSection.
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 9f8c6833ff3d..7b0641da54dc 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -3508,8 +3508,7 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool 
bWithPrev, sal_uInt16 nMode
     getIDocumentFieldsAccess().UpdateTableFields( &aMsgHint );
 
     // The actual merge
-    SwNodeIndex aIdx( bWithPrev ? *pTableNd : *pDelTableNd );
-    bool bRet = rNds.MergeTable( aIdx, !bWithPrev, nMode );
+    bool bRet = rNds.MergeTable( bWithPrev ? *pTableNd : *pDelTableNd, 
!bWithPrev, nMode );
 
     if( pHistory )
     {
@@ -3527,10 +3526,9 @@ bool SwDoc::MergeTable( const SwPosition& rPos, bool 
bWithPrev, sal_uInt16 nMode
     return bRet;
 }
 
-bool SwNodes::MergeTable( const SwNodeIndex& rPos, bool bWithPrev,
-                            sal_uInt16 nMode )
+bool SwNodes::MergeTable( SwNode& rPos, bool bWithPrev, sal_uInt16 nMode )
 {
-    SwTableNode* pDelTableNd = rPos.GetNode().GetTableNode();
+    SwTableNode* pDelTableNd = rPos.GetTableNode();
     OSL_ENSURE( pDelTableNd, "Where did the TableNode go?" );
 
     SwTableNode* pTableNd = (*this)[ rPos.GetIndex() - 1]->FindTableNode();
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 7e96d8fe04bb..e27f534bd8a4 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -2893,7 +2893,7 @@ void SwUndoSplitTable::UndoImpl(::sw::UndoRedoContext & 
rContext)
     default: break;
     }
 
-    pDoc->GetNodes().MergeTable( rIdx );
+    pDoc->GetNodes().MergeTable( rIdx.GetNode() );
 
     if( m_pHistory )
     {
commit 0cedac9c64fe4d636be66d43d89c4c939865359b
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Aug 10 08:19:05 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sat Aug 13 10:12:43 2022 +0200

    no need to allocate these on the heap
    
    Change-Id: I692428cc8821f3dea53b4d6b52ced965b17f2ec4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138218
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index 538dcd3beef4..ac731e549823 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -916,13 +916,13 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex 
const& rNdIdx,
     // but by simply rewiring them
     bool bInsFrame = bCreateFrames && !pSectNd->GetSection().IsHiddenFlag() &&
                    GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell();
-    SwNode2LayoutSaveUpperFrames *pNode2Layout = nullptr;
+    std::optional<SwNode2LayoutSaveUpperFrames> oNode2Layout;
     if( bInsFrame )
     {
         SwNodeIndex aTmp( *pSectNd );
         if( !pSectNd->GetNodes().FindPrvNxtFrameNode( aTmp, 
pSectNd->EndOfSectionNode() ) )
             // Collect all Uppers
-            pNode2Layout = new SwNode2LayoutSaveUpperFrames(*pSectNd);
+            oNode2Layout.emplace(*pSectNd);
     }
 
     // Set the right StartNode for all in this Area
@@ -966,11 +966,11 @@ SwSectionNode* SwNodes::InsertTextSection(SwNodeIndex 
const& rNdIdx,
 
     if( bInsFrame )
     {
-        if( pNode2Layout )
+        if( oNode2Layout )
         {
             SwNodeOffset nIdx = pSectNd->GetIndex();
-            pNode2Layout->RestoreUpperFrames( pSectNd->GetNodes(), nIdx, nIdx 
+ 1 );
-            delete pNode2Layout;
+            oNode2Layout->RestoreUpperFrames( pSectNd->GetNodes(), nIdx, nIdx 
+ 1 );
+            oNode2Layout.reset();
         }
         else
             pSectNd->MakeOwnFrames(&aInsPos);
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index c962688f9dd5..9f8c6833ff3d 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -1586,12 +1586,12 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, 
sal_Unicode cCh,
         return false;
 
     // If the Table was alone in a Section, create the Frames via the Table's 
Upper
-    SwNode2LayoutSaveUpperFrames * pNode2Layout = nullptr;
+    std::optional<SwNode2LayoutSaveUpperFrames> oNode2Layout;
     SwNodeIndex aFrameIdx( rRange.aStart );
     SwNode* pFrameNd = FindPrvNxtFrameNode( aFrameIdx, &rRange.aEnd.GetNode() 
);
     if( !pFrameNd )
         // Collect all Uppers
-        pNode2Layout = new SwNode2LayoutSaveUpperFrames(*pTableNd);
+        oNode2Layout.emplace(*pTableNd);
 
     // Delete the Frames
     pTableNd->DelFrames();
@@ -1630,9 +1630,9 @@ bool SwNodes::TableToText( const SwNodeRange& rRange, 
sal_Unicode cCh,
     SwNodeOffset nStt = aDelRg.aStart.GetIndex(), nEnd = 
aDelRg.aEnd.GetIndex();
     if( !pFrameNd )
     {
-        pNode2Layout->RestoreUpperFrames( *this,
+        oNode2Layout->RestoreUpperFrames( *this,
                         aDelRg.aStart.GetIndex(), aDelRg.aEnd.GetIndex() );
-        delete pNode2Layout;
+        oNode2Layout.reset();
     }
     else
     {

Reply via email to