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 <jluth@mail.com>
This commit is contained in:
Justin Luth
2025-03-09 00:46:50 +01:00
parent f668fab044
commit 60788682d3
5 changed files with 88 additions and 0 deletions
+22
View File
@@ -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:
+1
View File
@@ -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 \
@@ -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 <swmodeltestbase.hxx>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <comphelper/configuration.hxx>
#include <comphelper/sequenceashashmap.hxx>
#include <officecfg/Office/Common.hxx>
#include <pam.hxx>
#include <unotxdoc.hxx>
#include <docsh.hxx>
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: */
@@ -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;