summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2024-10-22 16:59:24 +0200
committerLászló Németh <nemeth@numbertext.org>2024-10-22 23:11:28 +0200
commit270c96e12c4a14c4f9e130d15310843da3a6af68 (patch)
treed19f1d88db2d46acad7c50c476568b8b007a6ead /sw
parenta07b4b432f47902290ff698ec48c79c63d3419ad (diff)
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 <nemeth@numbertext.org> Tested-by: Jenkins
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/odfexport/data/tdf163575.docxbin0 -> 59565 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport2.cxx6
-rw-r--r--sw/source/core/text/pormulti.cxx2
3 files changed, 8 insertions, 0 deletions
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
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf163575.docx
Binary files 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;
}