sw/qa/extras/odfexport/data/tdf150394.odt |binary sw/qa/extras/odfexport/odfexport.cxx | 6 ++++++ sw/source/core/text/guess.cxx | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-)
New commits: commit f0454fe3bb5f8b589cc994203060a94d5cdad0a4 Author: László Németh <nem...@numbertext.org> AuthorDate: Mon Aug 15 12:12:23 2022 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Thu Aug 18 11:47:15 2022 +0200 tdf#150394 sw: fix crash of "Don't hyphenate last word" Multiline last words, e.g. long URLs resulted crashing using the new hyphenation option "Don't hyphenate last word". Follow-up to commit 8c018910ae4d8701b1ce2a95727b9baed4016da3 "tdf#149248 sw offapi xmloff: add option to not hyphenate last word". Note: .fodt format is not applicable for unit testing. Change-Id: I8633af1517f09003b40a06825ad14f3ed7f882a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138296 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/odfexport/data/tdf150394.odt b/sw/qa/extras/odfexport/data/tdf150394.odt new file mode 100644 index 000000000000..e514f405bcd3 Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf150394.odt differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index ad65d884437b..1ff5f4574a45 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -3057,6 +3057,12 @@ DECLARE_ODFEXPORT_TEST(tdf149248, "tdf149248.odt") CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getParagraph(4), "ParaHyphenationNoLastWord")); } +DECLARE_ODFEXPORT_TEST(testTdf150394, "tdf150394.odt") +{ + // crashes at import time + CPPUNIT_ASSERT_EQUAL(1, getPages()); +} + DECLARE_ODFEXPORT_TEST(tdf149324, "tdf149324.odt") { CPPUNIT_ASSERT_EQUAL(1, getPages()); diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 34681c158ed4..23b7319b5b14 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -257,7 +257,12 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // don't hyphenate the last word of the paragraph if ( bHyphenationNoLastWord && sal_Int32(m_nCutPos) > nLastWord && - TextFrameIndex(COMPLETE_STRING) != m_nCutPos ) + TextFrameIndex(COMPLETE_STRING) != m_nCutPos && + // if the last word is multiple line long, e.g. an URL, + // apply this only if the space before the word is there + // in the actual line, i.e. start the long word in a new + // line, but still allows to break its last parts + sal_Int32(rInf.GetIdx()) < nLastWord ) { m_nCutPos = TextFrameIndex(nLastWord); }