summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-08-11 09:21:30 +0200
committerMichael Meeks <michael.meeks@collabora.com>2022-08-11 20:56:23 +0200
commit53a9745c2a1dc4444c659b954d7d6f0588ffb5d7 (patch)
treeaed33b4e27297ef73265d9bfffe782b8323c9e36
parent09ac0b5b1b88c3e438ce98f175aef8e46f14f3b2 (diff)
jsdialog: send MessageDialog on run not when built cp-22.05.5-3
- some message boxes doesn't have correct notifier set initially - then when runAsync is called it is ok so we can remember widget Signed-off-by: Szymon Kłos <szymon.klos@collabora.com> Change-Id: I8ecf2d20ef4c2ebda3acf3b80bb390717b6caf6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138107 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--vcl/inc/jsdialog/jsdialogbuilder.hxx14
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx45
2 files changed, 49 insertions, 10 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 304b9c330795..e5f3e6916d76 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -219,6 +219,8 @@ class JSInstanceBuilder final : public SalInstanceBuilder, public JSDialogSender
/// When LOKNotifier is set by jsdialogs code we need to release it
VclPtr<vcl::Window> m_aWindowToRelease;
+ friend class JSMessageDialog; // static message boxes have to be registered outside
+
friend VCL_DLLPUBLIC bool jsdialog::ExecuteAction(const std::string& nWindowId,
const OString& rWidget, StringMap& rData);
friend VCL_DLLPUBLIC void jsdialog::SendFullUpdate(const std::string& nWindowId,
@@ -421,8 +423,7 @@ public:
virtual void grab_focus() override
{
BaseInstanceClass::grab_focus();
- std::unique_ptr<jsdialog::ActionDataMap> pMap
- = std::make_unique<jsdialog::ActionDataMap>();
+ std::unique_ptr<jsdialog::ActionDataMap> pMap = std::make_unique<jsdialog::ActionDataMap>();
(*pMap)[ACTION_TYPE] = "grab_focus";
sendAction(std::move(pMap));
}
@@ -567,6 +568,8 @@ class JSMessageDialog final : public JSWidget<SalInstanceMessageDialog, ::Messag
DECL_LINK(OKHdl, weld::Button&, void);
DECL_LINK(CancelHdl, weld::Button&, void);
+ void RememberMessageDialog();
+
public:
JSMessageDialog(JSDialogSender* pSender, ::MessageDialog* pDialog, SalInstanceBuilder* pBuilder,
bool bTakeOwnership);
@@ -578,6 +581,13 @@ public:
virtual void set_secondary_text(const OUString& rText) override;
virtual void response(int response) override;
+
+ // TODO: move to dialog class so we will not send json when built but on run
+ bool runAsync(std::shared_ptr<weld::DialogController> aOwner,
+ const std::function<void(sal_Int32)>& rEndDialogFn) override;
+
+ bool runAsync(std::shared_ptr<Dialog> const& rxSelf,
+ const std::function<void(sal_Int32)>& rEndDialogFn) override;
};
class JSCheckButton final : public JSWidget<SalInstanceCheckButton, ::CheckBox>
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 11edcb26d94d..5c62face9769 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1174,18 +1174,14 @@ weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParen
aJsonWriter.put("jsontype", "dialog");
std::unique_ptr<char[], o3tl::free_delete> message(aJsonWriter.extractData());
pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.get());
+
+ std::string sWindowId = std::to_string(xMessageDialog->GetLOKWindowId());
+ InsertWindowToMap(sWindowId);
}
xMessageDialog->SetLOKTunnelingState(false);
- std::string sWindowId = std::to_string(xMessageDialog->GetLOKWindowId());
- InsertWindowToMap(sWindowId);
-
- weld::MessageDialog* pRet = new JSMessageDialog(xMessageDialog, nullptr, true);
-
- if (pRet)
- RememberWidget(sWindowId, "__DIALOG__", pRet);
- return pRet;
+ return new JSMessageDialog(xMessageDialog, nullptr, true);
}
JSDialog::JSDialog(JSDialogSender* pSender, ::Dialog* pDialog, SalInstanceBuilder* pBuilder,
@@ -1421,6 +1417,39 @@ JSMessageDialog::~JSMessageDialog()
JSInstanceBuilder::RemoveWindowWidget(m_sWindowId);
}
+void JSMessageDialog::RememberMessageDialog()
+{
+ static OStringLiteral sWidgetName = "__DIALOG__";
+ std::string sWindowId = std::to_string(m_xMessageDialog->GetLOKWindowId());
+ if (JSInstanceBuilder::FindWeldWidgetsMap(sWindowId, sWidgetName) != nullptr)
+ return;
+
+ JSInstanceBuilder::InsertWindowToMap(sWindowId);
+ JSInstanceBuilder::RememberWidget(sWindowId, sWidgetName, this);
+}
+
+bool JSMessageDialog::runAsync(std::shared_ptr<weld::DialogController> aOwner,
+ const std::function<void(sal_Int32)>& rEndDialogFn)
+{
+ bool bRet = SalInstanceMessageDialog::runAsync(aOwner, rEndDialogFn);
+
+ RememberMessageDialog();
+ sendFullUpdate();
+
+ return bRet;
+}
+
+bool JSMessageDialog::runAsync(std::shared_ptr<Dialog> const& rxSelf,
+ const std::function<void(sal_Int32)>& rEndDialogFn)
+{
+ bool bRet = SalInstanceMessageDialog::runAsync(rxSelf, rEndDialogFn);
+
+ RememberMessageDialog();
+ sendFullUpdate();
+
+ return bRet;
+}
+
IMPL_LINK_NOARG(JSMessageDialog, OKHdl, weld::Button&, void) { response(RET_OK); }
IMPL_LINK_NOARG(JSMessageDialog, CancelHdl, weld::Button&, void) { response(RET_CANCEL); }