summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2019-11-26 10:47:33 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2019-11-28 08:34:20 +0100
commitae9e1569e736ad63bf2a2e197441657283c3f344 (patch)
treeafdf048444ff0a7836552735cd7f20d61673a5ed
parentcc4dbe473b0b68dbe120065c1d6a64a087f41ba2 (diff)
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> (cherry picked from commit 880ff26edff0f7dfdd0d5b74fd9d7026fd2d8523) Reviewed-on: https://gerrit.libreoffice.org/83954 Tested-by: Jenkins
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--include/sfx2/viewsh.hxx1
-rw-r--r--include/vcl/IDialogRenderable.hxx3
-rw-r--r--sc/source/ui/drawfunc/drawsh2.cxx28
-rw-r--r--sd/source/ui/view/drviewsf.cxx29
-rw-r--r--sfx2/source/view/lokhelper.cxx25
-rw-r--r--sfx2/source/view/viewsh.cxx5
-rw-r--r--sw/source/uibase/shells/drawdlg.cxx27
8 files changed, 39 insertions, 81 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 760b2ed5dfc6..889788454d41 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -42,6 +42,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,
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index d65fae656b16..691ee99839e4 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -219,6 +219,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
diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx
index 86ea333d1100..969c15421995 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -17,6 +17,8 @@
#include <vector>
+class SfxItemSet;
+
namespace vcl
{
@@ -30,6 +32,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;
diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx
index e2ef0c75a173..0e3bf2b3529b 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -57,32 +57,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()),
@@ -398,7 +372,7 @@ void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet )
SfxViewShell* pViewShell = GetDrawView()->GetSfxViewShell();
if (pViewShell && comphelper::LibreOfficeKit::isActive())
- lcl_sendAttrUpdatesForLOK( pViewShell, rSet );
+ pViewShell->sendUnoStatus( &rSet );
}
}
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index be7befd1dc94..5977fb697140 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -70,33 +70,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 {
/**
@@ -762,7 +735,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
SfxViewShell* pViewShell = GetDrawView()->GetSfxViewShell();
if (pViewShell && comphelper::LibreOfficeKit::isActive())
- lcl_sendAttrUpdatesForLOK( pViewShell, *pSet );
+ pViewShell->sendUnoStatus( &rSet );
}
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 6dea1bc3d125..ee032c6f4977 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -183,6 +183,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,
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 0301bd2acd59..78f498143a57 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2015,6 +2015,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);
diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx
index 558942f9d437..d9c82359dc83 100644
--- a/sw/source/uibase/shells/drawdlg.cxx
+++ b/sw/source/uibase/shells/drawdlg.cxx
@@ -257,31 +257,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)
@@ -353,7 +328,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: */