summaryrefslogtreecommitdiffstats
path: root/i18npool/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-02-22 17:18:25 -0500
committerKohei Yoshida <kyoshida@novell.com>2011-02-22 17:18:25 -0500
commit680debe50b6c3e62ca82be368e09fa8cf423a373 (patch)
tree4be7177add9e865f9a9f49401d30cda755a451ec /i18npool/source
parentFixed indentation and bracket style. (diff)
downloadcore-680debe50b6c3e62ca82be368e09fa8cf423a373.tar.gz
core-680debe50b6c3e62ca82be368e09fa8cf423a373.zip
Break up giant if statement into smaller ones.
Diffstat (limited to 'i18npool/source')
-rw-r--r--i18npool/source/localedata/localedata.cxx76
1 files changed, 51 insertions, 25 deletions
diff --git a/i18npool/source/localedata/localedata.cxx b/i18npool/source/localedata/localedata.cxx
index ca975bb2275e..bb8c988aff12 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -1293,33 +1293,59 @@ oslGenericFunction SAL_CALL LocaleData::getFunctionSymbol( const Locale& rLocale
LocaleDataLookupTableItem *pCachedItem = 0;
- if ((l > 0 && c > 0 && v > 0 &&
- // load function with name <func>_<lang>_<country>_<varian>
- (pSymbol = rLookupTable.getFunctionSymbolByName(aBuf.append(rLocale.Language).append(under).append(
- rLocale.Country).append(under).append(rLocale.Variant).makeStringAndClear(), pFunction, &pCachedItem)) != 0) ||
- (l > 0 && c > 0 &&
- // load function with name <ase>_<lang>_<country>
- (pSymbol = rLookupTable.getFunctionSymbolByName(aBuf.append(rLocale.Language).append(under).append(
- rLocale.Country).makeStringAndClear(), pFunction, &pCachedItem)) != 0) ||
- (l > 0 && c > 0 && rLocale.Language.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("zh")) &&
- (rLocale.Country.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("HK")) ||
- rLocale.Country.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("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)) != 0) ||
- (l > 0 &&
- // load function with name <func>_<lang>
- (pSymbol = rLookupTable.getFunctionSymbolByName(rLocale.Language, pFunction, &pCachedItem)) != 0) ||
- // load default function with name <func>_en_US
- (pSymbol = rLookupTable.getFunctionSymbolByName(en_US, pFunction, &pCachedItem)) != 0)
+ if (l <= 0)
+ // At minimum we need the lang name.
+ throw RuntimeException();
+
+ if (c > 0 && v > 0)
+ {
+ // load function with name <func>_<lang>_<country>_<variant>
+ pSymbol = rLookupTable.getFunctionSymbolByName(
+ aBuf.append(rLocale.Language).append(under).append(rLocale.Country).append(under).append(rLocale.Variant).makeStringAndClear(),
+ pFunction, &pCachedItem);
+ }
+
+ if (!pSymbol && c > 0)
+ {
+ // load function with name <ase>_<lang>_<country>
+ pSymbol = rLookupTable.getFunctionSymbolByName(
+ aBuf.append(rLocale.Language).append(under).append(rLocale.Country).makeStringAndClear(),
+ pFunction, &pCachedItem);
+ }
+
+ if (!pSymbol && c > 0 &&
+ rLocale.Language.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("zh")) &&
+ (rLocale.Country.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("HK")) ||
+ rLocale.Country.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("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);
+ }
+
+ if (!pSymbol)
+ {
+ // load function with name <func>_<lang>
+ pSymbol = rLookupTable.getFunctionSymbolByName(rLocale.Language, pFunction, &pCachedItem);
+ }
+
+ if (!pSymbol)
{
- if( pCachedItem )
- cachedItem.reset( pCachedItem );
- if( cachedItem.get())
- cachedItem->aLocale = rLocale;
- return pSymbol;
+ // load default function with name <func>_en_US
+ pSymbol = rLookupTable.getFunctionSymbolByName(en_US, pFunction, &pCachedItem);
}
- throw RuntimeException();
+
+ if (!pSymbol)
+ // Appropriate symbol could not be found. Give up.
+ throw RuntimeException();
+
+ if (pCachedItem)
+ cachedItem.reset(pCachedItem);
+ if (cachedItem.get())
+ cachedItem->aLocale = rLocale;
+
+ return pSymbol;
}
Sequence< Locale > SAL_CALL