sw/qa/extras/ooxmlexport/data/tdf167721_zeroCh.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport22.cxx | 10 ++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-)
New commits: commit 104a7e6b50329450cf7757fbede0c8acc734fb1f Author: Justin Luth <jl...@mail.com> AuthorDate: Thu Aug 14 13:55:53 2025 -0400 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Aug 19 16:50:15 2025 +0200 tdf#167721 docx export: don't spam *Chars=0 I don't think we ever import this situation in DOCX (and no existing unit tests were found), but if a margin is stored in LO as FONT_CJK_ADVANCE 0.0 then it is already written out as disabled, so a style that inherits that disabled item doesn't need to re-disable it. make CppunitTest_sw_ooxmlexport22 \ CPPUNIT_TEST_NAME=testTdf167721_zeroCh Change-Id: Id6c90ca3e4704f2baf3619cce6470b517ea1772f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189637 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189652 diff --git a/sw/qa/extras/ooxmlexport/data/tdf167721_zeroCh.odt b/sw/qa/extras/ooxmlexport/data/tdf167721_zeroCh.odt new file mode 100644 index 000000000000..064204cde7a4 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf167721_zeroCh.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx index a929eb6faad0..9426ec190668 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport22.cxx @@ -357,6 +357,16 @@ DECLARE_OOXMLEXPORT_TEST(testTdf167721_chUnits3, "tdf167721_chUnits3.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(353), getProperty<sal_Int32>(xPara, u"ParaRightMargin"_ustr)); } +CPPUNIT_TEST_FIXTURE(Test, testTdf167721_zeroCh) +{ + loadAndSave("tdf167721_zeroCh.odt"); + + xmlDocUniquePtr pXmlStyles = parseExport(u"word/styles.xml"_ustr); + + // only one style should disable the ic-unit right margin with a zero. + assertXPath(pXmlStyles, "//w:ind[@w:endChars='0']", 1); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf83844) { createSwDoc("tdf83844.fodt"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index cd8042d56eaa..d1c000cf20ac 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -9437,7 +9437,7 @@ void DocxAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rF if (pInherited) { stValue = pInherited->GetTextFirstLineOffset(); - if (stValue.m_nUnit == css::util::MeasureUnit::FONT_CJK_ADVANCE) + if (stValue.m_nUnit == css::util::MeasureUnit::FONT_CJK_ADVANCE && stValue.m_dValue != 0.0) { AddToAttrList(m_pLRSpaceAttrList, FSNS(XML_w, @@ -9521,7 +9521,7 @@ void DocxAttributeOutput::FormatTextLeftMargin(SvxTextLeftMarginItem const& rTex if (pInherited) { stValue = pInherited->GetTextLeft(); - if (stValue.m_nUnit == css::util::MeasureUnit::FONT_CJK_ADVANCE) + if (stValue.m_nUnit == css::util::MeasureUnit::FONT_CJK_ADVANCE && stValue.m_dValue != 0.0) { AddToAttrList(m_pLRSpaceAttrList, FSNS(XML_w, bEcma1st ? XML_leftChars : XML_startChars), @@ -9561,7 +9561,7 @@ void DocxAttributeOutput::FormatRightMargin(SvxRightMarginItem const& rRightMarg if (pInherited) { stValue = pInherited->GetRight(); - if (stValue.m_nUnit == css::util::MeasureUnit::FONT_CJK_ADVANCE) + if (stValue.m_nUnit == css::util::MeasureUnit::FONT_CJK_ADVANCE && stValue.m_dValue != 0.0) { AddToAttrList(m_pLRSpaceAttrList, FSNS(XML_w, bEcma1st ? XML_rightChars : XML_endChars), OString::number(0));