From 60788682d3d62264e8a5ac42f3469f2d2f55815c Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Sat, 8 Mar 2025 15:30:41 -0500 Subject: [PATCH] tdf#165642 docx export glossary: RT endnotes.xml/footnotes.xml too settings.xml might refer to endnotePr (in which case there must be an endnotes.xml file) and / or footnotePr (in which case there must be a footnotes.xml file) so round-trip these 2 files also if they exist in the glossary folder. Otherwise MS Word complains about invalid content. For this particular unit test it went bad in LO 7.4.4, but in other circumstances, it already goes bad in LO 4.3. make CppunitTest_sw_ooxmlexport22 \ CPPUNIT_TEST_NAME=testTdf165642_glossaryFootnote Change-Id: Ib4c2513fa915fc4de4aee056b67a5936be5c52a1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182674 Tested-by: Jenkins Reviewed-by: Justin Luth --- sw/CppunitTest_sw_ooxmlexport22.mk | 22 ++++++++ sw/Module_sw.mk | 1 + .../data/tdf165642_glossaryFootnote.docx | Bin 0 -> 7981 bytes sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 49 ++++++++++++++++++ .../writerfilter/ooxml/OOXMLDocumentImpl.cxx | 16 ++++++ 5 files changed, 88 insertions(+) create mode 100644 sw/CppunitTest_sw_ooxmlexport22.mk create mode 100644 sw/qa/extras/ooxmlexport/data/tdf165642_glossaryFootnote.docx create mode 100644 sw/qa/extras/ooxmlexport/ooxmlexport22.cxx diff --git a/sw/CppunitTest_sw_ooxmlexport22.mk b/sw/CppunitTest_sw_ooxmlexport22.mk new file mode 100644 index 000000000000..e1137f9c302c --- /dev/null +++ b/sw/CppunitTest_sw_ooxmlexport22.mk @@ -0,0 +1,22 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +#************************************************************************* +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +#************************************************************************* + +$(eval $(call sw_ooxmlexport_test,22)) + +$(eval $(call gb_CppunitTest_use_custom_headers,sw_ooxmlexport22,\ + officecfg/registry \ +)) + +ifneq ($(filter MORE_FONTS,$(BUILD_TYPE)),) +$(eval $(call gb_CppunitTest_set_non_application_font_use,sw_ooxmlexport22,abort)) +endif + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 6d4ed9f55967..19fecbe6d9cf 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -99,6 +99,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_ooxmlexport19 \ CppunitTest_sw_ooxmlexport20 \ CppunitTest_sw_ooxmlexport21 \ + CppunitTest_sw_ooxmlexport22 \ CppunitTest_sw_ooxmlexport_template \ CppunitTest_sw_ooxmlfieldexport \ CppunitTest_sw_ooxmllinks \ diff --git a/sw/qa/extras/ooxmlexport/data/tdf165642_glossaryFootnote.docx b/sw/qa/extras/ooxmlexport/data/tdf165642_glossaryFootnote.docx new file mode 100644 index 0000000000000000000000000000000000000000..6188a919522baf87c9264a4ed4ad9b08fd2089c7 GIT binary patch literal 7981 zcma)>by$>J*TzSN4oPW{Eg5RLN zM-8=|{b`K3l z4?J~@2RYBh=L^k21_fCElqW{P;ArA+s$cfEgtj zC4}|V!$b#1>wGnIg-DoZoAObq{=6+oysqfy8y9N*PG2sEG13EfFnQPt5bM!4BeAYR>p?~!Lh8t6yDz9Ge9r>jSw2DEe_RJ;4%2#j zr-DEW|8U_Lm|d!hUdY=vu?-YNWnc0%GhGpK_t5H7=BA9Ud1K68rJpe@*y|v6Kk`n* z3TxnAX=4LfKjNAEVu9uv;P)_lGEgP)MVKT6@`_Cw;cH2zBqC~JJj9l9h zqk0b+Jyvu+>3y;_x~6m=b6Ih)3XQ0Zf2ICxI^G?JVO6(SPdnbzq)NAStHB3y?KK$M zcV#rZhwFK^3Jowv$HOc&Xw>pG#sr{+)HE*C!d_T4Yd~?X7pN(A<}F&Sg)4&V`1~*N z@m%oCJv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|>3bCcrsjlTKOCy&e z)jk~ufz)cBaxKx_AcpYn5(m|ew@HpB4p7Z|f;|B_8F%6Y;=SDYH}y~RF}KfQKK>0j za^OGRn-Kmqim(7@q8A_kXFeeOxJCJ6dHi7g(;dnW7VOXiDD@HfoAuKjf&niMzt;l) z>6+p4+MKT(%5 z=vssEA{&25dDUXP{H2Y42VSn=zf$TS-|$bS-Q_7e!aBtFZ-2?cgUN8MefMh(T{ZA7 zGi$CeFX?fumG?`Jt7hJ1Jy1~oob3-tWTvZe;y;K40*E zw?HoQ6Vdp;d_w%6{43aN*C+yP8DDI6umSV1O2I>P@!$Ue?nr~g literal 0 HcmV?d00001 diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx new file mode 100644 index 000000000000..34408dcc958b --- /dev/null +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include + +#include + +#include +#include +#include + +#include +#include +#include + +namespace +{ +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase(u"/sw/qa/extras/ooxmlexport/data/"_ustr, u"Office Open XML Text"_ustr) + { + } +}; + +CPPUNIT_TEST_FIXTURE(Test, testTdf165642_glossaryFootnote) +{ + loadAndSave("tdf165642_glossaryFootnote.docx"); + // round-trip'ing the settings.xml file as is, it contains footnote/endnote references + xmlDocUniquePtr pXmlSettings = parseExport(u"word/glossary/settings.xml"_ustr); + assertXPath(pXmlSettings, "//w:endnotePr", 1); + assertXPath(pXmlSettings, "//w:footnotePr", 1); + + // thus, the footnote and endnote files must also be round-tripped + parseExport(u"word/glossary/endnotes.xml"_ustr); + parseExport(u"word/glossary/footnotes.xml"_ustr); +} + +} // end of anonymous namespace +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx index 9192f1055a89..8caaddbc1e6a 100644 --- a/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx +++ b/sw/source/writerfilter/ooxml/OOXMLDocumentImpl.cxx @@ -608,10 +608,14 @@ void OOXMLDocumentImpl::resolveCustomXmlStream(Stream & rStream) namespace { constexpr OUStringLiteral sSettingsType = u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"; +constexpr OUStringLiteral sEndnotesType = u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes"; +constexpr OUStringLiteral sFootnotesType = u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes"; constexpr OUStringLiteral sStylesType = u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"; constexpr OUStringLiteral sFonttableType = u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable"; constexpr OUStringLiteral sWebSettings = u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings"; constexpr OUStringLiteral sSettingsTypeStrict = u"http://purl.oclc.org/ooxml/officeDocument/relationships/settings"; +constexpr OUStringLiteral sEndnoteTypeStrict = u"http://purl.oclc.org/ooxml/officeDocument/relationships/endnotes"; +constexpr OUStringLiteral sFootnoteTypeStrict = u"http://purl.oclc.org/ooxml/officeDocument/relationships/footnotes"; constexpr OUStringLiteral sStylesTypeStrict = u"http://purl.oclc.org/ooxml/officeDocument/relationships/styles"; constexpr OUStringLiteral sFonttableTypeStrict = u"http://purl.oclc.org/ooxml/officeDocument/relationships/fontTable"; constexpr OUStringLiteral sWebSettingsStrict = u"http://purl.oclc.org/ooxml/officeDocument/relationships/webSettings"; @@ -623,6 +627,8 @@ constexpr OUStringLiteral sTargetMode = u"TargetMode"; constexpr OUString sContentType = u"_contentType"_ustr; constexpr OUStringLiteral sRelDom = u"_relDom"; constexpr OUStringLiteral sSettingsContentType = u"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"; +constexpr OUStringLiteral sEndnotesContentType = u"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"; +constexpr OUStringLiteral sFootnotesContentType = u"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml"; constexpr OUStringLiteral sStylesContentType = u"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"; constexpr OUStringLiteral sWebsettingsContentType = u"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml"; constexpr OUStringLiteral sFonttableContentType = u"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"; @@ -663,6 +669,16 @@ void OOXMLDocumentImpl::resolveGlossaryStream(Stream & /*rStream*/) nType = OOXMLStream::SETTINGS; aRelDefinition.put(sContentType, sSettingsContentType); } + else if (gType == sEndnotesType || gType == sEndnoteTypeStrict) + { + nType = OOXMLStream::ENDNOTES; + aRelDefinition.put(sContentType, sEndnotesContentType); + } + else if (gType == sFootnotesType || gType == sFootnoteTypeStrict) + { + nType = OOXMLStream::FOOTNOTES; + aRelDefinition.put(sContentType, sFootnotesContentType); + } else if (gType == sStylesType || gType == sStylesTypeStrict) { nType = OOXMLStream::STYLES;