Kaydet (Commit) 62f56ba0 authored tarafından Eike Rathke's avatar Eike Rathke

use LanguageTag and getFallbackStrings()

Change-Id: I398fb1cd3a2f456562d879b417ec964f21f67464
üst ac469cee
...@@ -1137,16 +1137,18 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN ...@@ -1137,16 +1137,18 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN
FontNameAttr aSearchAttr; FontNameAttr aSearchAttr;
aSearchAttr.Name = aSearchFont; aSearchAttr.Name = aSearchFont;
Locale aLocale; LanguageTag aLanguageTag( rLocale);
aLocale.Language = rLocale.Language.toAsciiLowerCase();
aLocale.Country = rLocale.Country.toAsciiUpperCase();
aLocale.Variant = rLocale.Variant.toAsciiUpperCase();
if( aLocale.Language.isEmpty() ) if( aLanguageTag.isSystemLocale() )
aLocale = SvtSysLocale().GetUILanguageTag().getLocale(); 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 ); boost::unordered_map< Locale, LocaleSubst, LocaleHash >::const_iterator lang = m_aSubst.find( aLocale );
if( lang != m_aSubst.end() ) if( lang != m_aSubst.end() )
{ {
...@@ -1165,15 +1167,6 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN ...@@ -1165,15 +1167,6 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN
return &rFoundAttr; 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; return NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment