Kaydet (Commit) c1ab08f2 authored tarafından navin's avatar navin Kaydeden (comit) Lior Kaplan

fix fdo#38951, use paragraph’s writing direction.

In case of RTL, we want bullet text e.g. “1. ,1)” to be reversed
e.g. “.1,(1”, so we need to check only paragraph’s writing direction
and pass that direction to DrawingText().
and fix drawing position calculation logic.

Change-Id: I303dc1b04ae5e66b1b5d25a40794be308f36668b
Reviewed-on: https://gerrit.libreoffice.org/2348Reviewed-by: 's avatarAhmad Harthi <aalharthi@kacst.edu.sa>
Tested-by: 's avatarAhmad Harthi <aalharthi@kacst.edu.sa>
(cherry picked from commit 2738fa9f)
Signed-off-by: 's avatarLior Kaplan <kaplanlior@gmail.com>
üst c388bdf4
...@@ -389,7 +389,7 @@ public: ...@@ -389,7 +389,7 @@ public:
unsigned mbEndOfBullet : 1; unsigned mbEndOfBullet : 1;
sal_uInt8 GetBiDiLevel() const { return mnBiDiLevel; } sal_uInt8 GetBiDiLevel() const { return mnBiDiLevel; }
sal_Bool IsRTL() const; sal_Bool IsRTL() const { return mnBiDiLevel % 2 ? sal_True : sal_False; }
DrawPortionInfo( DrawPortionInfo(
const Point& rPos, const Point& rPos,
......
...@@ -950,7 +950,7 @@ void Outliner::PaintBullet( sal_uInt16 nPara, const Point& rStartPos, ...@@ -950,7 +950,7 @@ void Outliner::PaintBullet( sal_uInt16 nPara, const Point& rStartPos,
if ( !bRightToLeftPara ) if ( !bRightToLeftPara )
aTextPos.X() = rStartPos.X() + aBulletArea.Left(); aTextPos.X() = rStartPos.X() + aBulletArea.Left();
else else
aTextPos.X() = rStartPos.X() + GetPaperSize().Width() - aBulletArea.Left(); aTextPos.X() = rStartPos.X() + GetPaperSize().Width() - aBulletArea.Right();
} }
else else
{ {
...@@ -984,7 +984,7 @@ void Outliner::PaintBullet( sal_uInt16 nPara, const Point& rStartPos, ...@@ -984,7 +984,7 @@ void Outliner::PaintBullet( sal_uInt16 nPara, const Point& rStartPos,
sal_uLong nLayoutMode = pOutDev->GetLayoutMode(); sal_uLong nLayoutMode = pOutDev->GetLayoutMode();
nLayoutMode &= ~(TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG); nLayoutMode &= ~(TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_COMPLEX_DISABLED|TEXT_LAYOUT_BIDI_STRONG);
if ( bRightToLeftPara ) if ( bRightToLeftPara )
nLayoutMode |= TEXT_LAYOUT_BIDI_RTL; nLayoutMode |= TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_LEFT;
pOutDev->SetLayoutMode( nLayoutMode ); pOutDev->SetLayoutMode( nLayoutMode );
if(bStrippingPortions) if(bStrippingPortions)
...@@ -1001,7 +1001,7 @@ void Outliner::PaintBullet( sal_uInt16 nPara, const Point& rStartPos, ...@@ -1001,7 +1001,7 @@ void Outliner::PaintBullet( sal_uInt16 nPara, const Point& rStartPos,
} }
DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), pBuf, DrawingText(aTextPos, pPara->GetText(), 0, pPara->GetText().getLength(), pBuf,
aSvxFont, nPara, 0xFFFF, 0xFF, 0, 0, false, false, true, 0, Color(), Color()); aSvxFont, nPara, 0xFFFF, bRightToLeftPara, 0, 0, false, false, true, 0, Color(), Color());
delete[] pBuf; delete[] pBuf;
} }
...@@ -2099,36 +2099,4 @@ bool Outliner::HasParaFlag( const Paragraph* pPara, sal_uInt16 nFlag ) const ...@@ -2099,36 +2099,4 @@ bool Outliner::HasParaFlag( const Paragraph* pPara, sal_uInt16 nFlag ) const
return pPara && pPara->HasFlag( nFlag ); return pPara && pPara->HasFlag( nFlag );
} }
sal_Bool DrawPortionInfo::IsRTL() const
{
if(0xFF == mnBiDiLevel)
{
// Use Bidi functions from icu 2.0 to calculate if this portion
// is RTL or not.
UErrorCode nError(U_ZERO_ERROR);
UBiDi* pBidi = ubidi_openSized(mrText.Len(), 0, &nError);
nError = U_ZERO_ERROR;
// I do not have this info here. Is it necessary? I'll have to ask MT.
const sal_uInt8 nDefaultDir = UBIDI_LTR; //IsRightToLeft( nPara ) ? UBIDI_RTL : UBIDI_LTR;
ubidi_setPara(pBidi, reinterpret_cast<const UChar *>(mrText.GetBuffer()), mrText.Len(), nDefaultDir, NULL, &nError); // UChar != sal_Unicode in MinGW
nError = U_ZERO_ERROR;
int32_t nStart(0);
int32_t nEnd;
UBiDiLevel nCurrDir;
ubidi_getLogicalRun(pBidi, nStart, &nEnd, &nCurrDir);
ubidi_close(pBidi);
// remember on-demand calculated state
((DrawPortionInfo*)this)->mnBiDiLevel = nCurrDir;
}
return (1 == (mnBiDiLevel % 2));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment