sw/qa/extras/ooxmlexport/data/tdf169413_asciiTheme.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport25.cxx | 7 +++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 11 +++++++---- 3 files changed, 14 insertions(+), 4 deletions(-)
New commits: commit 2a6de61011f4752451c266557d7d8f94562735b8 Author: Justin Luth <[email protected]> AuthorDate: Sat Nov 15 14:08:13 2025 -0500 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Nov 17 09:29:08 2025 +0100 tdf#169413 docx export: don't write themes twice in w:rFonts A round-trip was reported as corrupt by both Writer and Word. This probably started in 6.0 with tdf#38778 although a bibisect pointed to my 24.2 patch for tdf#108505. Although I'm not exactly sure what triggers this, grabBag was doubling up the bug report's conf12.docx w:cstheme in rFonts which looked like <w:rFonts w:cstheme="minorHAnsi" w:cs="Calibri" w:cstheme="minorHAnsi"/> and duplicate entries are invalid XML - even firefox complains. make CppunitTest_sw_ooxmlexport25 \ CPPUNIT_TEST_NAME=testTdf169413_asciiTheme Change-Id: Id9561b940c2c536147422e10a8c1d37ea51c2e78 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194057 Reviewed-by: Justin Luth <[email protected]> Tested-by: Jenkins (cherry picked from commit 9e8211b1c2a814880c0108b2122a6085be192b82) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194062 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/data/tdf169413_asciiTheme.docx b/sw/qa/extras/ooxmlexport/data/tdf169413_asciiTheme.docx new file mode 100644 index 000000000000..308e44019bbf Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf169413_asciiTheme.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx index 0f875a50a176..c49120ac2834 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport25.cxx @@ -83,6 +83,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf165478_bottomAligned, "tdf165478_bottomAligned.d CPPUNIT_ASSERT_EQUAL(nCellBottom, nTextBottom); } +CPPUNIT_TEST_FIXTURE(Test, testTdf169413_asciiTheme) +{ + // the document failed to reload without errors after a round-trip + createSwDoc("tdf169413_asciiTheme.docx"); + saveAndReload(mpFilter); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf166620) { createSwDoc(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index ea532b104018..de6ca5746089 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3139,7 +3139,7 @@ void DocxAttributeOutput::CmdEndField_Impl(SwTextNode const*const pNode, /// </w:rPr> /// <w:fldChar w:fldCharType="begin" /> /// </w:r> -/// <w:r> +/// <w:r> /// <w:rPr> /// <!-- properties written with DoWriteFieldRunProperties() /// </w:rPr> @@ -10349,19 +10349,22 @@ void DocxAttributeOutput::CharGrabBag( const SfxGrabBagItem& rItem ) { if ( rGrabBagElement.second >>= sOriginalValue ) bWriteCSTheme = - ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, XML_cs ) ) == sOriginalValue ); + (m_pFontsAttrList->getOptionalValue(FSNS( XML_w, XML_cs)) == sOriginalValue) + && !m_pFontsAttrList->hasAttribute(FSNS(XML_w, XML_cstheme)); } else if ( m_pFontsAttrList.is() && rGrabBagElement.first == "CharThemeFontNameAscii" ) { if ( rGrabBagElement.second >>= sOriginalValue ) bWriteAsciiTheme = - ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, XML_ascii ) ) == sOriginalValue ); + (m_pFontsAttrList->getOptionalValue(FSNS( XML_w, XML_ascii)) == sOriginalValue) + && !m_pFontsAttrList->hasAttribute(FSNS(XML_w, XML_asciiTheme)); } else if ( m_pFontsAttrList.is() && rGrabBagElement.first == "CharThemeFontNameEastAsia" ) { if ( rGrabBagElement.second >>= sOriginalValue ) bWriteEastAsiaTheme = - ( m_pFontsAttrList->getOptionalValue( FSNS( XML_w, XML_eastAsia ) ) == sOriginalValue ); + (m_pFontsAttrList->getOptionalValue(FSNS(XML_w, XML_eastAsia)) == sOriginalValue) + && !m_pFontsAttrList->hasAttribute(FSNS(XML_w, XML_eastAsiaTheme)); } }
