From f7002026d91bde71c4baceb3ff0bd318a45bf72d Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 5 Sep 2013 11:39:59 +0200 Subject: use get*LocaleServiceName Change-Id: Ieb286027644446c1109ab4fc637445c3582e316e --- i18npool/source/localedata/localedata.cxx | 50 ++++++++----------------------- 1 file changed, 12 insertions(+), 38 deletions(-) (limited to 'i18npool') diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx index 2b5ed9e93a0e..f453052b5219 100644 --- a/i18npool/source/localedata/localedata.cxx +++ b/i18npool/source/localedata/localedata.cxx @@ -453,12 +453,8 @@ oslGenericFunction SAL_CALL lcl_LookupTableHelper::getFunctionSymbolByName( Locale aFbLocale = MsLangId::getFallbackLocale( aLocale); if (aFbLocale == aLocale) bFallback = false; // may be a "language-only-locale" like Interlingua (ia) - else if (!aFbLocale.Country.isEmpty()) { - OUStringBuffer aBuf(5); - aFallback = aBuf.append(aFbLocale.Language).append( under).append(aFbLocale.Country).makeStringAndClear(); - } else - aFallback = aFbLocale.Language; + aFallback = LocaleData::getFirstLocaleServiceName( aFbLocale); } for ( sal_Int16 i = 0; i < nbOfLocales; i++) @@ -1474,44 +1470,22 @@ oslGenericFunction SAL_CALL LocaleData::getFunctionSymbol( const Locale& rLocale } oslGenericFunction pSymbol = 0; - - sal_Int32 l = rLocale.Language.getLength(); - sal_Int32 c = rLocale.Country.getLength(); - sal_Int32 v = rLocale.Variant.getLength(); - aBuf.ensureCapacity(l+c+v+3); - LocaleDataLookupTableItem *pCachedItem = 0; - if (l > 0 && c > 0 && v > 0) - { - // load function with name ___ - pSymbol = rLookupTable.getFunctionSymbolByName( - aBuf.append(rLocale.Language).append(under).append(rLocale.Country).append(under).append(rLocale.Variant).makeStringAndClear(), - pFunction, &pCachedItem); - } - - if (!pSymbol && l > 0 && c > 0) - { - // load function with name __ - pSymbol = rLookupTable.getFunctionSymbolByName( - aBuf.append(rLocale.Language).append(under).append(rLocale.Country).makeStringAndClear(), - pFunction, &pCachedItem); - } - - if (!pSymbol && l > 0 && c > 0 && rLocale.Language == "zh" && (rLocale.Country == "HK" || rLocale.Country == "MO")) - { - // if the country code is HK or MO, one more step to try TW. - pSymbol = rLookupTable.getFunctionSymbolByName( - aBuf.append(rLocale.Language).append(under).append("TW").makeStringAndClear(), - pFunction, &pCachedItem); - } - + // Load function with name __ or _ and + // fallbacks. + pSymbol = rLookupTable.getFunctionSymbolByName( LocaleData::getFirstLocaleServiceName( rLocale), + pFunction, &pCachedItem); if (!pSymbol) { - // load function with name _ - pSymbol = rLookupTable.getFunctionSymbolByName(rLocale.Language, pFunction, &pCachedItem); + ::std::vector< OUString > aFallbacks( LocaleData::getFallbackLocaleServiceNames( rLocale)); + for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it) + { + pSymbol = rLookupTable.getFunctionSymbolByName( *it, pFunction, &pCachedItem); + if (pSymbol) + break; + } } - if (!pSymbol) { // load default function with name _en_US -- cgit