include/sfx2/lokhelper.hxx | 2 ++ include/sfx2/viewsh.hxx | 1 + include/vcl/IDialogRenderable.hxx | 3 +++ sc/source/ui/drawfunc/drawsh2.cxx | 28 +--------------------------- sd/source/ui/view/drviewsf.cxx | 29 +---------------------------- sfx2/source/view/lokhelper.cxx | 25 +++++++++++++++++++++++++ sfx2/source/view/viewsh.cxx | 5 +++++ sw/source/uibase/shells/drawdlg.cxx | 27 +-------------------------- 8 files changed, 39 insertions(+), 81 deletions(-)
New commits: commit 880ff26edff0f7dfdd0d5b74fd9d7026fd2d8523 Author: Szymon Kłos <[email protected]> AuthorDate: Tue Nov 26 10:47:33 2019 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Wed Nov 27 22:37:25 2019 +0100 jsdialogs: share the commands updates sending code Change-Id: I34c1e03a8f92efe0c0dd391d16ff907919e65b00 Reviewed-on: https://gerrit.libreoffice.org/83748 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index 57ff680cfdb0..697840ff035b 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -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, diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 0f6915d8a9c0..599aedf2cb53 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -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 diff --git a/include/vcl/IDialogRenderable.hxx b/include/vcl/IDialogRenderable.hxx index a2c9b8416ccd..963fd4998182 100644 --- a/include/vcl/IDialogRenderable.hxx +++ b/include/vcl/IDialogRenderable.hxx @@ -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; diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx index aa1c0bfd93a2..852f1931d64a 100644 --- a/sc/source/ui/drawfunc/drawsh2.cxx +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -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 ); } } diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx index fea9c35e5a20..6e00a5256646 100644 --- a/sd/source/ui/view/drviewsf.cxx +++ b/sd/source/ui/view/drviewsf.cxx @@ -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 ); diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 035c4c7fff06..4571d74c7059 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -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, diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 42d85f336da8..f8ffb6ddae1c 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -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); diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index 4e31cf1097f4..a8100523c9e5 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -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: */ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
