sw/CppunitTest_sw_ooxmlexport26.mk | 16 ++++++++ sw/Module_sw.mk | 1 sw/qa/extras/ooxmlexport/data/tdf166850.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport26.cxx | 41 +++++++++++++++++++++ sw/source/writerfilter/dmapper/StyleSheetTable.cxx | 16 +++++--- sw/source/writerfilter/dmapper/StyleSheetTable.hxx | 2 - 6 files changed, 70 insertions(+), 6 deletions(-)
New commits: commit bce4f99ded571a55d7dbc1e98fdb3aaee5dba821 Author: Oliver Specht <[email protected]> AuthorDate: Tue Jun 3 16:21:43 2025 +0200 Commit: Thorsten Behrens <[email protected]> CommitDate: Thu Jun 5 10:26:24 2025 +0200 tdf#166850 Apply converted style name to StyleRef field As a result of e45f187870362ed4448f4a9fb96883b8431887fb the StyleRef field needs to use the modified style name with (suffix " (user)") The related JUnit test requires a German locale to detect the related issue. Otherwise there is no suffix that needs to be applied to the field. Change-Id: Iad4257568ad05900df63a6098ba81e926df701e1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186175 Tested-by: allotropia jenkins <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> diff --git a/sw/CppunitTest_sw_ooxmlexport26.mk b/sw/CppunitTest_sw_ooxmlexport26.mk new file mode 100755 index 000000000000..8b57467c2f61 --- /dev/null +++ b/sw/CppunitTest_sw_ooxmlexport26.mk @@ -0,0 +1,16 @@ +# -*- 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,26)) + +$(call gb_CppunitTest_get_target,sw_ooxmlexport26) : export LO_TEST_LOCALE=de + +# vim: set noet sw=4 ts=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index 2db6fbace5f5..eff75e729847 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -98,6 +98,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\ CppunitTest_sw_ooxmlexport19 \ CppunitTest_sw_ooxmlexport20 \ CppunitTest_sw_ooxmlexport21 \ + CppunitTest_sw_ooxmlexport26 \ CppunitTest_sw_ooxmlexport_template \ CppunitTest_sw_ooxmlfieldexport \ CppunitTest_sw_ooxmllinks \ diff --git a/sw/qa/extras/ooxmlexport/data/tdf166850.docx b/sw/qa/extras/ooxmlexport/data/tdf166850.docx new file mode 100644 index 000000000000..5fb96bdb2276 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf166850.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport26.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport26.cxx new file mode 100755 index 000000000000..bbf917d07fb0 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/ooxmlexport26.cxx @@ -0,0 +1,41 @@ +/* -*- 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 <IDocumentLayoutAccess.hxx> +#include <wrtsh.hxx> + +namespace +{ +class Test : public SwModelTestBase +{ +public: + Test() + : SwModelTestBase(u"/sw/qa/extras/ooxmlexport/data/"_ustr, u"Office Open XML Text"_ustr) + { + } +}; + +//test requires German user interface otherwise it will not detect the issue +CPPUNIT_TEST_FIXTURE(Test, testTdf166850) +{ + createSwDoc("tdf166850.docx"); + SwDoc* pDoc = getSwDoc(); + SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(); + pViewShell->UpdateFields(); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[2]/header/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion", + "expand", u"Heading 1"_ustr); +} + +} // end of anonymous namespace +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx index c43c7af27ffe..81928390fcbd 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.cxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.cxx @@ -1107,19 +1107,22 @@ OUString StyleSheetTable::CloneTOCStyle(FontTablePtr const& rFontTable, StyleShe // the old converted name is what is applied to paragraphs m_pImpl->m_ClonedTOCStylesMap.emplace(pStyle->m_sConvertedStyleName, pClone->m_sConvertedStyleName); std::vector<StyleSheetEntryPtr> const styles{ pClone }; - ApplyStyleSheetsImpl(rFontTable, styles); + std::vector<OUString> aRetStyleNames = ApplyStyleSheetsImpl(rFontTable, styles); + pClone->m_sConvertedStyleName = aRetStyleNames[0]; return pClone->m_sConvertedStyleName; } void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) { - return ApplyStyleSheetsImpl(rFontTable, m_pImpl->m_aStyleSheetEntries); + ApplyStyleSheetsImpl(rFontTable, m_pImpl->m_aStyleSheetEntries); } -void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std::vector<StyleSheetEntryPtr> const& rEntries) +std::vector<OUString> StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std::vector<StyleSheetEntryPtr> const& rEntries) { + std::vector<OUString> aStyleUINames(rEntries.size()); + std::vector<OUString>::iterator aStyleUINamesIt = aStyleUINames.begin(); if (!m_pImpl->m_xTextDocument) - return; + return aStyleUINames; try { uno::Reference< container::XNameAccess > xStyleFamilies = m_pImpl->m_xTextDocument->getStyleFamilies(); @@ -1138,6 +1141,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: std::vector<beans::PropertyValue> aTableStylesVec; for (auto& pEntry : rEntries) { + *aStyleUINamesIt = pEntry->m_sStyleName; if( pEntry->m_nStyleTypeCode == STYLE_TYPE_UNKNOWN && !pEntry->m_sStyleName.isEmpty() ) pEntry->m_nStyleTypeCode = STYLE_TYPE_PARA; // unspecified style types are considered paragraph styles @@ -1424,7 +1428,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: aMissingParent.emplace_back( sParentStyle, xStyle ); xStyles->insertByName( sConvertedStyleName, uno::Any( xStyle) ); - + *aStyleUINamesIt = static_cast<SwXStyle*>(xStyle.get())->GetStyleName(); if (!m_pImpl->m_bIsNewDoc && bParaStyle) { // Remember the inserted style, which may or may not be referred during @@ -1454,6 +1458,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: pEntry->m_pProperties->InsertProps( m_pImpl->m_pDefaultCharProps, /*bOverwrite=*/false ); pEntry->m_pProperties->InsertProps( m_pImpl->m_pDefaultParaProps, /*bOverwrite=*/false ); } + ++aStyleUINamesIt; } // Update the styles that were created before their parents or next-styles @@ -1506,6 +1511,7 @@ void StyleSheetTable::ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std:: { DBG_UNHANDLED_EXCEPTION("writerfilter", "Styles could not be imported completely"); } + return aStyleUINames; } diff --git a/sw/source/writerfilter/dmapper/StyleSheetTable.hxx b/sw/source/writerfilter/dmapper/StyleSheetTable.hxx index fc2d2a0ba8fa..9185de09712a 100644 --- a/sw/source/writerfilter/dmapper/StyleSheetTable.hxx +++ b/sw/source/writerfilter/dmapper/StyleSheetTable.hxx @@ -128,7 +128,7 @@ private: void applyDefaults(bool bParaProperties); - void ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std::vector<StyleSheetEntryPtr> const& rEntries); + std::vector<OUString> ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std::vector<StyleSheetEntryPtr> const& rEntries); };
