[Libreoffice-commits] core.git: 3 commits - i18nlangtag/source include/unotools unotools/source vcl/source
Eike Rathke
erack at redhat.com
Thu Jul 11 15:10:36 PDT 2013
i18nlangtag/source/languagetag/languagetag.cxx | 9 +-
include/unotools/fontcfg.hxx | 49 ++----------
unotools/source/config/fontcfg.cxx | 96 +++++++++++++------------
vcl/source/app/settings.cxx | 2
vcl/source/gdi/outdev3.cxx | 31 +++-----
vcl/source/window/window.cxx | 2
6 files changed, 79 insertions(+), 110 deletions(-)
New commits:
commit f66f896657967c0ce3c75680e956cad918a632d3
Author: Eike Rathke <erack at redhat.com>
Date: Fri Jul 12 00:08:32 2013 +0200
DefaultFontConfiguration and FontSubstConfiguration with LanguageTag
Change-Id: I6c111392537d114358d0574f2dbdf40f684b5103
diff --git a/include/unotools/fontcfg.hxx b/include/unotools/fontcfg.hxx
index 5e63ddb..e33397f 100644
--- a/include/unotools/fontcfg.hxx
+++ b/include/unotools/fontcfg.hxx
@@ -19,6 +19,7 @@
#ifndef _UNOTOOLS_FONTCFG_HXX
#define _UNOTOOLS_FONTCFG_HXX
+#include <i18nlangtag/languagetag.hxx>
#include <unotools/unotoolsdllapi.h>
#include <tools/solar.h>
#include <tools/fontenum.hxx>
@@ -59,8 +60,8 @@ class UNOTOOLS_DLLPUBLIC DefaultFontConfiguration
static DefaultFontConfiguration& get();
- OUString getDefaultFont( const com::sun::star::lang::Locale& rLocale, int nType ) const;
- OUString getUserInterfaceFont( const com::sun::star::lang::Locale& rLocale ) const;
+ OUString getDefaultFont( const LanguageTag& rLanguageTag, int nType ) const;
+ OUString getUserInterfaceFont( const LanguageTag& rLanguageTag ) const;
};
// IMPL_FONT_ATTR_DEFAULT - Default-Font like Andale Sans UI, Palace Script, Albany, Thorndale, Cumberland, ...
@@ -175,10 +176,7 @@ public:
const FontNameAttr* getSubstInfo(
const OUString& rFontName,
- const com::sun::star::lang::Locale& rLocale =
- com::sun::star::lang::Locale( OUString( "en" ),
- OUString(),
- OUString() )
+ const LanguageTag& rLanguageTag = LanguageTag( OUString( "en"))
) const;
static void getMapName( const OUString& rOrgName, OUString& rShortName, OUString& rFamilyName, FontWeight& rWeight, FontWidth& rWidth, sal_uLong& rType );
};
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index b61de13..3edd9b4 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -209,24 +209,23 @@ OUString DefaultFontConfiguration::tryLocale( const OUString& rBcp47, const OUSt
return aRet;
}
-OUString DefaultFontConfiguration::getDefaultFont( const Locale& rLocale, int nType ) const
+OUString DefaultFontConfiguration::getDefaultFont( const LanguageTag& rLanguageTag, int nType ) const
{
OUString aType = OUString::createFromAscii( getKeyType( nType ) );
- LanguageTag aLanguageTag( rLocale);
// Try the simple cases first without constructing fallbacks.
- OUString aRet = tryLocale( aLanguageTag.getBcp47(), aType );
+ OUString aRet = tryLocale( rLanguageTag.getBcp47(), aType );
if (aRet.isEmpty())
{
- if (rLocale.Variant.isEmpty())
+ if (rLanguageTag.isIsoLocale())
{
- if (!rLocale.Country.isEmpty())
+ if (!rLanguageTag.getCountry().isEmpty())
{
- aRet = tryLocale( rLocale.Language, aType );
+ aRet = tryLocale( rLanguageTag.getLanguage(), aType );
}
}
else
{
- ::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings());
+ ::std::vector< OUString > aFallbacks( rLanguageTag.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)
@@ -242,13 +241,13 @@ OUString DefaultFontConfiguration::getDefaultFont( const Locale& rLocale, int nT
return aRet;
}
-OUString DefaultFontConfiguration::getUserInterfaceFont( const Locale& rLocale ) const
+OUString DefaultFontConfiguration::getUserInterfaceFont( const LanguageTag& rLanguageTag ) const
{
- Locale aLocale = rLocale;
- if( aLocale.Language.isEmpty() )
- aLocale = SvtSysLocale().GetUILanguageTag().getLocale();
+ LanguageTag aLanguageTag( rLanguageTag);
+ if( aLanguageTag.isSystemLocale() )
+ aLanguageTag = SvtSysLocale().GetUILanguageTag();
- OUString aUIFont = getDefaultFont( aLocale, DEFAULTFONT_UI_SANS );
+ OUString aUIFont = getDefaultFont( aLanguageTag, DEFAULTFONT_UI_SANS );
if( !aUIFont.isEmpty() )
return aUIFont;
@@ -265,16 +264,18 @@ OUString DefaultFontConfiguration::getUserInterfaceFont( const Locale& rLocale )
#define FALLBACKFONT_UI_SANS_CHINSIM "Andale Sans UI;Arial Unicode MS;ZYSong18030;AR PL SungtiL GB;AR PL KaitiM GB;SimSun;Lucida Sans Unicode;Fangsong;Hei;Song;Kai;Ming;gnu-unifont;Interface User;"
#define FALLBACKFONT_UI_SANS_CHINTRD "Andale Sans UI;Arial Unicode MS;AR PL Mingti2L Big5;AR PL KaitiM Big5;Kai;PMingLiU;MingLiU;Ming;Lucida Sans Unicode;gnu-unifont;Interface User;"
+ const OUString aLanguage( aLanguageTag.getLanguage());
+
// optimize font list for some locales, as long as Andale Sans UI does not support them
- if( aLocale.Language == "ar" || aLocale.Language == "he" || aLocale.Language == "iw" )
+ if( aLanguage == "ar" || aLanguage == "he" || aLanguage == "iw" )
{
return OUString(FALLBACKFONT_UI_SANS_ARABIC);
}
- else if ( aLocale.Language == "th" )
+ else if ( aLanguage == "th" )
{
return OUString(FALLBACKFONT_UI_SANS_THAI);
}
- else if ( aLocale.Language == "ko" )
+ else if ( aLanguage == "ko" )
{
// we need localized names for korean fonts
const sal_Unicode aSunGulim[] = { 0xC36C, 0xAD74, 0xB9BC, 0 };
@@ -289,23 +290,19 @@ OUString DefaultFontConfiguration::getUserInterfaceFont( const Locale& rLocale )
return aFallBackKoreanLocalized.makeStringAndClear();
}
- else if( aLocale.Language == "cs" ||
- aLocale.Language == "hu" ||
- aLocale.Language == "pl" ||
- aLocale.Language == "ro" ||
- aLocale.Language == "rm" ||
- aLocale.Language == "hr" ||
- aLocale.Language == "sk" ||
- aLocale.Language == "sl" ||
- aLocale.Language == "sb")
+ else if( aLanguage == "cs" ||
+ aLanguage == "hu" ||
+ aLanguage == "pl" ||
+ aLanguage == "ro" ||
+ aLanguage == "rm" ||
+ aLanguage == "hr" ||
+ aLanguage == "sk" ||
+ aLanguage == "sl" ||
+ aLanguage == "sb")
{
return OUString(FALLBACKFONT_UI_SANS_LATIN2);
}
- else if (MsLangId::isTraditionalChinese(aLocale))
- return OUString(FALLBACKFONT_UI_SANS_CHINTRD);
- else if (MsLangId::isSimplifiedChinese(aLocale))
- return OUString(FALLBACKFONT_UI_SANS_CHINSIM);
- else if ( aLocale.Language == "ja" )
+ else if ( aLanguage == "ja" )
{
// we need localized names for japanese fonts
const sal_Unicode aMSGothic[] = { 0xFF2D, 0xFF33, ' ', 0x30B4, 0x30B7, 0x30C3, 0x30AF, 0 };
@@ -331,6 +328,14 @@ OUString DefaultFontConfiguration::getUserInterfaceFont( const Locale& rLocale )
return aFallBackJapaneseLocalized.makeStringAndClear();
}
+ else
+ {
+ Locale aLocale( aLanguageTag.getLocale());
+ if (MsLangId::isTraditionalChinese(aLocale))
+ return OUString(FALLBACKFONT_UI_SANS_CHINTRD);
+ else if (MsLangId::isSimplifiedChinese(aLocale))
+ return OUString(FALLBACKFONT_UI_SANS_CHINSIM);
+ }
return OUString(FALLBACKFONT_UI_SANS);
}
@@ -1125,7 +1130,8 @@ void FontSubstConfiguration::readLocaleSubst( const OUString& rBcp47 ) const
}
}
-const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontName, const Locale& rLocale ) const
+const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontName,
+ const LanguageTag& rLanguageTag ) const
{
if( rFontName.isEmpty() )
return NULL;
@@ -1136,7 +1142,7 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN
FontNameAttr aSearchAttr;
aSearchAttr.Name = aSearchFont;
- LanguageTag aLanguageTag( rLocale);
+ LanguageTag aLanguageTag( rLanguageTag);
if( aLanguageTag.isSystemLocale() )
aLanguageTag = SvtSysLocale().GetUILanguageTag();
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 1412071..14ab944 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -377,7 +377,7 @@ void ImplStyleData::SetStandardStyles()
Font aStdFont( FAMILY_SWISS, Size( 0, 8 ) );
aStdFont.SetCharSet( osl_getThreadTextEncoding() );
aStdFont.SetWeight( WEIGHT_NORMAL );
- aStdFont.SetName( utl::DefaultFontConfiguration::get().getUserInterfaceFont(com::sun::star::lang::Locale( OUString( "en" ), OUString(), OUString() ) ) );
+ aStdFont.SetName( utl::DefaultFontConfiguration::get().getUserInterfaceFont( LanguageTag("en")) );
maAppFont = aStdFont;
maHelpFont = aStdFont;
maMenuFont = aStdFont;
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 8c65703..8f67176 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -426,19 +426,14 @@ static void ImplFontSubstitute( OUString& rFontName,
Font OutputDevice::GetDefaultFont( sal_uInt16 nType, LanguageType eLang,
sal_uLong nFlags, const OutputDevice* pOutDev )
{
- com::sun::star::lang::Locale aLocale;
- if( eLang == LANGUAGE_NONE || eLang == LANGUAGE_SYSTEM || eLang == LANGUAGE_DONTKNOW )
- {
- aLocale = Application::GetSettings().GetUILanguageTag().getLocale();
- }
- else
- {
- aLocale = LanguageTag( eLang ).getLocale();
- }
+ LanguageTag aLanguageTag(
+ ( eLang == LANGUAGE_NONE || eLang == LANGUAGE_SYSTEM || eLang == LANGUAGE_DONTKNOW ) ?
+ Application::GetSettings().GetUILanguageTag() :
+ LanguageTag( eLang ));
utl::DefaultFontConfiguration& rDefaults = utl::DefaultFontConfiguration::get();
- String aSearch = rDefaults.getUserInterfaceFont( aLocale ); // ensure a fallback
- String aDefault = rDefaults.getDefaultFont( aLocale, nType );
+ String aSearch = rDefaults.getUserInterfaceFont( aLanguageTag ); // ensure a fallback
+ String aDefault = rDefaults.getDefaultFont( aLanguageTag, nType );
if( aDefault.Len() )
aSearch = aDefault;
@@ -1895,23 +1890,23 @@ ImplDevFontListData* ImplDevFontList::FindDefaultFont() const
// try to find one of the default fonts of the
// UNICODE, SANSSERIF, SERIF or FIXED default font lists
const DefaultFontConfiguration& rDefaults = DefaultFontConfiguration::get();
- com::sun::star::lang::Locale aLocale( OUString( "en" ), OUString(), OUString() );
- String aFontname = rDefaults.getDefaultFont( aLocale, DEFAULTFONT_SANS_UNICODE );
+ LanguageTag aLanguageTag( OUString( "en"));
+ String aFontname = rDefaults.getDefaultFont( aLanguageTag, DEFAULTFONT_SANS_UNICODE );
ImplDevFontListData* pFoundData = ImplFindByTokenNames( aFontname );
if( pFoundData )
return pFoundData;
- aFontname = rDefaults.getDefaultFont( aLocale, DEFAULTFONT_SANS );
+ aFontname = rDefaults.getDefaultFont( aLanguageTag, DEFAULTFONT_SANS );
pFoundData = ImplFindByTokenNames( aFontname );
if( pFoundData )
return pFoundData;
- aFontname = rDefaults.getDefaultFont( aLocale, DEFAULTFONT_SERIF );
+ aFontname = rDefaults.getDefaultFont( aLanguageTag, DEFAULTFONT_SERIF );
pFoundData = ImplFindByTokenNames( aFontname );
if( pFoundData )
return pFoundData;
- aFontname = rDefaults.getDefaultFont( aLocale, DEFAULTFONT_FIXED );
+ aFontname = rDefaults.getDefaultFont( aLanguageTag, DEFAULTFONT_FIXED );
pFoundData = ImplFindByTokenNames( aFontname );
if( pFoundData )
return pFoundData;
@@ -2559,8 +2554,8 @@ ImplDevFontListData* ImplDevFontList::ImplFindByFont( FontSelectPattern& rFSD,
// if a target symbol font is not available use a default symbol font
if( rFSD.IsSymbolFont() )
{
- com::sun::star::lang::Locale aDefaultLocale( OUString( "en" ), OUString(), OUString() );
- aSearchName = DefaultFontConfiguration::get().getDefaultFont( aDefaultLocale, DEFAULTFONT_SYMBOL );
+ LanguageTag aDefaultLanguageTag( OUString( "en"));
+ aSearchName = DefaultFontConfiguration::get().getDefaultFont( aDefaultLanguageTag, DEFAULTFONT_SYMBOL );
ImplDevFontListData* pFoundData = ImplFindByTokenNames( aSearchName );
if( pFoundData )
return pFoundData;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 2125cda..2a7440a 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -470,7 +470,7 @@ void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, sal_Bool bCallHdl
if ( !bUseSystemFont )
{
ImplInitFontList();
- String aConfigFont = utl::DefaultFontConfiguration::get().getUserInterfaceFont( rSettings.GetUILanguageTag().getLocale() );
+ String aConfigFont = utl::DefaultFontConfiguration::get().getUserInterfaceFont( rSettings.GetUILanguageTag() );
sal_Int32 nIndex = 0;
while( nIndex != -1 )
{
commit 1254a00da0fff439c8f8ac1697da7a96e10b1705
Author: Eike Rathke <erack at redhat.com>
Date: Thu Jul 11 23:08:40 2013 +0200
eliminated some back and forth conversion between bcp47 and Locale
Change-Id: If97a4b695262a99979dbab1bcec75fe694c4de80
diff --git a/include/unotools/fontcfg.hxx b/include/unotools/fontcfg.hxx
index 3e7f0ac..5e63ddb 100644
--- a/include/unotools/fontcfg.hxx
+++ b/include/unotools/fontcfg.hxx
@@ -30,37 +30,9 @@
#include <boost/unordered_set.hpp>
#include <vector>
-namespace com {
-namespace sun {
-namespace star {
-namespace lang {
-
-// equality operator needed for hash_map;
-// (-> why does this need to be in the namespace of Locale ? g++ fails to compile else)
-inline bool operator==( const com::sun::star::lang::Locale& rLeft, const com::sun::star::lang::Locale& rRight )
-{
- return
- rLeft.Language.equals( rRight.Language ) &&
- rLeft.Country.equals( rRight.Country ) &&
- rLeft.Variant.equals( rRight.Variant )
- ;
-}
-}}}}
-
namespace utl
{
-struct LocaleHash
-{
- size_t operator()( const com::sun::star::lang::Locale& rLocale ) const
- {
- return
- (size_t)rLocale.Language.hashCode() ^
- (size_t)rLocale.Country.hashCode() ^
- (size_t)rLocale.Variant.hashCode();
- }
-};
-
class UNOTOOLS_DLLPUBLIC DefaultFontConfiguration
{
com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
@@ -77,12 +49,9 @@ class UNOTOOLS_DLLPUBLIC DefaultFontConfiguration
mutable com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xAccess;
};
- boost::unordered_map< com::sun::star::lang::Locale,
- LocaleAccess,
- utl::LocaleHash >
- m_aConfig;
+ boost::unordered_map< OUString, LocaleAccess, OUStringHash > m_aConfig;
- OUString tryLocale( const com::sun::star::lang::Locale& rLocale, const OUString& rType ) const;
+ OUString tryLocale( const OUString& rBcp47, const OUString& rType ) const;
public:
DefaultFontConfiguration();
@@ -183,7 +152,7 @@ private:
LocaleSubst() : bConfigRead( false ) {}
};
- boost::unordered_map< com::sun::star::lang::Locale, LocaleSubst, utl::LocaleHash > m_aSubst;
+ boost::unordered_map< OUString, LocaleSubst, OUStringHash > m_aSubst;
typedef boost::unordered_set< OUString, OUStringHash > UniqueSubstHash;
mutable UniqueSubstHash maSubstHash;
@@ -197,7 +166,7 @@ private:
const OUString& rType ) const;
unsigned long getSubstType( const com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > xFont,
const OUString& rType ) const;
- void readLocaleSubst( const com::sun::star::lang::Locale& rLocale ) const;
+ void readLocaleSubst( const OUString& rBcp47 ) const;
public:
FontSubstConfiguration();
~FontSubstConfiguration();
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index e9cec6c..b61de13 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -126,7 +126,8 @@ DefaultFontConfiguration::DefaultFontConfiguration()
const OUString* pLocaleStrings = aLocales.getConstArray();
for( int i = 0; i < nLocales; i++ )
{
- Locale aLoc( LanguageTag( pLocaleStrings[i]).getLocale( false));
+ // Feed through LanguageTag for casing.
+ OUString aLoc( LanguageTag( pLocaleStrings[i], true).getBcp47( false));
m_aConfig[ aLoc ] = LocaleAccess();
m_aConfig[ aLoc ].aConfigLocaleString = pLocaleStrings[i];
}
@@ -160,12 +161,11 @@ DefaultFontConfiguration::~DefaultFontConfiguration()
m_xConfigProvider.clear();
}
-OUString DefaultFontConfiguration::tryLocale( const Locale& rLocale, const OUString& rType ) const
+OUString DefaultFontConfiguration::tryLocale( const OUString& rBcp47, const OUString& rType ) const
{
OUString aRet;
- boost::unordered_map< Locale, LocaleAccess, LocaleHash >::const_iterator it =
- m_aConfig.find( rLocale );
+ boost::unordered_map< OUString, LocaleAccess, OUStringHash >::const_iterator it = m_aConfig.find( rBcp47 );
if( it != m_aConfig.end() )
{
if( !it->second.xAccess.is() )
@@ -212,33 +212,32 @@ OUString DefaultFontConfiguration::tryLocale( const Locale& rLocale, const OUStr
OUString DefaultFontConfiguration::getDefaultFont( const Locale& rLocale, int nType ) const
{
OUString aType = OUString::createFromAscii( getKeyType( nType ) );
- OUString aRet = tryLocale( rLocale, aType );
+ LanguageTag aLanguageTag( rLocale);
+ // Try the simple cases first without constructing fallbacks.
+ OUString aRet = tryLocale( aLanguageTag.getBcp47(), aType );
if (aRet.isEmpty())
{
if (rLocale.Variant.isEmpty())
{
if (!rLocale.Country.isEmpty())
{
- Locale aLocale( rLocale.Language, "", "");
- aRet = tryLocale( aLocale, aType );
+ aRet = tryLocale( rLocale.Language, aType );
}
}
else
{
- ::std::vector< OUString > aFallbacks( LanguageTag( rLocale).getFallbackStrings());
+ ::std::vector< OUString > aFallbacks( aLanguageTag.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 );
+ aRet = tryLocale( *it, aType );
}
}
}
if( aRet.isEmpty() )
{
- Locale aLocale("en","","");
- aRet = tryLocale( aLocale, aType );
+ aRet = tryLocale( "en", aType );
}
return aRet;
}
@@ -388,7 +387,8 @@ FontSubstConfiguration::FontSubstConfiguration() :
const OUString* pLocaleStrings = aLocales.getConstArray();
for( int i = 0; i < nLocales; i++ )
{
- Locale aLoc( LanguageTag( pLocaleStrings[i]).getLocale( false));
+ // Feed through LanguageTag for casing.
+ OUString aLoc( LanguageTag( pLocaleStrings[i], true).getBcp47( false));
m_aSubst[ aLoc ] = LocaleSubst();
m_aSubst[ aLoc ].aConfigLocaleString = pLocaleStrings[i];
}
@@ -1046,10 +1046,9 @@ unsigned long FontSubstConfiguration::getSubstType( const com::sun::star::uno::R
return type;
}
-void FontSubstConfiguration::readLocaleSubst( const com::sun::star::lang::Locale& rLocale ) const
+void FontSubstConfiguration::readLocaleSubst( const OUString& rBcp47 ) const
{
- boost::unordered_map< Locale, LocaleSubst, LocaleHash >::const_iterator it =
- m_aSubst.find( rLocale );
+ boost::unordered_map< OUString, LocaleSubst, OUStringHash >::const_iterator it = m_aSubst.find( rBcp47 );
if( it != m_aSubst.end() )
{
if( ! it->second.bConfigRead )
@@ -1148,12 +1147,11 @@ const FontNameAttr* FontSubstConfiguration::getSubstInfo( const OUString& rFontN
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< OUString, LocaleSubst, OUStringHash >::const_iterator lang = m_aSubst.find( *fb );
if( lang != m_aSubst.end() )
{
if( ! lang->second.bConfigRead )
- readLocaleSubst( aLocale );
+ readLocaleSubst( *fb );
// try to find an exact match
// because the list is sorted this will also find fontnames of the form searchfontname*
std::vector< FontNameAttr >::const_iterator it = ::std::lower_bound( lang->second.aSubstAttributes.begin(), lang->second.aSubstAttributes.end(), aSearchAttr, StrictStringSort() );
commit 642f458c23eefc9fcf5447362a049329b489adf0
Author: Eike Rathke <erack at redhat.com>
Date: Thu Jul 11 22:10:48 2013 +0200
use OUStringBuffer
Change-Id: If82c2114a1145e1bfdede9205461717c04043db2
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 0309ca1..c1319dd 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -467,11 +467,14 @@ bool LanguageTag::canonicalize()
if (eExt == EXTRACTED_LSC)
{
// Rebuild bcp47 with proper casing of tags.
- OUString aStr( aLanguage);
+ OUStringBuffer aBuf( aLanguage.getLength() + 1 + aScript.getLength() +
+ 1 + aCountry.getLength());
+ aBuf.append( aLanguage);
if (!aScript.isEmpty())
- aStr += "-" + aScript;
+ aBuf.append('-').append( aScript);
if (!aCountry.isEmpty())
- aStr += "-" + aCountry;
+ aBuf.append('-').append( aCountry);
+ OUString aStr( aBuf.makeStringAndClear());
if (maBcp47 != aStr)
{
maBcp47 = aStr;
More information about the Libreoffice-commits
mailing list