diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2020-06-02 11:51:52 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.com> | 2020-07-06 17:34:16 +0200 |
commit | 6c09506d3da25f6f478c4f8ce94f7e5c0412b1fd (patch) | |
tree | 52726201f49408dc032192820e36647757a44f90 /sfx2 | |
parent | 2947c08471c10fddd9e6b5b21aea2ac00d60d14c (diff) |
introduce property-tree versions of SfxLokHelper::notifyOtherView*()
Change-Id: I4ebbc166da94eab6e35984c50220dde7daf7adde
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98055
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 0b92060785bb..03241d065a78 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -30,6 +30,8 @@ #include <shellimpl.hxx> +#include <boost/property_tree/json_parser.hpp> + using namespace com::sun::star; namespace { @@ -288,6 +290,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()) @@ -300,6 +312,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()) @@ -315,6 +336,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) { |