sw/qa/extras/odfexport/data/tdf163575.docx |binary sw/qa/extras/odfexport/odfexport2.cxx | 6 ++++++ sw/source/core/text/pormulti.cxx | 2 ++ 3 files changed, 8 insertions(+)
New commits: commit 270c96e12c4a14c4f9e130d15310843da3a6af68 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Oct 22 16:59:24 2024 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Oct 22 23:11:28 2024 +0200 tdf#163575 sw smart justify: fix size resolution for SwBidiPortion Negative space sizes (i.e. shrunk lines at image wrapping) stored over LONG_MAX/2, and these values had no resolution in SwBidiPortion, causing crash/assert in conversion of DOCX document containing e.g. Arabic text wrapping around images. Note: apply the resolution in SwDoubleLinePortion, too. Regression since commit 1fb6de02709a5f420f21ebd683915da50ce0d198 "tdf#163149 sw smart justify: fix line shrinking at image wrapping". Change-Id: I6e45592c4eed247871d35e1f02fd5a038baddf85 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175419 Reviewed-by: László Németh <nem...@numbertext.org> Tested-by: Jenkins diff --git a/sw/qa/extras/odfexport/data/tdf163575.docx b/sw/qa/extras/odfexport/data/tdf163575.docx new file mode 100644 index 000000000000..8d6c8f17fe69 Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf163575.docx differ diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index e4285bdbdb73..e365cf32ab08 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -550,6 +550,12 @@ CPPUNIT_TEST_FIXTURE(Test, tdf99631) assertXPathContent(pXmlDoc2, "//config:config-item[@config:name='VisibleAreaHeight']", u"1355"); } +CPPUNIT_TEST_FIXTURE(Test, tdf163575) +{ + // crashes/assert at export time + loadAndReload("tdf163575.docx"); +} + CPPUNIT_TEST_FIXTURE(Test, tdf145871) { loadAndReload("tdf145871.odt"); diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 1b9dcf6d0579..cdd52ee951fa 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -224,6 +224,7 @@ SwBidiPortion::SwBidiPortion(TextFrameIndex const nEnd, sal_uInt8 nLv) SwTwips SwBidiPortion::CalcSpacing( tools::Long nSpaceAdd, const SwTextSizeInfo& rInf ) const { + nSpaceAdd = nSpaceAdd > LONG_MAX/2 ? LONG_MAX/2 - nSpaceAdd : nSpaceAdd; return HasTabulator() ? 0 : sal_Int32(GetSpaceCnt(rInf)) * nSpaceAdd / SPACING_PRECISION_FACTOR; } @@ -510,6 +511,7 @@ void SwDoubleLinePortion::CalcBlanks( SwTextFormatInfo &rInf ) SwTwips SwDoubleLinePortion::CalcSpacing( tools::Long nSpaceAdd, const SwTextSizeInfo & ) const { + nSpaceAdd = nSpaceAdd > LONG_MAX/2 ? LONG_MAX/2 - nSpaceAdd : nSpaceAdd; return HasTabulator() ? 0 : sal_Int32(GetSpaceCnt()) * nSpaceAdd / SPACING_PRECISION_FACTOR; }