summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2019-10-11 08:53:14 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2019-10-15 15:59:07 +0200
commitef433656498ce52b69849915671d4aa34ec59136 (patch)
tree7cf4fd40d96bf23fac9f6a34d69ad151d1f20f08 /desktop
parentad070ddeea5079300c0ed955cf5688548400221b (diff)
jsdialogs: handle dialog events
Change-Id: Icc092cd5b06168d9de8ebed891fc03491865dbad Reviewed-on: https://gerrit.libreoffice.org/80788 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx4
-rw-r--r--desktop/source/lib/init.cxx45
2 files changed, 47 insertions, 2 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 5945a3bd378a..49a26253b388 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2742,10 +2742,12 @@ void DesktopLOKTest::testABI()
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));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), offsetof(struct _LibreOfficeKitDocumentClass, sendDialogEvent));
+
// Extending is fine, update this, and add new assert for the offsetof the
// new method
- CPPUNIT_ASSERT_EQUAL(documentClassOffset(56), sizeof(struct _LibreOfficeKitDocumentClass));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(57), sizeof(struct _LibreOfficeKitDocumentClass));
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cd604f939d8b..1790bdbfa478 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -147,6 +147,7 @@
#include <vcl/builder.hxx>
#include <vcl/abstdlg.hxx>
#include <tools/diagnose_ex.h>
+#include <vcl/uitest/uiobject.hxx>
#include <app.hxx>
@@ -768,7 +769,9 @@ static void doc_removeTextContext(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
int nCharBefore,
int nCharAfter);
-
+static void doc_sendDialogEvent(LibreOfficeKitDocument* pThis,
+ unsigned nLOKWindowId,
+ const char* pArguments);
static void doc_postWindowKeyEvent(LibreOfficeKitDocument* pThis,
unsigned nLOKWindowId,
int nType,
@@ -942,6 +945,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent;
m_pDocumentClass->postMouseEvent = doc_postMouseEvent;
m_pDocumentClass->postWindowMouseEvent = doc_postWindowMouseEvent;
+ m_pDocumentClass->sendDialogEvent = doc_sendDialogEvent;
m_pDocumentClass->postUnoCommand = doc_postUnoCommand;
m_pDocumentClass->setTextSelection = doc_setTextSelection;
m_pDocumentClass->getTextSelection = doc_getTextSelection;
@@ -3256,6 +3260,45 @@ public:
virtual void SAL_CALL disposing(const css::lang::EventObject&) override {}
};
+static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWindowId, const char* pArguments)
+{
+ SolarMutexGuard aGuard;
+
+ char* pCopy = strdup(pArguments);
+ if (!pCopy) {
+ SetLastExceptionMsg("String copying error.");
+ return;
+ }
+
+ char* pIdChar = strtok(pCopy, " ");
+
+ if (!pIdChar) {
+ SetLastExceptionMsg("Error parsing the command.");
+ return;
+ }
+
+ OUString sId = OUString::createFromAscii(pIdChar);
+ free(pCopy);
+
+ VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nWindowId);
+ if (!pWindow)
+ {
+ SetLastExceptionMsg("Document doesn't support dialog rendering, or window not found.");
+ return;
+ }
+ else
+ {
+ OUString sAction("CLICK");
+ WindowUIObject aUIObject(pWindow);
+ std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(sId));
+ if (pUIWindow)
+ pUIWindow->execute(sAction, StringMap());
+
+ // force resend
+ pWindow->Resize();
+ }
+}
+
static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished)
{
comphelper::ProfileZone aZone("doc_postUnoCommand");