summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-01-11 19:58:02 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-01-12 01:02:11 +0100
commit24613d7abf820aff639a276a1819ada8d83e9063 (patch)
tree7481aae8a237cf9130449f447910bf8b3f267dd5 /sw/qa/extras
parente8bee017fb46f47a4164517813b9d89e43a258e0 (diff)
tdf#122658: Empty date form field is not exported correctly to DOCX file
We need to export date format and also text content in case of empty date field. Otherwise the exported date field will be lost during import into LO Writer or MSO Word. Change-Id: I5cf65bedba010f64ca8f56262057f3cce32b0943 Reviewed-on: https://gerrit.libreoffice.org/66194 Tested-by: Jenkins Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/qa/extras')
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/empty-date-control.odtbin0 -> 8668 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport13.cxx20
2 files changed, 20 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/empty-date-control.odt b/sw/qa/extras/ooxmlexport/data/empty-date-control.odt
new file mode 100755
index 000000000000..acd5b8b94e73
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/empty-date-control.odt
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index b22c5cd96083..dac93371abb6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -14,6 +14,7 @@
#include <com/sun/star/text/WritingMode2.hpp>
#include <com/sun/star/text/XTextFrame.hpp>
#include <com/sun/star/text/XTextFramesSupplier.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
#include <sfx2/docfile.hxx>
#include <sfx2/docfilt.hxx>
@@ -66,6 +67,25 @@ DECLARE_OOXMLEXPORT_TEST(testendingSectionProps, "endingSectionProps.docx")
CPPUNIT_ASSERT_EQUAL_MESSAGE("Section Left Margin", sal_Int32(2540), getProperty<sal_Int32>(xSect, "SectionLeftMargin"));
}
+DECLARE_OOXMLEXPORT_TEST(testDateControl, "empty-date-control.odt")
+{
+ // Check that we did not lost the date control
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xDraws->getCount());
+ uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT(xControl->getControl().is());
+
+ // check XML
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ // We need to export date format and a dummy character (" ") for empty date control
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dd/MM/yyyy");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", u" ");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */