Kaydet (Commit) 6c76a0a8 authored tarafından Justin Luth's avatar Justin Luth Kaydeden (comit) Caolán McNamara

tdf#91641 adjust cursor when deleting preceding characters

IMDeleteSurrounding is used by input methods to take multiple
keystrokes and convert them into a special character.  Then the
composing keystrokes are removed.
Before this fix, the cursor placement was not adjusted,
so the special character was inserted in the wrong position
and if 3+ keystrokes were involved, the wrong characters were deleted.

Change-Id: I35b97bc150dc68ffe65eebc59450e21e0033bd16
Reviewed-on: https://gerrit.libreoffice.org/15961Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst c0a79b1d
...@@ -4655,7 +4655,7 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint ...@@ -4655,7 +4655,7 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin); uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin);
if (xText.is()) if (xText.is())
{ {
sal_uInt32 nPosition = xText->getCaretPosition(); sal_Int32 nPosition = xText->getCaretPosition();
// #i111768# range checking // #i111768# range checking
sal_Int32 nDeletePos = nPosition + offset; sal_Int32 nDeletePos = nPosition + offset;
sal_Int32 nDeleteEnd = nDeletePos + nchars; sal_Int32 nDeleteEnd = nDeletePos + nchars;
...@@ -4667,6 +4667,14 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint ...@@ -4667,6 +4667,14 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
nDeleteEnd = xText->getCharacterCount(); nDeleteEnd = xText->getCharacterCount();
xText->deleteText(nDeletePos, nDeleteEnd); xText->deleteText(nDeletePos, nDeleteEnd);
//tdf91641 adjust cursor if deleted chars shift it forward (normal case)
if (nDeletePos < nPosition)
{
if (nDeleteEnd <= nPosition)
xText->setCaretPosition( nPosition-(nDeleteEnd-nDeletePos) );
else
xText->setCaretPosition( nDeletePos );
}
return true; return true;
} }
......
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