22 #include <com/sun/star/i18n/MultipleCharsOutputException.hpp>
23 #include <com/sun/star/i18n/TransliterationType.hpp>
24 #include <rtl/ustring.hxx>
25 #include <rtl/ustrbuf.hxx>
34 sal_Int16 SAL_CALL TextToPronounce_zh::getType()
36 return TransliterationType::ONE_TO_ONE| TransliterationType::IGNORE;
44 sal_uInt16 address =
idx[0][ch>>8];
45 if (address != 0xFFFF)
47 &
idx[2][
idx[1][address + (ch & 0xFF)]]);
53 TextToPronounce_zh::foldingImpl(
const OUString & inStr, sal_Int32 startPos,
57 const sal_Unicode * chArr = inStr.getStr() + startPos;
62 if (startPos + nCount > inStr.getLength())
63 nCount = inStr.getLength() - startPos;
65 auto ppOffset = pOffset ? pOffset->getArray() :
nullptr;
68 for (sal_Int32
i = 0;
i < nCount;
i++) {
69 OUString pron(getPronounce(chArr[
i]));
73 ppOffset[i + 1] = (*pOffset)[i] + pron.getLength();
75 return sb.makeStringAndClear();
79 TextToPronounce_zh::transliterateChar2String(
sal_Unicode inChar)
81 return OUString(getPronounce(inChar));
85 TextToPronounce_zh::transliterateChar2Char(
sal_Unicode inChar)
88 if (!pron || !pron[0])
91 throw MultipleCharsOutputException();
96 TextToPronounce_zh::equals(
const OUString & str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32 & nMatch1,
97 const OUString & str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32 & nMatch2)
103 if (nCount1 + pos1 > str1.getLength())
104 nCount1 = str1.getLength() - pos1;
106 if (nCount2 + pos2 > str2.getLength())
107 nCount2 = str2.getLength() - pos2;
109 realCount = std::min(nCount1, nCount2);
111 s1 = str1.getStr() + pos1;
112 s2 = str2.getStr() + pos2;
113 for (i = 0; i < realCount; i++) {
116 if (pron1 != pron2) {
117 nMatch1 = nMatch2 = i;
121 nMatch1 = nMatch2 = realCount;
122 return (nCount1 == nCount2);
125 #ifdef DISABLE_DYNLOADING
129 sal_uInt16** get_collator_data_zh_zhuyin();
130 sal_uInt16** get_collator_data_zh_pinyin();
136 TextToPinyin_zh_CN::TextToPinyin_zh_CN() :
137 #ifndef DISABLE_DYNLOADING
138 TextToPronounce_zh(
"get_zh_pinyin")
140 TextToPronounce_zh(get_collator_data_zh_pinyin)
147 TextToChuyin_zh_TW::TextToChuyin_zh_TW() :
148 #ifndef DISABLE_DYNLOADING
149 TextToPronounce_zh(
"get_zh_zhuyin")
151 TextToPronounce_zh(get_collator_data_zh_zhuyin)
158 #ifndef DISABLE_DYNLOADING
167 OUString lib(
"index_data" SAL_DLLEXTENSION);
169 hModule = osl_loadModuleRelative(
170 &
thisModule, lib.pData, SAL_LOADMODULE_DEFAULT );
173 sal_uInt16** (*function)() =
reinterpret_cast<sal_uInt16** (*)()
>(osl_getFunctionSymbol(
hModule, OUString::createFromAscii(func_name).
pData));
190 #ifndef DISABLE_DYNLOADING
std::unique_ptr< sal_Int32[]> pData
const char * transliterationName
const char * implementationName
virtual ~TextToPronounce_zh() override
TextToPronounce_zh(const char *func_name)
Constant values shared between i18npool and, for example, the number formatter.