From 4a68361d578fe3bf313f80d8e186079bd34b2300 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Mon, 25 Mar 2019 18:23:36 +0900 Subject: tdf#124146 support posting of gesture event for LOKit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I51845f2e41dbcbe1ae6cb0a18cf9f42d5549968b Reviewed-on: https://gerrit.libreoffice.org/69657 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 +- desktop/source/lib/init.cxx | 45 +++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) (limited to 'desktop') diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 445901108ed4..413b697be70a 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2696,9 +2696,10 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct _LibreOfficeKitDocumentClass, addCertificate)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct _LibreOfficeKitDocumentClass, getSignatureState)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct _LibreOfficeKitDocumentClass, renderShapeSelection)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), offsetof(struct _LibreOfficeKitDocumentClass, postWindowGestureEvent)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(48), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a83af85d4441..dfbbdd8386dc 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -107,6 +107,7 @@ #include #include #include +#include #include #include #include @@ -744,6 +745,12 @@ static void doc_postWindowMouseEvent (LibreOfficeKitDocument* pThis, int nCount, int nButtons, int nModifier); +static void doc_postWindowGestureEvent(LibreOfficeKitDocument* pThis, + unsigned nLOKWindowId, + const char* pType, + int nX, + int nY, + int nOffset); static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, @@ -879,6 +886,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference getSignatureState = doc_getSignatureState; m_pDocumentClass->renderShapeSelection = doc_renderShapeSelection; + m_pDocumentClass->postWindowGestureEvent = doc_postWindowGestureEvent; gDocumentClass = m_pDocumentClass; } @@ -3020,6 +3028,43 @@ static void doc_postWindowMouseEvent(LibreOfficeKitDocument* /*pThis*/, unsigned } } +static void doc_postWindowGestureEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nLOKWindowId, const char* pType, int nX, int nY, int nOffset) +{ + SolarMutexGuard aGuard; + if (gImpl) + gImpl->maLastExceptionMsg.clear(); + + VclPtr pWindow = vcl::Window::FindLOKWindow(nLOKWindowId); + if (!pWindow) + { + gImpl->maLastExceptionMsg = "Document doesn't support dialog rendering, or window not found."; + return; + } + + OString aType(pType); + GestureEventType eEventType = GestureEventType::PanningUpdate; + + if (aType == "panBegin") + eEventType = GestureEventType::PanningBegin; + else if (aType == "panEnd") + eEventType = GestureEventType::PanningEnd; + + GestureEvent aEvent { + sal_Int32(nX), + sal_Int32(nY), + eEventType, + sal_Int32(nOffset), + PanningOrientation::Vertical, + }; + + if (Dialog* pDialog = dynamic_cast(pWindow.get())) + { + pDialog->EnableInput(); + } + + Application::PostGestureEvent(VclEventId::WindowGestureEvent, pWindow, &aEvent); +} + static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int nX, int nY) { SolarMutexGuard aGuard; -- cgit