sw/qa/extras/inc/swmodeltestbase.hxx | 9 ++---- sw/qa/extras/mailmerge/data/tdf78611.odt |binary sw/qa/extras/mailmerge/mailmerge.cxx | 46 +++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 5 deletions(-)
New commits: commit 7bbc1fd443ff0b137206ad279eaed7bd4d5ec6ec Author: Serge Krot <serge.k...@cib.de> AuthorDate: Wed Dec 12 15:18:05 2018 +0100 Commit: Thorsten Behrens <thorsten.behr...@cib.de> CommitDate: Thu Dec 13 00:38:32 2018 +0100 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.behr...@cib.de> diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index d3d64c8ea434..bbe675e23bbe 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -349,8 +349,8 @@ protected: return false; } -private: - void dumpLayout() +protected: + void dumpLayout(uno::Reference< lang::XComponent > & rComponent) { // create the xml writer mpXmlBuffer = xmlBufferCreate(); @@ -358,7 +358,7 @@ private: 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 @@ private: xmlFreeTextWriter(pXmlWriter); } -protected: void discardDumpedLayout() { if (mpXmlBuffer) @@ -429,7 +428,7 @@ protected: 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 000000000000..577597654740 Binary files /dev/null and b/sw/qa/extras/mailmerge/data/tdf78611.odt differ diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index ebcea54e764d..6efa3aaa4f6b 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -276,6 +276,17 @@ public: 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(testTdf62364, "tdf62364.odt", "10-testing-addresses } } +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: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits