diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2019-12-10 15:16:32 +0100 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2019-12-11 22:51:03 +0100 |
commit | dd27fedb88cc18bbfc669503cfe510d99f40f05d (patch) | |
tree | 460ef56c194da26cc3a095648bbcd13cac40c445 | |
parent | ef8674a48888e2601653fd6481b6542914ffd97c (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/84914
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | include/sfx2/lokhelper.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/viewsh.hxx | 1 | ||||
-rw-r--r-- | include/vcl/IDialogRenderable.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/drawfunc/drawsh2.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/drviewsf.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdedtv1.cxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/grafctrl.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawdlg.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/shells/grfsh.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/shells/txtattr.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewtab.cxx | 4 |
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 1b46491c65c8..906f4b331e90 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -732,10 +732,6 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet ) rSet.DisableItem( nWhich ); } nWhich = aNewIter.NextWhich(); - - SfxViewShell* pViewShell = GetDrawView()->GetSfxViewShell(); - if (pViewShell && comphelper::LibreOfficeKit::isActive()) - pViewShell->sendUnoStatus( &rSet ); } } diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 496ea66b497f..bec98c57b486 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> @@ -1211,6 +1212,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 c38739f69e90..fb38b4a91e91 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -206,34 +206,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 baaceb0b6a73..52ddcd97668b 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -2020,11 +2020,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 20bdf962839b..588dbc25623f 100644 --- a/svx/source/tbxctrls/grafctrl.cxx +++ b/svx/source/tbxctrls/grafctrl.cxx @@ -1034,10 +1034,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 457e0e341cd7..0437340ebf98 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -336,10 +336,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 98e3606f152a..0b417f441e76 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 81b44e58ec51..ac46c5a1622a 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: */ |