summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2018-01-21 13:22:51 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-22 07:05:25 +0100
commitdf9a20fc3fce72ab19e71f3b17c43b5cb97dc871 (patch)
treed45c5ba3fd0c5449c7c009c63d4c55a80db7ba00 /vcl
parent3b666f6819bb0230520bc724d5e33a7a349aa15c (diff)
improve RTL detection in TextEngine
the ubidi_getLogicalRun call returns a direction bool in bit 0, so the old code would only have been correct for embedding level 0. found by an up and coming loplugin. Change-Id: I56658981fbd32caf0d961d47d76b668f1dd1b680 Reviewed-on: https://gerrit.libreoffice.org/48261 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/edit/textdat2.hxx6
-rw-r--r--vcl/source/edit/texteng.cxx11
2 files changed, 9 insertions, 8 deletions
diff --git a/vcl/source/edit/textdat2.hxx b/vcl/source/edit/textdat2.hxx
index a69c718fd140..3c60509594d7 100644
--- a/vcl/source/edit/textdat2.hxx
+++ b/vcl/source/edit/textdat2.hxx
@@ -99,11 +99,11 @@ public:
struct TEWritingDirectionInfo
{
- sal_uInt8 nType;
+ bool bLeftToRight;
sal_Int32 nStartPos;
sal_Int32 nEndPos;
- TEWritingDirectionInfo( sal_uInt8 Type, sal_Int32 Start, sal_Int32 End )
- : nType {Type}
+ TEWritingDirectionInfo( bool LeftToRight, sal_Int32 Start, sal_Int32 End )
+ : bLeftToRight {LeftToRight}
, nStartPos {Start}
, nEndPos {End}
{}
diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx
index ec57a36041a2..f8faf331ccf2 100644
--- a/vcl/source/edit/texteng.cxx
+++ b/vcl/source/edit/texteng.cxx
@@ -2778,7 +2778,8 @@ void TextEngine::ImpInitWritingDirections( sal_uInt32 nPara )
for ( long nIdx = 0; nIdx < nCount; ++nIdx )
{
ubidi_getLogicalRun( pBidi, nStart, &nEnd, &nCurrDir );
- rInfos.emplace_back( nCurrDir, nStart, nEnd );
+ // bit 0 of nCurrDir indicates direction
+ rInfos.emplace_back( /*bLeftToRight*/ nCurrDir % 2 == 0, nStart, nEnd );
nStart = nEnd;
}
@@ -2791,9 +2792,9 @@ void TextEngine::ImpInitWritingDirections( sal_uInt32 nPara )
}
-sal_uInt8 TextEngine::ImpGetRightToLeft( sal_uInt32 nPara, sal_Int32 nPos )
+bool TextEngine::ImpGetRightToLeft( sal_uInt32 nPara, sal_Int32 nPos )
{
- sal_uInt8 nRightToLeft = 0;
+ bool bRightToLeft = false;
TextNode* pNode = mpDoc->GetNodes()[ nPara ];
if ( pNode && !pNode->GetText().isEmpty() )
@@ -2807,12 +2808,12 @@ sal_uInt8 TextEngine::ImpGetRightToLeft( sal_uInt32 nPara, sal_Int32 nPos )
{
if ( rWritingDirectionInfo.nStartPos <= nPos && rWritingDirectionInfo.nEndPos >= nPos )
{
- nRightToLeft = rWritingDirectionInfo.nType;
+ bRightToLeft = !rWritingDirectionInfo.bLeftToRight;
break;
}
}
}
- return nRightToLeft;
+ return bRightToLeft;
}
long TextEngine::ImpGetPortionXOffset( sal_uInt32 nPara, TextLine const * pLine, std::size_t nTextPortion )