summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Hung <marklh9@gmail.com>2018-04-01 19:33:00 +0800
committerMark Hung <marklh9@gmail.com>2018-04-07 09:38:18 +0200
commita0bcbf72614344639235a46d1cc81483f93a3d61 (patch)
tree0d938984c377395f1bbc94d381b070ee1345701f
parent7b185bef65472d10f9fb65d24e0757b90172796c (diff)
tdf#116182: correct the index before using CalcSpacing.
Keep the index of pLastBidiPor when it is set, then correct the index before invoking pLastBidiPor->CalSpacing, otherwise we are invoking CalSpacing with SwTextSizeInfo that has incorrect index. Change-Id: Ifd6b598ea3c860dcf61fb2c47029ef8c1c912dd1 Reviewed-on: https://gerrit.libreoffice.org/52222 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mark Hung <marklh9@gmail.com>
-rw-r--r--sw/source/core/text/itrcrsr.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/sw/source/core/text/itrcrsr.cxx b/sw/source/core/text/itrcrsr.cxx
index 4abf0cb7a153..750492f7e83e 100644
--- a/sw/source/core/text/itrcrsr.cxx
+++ b/sw/source/core/text/itrcrsr.cxx
@@ -502,6 +502,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, const sal_Int32 nOfst,
SwTwips nTmpFirst = 0;
SwLinePortion *pPor = m_pCurr->GetFirstPortion();
SwBidiPortion* pLastBidiPor = nullptr;
+ sal_Int32 nLastBidiIdx = -1;
SwTwips nLastBidiPorWidth = 0;
std::deque<sal_uInt16>* pKanaComp = m_pCurr->GetpKanaComp();
sal_uInt16 nSpaceIdx = 0;
@@ -646,6 +647,7 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, const sal_Int32 nOfst,
aInf.GetIdx() + pPor->GetLen() == nOfst )
{
pLastBidiPor = static_cast<SwBidiPortion*>(pPor);
+ nLastBidiIdx = aInf.GetIdx();
nLastBidiPorWidth = pLastBidiPor->Width() +
pLastBidiPor->CalcSpacing( nSpaceAdd, aInf );
}
@@ -1122,8 +1124,12 @@ void SwTextCursor::GetCharRect_( SwRect* pOrig, const sal_Int32 nOfst,
{
OSL_ENSURE( static_cast<const SwMultiPortion*>(pLast)->IsBidi(),
"Non-BidiPortion inside BidiPortion" );
+ sal_Int32 nIdx = aInf.GetIdx();
+ // correct the index before using CalcSpacing.
+ aInf.SetIdx(nLastBidiIdx);
pOrig->Pos().AdjustX(pLast->Width() +
pLast->CalcSpacing( nSpaceAdd, aInf ) );
+ aInf.SetIdx(nIdx);
}
}
}