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 | 17 ++++++++-- 6 files changed, 80 insertions(+), 5 deletions(-)
New commits: commit c475e087c6446c5fe937653310d69cef60fc3f06 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Tue Jul 16 15:38:23 2019 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Wed Oct 2 19:47:15 2019 +0200 Adopt a more brute-force approach for deleting text for now. Change-Id: Ib5e75703a50ec89716542c45bc9dd58f0e631509 Reviewed-on: https://gerrit.libreoffice.org/79881 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/80058 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 35e2635fd6e1..529faf90f17a 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -316,8 +316,19 @@ namespace switch (pLOKEv->mnEvent) { case VclEventId::WindowKeyInput: - pLOKEv->mpWindow->KeyInput(pLOKEv->maKeyEvent); + { + sal_uInt16 nRepeat = pLOKEv->maKeyEvent.GetRepeat(); + if (nRepeat > 0) + { + KeyEvent singlePress(pLOKEv->maKeyEvent.GetCharCode(), + pLOKEv->maKeyEvent.GetKeyCode()); + for (sal_uInt16 i = 0; i <= nRepeat; ++i) + pLOKEv->mpWindow->KeyInput(singlePress); + } + else + pLOKEv->mpWindow->KeyInput(pLOKEv->maKeyEvent); break; + } case VclEventId::WindowKeyUp: pLOKEv->mpWindow->KeyUp(pLOKEv->maKeyEvent); break; commit c34917430a9f1ee32a52259c7b73ad49c0489c61 Author: Marco Cecchetti <mrcek...@gmail.com> AuthorDate: Wed Jul 10 10:32:07 2019 +0200 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Wed Oct 2 19:47:04 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.me...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/80057 Tested-by: Michael Meeks <michael.me...@collabora.com> diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index d2e6b1890f97..27b987b8bc51 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2713,10 +2713,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 1f4e24862d0d..9beabf8c1d1d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -760,6 +760,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, @@ -929,6 +934,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; @@ -3036,6 +3042,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 dd0ad0391643..ed64d6447fe6 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 f3fc023a290e..49311105fff2 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -64,7 +64,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 4473602e0484..35e2635fd6e1 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -372,7 +372,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) @@ -386,7 +386,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); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits