[Libreoffice-commits] core.git: desktop/qa desktop/source include/LibreOfficeKit include/sfx2 sfx2/source

Marco Cecchetti (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 1 08:02:35 UTC 2019


 desktop/qa/desktop_lib/test_desktop_lib.cxx |    3 +
 desktop/source/lib/init.cxx                 |   44 ++++++++++++++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h     |    6 +++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   13 ++++++++
 include/sfx2/lokhelper.hxx                  |    2 -
 sfx2/source/view/lokhelper.cxx              |    4 +-
 6 files changed, 68 insertions(+), 4 deletions(-)

New commits:
commit 9590e8d0a2194b36d5a025a21dc2e71f37f4f54b
Author:     Marco Cecchetti <mrcekets at gmail.com>
AuthorDate: Wed Jul 10 10:32:07 2019 +0200
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Oct 1 10:01:57 2019 +0200

    lok: handling a single msg for deleting multiple characters
    
    also includes:
    
            lok: fixing testABI failure
            Change-Id: I4df662a0df49a864c4b307efdd963b857bb77792
    
            lok: missing removeTextContext implementation for Document class
            Change-Id: I884ad07f330afc19dfe759c08c8a17bdb4f9dcf3
    
    Change-Id: I045d89f9fa478f37fc2917e159e044eee7e1ab31
    Reviewed-on: https://gerrit.libreoffice.org/79879
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 93e81b595f65..eb3c713560ee 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2782,10 +2782,11 @@ void DesktopLOKTest::testABI()
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(52), offsetof(struct _LibreOfficeKitDocumentClass, getClipboard));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(53), offsetof(struct _LibreOfficeKitDocumentClass, setClipboard));
     CPPUNIT_ASSERT_EQUAL(documentClassOffset(54), offsetof(struct _LibreOfficeKitDocumentClass, getSelectionType));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), offsetof(struct _LibreOfficeKitDocumentClass, removeTextContext));
 
     // Extending is fine, update this, and add new assert for the offsetof the
     // new method
-    CPPUNIT_ASSERT_EQUAL(documentClassOffset(55), sizeof(struct _LibreOfficeKitDocumentClass));
+    CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), sizeof(struct _LibreOfficeKitDocumentClass));
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2af356e0bb7b..3b8e7eb128c7 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -764,6 +764,11 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis,
                                             unsigned nWindowId,
                                             int nType,
                                             const char* pText);
+static void doc_removeTextContext(LibreOfficeKitDocument* pThis,
+                                  unsigned nLOKWindowId,
+                                  int nCharBefore,
+                                  int nCharAfter);
+
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
                                    unsigned nLOKWindowId,
                                    int nType,
@@ -933,6 +938,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->registerCallback = doc_registerCallback;
         m_pDocumentClass->postKeyEvent = doc_postKeyEvent;
         m_pDocumentClass->postWindowExtTextInputEvent = doc_postWindowExtTextInputEvent;
+        m_pDocumentClass->removeTextContext = doc_removeTextContext;
         m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
         m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
         m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
@@ -3053,6 +3059,44 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig
     }
 }
 
+static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nCharBefore, int nCharAfter)
+{
+    SolarMutexGuard aGuard;
+    VclPtr<vcl::Window> pWindow;
+    if (nLOKWindowId == 0)
+    {
+        ITiledRenderable* pDoc = getTiledRenderable(pThis);
+        if (!pDoc)
+        {
+            gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+            return;
+        }
+        pWindow = pDoc->getDocWindow();
+    }
+    else
+    {
+        pWindow = vcl::Window::FindLOKWindow(nLOKWindowId);
+    }
+
+    if (!pWindow)
+    {
+        gImpl->maLastExceptionMsg = "No window found for window id: " + OUString::number(nLOKWindowId);
+        return;
+    }
+
+    if (nCharBefore > 0)
+    {
+        // backspace
+        SfxLokHelper::postKeyEventAsync(pWindow, LOK_EXT_TEXTINPUT, 8, 1283, nCharBefore - 1);
+    }
+
+    if (nCharAfter > 0)
+    {
+        // delete (forward)
+        SfxLokHelper::postKeyEventAsync(pWindow, LOK_EXT_TEXTINPUT, 46, 1286, nCharAfter - 1);
+    }
+}
+
 static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, int nType, int nCharCode, int nKeyCode)
 {
     comphelper::ProfileZone aZone("doc_postWindowKeyEvent");
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 93b430f5da0b..6060b015be01 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -408,6 +408,12 @@ struct _LibreOfficeKitDocumentClass
     /// @see lok::Document::getSelectionType
     int (*getSelectionType) (LibreOfficeKitDocument* pThis);
 
+    /// @see lok::Document::removeTextContext
+    void (*removeTextContext) (LibreOfficeKitDocument* pThis,
+                               unsigned nWindowId,
+                               int nBefore,
+                               int nAfter);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 3c81e4a03ae2..f92ea7d8d9f0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -728,6 +728,19 @@ public:
         return mpDoc->pClass->resizeWindow(mpDoc, nWindowId, width, height);
     }
 
+    /**
+     * For deleting many characters all at once
+     *
+     * @param nWindowId Specify the window id to post the input event to. If
+     * nWindow is 0, the event is posted into the document
+     * @param nBefore The characters to be deleted before the cursor position
+     * @param nAfter The characters to be deleted after the cursor position
+     */
+    void removeTextContext(unsigned nWindowId, int nBefore, int nAfter)
+    {
+        mpDoc->pClass->removeTextContext(mpDoc, nWindowId, nBefore, nAfter);
+    }
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 4973fba83e19..1e6a0caad205 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -63,7 +63,7 @@ public:
 
     /// Helper for posting async key event
     static void postKeyEventAsync(const VclPtr<vcl::Window> &xWindow,
-                                  int nType, int nCharCode, int nKeyCode);
+                                  int nType, int nCharCode, int nKeyCode, int nRepeat = 0);
 
     /// Helper for posting async mouse event
     static void postMouseEventAsync(const VclPtr<vcl::Window> &xWindow,
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 39e0bc1f9899..f5d182ffcfbe 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -375,7 +375,7 @@ namespace
 }
 
 void SfxLokHelper::postKeyEventAsync(const VclPtr<vcl::Window> &xWindow,
-                                     int nType, int nCharCode, int nKeyCode)
+                                     int nType, int nCharCode, int nKeyCode, int nRepeat)
 {
     LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
     switch (nType)
@@ -389,7 +389,7 @@ void SfxLokHelper::postKeyEventAsync(const VclPtr<vcl::Window> &xWindow,
     default:
         assert(false);
     }
-    pLOKEv->maKeyEvent = KeyEvent(nCharCode, nKeyCode, 0);
+    pLOKEv->maKeyEvent = KeyEvent(nCharCode, nKeyCode, nRepeat);
     pLOKEv->mpWindow = xWindow;
     postEventAsync(pLOKEv);
 }


More information about the Libreoffice-commits mailing list