/nlpsolver/

-5-2'>distro/cib/libreoffice-5-2 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/sw/qa/extras/ooxmlexport
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-04-28 10:12:29 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-02 13:49:06 +0200
commit38ae2a54e2efc1c957868b6d8e93bd49bb3e08c7 (patch)
tree1d1f2d7088a371601ddb981464f01be32e86edc6 /sw/qa/extras/ooxmlexport
parent112309a07b55d5b4a9a4b7395df7612240df5684 (diff)
sw content controls, checkbox: add DOCX export
Map the 4 UNO properties to the following XML construct: <w14:checkbox> <w14:checked w14:val="0"/> <w14:checkedState w14:val="2612"/> <w14:uncheckedState w14:val="2610"/> </w14:checkbox> (cherry picked from commit 8642389b954a0b8f5673c85f44d8b0ea34eb3430) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport17.cxx Change-Id: I6457754e5dc9750204da7f2e5e479589380f3992 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133644 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/extras/ooxmlexport')
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport17.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
index b72a470978cc..38a17bca714b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx
@@ -146,6 +146,42 @@ CPPUNIT_TEST_FIXTURE(Test, testContentControlExport)
assertXPath(pXmlDoc, "//w:sdt/w:sdtContent", 1);
}
+CPPUNIT_TEST_FIXTURE(Test, testCheckboxContentControlExport)
+{
+ // Given a document with a checkbox content control around a text portion:
+ mxComponent = loadFromDesktop("private:factory/swriter");
+ uno::Reference<lang::XMultiServiceFactory> xMSF(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XText> xText = xTextDocument->getText();
+ uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
+ xText->insertString(xCursor, OUString(u"☐"), /*bAbsorb=*/false);
+ xCursor->gotoStart(/*bExpand=*/false);
+ xCursor->gotoEnd(/*bExpand=*/true);
+ uno::Reference<text::XTextContent> xContentControl(
+ xMSF->createInstance("com.sun.star.text.ContentControl"), uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xContentControlProps(xContentControl, uno::UNO_QUERY);
+ xContentControlProps->setPropertyValue("Checkbox", uno::makeAny(true));
+ xContentControlProps->setPropertyValue("Checked", uno::makeAny(true));
+ xContentControlProps->setPropertyValue("CheckedState", uno::makeAny(OUString(u"☒")));
+ xContentControlProps->setPropertyValue("UncheckedState", uno::makeAny(OUString(u"☐")));
+ xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true);
+
+ // When exporting to DOCX:
+ save("Office Open XML Text", maTempFile);
+ mbExported = true;
+
+ // Then make sure the expected markup is used:
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ // Without the fix in place, this test would have failed with:
+ // - Expected: 1
+ // - Actual : 0
+ // - XPath '//w:sdt/w:sdtPr/w14:checkbox/w14:checked' number of nodes is incorrect
+ // i.e. <w14:checkbox> and its child elements were lost.
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w14:checkbox/w14:checked", "val", "1");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w14:checkbox/w14:checkedState", "val", "2612");
+ assertXPath(pXmlDoc, "//w:sdt/w:sdtPr/w14:checkbox/w14:uncheckedState", "val", "2610");
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf137466, "tdf137466.docx")
{
xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");