[Libreoffice-commits] core.git: include/vcl vcl/source
Noel Grandin
noelgrandin at gmail.com
Mon Jan 22 06:05:53 UTC 2018
include/vcl/texteng.hxx | 3 +--
vcl/source/edit/textdat2.hxx | 6 +++---
vcl/source/edit/texteng.cxx | 11 ++++++-----
3 files changed, 10 insertions(+), 10 deletions(-)
New commits:
commit df9a20fc3fce72ab19e71f3b17c43b5cb97dc871
Author: Noel Grandin <noelgrandin at gmail.com>
Date: Sun Jan 21 13:22:51 2018 +0200
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 at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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 )
More information about the Libreoffice-commits
mailing list