diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-01-19 11:11:43 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-01-26 09:30:11 +0000 |
commit | d3fe36ac90c3186f14405305e07b700de6f01581 (patch) | |
tree | e3ab3796370f919e1d926fc884a217c3cce9dc79 /sw/qa/extras | |
parent | 6c6881f9c1011366c58176646f1770f6ecf7f4cf (diff) |
bnc#1014896 tdf#105417 sw hyphenation: avoid infinite loop on ...
... zero-length last line
This hang happened when the user executed Tools -> Language ->
Hyphenation -> Hyphenate All.
This problem is visible only if all of these conditions are met:
- a line in a paragraph has a word that already contains a soft-hyphen,
but not at the position where the automatic hyphenation would insert
it
- the last line ends with a word that can be hyphenated
- there is a fly frame in the document
In this case it happens during hyphenation that the layout has an
additional empty line at the end (which is removed by the time the
layout finishes), so we hit the case when SwTextFormatter::Hyphenate()
skips the "if( m_pCurr->PrtWidth() && m_pCurr->GetLen() )" block.
Normally hyphenation terminates when it iterates over the portions of the
line and no overrun nor any existing hyphen portion are seen, but in
this case that never happened. Fix the problem by terminating not only
when we reach the end of the portion iteration, but also when the
portion list is non-existing (has zero length).
(cherry picked from commit 1b6fa616087e7415be9dc7113bbd8bf381aadd70)
Conflicts:
sw/qa/extras/uiwriter/uiwriter.cxx
sw/source/uibase/lingu/hyp.cxx
Change-Id: I71d4b040a2d4692ae6eb92807dbbbb42b077a0f8
Reviewed-on: https://gerrit.libreoffice.org/33310
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sw/qa/extras')
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf105417.odt | bin | 0 -> 9238 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 27 |
2 files changed, 27 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf105417.odt b/sw/qa/extras/uiwriter/data/tdf105417.odt Binary files differnew file mode 100644 index 000000000000..d594d2a5aed5 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf105417.odt diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index b3f4d63568ff..d68e957ea474 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -85,6 +85,7 @@ #include <paratr.hxx> #include <drawfont.hxx> #include <txtfrm.hxx> +#include <hyp.hxx> #include <editeng/svxenum.hxx> #include <comphelper/propertysequence.hxx> #include <sfx2/classificationhelper.hxx> @@ -92,6 +93,7 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/dispatch.hxx> #include <comphelper/propertyvalue.hxx> +#include <editeng/unolingu.hxx> static const char* DATA_DIRECTORY = "/sw/qa/extras/uiwriter/data/"; @@ -201,6 +203,7 @@ public: void testTdf95699(); void testTdf104440(); void testTdf104425(); + void testTdf105417(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -303,6 +306,7 @@ public: CPPUNIT_TEST(testTdf95699); CPPUNIT_TEST(testTdf104440); CPPUNIT_TEST(testTdf104425); + CPPUNIT_TEST(testTdf105417); CPPUNIT_TEST_SUITE_END(); private: @@ -3516,6 +3520,29 @@ void SwUiWriterTest::testTdf104425() CPPUNIT_ASSERT_DOUBLES_EQUAL(700.0, fSumHeight_mm, 0.05); } +void SwUiWriterTest::testTdf105417() +{ + SwDoc* pDoc = createDoc("tdf105417.odt"); + CPPUNIT_ASSERT(pDoc); + SwView* pView = pDoc->GetDocShell()->GetView(); + CPPUNIT_ASSERT(pView); + uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); + CPPUNIT_ASSERT(xHyphenator.is()); + // If there are no English hyphenation rules installed, we can't test + // hyphenation. + if (!xHyphenator->hasLocale(lang::Locale("en", "US", OUString()))) + return; + + uno::Reference<linguistic2::XLinguProperties> xLinguProperties(LinguMgr::GetLinguPropertySet()); + // Automatic hyphenation means not opening a dialog, but going ahead + // non-interactively. + xLinguProperties->setIsHyphAuto(true); + SwHyphWrapper aWrap(pView, xHyphenator, /*bStart=*/false, /*bOther=*/true, /*bSelection=*/false); + // This never returned, it kept trying to hyphenate the last word + // (greenbacks) again and again. + aWrap.SpellDocument(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); |