sw/qa/extras/ooxmlexport/data/conditional-text.fodt | 2 +- sw/source/filter/ww8/docxattributeoutput.cxx | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-)
New commits: commit 98550980e414ca6d611e6c3779eed2e5e66f5641 Author: Justin Luth <jl...@mail.com> AuthorDate: Tue Jan 17 14:26:52 2023 -0500 Commit: Justin Luth <jl...@mail.com> CommitDate: Tue Jan 17 22:18:42 2023 +0000 tdf#114537 docx export: export conditional text in quotes DOCX is very much dependent on the true and false text being in quotes. Likely any inside quotes need to be escaped, but I haven't looked at that yet. Change-Id: I9f1976a92ea21d9d444ab2e405a0678daa8f939c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145684 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 296c1c4ecc4d..244fdf84b6e1 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/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 0a95e6c44cd6..b8a7dee024ec 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8737,7 +8737,7 @@ void DocxAttributeOutput::HiddenField(const SwField& rField) OUString aTrueFalse = rField.GetPar2(); sal_Int32 nPos = aTrueFalse.indexOf('|'); OUString aTrue; - std::u16string_view aFalse; + OUString aFalse; if (nPos == -1) { aTrue = aTrueFalse; @@ -8747,6 +8747,11 @@ void DocxAttributeOutput::HiddenField(const SwField& rField) aTrue = aTrueFalse.subView(0, nPos); aFalse = aTrueFalse.subView(nPos + 1); } + if (aTrue.getLength() > 1 && aTrue.startsWith("\"") && aTrue.endsWith("\"")) + aTrue = aTrue.copy(1, aTrue.getLength() - 2); + if (aFalse.getLength() > 1 && aFalse.startsWith("\"") && aFalse.endsWith("\"")) + aFalse = aFalse.copy(1, aFalse.getLength() - 2); + OUString aCmd = FieldString(ww::eIF) + aCond + " \"" + aTrue + "\" \"" + aFalse + "\""; m_rExport.OutputField(&rField, ww::eIF, aCmd); return;