[Libreoffice-commits] core.git: 2 commits - unotools/source
Eike Rathke
erack at redhat.com
Thu Jul 11 11:47:30 PDT 2013
unotools/source/config/fontcfg.cxx | 62 ++++++++++++++++++-------------------
1 file changed, 31 insertions(+), 31 deletions(-)
New commits:
commit 62f56ba02d7d664a835a36bfabe3a1704b175baa
Author: Eike Rathke <erack at redhat.com>
Date: Thu Jul 11 20:33:56 2013 +0200
use LanguageTag and getFallbackStrings()
Change-Id: I398fb1cd3a2f456562d879b417ec964f21f67464
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index 5e074d3..e9cec6c 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;
}
commit ac469ceef535c5463443d3d81dc02cd9744785a8
Author: Eike Rathke <erack at redhat.com>
Date: Thu Jul 11 20:10:49 2013 +0200
use LanguageTag::getFallbackStrings()
Change-Id: Id9403337375077931e976358c4410ad18ac0e092
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index 205746d..5e074d3 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;
More information about the Libreoffice-commits
mailing list