diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-05-27 11:38:42 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-27 12:11:46 +0200 |
commit | 79baafccf3d390810f516b2cf9cb3ad2b4e9e63b (patch) | |
tree | e795e64c75b64c1232616d365be8fea60f0e2085 /xmloff/qa | |
parent | bd6cb0d8219b117b1a72774c26d54774c72602da (diff) |
sw content controls, date: add current date handling
While working on the DOCX import for dates, it turns out there is a need
to store the selected date in machine-readable format as well. This is
useful, because once the timestamp is formatted, the user is allowed to
hand-edit the result, so otherwise the selected date would be lost.
This commit adds:
- doc model & UNO API
- click handler (store the selected date, default to the current date in
the date picker if possible)
- ODT filter
- DOCX export
And tests for all these.
Change-Id: I00f4e87ebfe0e8a19486367c32d472ccd2ff16a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135035
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'xmloff/qa')
-rw-r--r-- | xmloff/qa/unit/data/content-control-date.fodt | 2 | ||||
-rw-r--r-- | xmloff/qa/unit/text.cxx | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/xmloff/qa/unit/data/content-control-date.fodt b/xmloff/qa/unit/data/content-control-date.fodt index dd3749a02e99..c49e51339c3b 100644 --- a/xmloff/qa/unit/data/content-control-date.fodt +++ b/xmloff/qa/unit/data/content-control-date.fodt @@ -2,7 +2,7 @@ <office:document xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> <office:body> <office:text> - <text:p><loext:content-control loext:date="true" loext:date-format="YYYY-MM-DD" loext:date-rfc-language-tag="en-US">choose a date</loext:content-control></text:p> + <text:p><loext:content-control loext:date="true" loext:date-format="YYYY-MM-DD" loext:date-rfc-language-tag="en-US" loext:current-date="2022-05-25T00:00:00Z">choose a date</loext:content-control></text:p> </office:text> </office:body> </office:document> diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 303f31c4ca40..2aed79376fe0 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -732,6 +732,8 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlExport) xContentControlProps->setPropertyValue("Date", uno::Any(true)); xContentControlProps->setPropertyValue("DateFormat", uno::Any(OUString("YYYY-MM-DD"))); xContentControlProps->setPropertyValue("DateLanguage", uno::Any(OUString("en-US"))); + xContentControlProps->setPropertyValue("CurrentDate", + uno::Any(OUString("2022-05-25T00:00:00Z"))); xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: @@ -752,6 +754,7 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlExport) assertXPath(pXmlDoc, "//loext:content-control", "date", "true"); assertXPath(pXmlDoc, "//loext:content-control", "date-format", "YYYY-MM-DD"); assertXPath(pXmlDoc, "//loext:content-control", "date-rfc-language-tag", "en-US"); + assertXPath(pXmlDoc, "//loext:content-control", "current-date", "2022-05-25T00:00:00Z"); } CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlImport) @@ -788,6 +791,9 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlImport) OUString aDateLanguage; xContentControlProps->getPropertyValue("DateLanguage") >>= aDateLanguage; CPPUNIT_ASSERT_EQUAL(OUString("en-US"), aDateLanguage); + OUString aCurrentDate; + xContentControlProps->getPropertyValue("CurrentDate") >>= aCurrentDate; + CPPUNIT_ASSERT_EQUAL(OUString("2022-05-25T00:00:00Z"), aCurrentDate); } CPPUNIT_PLUGIN_IMPLEMENT(); |