summaryrefslogtreecommitdiff
path: root/sw/qa/extras/mailmerge
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-08-11 18:39:20 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2016-08-29 13:13:17 +0200
commitd943d4faf92f0b86c25f3cd6fe77ed8a7d4905d1 (patch)
tree620b5623841fe6480e6e4f9e278a59f8d57dbc1d /sw/qa/extras/mailmerge
parent345b7023b80587e1a022ff7d2ce16e8afb23d9c5 (diff)
Fix SwDoc::AppendDoc for trailing sections
We already treat the StartOfContent node special in the CopyRange function to prevent merging of SwTextNodes. For trailing sections, we have to expand the code to treat EndOfContent special too, because the supplied SwPaM range is handled as [mark, point[, so it previously missed the section end node, which resulted in "unhiding" the last section, if it was the last node in the document. Change-Id: Ie094e2a0182647a49c9ba45d08a7dd2cabe667c6
Diffstat (limited to 'sw/qa/extras/mailmerge')
-rw-r--r--sw/qa/extras/mailmerge/data/sections_first_last.odtbin0 -> 9010 bytes
-rw-r--r--sw/qa/extras/mailmerge/mailmerge.cxx38
2 files changed, 38 insertions, 0 deletions
diff --git a/sw/qa/extras/mailmerge/data/sections_first_last.odt b/sw/qa/extras/mailmerge/data/sections_first_last.odt
new file mode 100644
index 000000000000..5a92adb0838d
--- /dev/null
+++ b/sw/qa/extras/mailmerge/data/sections_first_last.odt
Binary files differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 4b2e8ef05794..84331cc8b4cf 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -32,6 +32,7 @@
#include <edtwin.hxx>
#include <olmenu.hxx>
#include <cmdid.h>
+#include <pagefrm.hxx>
/**
* Maps database URIs to the registered database names for quick lookups
@@ -531,5 +532,42 @@ DECLARE_SHELL_MAILMERGE_TEST_SELECTION(testTdf95292, "linked-labels.odt", "10-te
CPPUNIT_ASSERT_EQUAL( sal_uInt16( 5 ), pWrtShell->GetPhyPageNum() );
}
+DECLARE_SHELL_MAILMERGE_TEST(test_sections_first_last, "sections_first_last.odt", "10-testing-addresses.ods", "testing-addresses")
+{
+ // A document with a leading, middle and trailing section
+ // Originally we were losing the trailing section during merge
+ executeMailMerge();
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+
+ // Get the size of the document in nodes
+ SwDoc *pDoc = pTextDoc->GetDocShell()->GetDoc();
+ sal_uLong nSize = pDoc->GetNodes().GetEndOfContent().GetIndex() - pDoc->GetNodes().GetEndOfExtras().GetIndex();
+ nSize -= 2; // The common start and end node
+ CPPUNIT_ASSERT_EQUAL( sal_uLong(13), nSize );
+
+ SwXTextDocument* pTextDocMM = dynamic_cast<SwXTextDocument *>(mxMMComponent.get());
+ CPPUNIT_ASSERT(pTextDocMM);
+
+ SwDoc *pDocMM = pTextDocMM->GetDocShell()->GetDoc();
+ sal_uLong nSizeMM = pDocMM->GetNodes().GetEndOfContent().GetIndex() - pDocMM->GetNodes().GetEndOfExtras().GetIndex();
+ nSizeMM -= 2;
+ CPPUNIT_ASSERT_EQUAL( sal_uLong(10 * nSize), nSizeMM );
+
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16(19), pDocMM->GetDocShell()->GetWrtShell()->GetPhyPageNum() );
+
+ // All even pages should be empty, all sub-documents have two pages
+ const SwRootFrame* pLayout = pDocMM->getIDocumentLayoutAccess().GetCurrentLayout();
+ const SwPageFrame* pPageFrm = static_cast<const SwPageFrame*>( pLayout->Lower() );
+ while ( pPageFrm )
+ {
+ bool bOdd = (1 == (pPageFrm->GetPhyPageNum() % 2));
+ CPPUNIT_ASSERT_EQUAL( !bOdd, pPageFrm->IsEmptyPage() );
+ CPPUNIT_ASSERT_EQUAL( sal_uInt16( bOdd ? 1 : 2 ), pPageFrm->GetVirtPageNum() );
+ pPageFrm = static_cast<const SwPageFrame*>( pPageFrm->GetNext() );
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */