jsdialogs: share the commands updates sending code
Change-Id: I34c1e03a8f92efe0c0dd391d16ff907919e65b00 Reviewed-on: https://gerrit.libreoffice.org/83748 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
This commit is contained in:
parent
c1f2ffa3e3
commit
880ff26edf
8 changed files with 39 additions and 81 deletions
|
@ -43,6 +43,8 @@ public:
|
|||
static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload);
|
||||
/// 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);
|
||||
/// Emits a LOK_CALLBACK_STATE_CHANGED
|
||||
static void sendUnoStatus(const SfxViewShell* pThisView, const SfxItemSet* pSet);
|
||||
/// Emits a LOK_CALLBACK_WINDOW
|
||||
static void notifyWindow(const SfxViewShell* pThisView,
|
||||
vcl::LOKWindowId nWindowId,
|
||||
|
|
|
@ -224,6 +224,7 @@ public:
|
|||
virtual const SfxShell* GetFormShell() const { return nullptr; };
|
||||
|
||||
// ILibreOfficeKitNotifier
|
||||
virtual void sendUnoStatus(const SfxItemSet* pSet) const override;
|
||||
virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload = std::vector<vcl::LOKPayloadItem>()) const override;
|
||||
|
||||
// Focus, KeyInput, Cursor
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
class SfxItemSet;
|
||||
|
||||
namespace vcl
|
||||
{
|
||||
|
||||
|
@ -31,6 +33,7 @@ public:
|
|||
virtual ~ILibreOfficeKitNotifier() {}
|
||||
|
||||
/// Callbacks
|
||||
virtual void sendUnoStatus(const SfxItemSet* pSet) const = 0;
|
||||
virtual void notifyWindow(vcl::LOKWindowId nLOKWindowId,
|
||||
const OUString& rAction,
|
||||
const std::vector<LOKPayloadItem>& rPayload = std::vector<LOKPayloadItem>()) const = 0;
|
||||
|
|
|
@ -59,32 +59,6 @@
|
|||
using namespace com::sun::star::drawing;
|
||||
using namespace com::sun::star;
|
||||
|
||||
namespace {
|
||||
void lcl_sendAttrUpdatesForLOK(SfxViewShell* pShell, const SfxItemSet& rSet)
|
||||
{
|
||||
if (!pShell)
|
||||
return;
|
||||
|
||||
boost::property_tree::ptree aTree;
|
||||
boost::property_tree::ptree anArray;
|
||||
|
||||
for(int i = 0; i < rSet.Count(); i++)
|
||||
{
|
||||
sal_uInt16 nWhich = rSet.GetWhichByPos(i);
|
||||
if (rSet.HasItem(nWhich) && SfxItemState::SET >= rSet.GetItemState(nWhich))
|
||||
{
|
||||
boost::property_tree::ptree aItem = rSet.Get(nWhich).dumpAsJSON();
|
||||
if (!aItem.empty())
|
||||
anArray.push_back(std::make_pair("", aItem));
|
||||
}
|
||||
}
|
||||
aTree.add_child("items", anArray);
|
||||
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aStream.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
ScDrawShell::ScDrawShell( ScViewData* pData ) :
|
||||
SfxShell(pData->GetViewShell()),
|
||||
|
@ -394,7 +368,7 @@ void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet )
|
|||
|
||||
SfxViewShell* pViewShell = GetDrawView()->GetSfxViewShell();
|
||||
if (pViewShell && comphelper::LibreOfficeKit::isActive())
|
||||
lcl_sendAttrUpdatesForLOK( pViewShell, rSet );
|
||||
pViewShell->sendUnoStatus( &rSet );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,33 +73,6 @@ using namespace com::sun::star::drawing;
|
|||
using namespace svx::sidebar;
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
namespace {
|
||||
void lcl_sendAttrUpdatesForLOK(SfxViewShell* pShell, const SfxItemSet& rSet)
|
||||
{
|
||||
if (!pShell)
|
||||
return;
|
||||
|
||||
boost::property_tree::ptree aTree;
|
||||
boost::property_tree::ptree anArray;
|
||||
|
||||
for(int i = 0; i < rSet.Count(); i++)
|
||||
{
|
||||
sal_uInt16 nWhich = rSet.GetWhichByPos(i);
|
||||
if (rSet.HasItem(nWhich) && SfxItemState::SET >= rSet.GetItemState(nWhich))
|
||||
{
|
||||
boost::property_tree::ptree aItem = rSet.Get(nWhich).dumpAsJSON();
|
||||
if (!aItem.empty())
|
||||
anArray.push_back(std::make_pair("", aItem));
|
||||
}
|
||||
}
|
||||
aTree.add_child("items", anArray);
|
||||
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aStream.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
namespace sd {
|
||||
|
||||
/**
|
||||
|
@ -733,7 +706,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
|
|||
|
||||
SfxViewShell* pViewShell = GetDrawView()->GetSfxViewShell();
|
||||
if (pViewShell && comphelper::LibreOfficeKit::isActive())
|
||||
lcl_sendAttrUpdatesForLOK( pViewShell, *pSet );
|
||||
pViewShell->sendUnoStatus( &rSet );
|
||||
}
|
||||
|
||||
SfxItemState eState = pSet->GetItemState( EE_PARA_LRSPACE );
|
||||
|
|
|
@ -181,6 +181,31 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
|
|||
}
|
||||
}
|
||||
|
||||
void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxItemSet* pSet)
|
||||
{
|
||||
if (!pShell || !pSet)
|
||||
return;
|
||||
|
||||
boost::property_tree::ptree aTree;
|
||||
boost::property_tree::ptree anArray;
|
||||
|
||||
for(int i = 0; i < pSet->Count(); i++)
|
||||
{
|
||||
sal_uInt16 nWhich = pSet->GetWhichByPos(i);
|
||||
if (pSet->HasItem(nWhich) && SfxItemState::SET >= pSet->GetItemState(nWhich))
|
||||
{
|
||||
boost::property_tree::ptree aItem = pSet->Get(nWhich).dumpAsJSON();
|
||||
if (!aItem.empty())
|
||||
anArray.push_back(std::make_pair("", aItem));
|
||||
}
|
||||
}
|
||||
aTree.add_child("items", anArray);
|
||||
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aStream.str().c_str());
|
||||
}
|
||||
|
||||
void SfxLokHelper::notifyWindow(const SfxViewShell* pThisView,
|
||||
vcl::LOKWindowId nLOKWindowId,
|
||||
const OUString& rAction,
|
||||
|
|
|
@ -1995,6 +1995,11 @@ Reference< view::XRenderable > SfxViewShell::GetRenderable()
|
|||
return xRender;
|
||||
}
|
||||
|
||||
void SfxViewShell::sendUnoStatus(const SfxItemSet* pSet) const
|
||||
{
|
||||
SfxLokHelper::sendUnoStatus(this, pSet);
|
||||
}
|
||||
|
||||
void SfxViewShell::notifyWindow(vcl::LOKWindowId nDialogId, const OUString& rAction, const std::vector<vcl::LOKPayloadItem>& rPayload) const
|
||||
{
|
||||
SfxLokHelper::notifyWindow(this, nDialogId, rAction, rPayload);
|
||||
|
|
|
@ -254,31 +254,6 @@ namespace
|
|||
pArgs->Put(aItem);
|
||||
}
|
||||
}
|
||||
|
||||
void lcl_sendAttrUpdatesForLOK(SfxViewShell* pShell, const SfxItemSet& rSet)
|
||||
{
|
||||
if (!pShell)
|
||||
return;
|
||||
|
||||
boost::property_tree::ptree aTree;
|
||||
boost::property_tree::ptree anArray;
|
||||
|
||||
for(int i = 0; i < rSet.Count(); i++)
|
||||
{
|
||||
sal_uInt16 nWhich = rSet.GetWhichByPos(i);
|
||||
if (rSet.HasItem(nWhich) && SfxItemState::SET >= rSet.GetItemState(nWhich))
|
||||
{
|
||||
boost::property_tree::ptree aItem = rSet.Get(nWhich).dumpAsJSON();
|
||||
if (!aItem.empty())
|
||||
anArray.push_back(std::make_pair("", aItem));
|
||||
}
|
||||
}
|
||||
aTree.add_child("items", anArray);
|
||||
|
||||
std::stringstream aStream;
|
||||
boost::property_tree::write_json(aStream, aTree);
|
||||
pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aStream.str().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SwDrawShell::ExecDrawAttrArgs(SfxRequest const & rReq)
|
||||
|
@ -350,7 +325,7 @@ void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
|
|||
|
||||
SfxViewShell* pViewShell = GetShell().GetSfxViewShell();
|
||||
if (pViewShell && comphelper::LibreOfficeKit::isActive())
|
||||
lcl_sendAttrUpdatesForLOK( pViewShell, rSet );
|
||||
pViewShell->sendUnoStatus( &rSet );
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
Loading…
Reference in a new issue