#95565#add phonetic entry for CJK index modules
This commit is contained in:
parent
8c1d2fdcc7
commit
bad692c5d3
3 changed files with 164 additions and 16 deletions
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: indexdata_ja_phonetic.h,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: khong $ $Date: 2002-05-31 04:48:43 $
|
||||
* last change: $Author: khong $ $Date: 2002-07-25 04:34:24 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -39,7 +39,7 @@
|
|||
************************************************************************/
|
||||
#include <sal/types.h>
|
||||
|
||||
static sal_uInt16 idx1[] = {
|
||||
static sal_uInt16 idx[] = {
|
||||
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, // 0000
|
||||
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, // 1000
|
||||
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, // 2000
|
||||
|
@ -58,7 +58,7 @@ static sal_uInt16 idx1[] = {
|
|||
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0100, // f000
|
||||
};
|
||||
|
||||
static sal_Unicode idx2[] = {
|
||||
static sal_Unicode syllable[] = {
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 3000
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 3010
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 3020
|
||||
|
@ -94,3 +94,40 @@ static sal_Unicode idx2[] = {
|
|||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 // FFF0
|
||||
};
|
||||
|
||||
|
||||
static sal_Unicode consonant[] = {
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 3000
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 3010
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 3020
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 3030
|
||||
0x3040, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x304B, 0x304B, 0x304B, 0x304B, 0x304B, // 3040
|
||||
0x304B, 0x304B, 0x304B, 0x304B, 0x304B, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x305F, // 3050
|
||||
0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x306A, 0x306A, 0x306A, 0x306A, 0x306A, 0x306F, // 3060
|
||||
0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x307E, 0x307E, // 3070
|
||||
0x307E, 0x307E, 0x307E, 0x3084, 0x3084, 0x3084, 0x3084, 0x3084, 0x3084, 0x3089, 0x3089, 0x3089, 0x3089, 0x3089, 0x308F, 0x308F, // 3080
|
||||
0x308F, 0x308F, 0x308F, 0x308F, 0x3042, 0x304B, 0x304B, 0x3097, 0x3098, 0x3099, 0x309A, 0x309B, 0x309C, 0x309D, 0x309E, 0x309F, // 3090
|
||||
0x30a0, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x304B, 0x304B, 0x304B, 0x304B, 0x304B, // 30A0
|
||||
0x304B, 0x304B, 0x304B, 0x304B, 0x304B, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, 0x305F, // 30B0
|
||||
0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x306A, 0x306A, 0x306A, 0x306A, 0x306A, 0x306F, // 30C0
|
||||
0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x307E, 0x307E, // 30D0
|
||||
0x307E, 0x307E, 0x307E, 0x3084, 0x3084, 0x3084, 0x3084, 0x3084, 0x3084, 0x3089, 0x3089, 0x3089, 0x3089, 0x3089, 0x308F, 0x308F, // 30E0
|
||||
0x308F, 0x308F, 0x308F, 0x308F, 0x3042, 0x304B, 0x304B, 0x308F, 0x308F, 0x308F, 0x308F, 0x30FB, 0x30FC, 0x30FD, 0x30FE, 0x30FF, // 30F0
|
||||
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FF00
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FF10
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FF20
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FF30
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FF40
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FF50
|
||||
0xFF60, 0xFF61, 0xFF62, 0xFF63, 0xFF64, 0xFF65, 0x308F, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x3084, 0x3084, 0x3084, 0x305F, // FF60
|
||||
0xFF70, 0x3042, 0x3042, 0x3042, 0x3042, 0x3042, 0x304B, 0x304B, 0x304B, 0x304B, 0x304B, 0x3055, 0x3055, 0x3055, 0x3055, 0x3055, // FF70
|
||||
0x305F, 0x305F, 0x305F, 0x305F, 0x305F, 0x306A, 0x306A, 0x306A, 0x306A, 0x306A, 0x306F, 0x306F, 0x306F, 0x306F, 0x306F, 0x307E, // FF80
|
||||
0x307E, 0x307E, 0x307E, 0x307E, 0x3084, 0x3084, 0x3084, 0x3089, 0x3089, 0x3089, 0x3089, 0x3089, 0x308F, 0x308F, 0xFF9E, 0xFF9F, // FF90
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FFA0
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FFB0
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FFC0
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FFD0
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // FFE0
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 // FFF0
|
||||
};
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: indexentrysupplier.cxx,v $
|
||||
*
|
||||
* $Revision: 1.8 $
|
||||
* $Revision: 1.9 $
|
||||
*
|
||||
* last change: $Author: khong $ $Date: 2002-06-18 22:29:26 $
|
||||
* last change: $Author: khong $ $Date: 2002-07-25 04:38:12 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -64,6 +64,9 @@
|
|||
#include <tools/intn.hxx>
|
||||
#include <tools/isolang.hxx>
|
||||
#include <indexentrysupplier.hxx>
|
||||
#include <data/zh_pinyin.h>
|
||||
#include <data/zh_zhuyin.h>
|
||||
#include <data/ko_phonetic.h>
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::lang;
|
||||
|
@ -92,7 +95,7 @@ static const struct {
|
|||
{ "hu", "alphanumeric", 1 },
|
||||
{ "is", "alphanumeric", 1 },
|
||||
{ "it", "alphanumeric", 1 },
|
||||
{ "ja", "phonetic", 1 },
|
||||
{ "ja", "phonetic (alphanumeric first) (grouped by syllable),phonetic (alphanumeric first) (grouped by consonant),phonetic (alphanumeric last) (grouped by syllable),phonetic (alphanumeric last) (grouped by consonant)", 4 },
|
||||
{ "ko", "dict", 1 },
|
||||
{ "nb", "alphanumeric", 1 },
|
||||
{ "nl", "alphanumeric", 1 },
|
||||
|
@ -104,8 +107,8 @@ static const struct {
|
|||
{ "sv", "alphanumeric", 1 },
|
||||
{ "tr", "alphanumeric", 1 },
|
||||
{ "th", "alphanumeric", 1 },
|
||||
{ "zh_CN", "pinyin stroke radical", 3 },
|
||||
{ "zh_TW", "stroke radical zhuyin pinyin", 4 },
|
||||
{ "zh_CN", "pinyin,stroke,radical", 3 },
|
||||
{ "zh_TW", "stroke,radical,zhuyin,pinyin", 4 },
|
||||
};
|
||||
|
||||
static const sal_Int16 nbOfLocales = sizeof(aLocaleList) / sizeof(aLocaleList[0]);
|
||||
|
@ -167,7 +170,7 @@ Sequence < OUString > SAL_CALL IndexEntrySupplier::getAlgorithmList( const Local
|
|||
algorithmList.realloc(aLocaleList[i].pAlgorithmCount);
|
||||
index = 0;
|
||||
for (sal_Int16 j=0; j<aLocaleList[i].pAlgorithmCount; j++)
|
||||
algorithmList[j] = algorithms.getToken(0, sal_Unicode(' '), index);
|
||||
algorithmList[j] = algorithms.getToken(0, sal_Unicode(','), index);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -186,14 +189,57 @@ sal_Bool SAL_CALL IndexEntrySupplier::loadAlgorithm( const Locale& rLocale, cons
|
|||
sal_Bool SAL_CALL IndexEntrySupplier::usePhoneticEntry( const Locale& rLocale ) throw (RuntimeException)
|
||||
{
|
||||
// First implementation only turns the feature on for Japanese language.
|
||||
return rLocale.Language.compareToAscii("ja") == 0;
|
||||
return rLocale.Language.equalsAscii("zh")
|
||||
|| rLocale.Language.equalsAscii("ja")
|
||||
|| rLocale.Language.equalsAscii("ko");
|
||||
}
|
||||
|
||||
OUString SAL_CALL IndexEntrySupplier::getPhoneticCandidate( const OUString& rIndexEntry,
|
||||
const Locale& rLocale ) throw (RuntimeException)
|
||||
{
|
||||
static OUString space(OUString::createFromAscii(" "));
|
||||
OUString candidate;
|
||||
// TODO: the phonetic candidate will be provided by language engine for CJK.
|
||||
return OUString();
|
||||
if (rLocale.Language.equalsAscii("zh")) {
|
||||
sal_Unicode *Str;
|
||||
sal_uInt16 *Index1, *Index2;
|
||||
if (rLocale.Country.equalsAscii("TW") ||
|
||||
rLocale.Country.equalsAscii("HK") ||
|
||||
rLocale.Country.equalsAscii("MO")) {
|
||||
Str = ZhuYinStr_zh;
|
||||
Index1 = ZhuYinIndex1_zh;
|
||||
Index2 = ZhuYinIndex2_zh;
|
||||
} else {
|
||||
Str = PinYinStr_zh;
|
||||
Index1 = PinYinIndex1_zh;
|
||||
Index2 = PinYinIndex2_zh;
|
||||
}
|
||||
|
||||
for (sal_Int32 i=0; i < rIndexEntry.getLength(); i++) {
|
||||
sal_Unicode ch = rIndexEntry[i];
|
||||
sal_uInt16 address = Index1[ch>>8];
|
||||
if (address != 0xFFFF)
|
||||
address = Index2[address + (ch & 0xFF)];
|
||||
if (i > 0)
|
||||
candidate += space;
|
||||
if (address != 0xFFFF)
|
||||
candidate += OUString(&Str[address]);
|
||||
}
|
||||
} else if (rLocale.Language.equalsAscii("ja")) {
|
||||
; // TODO
|
||||
} else if (rLocale.Language.equalsAscii("ko")) {
|
||||
for (sal_Int32 i=0; i < rIndexEntry.getLength(); i++) {
|
||||
sal_Unicode ch = rIndexEntry[i];
|
||||
sal_uInt16 address = PhoneticIndex_ko[ch>>8];
|
||||
if (address != 0xFFFF)
|
||||
address = PhoneticCharacter_ko[address + (ch & 0xFF)];
|
||||
if (address != 0xFFFF)
|
||||
candidate += OUString(address);
|
||||
else
|
||||
candidate += space;
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
OUString SAL_CALL IndexEntrySupplier::getIndexKey( const OUString& rIndexEntry,
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: indexentrysupplier_ja_phonetic.cxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: khong $Date: 2002/05/31 04:51:19 $
|
||||
* last change: $Author: khong $Date: 2002/06/18 22:29:26 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -62,12 +62,77 @@
|
|||
#define INDEXENTRYSUPPLIER_ja_phonetic
|
||||
#include <indexentrysupplier_asian.hxx>
|
||||
#include <data/indexdata_ja_phonetic.h>
|
||||
#include <strings.h>
|
||||
|
||||
namespace com { namespace sun { namespace star { namespace i18n {
|
||||
|
||||
rtl::OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexCharacter( const rtl::OUString& rIndexEntry,
|
||||
const lang::Locale& rLocale, const rtl::OUString& rSortAlgorithm ) throw (com::sun::star::uno::RuntimeException) {
|
||||
return IndexEntrySupplier_CJK::getIndexString(rIndexEntry.toChar(), idx1, idx2);
|
||||
const lang::Locale& rLocale, const rtl::OUString& rSortAlgorithm )
|
||||
throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
return IndexEntrySupplier_CJK::getIndexString(rIndexEntry.toChar(), idx,
|
||||
strstr(implementationName, "syllable") ? syllable : consonant);
|
||||
}
|
||||
|
||||
rtl::OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexKey( const rtl::OUString& IndexEntry,
|
||||
const rtl::OUString& PhoneticEntry, const lang::Locale& rLocale )
|
||||
throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
return IndexEntrySupplier_CJK::getIndexString(
|
||||
PhoneticEntry.getLength() > 0 ? PhoneticEntry.toChar() : IndexEntry.toChar(), idx,
|
||||
strstr(implementationName, "syllable") ? syllable : consonant);
|
||||
}
|
||||
|
||||
sal_Int16 SAL_CALL IndexEntrySupplier_ja_phonetic::compareIndexEntry(
|
||||
const rtl::OUString& IndexEntry1, const rtl::OUString& PhoneticEntry1, const lang::Locale& rLocale1,
|
||||
const rtl::OUString& IndexEntry2, const rtl::OUString& PhoneticEntry2, const lang::Locale& rLocale2 )
|
||||
throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
sal_Int16 result = collator->compareString(
|
||||
IndexEntrySupplier_ja_phonetic::getIndexKey(IndexEntry1, PhoneticEntry1, rLocale1),
|
||||
IndexEntrySupplier_ja_phonetic::getIndexKey(IndexEntry2, PhoneticEntry2, rLocale2));
|
||||
|
||||
if (result == 0)
|
||||
return collator->compareString(
|
||||
PhoneticEntry1.getLength() > 0 ? PhoneticEntry1 : IndexEntry1,
|
||||
PhoneticEntry2.getLength() > 0 ? PhoneticEntry2 : IndexEntry2);
|
||||
else
|
||||
return result;
|
||||
}
|
||||
|
||||
static sal_Char first[] = "ja_phonetic_alphanumeric_first";
|
||||
sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_syllable::loadAlgorithm(
|
||||
const com::sun::star::lang::Locale& rLocale, const rtl::OUString& SortAlgorithm,
|
||||
sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
aSortAlgorithm = SortAlgorithm;
|
||||
aLocale = rLocale;
|
||||
return collator->loadCollatorAlgorithm(rtl::OUString::createFromAscii(first), rLocale, collatorOptions) == 0;
|
||||
}
|
||||
sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_consonant::loadAlgorithm(
|
||||
const com::sun::star::lang::Locale& rLocale, const rtl::OUString& SortAlgorithm,
|
||||
sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
aSortAlgorithm = SortAlgorithm;
|
||||
aLocale = rLocale;
|
||||
return collator->loadCollatorAlgorithm(rtl::OUString::createFromAscii(first), rLocale, collatorOptions) == 0;
|
||||
}
|
||||
static sal_Char last[] = "ja_phonetic_alphanumeric_last";
|
||||
sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_syllable::loadAlgorithm(
|
||||
const com::sun::star::lang::Locale& rLocale, const rtl::OUString& SortAlgorithm,
|
||||
sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
aSortAlgorithm = SortAlgorithm;
|
||||
aLocale = rLocale;
|
||||
return collator->loadCollatorAlgorithm(rtl::OUString::createFromAscii(last), rLocale, collatorOptions) == 0;
|
||||
}
|
||||
sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_consonant::loadAlgorithm(
|
||||
const com::sun::star::lang::Locale& rLocale, const rtl::OUString& SortAlgorithm,
|
||||
sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
|
||||
{
|
||||
aSortAlgorithm = SortAlgorithm;
|
||||
aLocale = rLocale;
|
||||
return collator->loadCollatorAlgorithm(rtl::OUString::createFromAscii(last), rLocale, collatorOptions) == 0;
|
||||
}
|
||||
|
||||
} } } }
|
||||
|
|
Loading…
Reference in a new issue