desktop/source/lib/init.cxx | 120 +++++++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 35 deletions(-)
New commits: commit 420ccf4bdd398558bc080e969e600204a286c82a Author: Szymon Kłos <[email protected]> AuthorDate: Thu Mar 5 12:24:27 2020 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Fri May 15 16:02:31 2020 +0200 jsdialog: execute actions using weld wrapper Change-Id: Ib9e1b52742b489e812e0756b364a7f7ac62f84ad Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94300 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9b02d51a65f2..52b75514870f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -156,6 +156,7 @@ #include <vcl/builder.hxx> #include <vcl/abstdlg.hxx> #include <vcl/uitest/uiobject.hxx> +#include <vcl/jsdialog/jsdialogbuilder.hxx> // Needef for getUndoManager() #include <com/sun/star/document/XUndoManager.hpp> @@ -3595,6 +3596,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(); @@ -3616,53 +3618,101 @@ static void doc_sendDialogEvent(LibreOfficeKitDocument* /*pThis*/, unsigned nWin 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(sUpAction, aMap); - } - else if (aMap["cmd"] == "minus") - { - pUIWindow->execute(sDownAction, 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(sClearAction, aMap); - pUIWindow->execute(sTypeAction, 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(sValue, 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(sClickAction, aMap); + if (bIsClickAction) + pUIWindow->execute(sClickAction, aMap); + } } } catch(...) {} _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
