[Libreoffice-commits] core.git: sw/qa

Eilidh McAdam eilidh.mcadam at itomig.de
Fri Dec 19 09:28:31 PST 2014


 sw/qa/extras/ooxmlexport/data/fixed-date-field.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx       |   22 ++++++++++++++++++++
 2 files changed, 22 insertions(+)

New commits:
commit 8ab2b17015592a6cdc8247b8bc245ff5f88bfec9
Author: Eilidh McAdam <eilidh.mcadam at itomig.de>
Date:   Thu Dec 11 00:26:41 2014 +0000

    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 at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

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 0000000..960e2db
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 d2a4c7f..7d18e3e 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: */


More information about the Libreoffice-commits mailing list