From 4b1c6ee557978fe253ebabeeaf93964a5deaf7eb Mon Sep 17 00:00:00 2001 From: Henry Castro Date: Fri, 25 Dec 2020 13:09:00 -0400 Subject: lok: add missing global notifier Occurs when server shows the "Macro Security Warning" before load the document if enable/disable macros, but there are no instances for document/view/controller yet. So it is required to use the global notifier so it can be sent messages to the client side using the JSDialog framework. Change-Id: I67f15b21cbaf21906b88145f3c5835cf0e1ff79d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108288 Tested-by: Jenkins Reviewed-by: Henry Castro --- desktop/source/lib/init.cxx | 7 +++++-- include/vcl/svapp.hxx | 14 +++++++++++++- vcl/source/app/svapp.cxx | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d59bbd80d3bf..c3214a771657 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2465,11 +2465,14 @@ static void lo_registerCallback (LibreOfficeKit* pThis, { SolarMutexGuard aGuard; + Application* pApp = GetpApp(); + assert(pApp); + LibLibreOffice_Impl* pLib = static_cast(pThis); pLib->maLastExceptionMsg.clear(); - pLib->mpCallback = pCallback; - pLib->mpCallbackData = pData; + pApp->m_pCallback = pLib->mpCallback = pCallback; + pApp->m_pCallbackData = pLib->mpCallbackData = pData; } static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const char* pFormat, const char* pFilterOptions) diff --git a/include/vcl/svapp.hxx b/include/vcl/svapp.hxx index b1d7759765c3..bfa92cf88321 100644 --- a/include/vcl/svapp.hxx +++ b/include/vcl/svapp.hxx @@ -27,12 +27,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -227,7 +229,7 @@ enum class DialogCancelMode { @see Desktop, ImplSVData */ -class VCL_DLLPUBLIC Application +class VCL_DLLPUBLIC Application : public vcl::ILibreOfficeKitNotifier { public: /** @name Initialization @@ -1319,6 +1321,16 @@ public: bool bMobile = false); static weld::Window* GetFrameWeld(const css::uno::Reference& rWindow); + + // ILibreOfficeKitNotifier + void* m_pCallbackData; + LibreOfficeKitCallback m_pCallback; + + virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId, + const OUString& rAction, + const std::vector& rPayload = std::vector()) const override; + virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) const override; + private: DECL_STATIC_LINK( Application, PostEventHandler, void*, void ); }; diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index 676fa26e1038..332075cccd93 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -164,6 +164,8 @@ Application::Application() osl_setEnvironment(aVar.pData, aValue.pData); ImplGetSVData()->mpApp = this; + m_pCallbackData = nullptr; + m_pCallback = nullptr; } Application::~Application() @@ -313,6 +315,23 @@ void Application::EndAllPopups() Application::PostUserEvent( LINK( nullptr, ImplSVAppData, ImplEndAllPopupsMsg ) ); } +void Application::notifyWindow(vcl::LOKWindowId /*nLOKWindowId*/, + const OUString& /*rAction*/, + const std::vector& /*rPayload = std::vector()*/) const +{ +} + +void Application::libreOfficeKitViewCallback(int nType, const char* pPayload) const +{ + if (!comphelper::LibreOfficeKit::isActive()) + return; + + if (m_pCallback) + { + m_pCallback(nType, pPayload, m_pCallbackData); + } +} + namespace { -- cgit