23#include <rtl/ustrbuf.hxx>
33#ifndef DISABLE_DYNLOADING
43#ifndef DISABLE_DYNLOADING
49 hModule = osl_loadModuleRelative(
50 &
thisModule, lib.pData, SAL_LOADMODULE_DEFAULT );
56#ifndef DISABLE_DYNLOADING
61#ifdef DISABLE_DYNLOADING
65sal_uInt16** get_indexdata_ko_dict(sal_Int16*);
66sal_uInt16** get_indexdata_zh_TW_radical(sal_Int16*);
67sal_uInt16** get_indexdata_zh_TW_stroke(sal_Int16*);
68sal_uInt16** get_indexdata_zh_pinyin(sal_Int16*);
69sal_uInt16** get_indexdata_zh_radical(sal_Int16*);
70sal_uInt16** get_indexdata_zh_stroke(sal_Int16*);
71sal_uInt16** get_indexdata_zh_zhuyin(sal_Int16*);
73sal_uInt16** get_ko_phonetic(sal_Int16*);
74sal_uInt16** get_zh_pinyin(sal_Int16*);
75sal_uInt16** get_zh_zhuyin(sal_Int16*);
83 const Locale& rLocale,
const OUString& rAlgorithm )
87 sal_uInt16** (*func)(sal_Int16*)=
nullptr;
88#ifndef DISABLE_DYNLOADING
90 OUString
get(
"get_indexdata_");
91 if ( rLocale.Language ==
"zh" && OUString(
"TW HK MO" ).indexOf(rLocale.Country) >= 0 )
92 func=
reinterpret_cast<sal_uInt16** (*)(sal_Int16*)
>(osl_getFunctionSymbol(
hModule, OUString(
get+rLocale.Language+
"_TW_"+rAlgorithm).pData));
94 func=
reinterpret_cast<sal_uInt16** (*)(sal_Int16*)
>(osl_getFunctionSymbol(
hModule, OUString(
get+rLocale.Language+
"_"+rAlgorithm).pData));
97 if ( rLocale.Language ==
"zh" && OUString(
"TW HK MO" ).indexOf(rLocale.Country) >= 0 ) {
98 if ( rAlgorithm ==
"radical" )
99 func = get_indexdata_zh_TW_radical;
100 else if ( rAlgorithm ==
"stroke" )
101 func = get_indexdata_zh_TW_stroke;
104 if ( rLocale.Language ==
"ko" ) {
105 if ( rAlgorithm ==
"dict" )
106 func = get_indexdata_ko_dict;
107 }
else if ( rLocale.Language ==
"zh" ) {
108 if ( rAlgorithm ==
"pinyin" )
109 func = get_indexdata_zh_pinyin;
110 else if ( rAlgorithm ==
"radical" )
111 func = get_indexdata_zh_radical;
112 else if ( rAlgorithm ==
"stroke" )
113 func = get_indexdata_zh_stroke;
114 else if ( rAlgorithm ==
"zhuyin" )
115 func = get_indexdata_zh_zhuyin;
121 sal_uInt16**
idx=func(&max_index);
122 if (
static_cast<sal_Int16
>(
ch >> 8) <= max_index) {
123 sal_uInt16 address=
idx[0][
ch >> 8];
124 if (address != 0xFFFF) {
125 address=
idx[1][address+(
ch & 0xFF)];
135 return OUString(&
idxStr[(
ch & 0xFFFFFF00) ? 0 :
ch], 1);
140 const OUString& rPhoneticEntry,
const Locale& rLocale)
147 const OUString& rIndexEntry1,
const OUString& rPhoneticEntry1,
const Locale& rLocale1,
148 const OUString& rIndexEntry2,
const OUString& rPhoneticEntry2,
const Locale& rLocale2 )
151 getEntry(rIndexEntry2, rPhoneticEntry2, rLocale2));
156 rLocale1.Language == rLocale2.Language && rLocale1.Country == rLocale2.Country &&
157 rLocale1.Variant == rLocale2.Variant)
159 return sal::static_int_cast< sal_Int16 >(
result);
164 const Locale& rLocale )
166 sal_uInt16 **(*func)(sal_Int16*)=
nullptr;
167#ifndef DISABLE_DYNLOADING
169 const char *func_name=
nullptr;
170 if ( rLocale.Language ==
"zh" )
171 func_name=(OUString(
"TW HK MO").indexOf(rLocale.Country) >= 0) ?
"get_zh_zhuyin" :
"get_zh_pinyin";
172 else if ( rLocale.Language ==
"ko" )
173 func_name=
"get_ko_phonetic";
175 func=
reinterpret_cast<sal_uInt16 **(*)(sal_Int16*)
>(osl_getFunctionSymbol(
hModule, OUString::createFromAscii(func_name).
pData));
178 if ( rLocale.Language ==
"zh" )
179 func = (OUString(
"TW HK MO").indexOf(rLocale.Country) >= 0) ? get_zh_zhuyin : get_zh_pinyin;
180 else if ( rLocale.Language ==
"ko" )
181 func = get_ko_phonetic;
185 OUStringBuffer candidate;
187 sal_uInt16**
idx=func(&max_index);
188 for (sal_Int32
i=0,j=0;
i < rIndexEntry.getLength();
i=j) {
189 sal_uInt32
ch = rIndexEntry.iterateCodePoints(&j);
190 if (
static_cast<sal_Int16
>(
ch>>8) <= max_index) {
191 sal_uInt16 address =
idx[0][
ch>>8];
192 if (address != 0xFFFF) {
193 address =
idx[1][address + (
ch & 0xFF)];
194 if (
i > 0 && rLocale.Language ==
"zh" )
195 candidate.append(
" ");
202 candidate.append(
" ");
205 return candidate.makeStringAndClear();
rtl::Reference< CollatorImpl > collator
const char * implementationName
const OUString & getEntry(const OUString &IndexEntry, const OUString &PhoneticEntry, const css::lang::Locale &rLocale) const
virtual ~IndexEntrySupplier_asian() override
OUString SAL_CALL getIndexCharacter(const OUString &rIndexEntry, const css::lang::Locale &rLocale, const OUString &rAlgorithm) override
sal_Int16 SAL_CALL compareIndexEntry(const OUString &rIndexEntry1, const OUString &rPhoneticEntry1, const css::lang::Locale &rLocale1, const OUString &rIndexEntry2, const OUString &rPhoneticEntry2, const css::lang::Locale &rLocale2) override
OUString SAL_CALL getPhoneticCandidate(const OUString &rIndexEntry, const css::lang::Locale &rLocale) override
OUString SAL_CALL getIndexKey(const OUString &rIndexEntry, const OUString &rPhoneticEntry, const css::lang::Locale &rLocale) override
IndexEntrySupplier_asian(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
const sal_Unicode idxStr[]
std::unique_ptr< sal_Int32[]> pData
Constant values shared between i18npool and, for example, the number formatter.
constexpr T & temporary(T &&x)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)