summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-01-02 02:07:24 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2016-01-02 03:51:10 +0100
commit480e943f0100154fa82942db092ed1f66b76ef66 (patch)
treefdf4f99a03cdf816deea81d9b251b0af4609f134
parentc91024891ff10c2ae01e11a28a9aecca2f36b6c3 (diff)
tdf#92623 MM: add unit test
Adds the missing unit test to the bugfix. Actually the original bug was a crash, so this just does some test on the resulting MM document. Change-Id: I4c9f031e57157fe5744aa8290b7503b7e1990fc7
-rw-r--r--sw/qa/extras/mailmerge/data/tdf92623.odtbin0 -> 12615 bytes
-rw-r--r--sw/qa/extras/mailmerge/mailmerge.cxx51
2 files changed, 51 insertions, 0 deletions
diff --git a/sw/qa/extras/mailmerge/data/tdf92623.odt b/sw/qa/extras/mailmerge/data/tdf92623.odt
new file mode 100644
index 000000000000..3dea8317c533
--- /dev/null
+++ b/sw/qa/extras/mailmerge/data/tdf92623.odt
Binary files differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 992ddd5ddeb0..f3598092871d 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -412,5 +412,56 @@ DECLARE_SHELL_MAILMERGE_TEST(testTdf90230, "empty.odt", "10-testing-addresses.od
executeMailMerge();
}
+DECLARE_SHELL_MAILMERGE_TEST(testTdf92623, "tdf92623.odt", "10-testing-addresses.ods", "testing-addresses")
+{
+ // Copying bookmarks for MM was broken because of the StartOfContent node copy
+ // copyied marks were off by one
+ executeMailMerge();
+
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ IDocumentMarkAccess const *pIDMA = pTextDoc->GetDocShell()->GetDoc()->getIDocumentMarkAccess();
+ // There is just one mark...
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pIDMA->getAllMarksCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), pIDMA->getBookmarksCount());
+ IDocumentMarkAccess::const_iterator_t mark = pIDMA->getAllMarksBegin();
+ // and it's a TEXT_FIELDMARK
+ CPPUNIT_ASSERT_EQUAL( sal_Int32(IDocumentMarkAccess::GetType( **mark )),
+ sal_Int32(IDocumentMarkAccess::MarkType::TEXT_FIELDMARK ) );
+ sal_uLong src_pos = (*mark)->GetMarkPos().nNode.GetIndex();
+
+ // Get the size of the document in nodes
+ SwDoc *doc = pTextDoc->GetDocShell()->GetDoc();
+ sal_uLong size = doc->GetNodes().GetEndOfContent().GetIndex() - doc->GetNodes().GetEndOfExtras().GetIndex();
+ CPPUNIT_ASSERT_EQUAL( sal_uLong(13), size );
+ size -= 2; // For common start and end nodes
+
+ // Iterate over all field marks in the target document and check that they
+ // are positioned at a multitude of the document size
+ SwXTextDocument* pMMTextDoc = dynamic_cast<SwXTextDocument *>(mxMMComponent.get());
+ CPPUNIT_ASSERT(pMMTextDoc);
+ pIDMA = pMMTextDoc->GetDocShell()->GetDoc()->getIDocumentMarkAccess();
+ // The target document has the duplicated amount of bookmarks
+ // as the helping uno bookmark from the mail merge is left in the doc
+ // TODO should be fixed!
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(20), pIDMA->getAllMarksCount());
+ std::set<sal_uLong> pages;
+ sal_Int32 countFieldMarks = 0;
+ for( mark = pIDMA->getAllMarksBegin(); mark != pIDMA->getAllMarksEnd(); ++mark )
+ {
+ IDocumentMarkAccess::MarkType markType = IDocumentMarkAccess::GetType( **mark );
+ if( markType == IDocumentMarkAccess::MarkType::TEXT_FIELDMARK )
+ {
+ sal_uLong pos = (*mark)->GetMarkPos().nNode.GetIndex() - src_pos;
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(0), pos % size);
+ CPPUNIT_ASSERT(pages.insert(pos).second);
+ countFieldMarks++;
+ }
+ else // see previous TODO
+ CPPUNIT_ASSERT_EQUAL( sal_Int32(markType), sal_Int32(IDocumentMarkAccess::MarkType::UNO_BOOKMARK) );
+ }
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(10), countFieldMarks);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */