lingucomponent/source/spellcheck/macosxspell/macspellimp.mm | 22 +++++++----- 1 file changed, 14 insertions(+), 8 deletions(-)
New commits: commit af8f93e0a538c0e69aa7255d7653baa6bea9e393 Author: Tor Lillqvist <[email protected]> Date: Thu May 17 12:35:34 2018 +0300 tdf#112442: Use list of available dictionaries, not available locales Also, turn some specific overly generic languages that LO doesn't recognise in this context into the country-specific ones that the dictionary (probably) is for. Skip some odd locales LO doesn't know in this context. In particular, what the system calls the "en" dictionary is for "en_US", and "nb" is for "nb_NO". The "es" one probably is for "es_ES". Also, skip some language-country combinations that LO doesn't recognise in this context. In particular, "en_JP" and "en_SG". In addition to the above, this change also reduces the delay after typing the first character into Writer with about half a second (on my machine). There is still a very noticeable delay left, though. (Reasons for this delay are very likely the cross-platform LightProof (Python) initialisation slowness, and on macOS the macxp_resolveAlias() crack in sal.) Change-Id: I29450775a263bdc03fd43849380f66e6ffffd09b Reviewed-on: https://gerrit.libreoffice.org/54476 Tested-by: Jenkins <[email protected]> Reviewed-by: Tor Lillqvist <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/56079 Reviewed-by: Andras Timar <[email protected]> Tested-by: Andras Timar <[email protected]> diff --git a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm index 217e030204fe..8c491892fb13 100644 --- a/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm +++ b/lingucomponent/source/spellcheck/macosxspell/macspellimp.mm @@ -110,16 +110,12 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales() // TODO How on Mac OS X? // invoke a second dictionary manager to get the shared dictionary list - NSArray *aLocales = [NSLocale availableLocaleIdentifiers]; + NSArray *aSpellCheckLanguages = [[NSSpellChecker sharedSpellChecker] availableLanguages]; - //Test for existence of the dictionaries - for (NSUInteger i = 0; i < [aLocales count]; i++) + for (NSUInteger i = 0; i < [aSpellCheckLanguages count]; i++) { - NSString* pLangStr = (NSString*)[aLocales objectAtIndex:i]; - if( [[NSSpellChecker sharedSpellChecker] setLanguage:pLangStr ] ) - { - postspdict.push_back( pLangStr ); - } + NSString* pLangStr = static_cast<NSString*>([aSpellCheckLanguages objectAtIndex:i]); + postspdict.push_back( pLangStr ); } numshr = postspdict.size(); @@ -151,6 +147,16 @@ Sequence< Locale > SAL_CALL MacSpellChecker::getLocales() NSString* aCountry = [ aLocDict objectForKey:NSLocaleCountryCode ]; OUString lang([aLang cStringUsingEncoding: NSUTF8StringEncoding], [aLang length], aEnc); OUString country([ aCountry cStringUsingEncoding: NSUTF8StringEncoding], [aCountry length], aEnc); + // Fix some overly generic or odd locales LO doesn't know + if (lang == "en" && country.isEmpty()) + country = "US"; // I guess that is what it means + else if (lang == "nb" && country.isEmpty()) + country = "NO"; + else if (lang == "es" && country.isEmpty()) + country = "ES"; // Probably better than claiming it to be for all es-* ? + else if ((lang == "en" && country == "JP") + || (lang == "en" && country == "SG")) + continue; // Just skip, LO doesn't have those yet in this context Locale nLoc( lang, country, OUString() ); newloc = 1; //eliminate duplicates (is this needed for MacOS?) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
