[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - desktop/source
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Fri May 15 14:03:08 UTC 2020
desktop/source/lib/init.cxx | 120 +++++++++++++++++++++++++++++++-------------
1 file changed, 85 insertions(+), 35 deletions(-)
New commits:
commit 420ccf4bdd398558bc080e969e600204a286c82a
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Thu Mar 5 12:24:27 2020 +0100
Commit: Szymon Kłos <szymon.klos at collabora.com>
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 <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
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(...) {}
More information about the Libreoffice-commits
mailing list