desktop/source/lib/init.cxx | 142 -------------------------------------------- 1 file changed, 2 insertions(+), 140 deletions(-)
New commits: commit 9a5329a266bd74abc4794f1fcbae3db07582dbde Author: Szymon Kłos <szymon.k...@collabora.com> AuthorDate: Fri Feb 10 14:56:06 2023 +0100 Commit: Szymon Kłos <szymon.k...@collabora.com> CommitDate: Mon Jul 10 11:36:30 2023 +0200 lok: remove old hack for LanguageTool locales Change-Id: I1098c51f03b4cdd4f21a635f7b6aae8e90fd9f9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146779 Reviewed-by: Henry Castro <hcas...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153962 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154162 Tested-by: Jenkins Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 539291218213..4f1b5287130f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -5620,132 +5620,6 @@ static void doc_setGraphicSelection(LibreOfficeKitDocument* pThis, int nType, in pDoc->setGraphicSelection(nType, nX, nY); } -static void getDocLanguages(LibreOfficeKitDocument* pThis, uno::Sequence<lang::Locale>& rSeq) -{ - SfxViewFrame* pViewFrame = SfxViewFrame::Current(); - if (!pViewFrame) - return; - - SfxDispatcher* pDispatcher = pViewFrame->GetBindings().GetDispatcher(); - if (!pDispatcher) - return; - - css::uno::Any aLangStatus; - pDispatcher->QueryState(SID_LANGUAGE_STATUS, aLangStatus); - - OUString sCurrent; - OUString sKeyboard; - OUString sGuessText; - SvtScriptType eScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN - | SvtScriptType::COMPLEX; - - Sequence<OUString> aSeqLang; - if (aLangStatus >>= aSeqLang) - { - if (aSeqLang.getLength() == 4) - { - sCurrent = aSeqLang[0]; - eScriptType = static_cast<SvtScriptType>(aSeqLang[1].toInt32()); - sKeyboard = aSeqLang[1]; - sGuessText = aSeqLang[2]; - } - } - else - { - aLangStatus >>= sCurrent; - } - - LanguageType nLangType; - std::set<LanguageType> aLangItems; - - if (!sCurrent.isEmpty()) - { - nLangType = SvtLanguageTable::GetLanguageType(sCurrent); - if (nLangType != LANGUAGE_DONTKNOW) - { - aLangItems.insert(nLangType); - } - } - - const AllSettings& rAllSettings = Application::GetSettings(); - nLangType = rAllSettings.GetLanguageTag().getLanguageType(); - if (nLangType != LANGUAGE_DONTKNOW && - (eScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType))) - { - aLangItems.insert(nLangType); - } - - nLangType = rAllSettings.GetUILanguageTag().getLanguageType(); - if (nLangType != LANGUAGE_DONTKNOW && - (eScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType))) - { - aLangItems.insert(nLangType); - } - - if (!sKeyboard.isEmpty()) - { - nLangType = SvtLanguageTable::GetLanguageType(sKeyboard); - if (nLangType != LANGUAGE_DONTKNOW && - (eScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType))) - { - aLangItems.insert(nLangType); - } - } - - if (!sGuessText.isEmpty()) - { - Reference<linguistic2::XLanguageGuessing> xLangGuesser; - try - { - xLangGuesser = linguistic2::LanguageGuessing::create(xContext); - } - catch(...) - { - } - - if (xLangGuesser.is()) - { - lang::Locale aLocale = xLangGuesser->guessPrimaryLanguage(sGuessText, 0, - sGuessText.getLength()); - LanguageTag aLanguageTag(aLocale); - nLangType = aLanguageTag.getLanguageType(false); - if (nLangType != LANGUAGE_DONTKNOW && - (eScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType))) - { - aLangItems.insert(nLangType); - } - } - } - - LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); - Reference<document::XDocumentLanguages> xDocumentLanguages(pDocument->mxComponent, UNO_QUERY); - if (xDocumentLanguages.is()) - { - const Sequence<lang::Locale> aLocales(xDocumentLanguages->getDocumentLanguages( - static_cast<sal_Int16>(eScriptType), 64)); - - for (const lang::Locale& aLocale : aLocales) - { - nLangType = SvtLanguageTable::GetLanguageType(aLocale.Language); - if (nLangType != LANGUAGE_DONTKNOW && - (eScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType))) - { - aLangItems.insert(nLangType); - } - } - } - - int nLocale = 0; - Sequence<lang::Locale> aLocales(aLangItems.size()); - auto pLocales = aLocales.getArray(); - for (const LanguageType& itLang : aLangItems) - { - pLocales[nLocale++] = LanguageTag::convertToLocale(itLang); - } - - rSeq = aLocales; -} - static void doc_resetSelection(LibreOfficeKitDocument* pThis) { comphelper::ProfileZone aZone("doc_resetSelection"); @@ -5777,7 +5651,7 @@ static void addLocale(boost::property_tree::ptree& rValues, css::lang::Locale co rValues.push_back(std::make_pair("", aChild)); } -static char* getLanguages(LibreOfficeKitDocument* pThis, const char* pCommand) +static char* getLanguages(const char* pCommand) { css::uno::Sequence< css::lang::Locale > aLocales; css::uno::Sequence< css::lang::Locale > aGrammarLocales; @@ -5802,18 +5676,6 @@ static char* getLanguages(LibreOfficeKitDocument* pThis, const char* pCommand) uno::Reference< linguistic2::XSupportedLocales > xSuppLoc( xGC, uno::UNO_QUERY_THROW ); aGrammarLocales = xSuppLoc->getLocales(); } - - // Fallback - - /* FIXME: To obtain the document languages the spell checker can be disabled, - so a future re-work of the getLanguages function is needed in favor to use - getDocLanguages */ - if (!aLocales.hasElements()) - { - uno::Sequence< css::lang::Locale > aSeq; - getDocLanguages(pThis, aSeq); - aLocales = aSeq; - } } boost::property_tree::ptree aTree; @@ -6161,7 +6023,7 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo if (!strcmp(pCommand, ".uno:LanguageStatus")) { - return getLanguages(pThis, pCommand); + return getLanguages(pCommand); } else if (!strcmp(pCommand, ".uno:CharFontName")) {