desktop/source/lib/init.cxx | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
New commits: commit 08ab67125bf1b88c3d4aea81c90d87da5bc30feb Author: Mert Tumer <mert.tu...@collabora.com> AuthorDate: Fri Jun 10 13:09:51 2022 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Sat Jan 28 09:22:22 2023 +0000 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> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145603 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index fdb420dfb13d..e562099082d3 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -131,6 +131,7 @@ #include <svtools/ctrltool.hxx> #include <svtools/langtab.hxx> #include <svtools/deeplcfg.hxx> +#include <svtools/languagetoolcfg.hxx> #include <vcl/fontcharmap.hxx> #ifdef IOS #include <vcl/sysdata.hxx> @@ -7016,7 +7017,36 @@ void setDeeplConfig() } } - +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) @@ -7332,6 +7362,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char setCertificateDir(); setDeeplConfig(); + setLanguageToolConfig(); if (bNotebookbar) {