summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-10-22 14:20:17 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-10-22 18:05:46 +0200
commit2d1a8f83ce4c74b2ede1e93e8e1d309a61b8af23 (patch)
tree0543143257b27657a667718f579a3fb4808c8e63 /vcl
parentf09cd9d20a01e8bf8e55d9ffc17ad3b3d7b20116 (diff)
fix welded editengine delete-surrounding
Change-Id: I71c2f8e2483c2ef8d7f5cfcfcd7849f64792022f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104659 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/app/customweld.cxx7
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx25
2 files changed, 30 insertions, 2 deletions
diff --git a/vcl/source/app/customweld.cxx b/vcl/source/app/customweld.cxx
index 9a56aeb0acbd..14fbef077454 100644
--- a/vcl/source/app/customweld.cxx
+++ b/vcl/source/app/customweld.cxx
@@ -39,6 +39,8 @@ CustomWeld::CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId,
m_xDrawingArea->connect_command(LINK(this, CustomWeld, DoCommand));
m_xDrawingArea->connect_query_tooltip(LINK(this, CustomWeld, DoRequestHelp));
m_xDrawingArea->connect_im_context_get_surrounding(LINK(this, CustomWeld, DoGetSurrounding));
+ m_xDrawingArea->connect_im_context_delete_surrounding(
+ LINK(this, CustomWeld, DoDeleteSurrounding));
}
IMPL_LINK(CustomWeld, DoResize, const Size&, rSize, void)
@@ -100,6 +102,11 @@ IMPL_LINK(CustomWeld, DoGetSurrounding, OUString&, rSurrounding, int)
{
return m_rWidgetController.GetSurroundingText(rSurrounding);
}
+
+IMPL_LINK(CustomWeld, DoDeleteSurrounding, const Selection&, rSelection, bool)
+{
+ return m_rWidgetController.DeleteSurroundingText(rSelection);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 13f97ceb7df9..fd4c339f5337 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -13851,19 +13851,40 @@ public:
if (nOffset > 0)
{
- while (nCursorIndex < sSurroundingText.getLength())
+ while (nOffset && nCursorIndex < sSurroundingText.getLength())
+ {
sSurroundingText.iterateCodePoints(&nCursorIndex, 1);
+ --nOffset;
+ }
}
else if (nOffset < 0)
{
- while (nCursorIndex > 0)
+ while (nOffset && nCursorIndex > 0)
+ {
sSurroundingText.iterateCodePoints(&nCursorIndex, -1);
+ ++nOffset;
+ }
+ }
+
+ if (nOffset)
+ {
+ SAL_WARN("vcl.gtk", "IM delete-surrounding, unable to move to offset: " << nOffset);
+ return false;
}
sal_Int32 nCursorEndIndex(nCursorIndex);
sal_Int32 nCount(0);
while (nCount < nChars && nCursorEndIndex < sSurroundingText.getLength())
+ {
+ sSurroundingText.iterateCodePoints(&nCursorEndIndex, 1);
++nCount;
+ }
+
+ if (nCount != nChars)
+ {
+ SAL_WARN("vcl.gtk", "IM delete-surrounding, unable to select: " << nChars << " characters");
+ return false;
+ }
bRet = pThis->m_pArea->im_context_delete_surrounding(Selection(nCursorIndex, nCursorEndIndex));
}