summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2019-12-10 15:16:32 +0100
committerSzymon Kłos <eszkadev@gmail.com>2020-05-13 19:52:47 +0200
commit60ac97df116da5f2d8e405509161ee4ac3167b00 (patch)
tree91ec168a2d332b01ff0ba175d5e47ada8b65f251
parent4c6ca777b1ea0ef2b36fc0c08b44220397f9361d (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>
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--include/sfx2/viewsh.hxx1
-rw-r--r--include/vcl/IDialogRenderable.hxx1
-rw-r--r--sc/source/ui/drawfunc/drawsh2.cxx4
-rw-r--r--sd/source/ui/view/drviewsf.cxx4
-rw-r--r--sfx2/source/control/unoctitm.cxx4
-rw-r--r--sfx2/source/view/lokhelper.cxx31
-rw-r--r--sfx2/source/view/viewsh.cxx5
-rw-r--r--svx/source/svdraw/svdedtv1.cxx4
-rw-r--r--svx/source/tbxctrls/grafctrl.cxx4
-rw-r--r--sw/source/uibase/shells/drawdlg.cxx4
-rw-r--r--sw/source/uibase/shells/grfsh.cxx4
-rw-r--r--sw/source/uibase/shells/txtattr.cxx4
-rw-r--r--sw/source/uibase/uiview/viewtab.cxx4
14 files changed, 15 insertions, 61 deletions
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 889788454d41..0a5af99a9e45 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -43,7 +43,7 @@ public:
/// 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);
+ static void sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem);
/// 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 691ee99839e4..d65fae656b16 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -219,7 +219,6 @@ 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 969c15421995..7e2d39c7a486 100644
--- a/include/vcl/IDialogRenderable.hxx
+++ b/include/vcl/IDialogRenderable.hxx
@@ -32,7 +32,6 @@ 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 0e3bf2b3529b..772e2936911a 100644
--- a/sc/source/ui/drawfunc/drawsh2.cxx
+++ b/sc/source/ui/drawfunc/drawsh2.cxx
@@ -369,10 +369,6 @@ void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet )
rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) );
}
}
-
- SfxViewShell* pViewShell = GetDrawView()->GetSfxViewShell();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &rSet );
}
}
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index c3ee5e83d1c3..95ecd4a0d52a 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -733,10 +733,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
}
nWhich = aNewIter.NextWhich();
}
-
- SfxViewShell* pViewShell = GetDrawView()->GetSfxViewShell();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &rSet );
}
SfxItemState eState = pSet->GetItemState( EE_PARA_LRSPACE );
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 52339b8c7f5b..6a217b14f880 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -69,6 +69,7 @@
#include <rtl/ustring.hxx>
#include <unotools/pathoptions.hxx>
#include <osl/time.h>
+#include <sfx2/lokhelper.hxx>
#include <iostream>
#include <map>
@@ -1220,6 +1221,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 acb4fea6f49a..68b4cfcb8159 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -204,34 +204,23 @@ namespace {
}
}
-void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxItemSet* pSet)
+void SfxLokHelper::sendUnoStatus(const SfxViewShell* pShell, const SfxPoolItem* pItem)
{
- if (!pShell || !pSet)
+ if (!pShell || !pItem)
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 d865e64f05b7..8a199623fa58 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -2013,11 +2013,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);
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 5439a2810395..cf29f4a268df 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -907,10 +907,6 @@ SfxItemSet SdrEditView::GetAttrFromMarked(bool bOnlyHardAttr) const
aSet.ClearItem(EE_FEATURE_NOTCONV);
aSet.ClearItem(EE_FEATURE_FIELD);
- SfxViewShell* pViewShell = SfxViewShell::Current();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &aSet );
-
return aSet;
}
diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx
index af5da09255bf..b321e0799f92 100644
--- a/svx/source/tbxctrls/grafctrl.cxx
+++ b/svx/source/tbxctrls/grafctrl.cxx
@@ -1017,10 +1017,6 @@ void SvxGrafAttrHelper::GetGrafAttrState( SfxItemSet& rSet, SdrView const & rVie
nWhich = aIter.NextWhich();
}
-
- SfxViewShell* pViewShell = SfxViewShell::Current();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &rSet );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx
index 5f9d04af8079..c0fff23e32f8 100644
--- a/sw/source/uibase/shells/drawdlg.cxx
+++ b/sw/source/uibase/shells/drawdlg.cxx
@@ -337,10 +337,6 @@ void SwDrawShell::GetDrawAttrState(SfxItemSet& rSet)
}
else
rSet.Put(pSdrView->GetDefaultAttr());
-
- SfxViewShell* pViewShell = GetShell().GetSfxViewShell();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &rSet );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index 13cd9a22b4ad..da49cf73992d 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -924,10 +924,6 @@ void SwGrfShell::GetAttrState(SfxItemSet &rSet)
nWhich = aIter.NextWhich();
}
SetGetStateSet( nullptr );
-
- SfxViewShell* pViewShell = GetShell().GetSfxViewShell();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &rSet );
}
void SwGrfShell::ExecuteRotation(SfxRequest const &rReq)
diff --git a/sw/source/uibase/shells/txtattr.cxx b/sw/source/uibase/shells/txtattr.cxx
index 1b11fcca7bad..c7fb5cc28965 100644
--- a/sw/source/uibase/shells/txtattr.cxx
+++ b/sw/source/uibase/shells/txtattr.cxx
@@ -846,10 +846,6 @@ void SwTextShell::GetAttrState(SfxItemSet &rSet)
}
rSet.Put(aCoreSet,false);
-
- SfxViewShell* pViewShell = SfxViewShell::Current();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &rSet );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index f5941793eadb..448387e2527e 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -2435,10 +2435,6 @@ void SwView::StateTabWin(SfxItemSet& rSet)
}
nWhich = aIter.NextWhich();
}
-
- SfxViewShell* pViewShell = SfxViewShell::Current();
- if (pViewShell && comphelper::LibreOfficeKit::isActive())
- pViewShell->sendUnoStatus( &rSet );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */