summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-11-13 16:26:43 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-11-14 12:01:39 +0100
commit5d839ff8a81ade6453a239a258b2a2571e32001e (patch)
treea1e187002f23bbc608b0dfe3bc107e7803ac4c12 /sw/qa
parent05b279e7e0773d3c3da2688a2b95edfb8c88308c (diff)
DOCX export: handle conditional fields
At least the subset where the condition syntax matches between Writer and Word. Change-Id: I107f2b4caeda6f7777696af8d5c5b455854cfa92 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105798 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/ooxmlexport/data/conditional-text.fodt8
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx13
2 files changed, 21 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/conditional-text.fodt b/sw/qa/extras/ooxmlexport/data/conditional-text.fodt
new file mode 100644
index 000000000000..296c1c4ecc4d
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/conditional-text.fodt
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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:ooow="http://openoffice.org/2004/writer" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+ <office:text>
+ <text:p><text:conditional-text text:condition="ooow:1 &lt; 2" text:string-value-if-true="True" text:string-value-if-false="False">True</text:conditional-text></text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index eaf33fdda6b0..1a94982df7e9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -663,6 +663,19 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf132185, "tdf132185.docx")
assertXPathContent(pXmlDoc, "/w:ftr/w:p/w:r[2]/w:instrText", " PAGE \\* roman ");
}
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testConditionalText, "conditional-text.fodt")
+{
+ // Load a document which has a conditional text field in it.
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ std::u16string_view aExpected(u" IF 1 < 2 \"True\" \"False\"");
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expression: xmlXPathNodeSetGetLength(pXmlNodes) > 0
+ // - In <...>, XPath '/w:document/w:body/w:p/w:r[2]/w:instrText' not found
+ // i.e. the field was lost on export.
+ assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText", aExpected);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */