From 8ab2b17015592a6cdc8247b8bc245ff5f88bfec9 Mon Sep 17 00:00:00 2001 From: Eilidh McAdam Date: Thu, 11 Dec 2014 00:26:41 +0000 Subject: 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 Tested-by: Miklos Vajna --- .../extras/ooxmlexport/data/fixed-date-field.docx | Bin 0 -> 5066 bytes sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 22 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 sw/qa/extras/ooxmlexport/data/fixed-date-field.docx diff --git a/sw/qa/extras/ooxmlexport/data/fixed-date-field.docx b/sw/qa/extras/ooxmlexport/data/fixed-date-field.docx new file mode 100644 index 000000000000..960e2db80873 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fixed-date-field.docx differ 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 xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference xFields(xFieldsAccess->createEnumeration()); + uno::Reference xField(xFields->nextElement(), uno::UNO_QUERY); + + // Check fixed property was imported and date value was parsed correctly + CPPUNIT_ASSERT_EQUAL(true, getProperty(xField, "IsFixed")); + com::sun::star::util::DateTime date = getProperty(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: */ -- cgit v1.2.3