desktop/qa/desktop_lib/test_desktop_lib.cxx |    3 +
 desktop/source/lib/init.cxx                 |   45 ++++++++++++++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h     |    9 +++++
 include/LibreOfficeKit/LibreOfficeKit.hxx   |   16 +++++++++
 4 files changed, 72 insertions(+), 1 deletion(-)

New commits:
commit 4a68361d578fe3bf313f80d8e186079bd34b2300
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Mar 25 18:23:36 2019 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Tue Mar 26 01:31:46 2019 +0100

    tdf#124146 support posting of gesture event for LOKit
    
    Change-Id: I51845f2e41dbcbe1ae6cb0a18cf9f42d5549968b
    Reviewed-on: https://gerrit.libreoffice.org/69657
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>

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 <svx/svxids.hrc>
 #include <svx/ucsubset.hxx>
 #include <vcl/vclevent.hxx>
+#include <vcl/GestureEvent.hxx>
 #include <vcl/svapp.hxx>
 #include <unotools/resmgr.hxx>
 #include <tools/fract.hxx>
@@ -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 
<css::lang::XCompone
         m_pDocumentClass->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<Window> 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<Dialog*>(pWindow.get()))
+    {
+        pDialog->EnableInput();
+    }
+
+    Application::PostGestureEvent(VclEventId::WindowGestureEvent, pWindow, 
&aEvent);
+}
+
 static void doc_setTextSelection(LibreOfficeKitDocument* pThis, int nType, int 
nX, int nY)
 {
     SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h 
b/include/LibreOfficeKit/LibreOfficeKit.h
index 2df1cea6dd31..0e596f5067ba 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -356,10 +356,19 @@ struct _LibreOfficeKitDocumentClass
 
     /// @see lok::Document::getSignatureState().
     int (*getSignatureState) (LibreOfficeKitDocument* pThis);
+// END CERTIFICATE AND SIGNING
 
     /// @see lok::Document::renderShapeSelection
     size_t (*renderShapeSelection)(LibreOfficeKitDocument* pThis, char** 
pOutput);
 
+    /// @see lok::Document::postWindowGestureEvent().
+    void (*postWindowGestureEvent) (LibreOfficeKitDocument* pThis,
+                                  unsigned nWindowId,
+                                  const char* pType,
+                                  int nX,
+                                  int nY,
+                                  int nOffset);
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx 
b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 31e95a09c0ec..bd678b0b81d0 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -629,6 +629,22 @@ public:
         return mpDoc->pClass->renderShapeSelection(mpDoc, pOutput);
     }
 
+    /**
+     * Posts a gesture event to the window with given id.
+     *
+     * @param nWindowId
+     * @param pType Event type, like panStart, panEnd, panUpdate.
+     * @param nX horizontal position in document coordinates
+     * @param nY vertical position in document coordinates
+     * @param nOffset difference value from when the gesture started to 
current value
+     */
+    void postWindowGestureEvent(unsigned nWindowId,
+                              const char* pType,
+                              int nX, int nY, int nOffset)
+    {
+        return mpDoc->pClass->postWindowGestureEvent(mpDoc, nWindowId, pType, 
nX, nY, nOffset);
+    }
+
 #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY
 };
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to