LibreOffice Module i18npool (master) 1
indexentrysupplier_ja_phonetic.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
22#include <collatorImpl.hxx>
25#include <string.h>
26
27using namespace ::com::sun::star::i18n;
28
29namespace i18npool {
30
31OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexCharacter( const OUString& rIndexEntry,
32 const css::lang::Locale& /*rLocale*/, const OUString& /*rSortAlgorithm*/ )
33{
34 sal_Unicode ch=rIndexEntry.toChar();
35 sal_uInt16 first = idx[ ch >> 8 ];
36 if (first == 0xFFFF) {
37 // using alphanumeric index for non-define string
38 return OUString(&idxStr[(ch & 0xFF00) ? 0 : ch], 1);
39 } else {
40 const sal_Unicode *idx2 = strstr(implementationName, "syllable") ? syllable : consonant;
41 return OUString(&idx2[ first + (ch & 0xff) ], 1);
42 }
43}
44
45OUString SAL_CALL IndexEntrySupplier_ja_phonetic::getIndexKey( const OUString& IndexEntry,
46 const OUString& PhoneticEntry, const css::lang::Locale& rLocale )
47{
48 return getIndexCharacter( PhoneticEntry.isEmpty() ? IndexEntry : PhoneticEntry , rLocale, OUString());
49}
50
52 const OUString& IndexEntry1, const OUString& PhoneticEntry1, const css::lang::Locale& rLocale1,
53 const OUString& IndexEntry2, const OUString& PhoneticEntry2, const css::lang::Locale& rLocale2 )
54{
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)) );
58
59 if (result == 0)
61 IndexEntry1, PhoneticEntry1, rLocale1,
62 IndexEntry2, PhoneticEntry2, rLocale2);
63 return result;
64}
65
66constexpr OUStringLiteral first = u"phonetic (alphanumeric first)";
67sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_syllable::loadAlgorithm(
68 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
69 sal_Int32 collatorOptions )
70{
71 return collator->loadCollatorAlgorithm(first, rLocale, collatorOptions) == 0;
72}
73sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_first_by_consonant::loadAlgorithm(
74 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
75 sal_Int32 collatorOptions )
76{
77 return collator->loadCollatorAlgorithm(first, rLocale, collatorOptions) == 0;
78}
79
80constexpr OUStringLiteral last = u"phonetic (alphanumeric last)";
81sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_syllable::loadAlgorithm(
82 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
83 sal_Int32 collatorOptions )
84{
85 return collator->loadCollatorAlgorithm(last, rLocale, collatorOptions) == 0;
86}
87sal_Bool SAL_CALL IndexEntrySupplier_ja_phonetic_alphanumeric_last_by_consonant::loadAlgorithm(
88 const css::lang::Locale& rLocale, const OUString& /*SortAlgorithm*/,
89 sal_Int32 collatorOptions )
90{
91 return collator->loadCollatorAlgorithm(last, rLocale, collatorOptions) == 0;
92}
93
94}
95
96/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Int16 SAL_CALL compareIndexEntry(const OUString &IndexEntry1, const OUString &PhoneticEntry1, const css::lang::Locale &rLocale1, const OUString &IndexEntry2, const OUString &PhoneticEntry2, const css::lang::Locale &rLocale2) override
virtual sal_Int16 SAL_CALL compareIndexEntry(const OUString &IndexEntry1, const OUString &PhoneticEntry1, const css::lang::Locale &rLocale1, const OUString &IndexEntry2, const OUString &PhoneticEntry2, const css::lang::Locale &rLocale2) override
virtual OUString SAL_CALL getIndexKey(const OUString &IndexEntry, const OUString &PhoneticEntry, const css::lang::Locale &rLocale) override
virtual OUString SAL_CALL getIndexCharacter(const OUString &rIndexEntry, const css::lang::Locale &rLocale, const OUString &rSortAlgorithm) override
float u
const sal_Unicode idxStr[]
const sal_uInt16 idx[]
const sal_Unicode consonant[]
const sal_Unicode syllable[]
Constant values shared between i18npool and, for example, the number formatter.
constexpr OUStringLiteral first
constexpr OUStringLiteral last
unsigned char sal_Bool
sal_uInt16 sal_Unicode
Any result