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 54423d5c51cb7733cb8766733ceec21d128c3bff Author: Serge Krot <serge.k...@cib.de> AuthorDate: Wed Dec 12 15:18:05 2018 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Aug 24 11:04:05 2021 +0200 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> (cherry picked from commit 7bbc1fd443ff0b137206ad279eaed7bd4d5ec6ec) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120913 Tested-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 5a11a088b9ba..df717abfb2d9 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -348,8 +348,8 @@ protected: return false; } -private: - void dumpLayout() +protected: + void dumpLayout(uno::Reference< lang::XComponent > & rComponent) { // create the xml writer mpXmlBuffer = xmlBufferCreate(); @@ -357,7 +357,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(); @@ -368,7 +368,6 @@ private: xmlFreeTextWriter(pXmlWriter); } -protected: void discardDumpedLayout() { if (mpXmlBuffer) @@ -428,7 +427,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 5b6411c153c0..9c84c312ef1e 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; @@ -1041,5 +1052,40 @@ DECLARE_FILE_MAILMERGE_TEST(testTdf123057_file, "pagecounttest.ott", "db_pagecou } } +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: */