diff options
author | Eike Rathke <erack@redhat.com> | 2013-07-11 20:10:49 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-07-11 20:47:08 +0200 |
commit | ac469ceef535c5463443d3d81dc02cd9744785a8 (patch) | |
tree | 0832554617d66fd37faa96f69fa3ed5cec2d3f00 /unotools | |
parent | 3c59183f5bfa22194f0287b449aaa6d882be8827 (diff) |
use LanguageTag::getFallbackStrings()
Change-Id: Id9403337375077931e976358c4410ad18ac0e092
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/config/fontcfg.cxx | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index 205746d4db19..5e074d39c650 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -211,26 +211,33 @@ OUString DefaultFontConfiguration::tryLocale( const Locale& rLocale, const OUStr OUString DefaultFontConfiguration::getDefaultFont( const Locale& rLocale, int nType ) const { - Locale aLocale; - aLocale.Language = rLocale.Language.toAsciiLowerCase(); - aLocale.Country = rLocale.Country.toAsciiUpperCase(); - aLocale.Variant = rLocale.Variant.toAsciiUpperCase(); - OUString aType = OUString::createFromAscii( getKeyType( nType ) ); - OUString aRet = tryLocale( aLocale, aType ); - if( aRet.isEmpty() && !aLocale.Variant.isEmpty() ) + OUString aRet = tryLocale( rLocale, aType ); + if (aRet.isEmpty()) { - aLocale.Variant = OUString(); - aRet = tryLocale( aLocale, aType ); - } - if( aRet.isEmpty() && !aLocale.Country.isEmpty() ) - { - aLocale.Country = OUString(); - aRet = tryLocale( aLocale, aType ); + if (rLocale.Variant.isEmpty()) + { + if (!rLocale.Country.isEmpty()) + { + Locale aLocale( rLocale.Language, "", ""); + aRet = tryLocale( aLocale, aType ); + } + } + else + { + ::std::vector< OUString > aFallbacks( LanguageTag( rLocale).getFallbackStrings()); + aFallbacks.erase( aFallbacks.begin()); // first is full BCP47, we already checked that + for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); + it != aFallbacks.end() && aRet.isEmpty(); ++it) + { + Locale aLocale( LanguageTag( *it).getLocale( false)); + aRet = tryLocale( aLocale, aType ); + } + } } if( aRet.isEmpty() ) { - aLocale.Language = OUString( "en" ); + Locale aLocale("en","",""); aRet = tryLocale( aLocale, aType ); } return aRet; |