diff options
author | Khaled Hosny <khaledhosny@eglug.org> | 2018-03-12 17:41:36 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-03-12 23:05:18 +0100 |
commit | 489c7088b4a99720d1a2839ed52b3becd7aac342 (patch) | |
tree | fd4287d2fa4420108526402ad406cf6729a1a785 | |
parent | 91bed85d835d038c993a548ce76025165d962f2b (diff) |
tdf#116322: Don’t hard-code RTL character ranges
Calc’s ScOutputData::LayoutStrings() has an optimization that skips edit
engine for what it seems to consider simple enough text (single script,
no bidi controls, etc) and it ends up calling this code in OutputDevice
that hard-codes RTL character ranges and skips bidi algorithm if none is
found. Since the list of RTL characters is not fixed and new version of
Unicode can added new RTL characters, help the next boor soul that will
spend another day debugging this in the future by removing the
hard-coded RTL ranges and instead check for some known LTR ranges.
Change-Id: I6eb8fd3d1342a5539d607bf54e9c2de31f5a32b4
Reviewed-on: https://gerrit.libreoffice.org/51118
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r-- | vcl/source/outdev/text.cxx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index ef7f4c249642..f51dbabc558c 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -1190,15 +1190,20 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr, nLayoutFlags |= SalLayoutFlags::BiDiStrong; else if( !(mnTextLayoutMode & ComplexTextLayoutFlags::BiDiRtl) ) { - // disable Bidi if no RTL hint and no RTL codes used - const sal_Unicode* pStr = rStr.getStr() + nMinIndex; - const sal_Unicode* pEnd = rStr.getStr() + nEndIndex; - for( ; pStr < pEnd; ++pStr ) - if( ((*pStr >= 0x0580) && (*pStr < 0x0800)) // middle eastern scripts - || ((*pStr >= 0xFB18) && (*pStr < 0xFE00)) // hebrew + arabic A presentation forms - || ((*pStr >= 0xFE70) && (*pStr < 0xFEFF)) ) // arabic presentation forms B + // Disable Bidi if no RTL hint and only known LTR codes used. + bool bAllLtr = true; + for (sal_Int32 i = nMinIndex; i < nEndIndex; i++) + { + // [0x0000, 0x052F] are Latin, Greek and Cyrillic. + // [0x0370, 0x03FF] has a few holes as if Unicode 10.0.0, but + // hopefully no RTL character will be encoded there. + if (rStr[i] > 0x052F) + { + bAllLtr = false; break; - if( pStr >= pEnd ) + } + } + if (bAllLtr) nLayoutFlags |= SalLayoutFlags::BiDiStrong; } |