diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2021-09-13 23:05:40 +0530 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-10-22 12:49:56 +0200 |
commit | 8de04f459611df936c0b315b6d48cb3dbcc1d5fa (patch) | |
tree | d0ba32ac0b7422b28e9db8525c9ca62de110d62a /desktop | |
parent | 751fa45b1780f275a7b8fdce52a2fd722e87fcb7 (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 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 10 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 21 |
2 files changed, 27 insertions, 4 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index d8ae56644263..19aa24684cb8 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3458,13 +3458,15 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(59), offsetof(struct _LibreOfficeKitDocumentClass, completeFunction)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(60), offsetof(struct _LibreOfficeKitDocumentClass, setWindowTextSelection)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), offsetof(struct _LibreOfficeKitDocumentClass, sendFormFieldEvent)); - CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), offsetof(struct _LibreOfficeKitDocumentClass, renderSearchResult)); - CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), offsetof(struct _LibreOfficeKitDocumentClass, setFreemiumDenyList)); - CPPUNIT_ASSERT_EQUAL(documentClassOffset(64), offsetof(struct _LibreOfficeKitDocumentClass, setFreemiumView)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(62), offsetof(struct _LibreOfficeKitDocumentClass, setFreemiumDenyList)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), offsetof(struct _LibreOfficeKitDocumentClass, setFreemiumView)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(64), offsetof(struct _LibreOfficeKitDocumentClass, setRestrictedCommandList)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), offsetof(struct _LibreOfficeKitDocumentClass, setRestrictedView)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), offsetof(struct _LibreOfficeKitDocumentClass, renderSearchResult)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(65), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(67), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 535cf9808d4d..3720ed54fbbf 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1077,6 +1077,13 @@ static void doc_setFreemiumView(LibreOfficeKitDocument* pThis, int nViewId, bool isFreemium); +static void doc_setRestrictedCommandList(LibreOfficeKitDocument* pThis, + const char* restrictedCommandList); + +static void doc_setRestrictedView(LibreOfficeKitDocument* pThis, + int nViewId, + bool isRestricted); + static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, @@ -1370,6 +1377,9 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->setFreemiumDenyList = doc_setFreemiumDenyList; m_pDocumentClass->setFreemiumView = doc_setFreemiumView; + m_pDocumentClass->setRestrictedCommandList = doc_setRestrictedCommandList; + m_pDocumentClass->setRestrictedView = doc_setRestrictedView; + gDocumentClass = m_pDocumentClass; } pClass = m_pDocumentClass.get(); @@ -3658,6 +3668,17 @@ static void doc_setFreemiumView(LibreOfficeKitDocument* /*pThis*/, int nViewId, SfxLokHelper::setFreemiumView(nViewId, isFreemium); } +static void doc_setRestrictedCommandList(LibreOfficeKitDocument* /*pThis*/, const char* restrictedCommandList) +{ + comphelper::LibreOfficeKit::setRestrictedCommandList(restrictedCommandList); +} + +static void doc_setRestrictedView(LibreOfficeKitDocument* /*pThis*/, int nViewId, bool isRestricted) +{ + SolarMutexGuard aGuard; + SfxLokHelper::setRestrictedView(nViewId, isRestricted); +} + static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, const char* pText) { comphelper::ProfileZone aZone("doc_postWindowExtTextInputEvent"); |