summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-07 18:04:09 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-03-08 17:50:59 +0100
commitb2385830711ec700956869ace7670edd845a50df (patch)
tree3ecc5b0eb28f5511aaf864639494273ba418cea6 /sw/qa/extras
parent4dcad28a5e2415c81d018bf38b4e8ed10f42da79 (diff)
ooxml: export date controls properly
Export date controls as ooxml Standard Document Tags (SDT) instead of replacing them with plain text. SDT date controls contain the date in ISO format as an attribute of <date> tag, a custom date format that can be specified by the user in the <dateFormat> tag and the date formatted in that custom format in the <w:sdtContent> tag. The unit test testFormControl from ooxmlexport suite was removed, it only checked if the date control was exported as text and it obviously fails now. A new test that checks the values of the exported control was written instead. A pair of date format functions were added to datetimeutils.hxx. TODO: to avoid supporting all the posible custom formats that can be specified in the <dateFormat> tag, it is forced to dd/mm/yyyy on export. Change-Id: I9d1b6f840ee9e133831fdb04ad399fe31bcb2063
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/ooxmlexport/data/date-control.docxbin0 -> 21367 bytes
-rwxr-xr-xsw/qa/extras/ooxmlexport/data/form-control.docxbin13507 -> 0 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx26
3 files changed, 18 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/date-control.docx b/sw/qa/extras/ooxmlexport/data/date-control.docx
new file mode 100644
index 000000000000..0563d56aac35
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/date-control.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/data/form-control.docx b/sw/qa/extras/ooxmlexport/data/form-control.docx
deleted file mode 100755
index 4f6305a8ca74..000000000000
--- a/sw/qa/extras/ooxmlexport/data/form-control.docx
+++ /dev/null
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index f9fda5fb1eb3..b870866495a3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -15,6 +15,7 @@
#include <com/sun/star/drawing/FillStyle.hpp>
#include <com/sun/star/drawing/LineJoint.hpp>
#include <com/sun/star/drawing/LineStyle.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/style/TabStop.hpp>
#include <com/sun/star/view/XViewSettingsSupplier.hpp>
@@ -2046,14 +2047,6 @@ DECLARE_OOXMLEXPORT_TEST(testAutofit, "autofit.docx")
CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "FrameIsAutomaticHeight")));
}
-DECLARE_OOXMLEXPORT_TEST(testFormControl, "form-control.docx")
-{
- if (!m_bExported)
- return;
- // "[Date]" was missing.
- getParagraph(1, "Foo [Date] bar.");
-}
-
DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
@@ -2963,6 +2956,23 @@ DECLARE_OOXMLEXPORT_TEST(testGenericTextField, "Unsupportedtextfields.docx")
CPPUNIT_ASSERT(contents.match("PRINTDATE \\* MERGEFORMAT"));
}
+DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
+{
+ // check XML
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z");
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "05/03/2014");
+
+ // check imported control
+ uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
+ util::Date aDate = getProperty<util::Date>(xControl->getControl(), "Date");
+ CPPUNIT_ASSERT_EQUAL(5, sal_Int32(aDate.Day));
+ CPPUNIT_ASSERT_EQUAL(3, sal_Int32(aDate.Month));
+ CPPUNIT_ASSERT_EQUAL(2014, sal_Int32(aDate.Year));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();