[Libreoffice-commits] core.git: 11 commits - i18nlangtag/qa i18nlangtag/source include/i18nlangtag rsc/source
Eike Rathke
erack at redhat.com
Fri Aug 23 14:09:36 PDT 2013
i18nlangtag/qa/cppunit/test_languagetag.cxx | 23 +--
i18nlangtag/source/isolang/isolang.cxx | 163 ++++++-------------------
i18nlangtag/source/isolang/mslangid.cxx | 32 ----
i18nlangtag/source/languagetag/languagetag.cxx | 22 ---
include/i18nlangtag/mslangid.hxx | 53 ++------
rsc/source/parser/rscibas.cxx | 10 -
6 files changed, 82 insertions(+), 221 deletions(-)
New commits:
commit 087ee66013916bd009eb0b29460ef1868b4d755c
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 22:27:14 2013 +0200
encapsulate IsoLangEntry again
Change-Id: I66475eb3914b07b4c7a045e295ef77a5de9439d4
diff --git a/i18nlangtag/qa/cppunit/test_languagetag.cxx b/i18nlangtag/qa/cppunit/test_languagetag.cxx
index c64d199..838f69b 100644
--- a/i18nlangtag/qa/cppunit/test_languagetag.cxx
+++ b/i18nlangtag/qa/cppunit/test_languagetag.cxx
@@ -299,25 +299,24 @@ void TestLanguageTag::testAllTags()
void TestLanguageTag::testAllIsoLangEntries()
{
- const MsLangId::IsoLangEntry* pLangEntry;
- sal_Int32 nIndex = 0;
- while (((pLangEntry = MsLangId::getIsoLangEntry( nIndex++ )) != NULL) && (pLangEntry->mnLang != LANGUAGE_DONTKNOW))
+ const ::std::vector< MsLangId::LanguagetagMapping > aList( MsLangId::getDefinedLanguagetags());
+ for (::std::vector< MsLangId::LanguagetagMapping >::const_iterator it( aList.begin()); it != aList.end(); ++it)
{
- LanguageTag aTagString( pLangEntry->getTagString(), true);
- LanguageTag aTagID( pLangEntry->mnLang);
- if (pLangEntry->getTagString() != aTagString.getBcp47())
+ LanguageTag aTagString( (*it).maBcp47, true);
+ LanguageTag aTagID( (*it).mnLang);
+ if ((*it).maBcp47 != aTagString.getBcp47())
{
- OString aMessage( OUStringToOString( pLangEntry->getTagString(), RTL_TEXTENCODING_ASCII_US));
+ OString aMessage( OUStringToOString( (*it).maBcp47, RTL_TEXTENCODING_ASCII_US));
aMessage += " -> " + OUStringToOString( aTagString.getBcp47(), RTL_TEXTENCODING_ASCII_US);
- CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), pLangEntry->getTagString() == aTagString.getBcp47());
+ CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), (*it).maBcp47 == aTagString.getBcp47());
}
- if (pLangEntry->getTagString() != aTagID.getBcp47())
+ if ((*it).maBcp47 != aTagID.getBcp47())
{
// There are multiple mappings, ID must be equal after conversions.
LanguageTag aTagBack( aTagID.getBcp47(), true);
if (aTagString.getLanguageType() != aTagBack.getLanguageType())
{
- OString aMessage( OUStringToOString( pLangEntry->getTagString(), RTL_TEXTENCODING_ASCII_US));
+ OString aMessage( OUStringToOString( (*it).maBcp47, RTL_TEXTENCODING_ASCII_US));
aMessage += " " + OString::number( aTagString.getLanguageType(), 16) +
" -> " + OString::number( aTagBack.getLanguageType(), 16);
CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), aTagString.getLanguageType() == aTagBack.getLanguageType());
@@ -327,13 +326,13 @@ void TestLanguageTag::testAllIsoLangEntries()
// This does not hold, there are cases like 'ar'
// LANGUAGE_ARABIC_PRIMARY_ONLY that when mapped back results in
// 'ar-SA' as default locale.
- if (pLangEntry->mnLang != aTagString.getLanguageType())
+ if ((*it).mnLang != aTagString.getLanguageType())
{
// There are multiple mappings, string must be equal after conversions.
LanguageTag aTagBack( aTagString.getLanguageType());
if (aTagID.getBcp47() != aTagBack.getBcp47())
{
- OString aMessage( OUStringToOString( pLangEntry->getTagString(), RTL_TEXTENCODING_ASCII_US));
+ OString aMessage( OUStringToOString( (*it).maBcp47, RTL_TEXTENCODING_ASCII_US));
aMessage += " " + OUStringToOString( aTagID.getBcp47(), RTL_TEXTENCODING_ASCII_US) +
" -> " + OUStringToOString( aTagBack.getBcp47(), RTL_TEXTENCODING_ASCII_US);
CPPUNIT_ASSERT_MESSAGE( aMessage.getStr(), aTagID.getBcp47() == aTagBack.getBcp47());
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 26ad88f..0373548 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -27,6 +27,16 @@
// =======================================================================
+struct IsoLangEntry
+{
+ LanguageType mnLang;
+ sal_Char maLangStr[4];
+ sal_Char maCountry[3];
+
+ /** Obtain a language tag string with '-' separator. */
+ OUString getTagString() const;
+};
+
struct IsoLangEngEntry
{
LanguageType mnLang;
@@ -89,7 +99,7 @@ struct IsoLangOtherEntry
* LANGUAGE_AZERI LANGUAGE_URDU LANGUAGE_KASHMIRI
*/
-static MsLangId::IsoLangEntry const aImplIsoLangEntries[] =
+static IsoLangEntry const aImplIsoLangEntries[] =
{
// MS-LANGID codes ISO639-1/2/3 ISO3166
{ LANGUAGE_ENGLISH, "en", "" },
@@ -524,10 +534,10 @@ static MsLangId::IsoLangEntry const aImplIsoLangEntries[] =
{ LANGUAGE_DONTKNOW, "", "" } // marks end of table
};
-static MsLangId::IsoLangEntry aLastResortFallbackEntry =
+static IsoLangEntry aLastResortFallbackEntry =
{ LANGUAGE_ENGLISH_US, "en", "US" };
-OUString MsLangId::IsoLangEntry::getTagString() const
+OUString IsoLangEntry::getTagString() const
{
if (maCountry[0])
return OUString( OUString::createFromAscii( maLangStr) + "-" + OUString::createFromAscii( maCountry));
@@ -695,7 +705,7 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
// -----------------------------------------------------------------------
-static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
+static const IsoLangEntry & lcl_lookupFallbackEntry(
const ::com::sun::star::lang::Locale & rLocale )
{
// language is lower case in table
@@ -705,8 +715,8 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
sal_Int32 nCountryLen = aUpperCountry.getLength();
// Search for locale and remember first lang-only.
- const MsLangId::IsoLangEntry* pFirstLang = NULL;
- const MsLangId::IsoLangEntry* pEntry = aImplIsoLangEntries;
+ const IsoLangEntry* pFirstLang = NULL;
+ const IsoLangEntry* pEntry = aImplIsoLangEntries;
do
{
if (aLowerLang.equalsAscii( pEntry->maLangStr))
@@ -762,7 +772,7 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
::com::sun::star::lang::Locale MsLangId::Conversion::lookupFallbackLocale(
const ::com::sun::star::lang::Locale & rLocale )
{
- const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( rLocale);
+ const IsoLangEntry& rEntry = lcl_lookupFallbackEntry( rLocale);
return ::com::sun::star::lang::Locale(
OUString::createFromAscii( rEntry.maLangStr),
OUString::createFromAscii( rEntry.maCountry),
@@ -985,15 +995,16 @@ LanguageType MsLangId::convertUnxByteStringToLanguage(
return Conversion::convertIsoNamesToLanguage( aLang, aCountry );
}
-// -----------------------------------------------------------------------
-// pass one IsoLangEntry to the outer world of the resource compiler
// static
-const MsLangId::IsoLangEntry* MsLangId::getIsoLangEntry( size_t nIndex )
+::std::vector< MsLangId::LanguagetagMapping > MsLangId::getDefinedLanguagetags()
{
- if (nIndex < SAL_N_ELEMENTS(aImplIsoLangEntries))
- return &aImplIsoLangEntries[ nIndex];
- return 0;
+ ::std::vector< LanguagetagMapping > aVec;
+ for (const IsoLangEntry* pEntry = aImplIsoLangEntries; pEntry->mnLang != LANGUAGE_DONTKNOW; ++pEntry)
+ {
+ aVec.push_back( LanguagetagMapping( pEntry->getTagString(), pEntry->mnLang));
+ }
+ return aVec;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index 37bc728..14386ec 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -25,6 +25,7 @@
#include "i18nlangtag/i18nlangtagdllapi.h"
#include "i18nlangtag/lang.h"
#include <com/sun/star/lang/Locale.hpp>
+#include <vector>
/** Methods related to Microsoft language IDs. For details about MS-LANGIDs
please see lang.h */
@@ -173,26 +174,19 @@ public:
// ---------------------------------------------------------------------------
- /** @internal - Access to fields of an element of the simple conversion table.
- For resource compiler build environment usage only! */
- struct IsoLangEntry
+ struct LanguagetagMapping
{
- LanguageType mnLang;
- sal_Char maLangStr[4];
- sal_Char maCountry[3];
+ OUString maBcp47;
+ LanguageType mnLang;
- /** Obtain a language tag string with '-' separator. */
- I18NLANGTAG_DLLPUBLIC OUString getTagString() const;
+ LanguagetagMapping( const OUString & rBcp47, LanguageType nLang ) : maBcp47(rBcp47), mnLang(nLang) {}
};
- /** @internal - Return a pointer to the IsoLangEntry of the underlying table,
- matching the offset passed by nIndex. Only meaningful for the resource
- compiler to build a list of known languages.
-
- @returns address of IsoLangEntry, or NULL pointer if nIndex exceeds the
- table elements' count.
+ /** @internal - Obtain a list of known locales (i.e. those that have a
+ defined mapping between MS-LangID and ISO codes or tags) as BCP 47
+ language tag strings.
*/
- static const IsoLangEntry* getIsoLangEntry( size_t nIndex );
+ static ::std::vector< LanguagetagMapping > getDefinedLanguagetags();
// ---------------------------------------------------------------------------
diff --git a/rsc/source/parser/rscibas.cxx b/rsc/source/parser/rscibas.cxx
index f4f05b5..dda165c 100644
--- a/rsc/source/parser/rscibas.cxx
+++ b/rsc/source/parser/rscibas.cxx
@@ -81,18 +81,18 @@ void RscLangEnum::Init( RscNameTable& rNames )
sal_Int32 nIndex = 0;
mnLangId = 0x400; // stay away from selfdefined...
- const MsLangId::IsoLangEntry* pLangEntry;
- while ( NULL != ( pLangEntry = MsLangId::getIsoLangEntry( nIndex )) && ( pLangEntry->mnLang != LANGUAGE_DONTKNOW ))
+ const ::std::vector< MsLangId::LanguagetagMapping > aList( MsLangId::getDefinedLanguagetags());
+ for (::std::vector< MsLangId::LanguagetagMapping >::const_iterator iTag( aList.begin()); iTag != aList.end(); ++iTag)
{
#if OSL_DEBUG_LEVEL > 2
fprintf( stderr, "ISO Language in : %d, 0x%04x, %s\n",
(int)nIndex,
- (unsigned)pLangEntry->mnLang,
- OUStringToOString( pLangEntry->getTagString(), RTL_TEXTENCODING_ASCII_US).getStr());
+ (unsigned)(*iTag).mnLang,
+ OUStringToOString( (*iTag).maBcp47, RTL_TEXTENCODING_ASCII_US).getStr());
fprintf( stderr, "ISO Language out:");
#endif
- LanguageTag aLanguageTag( pLangEntry->getTagString());
+ LanguageTag aLanguageTag( (*iTag).maBcp47);
::std::vector< OUString > aFallbacks( aLanguageTag.getFallbackStrings());
for (::std::vector< OUString >::const_iterator it( aFallbacks.begin()); it != aFallbacks.end(); ++it)
{
commit 5b2a740b9cacd1e0e4d2164647e89fb6b1e6c39e
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 20:37:46 2013 +0200
use sensible indenting
Change-Id: Iea3c9e579e8236a9b7e1a57b4e7ec1c760f278e9
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 5fa7d5c..26ad88f 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -946,8 +946,7 @@ LanguageType MsLangId::convertUnxByteStringToLanguage(
if (nAtPos >= 0)
aAtString = rString.copy( nAtPos+1 );
- if ( ((nLangSepPos >= 0) && (nLangSepPos > nCountrySepPos))
- || ((nLangSepPos < 0)) )
+ if (((nLangSepPos >= 0) && (nLangSepPos > nCountrySepPos)) || (nLangSepPos < 0))
{
// eg. "el.sun_eu_greek", "tchinese", "es.ISO8859-15"
aLang = rString.copy( 0, nCountrySepPos );
@@ -969,14 +968,14 @@ LanguageType MsLangId::convertUnxByteStringToLanguage(
const IsoLangGLIBCModifiersEntry* pGLIBCModifiersEntry = aImplIsoLangGLIBCModifiersEntries;
do
{ // avoid embedded \0 warning
- if (( aLowerLang.equals( static_cast< const char* >( pGLIBCModifiersEntry->maLangStr ))) &&
- ( aAtString.equals( static_cast< const char* >( pGLIBCModifiersEntry->maAtString ))))
+ if (aLowerLang.equals( static_cast< const char* >( pGLIBCModifiersEntry->maLangStr )) &&
+ aAtString.equals( static_cast< const char* >( pGLIBCModifiersEntry->maAtString )))
{
- if ( aUpperCountry.isEmpty() ||
- aUpperCountry.equals( static_cast< const char* >( pGLIBCModifiersEntry->maCountry )))
- {
+ if (aUpperCountry.isEmpty() ||
+ aUpperCountry.equals( static_cast< const char* >( pGLIBCModifiersEntry->maCountry )))
+ {
return pGLIBCModifiersEntry->mnLang;
- }
+ }
}
++pGLIBCModifiersEntry;
}
commit fc0f7eaa73b671aea03b9182db3391382d6e8eb8
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 20:30:12 2013 +0200
do not convert to IsoLangNoneStdEntry
Change-Id: I94ba55f2ab8e9b495d8f02b137c940fe5173b8fd
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 527ace3..5fa7d5c 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -675,23 +675,6 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
}
while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
- // Search for LangID if we didn't find a specific ISO combination.
- // All entries in this table are allowed for mime specifications,
- // but not defined ISO combinations.
- const IsoLangNoneStdEntry* pNoneStdEntry = aImplIsoNoneStdLangEntries;
- do
- {
- if ( pNoneStdEntry->mnLang == nLang )
- {
- rLocale.Language = OUString::createFromAscii( pNoneStdEntry->maLangStr );
- rLocale.Country = OUString::createFromAscii( pNoneStdEntry->maCountry );
- rLocale.Variant = OUString();
- return;
- }
- ++pNoneStdEntry;
- }
- while ( pNoneStdEntry->mnLang != LANGUAGE_DONTKNOW );
-
// Look for privateuse definitions.
const IsoLangOtherEntry* pPrivateEntry = aImplPrivateUseEntries;
do
commit 5cc7914d9199833d4ef03afe62f03d88693ed1f8
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 20:22:04 2013 +0200
do not resolve system language here
Change-Id: I77b8a3d750ba3a629252805342ab385731238ee3
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 31ecf08..527ace3 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -660,9 +660,6 @@ static IsoLangOtherEntry const aImplPrivateUseEntries[] =
void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
::com::sun::star::lang::Locale & rLocale )
{
- if ( nLang == LANGUAGE_SYSTEM )
- nLang = MsLangId::getSystemLanguage();
-
// Search for LangID (in this table we find only defined ISO combinations)
const IsoLangEntry* pEntry = aImplIsoLangEntries;
do
commit 54e3af6ab108774bc0065be92798137e403ea25c
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 20:11:15 2013 +0200
passed rLocale remains unchanged if no mapping found
Change-Id: I4d1494dc5cba7a92fb067191477c3cbba46b056d
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 1e7ac84..31ecf08 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -710,10 +710,7 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
}
while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
- // Not found. The effective result is the empty SYSTEM locale.
- rLocale.Language = OUString();
- rLocale.Country = OUString();
- rLocale.Variant = OUString();
+ // Not found. Passed rLocale argument remains unchanged.
}
// -----------------------------------------------------------------------
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index f33b125..37bc728 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -242,7 +242,12 @@ public:
I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale convertLanguageToLocale(
LanguageType nLang, bool bResolveSystem );
- /** Used by convertLanguageToLocale(LanguageType,bool) */
+ /** Used by convertLanguageToLocale(LanguageType,bool)
+
+ @return rLocale set to mapped values, unchanged if no mapping was
+ found. E.g. pass empty Locale to obtain empty SYSTEM locale
+ for that case.
+ */
I18NLANGTAG_DLLPRIVATE static void convertLanguageToLocaleImpl(
LanguageType nLang, ::com::sun::star::lang::Locale & rLocale );
commit f3e124f4bd759095d977a9639d226ed582ed76d7
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 20:05:09 2013 +0200
moved privateuse handling to convertLanguageToLocaleImpl()
Change-Id: Id9cdd5734f54fd4fca43f5e0d928d9cb37e8f63f
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 3edc599..1e7ac84 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -23,6 +23,7 @@
#include <rtl/strbuf.hxx>
#include "i18nlangtag/mslangid.hxx"
+#include "i18nlangtag/languagetag.hxx"
// =======================================================================
@@ -670,6 +671,7 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
{
rLocale.Language = OUString::createFromAscii( pEntry->maLangStr );
rLocale.Country = OUString::createFromAscii( pEntry->maCountry );
+ rLocale.Variant = OUString();
return;
}
++pEntry;
@@ -686,6 +688,7 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
{
rLocale.Language = OUString::createFromAscii( pNoneStdEntry->maLangStr );
rLocale.Country = OUString::createFromAscii( pNoneStdEntry->maCountry );
+ rLocale.Variant = OUString();
return;
}
++pNoneStdEntry;
@@ -698,17 +701,19 @@ void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
{
if ( pPrivateEntry->mnLang == nLang )
{
- rLocale.Language = OUString::createFromAscii( pPrivateEntry->mpLangStr );
+ rLocale.Language = I18NLANGTAG_QLT;
rLocale.Country = OUString();
+ rLocale.Variant = OUString::createFromAscii( pPrivateEntry->mpLangStr );
return;
}
++pPrivateEntry;
}
while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
- // not found
+ // Not found. The effective result is the empty SYSTEM locale.
rLocale.Language = OUString();
rLocale.Country = OUString();
+ rLocale.Variant = OUString();
}
// -----------------------------------------------------------------------
diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx
index c31fde1..a4daef86 100644
--- a/i18nlangtag/source/isolang/mslangid.cxx
+++ b/i18nlangtag/source/isolang/mslangid.cxx
@@ -156,13 +156,6 @@ LanguageType MsLangId::resolveSystemLanguageByScriptType( LanguageType nLang, sa
if (bResolveSystem || nLang == LANGUAGE_DONTKNOW)
nLang = MsLangId::getRealLanguage( nLang);
convertLanguageToLocaleImpl( nLang, aLocale);
- /* FIXME: this x-... is temporary until conversion will be moved up to
- * LanguageTag. Also handle the nasty "*" joker as privateuse. */
- if (aLocale.Language.startsWith( "x-") || (aLocale.Language == "*"))
- {
- aLocale.Variant = aLocale.Language;
- aLocale.Language = "qlt";
- }
}
return aLocale;
}
commit 22c19620dc44b8f619936c7dbd4b07c6a372d2de
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 19:53:27 2013 +0200
convertLanguageToIsoNames() -> convertLanguageToLocaleImpl()
Change-Id: I4e34fb09a901a414f3106883d9ace1bff81311b5
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index e16e230..3edc599 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -656,8 +656,8 @@ static IsoLangOtherEntry const aImplPrivateUseEntries[] =
// =======================================================================
// static
-void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
- OUString& rLangStr, OUString& rCountry )
+void MsLangId::Conversion::convertLanguageToLocaleImpl( LanguageType nLang,
+ ::com::sun::star::lang::Locale & rLocale )
{
if ( nLang == LANGUAGE_SYSTEM )
nLang = MsLangId::getSystemLanguage();
@@ -668,8 +668,8 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
{
if ( pEntry->mnLang == nLang )
{
- rLangStr = OUString::createFromAscii( pEntry->maLangStr );
- rCountry = OUString::createFromAscii( pEntry->maCountry );
+ rLocale.Language = OUString::createFromAscii( pEntry->maLangStr );
+ rLocale.Country = OUString::createFromAscii( pEntry->maCountry );
return;
}
++pEntry;
@@ -684,8 +684,8 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
{
if ( pNoneStdEntry->mnLang == nLang )
{
- rLangStr = OUString::createFromAscii( pNoneStdEntry->maLangStr );
- rCountry = OUString::createFromAscii( pNoneStdEntry->maCountry );
+ rLocale.Language = OUString::createFromAscii( pNoneStdEntry->maLangStr );
+ rLocale.Country = OUString::createFromAscii( pNoneStdEntry->maCountry );
return;
}
++pNoneStdEntry;
@@ -698,8 +698,8 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
{
if ( pPrivateEntry->mnLang == nLang )
{
- rLangStr = OUString::createFromAscii( pPrivateEntry->mpLangStr );
- rCountry = OUString();
+ rLocale.Language = OUString::createFromAscii( pPrivateEntry->mpLangStr );
+ rLocale.Country = OUString();
return;
}
++pPrivateEntry;
@@ -707,8 +707,8 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
while ( pPrivateEntry->mnLang != LANGUAGE_DONTKNOW );
// not found
- rLangStr = OUString();
- rCountry = OUString();
+ rLocale.Language = OUString();
+ rLocale.Country = OUString();
}
// -----------------------------------------------------------------------
diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx
index 2e9ca7e..c31fde1 100644
--- a/i18nlangtag/source/isolang/mslangid.cxx
+++ b/i18nlangtag/source/isolang/mslangid.cxx
@@ -155,7 +155,7 @@ LanguageType MsLangId::resolveSystemLanguageByScriptType( LanguageType nLang, sa
// but not LANGUAGE_SYSTEM or others.
if (bResolveSystem || nLang == LANGUAGE_DONTKNOW)
nLang = MsLangId::getRealLanguage( nLang);
- convertLanguageToIsoNames( nLang, aLocale.Language, aLocale.Country);
+ convertLanguageToLocaleImpl( nLang, aLocale);
/* FIXME: this x-... is temporary until conversion will be moved up to
* LanguageTag. Also handle the nasty "*" joker as privateuse. */
if (aLocale.Language.startsWith( "x-") || (aLocale.Language == "*"))
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index da2e199..f33b125 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -243,8 +243,8 @@ public:
LanguageType nLang, bool bResolveSystem );
/** Used by convertLanguageToLocale(LanguageType,bool) */
- I18NLANGTAG_DLLPRIVATE static void convertLanguageToIsoNames(
- LanguageType nLang, OUString& rLangStr, OUString& rCountry );
+ I18NLANGTAG_DLLPRIVATE static void convertLanguageToLocaleImpl(
+ LanguageType nLang, ::com::sun::star::lang::Locale & rLocale );
I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
commit d85566a48e47c8b4788b77d7cce77803ff797352
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 19:28:36 2013 +0200
eliminated lookupFallbackLocale(LanguageType)
Change-Id: I2a2a983acbd8af0487e7148f9dee2a73dc314891
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index 6f4af1c..e16e230 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -713,73 +713,6 @@ void MsLangId::Conversion::convertLanguageToIsoNames( LanguageType nLang,
// -----------------------------------------------------------------------
-// -----------------------------------------------------------------------
-
-static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry( LanguageType nLang )
-{
- LanguageType nPrimary = MsLangId::getPrimaryLanguage( nLang);
-
- // Search for LangID and remember first lang-only.
- const MsLangId::IsoLangEntry* pFirstPrimary = NULL;
- const MsLangId::IsoLangEntry* pEntry = aImplIsoLangEntries;
- do
- {
- if (pEntry->mnLang == nLang)
- {
- if (*pEntry->maCountry)
- return *pEntry;
- switch (nLang)
- {
- // These are known to have no country assigned.
- case LANGUAGE_BASQUE:
- case LANGUAGE_USER_ESPERANTO:
- case LANGUAGE_USER_INTERLINGUA:
- case LANGUAGE_USER_LOJBAN:
- return *pEntry;
- default:
- ; // nothing
- }
- }
- if (!pFirstPrimary &&
- MsLangId::getPrimaryLanguage( pEntry->mnLang) == nPrimary)
- pFirstPrimary = pEntry;
- ++pEntry;
- }
- while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
-
- // Language not found at all => use default.
- if (!pFirstPrimary)
- return aLastResortFallbackEntry;
-
- // Search for first entry of primary language with any country.
- pEntry = pFirstPrimary;
- do
- {
- if (MsLangId::getPrimaryLanguage( pEntry->mnLang) == nLang)
- {
- if (*pEntry->maCountry)
- return *pEntry;
- }
- ++pEntry;
- }
- while ( pEntry->mnLang != LANGUAGE_DONTKNOW );
-
- return aLastResortFallbackEntry;
-}
-
-
-// static
-::com::sun::star::lang::Locale MsLangId::Conversion::lookupFallbackLocale( LanguageType nLang )
-{
- const MsLangId::IsoLangEntry& rEntry = lcl_lookupFallbackEntry( nLang);
- return ::com::sun::star::lang::Locale(
- OUString::createFromAscii( rEntry.maLangStr),
- OUString::createFromAscii( rEntry.maCountry),
- OUString());
-}
-
-// -----------------------------------------------------------------------
-
static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry(
const ::com::sun::star::lang::Locale & rLocale )
{
diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx
index f488e9c..2e9ca7e 100644
--- a/i18nlangtag/source/isolang/mslangid.cxx
+++ b/i18nlangtag/source/isolang/mslangid.cxx
@@ -195,9 +195,9 @@ LanguageType MsLangId::Conversion::convertLocaleToLanguage(
{
// empty language => LANGUAGE_SYSTEM
if (rLocale.Language.isEmpty())
- return Conversion::lookupFallbackLocale( MsLangId::getRealLanguage( LANGUAGE_SYSTEM));
-
- return Conversion::lookupFallbackLocale( rLocale);
+ return Conversion::lookupFallbackLocale( Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM, true));
+ else
+ return Conversion::lookupFallbackLocale( rLocale);
}
// static
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index c57f528..da2e199 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -249,10 +249,6 @@ public:
I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
const ::com::sun::star::lang::Locale & rLocale );
-
- /** Used by getFallbackLocale(Locale) */
- I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
- LanguageType nLang );
};
private:
commit 782808487510adae542ef25a9745d85f01d9dc38
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 17:32:05 2013 +0200
eliminated lookupFallbackLanguage(LanguageType)
Change-Id: I2c69fce56151d4afcf5a68c29fd6755ff4f3b8dd
diff --git a/i18nlangtag/source/isolang/isolang.cxx b/i18nlangtag/source/isolang/isolang.cxx
index a581b3e..6f4af1c 100644
--- a/i18nlangtag/source/isolang/isolang.cxx
+++ b/i18nlangtag/source/isolang/isolang.cxx
@@ -767,12 +767,6 @@ static const MsLangId::IsoLangEntry & lcl_lookupFallbackEntry( LanguageType nLan
return aLastResortFallbackEntry;
}
-// static
-LanguageType MsLangId::Conversion::lookupFallbackLanguage( LanguageType nLang )
-{
- return lcl_lookupFallbackEntry( nLang).mnLang;
-}
-
// static
::com::sun::star::lang::Locale MsLangId::Conversion::lookupFallbackLocale( LanguageType nLang )
diff --git a/i18nlangtag/source/languagetag/languagetag.cxx b/i18nlangtag/source/languagetag/languagetag.cxx
index 585929b..62e1d9c1 100644
--- a/i18nlangtag/source/languagetag/languagetag.cxx
+++ b/i18nlangtag/source/languagetag/languagetag.cxx
@@ -1120,22 +1120,12 @@ LanguageTag & LanguageTag::makeFallback()
{
if (!mbIsFallback)
{
- if (mbInitializedLangID)
- {
- LanguageType nLang1 = getLanguageType();
- LanguageType nLang2 = MsLangId::Conversion::lookupFallbackLanguage( nLang1);
- if (nLang1 != nLang2)
- reset( nLang2);
- }
- else
- {
- const lang::Locale& rLocale1 = getLocale();
- lang::Locale aLocale2( MsLangId::Conversion::lookupFallbackLocale( rLocale1));
- if ( rLocale1.Language != aLocale2.Language ||
- rLocale1.Country != aLocale2.Country ||
- rLocale1.Variant != aLocale2.Variant)
- reset( aLocale2);
- }
+ const lang::Locale& rLocale1 = getLocale( true);
+ lang::Locale aLocale2( MsLangId::Conversion::lookupFallbackLocale( rLocale1));
+ if ( rLocale1.Language != aLocale2.Language ||
+ rLocale1.Country != aLocale2.Country ||
+ rLocale1.Variant != aLocale2.Variant)
+ reset( aLocale2);
mbIsFallback = true;
}
return *this;
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index 433e326..c57f528 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -247,8 +247,6 @@ public:
LanguageType nLang, OUString& rLangStr, OUString& rCountry );
- I18NLANGTAG_DLLPRIVATE static LanguageType lookupFallbackLanguage( LanguageType nLang );
-
I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
const ::com::sun::star::lang::Locale & rLocale );
commit a829a352667d271408f791ee5e8a20dba844a5ff
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 17:01:35 2013 +0200
extra convertLanguageToLocale(LanguageType,Locale) is unneeded
Change-Id: I3a56e7cafeb2453b877582f6c2d1a705cb91723b
diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx
index 8ef2aa3..f488e9c 100644
--- a/i18nlangtag/source/isolang/mslangid.cxx
+++ b/i18nlangtag/source/isolang/mslangid.cxx
@@ -141,22 +141,6 @@ LanguageType MsLangId::resolveSystemLanguageByScriptType( LanguageType nLang, sa
return nLang;
}
-// static
-void MsLangId::Conversion::convertLanguageToLocale( LanguageType nLang,
- ::com::sun::star::lang::Locale & rLocale )
-{
- if (!rLocale.Variant.isEmpty())
- rLocale.Variant = OUString();
- convertLanguageToIsoNames( nLang, rLocale.Language, rLocale.Country);
- /* FIXME: this x-... is temporary until conversion will be moved up to
- * LanguageTag. Also handle the nasty "*" joker as privateuse. */
- if (rLocale.Language.startsWith( "x-") || (rLocale.Language == "*"))
- {
- rLocale.Variant = rLocale.Language;
- rLocale.Language = "qlt";
- }
-}
-
// static
::com::sun::star::lang::Locale MsLangId::Conversion::convertLanguageToLocale(
@@ -171,7 +155,14 @@ void MsLangId::Conversion::convertLanguageToLocale( LanguageType nLang,
// but not LANGUAGE_SYSTEM or others.
if (bResolveSystem || nLang == LANGUAGE_DONTKNOW)
nLang = MsLangId::getRealLanguage( nLang);
- convertLanguageToLocale( nLang, aLocale);
+ convertLanguageToIsoNames( nLang, aLocale.Language, aLocale.Country);
+ /* FIXME: this x-... is temporary until conversion will be moved up to
+ * LanguageTag. Also handle the nasty "*" joker as privateuse. */
+ if (aLocale.Language.startsWith( "x-") || (aLocale.Language == "*"))
+ {
+ aLocale.Variant = aLocale.Language;
+ aLocale.Language = "qlt";
+ }
}
return aLocale;
}
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index 4d05468..433e326 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -242,14 +242,7 @@ public:
I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale convertLanguageToLocale(
LanguageType nLang, bool bResolveSystem );
- /** Convert a LanguageType to a Locale, resolving LANGUAGE_SYSTEM.
-
- Used by convertLanguageToLocale(LanguageType,bool)
- */
- I18NLANGTAG_DLLPRIVATE static void convertLanguageToLocale(
- LanguageType nLang, ::com::sun::star::lang::Locale & rLocale );
-
- /** Used by convertLanguageToLocale(LanguageType,Locale) */
+ /** Used by convertLanguageToLocale(LanguageType,bool) */
I18NLANGTAG_DLLPRIVATE static void convertLanguageToIsoNames(
LanguageType nLang, OUString& rLangStr, OUString& rCountry );
commit 84df29d34de7e1c36f57895f914a8b8090dff518
Author: Eike Rathke <erack at redhat.com>
Date: Fri Aug 23 15:52:07 2013 +0200
extra convertLanguageToLocaleWithFallback(LanguageType) is unneeded
Change-Id: I67805c7f7a238e384a3cb6c3e58186e890594c49
diff --git a/i18nlangtag/source/isolang/mslangid.cxx b/i18nlangtag/source/isolang/mslangid.cxx
index 08e618e..8ef2aa3 100644
--- a/i18nlangtag/source/isolang/mslangid.cxx
+++ b/i18nlangtag/source/isolang/mslangid.cxx
@@ -199,20 +199,12 @@ LanguageType MsLangId::Conversion::convertLocaleToLanguage(
// static
-::com::sun::star::lang::Locale MsLangId::Conversion::convertLanguageToLocaleWithFallback(
- LanguageType nLang )
-{
- return lookupFallbackLocale( MsLangId::getRealLanguage( nLang));
-}
-
-
-// static
::com::sun::star::lang::Locale MsLangId::getFallbackLocale(
const ::com::sun::star::lang::Locale & rLocale )
{
// empty language => LANGUAGE_SYSTEM
if (rLocale.Language.isEmpty())
- return Conversion::convertLanguageToLocaleWithFallback( LANGUAGE_SYSTEM);
+ return Conversion::lookupFallbackLocale( MsLangId::getRealLanguage( LANGUAGE_SYSTEM));
return Conversion::lookupFallbackLocale( rLocale);
}
diff --git a/include/i18nlangtag/mslangid.hxx b/include/i18nlangtag/mslangid.hxx
index 8148d17..4d05468 100644
--- a/include/i18nlangtag/mslangid.hxx
+++ b/include/i18nlangtag/mslangid.hxx
@@ -259,16 +259,7 @@ public:
I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
const ::com::sun::star::lang::Locale & rLocale );
-
- /** Convert a LanguageType to a Locale, resolving LANGUAGE_SYSTEM,
- falling back to a default locale if no exact match was found.
-
- Used by getFallbackLocale(Locale)
- */
- I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale convertLanguageToLocaleWithFallback(
- LanguageType nLang );
-
- /** Used by convertLanguageToLocaleWithFallback(LanguageType) */
+ /** Used by getFallbackLocale(Locale) */
I18NLANGTAG_DLLPRIVATE static ::com::sun::star::lang::Locale lookupFallbackLocale(
LanguageType nLang );
};
More information about the Libreoffice-commits
mailing list