diff options
author | Eike Rathke <erack@redhat.com> | 2013-07-11 20:33:56 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-07-11 20:47:08 +0200 |
commit | 62f56ba02d7d664a835a36bfabe3a1704b175baa (patch) | |
tree | 4dd70ed00c8e6a9c1384c3ea1647423d415a346e /unotools | |
parent | ac469ceef535c5463443d3d81dc02cd9744785a8 (diff) |
use LanguageTag and getFallbackStrings()
Change-Id: I398fb1cd3a2f456562d879b417ec964f21f67464
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/config/fontcfg.cxx | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index 5e074d39c650..e9cec6c952f5 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -1137,16 +1137,18 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN FontNameAttr aSearchAttr; aSearchAttr.Name = aSearchFont; - Locale aLocale; - aLocale.Language = rLocale.Language.toAsciiLowerCase(); - aLocale.Country = rLocale.Country.toAsciiUpperCase(); - aLocale.Variant = rLocale.Variant.toAsciiUpperCase(); + LanguageTag aLanguageTag( rLocale); - if( aLocale.Language.isEmpty() ) - aLocale = SvtSysLocale().GetUILanguageTag().getLocale(); + if( aLanguageTag.isSystemLocale() ) + aLanguageTag = SvtSysLocale().GetUILanguageTag(); - while( !aLocale.Language.isEmpty() ) + ::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings()); + if (aLanguageTag.getLanguage() != "en") + aFallbacks.push_back("en"); + + for (::std::vector< OUString >::const_iterator fb( aFallbacks.begin()); fb != aFallbacks.end(); ++fb) { + Locale aLocale( LanguageTag( *fb).getLocale()); boost::unordered_map< Locale, LocaleSubst, LocaleHash >::const_iterator lang = m_aSubst.find( aLocale ); if( lang != m_aSubst.end() ) { @@ -1165,15 +1167,6 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN return &rFoundAttr; } } - // gradually become more unspecific - if( !aLocale.Variant.isEmpty() ) - aLocale.Variant = OUString(); - else if( !aLocale.Country.isEmpty() ) - aLocale.Country = OUString(); - else if( aLocale.Language != "en" ) - aLocale.Language = OUString( "en" ); - else - aLocale.Language = OUString(); } return NULL; } |