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 301c94a73b96c45cb4bf6ed23b7626cb43a98605 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: Fri Aug 19 07:59:27 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> (cherry picked from commit 619a00a0e6ec7d7c2462b533e0ba506732d94e8e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138424 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 73b9bcfbf6d0..45e690a7643c 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -3045,6 +3045,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 d469083f7eb1..d209105cd523 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -254,7 +254,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); }