summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2023-03-28 13:15:09 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2023-03-31 12:57:59 +0000
commit992d86b1b67a6bd28bbf5e63b2d2406881f476b7 (patch)
tree3ff245f4f861825f98db85bda5f3915c7c74f272 /sw/qa
parent42a432d0023bd0a2da7c3683e43575b0386e705c (diff)
tdf#150542: DOCX import: support for document varibles
Writer does insert document variables only if they are in document body as DOCVARIABLE fields. But ones given in settings.xml (w:docVars/w:docVar) were ignored. Moreover variables in settings should have priority and overwrite ones in fields. Word by default does show only field results, but refreshing field values will override values with ones from settings. Change-Id: I7103c90eef59ab18f8a25e616dcf8a8b1c6dcb08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149646 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf150542.docxbin0 -> 2978 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport16.cxx21
2 files changed, 21 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf150542.docx b/sw/qa/extras/ooxmlexport/data/tdf150542.docx
new file mode 100644
index 000000000000..3f115fa69370
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf150542.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 0394c03495a6..6d501548ad25 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -994,6 +994,27 @@ CPPUNIT_TEST_FIXTURE(Test, Test_ShadowDirection)
"rotWithShape", "0");
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf150542)
+{
+ loadAndSave("tdf150542.docx");
+
+ xmlDocUniquePtr pSettingsDoc = parseExport("word/settings.xml");
+ // Ensure that all docvars from input are written back and with correct values.
+ // Order of document variables is not checked. So this can fail at some time if order is changed.
+ assertXPath(pSettingsDoc,
+ "/w:settings/w:docVars/w:docVar[1]", "name", u"LocalChars\u00C1\u0072\u0076\u00ED\u007A\u0074\u0075\u0072\u006F\u0054\u00FC\u006B\u00F6\u0072\u0066\u00FA\u0072\u00F3\u0067\u00E9\u0070");
+ assertXPath(pSettingsDoc,
+ "/w:settings/w:docVars/w:docVar[1]", "val", u"Correct value (\u00E1\u0072\u0076\u00ED\u007A\u0074\u0075\u0072\u006F\u0020\u0074\u00FC\u006B\u00F6\u0072\u0066\u00FA\u0072\u00F3\u0067\u00E9\u0070)");
+ assertXPath(pSettingsDoc,
+ "/w:settings/w:docVars/w:docVar[2]", "name", "DocVar1");
+ assertXPath(pSettingsDoc,
+ "/w:settings/w:docVars/w:docVar[2]", "val", "DocVar1 Value");
+ assertXPath(pSettingsDoc,
+ "/w:settings/w:docVars/w:docVar[3]", "name", "DocVar3");
+ assertXPath(pSettingsDoc,
+ "/w:settings/w:docVars/w:docVar[3]", "val", "DocVar3 Value");
+}
+
CPPUNIT_TEST_FIXTURE(Test, testTdf139549)
{
loadAndSave("tdf139549.docx");