diff options
author | Tor Lillqvist <tml@iki.fi> | 2012-04-18 01:21:31 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@iki.fi> | 2012-04-18 01:23:51 +0300 |
commit | f06e6513a805d810d3ef8fc9ccf90d1b7cf48c3d (patch) | |
tree | cc24f18f066b0aa0f4f5c77ae4dfb052ce651397 /i18npool/source/collator | |
parent | 4048a810a0c00af2bf94d24243ff02a832f63de3 (diff) |
Use static linking when DISABLE_DYNLOADING (iOS)
Diffstat (limited to 'i18npool/source/collator')
-rw-r--r-- | i18npool/source/collator/collator_unicode.cxx | 111 | ||||
-rw-r--r-- | i18npool/source/collator/gencoll_rule.cxx | 7 |
2 files changed, 109 insertions, 9 deletions
diff --git a/i18npool/source/collator/collator_unicode.cxx b/i18npool/source/collator/collator_unicode.cxx index f574cdfd430c..7cbb59833e70 100644 --- a/i18npool/source/collator/collator_unicode.cxx +++ b/i18npool/source/collator/collator_unicode.cxx @@ -47,16 +47,53 @@ Collator_Unicode::Collator_Unicode() implementationName = "com.sun.star.i18n.Collator_Unicode"; collator = NULL; uca_base = NULL; +#ifndef DISABLE_DYNLOADING hModule = NULL; +#endif } Collator_Unicode::~Collator_Unicode() { if (collator) delete collator; if (uca_base) delete uca_base; +#ifndef DISABLE_DYNLOADING if (hModule) osl_unloadModule(hModule); +#endif } +#ifdef DISABLE_DYNLOADING + +extern "C" { + +// For DISABLE_DYNLOADING the generated functions have names that +// start with get_collator_data_ to avoid clashing with a few +// functions in the generated libindex_data that are called just +// get_zh_pinyin for instance. + +const sal_uInt8* get_collator_data_ca_charset(); +const sal_uInt8* get_collator_data_dz_charset(); +const sal_uInt8* get_collator_data_hu_charset(); +const sal_uInt8* get_collator_data_ja_charset(); +const sal_uInt8* get_collator_data_ja_phonetic_alphanumeric_first(); +const sal_uInt8* get_collator_data_ja_phonetic_alphanumeric_last(); +const sal_uInt8* get_collator_data_ko_charset(); +const sal_uInt8* get_collator_data_ku_alphanumeric(); +const sal_uInt8* get_collator_data_ln_charset(); +const sal_uInt8* get_collator_data_my_dictionary(); +const sal_uInt8* get_collator_data_ne_charset(); +const sal_uInt8* get_collator_data_zh_TW_charset(); +const sal_uInt8* get_collator_data_zh_TW_radical(); +const sal_uInt8* get_collator_data_zh_TW_stroke(); +const sal_uInt8* get_collator_data_zh_charset(); +const sal_uInt8* get_collator_data_zh_pinyin(); +const sal_uInt8* get_collator_data_zh_radical(); +const sal_uInt8* get_collator_data_zh_stroke(); +const sal_uInt8* get_collator_data_zh_zhuyin(); + +} + +#endif + sal_Int32 SAL_CALL Collator_Unicode::compareSubstring( const OUString& str1, sal_Int32 off1, sal_Int32 len1, const OUString& str2, sal_Int32 off2, sal_Int32 len2) throw(RuntimeException) @@ -70,8 +107,12 @@ Collator_Unicode::compareString( const OUString& str1, const OUString& str2) thr return collator->compare(reinterpret_cast<const UChar *>(str1.getStr()), reinterpret_cast<const UChar *>(str2.getStr())); // UChar != sal_Unicode in MinGW } +#ifndef DISABLE_DYNLOADING + extern "C" { static void SAL_CALL thisModule() {} } +#endif + sal_Int32 SAL_CALL Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang::Locale& rLocale, sal_Int32 options) throw(RuntimeException) @@ -84,6 +125,9 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: if (! U_SUCCESS(status)) throw RuntimeException(); } if (!collator && OUString::createFromAscii(LOCAL_RULE_LANGS).indexOf(rLocale.Language) >= 0) { + const sal_uInt8* (*func)() = NULL; + +#ifndef DISABLE_DYNLOADING OUStringBuffer aBuf; #ifdef SAL_DLLPREFIX aBuf.appendAscii(SAL_DLLPREFIX); @@ -91,7 +135,6 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: aBuf.appendAscii( "collator_data" ).appendAscii( SAL_DLLEXTENSION ); hModule = osl_loadModuleRelative( &thisModule, aBuf.makeStringAndClear().pData, SAL_LOADMODULE_DEFAULT ); if (hModule) { - const sal_uInt8* (*func)() = NULL; aBuf.appendAscii("get_").append(rLocale.Language).appendAscii("_"); if ( rLocale.Language == "zh" ) { OUString func_base = aBuf.makeStringAndClear(); @@ -114,13 +157,65 @@ Collator_Unicode::loadCollatorAlgorithm(const OUString& rAlgorithm, const lang:: } func=(const sal_uInt8* (*)()) osl_getFunctionSymbol(hModule, aBuf.makeStringAndClear().pData); } - if (func) { - const sal_uInt8* ruleImage=func(); - uca_base = new RuleBasedCollator(static_cast<UChar*>(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(); - } + } +#else + if ( rLocale.Language == "ca" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_ca_charset; + } else if ( rLocale.Language == "dz" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_dz_charset; + } else if ( rLocale.Language == "hu" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_hu_charset; + } else if ( rLocale.Language == "ja" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_hu_charset; + else if ( rAlgorithm == "phonetic (alphanumeric first)" ) + func = get_collator_data_ja_phonetic_alphanumeric_first; + else if ( rAlgorithm == "phonetic (alphanumeric last)" ) + func = get_collator_data_ja_phonetic_alphanumeric_last; + } else if ( rLocale.Language == "ko" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_ko_charset; + } else if ( rLocale.Language == "ku" ) { + if ( rAlgorithm == "alphanumeric" ) + func = get_collator_data_ku_alphanumeric; + } else if ( rLocale.Language == "ln" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_ln_charset; + } else if ( rLocale.Language == "my" ) { + if ( rAlgorithm == "dictionary" ) + func = get_collator_data_my_dictionary; + } else if ( rLocale.Language == "ne" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_ne_charset; + } else if ( rLocale.Language == "zh" && (rLocale.Country == "TW" || rLocale.Country == "HK" || rLocale.Country == "MO") ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_zh_TW_charset; + else if ( rAlgorithm == "radical" ) + func = get_collator_data_zh_TW_radical; + else if ( rAlgorithm == "stroke" ) + func = get_collator_data_zh_TW_stroke; + } else if ( rLocale.Language == "zh" ) { + if ( rAlgorithm == "charset" ) + func = get_collator_data_zh_charset; + else if ( rAlgorithm == "pinyin" ) + func = get_collator_data_zh_pinyin; + else if ( rAlgorithm == "radical" ) + func = get_collator_data_zh_radical; + else if ( rAlgorithm == "stroke" ) + func = get_collator_data_zh_stroke; + else if ( rAlgorithm == "zhuyin" ) + func = get_collator_data_zh_zhuyin; + } +#endif + if (func) { + const sal_uInt8* ruleImage=func(); + uca_base = new RuleBasedCollator(static_cast<UChar*>(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) { diff --git a/i18npool/source/collator/gencoll_rule.cxx b/i18npool/source/collator/gencoll_rule.cxx index 61911f7ac327..921eade92673 100644 --- a/i18npool/source/collator/gencoll_rule.cxx +++ b/i18npool/source/collator/gencoll_rule.cxx @@ -72,7 +72,12 @@ void data_write(char* file, char* name, sal_uInt8 *data, sal_Int32 len) } fprintf(fp, "\n};\n\n"); - fprintf(fp, "const sal_uInt8* get_%s() { return %s; }\n\n", name, name); + fprintf(fp, "#ifndef DISABLE_DYNLOADING\n"); + fprintf(fp, "SAL_DLLPUBLIC_EXPORT const sal_uInt8* get_%s() { return %s; }\n", name, name); + fprintf(fp, "#else\n"); + fprintf(fp, "SAL_DLLPUBLIC_EXPORT const sal_uInt8* get_collator_data_%s() { return %s; }\n", name, name); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); fprintf (fp, "}\n"); fclose(fp); |