summaryrefslogtreecommitdiffstats
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
parentremove some sal_Bool remnants (diff)
downloadcore-df9a20fc3fce72ab19e71f3b17c43b5cb97dc871.tar.gz
core-df9a20fc3fce72ab19e71f3b17c43b5cb97dc871.zip
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>
-rw-r--r--include/vcl/texteng.hxx3
-rw-r--r--vcl/source/edit/textdat2.hxx6
-rw-r--r--vcl/source/edit/texteng.cxx11
3 files changed, 10 insertions, 10 deletions
diff --git a/include/vcl/texteng.hxx b/include/vcl/texteng.hxx
index dcab1dd337b2..7d642ee7e116 100644
--- a/include/vcl/texteng.hxx
+++ b/include/vcl/texteng.hxx
@@ -62,7 +62,6 @@ namespace svl
class TextLine;
class TETextPortion;
-
struct TEIMEInfos;
class SvtCTLOptions;
@@ -195,7 +194,7 @@ class VCL_DLLPUBLIC TextEngine : public SfxBroadcaster
long ImpGetPortionXOffset( sal_uInt32 nPara, TextLine const * pLine, std::size_t nTextPortion );
long ImpGetXPos( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nIndex, bool bPreferPortionStart = false );
long ImpGetOutputOffset( sal_uInt32 nPara, TextLine* pLine, sal_Int32 nIndex, sal_Int32 nIndex2 );
- sal_uInt8 ImpGetRightToLeft( sal_uInt32 nPara, sal_Int32 nPos );
+ bool ImpGetRightToLeft( sal_uInt32 nPara, sal_Int32 nPos );
static void ImpInitLayoutMode( OutputDevice* pOutDev );
TxtAlign ImpGetAlign() const;
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 )