diff options
-rw-r--r-- | android/Bootstrap/src/org/libreoffice/kit/Document.java | 2 | ||||
-rw-r--r-- | comphelper/source/misc/lok.cxx | 60 | ||||
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 5 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 17 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 7 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 9 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 9 | ||||
-rw-r--r-- | include/comphelper/lok.hxx | 7 | ||||
-rw-r--r-- | include/sfx2/lokhelper.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/viewsh.hxx | 14 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 1 | ||||
-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 |
14 files changed, 55 insertions, 140 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java index ed7208da5924..7d95268e224f 100644 --- a/android/Bootstrap/src/org/libreoffice/kit/Document.java +++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java @@ -92,7 +92,7 @@ public class Document { public static final int CALLBACK_COMMENT = 32; public static final int CALLBACK_INVALIDATE_HEADER = 33; public static final int CALLBACK_CELL_ADDRESS = 34; - public static final int CALLBACK_SC_FOLLOW_JUMP = 52; + public static final int CALLBACK_SC_FOLLOW_JUMP = 54; /** * Set text selection types diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index 26c798eeaff4..45037f862bd7 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -35,10 +35,6 @@ static bool g_bLocalRendering(false); static Compat g_eCompatFlags(Compat::none); -static std::unordered_set<OUString> g_vFreemiumDenyList; - -static std::unordered_set<OUString> g_vRestrictedCommandList; - namespace { @@ -287,62 +283,6 @@ void statusIndicatorFinish() pStatusIndicatorCallback(pStatusIndicatorCallbackData, statusIndicatorCallbackType::Finish, 0, nullptr); } -void setBlockedCommandList(const char* bolckedCommandList) -{ - - OUString BolckedListString(bolckedCommandList, strlen(bolckedCommandList), RTL_TEXTENCODING_UTF8); - - OUString type = BolckedListString.getToken(0, '-'); - - if (type == "freemium") - { - if(!g_vFreemiumDenyList.empty()) - return; - OUString commands = BolckedListString.getToken(1, '-'); - - OUString command = commands.getToken(0, ' '); - for (size_t i = 1; !command.isEmpty(); i++) - { - g_vFreemiumDenyList.emplace(command); - command = commands.getToken(i, ' '); - } - } - else - { - if(!g_vRestrictedCommandList.empty()) - return; - - OUString commands = BolckedListString.getToken(1, '-'); - - OUString command = commands.getToken(0, ' '); - for (size_t i = 1; !command.isEmpty(); i++) - { - g_vRestrictedCommandList.emplace(command); - command = commands.getToken(i, ' '); - } - } -} - -const std::unordered_set<OUString>& getFreemiumDenyList() -{ - return g_vFreemiumDenyList; -} - -bool isCommandFreemiumDenied(const OUString& command) -{ - return g_vFreemiumDenyList.find(command) != g_vFreemiumDenyList.end(); -} - -const std::unordered_set<OUString>& getRestrictedCommandList() -{ - return g_vRestrictedCommandList; -} - -bool isRestrictedCommand(const OUString& command) -{ - return g_vRestrictedCommandList.find(command) != g_vRestrictedCommandList.end(); -} - } // namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 0fa5dc7ae6fe..cfa8e039a5d0 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3459,12 +3459,11 @@ void DesktopLOKTest::testABI() 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, setBlockedCommandList)); - CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), offsetof(struct _LibreOfficeKitDocumentClass, setBlockedCommandView)); - CPPUNIT_ASSERT_EQUAL(documentClassOffset(64), offsetof(struct _LibreOfficeKitDocumentClass, renderSearchResult)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(63), 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(64), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 62aeabfadd67..4d6a93877e6f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1071,12 +1071,8 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nCharCode, int nKeyCode); static void doc_setBlockedCommandList(LibreOfficeKitDocument* pThis, - const char* bolckedCommandList); - -static void doc_setBlockedCommandView(LibreOfficeKitDocument* pThis, int nViewId, - const char* type, - bool isBlocked); + const char* bolckedCommandList); static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, @@ -1369,7 +1365,6 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->renderSearchResult = doc_renderSearchResult; m_pDocumentClass->setBlockedCommandList = doc_setBlockedCommandList; - m_pDocumentClass->setBlockedCommandView = doc_setBlockedCommandView; gDocumentClass = m_pDocumentClass; } @@ -3648,16 +3643,10 @@ static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nChar } } -static void doc_setBlockedCommandList(LibreOfficeKitDocument* /*pThis*/, const char* bolckedCommandList) -{ - comphelper::LibreOfficeKit::setBlockedCommandList(bolckedCommandList); -} - -static void doc_setBlockedCommandView(LibreOfficeKitDocument* /*pThis*/, int nViewId, const char* type, bool isBlocked) +static void doc_setBlockedCommandList(LibreOfficeKitDocument* /*pThis*/, int nViewId, const char* bolckedCommandList) { SolarMutexGuard aGuard; - OUString aType(type, strlen(type), RTL_TEXTENCODING_UTF8); - SfxLokHelper::setBlockedCommandView(nViewId, aType, isBlocked); + SfxLokHelper::setBlockedCommandList(nViewId, bolckedCommandList); } static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, const char* pText) diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 72beeb613246..29ffeff44bbb 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -460,14 +460,9 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::setBlockedCommandList void (*setBlockedCommandList) (LibreOfficeKitDocument* pThis, + int nViewId, const char* bolckedCommandList); - /// @see lok::Document::setBlockedCommandView - void (*setBlockedCommandView) (LibreOfficeKitDocument* pThis, - int nViewId, - const char* type, - bool isBlocked); - /// @see lok::Document::renderSearchResult bool (*renderSearchResult) (LibreOfficeKitDocument* pThis, const char* pSearchResult, diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 114438445350..bde89ec4240c 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -787,14 +787,9 @@ public: mpDoc->pClass->sendFormFieldEvent(mpDoc, pArguments); } - void setBlockedCommandList(const char* bolckedCommandList) + void setBlockedCommandList(int nViewId, const char* bolckedCommandList) { - mpDoc->pClass->setBlockedCommandList(mpDoc, bolckedCommandList); - } - - void setBlockedCommandView(int nViewId, const char* type, bool isBlocked) - { - mpDoc->pClass->setBlockedCommandView(mpDoc, nViewId, type, isBlocked); + mpDoc->pClass->setBlockedCommandList(mpDoc, nViewId, bolckedCommandList); } /** * Render input search result to a bitmap buffer. diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 497a5eacc804..006713447aed 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -780,6 +780,11 @@ typedef enum LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR = 52, /** + * When a user tries to use command which is restricted for that user + */ + LOK_COMMAND_BLOCKED = 53, + + /** * The position of the cell cursor jumped to. * * Payload format: "x, y, width, height, column, row", where the first @@ -789,7 +794,7 @@ typedef enum * * Rectangle format is the same as LOK_CALLBACK_INVALIDATE_TILES. */ - LOK_CALLBACK_SC_FOLLOW_JUMP = 53, + LOK_CALLBACK_SC_FOLLOW_JUMP = 54, } LibreOfficeKitCallbackType; @@ -924,6 +929,8 @@ static inline const char* lokCallbackTypeToString(int nType) return "LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY"; case LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR: return "LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR"; + case LOK_COMMAND_BLOCKED: + return "LOK_COMMAND_BLOCKED"; case LOK_CALLBACK_SC_FOLLOW_JUMP: return "LOK_CALLBACK_SC_FOLLOW_JUMP"; } diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx index 1ea5b23f017d..54d461dc8cbc 100644 --- a/include/comphelper/lok.hxx +++ b/include/comphelper/lok.hxx @@ -12,8 +12,6 @@ #include <comphelper/comphelperdllapi.h> #include <rtl/ustring.hxx> -#include <vector> -#include <unordered_set> class LanguageTag; @@ -112,11 +110,6 @@ COMPHELPER_DLLPUBLIC void statusIndicatorSetValue(int percent); COMPHELPER_DLLPUBLIC void statusIndicatorFinish(); COMPHELPER_DLLPUBLIC void setBlockedCommandList(const char* bolckedCommandList); -COMPHELPER_DLLPUBLIC const std::unordered_set<OUString>& getFreemiumDenyList(); -COMPHELPER_DLLPUBLIC bool isCommandFreemiumDenied(const OUString& command); - -COMPHELPER_DLLPUBLIC const std::unordered_set<OUString>& getRestrictedCommandList(); -COMPHELPER_DLLPUBLIC bool isRestrictedCommand(const OUString& command); } #endif // INCLUDED_COMPHELPER_LOK_HXX diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx index f37d70f30abf..9de82ce9049c 100644 --- a/include/sfx2/lokhelper.hxx +++ b/include/sfx2/lokhelper.hxx @@ -64,7 +64,7 @@ public: /// Get viewIds of views of the current DocId. static bool getViewIds(int nDocId, int* pArray, size_t nSize); /// Set View Blocked for some uno commands - static void setBlockedCommandView(int nViewId, const OUString& type, bool isBlocked); + static void setBlockedCommandList(int nViewId, const char* bolckedCommandList); /// Get the document id for a view static int getDocumentIdOfView(int nViewId); /// Get the default language that should be used for views diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx index 29cf9b756ad7..4dd1783fabe9 100644 --- a/include/sfx2/viewsh.hxx +++ b/include/sfx2/viewsh.hxx @@ -34,6 +34,7 @@ #include <LibreOfficeKit/LibreOfficeKitTypes.h> #include <editeng/outliner.hxx> #include <functional> +#include <unordered_set> class SfxTabPage; class SfxBaseController; @@ -166,8 +167,7 @@ friend class SfxPrinterController; LanguageTag maLOKLanguageTag; LanguageTag maLOKLocale; LOKDeviceFormFactor maLOKDeviceFormFactor; - bool mbLOKIsFreemiumView; - bool mbLOKIsRestrictedView; + std::unordered_set<OUString> mvLOKBlockedCommandList; /// Used to set the DocId at construction time. See SetCurrentDocId. static ViewShellDocId mnCurrentDocId; @@ -394,13 +394,9 @@ public: virtual tools::Rectangle getLOKVisibleArea() const { return tools::Rectangle(); } - // Freemium view settings - void setFreemiumView(bool isFreemium) { mbLOKIsFreemiumView = isFreemium; } - bool isFreemiumView() const { return mbLOKIsFreemiumView; } - - // Restricted view setting - void setRestrictedView(bool isRestricted) { mbLOKIsRestrictedView = isRestricted; } - bool isRestrictedView() { return mbLOKIsRestrictedView; } + // Blocked Command view settings + void setBlockedCommandList(const char* bolckedCommandList); + bool isBlockedCommand(OUString command); }; diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 330361209ba0..b0fffd490219 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -1415,6 +1415,7 @@ callback (gpointer pData) case LOK_CALLBACK_FORM_FIELD_BUTTON: case LOK_CALLBACK_INVALIDATE_SHEET_GEOMETRY: case LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR: + case LOK_COMMAND_BLOCKED: case LOK_CALLBACK_SC_FOLLOW_JUMP: { // TODO: Implement me 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: */ |