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 | |
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
-rw-r--r-- | desktop/source/lib/init.cxx | 128 | ||||
-rw-r--r-- | include/vcl/jsdialog/jsdialogbuilder.hxx | 3 | ||||
-rw-r--r-- | include/vcl/salvtables.hxx | 5 | ||||
-rw-r--r-- | include/vcl/toolkit/combobox.hxx | 2 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 1 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 2 |
6 files changed, 101 insertions, 40 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(...) {} diff --git a/include/vcl/jsdialog/jsdialogbuilder.hxx b/include/vcl/jsdialog/jsdialogbuilder.hxx index 0efd6c0d36ea..382623a83da6 100644 --- a/include/vcl/jsdialog/jsdialogbuilder.hxx +++ b/include/vcl/jsdialog/jsdialogbuilder.hxx @@ -7,9 +7,10 @@ #include <vcl/virdev.hxx> #include <vcl/builder.hxx> #include <vcl/salvtables.hxx> -#include <vcl/toolkit/combobox.hxx> #include <vcl/button.hxx> +class ComboBox; + class JSDialogSender { VclPtr<vcl::Window> m_aOwnedToplevel; diff --git a/include/vcl/salvtables.hxx b/include/vcl/salvtables.hxx index 87d387f43257..ad5827a82e61 100644 --- a/include/vcl/salvtables.hxx +++ b/include/vcl/salvtables.hxx @@ -22,7 +22,8 @@ #include <vcl/toolkit/combobox.hxx> #include <vcl/tabctrl.hxx> #include <vcl/layout.hxx> -#include <messagedialog.hxx> + +class MessageDialog; class SalInstanceBuilder : public weld::Builder { @@ -158,7 +159,7 @@ public: virtual ~SalInstanceBuilder() override; }; -class SalInstanceMenu : public weld::Menu +class SAL_DLLPUBLIC_RTTI SalInstanceMenu : public weld::Menu { private: VclPtr<PopupMenu> m_xMenu; diff --git a/include/vcl/toolkit/combobox.hxx b/include/vcl/toolkit/combobox.hxx index a3c4e1cee5b3..d81e70fbb610 100644 --- a/include/vcl/toolkit/combobox.hxx +++ b/include/vcl/toolkit/combobox.hxx @@ -20,7 +20,7 @@ #ifndef INCLUDED_VCL_COMBOBOX_HXX #define INCLUDED_VCL_COMBOBOX_HXX -#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) +#if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS) && !defined(DESKTOP_DLLIMPLEMENTATION) #error "don't use this in new code" #endif diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 938cf471cc76..5cb4132fc8f8 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -5,6 +5,7 @@ #include <vcl/tabpage.hxx> #include <vcl/toolkit/dialog.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <vcl/toolkit/combobox.hxx> void JSDialogSender::notifyDialogState() { diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index 1759a1e83860..08a62cd63e46 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -72,6 +72,8 @@ #include <bitmaps.hlst> #include <wizdlg.hxx> #include <vcl/salvtables.hxx> +#include <messagedialog.hxx> +#include <vcl/toolkit/combobox.hxx> #include <boost/property_tree/ptree.hpp> |