tdf#148309 sw_redlinehide: fix mail merge performance regression
The problem is that in the call to pTargetShell->EndAllAction(), the
cursor is on the node before the newly appended one that has the page
break, and only this node is formatted (via GetFormatted()), so no new
page frames are inserted in the layout, which then creates massive
performance problems later, particularly since the bugdoc contains
multiple at-page anchored flys.
(regression from commit 42448f48bb48a13d6618a181b12840db6d85c574)
Change-Id: I05cd2a515a7f67132ab1c8c6fa0d675252ea3a15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135356
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit ff525d0d70ea9d189a430bde944b56d048b03e55)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135273
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 7aa134e..da65b29 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1102,6 +1102,11 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu
// set break on the last paragraph
getIDocumentContentOperations().InsertPoolItem(SwPaM(aBreakPos),
pageDesc, SetAttrMode::DEFAULT, pTargetShell->GetLayout());
// tdf#148309 move to the last node - so that the "flush page break"
// code below will format the frame of the node with the page break,
// which is required for new page frames to be created! Else layout
// performance will be terrible.
pTargetShell->SttEndDoc(false);
// 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
@@ -1132,6 +1137,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu
if ( !bDeletePrevious )
{
SAL_INFO( "sw.pageframe", "(Flush pagebreak AKA EndAllAction" );
assert(pTargetShell->GetCursor()->GetPoint()->nNode.GetNode().GetTextNode()->GetSwAttrSet().HasItem(RES_PAGEDESC));
pTargetShell->EndAllAction();
SAL_INFO( "sw.pageframe", "Flush changes AKA EndAllAction)" );
pTargetShell->StartAllAction();