sw/qa/extras/ooxmlexport/data/conditional-text.fodt | 2 +- sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 2 +- sw/source/filter/ww8/docxattributeoutput.cxx | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-)
New commits: commit 29f23c0e71437303982a094040373b509afc7010 Author: Justin Luth <jl...@mail.com> AuthorDate: Tue Jan 17 15:05:25 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Wed Jan 18 03:32:40 2023 +0000 tdf#114537 docx export: export conditional text with " as ' I couldn't find any way in MS Word to escape a double-quote that is inside of a conditonal text result. So just "emulate" that with a single-quote, which is a common substitute at least in the English world. Hmm, Google says that { QUOTE 34 } would do the trick, but it didn't work for me in Word 2010. Change-Id: Ib9833e482911809c86b4e300533ea0aedbeed71c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145685 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ooxmlexport/data/conditional-text.fodt b/sw/qa/extras/ooxmlexport/data/conditional-text.fodt index 244fdf84b6e1..2486d0f6aa89 100644 --- a/sw/qa/extras/ooxmlexport/data/conditional-text.fodt +++ b/sw/qa/extras/ooxmlexport/data/conditional-text.fodt @@ -2,7 +2,7 @@ <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 < 2" text:string-value-if-true=""True"" text:string-value-if-false="False">True</text:conditional-text></text:p> + <text:p><text:conditional-text text:condition="ooow:1 < 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 96ba5e5a83e1..87d0878b6c0c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -809,7 +809,7 @@ CPPUNIT_TEST_FIXTURE(Test, testConditionalText) loadAndReload("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\""); + 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 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index b8a7dee024ec..fd4794593f1f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8752,7 +8752,9 @@ void DocxAttributeOutput::HiddenField(const SwField& rField) if (aFalse.getLength() > 1 && aFalse.startsWith("\"") && aFalse.endsWith("\"")) aFalse = aFalse.copy(1, aFalse.getLength() - 2); - OUString aCmd = FieldString(ww::eIF) + aCond + " \"" + aTrue + "\" \"" + aFalse + "\""; + // Substitute a single quote for an illegal double quote if one exists + OUString aCmd = FieldString(ww::eIF) + aCond + " \"" + aTrue.replaceAll("\"", "'") + + "\" \"" + aFalse.replaceAll("\"", "'") + "\""; m_rExport.OutputField(&rField, ww::eIF, aCmd); return; }