summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/mailmerge/data/section_ps.odtbin0 -> 9011 bytes
-rw-r--r--sw/qa/extras/mailmerge/mailmerge.cxx33
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx9
3 files changed, 42 insertions, 0 deletions
diff --git a/sw/qa/extras/mailmerge/data/section_ps.odt b/sw/qa/extras/mailmerge/data/section_ps.odt
new file mode 100644
index 000000000000..dd9704845fac
--- /dev/null
+++ b/sw/qa/extras/mailmerge/data/section_ps.odt
Binary files differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 12fe9cade56b..1e1d94efb572 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -1055,5 +1055,38 @@ DECLARE_FILE_MAILMERGE_TEST(testTdf122156_file, "linked-with-condition.odt", "5-
}
}
+DECLARE_SHELL_MAILMERGE_TEST(testTdf121168, "section_ps.odt", "4_v01.ods", "Tabelle1")
+{
+ // A document starting with a section on a page with non-default page style with header
+ executeMailMerge();
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxMMComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ // 4 documents 1 page each, starting at odd page numbers => 7
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(7), pTextDoc->GetDocShell()->GetWrtShell()->GetPhyPageNum());
+
+ SwDoc* pDocMM = pTextDoc->GetDocShell()->GetDoc();
+ sal_uLong nSizeMM = pDocMM->GetNodes().GetEndOfContent().GetIndex()
+ - pDocMM->GetNodes().GetEndOfExtras().GetIndex() - 2;
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(16), nSizeMM);
+
+ // All even pages should be empty, all sub-documents have one page
+ const SwRootFrame* pLayout = pDocMM->getIDocumentLayoutAccess().GetCurrentLayout();
+ const SwPageFrame* pPageFrm = static_cast<const SwPageFrame*>(pLayout->Lower());
+ while (pPageFrm)
+ {
+ sal_uInt16 nPageNum = pPageFrm->GetPhyPageNum();
+ bool bOdd = (1 == (nPageNum % 2));
+ CPPUNIT_ASSERT_EQUAL(!bOdd, pPageFrm->IsEmptyPage());
+ CPPUNIT_ASSERT_EQUAL(sal_uInt16(bOdd ? 1 : 2), pPageFrm->GetVirtPageNum());
+ if (bOdd)
+ {
+ const SwPageDesc* pDesc = pPageFrm->GetPageDesc();
+ CPPUNIT_ASSERT_EQUAL(OUString("Teststyle" + OUString::number(nPageNum / 2 + 1)),
+ pDesc->GetName());
+ }
+ pPageFrm = static_cast<const SwPageFrame*>(pPageFrm->GetNext());
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 47691cf0d181..2e70ccaea415 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1455,6 +1455,15 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
// ExpFields update during printing, generation of preview, etc.
pWorkShell->LockExpFields();
pWorkShell->CalcLayout();
+ // tdf#121168: Now force correct page descriptions applied to page frames. Without
+ // this, e.g., page frames starting with sections could have page descriptions set
+ // wrong. This would lead to wrong page styles applied in SwDoc::AppendDoc below.
+ pWorkShell->GetViewOptions()->SetIdle(true);
+ for (auto aLayout : pWorkShell->GetDoc()->GetAllLayouts())
+ {
+ aLayout->FreezeLayout(false);
+ aLayout->AllCheckPageDescs();
+ }
}
lcl_emitEvent(SfxEventHintId::SwEventFieldMerge, STR_SW_EVENT_FIELD_MERGE, xWorkDocSh);