merge the formfield patch from ooo-build
[ooovba.git] / i18npool / source / indexentry / indexentrysupplier_ja_phonetic.cxx
blobb52b49e606ce69e0d62189ba3f1f5f5361c8773a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: indexentrysupplier_ja_phonetic.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_i18npool.hxx"
34 #include <indexentrysupplier_ja_phonetic.hxx>
35 #include <data/indexdata_alphanumeric.h>
36 #include <data/indexdata_ja_phonetic.h>
37 #include <string.h>
39 using namespace ::rtl;
41 namespace com { namespace sun { namespace star { namespace i18n {
43 OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexCharacter( const OUString& rIndexEntry,
44 const lang::Locale& /*rLocale*/, const OUString& /*rSortAlgorithm*/ )
45 throw (com::sun::star::uno::RuntimeException)
47 sal_Unicode ch=rIndexEntry.toChar();
48 sal_uInt16 first = idx[ ch >> 8 ];
49 if (first == 0xFFFF) {
50 // using alphanumeric index for non-define stirng
51 return OUString(&idxStr[(ch & 0xFF00) ? 0 : ch], 1);
52 } else {
53 sal_Unicode *idx2 = strstr(implementationName, "syllable") ? syllable : consonant;
54 return OUString(&idx2[ first + (ch & 0xff) ], 1);
58 OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexKey( const OUString& IndexEntry,
59 const OUString& PhoneticEntry, const lang::Locale& rLocale )
60 throw (com::sun::star::uno::RuntimeException)
62 return getIndexCharacter( PhoneticEntry.getLength() > 0 ? PhoneticEntry : IndexEntry, rLocale, OUString());
65 sal_Int16 SAL_CALL IndexEntrySupplier_ja_phonetic::compareIndexEntry(
66 const OUString& IndexEntry1, const OUString& PhoneticEntry1, const lang::Locale& rLocale1,
67 const OUString& IndexEntry2, const OUString& PhoneticEntry2, const lang::Locale& rLocale2 )
68 throw (com::sun::star::uno::RuntimeException)
70 sal_Int16 result = sal::static_int_cast<sal_Int16>( collator->compareString(
71 IndexEntrySupplier_ja_phonetic::getIndexKey(IndexEntry1, PhoneticEntry1, rLocale1),
72 IndexEntrySupplier_ja_phonetic::getIndexKey(IndexEntry2, PhoneticEntry2, rLocale2)) );
74 if (result == 0)
75 return IndexEntrySupplier_Common::compareIndexEntry(
76 IndexEntry1, PhoneticEntry1, rLocale1,
77 IndexEntry2, PhoneticEntry2, rLocale2);
78 return result;
81 static sal_Char first[] = "ja_phonetic (alphanumeric first)";
82 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_syllable::loadAlgorithm(
83 const com::sun::star::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
84 sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
86 return collator->loadCollatorAlgorithm(OUString::createFromAscii(first), rLocale, collatorOptions) == 0;
88 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_consonant::loadAlgorithm(
89 const com::sun::star::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
90 sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
92 return collator->loadCollatorAlgorithm(OUString::createFromAscii(first), rLocale, collatorOptions) == 0;
95 static sal_Char last[] = "ja_phonetic (alphanumeric last)";
96 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_syllable::loadAlgorithm(
97 const com::sun::star::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
98 sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
100 return collator->loadCollatorAlgorithm(OUString::createFromAscii(last), rLocale, collatorOptions) == 0;
102 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_consonant::loadAlgorithm(
103 const com::sun::star::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
104 sal_Int32 collatorOptions ) throw (com::sun::star::uno::RuntimeException)
106 return collator->loadCollatorAlgorithm(OUString::createFromAscii(last), rLocale, collatorOptions) == 0;
109 } } } }