tdf#159032 sw smart justify: fix crash with complex tables
Regression from commit 36bfc86e27fa03ee16f87819549ab126c5a68cac
"tdf#119908 tdf#158776 sw smart justify: shrink only spaces"
Change-Id: Ia3f39ad6549ea909bfe327ff8c8cbde821b90f46
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161652
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf124795-5.docx b/sw/qa/extras/ooxmlexport/data/tdf124795-5.docx
new file mode 100644
index 0000000..19fd5f4
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf124795-5.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 0656bb8..4b0fbdd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -1414,6 +1414,12 @@ DECLARE_OOXMLEXPORT_TEST(testTdf158436, "tdf158436.docx")
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
DECLARE_OOXMLEXPORT_TEST(testTdf159032, "tdf124795-5.docx")
{
// This resulted crashing
CPPUNIT_ASSERT_EQUAL(57, getPages());
}
CPPUNIT_TEST_FIXTURE(Test, testHyphenationAuto)
{
loadAndReload("hyphenation.odt");
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index 0372a35..228e2e0 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -308,6 +308,7 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf )
// adjusted line by shrinking spaces using the know space count from the first Guess() call
const SvxAdjust& rAdjust = rInf.GetTextFrame()->GetTextNodeForParaProps()->GetSwAttrSet().GetAdjust().GetAdjust();
if ( bFull && rAdjust == SvxAdjust::Block &&
aGuess.BreakPos() != TextFrameIndex(COMPLETE_STRING) &&
rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(
DocumentSettingId::JUSTIFY_LINES_WITH_SHRINKING) &&
// tdf#158436 avoid shrinking at underflow, e.g. no-break space after a