summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorJustin Luth <justin_luth@sil.org>2015-06-30 15:55:46 +0300
committerCaolán McNamara <caolanm@redhat.com>2015-06-30 14:37:08 +0000
commit227e7f903fee64d63b48bd31707887ba28a019bc (patch)
tree03db0a4d6e8894d1414b954b12ab99f03ef6930f /vcl
parent59487150df556457cb3c919b0b0ea5d6b625b185 (diff)
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. Also fixes "editLine should have focus on accessibleText init." The first time an accessibleEdit is created, it didnt recognize any focused text when editing in the "Input Line". Change-Id: I5be9b75f74d4df82fbd57da3817a626b5fcbeba1 Reviewed-on: https://gerrit.libreoffice.org/15961 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-on: https://gerrit.libreoffice.org/16619
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/gtk/window/gtksalframe.cxx12
1 files changed, 10 insertions, 2 deletions
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
index 017b7f1f2c91..7d25640b4c64 100644
--- a/vcl/unx/gtk/window/gtksalframe.cxx
+++ b/vcl/unx/gtk/window/gtksalframe.cxx
@@ -4630,7 +4630,7 @@ gboolean GtkSalFrame::IMHandler::signalIMRetrieveSurrounding( GtkIMContext* pCon
uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin);
if (xText.is())
{
- sal_uInt32 nPosition = xText->getCaretPosition();
+ sal_Int32 nPosition = xText->getCaretPosition();
OUString sAllText = xText->getText();
OString sUTF = OUStringToOString(sAllText, RTL_TEXTENCODING_UTF8);
OUString sCursorText(sAllText.copy(0, nPosition));
@@ -4652,7 +4652,7 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
uno::Reference<accessibility::XAccessibleEditableText> xText = lcl_GetxText(pFocusWin);
if (xText.is())
{
- sal_uInt32 nPosition = xText->getCaretPosition();
+ sal_Int32 nPosition = xText->getCaretPosition();
// #i111768# range checking
sal_Int32 nDeletePos = nPosition + offset;
sal_Int32 nDeleteEnd = nDeletePos + nchars;
@@ -4664,6 +4664,14 @@ gboolean GtkSalFrame::IMHandler::signalIMDeleteSurrounding( GtkIMContext*, gint
nDeleteEnd = xText->getCharacterCount();
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;
}