[Libreoffice-commits] core.git: 6 commits - i18nlangtag/source i18npool/Library_i18npool.mk i18npool/source include/i18nlangtag lotuswordpro/source
Eike Rathke
erack at redhat.com
Wed Apr 24 15:01:30 PDT 2013
i18nlangtag/source/languagetag/languagetagicu.cxx | 11 +++
i18npool/Library_i18npool.mk | 1
i18npool/source/breakiterator/breakiterator_unicode.cxx | 7 +-
i18npool/source/collator/collator_unicode.cxx | 9 +--
i18npool/source/ordinalsuffix/ordinalsuffix.cxx | 15 ++---
include/i18nlangtag/languagetagicu.hxx | 12 ++++
lotuswordpro/source/filter/lwptools.cxx | 45 ----------------
7 files changed, 37 insertions(+), 63 deletions(-)
New commits:
commit 86acfb46ceb8946c6029811592d93041936e0091
Author: Eike Rathke <erack at redhat.com>
Date: Thu Apr 25 00:00:07 2013 +0200
removed commented out code that wouldn't be correct anyway
Change-Id: I1fc5f6b7e779ae0c9ac5f30934c2c5d75757581d
diff --git a/lotuswordpro/source/filter/lwptools.cxx b/lotuswordpro/source/filter/lwptools.cxx
index 9ef4ec5..77eb3dc 100644
--- a/lotuswordpro/source/filter/lwptools.cxx
+++ b/lotuswordpro/source/filter/lwptools.cxx
@@ -262,29 +262,7 @@ XFDateStyle* LwpTools::GetSystemDateStyle(sal_Bool bLongFormat)
style = icu::DateFormat::FULL;//system full date format
else
style = icu::DateFormat::SHORT;//system short date format
-/* ::com::sun::star::lang::Locale aLocale=Application::GetSettings().GetLocale();
- OUString strLang = aLocale.Language;
- OUString strCountry = aLocale.Country;
- strLang = strLang + A2OUSTR("_");
- OUString strLocale = strLang + strCountry;
- int32_t nLength = 0;
- int32_t nLengthNeed;
- UErrorCode status = U_ZERO_ERROR;
- UChar* pattern = NULL;
-
- UDateFormat* fmt= udat_open(UDAT_FULL, UDAT_FULL,
- (char*)(OUStringToOString(strLocale,RTL_TEXTENCODING_MS_1252).getStr()), NULL, 0, NULL, 0, &status);
-
- nLengthNeed = udat_toPattern(fmt,true,NULL,nLength,&status);
- if (status == U_BUFFER_OVERFLOW_ERROR)
- {
- status = U_ZERO_ERROR;
- nLength = nLengthNeed +1;
- pattern = (UChar*)malloc(sizeof(UChar)*nLength);
- udat_toPattern(fmt,true,pattern,nLength,&status);
- }
-*/
//1 get locale for system
icu::Locale aLocale( LanguageTagIcu::getIcuLocale( Application::GetSettings().GetLanguageTag()));
//2 get icu format pattern by locale
@@ -671,29 +649,6 @@ XFDateStyle* LwpTools::GetSystemDateStyle(sal_Bool bLongFormat)
*/
XFTimeStyle* LwpTools::GetSystemTimeStyle()
{
-/* ::com::sun::star::lang::Locale aLocale=Application::GetSettings().GetLocale();
- OUString strLang = aLocale.Language;
- OUString strCountry = aLocale.Country;
- strLang = strLang + A2OUSTR("_");
- OUString strLocale = strLang + strCountry;
-
- int32_t nLength = 0;
- int32_t nLengthNeed;
- UErrorCode status = U_ZERO_ERROR;
- UChar* pattern = NULL;
-
- UDateFormat* fmt= udat_open(UDAT_FULL, UDAT_FULL,
- (char*)(OUStringToOString(strLocale,RTL_TEXTENCODING_MS_1252).getStr()), NULL, 0, NULL, 0, &status);
-
- nLengthNeed = udat_toPattern(fmt,true,NULL,nLength,&status);
- if (status == U_BUFFER_OVERFLOW_ERROR)
- {
- status = U_ZERO_ERROR;
- nLength = nLengthNeed +1;
- pattern = (UChar*)malloc(sizeof(UChar)*nLength);
- udat_toPattern(fmt,true,pattern,nLength,&status);
- }
-*/
//1 get locale for system
icu::Locale aLocale( LanguageTagIcu::getIcuLocale( Application::GetSettings().GetLanguageTag()));
//2 get icu format pattern by locale
commit f62a00f32a1adb4052b05e406cb0e040c7f2360d
Author: Eike Rathke <erack at redhat.com>
Date: Wed Apr 24 23:55:28 2013 +0200
can we stick a with our naming conventions, just a little bit?
Change-Id: I1457c64162c2aeb083e98a28737991ae6d0eee2e
diff --git a/i18npool/source/ordinalsuffix/ordinalsuffix.cxx b/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
index 953c886..f9491b2 100644
--- a/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
+++ b/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
@@ -66,19 +66,19 @@ namespace
* than english ones, ICU 4.2+ has to be used.
*/
uno::Sequence< OUString > SAL_CALL OrdinalSuffix::getOrdinalSuffix( sal_Int32 nNumber,
- const lang::Locale &aLocale ) throw( RuntimeException )
+ const lang::Locale &rLocale ) throw( RuntimeException )
{
uno::Sequence< OUString > retValue;
// Get the value from ICU
UErrorCode nCode = U_ZERO_ERROR;
- const icu::Locale rIcuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( aLocale)));
+ const icu::Locale aIcuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( rLocale)));
- icu::RuleBasedNumberFormat formatter(icu::URBNF_ORDINAL, rIcuLocale, nCode);
+ icu::RuleBasedNumberFormat formatter(icu::URBNF_ORDINAL, aIcuLocale, nCode);
if (!U_SUCCESS(nCode))
return retValue;
- boost::scoped_ptr<NumberFormat> xNumberFormat(icu::NumberFormat::createInstance(rIcuLocale, nCode));
+ boost::scoped_ptr<NumberFormat> xNumberFormat(icu::NumberFormat::createInstance(aIcuLocale, nCode));
if (!U_SUCCESS(nCode))
return retValue;
commit be35d10c9124d4559e54444ccd1f70b334047c13
Author: Eike Rathke <erack at redhat.com>
Date: Wed Apr 24 23:53:49 2013 +0200
use LanguageTagIcu
Change-Id: I1e66fa3edb2ddf2b6d6f4cdd25104772ff02c70a
diff --git a/i18npool/source/ordinalsuffix/ordinalsuffix.cxx b/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
index 45306cf..953c886 100644
--- a/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
+++ b/i18npool/source/ordinalsuffix/ordinalsuffix.cxx
@@ -18,6 +18,8 @@
*/
#include <boost/scoped_ptr.hpp>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/languagetagicu.hxx>
#include <comphelper/processfactory.hxx>
#include <string.h>
#include "ordinalsuffix.hxx"
@@ -25,8 +27,6 @@
#include <unicode/rbnf.h>
#include <unicode/normlzr.h>
-#define CSTR( ouStr ) OUStringToOString( ouStr, RTL_TEXTENCODING_UTF8 ).getStr( )
-
using namespace ::com::sun::star::i18n;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star;
@@ -72,10 +72,7 @@ uno::Sequence< OUString > SAL_CALL OrdinalSuffix::getOrdinalSuffix( sal_Int32 nN
// Get the value from ICU
UErrorCode nCode = U_ZERO_ERROR;
- const icu::Locale rIcuLocale(
- CSTR( aLocale.Language ),
- CSTR( aLocale.Country ),
- CSTR( aLocale.Variant ) );
+ const icu::Locale rIcuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( aLocale)));
icu::RuleBasedNumberFormat formatter(icu::URBNF_ORDINAL, rIcuLocale, nCode);
if (!U_SUCCESS(nCode))
commit 0cb65cee8a700afdcde945e5a8291b6498042bb9
Author: Eike Rathke <erack at redhat.com>
Date: Wed Apr 24 23:48:44 2013 +0200
use LanguageTagIcu
Change-Id: I7b052a3f73740ff3a35f38dc2d96bc621b8d8deb
diff --git a/i18npool/source/collator/collator_unicode.cxx b/i18npool/source/collator/collator_unicode.cxx
index 40b5c47..a7cf05b 100644
--- a/i18npool/source/collator/collator_unicode.cxx
+++ b/i18npool/source/collator/collator_unicode.cxx
@@ -22,6 +22,8 @@
#include "lrl_include.hxx"
#include <rtl/ustrbuf.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/languagetagicu.hxx>
#include <collator_unicode.hxx>
#include <localedata.hxx>
#include <com/sun/star/i18n/CollatorOptions.hpp>
@@ -213,13 +215,10 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang::
/** ICU collators are loaded using a locale only.
ICU uses Variant as collation algorithm name (like de__PHONEBOOK
locale), note the empty territory (Country) designator in this special
- case here. The icu::Locale contructor changes the algorithm name to
+ case here. The icu::Locale constructor changes the algorithm name to
uppercase itself, so we don't have to bother with that.
*/
- icu::Locale icuLocale(
- OUStringToOString(rLocale.Language, RTL_TEXTENCODING_ASCII_US).getStr(),
- OUStringToOString(rLocale.Country, RTL_TEXTENCODING_ASCII_US).getStr(),
- OUStringToOString(rAlgorithm, RTL_TEXTENCODING_ASCII_US).getStr());
+ icu::Locale icuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( rLocale), rAlgorithm));
// load ICU collator
collator = (RuleBasedCollator*) icu::Collator::createInstance(icuLocale, status);
if (! U_SUCCESS(status)) throw RuntimeException();
commit 4806df614a0e7e499aef3d10f77923f189207205
Author: Eike Rathke <erack at redhat.com>
Date: Wed Apr 24 23:42:47 2013 +0200
added LanguageTagIcu::getIcuLocale() with additional variant
Change-Id: I5a5689f449ac7653bb716f2ce67ea1039fe2559c
diff --git a/i18nlangtag/source/languagetag/languagetagicu.cxx b/i18nlangtag/source/languagetag/languagetagicu.cxx
index 6f426d6..e088b3c 100644
--- a/i18nlangtag/source/languagetag/languagetagicu.cxx
+++ b/i18nlangtag/source/languagetag/languagetagicu.cxx
@@ -33,4 +33,15 @@ icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag )
OUStringToOString( rLanguageTag.getBcp47(), RTL_TEXTENCODING_ASCII_US).getStr());
}
+
+// static
+icu::Locale LanguageTagIcu::getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant )
+{
+ /* FIXME: how should this work with any BCP47? */
+ return icu::Locale(
+ OUStringToOString( rLanguageTag.getLanguage(), RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString( rLanguageTag.getCountry(), RTL_TEXTENCODING_ASCII_US).getStr(),
+ OUStringToOString( rVariant, RTL_TEXTENCODING_ASCII_US).getStr());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/i18nlangtag/languagetagicu.hxx b/include/i18nlangtag/languagetagicu.hxx
index 20e5349..2fc9db3 100644
--- a/include/i18nlangtag/languagetagicu.hxx
+++ b/include/i18nlangtag/languagetagicu.hxx
@@ -12,6 +12,7 @@
#include <sal/config.h>
#include <i18nlangtag/i18nlangtagdllapi.h>
+#include <rtl/ustring.hxx>
#include <unicode/locid.h>
class LanguageTag;
@@ -37,6 +38,17 @@ public:
Always resolves an empty tag to the system locale.
*/
static icu::Locale getIcuLocale( const LanguageTag & rLanguageTag );
+
+ /** Obtain language tag as ICU icu::Locale, adding variant data.
+
+ From the LanguageTag only language and country are used to construct
+ the icu:Locale, the variant field is copied from rVariant. For example
+ needed to create an icu::Collator instance where the variant field
+ denotes the algorithm to be used.
+
+ Always resolves an empty tag to the system locale.
+ */
+ static icu::Locale getIcuLocale( const LanguageTag & rLanguageTag, const OUString & rVariant );
};
#endif // INCLUDED_I18NLANGTAG_LANGUAGETAGICU_HXX
commit 3ca2240e4818a554d290ca46536dddcf3d18d332
Author: Eike Rathke <erack at redhat.com>
Date: Wed Apr 24 23:22:01 2013 +0200
use LanguageTagIcu
Change-Id: I3ced460cc5a03554dc77e19381af8a5ba202d2ab
diff --git a/i18npool/Library_i18npool.mk b/i18npool/Library_i18npool.mk
index 955579f..5fe9e2c 100644
--- a/i18npool/Library_i18npool.mk
+++ b/i18npool/Library_i18npool.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_Library_use_libraries,i18npool,\
cppu \
cppuhelper \
i18nlangtag \
+ i18nlangtagicu \
i18nutil \
sal \
$(gb_UWINAPI) \
diff --git a/i18npool/source/breakiterator/breakiterator_unicode.cxx b/i18npool/source/breakiterator/breakiterator_unicode.cxx
index 5b24f81..620bba1 100644
--- a/i18npool/source/breakiterator/breakiterator_unicode.cxx
+++ b/i18npool/source/breakiterator/breakiterator_unicode.cxx
@@ -19,6 +19,8 @@
#include <breakiterator_unicode.hxx>
#include <localedata.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/languagetagicu.hxx>
#include <unicode/uchar.h>
#include <unicode/locid.h>
#include <unicode/rbbi.h>
@@ -148,10 +150,7 @@ void SAL_CALL BreakIterator_Unicode::loadICUBreakIterator(const com::sun::star::
}
if (!icuBI->aBreakIterator) {
- icu::Locale icuLocale(
- OUStringToOString(rLocale.Language, RTL_TEXTENCODING_ASCII_US).getStr(),
- OUStringToOString(rLocale.Country, RTL_TEXTENCODING_ASCII_US).getStr(),
- OUStringToOString(rLocale.Variant, RTL_TEXTENCODING_ASCII_US).getStr());
+ icu::Locale icuLocale( LanguageTagIcu::getIcuLocale( LanguageTag( rLocale)));
status = U_ZERO_ERROR;
switch (rBreakType) {
More information about the Libreoffice-commits
mailing list