summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx3
-rw-r--r--desktop/source/lib/init.cxx45
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h9
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx16
4 files changed, 72 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 5e71f5771835..2b1c6ae96af6 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2454,9 +2454,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 7dd7fe6644e1..afceb472a8e6 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -101,6 +101,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>
@@ -648,6 +649,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,
@@ -783,6 +790,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;
}
@@ -2777,6 +2785,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 4dd23a2cbc7a..dcaf4583b27e 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -346,10 +346,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 5d7771cf80b0..2266fc80e7c5 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
};