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>
This commit is contained in:
@@ -39,6 +39,8 @@ struct SFX2_DLLPUBLIC LokMouseEventData
|
||||
{}
|
||||
};
|
||||
|
||||
#include <boost/property_tree/ptree_fwd.hpp>
|
||||
|
||||
class SFX2_DLLPUBLIC SfxLokHelper
|
||||
{
|
||||
public:
|
||||
@@ -75,8 +77,12 @@ public:
|
||||
static void forEachOtherView(ViewShellType* pThisViewShell, FunctionType f);
|
||||
/// Invoke the LOK callback of all other views showing the same document as pThisView, with a payload of rKey-rPayload.
|
||||
static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload);
|
||||
/// Invoke the LOK callback of all views except pThisView, with a JSON payload created from the given property tree.
|
||||
static void notifyOtherViews(SfxViewShell* pThisView, int nType, const boost::property_tree::ptree& rTree);
|
||||
/// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
|
||||
static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
|
||||
/// Same as notifyOtherViews(), the property-tree version, but works on a selected "other" view, not on all of them.
|
||||
static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const boost::property_tree::ptree& rTree);
|
||||
/// Emits a LOK_CALLBACK_STATE_CHANGED
|
||||
static void sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem);
|
||||
/// Emits a LOK_CALLBACK_WINDOW
|
||||
|
@@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user