diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-05-13 08:26:32 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-13 09:10:25 +0200 |
commit | c7d80d229a5660a0ee702477bfbd2ca137992a7d (patch) | |
tree | 841439801c80dab822561b224b162f86c748f4e5 /desktop | |
parent | 09e0cfd9b3e391435c39d3bc933d26a87e2b082e (diff) |
sw content controls, dropdown: add LOK API
- expose the available list items in a new "items" key of the
LOK_CALLBACK_CONTENT_CONTROL callback
- add a new lok::Document::sendContentControlEvent() function to be able
to select a list item from the current drop-down
- add a new listbox to the gtktiledviewer toolbar to select a content
control list item when the cursor is inside a dropdown
- add tests for the array API of tools::JsonWriter
Change-Id: I47f1333a7815d67952f7c20a9cba1b248886f6dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134256
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 4 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 32 |
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 038ea2db6aca..f2fd0ab16173 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3631,10 +3631,12 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), offsetof(struct _LibreOfficeKitDocumentClass, sendFormFieldEvent)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), offsetof(struct _LibreOfficeKitDocumentClass, setBlockedCommandList)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), offsetof(struct _LibreOfficeKitDocumentClass, renderSearchResult)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(64), + offsetof(struct _LibreOfficeKitDocumentClass, sendContentControlEvent)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(64), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 50ae3a5da400..45f059a73d7d 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1143,6 +1143,8 @@ static bool doc_renderSearchResult(LibreOfficeKitDocument* pThis, const char* pSearchResult, unsigned char** pBitmapBuffer, int* pWidth, int* pHeight, size_t* pByteSize); +static void doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const char* pArguments); + } // extern "C" namespace { @@ -1286,6 +1288,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->setBlockedCommandList = doc_setBlockedCommandList; + m_pDocumentClass->sendContentControlEvent = doc_sendContentControlEvent; + gDocumentClass = m_pDocumentClass; } pClass = m_pDocumentClass.get(); @@ -6070,6 +6074,34 @@ static bool doc_renderSearchResult(LibreOfficeKitDocument* pThis, return true; } +static void doc_sendContentControlEvent(LibreOfficeKitDocument* pThis, const char* pArguments) +{ + SolarMutexGuard aGuard; + + // Supported in Writer only + if (doc_getDocumentType(pThis) != LOK_DOCTYPE_TEXT) + { + return; + } + + StringMap aMap(jsdialog::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("selected") == aMap.end()) + { + SetLastExceptionMsg("Wrong arguments for sendContentControlEvent"); + return; + } + + pDoc->executeContentControlEvent(aMap); +} + static char* lo_getError (LibreOfficeKit *pThis) { comphelper::ProfileZone aZone("lo_getError"); |