diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-01-28 14:34:01 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-01-28 14:34:01 +0000 |
commit | 5c1ea4f22d073d0ca41abb2b9de2d938aaffccdc (patch) | |
tree | 86d436ce449a74142389b7c9988ae6b296bc21a7 /i18npool | |
parent | 3f0b51776602c45e8aca991450fcbb30f2484ae5 (diff) |
INTEGRATION: CWS i18n39 (1.17.8); FILE MERGED
2008/01/11 07:30:04 khong 1.17.8.2: i78055 provide UCA as base for ICU collator constructor from image rule
2008/01/08 04:26:40 khong 1.17.8.1: i78055 move simple collator tailoring to localedata
Diffstat (limited to 'i18npool')
-rw-r--r-- | i18npool/source/collator/collator_unicode.cxx | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/i18npool/source/collator/collator_unicode.cxx b/i18npool/source/collator/collator_unicode.cxx index 95b5da31e468..ada7768eb21d 100644 --- a/i18npool/source/collator/collator_unicode.cxx +++ b/i18npool/source/collator/collator_unicode.cxx @@ -4,9 +4,9 @@ * * $RCSfile: collator_unicode.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: ihi $ $Date: 2008-01-16 14:32:11 $ + * last change: $Author: vg $ $Date: 2008-01-28 15:34:01 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -41,6 +41,7 @@ #include <rtl/ustrbuf.hxx> #include <collator_unicode.hxx> +#include <localedata.hxx> #include <com/sun/star/i18n/CollatorOptions.hpp> using namespace ::com::sun::star; @@ -54,12 +55,14 @@ Collator_Unicode::Collator_Unicode() { implementationName = "com.sun.star.i18n.Collator_Unicode"; collator = NULL; + uca_base = NULL; hModule = NULL; } Collator_Unicode::~Collator_Unicode() { if (collator) delete collator; + if (uca_base) delete uca_base; if (hModule) osl_unloadModule(hModule); } @@ -83,22 +86,13 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: throw(RuntimeException) { if (!collator) { - /** 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 - 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()); - // load ICU collator UErrorCode status = U_ZERO_ERROR; - collator = (RuleBasedCollator*) icu::Collator::createInstance(icuLocale, status); - if (! U_SUCCESS(status)) - throw RuntimeException(); - if (OUString::createFromAscii(LOCAL_RULE_LANGS).indexOf(rLocale.Language) >= 0) { + OUString rule = LocaleData().getCollatorRuleByAlgorithm(rLocale, rAlgorithm); + if (rule.getLength() > 0) { + collator = new RuleBasedCollator(rule.getStr(), status); + if (! U_SUCCESS(status)) throw RuntimeException(); + } + if (!collator && OUString::createFromAscii(LOCAL_RULE_LANGS).indexOf(rLocale.Language) >= 0) { OUStringBuffer aBuf; #ifdef SAL_DLLPREFIX aBuf.appendAscii(SAL_DLLPREFIX); @@ -131,12 +125,28 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: } if (func) { const sal_uInt8* ruleImage=func(); - collator = new RuleBasedCollator(reinterpret_cast<const uint8_t*>(ruleImage), -1, collator, status); - if (! U_SUCCESS(status)) - throw RuntimeException(); + uca_base = new RuleBasedCollator((sal_Unicode*)NULL, status); + if (! U_SUCCESS(status)) throw RuntimeException(); + collator = new RuleBasedCollator(reinterpret_cast<const uint8_t*>(ruleImage), -1, uca_base, status); + if (! U_SUCCESS(status)) throw RuntimeException(); } } } + if (!collator) { + /** 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 + 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()); + // load ICU collator + collator = (RuleBasedCollator*) icu::Collator::createInstance(icuLocale, status); + if (! U_SUCCESS(status)) throw RuntimeException(); + } } if (options & CollatorOptions::CollatorOptions_IGNORE_CASE_ACCENT) |