summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-08-11 15:08:01 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-08-11 17:28:51 +0200
commit0d9d0ca83fc072979ffda84d993055f44793d05d (patch)
tree57887d3f41b083e3a68bfcf469dcff3be94585b6 /sfx2
parent10e81b3dd5e0712eb8298ee7b6ebf844440fc2d8 (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>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/sidebar/ContextChangeBroadcaster.cxx13
-rw-r--r--sfx2/source/view/lokhelper.cxx11
2 files changed, 14 insertions, 10 deletions
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());
}