summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlimport
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-30 09:00:25 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-30 09:36:51 +0200
commit5ee8670f18cb8b1913a23d04590d6a31ac9730de (patch)
treecc3475b36e991362e9633021aa9a09457c3a7558 /sw/qa/extras/ooxmlimport
parent43458f83f29067752cfb3df2ccfe0eeb940f4b71 (diff)
sw content controls, date: add DOCX import
- map <w:date> <w:dateFormat w:val="..."/> <w:lid w:val="..."/> </w:date> to the Date, DateFormat and DateLanguage UNO properties of content controls instead of fieldmarks, which model content controls poorly - fix CppunitTest_sw_ooxmlexport8's testN820509: date SDT is now a content control - add current date DOCX import - fix CppunitTest_sw_ooxmlexport13's testDateControl: date SDT is now a content control - fix CppunitTest_sw_ooxmlexport13's testInvalidDateFormField: date SDT is now a content control - fix CppunitTest_sw_ooxmlexport5's testfdo83048: minimal support for nested SDTs in DomainMapper::lcl_attribute() - fix CppunitTest_sw_ooxmlfieldexport's testDateFieldAtEndOfParagraph: date SDT is now a content control - fix CppunitTest_sw_ooxmlfieldexport's testDateFieldInShape: date SDT is now a content control - fix CppunitTest_sw_ooxmlfieldexport's testSdtDateDuplicate: date SDT is now a content control - fix CppunitTest_sw_ooxmlfieldexport's testSdtDatePicker: - retain placeholder - retain data binding - retain color - fix CppunitTest_sw_ooxmlimport2's testTdf121203: date SDT is now a content control - fix CppunitTest_sw_globalfilter's testDateFormFieldCharacterFormatting: date SDT is now a content control - fix CppunitTest_sw_globalfilter's testDateFormField: date SDT is now a content control Change-Id: I5a4c34217d23ed6fa0916e4dd6290351456b7232 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135109 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa/extras/ooxmlimport')
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport2.cxx42
1 files changed, 20 insertions, 22 deletions
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
index 4a2c6771674d..fd148cd8db49 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport2.cxx
@@ -172,34 +172,32 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf121203)
{
load(mpTestDocumentPath, "tdf121203.docx");
// We imported the date field
- SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
- CPPUNIT_ASSERT(pTextDoc);
- SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
- IDocumentMarkAccess* pMarkAccess = pDoc->getIDocumentMarkAccess();
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMarkAccess->getAllMarksCount());
+ uno::Reference<beans::XPropertySet> xTextPortion(getRun(getParagraph(1), 1), uno::UNO_QUERY);
+ OUString aPortionType;
+ xTextPortion->getPropertyValue("TextPortionType") >>= aPortionType;
+ CPPUNIT_ASSERT_EQUAL(OUString("ContentControl"), aPortionType);
// Custom sdt date content is imported correctly
- ::sw::mark::IDateFieldmark* pFieldmark
- = dynamic_cast<::sw::mark::IDateFieldmark*>(*pMarkAccess->getAllMarksBegin());
- CPPUNIT_ASSERT(pFieldmark);
- CPPUNIT_ASSERT_EQUAL(OUString(ODF_FORMDATE), pFieldmark->GetFieldname());
+ uno::Reference<text::XTextContent> xContentControl;
+ xTextPortion->getPropertyValue("ContentControl") >>= xContentControl;
+ uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY);
+ bool bDate{};
+ xContentControlProps->getPropertyValue("Date") >>= bDate;
+ CPPUNIT_ASSERT(bDate);
- const sw::mark::IFieldmark::parameter_map_t* const pParameters = pFieldmark->GetParameters();
OUString sDateFormat;
- auto pResult = pParameters->find(ODF_FORMDATE_DATEFORMAT);
- if (pResult != pParameters->end())
- {
- pResult->second >>= sDateFormat;
- }
+ xContentControlProps->getPropertyValue("DateFormat") >>= sDateFormat;
OUString sLang;
- pResult = pParameters->find(ODF_FORMDATE_DATEFORMAT_LANGUAGE);
- if (pResult != pParameters->end())
- {
- pResult->second >>= sLang;
- }
-
- OUString sCurrentDate = pFieldmark->GetContent();
+ xContentControlProps->getPropertyValue("DateLanguage") >>= sLang;
+
+ uno::Reference<container::XEnumerationAccess> xContentControlEnumAccess(xContentControl,
+ uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xContentControlEnum
+ = xContentControlEnumAccess->createEnumeration();
+ uno::Reference<text::XTextRange> xTextPortionRange(xContentControlEnum->nextElement(),
+ uno::UNO_QUERY);
+ OUString sCurrentDate = xTextPortionRange->getString();
CPPUNIT_ASSERT_EQUAL(OUString("dd-MMM-yy"), sDateFormat);
CPPUNIT_ASSERT_EQUAL(OUString("en-GB"), sLang);
CPPUNIT_ASSERT_EQUAL(OUString("17-Oct-2018 09:00"), sCurrentDate);