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 /comphelper | |
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 'comphelper')
-rw-r--r-- | comphelper/source/misc/lok.cxx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx index d7b34bccafee..957697302e89 100644 --- a/comphelper/source/misc/lok.cxx +++ b/comphelper/source/misc/lok.cxx @@ -41,6 +41,8 @@ static Compat g_eCompatFlags(Compat::none); static std::vector<OUString> g_vFreemiumDenyList; +static std::vector<OUString> g_vRestrictedCommandList; + namespace { @@ -316,6 +318,31 @@ bool isCommandFreemiumDenied(const OUString& command) return std::find(g_vFreemiumDenyList.begin(), g_vFreemiumDenyList.end(), command) != g_vFreemiumDenyList.end(); } +void setRestrictedCommandList(const char* restrictedCommandList) +{ + if(!g_vRestrictedCommandList.empty()) + return; + + OUString RestrictedListString(restrictedCommandList, strlen(restrictedCommandList), RTL_TEXTENCODING_UTF8); + + OUString command = RestrictedListString.getToken(0, ' '); + for (size_t i = 1; !command.isEmpty(); i++) + { + g_vRestrictedCommandList.emplace_back(command); + command = RestrictedListString.getToken(i, ' '); + } +} + +const std::vector<OUString>& getRestrictedCommandList() +{ + return g_vRestrictedCommandList; +} + +bool isRestrictedCommand(const OUString& command) +{ + return std::find(g_vRestrictedCommandList.begin(), g_vRestrictedCommandList.end(), command) != g_vRestrictedCommandList.end(); +} + } // namespace LibreOfficeKit } // namespace comphelper |