diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2022-01-07 15:50:16 +0530 |
---|---|---|
committer | Pranam Lashkari <lpranam@collabora.com> | 2022-01-10 12:58:49 +0100 |
commit | 0a0cc4b5547f2de729474e5119d18c9837eadca2 (patch) | |
tree | ca437ddc5fd16bd098b6b2f59365711361aa5953 /desktop | |
parent | faed3047e9fa7e8ed6d33f1801e661a4e56d46c1 (diff) |
LOK: introduce way to restrict uno commands
With this new API we can define which uno commands to restrict their functionality
Change-Id: I9f3fd659d373e56542c5323922a53564f1cfb27b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128105
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 4 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 21 |
2 files changed, 24 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 9d454752239c..66ff39edd7b3 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3309,10 +3309,12 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(61), offsetof(struct _LibreOfficeKitDocumentClass, sendFormFieldEvent)); 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)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(64), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(66), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 5e82c3d379ff..30ee6bb0f607 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1088,6 +1088,13 @@ static void doc_setFreemiumDenyList(const char* freemiumDenyList); static void doc_setFreemiumView(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, @@ -1374,6 +1381,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(); @@ -3684,6 +3694,17 @@ static void doc_setFreemiumView(int nViewId, bool isFreemium) 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"); |