summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorPranam Lashkari <lpranam@collabora.com>2021-06-02 19:06:52 +0530
committerPranam Lashkari <lpranam@collabora.com>2021-06-23 17:11:46 +0200
commit1b9fe58acb7b5bbbc83ecca30e17663fff7f0db4 (patch)
tree5f957f515079cae501c2b2f12d08cbd77bd82461 /sfx2
parentce275a824aab6601c9de0b61f4b8568b9478ce19 (diff)
LOK: introduced Freemium LOK API
also block the uno commands from deny list Change-Id: Iee994411891b73b865e6496403682f996d5e9321 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116384 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Pranam Lashkari <lpranam@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/control/unoctitm.cxx19
-rw-r--r--sfx2/source/view/lokhelper.cxx25
2 files changed, 44 insertions, 0 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index e9019fab2326..f8039ca9d4b7 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -68,6 +68,7 @@
#include <unotools/pathoptions.hxx>
#include <osl/time.h>
#include <sfx2/lokhelper.hxx>
+#include <basic/sberrors.hxx>
#include <map>
#include <memory>
@@ -617,6 +618,24 @@ void SfxDispatchController_Impl::dispatch( const css::util::URL& aURL,
collectUIInformation(aURL, aArgs);
SolarMutexGuard aGuard;
+
+ if (comphelper::LibreOfficeKit::isActive() &&
+ SfxViewShell::Current()->isFreemiumView() &&
+ comphelper::LibreOfficeKit::isCommandFreemiumDenied(aURL.Complete))
+ {
+ boost::property_tree::ptree aTree;
+ aTree.put("code", "");
+ aTree.put("kind", "freemiumdeny");
+ aTree.put("cmd", aURL.Complete);
+ aTree.put("message", "Blocked Freemium 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 53f95e60e737..364490a479ac 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -178,6 +178,23 @@ void SfxLokHelper::setView(int nId)
}
+SfxViewShell* SfxLokHelper::getViewOfId(int nId)
+{
+ SfxApplication* pApp = SfxApplication::Get();
+ if (pApp == nullptr)
+ return nullptr;
+
+ const ViewShellId nViewShellId(nId);
+ SfxViewShellArr_Impl& rViewArr = pApp->GetViewShells_Impl();
+ for (SfxViewShell* pViewShell : rViewArr)
+ {
+ if (pViewShell->GetViewShellId() == nViewShellId)
+ return pViewShell;
+ }
+
+ return nullptr;
+}
+
int SfxLokHelper::getView(const SfxViewShell* pViewShell)
{
if (!pViewShell)
@@ -717,6 +734,14 @@ void SfxLokHelper::postKeyEventAsync(const VclPtr<vcl::Window> &xWindow,
postEventAsync(pLOKEv);
}
+void SfxLokHelper::setFreemiumView(int nViewId, bool isFreemium)
+{
+ SfxViewShell* pViewShell = SfxLokHelper::getViewOfId(nViewId);
+
+ if(pViewShell)
+ pViewShell->setFreemiumView(isFreemium);
+}
+
void SfxLokHelper::postExtTextEventAsync(const VclPtr<vcl::Window> &xWindow,
int nType, const OUString &rText)
{