basic/source/runtime/methods.cxx | 2 +- include/vcl/svapp.hxx | 11 ++++++++--- include/vcl/weld.hxx | 2 ++ sfx2/source/appl/app.cxx | 3 ++- vcl/inc/jsdialog/jsdialogbuilder.hxx | 9 ++++++++- vcl/inc/salvtables.hxx | 2 ++ vcl/jsdialog/jsdialogbuilder.cxx | 20 ++++++++++++++++++-- vcl/source/app/salvtables.cxx | 5 +++++ vcl/source/app/svapp.cxx | 1 + vcl/source/window/builder.cxx | 5 +++-- vcl/source/window/dialog.cxx | 3 ++- vcl/unx/gtk3/gtkinst.cxx | 6 ++++++ 12 files changed, 58 insertions(+), 11 deletions(-)
New commits: commit 92d80c58f1a8b1e24376ece06958f0b7f37f9513 Author: Marco Cecchetti <marco.cecche...@collabora.com> AuthorDate: Wed Feb 15 23:52:53 2023 +0100 Commit: Marco Cecchetti <marco.cecche...@collabora.com> CommitDate: Mon Feb 20 11:07:32 2023 +0000 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/+/147227 Tested-by: Marco Cecchetti <marco.cecche...@collabora.com> Reviewed-by: Marco Cecchetti <marco.cecche...@collabora.com> diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 9cc839a1e154..e5a3bf3b2e21 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4403,7 +4403,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 c51bd9356531..eacf9e779b5e 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 5192e37a1a2f..c99b3c19f4f0 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 @@ -301,7 +306,8 @@ public: static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, - const OUString& rPrimaryMessage); + const OUString& rPrimaryMessage, + const vcl::ILibreOfficeKitNotifier* pNotifier = nullptr); static void AddChildWidget(const std::string& nWindowId, const OString& id, weld::Widget* pWidget); @@ -599,6 +605,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 d6968e36d00c..36416deb5910 100644 --- a/vcl/inc/salvtables.hxx +++ b/vcl/inc/salvtables.hxx @@ -491,6 +491,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 f9fd939b38a8..abb53f8c6a05 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1156,14 +1156,18 @@ std::unique_ptr<weld::Image> JSInstanceBuilder::weld_image(const OString& id) weld::MessageDialog* JSInstanceBuilder::CreateMessageDialog(weld::Widget* pParent, VclMessageType eMessageType, VclButtonsType eButtonType, - const OUString& rPrimaryMessage) + 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; @@ -1447,6 +1451,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 259192c854cb..482b5a59e145 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 43e97b2a1d6d..f503310949f2 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 55c5fca696ad..9c6e8d97881a 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -212,10 +212,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 75b3f418c72e..7efbfc45b432 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -6590,6 +6590,12 @@ public: return aRet; } + virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() override + { + // dummy implementation + return nullptr; + } + virtual ~GtkInstanceWindow() override { if (m_nToplevelFocusChangedSignalId)