diff options
author | Michael Stahl <mstahl@redhat.com> | 2013-09-02 15:58:00 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-09-03 11:52:32 +0000 |
commit | aa9bef8271ed50a397c959ed53c91ee44b3dcb10 (patch) | |
tree | 9fcfdfd2cfd5bdd4e48f6162736c535d85b12215 | |
parent | 312ddda98c447925bd85721f361ab9a4ecba4fef (diff) |
fdo#68750: ensure that GetSuggestedEndOfSentence makes progress
Checking a string of 17399 spaces takes 20 seconds here in
GrammarCheckingIterator::GetSuggestedEndOfSentence() because
BreakIterator_Unicode::endOfSentence() will always return
0 as a result regardless of what nStartPos it gets.
Change-Id: Id02440a91d7015c2896e387854445ee5383092fa
(cherry picked from commit b23999755a865a277c29adfc1dc0c249275bfd7e)
Reviewed-on: https://gerrit.libreoffice.org/5758
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | linguistic/source/gciterator.cxx | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 4c08a9eed79d..f12b6f2136aa 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -754,13 +754,23 @@ sal_Int32 GrammarCheckingIterator::GetSuggestedEndOfSentence( m_xBreakIterator = i18n::BreakIterator::create(xContext); } sal_Int32 nTextLen = rText.getLength(); - sal_Int32 nEndPosition; + sal_Int32 nEndPosition(0); sal_Int32 nTmpStartPos = nSentenceStartPos; do { + sal_Int32 const nPrevEndPosition(nEndPosition); nEndPosition = nTextLen; if (nTmpStartPos < nTextLen) + { nEndPosition = m_xBreakIterator->endOfSentence( rText, nTmpStartPos, rLocale ); + if (nEndPosition <= nPrevEndPosition) + { + // fdo#68750 if there's no progress at all then presumably + // there's no end of sentence in this paragraph so just + // set the end position to end of paragraph + nEndPosition = nTextLen; + } + } if (nEndPosition < 0) nEndPosition = nTextLen; |