sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 4 ++-- sw/source/filter/ww8/ww8atr.cxx | 2 +- sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-)
New commits: commit b657b6c6c918fb7c239ad835db44de249b1c1763 Author: Justin Luth <jl...@mail.com> AuthorDate: Thu Jul 18 08:16:42 2024 -0400 Commit: Justin Luth <jl...@mail.com> CommitDate: Fri Jul 19 02:51:22 2024 +0200 related tdf#125469 docx im/export: better precision percent<->value A line spacing difference of 1.07 and 1.06 is significant for layout. Use rounding to get better round-trippability. This patch was created based on a code read, finding a DOUBLES unit test and having related coding attempts noticing integer precision loss. make CppunitTest_sw_ooxmlexport13 \ CPPUNIT_TEST_NAME=testTdf118947_tableStyle The export change is a blind fix (but older LO now opens ooxmlexport13's RT as 1.07% (256.8) because we now write w:line="257" (1.07083) instead of 256 (1.066). The import change is confirmed by ooxmlexport13 (matching Word 2010). Change-Id: I196af783b80688839c59058feb82bf00d40d9088 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170669 Tested-by: Jenkins Reviewed-by: Justin Luth <jl...@mail.com> diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index 3712cb56bade..c98b85f241a9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -501,7 +501,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle, "tdf118947_tableStyle.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("TextBody has 1pt space below paragraph", sal_Int32(35), getProperty<sal_Int32>(xPara, u"ParaBottomMargin"_ustr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table has 10pt space above paragraph", sal_Int32(353), getProperty<sal_Int32>(xPara, u"ParaTopMargin"_ustr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table style sets 0 right margin", sal_Int32(0), getProperty<sal_Int32>(xPara, u"ParaRightMargin"_ustr)); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("TextBody has 1.07 line-spacing", sal_Int16(107), getProperty<style::LineSpacing>(xPara, u"ParaLineSpacing"_ustr).Height, 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("TextBody has 1.07 line-spacing", sal_Int16(107), getProperty<style::LineSpacing>(xPara, u"ParaLineSpacing"_ustr).Height); // table-style based paragraph background color CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing paragraph background color in cell A1", Color(0xCCFFCC), getProperty<Color>(xPara, u"ParaBackColor"_ustr)); @@ -516,7 +516,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle, "tdf118947_tableStyle.docx") CPPUNIT_ASSERT_EQUAL_MESSAGE("Normal has 0pt space below paragraph", sal_Int32(0), getProperty<sal_Int32>(xPara, u"ParaBottomMargin"_ustr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table sets 10pt space above paragraph", sal_Int32(353), getProperty<sal_Int32>(xPara, u"ParaTopMargin"_ustr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Table style sets 0 right margin", sal_Int32(0), getProperty<sal_Int32>(xPara, u"ParaRightMargin"_ustr)); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table sets 2.5 line-spacing", sal_Int16(250), getProperty<style::LineSpacing>(xPara, u"ParaLineSpacing"_ustr).Height, 1); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Table sets 2.5 line-spacing", sal_Int16(250), getProperty<style::LineSpacing>(xPara, u"ParaLineSpacing"_ustr).Height); CPPUNIT_ASSERT_EQUAL_MESSAGE("Paragraph background color in cell A2", sal_Int32(-1), getProperty<sal_Int32>(xPara, u"ParaBackColor"_ustr)); CPPUNIT_ASSERT_EQUAL_MESSAGE("Compat mode overrides left adjust", style::ParagraphAdjust_RIGHT, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xPara, u"ParaAdjust"_ustr))); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 3b03cfdf7f13..d72db627eced 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -5162,7 +5162,7 @@ void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing ) else // Proportional { if ( rSpacing.GetInterLineSpaceRule() != SvxInterLineSpaceRule::Off ) - nSpace = static_cast<short>( ( 240L * rSpacing.GetPropLineSpace() ) / 100L ); + nSpace = static_cast<short>(round(240.0 * rSpacing.GetPropLineSpace() / 100)); nMulti = 1; } } diff --git a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx index 83a9301c0738..d814ab4ee603 100644 --- a/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapper_Impl.cxx @@ -5112,7 +5112,7 @@ void DomainMapper_Impl::SetLineSpacing(const Id nName, sal_Int32 nIntValue, bool appendGrabBag(m_aSubInteropGrabBag, u"line"_ustr, OUString::number(nIntValue)); // now set the value depending on the Mode if (aSpacing.Mode == style::LineSpacingMode::PROP) - aSpacing.Height = sal_Int16(nIntValue * 100 / nSingleLineSpacing); + aSpacing.Height = sal_Int16(round(nIntValue * 100.0 / nSingleLineSpacing)); else aSpacing.Height = sal_Int16(ConversionHelper::convertTwipToMm100_Limited(nIntValue)); } @@ -5126,9 +5126,9 @@ void DomainMapper_Impl::SetLineSpacing(const Id nName, sal_Int32 nIntValue, bool { aSpacing.Mode = style::LineSpacingMode::PROP; // reinterpret the already set value - aSpacing.Height - = sal_Int16(aSpacing.Height * 100 - / ConversionHelper::convertTwipToMm100_Limited(nSingleLineSpacing)); + aSpacing.Height = sal_Int16( + round(aSpacing.Height * 100.0 + / ConversionHelper::convertTwipToMm100_Limited(nSingleLineSpacing))); } else {