build fix
[LibreOffice.git] / i18npool / source / indexentry / indexentrysupplier_ja_phonetic.cxx
blobd7ccf35857febb83b830a39c60a622121b41720d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <indexentrysupplier_ja_phonetic.hxx>
22 #include <data/indexdata_alphanumeric.h>
23 #include <data/indexdata_ja_phonetic.h>
24 #include <string.h>
26 namespace com { namespace sun { namespace star { namespace i18n {
28 OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexCharacter( const OUString& rIndexEntry,
29 const lang::Locale& /*rLocale*/, const OUString& /*rSortAlgorithm*/ )
30 throw (css::uno::RuntimeException, std::exception)
32 sal_Unicode ch=rIndexEntry.toChar();
33 sal_uInt16 first = idx[ ch >> 8 ];
34 if (first == 0xFFFF) {
35 // using alphanumeric index for non-define string
36 return OUString(&idxStr[(ch & 0xFF00) ? 0 : ch], 1);
37 } else {
38 const sal_Unicode *idx2 = strstr(implementationName, "syllable") ? syllable : consonant;
39 return OUString(&idx2[ first + (ch & 0xff) ], 1);
43 OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexKey( const OUString& IndexEntry,
44 const OUString& PhoneticEntry, const lang::Locale& rLocale )
45 throw (css::uno::RuntimeException, std::exception)
47 return getIndexCharacter( PhoneticEntry.isEmpty() ? IndexEntry : PhoneticEntry , rLocale, OUString());
50 sal_Int16 SAL_CALL IndexEntrySupplier_ja_phonetic::compareIndexEntry(
51 const OUString& IndexEntry1, const OUString& PhoneticEntry1, const lang::Locale& rLocale1,
52 const OUString& IndexEntry2, const OUString& PhoneticEntry2, const lang::Locale& rLocale2 )
53 throw (css::uno::RuntimeException, std::exception)
55 sal_Int16 result = sal::static_int_cast<sal_Int16>( collator->compareString(
56 IndexEntrySupplier_ja_phonetic::getIndexKey(IndexEntry1, PhoneticEntry1, rLocale1),
57 IndexEntrySupplier_ja_phonetic::getIndexKey(IndexEntry2, PhoneticEntry2, rLocale2)) );
59 if (result == 0)
60 return IndexEntrySupplier_Common::compareIndexEntry(
61 IndexEntry1, PhoneticEntry1, rLocale1,
62 IndexEntry2, PhoneticEntry2, rLocale2);
63 return result;
66 static const sal_Char first[] = "ja_phonetic (alphanumeric first)";
67 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_syllable::loadAlgorithm(
68 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
69 sal_Int32 collatorOptions ) throw (css::uno::RuntimeException, std::exception)
71 return collator->loadCollatorAlgorithm(first, rLocale, collatorOptions) == 0;
73 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_consonant::loadAlgorithm(
74 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
75 sal_Int32 collatorOptions ) throw (css::uno::RuntimeException, std::exception)
77 return collator->loadCollatorAlgorithm(first, rLocale, collatorOptions) == 0;
80 static const sal_Char last[] = "ja_phonetic (alphanumeric last)";
81 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_syllable::loadAlgorithm(
82 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
83 sal_Int32 collatorOptions ) throw (css::uno::RuntimeException, std::exception)
85 return collator->loadCollatorAlgorithm(last, rLocale, collatorOptions) == 0;
87 sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_consonant::loadAlgorithm(
88 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
89 sal_Int32 collatorOptions ) throw (css::uno::RuntimeException, std::exception)
91 return collator->loadCollatorAlgorithm(last, rLocale, collatorOptions) == 0;
94 } } } }
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */