summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-10-28 16:58:41 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-10-28 18:07:21 +0100
commit7b0534cb70e96028c8525285c42a71415704cede (patch)
treee247e8879bbc36729a31ce22071f8b13aef4596e /sw
parent398e1e6ae83999eea8fb8c845190667695ac115f (diff)
Related: tdf#125038 DOCX import: fix unexpected MERGEFIELD result inside IF
The problem is that DOCX supports nesting MERGEFIELD fields inside IF fields, while SwHiddenTextField only supports a single string as a condition. This means in case there are MERGEFIELD fields inside the IF field, those fields will be inserted to the doc model before the IF field, exposing their value, while Word only uses their value during the evaluation of the IF expression. Fix the problem by inspecting the parent field command before setting the MERGEFIELD result. Change-Id: Ieca098f16f756bab5d23f219fa4ca30d077d4bb7 Reviewed-on: https://gerrit.libreoffice.org/81615 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf125038.docxbin0 -> 12690 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx9
2 files changed, 9 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf125038.docx b/sw/qa/extras/ooxmlexport/data/tdf125038.docx
new file mode 100644
index 000000000000..b4dd622f95e0
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf125038.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index b06b342c7071..6dd91d44960a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -39,6 +39,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf108350_noFontdefaults, "tdf108350_noFontdefaults
//CPPUNIT_ASSERT_EQUAL_MESSAGE("Font size", 10.f, getProperty<float>(xStyleProps, "CharHeight"));
}
+DECLARE_OOXMLIMPORT_TEST(testTdf125038, "tdf125038.docx")
+{
+ OUString aActual = getParagraph(1)->getString();
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: phone:...
+ // - Actual : result1result2phone:...
+ // i.e. the result if the inner MERGEFIELD fields ended up in the body text.
+ CPPUNIT_ASSERT_EQUAL(OUString("phone: \t1234567890"), aActual);
+}
CPPUNIT_PLUGIN_IMPLEMENT();