diff options
Diffstat (limited to 'lingucomponent/source/lingutil/lingutil.cxx')
-rw-r--r-- | lingucomponent/source/lingutil/lingutil.cxx | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/lingucomponent/source/lingutil/lingutil.cxx b/lingucomponent/source/lingutil/lingutil.cxx index a05145e4e26b..1c9f449ce499 100644 --- a/lingucomponent/source/lingutil/lingutil.cxx +++ b/lingucomponent/source/lingutil/lingutil.cxx @@ -67,64 +67,64 @@ static void GetOldStyleDicsInDir( std::vector< SvtLinguConfigDictionaryEntry >& aRes ) { osl::Directory aSystemDicts(aSystemDir); - if (aSystemDicts.open() == osl::FileBase::E_None) + if (aSystemDicts.open() != osl::FileBase::E_None) + return; + + osl::DirectoryItem aItem; + osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL); + while (aSystemDicts.getNextItem(aItem) == osl::FileBase::E_None) { - osl::DirectoryItem aItem; - osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL); - while (aSystemDicts.getNextItem(aItem) == osl::FileBase::E_None) + aItem.getFileStatus(aFileStatus); + OUString sPath = aFileStatus.getFileURL(); + if (sPath.endsWith(aSystemSuffix)) { - aItem.getFileStatus(aFileStatus); - OUString sPath = aFileStatus.getFileURL(); - if (sPath.endsWith(aSystemSuffix)) + sal_Int32 nStartIndex = sPath.lastIndexOf('/') + 1; + if (!sPath.match(aSystemPrefix, nStartIndex)) + continue; + OUString sChunk = sPath.copy(nStartIndex + aSystemPrefix.getLength(), + sPath.getLength() - aSystemSuffix.getLength() - + nStartIndex - aSystemPrefix.getLength()); + if (sChunk.isEmpty()) + continue; + + // We prefer (now) to use language tags. + // Avoid feeding in the older LANG_REGION scheme to the BCP47 + // ctor as that triggers use of liblangtag and initializes its + // database which we do not want during startup. Convert + // instead. + sChunk = sChunk.replace( '_', '-'); + + // There's a known exception to the rule, the dreaded + // hu_HU_u8.dic of the myspell-hu package, see + // http://packages.debian.org/search?arch=any&searchon=contents&keywords=hu_HU_u8.dic + // This was ignored because unknown in the old implementation, + // truncate to the known locale and either insert because hu_HU + // wasn't encountered yet, or skip because it was. It doesn't + // really matter because the proper new-style hu_HU dictionary + // will take precedence anyway if installed with a Hungarian + // languagepack. Again, this is only to not pull in all + // liblangtag and stuff during startup, the result would be + // !isValidBcp47() and the dictionary ignored. + if (sChunk == "hu-HU-u8") + sChunk = "hu-HU"; + + LanguageTag aLangTag(sChunk, true); + if (!aLangTag.isValidBcp47()) + continue; + + // Thus we first get the language of the dictionary + const OUString& aLocaleName(aLangTag.getBcp47()); + + if (aDicLangInUse.insert(aLocaleName).second) { - sal_Int32 nStartIndex = sPath.lastIndexOf('/') + 1; - if (!sPath.match(aSystemPrefix, nStartIndex)) - continue; - OUString sChunk = sPath.copy(nStartIndex + aSystemPrefix.getLength(), - sPath.getLength() - aSystemSuffix.getLength() - - nStartIndex - aSystemPrefix.getLength()); - if (sChunk.isEmpty()) - continue; - - // We prefer (now) to use language tags. - // Avoid feeding in the older LANG_REGION scheme to the BCP47 - // ctor as that triggers use of liblangtag and initializes its - // database which we do not want during startup. Convert - // instead. - sChunk = sChunk.replace( '_', '-'); - - // There's a known exception to the rule, the dreaded - // hu_HU_u8.dic of the myspell-hu package, see - // http://packages.debian.org/search?arch=any&searchon=contents&keywords=hu_HU_u8.dic - // This was ignored because unknown in the old implementation, - // truncate to the known locale and either insert because hu_HU - // wasn't encountered yet, or skip because it was. It doesn't - // really matter because the proper new-style hu_HU dictionary - // will take precedence anyway if installed with a Hungarian - // languagepack. Again, this is only to not pull in all - // liblangtag and stuff during startup, the result would be - // !isValidBcp47() and the dictionary ignored. - if (sChunk == "hu-HU-u8") - sChunk = "hu-HU"; - - LanguageTag aLangTag(sChunk, true); - if (!aLangTag.isValidBcp47()) - continue; - - // Thus we first get the language of the dictionary - const OUString& aLocaleName(aLangTag.getBcp47()); - - if (aDicLangInUse.insert(aLocaleName).second) - { - // add the dictionary to the resulting vector - SvtLinguConfigDictionaryEntry aDicEntry; - aDicEntry.aLocations.realloc(1); - aDicEntry.aLocaleNames.realloc(1); - aDicEntry.aLocations[0] = sPath; - aDicEntry.aFormatName = aFormatName; - aDicEntry.aLocaleNames[0] = aLocaleName; - aRes.push_back( aDicEntry ); - } + // add the dictionary to the resulting vector + SvtLinguConfigDictionaryEntry aDicEntry; + aDicEntry.aLocations.realloc(1); + aDicEntry.aLocaleNames.realloc(1); + aDicEntry.aLocations[0] = sPath; + aDicEntry.aFormatName = aFormatName; + aDicEntry.aLocaleNames[0] = aLocaleName; + aRes.push_back( aDicEntry ); } } } |