diff options
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/mailmerge/data/tdf118845.fodt | 28 | ||||
-rw-r--r-- | sw/qa/extras/mailmerge/mailmerge.cxx | 49 |
2 files changed, 77 insertions, 0 deletions
diff --git a/sw/qa/extras/mailmerge/data/tdf118845.fodt b/sw/qa/extras/mailmerge/data/tdf118845.fodt new file mode 100644 index 000000000000..64a5180da718 --- /dev/null +++ b/sw/qa/extras/mailmerge/data/tdf118845.fodt @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:settings> + <config:config-item-set config:name="ooo:configuration-settings"> + <config:config-item config:name="CurrentDatabaseDataSource" config:type="string">4_v01</config:config-item> + <config:config-item config:name="CurrentDatabaseCommand" config:type="string">Tabelle1</config:config-item> + <config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item> + <config:config-item config:name="EmptyDbFieldHidesPara" config:type="boolean">true</config:config-item> + </config:config-item-set> + </office:settings> + <office:automatic-styles> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21cm" fo:page-height="29.7cm" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm"/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:p><text:hidden-paragraph text:condition="ooow:([4_v01.Tabelle1.Anrede] != "Frau" OR NOT [4_v01.Tabelle1.Nachname]) OR (![4_v01.Tabelle1.Nachname])"/><text:span text:style-name="T1">Dear Mrs. </text:span><text:span text:style-name="T1"><text:database-display text:table-name="Tabelle1" text:table-type="table" text:column-name="Nachname" text:database-name="4_v01"><Nachname></text:database-display></text:span><text:span text:style-name="T1">,</text:span></text:p> + <text:p><text:hidden-paragraph text:condition="ooow:[4_v01.Tabelle1.Anrede] == "Frau" OR NOT [4_v01.Tabelle1.Nachname]"/><text:span text:style-name="T1">Dear Mr. </text:span><text:span text:style-name="T1"><text:database-display text:table-name="Tabelle1" text:table-type="table" text:column-name="Nachname" text:database-name="4_v01"><Nachname></text:database-display></text:span><text:span text:style-name="T1">,</text:span></text:p> + <text:p><text:hidden-paragraph text:condition="ooow:[4_v01.Tabelle1.Nachname]"/><text:span text:style-name="T1">To whom it may concern,</text:span></text:p> + <text:p/> + </office:text> + </office:body> +</office:document>
\ No newline at end of file diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx index e21f0fe44d0c..ba4c5dd401bd 100644 --- a/sw/qa/extras/mailmerge/mailmerge.cxx +++ b/sw/qa/extras/mailmerge/mailmerge.cxx @@ -818,5 +818,54 @@ DECLARE_FILE_MAILMERGE_TEST(testEmptyValuesNewFODT, "tdf35798-new.fodt", "5-with } } +DECLARE_SHELL_MAILMERGE_TEST(testTdf118845, "tdf118845.fodt", "4_v01.ods", "Tabelle1") +{ + executeMailMerge(); + + // Both male and female greetings were shown, thus each page had 3 paragraphs + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxMMComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + sal_uInt16 nPhysPages = pTextDoc->GetDocShell()->GetWrtShell()->GetPhyPageNum(); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(7), nPhysPages); // 4 pages, each odd, and 3 blanks + + uno::Reference<text::XTextDocument> xTextDocument(mxMMComponent, uno::UNO_QUERY); + + int nParaCount = 0; + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + while (xParaEnum->hasMoreElements()) + { + xParaEnum->nextElement(); + nParaCount++; + } + CPPUNIT_ASSERT_EQUAL(8, nParaCount); + + uno::Reference<text::XTextRange> xParagraph(getParagraphOrTable(1, xTextDocument->getText()), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Dear Mrs. Mustermann1,"), xParagraph->getString()); + + xParagraph.set(getParagraphOrTable(2, xTextDocument->getText()), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString(""), xParagraph->getString()); + + xParagraph.set(getParagraphOrTable(3, xTextDocument->getText()), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Dear Mr. Mustermann2,"), xParagraph->getString()); + + xParagraph.set(getParagraphOrTable(4, xTextDocument->getText()), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString(""), xParagraph->getString()); + + xParagraph.set(getParagraphOrTable(5, xTextDocument->getText()), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Dear Mrs. Mustermann3,"), xParagraph->getString()); + + xParagraph.set(getParagraphOrTable(6, xTextDocument->getText()), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString(""), xParagraph->getString()); + + xParagraph.set(getParagraphOrTable(7, xTextDocument->getText()), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Dear Mr. Mustermann4,"), xParagraph->getString()); + + xParagraph.set(getParagraphOrTable(8, xTextDocument->getText()), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString(""), xParagraph->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |