diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2023-02-15 23:52:53 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2023-03-03 17:30:52 +0000 |
commit | 00ac4d375922b96d94e42846c9555d22470fb2f6 (patch) | |
tree | 46f9690ed006dbaa382404f13710978d36c1cb8d | |
parent | 3fce5f707789fe623672e2eebd731756c826dadc (diff) |
lok: macro: VBA message dialogs was causing assertion failure
Get VBA MsgBox and VBA Runtime Script Error dialogs to be displayed
correctly without causing an assertion failure.
Provided a solution that allows VBA MsgBox to be executed in a
not-async way so that the VBA script is paused until the message box
is closed.
Change-Id: Ica7d0d343a0ea4b6a163c1c43572f18a5779a0ca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147243
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147321
Tested-by: Jenkins
-rw-r--r-- | basic/source/runtime/methods.cxx | 2 | ||||
-rw-r--r-- | include/vcl/svapp.hxx | 11 | ||||
-rw-r--r-- | include/vcl/weld.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/app.cxx | 3 | ||||
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 14 | ||||
-rw-r--r-- | vcl/inc/salvtables.hxx | 2 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 25 | ||||
-rw-r--r-- | vcl/source/app/salvtables.cxx | 5 | ||||
-rw-r--r-- | vcl/source/app/svapp.cxx | 1 | ||||
-rw-r--r-- | vcl/source/window/builder.cxx | 5 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtkinst.cxx | 6 |
12 files changed, 62 insertions, 17 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 975495fa41cf..8d50c6cc3409 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4395,7 +4395,7 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool) } std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, - eType, VclButtonsType::NONE, aMsg)); + eType, VclButtonsType::NONE, aMsg, GetpApp())); switch (nStyle) { diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index 55d7aa87adf2..326b8b3761ea 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -58,8 +58,12 @@ class DataChangedEvent; class Accelerator; class Help; class OutputDevice; -namespace vcl { class Window; } -namespace vcl { class KeyCode; } +namespace vcl { + class KeyCode; + class ILibreOfficeKitNotifier; + class Window; +} + class NotifyEvent; class KeyEvent; class MouseEvent; @@ -1348,7 +1352,8 @@ public: static std::unique_ptr<weld::Builder> CreateInterimBuilder(vcl::Window* pParent, const OUString &rUIFile, bool bAllowCycleFocusOut, sal_uInt64 nLOKWindowId = 0); static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, - VclButtonsType eButtonType, const OUString& rPrimaryMessage); + VclButtonsType eButtonType, const OUString& rPrimaryMessage, + const ILibreOfficeKitNotifier* pNotifier = nullptr); static weld::Window* GetFrameWeld(const css::uno::Reference<css::awt::XWindow>& rWindow); diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index c9273bf4743b..e352c2e357f7 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -565,6 +565,8 @@ public: // render the widget to an output device virtual VclPtr<VirtualDevice> screenshot() = 0; + + virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() = 0; }; class VCL_DLLPUBLIC WaitObject diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index f225315d6ecd..41a637a5d913 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -413,7 +413,8 @@ IMPL_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, pStarBas pViewFrame ? pViewFrame->GetFrameWeld() : nullptr, VclMessageType::Error, VclButtonsType::Ok, - aError)); + aError, + GetpApp())); xBox->runAsync(xBox, [](sal_Int32 /*nResult*/) {}); } diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index c2341c7568b2..eca79153ff3a 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -41,6 +41,11 @@ class VclMultiLineEdit; class SvTabListBox; class IconView; +namespace vcl +{ +class ILibreOfficeKitNotifier; +} + typedef std::map<OString, weld::Widget*> WidgetMap; namespace jsdialog @@ -299,10 +304,10 @@ public: virtual std::unique_ptr<weld::Widget> weld_widget(const OString& id) override; virtual std::unique_ptr<weld::Image> weld_image(const OString& id) override; - static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, - VclMessageType eMessageType, - VclButtonsType eButtonType, - const OUString& rPrimaryMessage); + static weld::MessageDialog* + CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, + VclButtonsType eButtonType, const OUString& rPrimaryMessage, + const vcl::ILibreOfficeKitNotifier* pNotifier = nullptr); static void AddChildWidget(const std::string& nWindowId, const OString& id, weld::Widget* pWidget); @@ -607,6 +612,7 @@ public: virtual void response(int response) override; + virtual int run() 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; diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx index a6d5f4319d7c..1fe2d85b29f0 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -497,6 +497,8 @@ public: virtual VclPtr<VirtualDevice> screenshot() override; + virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() override; + virtual ~SalInstanceWindow() override; }; diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index ff6466d4b565..389bd4528ccb 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1165,17 +1165,20 @@ std::unique_ptr<weld::Image> JSInstanceBuilder::weld_image(const OString& id) return pWeldWidget; } -weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, - VclMessageType eMessageType, - VclButtonsType eButtonType, - const OUString& rPrimaryMessage) +weld::MessageDialog* +JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, + VclButtonsType eButtonType, const OUString& rPrimaryMessage, + const vcl::ILibreOfficeKitNotifier* pNotifier) { SalInstanceWidget* pParentInstance = dynamic_cast<SalInstanceWidget*>(pParent); SystemWindow* pParentWidget = pParentInstance ? pParentInstance->getSystemWindow() : nullptr; VclPtrInstance<::MessageDialog> xMessageDialog(pParentWidget, rPrimaryMessage, eMessageType, eButtonType); - const vcl::ILibreOfficeKitNotifier* pNotifier = xMessageDialog->GetLOKNotifier(); + if (pNotifier) + xMessageDialog->SetLOKNotifier(pNotifier); + + pNotifier = xMessageDialog->GetLOKNotifier(); if (pNotifier) { tools::JsonWriter aJsonWriter; @@ -1465,6 +1468,18 @@ void JSMessageDialog::RememberMessageDialog() JSInstanceBuilder::RememberWidget(sWindowId, sWidgetName, this); } +int JSMessageDialog::run() +{ + if (GetLOKNotifier()) + { + RememberMessageDialog(); + sendFullUpdate(); + } + + int bRet = SalInstanceMessageDialog::run(); + return bRet; +} + bool JSMessageDialog::runAsync(std::shared_ptr<weld::DialogController> aOwner, const std::function<void(sal_Int32)>& rEndDialogFn) { diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index eb2697b61b03..f8dcfba0a16b 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -1696,6 +1696,11 @@ weld::ScreenShotCollection SalInstanceWindow::collect_screenshot_data() return aRet; } +const vcl::ILibreOfficeKitNotifier* SalInstanceWindow::GetLOKNotifier() +{ + return m_xWindow ? m_xWindow->GetLOKNotifier() : nullptr; +} + SalInstanceWindow::~SalInstanceWindow() { // tdf#129745 only undo overriding child help for the normal case, not for diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index d2c6294917f0..a580a8215cdb 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -319,6 +319,7 @@ void Application::notifyWindow(vcl::LOKWindowId /*nLOKWindowId*/, const OUString& /*rAction*/, const std::vector<vcl::LOKPayloadItem>& /*rPayload = std::vector<LOKPayloadItem>()*/) const { + SAL_WARN("vcl", "Invoked not implemented method: Application::notifyWindow"); } void Application::libreOfficeKitViewCallback(int nType, const char* pPayload) const diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 2463c68182a6..047fd6e4ae9c 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -213,10 +213,11 @@ std::unique_ptr<weld::Builder> Application::CreateInterimBuilder(vcl::Window* pP } weld::MessageDialog* Application::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, - VclButtonsType eButtonType, const OUString& rPrimaryMessage) + VclButtonsType eButtonType, const OUString& rPrimaryMessage, + const ILibreOfficeKitNotifier* pNotifier) { if (comphelper::LibreOfficeKit::isActive()) - return JSInstanceBuilder::CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); + return JSInstanceBuilder::CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage, pNotifier); else return ImplGetSVData()->mpDefInst->CreateMessageDialog(pParent, eMessageType, eButtonType, rPrimaryMessage); } diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index b8d81a4b8130..a255ed4b9a47 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1131,7 +1131,8 @@ void Dialog::EndDialog( tools::Long nResult ) { if(const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier()) { - pNotifier->notifyWindow(GetLOKWindowId(), "close"); + if (mpDialogImpl->m_bLOKTunneling) + pNotifier->notifyWindow(GetLOKWindowId(), "close"); ReleaseLOKNotifier(); } } diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index c1e38223ffa5..501521e82491 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -6591,6 +6591,12 @@ public: return aRet; } + virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() override + { + // dummy implementation + return nullptr; + } + virtual ~GtkInstanceWindow() override { if (m_nToplevelFocusChangedSignalId) |