summaryrefslogtreecommitdiff
path: root/sfx2/source/view/lokhelper.cxx
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2020-06-02 11:51:52 +0530
committerDennis Francis <dennis.francis@collabora.com>2020-07-07 07:46:56 +0200
commit2f72fa980c2c81248c32d3b95598c23aba6ac6ed (patch)
tree2841e0feed41fa178171b58febb0642db430e892 /sfx2/source/view/lokhelper.cxx
parent06f1f8d817a2ea86e29bbef7cf0995ce337c56be (diff)
introduce property-tree versions of SfxLokHelper::notifyOtherView*()
Change-Id: I4ebbc166da94eab6e35984c50220dde7daf7adde Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98119 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sfx2/source/view/lokhelper.cxx')
-rw-r--r--sfx2/source/view/lokhelper.cxx37
1 files changed, 37 insertions, 0 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index af7b75a26897..67097c444990 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -291,6 +291,16 @@ static OString lcl_escapeQuotes(const OString &rStr)
return aBuf.makeStringAndClear();
}
+static OString lcl_generateJSON(SfxViewShell* pView, const boost::property_tree::ptree& rTree)
+{
+ boost::property_tree::ptree aMessageProps = rTree;
+ aMessageProps.put("viewId", SfxLokHelper::getView(pView));
+ aMessageProps.put("part", pView->getPart());
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aMessageProps, false /* pretty */);
+ return OString(aStream.str().c_str()).trim();
+}
+
void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload)
{
if (DisableCallbacks::disabled())
@@ -303,6 +313,15 @@ void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const*
pOtherView->libreOfficeKitViewCallback(nType, aPayload.getStr());
}
+void SfxLokHelper::notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType,
+ const boost::property_tree::ptree& rTree)
+{
+ if (DisableCallbacks::disabled())
+ return;
+
+ pOtherView->libreOfficeKitViewCallback(nType, lcl_generateJSON(pThisView, rTree).getStr());
+}
+
void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload)
{
if (DisableCallbacks::disabled())
@@ -318,6 +337,24 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
}
}
+void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const boost::property_tree::ptree& rTree)
+{
+ if (SfxLokHelper::getViewsCount() <= 1 || DisableCallbacks::disabled())
+ return;
+
+ // Payload is only dependent on pThisView.
+ OString aPayload = lcl_generateJSON(pThisView, rTree);
+
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while (pViewShell)
+ {
+ if (pViewShell != pThisView)
+ pViewShell->libreOfficeKitViewCallback(nType, aPayload.getStr());
+
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+}
+
namespace {
OUString lcl_getNameForSlot(const SfxViewShell* pShell, sal_uInt16 nWhich)
{