summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2021-09-13 23:05:40 +0530
committerMiklos Vajna <vmiklos@collabora.com>2021-10-22 12:49:56 +0200
commit8de04f459611df936c0b315b6d48cb3dbcc1d5fa (patch)
treed0ba32ac0b7422b28e9db8525c9ca62de110d62a /sfx2
parent751fa45b1780f275a7b8fdce52a2fd722e87fcb7 (diff)
LOK: introduce way to restrict uno commands
With this new API we can define which uno commands to restrict their functionality Conflicts: desktop/qa/desktop_lib/test_desktop_lib.cxx include/LibreOfficeKit/LibreOfficeKit.h include/LibreOfficeKit/LibreOfficeKit.hxx include/sfx2/viewsh.hxx Change-Id: I9f3fd659d373e56542c5323922a53564f1cfb27b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124046 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/unoctitm.cxx17
-rw-r--r--sfx2/source/view/lokhelper.cxx7
-rw-r--r--sfx2/source/view/viewsh.cxx1
3 files changed, 25 insertions, 0 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index a20056c15fff..5b55a4d75b75 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -543,6 +543,23 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
return;
}
+ if (comphelper::LibreOfficeKit::isActive() &&
+ SfxViewShell::Current()->isRestrictedView() &&
+ comphelper::LibreOfficeKit::isRestrictedCommand(aURL.Complete))
+ {
+ boost::property_tree::ptree aTree;
+ aTree.put("code", "");
+ aTree.put("kind", "restricted");
+ aTree.put("cmd", aURL.Complete);
+ aTree.put("message", "Blocked restricted feature");
+ aTree.put("viewID", SfxViewShell::Current()->GetViewShellId().get());
+
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, aTree);
+ SfxViewShell::Current()->libreOfficeKitViewCallback(LOK_CALLBACK_ERROR, aStream.str().c_str());
+ return;
+ }
+
if (
!(pDispatch &&
(
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index f62497f5ae81..bfb55c10eff1 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -747,6 +747,13 @@ void SfxLokHelper::setFreemiumView(int nViewId, bool isFreemium)
pViewShell->setFreemiumView(isFreemium);
}
+void SfxLokHelper::setRestrictedView(int nViewId, bool isRestricted)
+{
+ SfxViewShell* pViewShell = SfxLokHelper::getViewOfId(nViewId);
+
+ if(pViewShell)
+ pViewShell->setRestrictedView(isRestricted);
+}
void SfxLokHelper::postExtTextEventAsync(const VclPtr<vcl::Window> &xWindow,
int nType, const OUString &rText)
{
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 4b12dae1c0ee..2b78cde00386 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1068,6 +1068,7 @@ SfxViewShell::SfxViewShell
, maLOKLocale(LANGUAGE_NONE)
, maLOKDeviceFormFactor(LOKDeviceFormFactor::UNKNOWN)
, mbLOKIsFreemiumView(false)
+, mbLOKIsRestrictedView(false)
{
SetMargin( pViewFrame->GetMargin_Impl() );