[Libreoffice-commits] core.git: include/vcl vcl/source vcl/unx

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 22 16:06:27 UTC 2020


 include/vcl/customweld.hxx    |    1 +
 vcl/source/app/customweld.cxx |    7 +++++++
 vcl/unx/gtk3/gtk3gtkinst.cxx  |   25 +++++++++++++++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

New commits:
commit 2d1a8f83ce4c74b2ede1e93e8e1d309a61b8af23
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Oct 22 14:20:17 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Oct 22 18:05:46 2020 +0200

    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 at redhat.com>

diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx
index b8c5490d0a15..64f980732dfb 100644
--- a/include/vcl/customweld.hxx
+++ b/include/vcl/customweld.hxx
@@ -152,6 +152,7 @@ private:
     DECL_LINK(DoStyleUpdated, weld::Widget&, void);
     DECL_LINK(DoRequestHelp, tools::Rectangle&, OUString);
     DECL_LINK(DoGetSurrounding, OUString&, int);
+    DECL_LINK(DoDeleteSurrounding, const Selection&, bool);
 
 public:
     CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId,
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));
         }


More information about the Libreoffice-commits mailing list