From 0d9d0ca83fc072979ffda84d993055f44793d05d Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Thu, 11 Aug 2022 15:08:01 +0300 Subject: lok: Simplify context change notification Change-Id: I3ead4deb5bdfe638bc49e05bfba0d8c630687958 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138141 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sfx2/source/sidebar/ContextChangeBroadcaster.cxx | 13 ++++++------- sfx2/source/view/lokhelper.cxx | 11 ++++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'sfx2') diff --git a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx index 0350929eedf1..d2d55b700fbc 100644 --- a/sfx2/source/sidebar/ContextChangeBroadcaster.cxx +++ b/sfx2/source/sidebar/ContextChangeBroadcaster.cxx @@ -86,18 +86,17 @@ void ContextChangeBroadcaster::BroadcastContextChange ( return; } - // notify the LOK too - if (comphelper::LibreOfficeKit::isActive()) - { - if (SfxViewShell* pViewShell = SfxViewShell::Get(rxFrame->getController())) - SfxLokHelper::notifyContextChange(pViewShell, rsModuleName, rsContextName); - } - const css::ui::ContextChangeEventObject aEvent( rxFrame->getController(), rsModuleName, rsContextName); + // notify the LOK too + if (comphelper::LibreOfficeKit::isActive()) + { + SfxLokHelper::notifyContextChange(aEvent); + } + css::uno::Reference xMultiplexer ( css::ui::ContextChangeEventMultiplexer::get( ::comphelper::getProcessComponentContext())); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 1d39838bfbf8..aa38c5dbee98 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -608,15 +609,19 @@ void SfxLokHelper::notifyAllViews(int nType, const OString& rPayload) } } -void SfxLokHelper::notifyContextChange(SfxViewShell const* pViewShell, const OUString& aApplication, const OUString& aContext) +void SfxLokHelper::notifyContextChange(const css::ui::ContextChangeEventObject& rEvent) { if (DisableCallbacks::disabled()) return; + SfxViewShell* pViewShell = SfxViewShell::Get({ rEvent.Source, css::uno::UNO_QUERY }); + if (!pViewShell) + return; + OString aBuffer = - OUStringToOString(aApplication.replace(' ', '_'), RTL_TEXTENCODING_UTF8) + + OUStringToOString(rEvent.ApplicationName.replace(' ', '_'), RTL_TEXTENCODING_UTF8) + " " + - OUStringToOString(aContext.replace(' ', '_'), RTL_TEXTENCODING_UTF8); + OUStringToOString(rEvent.ContextName.replace(' ', '_'), RTL_TEXTENCODING_UTF8); pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_CHANGED, aBuffer.getStr()); } -- cgit