Kaydet (Commit) 455e2172 authored tarafından Khaled Hosny's avatar Khaled Hosny

Fix Core Text GetCaretPositions()

The secondary caret is a special caret that is inserted when the text
changes its direction e.g. between an RTL and LTR segments, not
whatever who wrote this code thought it is.

This should now be more or less the same as ATSUI version (for better or
worse), though it probably makes no difference anyway since
GetCaretPositions(), despite its name, is *not* used for determining
caret positions but only for drawing mnemonic underlines, and we don’t
draw any menus by ourselves on Mac.

While at it, adopt variable naming used in the rest of the code (not the
spacing, though. Why any sane person would want no space before opening
parenthesis and space after it!).

Change-Id: I3e8d1db33c899d0c69f65b57f0a52d10cbed1025
üst 0ac44511
......@@ -373,20 +373,25 @@ bool CoreTextLayout::GetBoundRect( SalGraphics& rGraphics, Rectangle& rVCLRect )
return true;
}
void CoreTextLayout::GetCaretPositions( int max_index, sal_Int32* caret_position ) const
void CoreTextLayout::GetCaretPositions(int nMaxIndex, sal_Int32* pCaretXArray) const
{
SAL_INFO( "vcl.coretext.layout", "GetCaretPositions(" << this << ",max_index=" << max_index << ")" );
int local_max = max_index < mnCharCount * 2 ? max_index : mnCharCount;
for( int i = 0 ; i < max_index - 1; i+=2 ) {
CGFloat primary, secondary;
primary = CTLineGetOffsetForStringIndex(mpLine, i >> 1, &secondary);
caret_position[i] = round_to_long(mnBaseAdvance + primary);
caret_position[i+1] = round_to_long(mnBaseAdvance + secondary);
i += 2;
}
for( int i = local_max ; i < max_index ; ++i ) {
caret_position[i] = -1;
SAL_INFO( "vcl.coretext.layout", "GetCaretPositions(" << this << ",nMaxIndex=" << nMaxIndex << ")" );
// initialize the caret positions
for (int i = 0; i < nMaxIndex; ++i)
pCaretXArray[i] = -1;
for (int i = 0 ; i < mnCharCount; i++)
{
CGFloat fPrimary, fSecondary;
fPrimary = CTLineGetOffsetForStringIndex(mpLine, i, &fSecondary);
// update previous trailing position
if (i > 0)
pCaretXArray[2*i-1] = round_to_long(mnBaseAdvance + fPrimary);
// update current leading position
if (2*i >= nMaxIndex)
break;
pCaretXArray[2*i+0] = round_to_long(mnBaseAdvance + fPrimary);
}
}
......
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