diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2020-03-05 12:24:27 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2020-06-20 20:36:11 +0200 |
commit | 5c44f1ef779bf196f874f47c14d2d0c7f58fbb2e (patch) | |
tree | a6d62349dd6d594eb72f2d88bd983dca87d462d4 /desktop | |
parent | 159ce7f29b0129e411276591e11eea6a30a981ab (diff) |
jsdialog: execute actions using weld wrapper
Change-Id: Ib9e1b52742b489e812e0756b364a7f7ac62f84ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94300
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94617
Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 128 |
1 files changed, 92 insertions, 36 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 2843c0f5c250..8bbec959b44f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -148,6 +148,7 @@ #include <vcl/abstdlg.hxx> #include <tools/diagnose_ex.h> #include <vcl/uitest/uiobject.hxx> +#include <vcl/jsdialog/jsdialogbuilder.hxx> // Needed for getUndoManager() #include <com/sun/star/document/XUndoManager.hpp> @@ -3587,6 +3588,7 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin StringMap aMap(jsonToStringMap(pArguments)); VclPtr<Window> pWindow = vcl::Window::FindLOKWindow(nWindowId); + JSInstanceBuilder* pBuilder = JSInstanceBuilder::FindLOKWeldBuilder(nWindowId); if (!pWindow && nWindowId >= 1000000000 /* why unsigned? */) pWindow = getSidebarWindow(); @@ -3598,57 +3600,111 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin } else if (aMap.find("id") != aMap.end()) { - const OUString sSelectAction("SELECT"); + static const OUString sClickAction("CLICK"); + static const OUString sSelectAction("SELECT"); + static const OUString sClearAction("CLEAR"); + static const OUString sTypeAction("TYPE"); + static const OUString sUpAction("UP"); + static const OUString sDownAction("DOWN"); + static const OUString sValue("VALUE"); try { - WindowUIObject aUIObject(pWindow); - std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"])); - if (pUIWindow) { - bool bIsClickAction = false; + bool bIsWeldedDialog = pBuilder != nullptr; + bool bContinueWithLOKWindow = false; - if (aMap.find("cmd") != aMap.end()) { - if (aMap["cmd"] == "selected") - { - aMap["POS"] = aMap["data"]; - aMap["TEXT"] = aMap["data"]; + if (bIsWeldedDialog) + { + OString sControlId = OUStringToOString(aMap["id"], RTL_TEXTENCODING_ASCII_US); + OUString sControlType = aMap["type"]; + OUString sAction = aMap["cmd"]; - pUIWindow->execute(sSelectAction, aMap); - } - else if (aMap["cmd"] == "plus") - { - pUIWindow->execute("UP", aMap); - } - else if (aMap["cmd"] == "minus") - { - pUIWindow->execute("DOWN", aMap); - } - else if (aMap["cmd"] == "set") + if (sControlType == "tabcontrol") + { + auto pNotebook = pBuilder->weld_notebook(sControlId, false); + if (pNotebook) { - aMap["TEXT"] = aMap["data"]; + if (sAction == "selecttab") + { + OString pageId = OUStringToOString(aMap["data"], RTL_TEXTENCODING_ASCII_US); + int page = std::atoi(pageId.getStr()); - pUIWindow->execute("CLEAR", aMap); - pUIWindow->execute("TYPE", aMap); + pNotebook->set_current_page(page); + } + else + bContinueWithLOKWindow = true; } - else if (aMap["cmd"] == "value") + } + else if (sControlType == "combobox") + { + auto pCombobox = pBuilder->weld_combo_box(sControlId, false); + if (pCombobox) { - aMap["VALUE"] = aMap["data"]; - pUIWindow->execute("VALUE", aMap); + if (sAction == "selected") + { + int separatorPos = aMap["data"].indexOf(';'); + if (separatorPos) + { + OUString entryPos = aMap["data"].copy(0, separatorPos); + OString posString = OUStringToOString(entryPos, RTL_TEXTENCODING_ASCII_US); + int pos = std::atoi(posString.getStr()); + pCombobox->set_active(pos); + } + } + else + bContinueWithLOKWindow = true; } - else if (aMap["cmd"] == "selecttab") - { - aMap["POS"] = aMap["data"]; + } + else + { + bContinueWithLOKWindow = true; + } + } + + if (!bIsWeldedDialog || bContinueWithLOKWindow) + { + WindowUIObject aUIObject(pWindow); + std::unique_ptr<UIObject> pUIWindow(aUIObject.get_child(aMap["id"])); + if (pUIWindow) { + bool bIsClickAction = false; + + if (aMap.find("cmd") != aMap.end()) { + if (aMap["cmd"] == "selected") + { + aMap["POS"] = aMap["data"]; + aMap["TEXT"] = aMap["data"]; + + pUIWindow->execute(sSelectAction, aMap); + } + else if (aMap["cmd"] == "plus") + { + pUIWindow->execute(sUpAction, aMap); + } + else if (aMap["cmd"] == "minus") + { + pUIWindow->execute(sDownAction, aMap); + } + else if (aMap["cmd"] == "set") + { + aMap["TEXT"] = aMap["data"]; - pUIWindow->execute(sSelectAction, aMap); + pUIWindow->execute(sClearAction, aMap); + pUIWindow->execute(sTypeAction, aMap); + } + else if (aMap["cmd"] == "value") + { + aMap["VALUE"] = aMap["data"]; + pUIWindow->execute(sValue, aMap); + } + else + bIsClickAction = true; } else bIsClickAction = true; - } - else - bIsClickAction = true; - if (bIsClickAction) - pUIWindow->execute("CLICK", aMap); + if (bIsClickAction) + pUIWindow->execute(sClickAction, aMap); + } } } catch(...) {} |