summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2020-05-06 14:33:10 +0200
committerAndras Timar <andras.timar@collabora.com>2020-05-24 17:35:34 +0200
commitee545aa5afb93fd227d43fcbad40fd1efcf14ff5 (patch)
tree100807712ab3718e5ee8d3d094bf66bfafbd8122 /desktop
parenta915465820067bb2fc0089fc642fdcc3161e98a0 (diff)
lok: MSForms: Handle event about item selection of a drop-down field.
Change-Id: I095013097348c98361b6614e4ddf1e9029923c7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93659 Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com> Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/qa/desktop_lib/test_desktop_lib.cxx3
-rw-r--r--desktop/source/lib/init.cxx33
2 files changed, 35 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx
index 35314f0da0f3..a8a9a9d8b7ea 100644
--- a/desktop/qa/desktop_lib/test_desktop_lib.cxx
+++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx
@@ -2879,10 +2879,11 @@ void DesktopLOKTest::testABI()
CPPUNIT_ASSERT_EQUAL(documentClassOffset(58), offsetof(struct _LibreOfficeKitDocumentClass, paintWindowForView));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct _LibreOfficeKitDocumentClass, completeFunction));
CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), offsetof(struct _LibreOfficeKitDocumentClass, setWindowTextSelection));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), offsetof(struct _LibreOfficeKitDocumentClass, sendFormFieldEvent));
// Extending is fine, update this, and add new assert for the offsetof the
// new method
- CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), sizeof(struct _LibreOfficeKitDocumentClass));
+ CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), sizeof(struct _LibreOfficeKitDocumentClass));
}
CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest);
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 6f563d1cf22c..d8f973dc3d83 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1143,6 +1143,10 @@ static void doc_resizeWindow(LibreOfficeKitDocument* pThis, unsigned nLOKWindowI
const int nWidth, const int nHeight);
static void doc_completeFunction(LibreOfficeKitDocument* pThis, int nIndex);
+
+
+static void doc_sendFormFieldEvent(LibreOfficeKitDocument* pThis,
+ const char* pArguments);
} // extern "C"
namespace {
@@ -1257,6 +1261,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->createViewWithOptions = doc_createViewWithOptions;
m_pDocumentClass->completeFunction = doc_completeFunction;
+ m_pDocumentClass->sendFormFieldEvent = doc_sendFormFieldEvent;
+
gDocumentClass = m_pDocumentClass;
}
pClass = m_pDocumentClass.get();
@@ -5540,6 +5546,33 @@ static void doc_completeFunction(LibreOfficeKitDocument* pThis, int nIndex)
pDoc->completeFunction(nIndex);
}
+
+static void doc_sendFormFieldEvent(LibreOfficeKitDocument* pThis, const char* pArguments)
+{
+ SolarMutexGuard aGuard;
+
+ // Supported in Writer only
+ if (doc_getDocumentType(pThis) != LOK_DOCTYPE_TEXT)
+ return;
+
+ StringMap aMap(jsonToStringMap(pArguments));
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ SetLastExceptionMsg("Document doesn't support tiled rendering!");
+ return;
+ }
+
+ // Sanity check
+ if (aMap.find("type") == aMap.end() || aMap.find("cmd") == aMap.end())
+ {
+ SetLastExceptionMsg("Wrong arguments for sendFormFieldEvent!");
+ return;
+ }
+
+ pDoc->executeFromFieldEvent(aMap);
+}
+
static char* lo_getError (LibreOfficeKit *pThis)
{
comphelper::ProfileZone aZone("lo_getError");