diff options
Diffstat (limited to 'sfx2')
-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 |
3 files changed, 14 insertions, 26 deletions
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); |