tdf#78611 mailmerge: new unit tests: numbering in headings
Change-Id: I8672376dabcdc0011c59bb9ac5c32b8dbb88396d
Reviewed-on: https://gerrit.libreoffice.org/65035
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index d3d64c8..bbe675e 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -349,8 +349,8 @@
return false;
}
private:
void dumpLayout()
protected:
void dumpLayout(uno::Reference< lang::XComponent > & rComponent)
{
// create the xml writer
mpXmlBuffer = xmlBufferCreate();
@@ -358,7 +358,7 @@
xmlTextWriterStartDocument(pXmlWriter, nullptr, nullptr, nullptr);
// create the dump
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(rComponent.get());
CPPUNIT_ASSERT(pTextDoc);
SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
@@ -369,7 +369,6 @@
xmlFreeTextWriter(pXmlWriter);
}
protected:
void discardDumpedLayout()
{
if (mpXmlBuffer)
@@ -429,7 +428,7 @@
xmlDocPtr parseLayoutDump()
{
if (!mpXmlBuffer)
dumpLayout();
dumpLayout(mxComponent);
return xmlParseMemory(reinterpret_cast<const char*>(xmlBufferContent(mpXmlBuffer)), xmlBufferLength(mpXmlBuffer));
}
diff --git a/sw/qa/extras/mailmerge/data/tdf78611.odt b/sw/qa/extras/mailmerge/data/tdf78611.odt
new file mode 100644
index 0000000..5775976
--- /dev/null
+++ b/sw/qa/extras/mailmerge/data/tdf78611.odt
Binary files differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index ebcea54..6efa3aa 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -276,6 +276,17 @@
loadMailMergeDocument( name );
}
/**
Resets currently opened layout of the original template,
and creates the layout of the document with N mails inside
(result run with text::MailMergeType::SHELL)
*/
void dumpMMLayout()
{
mpXmlBuffer = xmlBufferPtr();
dumpLayout(mxMMComponent);
}
protected:
// Returns page number of the first page of a MM document inside the large MM document (used in the SHELL case).
int documentStartPageNumber( int document ) const;
@@ -928,5 +939,40 @@
}
}
DECLARE_SHELL_MAILMERGE_TEST(testTd78611_shell, "tdf78611.odt", "10-testing-addresses.ods", "testing-addresses")
{
// prepare unit test and run
executeMailMerge();
// reset currently opened layout of the original template,
// and create the layout of the document with 10 mails inside
dumpMMLayout();
// check: each page (one page is one sub doc) has different paragraphs and header paragraphs.
// All header paragraphs should have numbering.
// check first page
CPPUNIT_ASSERT_EQUAL( OUString("1"), parseDump("/root/page[1]/body/txt[6]/Special", "rText"));
CPPUNIT_ASSERT_EQUAL( OUString("1.1"), parseDump("/root/page[1]/body/txt[8]/Special", "rText"));
CPPUNIT_ASSERT_EQUAL( OUString("1.2"), parseDump("/root/page[1]/body/txt[10]/Special", "rText"));
// check some other pages
CPPUNIT_ASSERT_EQUAL( OUString("1"), parseDump("/root/page[3]/body/txt[6]/Special", "rText"));
CPPUNIT_ASSERT_EQUAL( OUString("1.1"), parseDump("/root/page[5]/body/txt[8]/Special", "rText"));
CPPUNIT_ASSERT_EQUAL( OUString("1.2"), parseDump("/root/page[7]/body/txt[10]/Special", "rText"));
}
DECLARE_FILE_MAILMERGE_TEST(testTd78611_file, "tdf78611.odt", "10-testing-addresses.ods", "testing-addresses")
{
executeMailMerge(true);
for (int doc = 0; doc < 10; ++doc)
{
loadMailMergeDocument( doc );
CPPUNIT_ASSERT_EQUAL( OUString("1"), parseDump("/root/page[1]/body/txt[6]/Special", "rText"));
CPPUNIT_ASSERT_EQUAL( OUString("1.1"), parseDump("/root/page[1]/body/txt[8]/Special", "rText"));
CPPUNIT_ASSERT_EQUAL( OUString("1.2"), parseDump("/root/page[1]/body/txt[10]/Special", "rText"));
}
}
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */