diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-08-11 15:08:01 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-08-11 17:28:51 +0200 |
commit | 0d9d0ca83fc072979ffda84d993055f44793d05d (patch) | |
tree | 57887d3f41b083e3a68bfcf469dcff3be94585b6 | |
parent | 10e81b3dd5e0712eb8298ee7b6ebf844440fc2d8 (diff) |
lok: Simplify context change notification
Change-Id: I3ead4deb5bdfe638bc49e05bfba0d8c630687958
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138141
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | include/sfx2/lokhelper.hxx | 4 | ||||
-rw-r--r-- | sfx2/source/sidebar/ContextChangeBroadcaster.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 11 | ||||
-rw-r--r-- | svx/source/sidebar/ContextChangeEventMultiplexer.cxx | 3 |
4 files changed, 18 insertions, 13 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 0b18c0fa7b5e..909b6335733d 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -44,6 +44,8 @@ struct SFX2_DLLPUBLIC LokMouseEventData #include <boost/property_tree/ptree_fwd.hpp> +namespace com::sun::star::ui { struct ContextChangeEventObject; }; + class SFX2_DLLPUBLIC SfxLokHelper { public: @@ -115,7 +117,7 @@ public: static void notifyAllViews(int nType, const OString& rPayload); /// Notify about the editing context change. - static void notifyContextChange(SfxViewShell const* pViewShell, const OUString& aApplication, const OUString& aContext); + static void notifyContextChange(const css::ui::ContextChangeEventObject& rEvent); // Notify about the given type needing an update. static void notifyUpdate(SfxViewShell const* pViewShell, int nType); 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<css::ui::XContextChangeEventMultiplexer> 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 <sfx2/lokhelper.hxx> #include <com/sun/star/frame/Desktop.hpp> +#include <com/sun/star/ui/ContextChangeEventObject.hpp> #include <comphelper/processfactory.hxx> #include <rtl/strbuf.hxx> @@ -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()); } diff --git a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx index ce552b0ac837..dd44e706aeec 100644 --- a/svx/source/sidebar/ContextChangeEventMultiplexer.cxx +++ b/svx/source/sidebar/ContextChangeEventMultiplexer.cxx @@ -53,8 +53,7 @@ void ContextChangeEventMultiplexer::NotifyContextChange ( // notify the LOK too after all the change have taken effect. if (comphelper::LibreOfficeKit::isActive()) { - if (SfxViewShell* pViewShell = SfxViewShell::Get(rxController)) - SfxLokHelper::notifyContextChange(pViewShell, GetModuleName(rxController->getFrame()), vcl::EnumContext::GetContextName(eContext)); + SfxLokHelper::notifyContextChange(aEvent); } } |