diff options
author | Eilidh McAdam <eilidh.mcadam@itomig.de> | 2014-12-11 00:26:41 +0000 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-12-19 17:28:05 +0000 |
commit | 8ab2b17015592a6cdc8247b8bc245ff5f88bfec9 (patch) | |
tree | 6537e51dc3a7e14589354701a5c79d00bf3d0fd3 | |
parent | 8826934016d60d0a4a1e824e3f1cff814d915515 (diff) |
fdo#59886 unit tests for DOCX fixed date field import/export.
Checks fixed date fields are exported to docx and imported from
docx with correct initial value.
Change-Id: Ia6b6180b59806e624b03dc81a903ab1ac6d33307
Reviewed-on: https://gerrit.libreoffice.org/13432
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fixed-date-field.docx | bin | 0 -> 5066 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 22 |
2 files changed, 22 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fixed-date-field.docx b/sw/qa/extras/ooxmlexport/data/fixed-date-field.docx Binary files differnew file mode 100644 index 000000000000..960e2db80873 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fixed-date-field.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index d2a4c7f61fa9..7d18e3e8b0c0 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -649,6 +649,28 @@ DECLARE_OOXMLEXPORT_TEST(testSdtCompanyMultipara, "sdt-company-multipara.docx") } } +DECLARE_OOXMLEXPORT_TEST(testFixedDateFields, "fixed-date-field.docx") +{ + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + uno::Reference<beans::XPropertySet> xField(xFields->nextElement(), uno::UNO_QUERY); + + // Check fixed property was imported and date value was parsed correctly + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xField, "IsFixed")); + com::sun::star::util::DateTime date = getProperty<com::sun::star::util::DateTime>(xField, "DateTimeValue"); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)24, date.Day); + CPPUNIT_ASSERT_EQUAL((sal_uInt16)7, date.Month); + CPPUNIT_ASSERT_EQUAL((sal_Int16)2014, date.Year); + + if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) + { + // Previously, fixed fields were exported as static text ("Date (fixed)") + // Check they are now exported correctly as fldChar with fldLock attribute + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/w:fldChar", "fldLock", "true"); + } +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |