diff options
-rw-r--r-- | cui/inc/strings.hrc | 2 | ||||
-rw-r--r-- | cui/source/options/optlanguagetool.cxx | 25 | ||||
-rw-r--r-- | cui/source/options/optlanguagetool.hxx | 3 |
3 files changed, 28 insertions, 2 deletions
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc index cea0b183e33a..b4b232b9ac5d 100644 --- a/cui/inc/strings.hrc +++ b/cui/inc/strings.hrc @@ -403,4 +403,6 @@ #define RID_CUISTR_ZIPFAIL NC_("RID_CUISTR_ZIPFAIL", "Creation of ZIP file failed.") #define RID_CUISTR_SAVED NC_("RID_CUISTR_SAVED", "The results have been successfully saved in the file 'GraphicTestResults.zip'!") +#define RID_LANGUAGETOOL_LEAVE_EMPTY NC_("RID_LANGUAGETOOL_LEAVE_EMPTY", "Leave this field empty to use the free version") + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optlanguagetool.cxx b/cui/source/options/optlanguagetool.cxx index 38807bc337d3..309ff2a09b52 100644 --- a/cui/source/options/optlanguagetool.cxx +++ b/cui/source/options/optlanguagetool.cxx @@ -20,6 +20,8 @@ #include "optlanguagetool.hxx" #include <svtools/languagetoolcfg.hxx> #include <sal/log.hxx> +#include <dialmgr.hxx> +#include <strings.hrc> OptLanguageToolTabPage::OptLanguageToolTabPage(weld::Container* pPage, weld::DialogController* pController, @@ -34,6 +36,11 @@ OptLanguageToolTabPage::OptLanguageToolTabPage(weld::Container* pPage, m_xActivateBox->connect_toggled(LINK(this, OptLanguageToolTabPage, CheckHdl)); SvxLanguageToolOptions& rLanguageOpts = SvxLanguageToolOptions::Get(); EnableControls(rLanguageOpts.getEnabled()); + + // tdf#150494 Set default values as placeholder text + m_xBaseURLED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY)); + m_xUsernameED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY)); + m_xApiKeyED->set_placeholder_text(CuiResId(RID_LANGUAGETOOL_LEAVE_EMPTY)); } OptLanguageToolTabPage::~OptLanguageToolTabPage() {} @@ -54,7 +61,14 @@ IMPL_LINK_NOARG(OptLanguageToolTabPage, CheckHdl, weld::Toggleable&, void) void OptLanguageToolTabPage::Reset(const SfxItemSet*) { SvxLanguageToolOptions& rLanguageOpts = SvxLanguageToolOptions::Get(); - m_xBaseURLED->set_text(rLanguageOpts.getBaseURL()); + + // tdf#150494 If no URL has been set, use the default URL + OUString aBaseURL = rLanguageOpts.getBaseURL(); + if (aBaseURL.isEmpty()) + m_xBaseURLED->set_text(LANGUAGETOOL_DEFAULT_URL); + else + m_xBaseURLED->set_text(rLanguageOpts.getBaseURL()); + m_xUsernameED->set_text(rLanguageOpts.getUsername()); m_xApiKeyED->set_text(rLanguageOpts.getApiKey()); } @@ -62,7 +76,14 @@ void OptLanguageToolTabPage::Reset(const SfxItemSet*) bool OptLanguageToolTabPage::FillItemSet(SfxItemSet*) { SvxLanguageToolOptions& rLanguageOpts = SvxLanguageToolOptions::Get(); - rLanguageOpts.setBaseURL(m_xBaseURLED->get_text()); + + // tdf#150494 If no URL has been set, then save the default URL + OUString aBaseURL = m_xBaseURLED->get_text(); + if (aBaseURL.isEmpty()) + rLanguageOpts.setBaseURL(LANGUAGETOOL_DEFAULT_URL); + else + rLanguageOpts.setBaseURL(aBaseURL); + rLanguageOpts.setUsername(m_xUsernameED->get_text()); rLanguageOpts.setApiKey(m_xApiKeyED->get_text()); return false; diff --git a/cui/source/options/optlanguagetool.hxx b/cui/source/options/optlanguagetool.hxx index 46a60ecbe103..8ee83ed4e367 100644 --- a/cui/source/options/optlanguagetool.hxx +++ b/cui/source/options/optlanguagetool.hxx @@ -18,6 +18,9 @@ */ #pragma once #include <sfx2/tabdlg.hxx> +#include <rtl/ustring.hxx> + +inline constexpr OUStringLiteral LANGUAGETOOL_DEFAULT_URL = u"https://api.languagetool.org/v2"; class OptLanguageToolTabPage : public SfxTabPage { |