sw/source/core/doc/docnew.cxx |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

New commits:
commit 228537cebb6ffa75e7e2270fb7bfd6e91fa6ba2c
Author:     Michael Weghorn <[email protected]>
AuthorDate: Fri Apr 1 08:14:30 2022 +0200
Commit:     Michael Weghorn <[email protected]>
CommitDate: Fri Apr 1 10:00:44 2022 +0200

    trac#34262 Revert "tdf#144565 sw_redlinehide: fix mailmerge when flys 
anchored at last node"
    
    Causes significant performance regressions
    with WollMux mail merge, so revert for now.
    
    Mail merge with the test doc from tdf#144565 at
    least already fails with LO 6.1 (Build-ID 2103)
    on moviA as well, so for now, better live with an existing
    bug than introducing a new one in our LO 6.4 based
    releases.
    
    This reverts commit beae7a08c30f2f368708dbc7a9988ecfad08af60.
    
    Change-Id: I6271ffe3f3036df6e16d93389ad21419b541e03e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132394
    Tested-by: Michael Weghorn <[email protected]>
    Reviewed-by: Michael Weghorn <[email protected]>

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index e125e44420b7..984f2335bc45 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1054,14 +1054,19 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, 
sal_uInt16 const nStartPageNu
         {
             SwNodeIndex aBreakIdx( GetNodes().GetEndOfContent(), -1 );
             SwPosition aBreakPos( aBreakIdx );
-            // insert new node - will be removed at the end...
-            // (don't SplitNode() as it may move flys to the wrong node)
-            getIDocumentContentOperations().AppendTextNode(aBreakPos);
-            SwFormatPageDesc pageDesc(pTargetPageDesc);
-            pageDesc.SetNumOffset(nStartPageNumber);
-            // set break on the last paragraph
-            getIDocumentContentOperations().InsertPoolItem(SwPaM(aBreakPos),
-                    pageDesc, SetAttrMode::DEFAULT, pTargetShell->GetLayout());
+            // InsertPageBreak just works on SwTextNode nodes, so make
+            // sure the last node is one!
+            bool bIsTextNode = aBreakIdx.GetNode().IsTextNode();
+            if ( !bIsTextNode )
+                getIDocumentContentOperations().AppendTextNode( aBreakPos );
+            const OUString name = pTargetPageDesc->GetName();
+            pTargetShell->InsertPageBreak( &name, nStartPageNumber );
+            if ( !bIsTextNode )
+            {
+                pTargetShell->SttEndDoc( false );
+                --aBreakIdx;
+                GetNodes().Delete( aBreakIdx );
+            }
 
             // There is now a new empty text node on the new page. If it has
             // any marks, those are from the previous page: move them back

Reply via email to