diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2021-09-17 19:13:15 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-10-22 17:49:20 +0200 |
commit | c4b934128965cbd461f1c61255fe0c5d25cc29d6 (patch) | |
tree | 04e4015769ed37bf876e3e7eec12bb863070cd97 /sfx2 | |
parent | d05c69a892535b910943fe98fbce42f5cc860aa4 (diff) |
LOK: maintain blocked command list per view
Conflicts:
include/LibreOfficeKit/LibreOfficeKitEnums.h
include/sfx2/viewsh.hxx
libreofficekit/source/gtk/lokdocview.cxx
sfx2/source/view/viewsh.cxx
Change-Id: I7c621accd84f49447ab3e08a4bb662a9b91b834a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124049
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/control/unoctitm.cxx | 31 | ||||
-rw-r--r-- | sfx2/source/view/lokhelper.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/view/viewsh.cxx | 23 |
3 files changed, 31 insertions, 31 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index eecf6fabead3..a095d5a656fb 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -516,17 +516,6 @@ void collectUIInformation(const util::URL& rURL, const css::uno::Sequence< css:: } } -static void lcl_BlockCommand(const rtl::OUString& command, const rtl::OUString& kind) -{ - tools::JsonWriter aTree; - aTree.put("code", ""); - aTree.put("kind", kind); - aTree.put("cmd", command); - aTree.put("message", "Blocked feature"); - aTree.put("viewID", SfxViewShell::Current()->GetViewShellId().get()); - - SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, aTree.extractData()); -} void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& aArgs, @@ -541,18 +530,16 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL, SolarMutexGuard aGuard; if (comphelper::LibreOfficeKit::isActive() && - SfxViewShell::Current()->isRestrictedView() && - comphelper::LibreOfficeKit::isRestrictedCommand(aURL.Complete)) - { - lcl_BlockCommand(aURL.Complete, "restricted"); - return; - } - - if (comphelper::LibreOfficeKit::isActive() && - SfxViewShell::Current()->isFreemiumView() && - comphelper::LibreOfficeKit::isCommandFreemiumDenied(aURL.Complete)) + SfxViewShell::Current()->isBlockedCommand(aURL.Complete)) { - lcl_BlockCommand(aURL.Complete, "freemiumdeny"); + tools::JsonWriter aTree; + aTree.put("code", ""); + aTree.put("kind", "BlockedCommand"); + aTree.put("cmd", aURL.Complete); + aTree.put("message", "Blocked feature"); + aTree.put("viewID", SfxViewShell::Current()->GetViewShellId().get()); + + SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_COMMAND_BLOCKED, aTree.extractData()); return; } diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx index 80fd65e45f7f..8210fd7faf35 100644 --- a/sfx2/source/view/lokhelper.cxx +++ b/sfx2/source/view/lokhelper.cxx @@ -739,17 +739,13 @@ void SfxLokHelper::postKeyEventAsync(const VclPtr<vcl::Window> &xWindow, postEventAsync(pLOKEv); } -void SfxLokHelper::setBlockedCommandView(int nViewId, const OUString& type, bool isBlocked) +void SfxLokHelper::setBlockedCommandList(int nViewId, const char* bolckedCommandList) { - OUString aType = type; SfxViewShell* pViewShell = SfxLokHelper::getViewOfId(nViewId); if(pViewShell) { - if(aType == "freemium") - pViewShell->setFreemiumView(isBlocked); - else - pViewShell->setRestrictedView(isBlocked); + pViewShell->setBlockedCommandList(bolckedCommandList); } } diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx index 2d21ee8b0909..ab03a4cc35f4 100644 --- a/sfx2/source/view/viewsh.cxx +++ b/sfx2/source/view/viewsh.cxx @@ -85,7 +85,7 @@ #include <sfx2/lokhelper.hxx> #include <sfx2/lokcallback.hxx> #include <openuriexternally.hxx> - +#include <iostream> #include <vector> #include <libxml/xmlwriter.h> @@ -1067,8 +1067,6 @@ SfxViewShell::SfxViewShell , maLOKLanguageTag(LANGUAGE_NONE) , maLOKLocale(LANGUAGE_NONE) , maLOKDeviceFormFactor(LOKDeviceFormFactor::UNKNOWN) -, mbLOKIsFreemiumView(false) -, mbLOKIsRestrictedView(false) { SetMargin( pViewFrame->GetMargin_Impl() ); @@ -2078,4 +2076,23 @@ weld::Window* SfxViewShell::GetFrameWeld() const return pWindow ? pWindow->GetFrameWeld() : nullptr; } +void SfxViewShell::setBlockedCommandList(const char* bolckedCommandList) +{ + if(!mvLOKBlockedCommandList.empty()) + return; + + OUString BolckedListString(bolckedCommandList, strlen(bolckedCommandList), RTL_TEXTENCODING_UTF8); + OUString command = BolckedListString.getToken(0, ' '); + for (size_t i = 1; !command.isEmpty(); i++) + { + mvLOKBlockedCommandList.emplace(command); + command = BolckedListString.getToken(i, ' '); + } +} + +bool SfxViewShell::isBlockedCommand(OUString command) +{ + return mvLOKBlockedCommandList.find(command) != mvLOKBlockedCommandList.end(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |