summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2019-12-10 15:16:32 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2019-12-11 11:13:17 +0100
commit23c8830da611d14dbffc2022efac28203352f6b9 (patch)
treec4014a43be69a105b2f3e9f9d731d788cabff9e1 /sfx2
parentb7e4b1a27b55dff4792ccd32b0c6658956dcf27a (diff)
jsdialog: send items on status change
Use existing mechanism, delete sending in getter code which caused unnecessary work. Change-Id: Ibc191c16b95fd58e7065e019f48f3837cfed5bbd Reviewed-on: https://gerrit.libreoffice.org/84888 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/unoctitm.cxx4
-rw-r--r--sfx2/source/view/lokhelper.cxx31
-rw-r--r--sfx2/source/view/viewsh.cxx5
3 files changed, 14 insertions, 26 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index c308a15bb53d..7b8d6d101df8 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -66,6 +66,7 @@
#include <rtl/ustring.hxx>
#include <unotools/pathoptions.hxx>
#include <osl/time.h>
+#include <sfx2/lokhelper.hxx>
#include <iostream>
#include <map>
@@ -1206,6 +1207,9 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c
}
else
{
+ // Try to send JSON state version
+ SfxLokHelper::sendUnoStatus(SfxViewShell::Current(), pState);
+
return;
}
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 65f8e5090972..5802a9b96ad8 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -235,34 +235,23 @@ namespace {
}
}
-void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxItemSet* pSet)
+void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem)
{
- if (!pShell || !pSet || DisableCallbacks::disabled())
+ if (!pShell || !pItem || DisableCallbacks::disabled())
return;
- boost::property_tree::ptree aTree;
- boost::property_tree::ptree anArray;
+ boost::property_tree::ptree aItem = pItem->dumpAsJSON();
- for(int i = 0; i < pSet->Count(); i++)
+ if (aItem.count("state"))
{
- sal_uInt16 nWhich = pSet->GetWhichByPos(i);
- if (pSet->HasItem(nWhich) && SfxItemState::SET >= pSet->GetItemState(nWhich))
- {
- boost::property_tree::ptree aItem = pSet->Get(nWhich).dumpAsJSON();
-
- OUString sCommand = lcl_getNameForSlot(pShell, nWhich);
- if (!sCommand.isEmpty())
- aItem.put("commandName", sCommand);
+ OUString sCommand = lcl_getNameForSlot(pShell, pItem->Which());
+ if (!sCommand.isEmpty())
+ aItem.put("commandName", sCommand);
- if (!aItem.empty())
- anArray.push_back(std::make_pair("", aItem));
- }
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aItem);
+ pShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, aStream.str().c_str());
}
- 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,
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 7e2ec6369e58..bc32de20a9e6 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2000,11 +2000,6 @@ 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);