diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2019-10-17 19:23:22 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2019-10-18 08:41:15 +0200 |
commit | cdeff4f1b4021c5fca55743e119a70fa2bd52b91 (patch) | |
tree | 9f8b92c4f99932bf35da732a9299fe5358c048e2 /desktop | |
parent | 0b24dcca00333405203c5cb3d1a92a81b346930d (diff) |
jsdialogs: handle combobox selections
Change-Id: Ib968bfaf7ad9e7becd16355259142d583bf7b5e3
Reviewed-on: https://gerrit.libreoffice.org/80991
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index ee0161d4eaf8..b3cd142d9790 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -3279,35 +3279,63 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin } char* pIdChar = strtok(pCopy, " "); + char* pOptionalEventType = strtok(nullptr, " "); + char* pOptionalData = strtok(nullptr, " "); if (!pIdChar) { SetLastExceptionMsg("Error parsing the command."); + free(pCopy); 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."); + free(pCopy); return; } else { - OUString sAction("CLICK"); + const OUString sClickAction("CLICK"); + const OUString sSelectAction("SELECT"); + try { WindowUIObject aUIObject(pWindow); std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(sId)); - if (pUIWindow) - pUIWindow->execute(sAction, StringMap()); + if (pUIWindow) { + if (pOptionalEventType) { + if (strcmp(pOptionalEventType, "selected") == 0 && pOptionalData) { + char* pPos = strtok(pOptionalData, ";"); + char* pText = strtok(nullptr, ";"); + + if (!pPos || !pText) + { + SetLastExceptionMsg("Error parsing the command."); + free(pCopy); + return; + } + + StringMap aMap; + aMap["POS"] = OUString::createFromAscii(pPos); + aMap["TEXT"] = OUString::createFromAscii(pText); + + pUIWindow->execute(sSelectAction, aMap); + } + } else { + pUIWindow->execute(sClickAction, StringMap()); + } + } } catch(...) {} // force resend pWindow->Resize(); } + + free(pCopy); } static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pCommand, const char* pArguments, bool bNotifyWhenFinished) |