diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2018-11-12 15:07:58 +0300 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-11-19 16:02:28 +0100 |
commit | 7c7f46faa213d9c20bf5cebcc72b0f5dc86b0248 (patch) | |
tree | 4db4419052b8caeee9e3584ddf4913cdea8dc72f /sw/source | |
parent | 21467c1c0fea676a33c7b7e75648947efea18fcb (diff) |
tdf#120677: restore treatment of blanks in SwTextGuess::Guess
Before commit 0be3db28a4db4d2c81a5cb2edd48711eec55b51b, all non-breakable
spaces were converted to plain spaces in SwTextSlot::SwTextSlot (see
pInf->SetText call there). The mentioned commit has changed that to allow
differentiating non-breakable spaces from other types of spaces (related
to the fix of tdf#115067). This broke following processing of the NBSPs
when they don't fit to line, causing infinite layout loop leading to OOM.
This allows to restore old behavior to not call the break iterator for
NBSP by explicitly checking for it.
Change-Id: I36ab06abb66bbe65a5fc542c41e816a9f20a2dcf
Reviewed-on: https://gerrit.libreoffice.org/63290
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 4bb28ad217ea9d6511b6921dcd3d28328edcb4d6)
Reviewed-on: https://gerrit.libreoffice.org/63304
Tested-by: Xisco Faulí <xiscofauli@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/text/guess.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 6b37ce710dc4..117656b5c69d 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -40,7 +40,14 @@ using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::linguistic2; -#define CH_FULL_BLANK 0x3000 +namespace{ + +const sal_Unicode CH_FULL_BLANK = 0x3000; +const sal_Unicode CH_NB_SPACE = 0xA0; + +bool IsBlank(sal_Unicode ch) { return ch == CH_BLANK || ch == CH_FULL_BLANK || ch == CH_NB_SPACE; } + +} // provides information for line break calculation // returns true if no line break has to be performed @@ -243,7 +250,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, sal_Unicode cCutChar = nCutPos < TextFrameIndex(rInf.GetText().getLength()) ? rInf.GetText()[sal_Int32(nCutPos)] : 0; - if( CH_BLANK == cCutChar || CH_FULL_BLANK == cCutChar ) + if (IsBlank(cCutChar)) { nBreakPos = nCutPos; TextFrameIndex nX = nBreakPos; @@ -253,23 +260,20 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // we step back until a non blank character has been found // or there is only one more character left while (nX && TextFrameIndex(rInf.GetText().getLength()) < nBreakPos && - ( CH_BLANK == ( cCutChar = rInf.GetChar( --nX ) ) || - CH_FULL_BLANK == cCutChar ) ) + IsBlank(rInf.GetChar(--nX))) --nBreakPos; } else // #i20878# { while (nX && nBreakPos > rInf.GetLineStart() + TextFrameIndex(1) && - ( CH_BLANK == ( cCutChar = rInf.GetChar( --nX ) ) || - CH_FULL_BLANK == cCutChar ) ) + IsBlank(rInf.GetChar(--nX))) --nBreakPos; } if( nBreakPos > rInf.GetIdx() ) nPorLen = nBreakPos - rInf.GetIdx(); while (++nCutPos < TextFrameIndex(rInf.GetText().getLength()) && - ( CH_BLANK == ( cCutChar = rInf.GetChar( nCutPos ) ) || - CH_FULL_BLANK == cCutChar ) ) + IsBlank(rInf.GetChar(nCutPos))) ; // nothing nBreakStart = nCutPos; |