summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2023-01-17 11:02:13 -0400
committerHenry Castro <hcastro@collabora.com>2023-02-03 12:32:50 +0000
commit967c56f7d4c46240a37b2d4dd0a2f577b621f75d (patch)
treeb67b2c15d01fe4ff080cb84ef752c170ac76493d /desktop
parentf74031d4eaeb289f062f77209da10d464c09c2a6 (diff)
lok: fix query language status
The Calc and Impress return language status as a SfxStringItem, but Writer is a SfxListStringItem. Signed-off-by: Henry Castro <hcastro@collabora.com> Change-Id: I88f77288e422a8f80473f0e33257078cfaa704b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145675 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146479 Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r--desktop/source/lib/init.cxx45
1 files changed, 29 insertions, 16 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index d19d2717ffaa..0e9e2c203fff 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -5399,22 +5399,34 @@ static void getDocLanguages(LibreOfficeKitDocument* pThis, uno::Sequence<lang::L
css::uno::Any aLangStatus;
pDispatcher->QueryState(SID_LANGUAGE_STATUS, aLangStatus);
- Sequence<OUString> aSeqLang;
- if (!(aLangStatus >>= aSeqLang))
- return;
+ OUString sCurrent;
+ OUString sKeyboard;
+ OUString sGuessText;
+ SvtScriptType eScriptType = SvtScriptType::LATIN | SvtScriptType::ASIAN
+ | SvtScriptType::COMPLEX;
- // (aSeqLang[0] == "Current Language", aSeqLang[1] == "Script Type",
- // aSeqLang[2] == "Keyboard Language", aSeqLang[3] == "Guess Text Lang")
- if (aSeqLang.getLength() != 4)
- return;
+ 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;
- SvtScriptType eScriptType = static_cast<SvtScriptType>(aSeqLang[1].toInt32());
- if (!aSeqLang[0].isEmpty())
+ if (!sCurrent.isEmpty())
{
- nLangType = SvtLanguageTable::GetLanguageType(aSeqLang[0]);
+ nLangType = SvtLanguageTable::GetLanguageType(sCurrent);
if (nLangType != LANGUAGE_DONTKNOW)
{
aLangItems.insert(nLangType);
@@ -5436,9 +5448,9 @@ static void getDocLanguages(LibreOfficeKitDocument* pThis, uno::Sequence<lang::L
aLangItems.insert(nLangType);
}
- if (!aSeqLang[2].isEmpty())
+ if (!sKeyboard.isEmpty())
{
- nLangType = SvtLanguageTable::GetLanguageType(aSeqLang[2]);
+ nLangType = SvtLanguageTable::GetLanguageType(sKeyboard);
if (nLangType != LANGUAGE_DONTKNOW &&
(eScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType)))
{
@@ -5446,7 +5458,7 @@ static void getDocLanguages(LibreOfficeKitDocument* pThis, uno::Sequence<lang::L
}
}
- if (!aSeqLang[3].isEmpty())
+ if (!sGuessText.isEmpty())
{
Reference<linguistic2::XLanguageGuessing> xLangGuesser;
try
@@ -5459,9 +5471,10 @@ static void getDocLanguages(LibreOfficeKitDocument* pThis, uno::Sequence<lang::L
if (xLangGuesser.is())
{
- lang::Locale aLocale = xLangGuesser->guessPrimaryLanguage(aSeqLang[3], 0,
- aSeqLang[3].getLength());
- nLangType = LanguageTag(aLocale).makeFallback().getLanguageType();
+ lang::Locale aLocale = xLangGuesser->guessPrimaryLanguage(sGuessText, 0,
+ sGuessText.getLength());
+ LanguageTag aLanguageTag(aLocale);
+ nLangType = aLanguageTag.getLanguageType(false);
if (nLangType != LANGUAGE_DONTKNOW &&
(eScriptType & SvtLanguageOptions::GetScriptTypeOfLanguage(nLangType)))
{