summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-27 12:35:20 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-27 13:42:59 +0200
commit0f70f4d76b5f68e5b1d81f0e300435ccef893c9a (patch)
tree9abd123d90ac222b25f343cf1f1eee6cd9d92d6d /sw/qa
parentd203d3aeb29a46bd85eb320d4ebcd7325ec4a1ab (diff)
sw content controls, date: preserve more properties
While working on the DOCX import for dates, it turns out there is a need to store more properties for DOCX export purposes. Given that these are potentially useful for full support, add dedicated UNO API and DOCX export for these (i.e. not just grab-bag), but omit UI or ODT filter for now. This includes: - <w:docPart w:val="..."> - <w:dataBinding w:prefixMappings="..." w:xpath="..." w:storeItemID="..."> - <w15:color w:val="..."> And tests for all these. Change-Id: I18ddec50d40c1c4abd87f7ea947a24dd8a92a755 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135039 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/core/unocore/unocore.cxx20
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport17.cxx12
2 files changed, 32 insertions, 0 deletions
diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx
index 1ccd8b250ec3..56b9ed4c74de 100644
--- a/sw/qa/core/unocore/unocore.cxx
+++ b/sw/qa/core/unocore/unocore.cxx
@@ -603,6 +603,17 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate)
xContentControlProps->setPropertyValue("DateLanguage", uno::Any(OUString("en-US")));
xContentControlProps->setPropertyValue("CurrentDate",
uno::Any(OUString("2022-05-25T00:00:00Z")));
+ xContentControlProps->setPropertyValue("PlaceholderDocPart",
+ uno::Any(OUString("DefaultPlaceholder_-1854013437")));
+ xContentControlProps->setPropertyValue(
+ "DataBindingPrefixMappings",
+ uno::Any(OUString("xmlns:ns0='http://schemas.microsoft.com/vsto/samples' ")));
+ xContentControlProps->setPropertyValue(
+ "DataBindingXpath",
+ uno::Any(OUString("/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]")));
+ xContentControlProps->setPropertyValue(
+ "DataBindingStoreItemID", uno::Any(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}")));
+ xContentControlProps->setPropertyValue("Color", uno::Any(OUString("008000")));
xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
// Then make sure that the specified properties are set:
@@ -617,6 +628,15 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate)
CPPUNIT_ASSERT_EQUAL(OUString("M/d/yyyy"), pContentControl->GetDateFormat());
CPPUNIT_ASSERT_EQUAL(OUString("en-US"), pContentControl->GetDateLanguage());
CPPUNIT_ASSERT_EQUAL(OUString("2022-05-25T00:00:00Z"), pContentControl->GetCurrentDate());
+ CPPUNIT_ASSERT_EQUAL(OUString("DefaultPlaceholder_-1854013437"),
+ pContentControl->GetPlaceholderDocPart());
+ CPPUNIT_ASSERT_EQUAL(OUString("xmlns:ns0='http://schemas.microsoft.com/vsto/samples' "),
+ pContentControl->GetDataBindingPrefixMappings());
+ CPPUNIT_ASSERT_EQUAL(OUString("/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]"),
+ pContentControl->GetDataBindingXpath());
+ CPPUNIT_ASSERT_EQUAL(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}"),
+ pContentControl->GetDataBindingStoreItemID());
+ CPPUNIT_ASSERT_EQUAL(OUString("008000"), pContentControl->GetColor());
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index 2ba7a7cfdd97..da72f770151b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -388,6 +388,12 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport)
xContentControlProps->setPropertyValue("Date", uno::Any(true));
xContentControlProps->setPropertyValue("DateFormat", uno::Any(OUString("M/d/yyyy")));
xContentControlProps->setPropertyValue("DateLanguage", uno::Any(OUString("en-US")));
+ xContentControlProps->setPropertyValue("CurrentDate", uno::Any(OUString("2022-05-26T00:00:00Z")));
+ xContentControlProps->setPropertyValue("PlaceholderDocPart", uno::Any(OUString("DefaultPlaceholder_-1854013437")));
+ xContentControlProps->setPropertyValue("DataBindingPrefixMappings", uno::Any(OUString("xmlns:ns0='http://schemas.microsoft.com/vsto/samples' ")));
+ xContentControlProps->setPropertyValue("DataBindingXpath", uno::Any(OUString("/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]")));
+ xContentControlProps->setPropertyValue("DataBindingStoreItemID", uno::Any(OUString("{241A8A02-7FFD-488D-8827-63FBE74E8BC9}")));
+ xContentControlProps->setPropertyValue("Color", uno::Any(OUString("008000")));
xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
// When exporting to DOCX:
@@ -403,6 +409,12 @@ CPPUNIT_TEST_FIXTURE(Test, testDateContentControlExport)
// i.e. the <w:date> was lost on export.
assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "M/d/yyyy");
assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:date/w:lid", "val", "en-US");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:date", "fullDate", "2022-05-26T00:00:00Z");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:placeholder/w:docPart", "val", "DefaultPlaceholder_-1854013437");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:dataBinding", "prefixMappings", "xmlns:ns0='http://schemas.microsoft.com/vsto/samples' ");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns0:employees[1]/ns0:employee[1]/ns0:hireDate[1]");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{241A8A02-7FFD-488D-8827-63FBE74E8BC9}");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w15:color", "val", "008000");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf148494)