[Libreoffice-commits] core.git: 7 commits - comphelper/README i18npool/inc i18npool/qa i18npool/source
Eike Rathke
erack at redhat.com
Wed Mar 27 12:38:41 PDT 2013
comphelper/README | 2
i18npool/inc/i18npool/lang.h | 4 +
i18npool/inc/i18npool/languagetag.hxx | 58 +++++++++-------
i18npool/inc/i18npool/mslangid.hxx | 14 ++-
i18npool/qa/cppunit/test_languagetag.cxx | 24 ++++++
i18npool/source/isolang/isolang.cxx | 101 +++++++++++++++++++---------
i18npool/source/isolang/mslangid.cxx | 16 +++-
i18npool/source/languagetag/languagetag.cxx | 64 +++++++++--------
8 files changed, 190 insertions(+), 93 deletions(-)
New commits:
commit c3763ef570e1c6aba53bc23ba3c03429891ad473
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 27 20:35:43 2013 +0100
rtl::OUString to OUString
Change-Id: I546132fbd8dbb621a8b436648d1e21a4dea79591
diff --git a/i18npool/inc/i18npool/mslangid.hxx b/i18npool/inc/i18npool/mslangid.hxx
index 1f959ad..b3d04ec 100644
--- a/i18npool/inc/i18npool/mslangid.hxx
+++ b/i18npool/inc/i18npool/mslangid.hxx
@@ -97,7 +97,7 @@ public:
// TODO: refactor to LanguageTag, used only in
// i18npool/source/isolang/inunx.cxx to convert Unix locale string
- static LanguageType convertUnxByteStringToLanguage( const rtl::OString& rString );
+ static LanguageType convertUnxByteStringToLanguage( const OString& rString );
static LanguageType resolveSystemLanguageByScriptType( LanguageType nLang, sal_Int16 nType );
@@ -206,7 +206,7 @@ public:
const ::com::sun::star::lang::Locale & rLocale );
friend LanguageType MsLangId::convertUnxByteStringToLanguage(
- const rtl::OString& rString );
+ const OString& rString );
/** Convert a Locale to a LanguageType with handling of an empty
@@ -217,16 +217,16 @@ public:
/** Convert x-... privateuse, used by convertLocaleToLanguage(Locale) */
I18NISOLANG_DLLPRIVATE static LanguageType convertPrivateUseToLanguage(
- const rtl::OUString& rPriv );
+ const OUString& rPriv );
/** Used by convertLocaleToLanguage(Locale) */
I18NISOLANG_DLLPRIVATE static LanguageType convertIsoNamesToLanguage(
- const rtl::OUString& rLang, const rtl::OUString& rCountry );
+ const OUString& rLang, const OUString& rCountry );
/** Used by convertUnxByteStringToLanguage(OString) */
I18NISOLANG_DLLPRIVATE static LanguageType convertIsoNamesToLanguage(
- const rtl::OString& rLang, const rtl::OString& rCountry );
+ const OString& rLang, const OString& rCountry );
/** Convert a LanguageType to a Locale.
@@ -248,7 +248,7 @@ public:
/** Used by convertLanguageToLocale(LanguageType,Locale) */
I18NISOLANG_DLLPRIVATE static void convertLanguageToIsoNames(
- LanguageType nLang, rtl::OUString& rLangStr, rtl::OUString& rCountry );
+ LanguageType nLang, OUString& rLangStr, OUString& rCountry );
I18NISOLANG_DLLPRIVATE static LanguageType lookupFallbackLanguage( LanguageType nLang );
diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx
index 21b7370..942cd84 100644
--- a/i18npool/source/isolang/isolang.cxx
+++ b/i18npool/source/isolang/isolang.cxx
@@ -642,7 +642,7 @@ static IsoLangOtherEntry const aImplPrivateUseEntries[] =
// static
void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
- rtl::OUString& rLangStr, rtl::OUString& rCountry )
+ OUString& rLangStr, OUString& rCountry )
{
if ( nLang == LANGUAGE_SYSTEM )
nLang = MsLangId::getSystemLanguage();
@@ -653,8 +653,8 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
{
if ( pEntry->mnLang == nLang )
{
- rLangStr = rtl::OUString::createFromAscii( pEntry->maLangStr );
- rCountry = rtl::OUString::createFromAscii( pEntry->maCountry );
+ rLangStr = OUString::createFromAscii( pEntry->maLangStr );
+ rCountry = OUString::createFromAscii( pEntry->maCountry );
return;
}
++pEntry;
@@ -669,8 +669,8 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
{
if ( pNoneStdEntry->mnLang == nLang )
{
- rLangStr = rtl::OUString::createFromAscii( pNoneStdEntry->maLangStr );
- rCountry = rtl::OUString::createFromAscii( pNoneStdEntry->maCountry );
+ rLangStr = OUString::createFromAscii( pNoneStdEntry->maLangStr );
+ rCountry = OUString::createFromAscii( pNoneStdEntry->maCountry );
return;
}
++pNoneStdEntry;
@@ -683,7 +683,7 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
{
if ( pPrivateEntry->mnLang == nLang )
{
- rLangStr = rtl::OUString::createFromAscii( pPrivateEntry->mpLangStr );
+ rLangStr = OUString::createFromAscii( pPrivateEntry->mpLangStr );
rCountry = OUString();
return;
}
@@ -692,8 +692,8 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
// not found
- rLangStr = rtl::OUString();
- rCountry = rtl::OUString();
+ rLangStr = OUString();
+ rCountry = OUString();
}
// -----------------------------------------------------------------------
@@ -764,9 +764,9 @@ LanguageType MsLangId::Conversion::lookupFallbackLanguage( LanguageType nLang )
{
const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( nLang);
return ::com::sun::star::lang::Locale(
- rtl::OUString::createFromAscii( rEntry.maLangStr),
- rtl::OUString::createFromAscii( rEntry.maCountry),
- rtl::OUString());
+ OUString::createFromAscii( rEntry.maLangStr),
+ OUString::createFromAscii( rEntry.maCountry),
+ OUString());
}
// -----------------------------------------------------------------------
@@ -775,9 +775,9 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
const ::com::sun::star::lang::Locale & rLocale )
{
// language is lower case in table
- rtl::OUString aLowerLang = rLocale.Language.toAsciiLowerCase();
+ OUString aLowerLang = rLocale.Language.toAsciiLowerCase();
// country is upper case in table
- rtl::OUString aUpperCountry = rLocale.Country.toAsciiUpperCase();
+ OUString aUpperCountry = rLocale.Country.toAsciiUpperCase();
sal_Int32 nCountryLen = aUpperCountry.getLength();
// Search for locale and remember first lang-only.
@@ -840,15 +840,15 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
{
const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( rLocale);
return ::com::sun::star::lang::Locale(
- rtl::OUString::createFromAscii( rEntry.maLangStr),
- rtl::OUString::createFromAscii( rEntry.maCountry),
- rtl::OUString());
+ OUString::createFromAscii( rEntry.maLangStr),
+ OUString::createFromAscii( rEntry.maCountry),
+ OUString());
}
// =======================================================================
// static
-LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const rtl::OUString& rPriv )
+LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const OUString& rPriv )
{
const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
do
@@ -862,13 +862,13 @@ LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const rtl::OUStr
// static
-LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OUString& rLang,
- const rtl::OUString& rCountry )
+LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const OUString& rLang,
+ const OUString& rCountry )
{
// language is lower case in table
- rtl::OUString aLowerLang = rLang.toAsciiLowerCase();
+ OUString aLowerLang = rLang.toAsciiLowerCase();
// country is upper case in table
- rtl::OUString aUpperCountry = rCountry.toAsciiUpperCase();
+ OUString aUpperCountry = rCountry.toAsciiUpperCase();
// first look for exact match
const IsoLangEntry* pFirstLang = NULL;
@@ -969,11 +969,11 @@ LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OUStrin
// -----------------------------------------------------------------------
// static
-LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OString& rLang,
- const rtl::OString& rCountry )
+LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const OString& rLang,
+ const OString& rCountry )
{
- rtl::OUString aLang = OStringToOUString( rLang, RTL_TEXTENCODING_ASCII_US);
- rtl::OUString aCountry = OStringToOUString( rCountry, RTL_TEXTENCODING_ASCII_US);
+ OUString aLang = OStringToOUString( rLang, RTL_TEXTENCODING_ASCII_US);
+ OUString aCountry = OStringToOUString( rCountry, RTL_TEXTENCODING_ASCII_US);
return convertIsoNamesToLanguage( aLang, aCountry);
}
@@ -1004,11 +1004,11 @@ static IsoLangGLIBCModifiersEntry const aImplIsoLangGLIBCModifiersEntries[] =
// static
LanguageType MsLangId::convertUnxByteStringToLanguage(
- const rtl::OString& rString )
+ const OString& rString )
{
- rtl::OString aLang;
- rtl::OString aCountry;
- rtl::OString aAtString;
+ OString aLang;
+ OString aCountry;
+ OString aAtString;
sal_Int32 nLangSepPos = rString.indexOf( (sal_Char)'_' );
sal_Int32 nCountrySepPos = rString.indexOf( (sal_Char)'.' );
@@ -1039,9 +1039,9 @@ LanguageType MsLangId::convertUnxByteStringToLanguage(
if (!aAtString.isEmpty())
{
// language is lower case in table
- rtl::OString aLowerLang = aLang.toAsciiLowerCase();
+ OString aLowerLang = aLang.toAsciiLowerCase();
// country is upper case in table
- rtl::OString aUpperCountry = aCountry.toAsciiUpperCase();
+ OString aUpperCountry = aCountry.toAsciiUpperCase();
const IsoLangGLIBCModifiersEntry* pGLIBCModifiersEntry = aImplIsoLangGLIBCModifiersEntries;
do
{ // avoid embedded \0 warning
diff --git a/i18npool/source/isolang/mslangid.cxx b/i18npool/source/isolang/mslangid.cxx
index e417f33..6afde62 100644
--- a/i18npool/source/isolang/mslangid.cxx
+++ b/i18npool/source/isolang/mslangid.cxx
@@ -146,7 +146,7 @@ void MsLangId::Conversion::convertLanguageToLocale( LanguageType nLang,
::com::sun::star::lang::Locale & rLocale )
{
if (!rLocale.Variant.isEmpty())
- rLocale.Variant = rtl::OUString();
+ rLocale.Variant = OUString();
convertLanguageToIsoNames( nLang, rLocale.Language, rLocale.Country);
/* FIXME: this x-... is temporary until conversion will be moved up to
* LanguageTag */
commit 609507a8737277b1e8a53165882c346931477e4b
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 27 20:31:55 2013 +0100
unit test for x-... privateuse
Change-Id: I46062bcece6ccbcebf421bc4334c1af05f27a8fb
diff --git a/i18npool/qa/cppunit/test_languagetag.cxx b/i18npool/qa/cppunit/test_languagetag.cxx
index f748802..f2f6e30 100644
--- a/i18npool/qa/cppunit/test_languagetag.cxx
+++ b/i18npool/qa/cppunit/test_languagetag.cxx
@@ -205,6 +205,30 @@ void TestLanguageTag::testAllTags()
CPPUNIT_ASSERT( qty.getLanguageType() == LANGUAGE_SYSTEM );
}
+ // 'x-comment' is a privateuse known "locale"
+ {
+ OUString s_xcomment( "x-comment" );
+ LanguageTag xcomment( s_xcomment );
+ lang::Locale aLocale = xcomment.getLocale();
+ CPPUNIT_ASSERT( xcomment.getBcp47() == s_xcomment );
+ CPPUNIT_ASSERT( aLocale.Language == "qlt" );
+ CPPUNIT_ASSERT( aLocale.Country == "" );
+ CPPUNIT_ASSERT( aLocale.Variant == "x-comment" );
+ CPPUNIT_ASSERT( xcomment.getLanguageType() == LANGUAGE_USER_PRIV_COMMENT );
+ }
+
+ // 'x-foobar' is a privateuse unknown "locale"
+ {
+ OUString s_xfoobar( "x-foobar" );
+ LanguageTag xfoobar( s_xfoobar );
+ lang::Locale aLocale = xfoobar.getLocale();
+ CPPUNIT_ASSERT( xfoobar.getBcp47() == s_xfoobar );
+ CPPUNIT_ASSERT( aLocale.Language == "qlt" );
+ CPPUNIT_ASSERT( aLocale.Country == "" );
+ CPPUNIT_ASSERT( aLocale.Variant == "x-foobar" );
+ CPPUNIT_ASSERT( xfoobar.getLanguageType() == LANGUAGE_SYSTEM );
+ }
+
// test reset() methods
{
LanguageTag aTag( LANGUAGE_DONTKNOW );
commit d35ed10d1d75c6ce3a850e844a931b95c12cd127
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 27 20:23:08 2013 +0100
handle x-... privateuse
Change-Id: I9ff44e7f3d3fd8fccc5b7134c18184040f797826
diff --git a/i18npool/inc/i18npool/languagetag.hxx b/i18npool/inc/i18npool/languagetag.hxx
index 5b88542..4d99e72 100644
--- a/i18npool/inc/i18npool/languagetag.hxx
+++ b/i18npool/inc/i18npool/languagetag.hxx
@@ -319,17 +319,25 @@ private:
static bool isIsoScript( const OUString& rScript );
static bool isIsoCountry( const OUString& rRegion );
+ enum Extraction
+ {
+ EXTRACTED_NONE,
+ EXTRACTED_LSC,
+ EXTRACTED_X
+ };
+
/** Of a simple language tag of the form lll[-Ssss][-CC] (i.e. one that
would fulfill the isIsoODF() condition) extract the portions.
Does not check case or content!
- @return TRUE if it detected a simple tag, else FALSE.
+ @return EXTRACTED_LSC if simple tag was detected, EXTRACTED_X if x-...
+ privateuse tag was detected, else EXTRACTED_NONE.
*/
- static bool simpleExtract( const OUString& rBcp47,
- OUString& rLanguage,
- OUString& rScript,
- OUString& rCountry );
+ static Extraction simpleExtract( const OUString& rBcp47,
+ OUString& rLanguage,
+ OUString& rScript,
+ OUString& rCountry );
};
#endif // INCLUDED_I18NPOOL_LANGUAGETAG_HXX
diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx
index e43bfe3..7b284b5 100644
--- a/i18npool/source/languagetag/languagetag.cxx
+++ b/i18npool/source/languagetag/languagetag.cxx
@@ -429,9 +429,10 @@ bool LanguageTag::canonicalize()
// without using liblangtag just to see if it is a simple known
// locale.
OUString aLanguage, aScript, aCountry;
- if (simpleExtract( maBcp47, aLanguage, aScript, aCountry))
+ Extraction eExt = simpleExtract( maBcp47, aLanguage, aScript, aCountry);
+ if (eExt == EXTRACTED_LSC || eExt == EXTRACTED_X)
{
- if (aScript.isEmpty())
+ if (eExt == EXTRACTED_LSC && aScript.isEmpty())
{
maLocale.Language = aLanguage;
maLocale.Country = aCountry;
@@ -960,7 +961,7 @@ bool LanguageTag::hasScript() const
bool LanguageTag::cacheSimpleLSC()
{
OUString aLanguage, aScript, aCountry;
- bool bRet = simpleExtract( maBcp47, aLanguage, aScript, aCountry);
+ bool bRet = (simpleExtract( maBcp47, aLanguage, aScript, aCountry) == EXTRACTED_LSC);
if (bRet)
{
maCachedLanguage = aLanguage;
@@ -1115,19 +1116,22 @@ bool LanguageTag::operator!=( const LanguageTag & rLanguageTag ) const
// static
-bool LanguageTag::simpleExtract( const OUString& rBcp47,
- OUString& rLanguage,
- OUString& rScript,
- OUString& rCountry )
+LanguageTag::Extraction LanguageTag::simpleExtract( const OUString& rBcp47,
+ OUString& rLanguage, OUString& rScript, OUString& rCountry )
{
- bool bRet = false;
+ Extraction eRet = EXTRACTED_NONE;
const sal_Int32 nLen = rBcp47.getLength();
const sal_Int32 nHyph1 = rBcp47.indexOf( '-');
- if ((nLen == 2 || nLen == 3) && nHyph1 < 0) // ll or lll
+ if (nHyph1 == 1 && rBcp47[0] == 'x') // x-... privateuse
+ {
+ // x-... privateuse tags MUST be known to us by definition.
+ eRet = EXTRACTED_X;
+ }
+ else if ((nLen == 2 || nLen == 3) && nHyph1 < 0) // ll or lll
{
rLanguage = rBcp47;
rScript = rCountry = OUString();
- bRet = true;
+ eRet = EXTRACTED_LSC;
}
else if ( (nLen == 5 && nHyph1 == 2) // ll-CC
|| (nLen == 6 && nHyph1 == 3)) // lll-CC
@@ -1135,7 +1139,7 @@ bool LanguageTag::simpleExtract( const OUString& rBcp47,
rLanguage = rBcp47.copy( 0, nHyph1);
rCountry = rBcp47.copy( nHyph1 + 1, 2);
rScript = OUString();
- bRet = true;
+ eRet = EXTRACTED_LSC;
}
else if ( (nHyph1 == 2 && nLen == 10) // ll-Ssss-CC check
|| (nHyph1 == 3 && nLen == 11)) // lll-Ssss-CC check
@@ -1146,12 +1150,12 @@ bool LanguageTag::simpleExtract( const OUString& rBcp47,
rLanguage = rBcp47.copy( 0, nHyph1);
rScript = rBcp47.copy( nHyph1 + 1, 4);
rCountry = rBcp47.copy( nHyph2 + 1, 2);
- bRet = true;
+ eRet = EXTRACTED_LSC;
}
}
- if (!bRet)
+ if (eRet == EXTRACTED_NONE)
rLanguage = rScript = rCountry = OUString();
- return bRet;
+ return eRet;
}
commit 46f47a6ec28dda0436b9c4fb54628a6e2e191285
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 27 20:20:50 2013 +0100
handle x-... privateuse conversion
Change-Id: I293ba38f02a93d161fd05beba02f2dcd974c63d3
diff --git a/i18npool/inc/i18npool/mslangid.hxx b/i18npool/inc/i18npool/mslangid.hxx
index c1682c3..1f959ad 100644
--- a/i18npool/inc/i18npool/mslangid.hxx
+++ b/i18npool/inc/i18npool/mslangid.hxx
@@ -215,6 +215,10 @@ public:
I18NISOLANG_DLLPRIVATE static LanguageType convertLocaleToLanguage(
const ::com::sun::star::lang::Locale & rLocale );
+ /** Convert x-... privateuse, used by convertLocaleToLanguage(Locale) */
+ I18NISOLANG_DLLPRIVATE static LanguageType convertPrivateUseToLanguage(
+ const rtl::OUString& rPriv );
+
/** Used by convertLocaleToLanguage(Locale) */
I18NISOLANG_DLLPRIVATE static LanguageType convertIsoNamesToLanguage(
const rtl::OUString& rLang, const rtl::OUString& rCountry );
diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx
index ba3b4e5..21b7370 100644
--- a/i18npool/source/isolang/isolang.cxx
+++ b/i18npool/source/isolang/isolang.cxx
@@ -848,6 +848,20 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
// =======================================================================
// static
+LanguageType MsLangId::Conversion::convertPrivateUseToLanguage( const rtl::OUString& rPriv )
+{
+ const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
+ do
+ {
+ if ( rPriv.equalsIgnoreAsciiCaseAscii( pPrivateEntry->mpLangStr ) )
+ return pPrivateEntry->mnLang;
+ ++pPrivateEntry;
+ } while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
+ return LANGUAGE_DONTKNOW;
+}
+
+
+// static
LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OUString& rLang,
const rtl::OUString& rCountry )
{
@@ -935,14 +949,9 @@ LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OUStrin
}
// Look for privateuse definitions.
- const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
- do
- {
- if ( aLowerLang.equalsAscii( pPrivateEntry->mpLangStr ) )
- return pPrivateEntry->mnLang;
- ++pPrivateEntry;
- }
- while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
+ LanguageType nLang = convertPrivateUseToLanguage( aLowerLang);
+ if (nLang != LANGUAGE_DONTKNOW)
+ return nLang;
// Now look for all other definitions, which are not standard
const IsoLangOtherEntry* pOtherEntry = aImplOtherEntries;
diff --git a/i18npool/source/isolang/mslangid.cxx b/i18npool/source/isolang/mslangid.cxx
index b3319aa..e417f33 100644
--- a/i18npool/source/isolang/mslangid.cxx
+++ b/i18npool/source/isolang/mslangid.cxx
@@ -148,6 +148,13 @@ void MsLangId::Conversion::convertLanguageToLocale( LanguageType nLang,
if (!rLocale.Variant.isEmpty())
rLocale.Variant = rtl::OUString();
convertLanguageToIsoNames( nLang, rLocale.Language, rLocale.Country);
+ /* FIXME: this x-... is temporary until conversion will be moved up to
+ * LanguageTag */
+ if (rLocale.Language.startsWith( "x-"))
+ {
+ rLocale.Variant = rLocale.Language;
+ rLocale.Language = "qlt";
+ }
}
@@ -178,8 +185,11 @@ LanguageType MsLangId::Conversion::convertLocaleToLanguage(
if (rLocale.Language.isEmpty())
return LANGUAGE_SYSTEM;
- LanguageType nRet = convertIsoNamesToLanguage( rLocale.Language,
- rLocale.Country);
+ /* FIXME: this x-... is temporary until conversion will be moved up to
+ * LanguageTag */
+ LanguageType nRet = ((!rLocale.Variant.isEmpty() && rLocale.Variant.startsWithIgnoreAsciiCase( "x-")) ?
+ convertPrivateUseToLanguage( rLocale.Variant) :
+ convertIsoNamesToLanguage( rLocale.Language, rLocale.Country));
if (nRet == LANGUAGE_DONTKNOW)
nRet = LANGUAGE_SYSTEM;
commit a0edc3fc9cc77172aec6d865e4aaf2500229fd96
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 27 18:48:02 2013 +0100
rtl::OUString to OUString
Change-Id: I2ce2b88532a22a8f0379605523e5e67b974bb6ba
diff --git a/i18npool/inc/i18npool/languagetag.hxx b/i18npool/inc/i18npool/languagetag.hxx
index 7dedc8f..5b88542 100644
--- a/i18npool/inc/i18npool/languagetag.hxx
+++ b/i18npool/inc/i18npool/languagetag.hxx
@@ -45,7 +45,7 @@ public:
so specifying bCanonicalize=false is not a guarantee that the tag will
stay identical to what was passed.
*/
- explicit LanguageTag( const rtl::OUString & rBcp47LanguageTag, bool bCanonicalize = false );
+ explicit LanguageTag( const OUString & rBcp47LanguageTag, bool bCanonicalize = false );
/** Init LanguageTag with Locale. */
explicit LanguageTag( const com::sun::star::lang::Locale & rLocale );
@@ -59,7 +59,7 @@ public:
country to replace the MsLangId::convert...IsoNames...() calls. Avoid
use in new code.
*/
- explicit LanguageTag( const rtl::OUString& rLanguage, const rtl::OUString& rCountry );
+ explicit LanguageTag( const OUString& rLanguage, const OUString& rCountry );
/** Init LanguageTag with rtl_Locale.
@@ -78,7 +78,7 @@ public:
locale to the real locale used.
If FALSE, return an empty OUString for such a tag.
*/
- const rtl::OUString & getBcp47( bool bResolveSystem = true ) const;
+ const OUString & getBcp47( bool bResolveSystem = true ) const;
/** Obtain language tag as Locale.
@@ -118,13 +118,13 @@ public:
Always resolves an empty tag to the system locale.
*/
- void getIsoLanguageCountry( rtl::OUString& rLanguage, rtl::OUString& rCountry ) const;
+ void getIsoLanguageCountry( OUString& rLanguage, OUString& rCountry ) const;
/** Get ISO 639 language code, or BCP 47 language.
Always resolves an empty tag to the system locale.
*/
- rtl::OUString getLanguage() const;
+ OUString getLanguage() const;
/** Get ISO 15924 script code, if not the default script according to
BCP 47. For default script an empty string is returned.
@@ -133,7 +133,7 @@ public:
Always resolves an empty tag to the system locale.
*/
- rtl::OUString getScript() const;
+ OUString getScript() const;
/** Get combined language and script code, separated by '-' if
non-default script, if default script only language.
@@ -142,21 +142,21 @@ public:
Always resolves an empty tag to the system locale.
*/
- rtl::OUString getLanguageAndScript() const;
+ OUString getLanguageAndScript() const;
/** Get ISO 3166 country alpha code. Empty if the BCP 47 tags denote a
region not expressable as 2 character country code.
Always resolves an empty tag to the system locale.
*/
- rtl::OUString getCountry() const;
+ OUString getCountry() const;
/** Get BCP 47 region tag, which may be an ISO 3166 country alpha code or
any other BCP 47 region tag.
Always resolves an empty tag to the system locale.
*/
- rtl::OUString getRegion() const;
+ OUString getRegion() const;
/** If language tag has a non-default script specified.
*/
@@ -197,7 +197,7 @@ public:
/** Reset with existing BCP 47 language tag string. See ctor. */
- void reset( const rtl::OUString & rBcp47LanguageTag, bool bCanonicalize = false );
+ void reset( const OUString & rBcp47LanguageTag, bool bCanonicalize = false );
/** Reset with Locale. */
void reset( const com::sun::star::lang::Locale & rLocale );
@@ -272,10 +272,10 @@ private:
};
mutable com::sun::star::lang::Locale maLocale;
- mutable rtl::OUString maBcp47;
- mutable rtl::OUString maCachedLanguage; ///< cache getLanguage()
- mutable rtl::OUString maCachedScript; ///< cache getScript()
- mutable rtl::OUString maCachedCountry; ///< cache getCountry()
+ mutable OUString maBcp47;
+ mutable OUString maCachedLanguage; ///< cache getLanguage()
+ mutable OUString maCachedScript; ///< cache getScript()
+ mutable OUString maCachedCountry; ///< cache getCountry()
mutable void* mpImplLangtag; ///< actually lt_tag_t pointer, encapsulated
mutable LanguageType mnLangID;
mutable Decision meIsValid;
@@ -302,9 +302,9 @@ private:
bool canonicalize();
- rtl::OUString getLanguageFromLangtag();
- rtl::OUString getScriptFromLangtag();
- rtl::OUString getRegionFromLangtag();
+ OUString getLanguageFromLangtag();
+ OUString getScriptFromLangtag();
+ OUString getRegionFromLangtag();
void resetVars();
@@ -315,9 +315,9 @@ private:
*/
bool cacheSimpleLSC();
- static bool isIsoLanguage( const rtl::OUString& rLanguage );
- static bool isIsoScript( const rtl::OUString& rScript );
- static bool isIsoCountry( const rtl::OUString& rRegion );
+ static bool isIsoLanguage( const OUString& rLanguage );
+ static bool isIsoScript( const OUString& rScript );
+ static bool isIsoCountry( const OUString& rRegion );
/** Of a simple language tag of the form lll[-Ssss][-CC] (i.e. one that
would fulfill the isIsoODF() condition) extract the portions.
@@ -326,10 +326,10 @@ private:
@return TRUE if it detected a simple tag, else FALSE.
*/
- static bool simpleExtract( const rtl::OUString& rBcp47,
- rtl::OUString& rLanguage,
- rtl::OUString& rScript,
- rtl::OUString& rCountry );
+ static bool simpleExtract( const OUString& rBcp47,
+ OUString& rLanguage,
+ OUString& rScript,
+ OUString& rCountry );
};
#endif // INCLUDED_I18NPOOL_LANGUAGETAG_HXX
diff --git a/i18npool/source/languagetag/languagetag.cxx b/i18npool/source/languagetag/languagetag.cxx
index 2386274..e43bfe3 100644
--- a/i18npool/source/languagetag/languagetag.cxx
+++ b/i18npool/source/languagetag/languagetag.cxx
@@ -145,7 +145,7 @@ void LiblantagDataRef::setupDataPath()
lt_db_set_datadir( maDataPath.getStr());
}
-LanguageTag::LanguageTag( const rtl::OUString & rBcp47LanguageTag, bool bCanonicalize )
+LanguageTag::LanguageTag( const OUString & rBcp47LanguageTag, bool bCanonicalize )
:
maBcp47( rBcp47LanguageTag),
mpImplLangtag( NULL),
@@ -209,7 +209,7 @@ LanguageTag::LanguageTag( LanguageType nLanguage )
}
-LanguageTag::LanguageTag( const rtl::OUString& rLanguage, const rtl::OUString& rCountry )
+LanguageTag::LanguageTag( const OUString& rLanguage, const OUString& rCountry )
:
maLocale( rLanguage, rCountry, ""),
mpImplLangtag( NULL),
@@ -353,7 +353,7 @@ void LanguageTag::resetVars()
}
-void LanguageTag::reset( const rtl::OUString & rBcp47LanguageTag, bool bCanonicalize )
+void LanguageTag::reset( const OUString & rBcp47LanguageTag, bool bCanonicalize )
{
resetVars();
maBcp47 = rBcp47LanguageTag;
@@ -684,7 +684,7 @@ void LanguageTag::convertFromRtlLocale()
}
-const rtl::OUString & LanguageTag::getBcp47( bool bResolveSystem ) const
+const OUString & LanguageTag::getBcp47( bool bResolveSystem ) const
{
if (!bResolveSystem && mbSystemLocale)
return theEmptyBcp47::get();
@@ -699,7 +699,7 @@ const rtl::OUString & LanguageTag::getBcp47( bool bResolveSystem ) const
}
-rtl::OUString LanguageTag::getLanguageFromLangtag()
+OUString LanguageTag::getLanguageFromLangtag()
{
OUString aLanguage;
if (meIsLiblangtagNeeded != DECISION_NO && !mpImplLangtag)
@@ -726,7 +726,7 @@ rtl::OUString LanguageTag::getLanguageFromLangtag()
}
-rtl::OUString LanguageTag::getScriptFromLangtag()
+OUString LanguageTag::getScriptFromLangtag()
{
OUString aScript;
if (meIsLiblangtagNeeded != DECISION_NO && !mpImplLangtag)
@@ -753,7 +753,7 @@ rtl::OUString LanguageTag::getScriptFromLangtag()
}
-rtl::OUString LanguageTag::getRegionFromLangtag()
+OUString LanguageTag::getRegionFromLangtag()
{
OUString aRegion;
if (meIsLiblangtagNeeded != DECISION_NO && !mpImplLangtag)
@@ -817,7 +817,7 @@ LanguageType LanguageTag::getLanguageType( bool bResolveSystem ) const
}
-void LanguageTag::getIsoLanguageCountry( rtl::OUString& rLanguage, rtl::OUString& rCountry ) const
+void LanguageTag::getIsoLanguageCountry( OUString& rLanguage, OUString& rCountry ) const
{
if (!isIsoLocale())
{
@@ -848,7 +848,7 @@ bool isUpperAscii( sal_Unicode c )
// static
-bool LanguageTag::isIsoLanguage( const rtl::OUString& rLanguage )
+bool LanguageTag::isIsoLanguage( const OUString& rLanguage )
{
/* TODO: ignore case? For now let's see where rubbish is used. */
bool b2chars;
@@ -865,7 +865,7 @@ bool LanguageTag::isIsoLanguage( const rtl::OUString& rLanguage )
// static
-bool LanguageTag::isIsoCountry( const rtl::OUString& rRegion )
+bool LanguageTag::isIsoCountry( const OUString& rRegion )
{
/* TODO: ignore case? For now let's see where rubbish is used. */
if (rRegion.isEmpty() ||
@@ -878,7 +878,7 @@ bool LanguageTag::isIsoCountry( const rtl::OUString& rRegion )
// static
-bool LanguageTag::isIsoScript( const rtl::OUString& rScript )
+bool LanguageTag::isIsoScript( const OUString& rScript )
{
/* TODO: ignore case? For now let's see where rubbish is used. */
if (rScript.isEmpty() ||
@@ -894,7 +894,7 @@ bool LanguageTag::isIsoScript( const rtl::OUString& rScript )
}
-rtl::OUString LanguageTag::getLanguage() const
+OUString LanguageTag::getLanguage() const
{
if (!mbCachedLanguage)
{
@@ -905,7 +905,7 @@ rtl::OUString LanguageTag::getLanguage() const
}
-rtl::OUString LanguageTag::getScript() const
+OUString LanguageTag::getScript() const
{
if (!mbCachedScript)
{
@@ -916,7 +916,7 @@ rtl::OUString LanguageTag::getScript() const
}
-rtl::OUString LanguageTag::getLanguageAndScript() const
+OUString LanguageTag::getLanguageAndScript() const
{
OUString aLanguageScript( getLanguage());
OUString aScript( getScript());
@@ -930,7 +930,7 @@ rtl::OUString LanguageTag::getLanguageAndScript() const
}
-rtl::OUString LanguageTag::getCountry() const
+OUString LanguageTag::getCountry() const
{
if (!mbCachedCountry)
{
@@ -943,7 +943,7 @@ rtl::OUString LanguageTag::getCountry() const
}
-rtl::OUString LanguageTag::getRegion() const
+OUString LanguageTag::getRegion() const
{
return const_cast<LanguageTag*>(this)->getRegionFromLangtag();
}
@@ -1115,10 +1115,10 @@ bool LanguageTag::operator!=( const LanguageTag & rLanguageTag ) const
// static
-bool LanguageTag::simpleExtract( const rtl::OUString& rBcp47,
- rtl::OUString& rLanguage,
- rtl::OUString& rScript,
- rtl::OUString& rCountry )
+bool LanguageTag::simpleExtract( const OUString& rBcp47,
+ OUString& rLanguage,
+ OUString& rScript,
+ OUString& rCountry )
{
bool bRet = false;
const sal_Int32 nLen = rBcp47.getLength();
commit 6558e62d58d0daf1d4a2562ca4618eb1083f30d4
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 27 18:05:17 2013 +0100
defined some x-... privateuse language tags
Change-Id: I1a4e00c677f7e5012831c0b36290c8585e45e474
diff --git a/i18npool/inc/i18npool/lang.h b/i18npool/inc/i18npool/lang.h
index dc55f3f..b761fff 100644
--- a/i18npool/inc/i18npool/lang.h
+++ b/i18npool/inc/i18npool/lang.h
@@ -566,6 +566,10 @@ typedef unsigned short LanguageType;
#define LANGUAGE_USER_YOMBE 0x0684
#define LANGUAGE_USER_YOMBE_CONGO 0x8284 /* makeLangID( 0x20, getPrimaryLanguage( LANGUAGE_USER_YOMBE)) */
#define LANGUAGE_USER_SIDAMA 0x0685
+
+#define LANGUAGE_USER_PRIV_COMMENT 0xFFEC /* privateuse "x-comment", primary 0x3ec, sub 0x3f */
+#define LANGUAGE_USER_PRIV_DEFAULT 0xFFED /* privateuse "x-default", primary 0x3ed, sub 0x3f */
+#define LANGUAGE_USER_PRIV_NOTRANSLATE 0xFFEE /* privateuse "x-no-translate" (sic!), primary 0x3ee, sub 0x3f */
#define LANGUAGE_MULTIPLE 0xFFEF /* multiple languages, primary 0x3ef, sub 0x3f */
#define LANGUAGE_UNDETERMINED 0xFFF0 /* undetermined language, primary 0x3f0, sub 0x3f */
#define LANGUAGE_USER_SYSTEM_CONFIG 0xFFFE /* not a locale, to be used only in configuration context to obtain system default, primary 0x3fe, sub 0x3f */
diff --git a/i18npool/source/isolang/isolang.cxx b/i18npool/source/isolang/isolang.cxx
index 1ae850d..ba3b4e5 100644
--- a/i18npool/source/isolang/isolang.cxx
+++ b/i18npool/source/isolang/isolang.cxx
@@ -628,6 +628,16 @@ static IsoLangOtherEntry const aImplOtherEntries[] =
{ LANGUAGE_DONTKNOW, NULL } // marks end of table
};
+
+// in this table are only privateuse names
+static IsoLangOtherEntry const aImplPrivateUseEntries[] =
+{
+ { LANGUAGE_USER_PRIV_NOTRANSLATE, "x-no-translate" }, //! not BCP47 but legacy in .xcu configmgr
+ { LANGUAGE_USER_PRIV_DEFAULT, "x-default" },
+ { LANGUAGE_USER_PRIV_COMMENT, "x-comment" },
+ { LANGUAGE_DONTKNOW, NULL } // marks end of table
+};
+
// =======================================================================
// static
@@ -667,6 +677,20 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
}
while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
+ // Look for privateuse definitions.
+ const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
+ do
+ {
+ if ( pPrivateEntry->mnLang == nLang )
+ {
+ rLangStr = rtl::OUString::createFromAscii( pPrivateEntry->mpLangStr );
+ rCountry = OUString();
+ return;
+ }
+ ++pPrivateEntry;
+ }
+ while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
+
// not found
rLangStr = rtl::OUString();
rCountry = rtl::OUString();
@@ -910,6 +934,16 @@ LanguageType MsLangId::Conversion::convertIsoNamesToLanguage( const rtl::OUStrin
aLowerLang = aUpperCountry.toAsciiLowerCase();
}
+ // Look for privateuse definitions.
+ const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
+ do
+ {
+ if ( aLowerLang.equalsAscii( pPrivateEntry->mpLangStr ) )
+ return pPrivateEntry->mnLang;
+ ++pPrivateEntry;
+ }
+ while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
+
// Now look for all other definitions, which are not standard
const IsoLangOtherEntry* pOtherEntry = aImplOtherEntries;
do
commit 222414f92e0ec478e4dcdd30fadf3ba7a4dcda2b
Author: Eike Rathke <erack at redhat.com>
Date: Wed Mar 27 16:08:00 2013 +0100
typo
Change-Id: I7e19c2b8a05a86f9995a879b5296f5ca93d3ef87
diff --git a/comphelper/README b/comphelper/README
index aa31ab3..e277935 100644
--- a/comphelper/README
+++ b/comphelper/README
@@ -1,4 +1,4 @@
Helper functionality for implementing UNO components
...anything not generic/mature enough to end up in URE's stable interface at
-cpphelper etc.
+cppuhelper etc.
More information about the Libreoffice-commits
mailing list