diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-05-06 14:33:10 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2020-05-08 22:42:35 +0200 |
commit | 36508d0110248f6683757602cd1668547dbfb253 (patch) | |
tree | 778f624fa5dbab2da79d9762b3f6895024a76a1a /desktop | |
parent | 4259509aa4f11cbcd63299bd17a4503ebdc22fc0 (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.cxx | 3 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 33 |
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 3344279f1a78..30dd2c60dc3c 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2923,10 +2923,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 ccd32a035ff5..c7763b608a28 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1137,6 +1137,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 { @@ -1252,6 +1256,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(); @@ -5412,6 +5418,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"); |