summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2023-02-15 23:52:53 +0100
committerMarco Cecchetti <marco.cecchetti@collabora.com>2023-02-20 10:24:04 +0000
commitc3c5a58606081e503e211919a7a089e26f1cd850 (patch)
treeebc4b35c5a9da3af8b24b979149e5d2d737366b1
parent99bb89a2629d3bd68c64e1ecf460ccb37741f6ae (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>
-rw-r--r--basic/source/runtime/methods.cxx2
-rw-r--r--include/vcl/svapp.hxx11
-rw-r--r--include/vcl/weld.hxx2
-rw-r--r--sfx2/source/appl/app.cxx3
-rw-r--r--vcl/inc/jsdialog/jsdialogbuilder.hxx9
-rw-r--r--vcl/inc/salvtables.hxx2
-rw-r--r--vcl/jsdialog/jsdialogbuilder.cxx20
-rw-r--r--vcl/source/app/salvtables.cxx5
-rw-r--r--vcl/source/app/svapp.cxx1
-rw-r--r--vcl/source/window/builder.cxx5
-rw-r--r--vcl/source/window/dialog.cxx3
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx6
12 files changed, 58 insertions, 11 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 851584b6db79..718385dedb6d 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -4456,7 +4456,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 2ca0b06fb50f..440a5f4849d3 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;
@@ -1329,7 +1333,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 ddcba84d8b71..5fdaa414df4b 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -557,6 +557,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 aabdd2e83cce..293deabad99d 100644
--- a/sfx2/source/appl/app.cxx
+++ b/sfx2/source/appl/app.cxx
@@ -424,7 +424,8 @@ IMPL_STATIC_LINK( SfxApplication, GlobalBasicErrorHdl_Impl, StarBASIC*, pStarBas
pViewFrame->GetFrameWeld(),
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 e57f22b8e212..ba5f91f8b889 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -40,6 +40,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 d1aa50d183e0..8722675d5df4 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -487,6 +487,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 3998ddf0e130..b261a5f0a5f5 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1158,14 +1158,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;
@@ -1449,6 +1453,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 3fe6f3a08acf..67cb0e5805ee 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1556,6 +1556,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 89cb5b61f8ef..2846badba117 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 024bb45663e2..191c78059071 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -208,10 +208,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 0579b61a76ad..ce10e363e0aa 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -1124,7 +1124,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 0d1e9ed18a47..668ca5d1f156 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -6417,6 +6417,12 @@ public:
return aRet;
}
+ virtual const vcl::ILibreOfficeKitNotifier* GetLOKNotifier() override
+ {
+ // dummy implementation
+ return nullptr;
+ }
+
virtual ~GtkInstanceWindow() override
{
if (m_nToplevelFocusChangedSignalId)