desktop/source/lib/init.cxx | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
New commits: commit 2b8d12bae6b1cf83e6f2e65f6d90afe8fc5a3c58 Author: Mert Tumer <mert.tu...@collabora.com> AuthorDate: Fri Jun 10 13:09:51 2022 +0300 Commit: Mert Tumer <mert.tu...@collabora.com> CommitDate: Tue Jun 14 16:13:34 2022 +0200 lok: set LanguageTool config parameters from environment Signed-off-by: Mert Tumer <mert.tu...@collabora.com> Change-Id: Ic7343439536abee626c269d2a824bb36f9abc40f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135583 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 63ad2bbad39c..ac644c8b02ba 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -127,6 +127,7 @@ #include <tools/json_writer.hxx> #include <svtools/ctrltool.hxx> #include <svtools/langtab.hxx> +#include <svtools/languagetoolcfg.hxx> #include <vcl/fontcharmap.hxx> #include <vcl/graphicfilter.hxx> #ifdef IOS @@ -6561,6 +6562,38 @@ void setCertificateDir() } } +void setLanguageToolConfig() +{ + const char* pEnabled = ::getenv("LANGUAGETOOL_ENABLED"); + const char* pBaseUrlString = ::getenv("LANGUAGETOOL_BASEURL"); + const char* pUsername = ::getenv("LANGUAGETOOL_USERNAME"); + const char* pApikey = ::getenv("LANGUAGETOOL_APIKEY"); + if (pEnabled && pBaseUrlString) + { + OUString aEnabled = OStringToOUString(pEnabled, RTL_TEXTENCODING_UTF8); + if (aEnabled != "true") + return; + OUString aBaseUrl = OStringToOUString(pBaseUrlString, RTL_TEXTENCODING_UTF8); + try + { + SvxLanguageToolOptions& rLanguageOpts = SvxLanguageToolOptions::Get(); + rLanguageOpts.setBaseURL(aBaseUrl); + rLanguageOpts.setEnabled(true); + if (pUsername && pApikey) + { + OUString aUsername = OStringToOUString(pUsername, RTL_TEXTENCODING_UTF8); + OUString aApiKey = OStringToOUString(pApikey, RTL_TEXTENCODING_UTF8); + rLanguageOpts.setUsername(aUsername); + rLanguageOpts.setApiKey(aApiKey); + } + } + catch(uno::Exception const& rException) + { + SAL_WARN("lok", "Failed to set LanguageTool API settings: " << rException.Message); + } + } +} + } static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char* pUserProfileUrl) @@ -6875,6 +6908,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char #endif setCertificateDir(); + setLanguageToolConfig(); if (bNotebookbar) {