24#include <com/sun/star/i18n/CollatorOptions.hpp>
35 const css::uno::Reference < css::uno::XComponentContext >& rxContext ) :
47 const OUString& rAlgorithm, sal_Int32 collatorOptions )
49 index->init(rLocale, rAlgorithm);
54 const OUString& rPhoneticEntry,
const lang::Locale& rLocale )
56 return index->getIndexDescription(
getEntry(rIndexEntry, rPhoneticEntry, rLocale));
60 const OUString& rIndexEntry1,
const OUString& rPhoneticEntry1,
const lang::Locale& rLocale1,
61 const OUString& rIndexEntry2,
const OUString& rPhoneticEntry2,
const lang::Locale& rLocale2 )
64 index->getIndexWeight(
getEntry(rIndexEntry1, rPhoneticEntry1, rLocale1)) -
65 index->getIndexWeight(
getEntry(rIndexEntry2, rPhoneticEntry2, rLocale2));
68 rIndexEntry1, rPhoneticEntry1, rLocale1,
69 rIndexEntry2, rPhoneticEntry2, rLocale2);
70 return result > 0 ? 1 : -1;
74 const lang::Locale& rLocale,
const OUString& rAlgorithm ) {
76 if (
loadAlgorithm( rLocale, rAlgorithm, CollatorOptions::CollatorOptions_IGNORE_CASE_ACCENT))
77 return index->getIndexDescription(rIndexEntry);
101 for (j = 0; j < key_count; j++) {
102 if (keys[j].key > 0 && (
i == keys[j].key ||
index->compare(
i, keys[j].
key) == 0)) {
103 table[
i-
start] = sal::static_int_cast<sal_uInt8>(j);
112Index::Index(
const css::uno::Reference < css::uno::XComponentContext >& rxContext)
126 return sal::static_int_cast<sal_Int16>(
collator->compareString(OUString(&c1, 1), OUString(&c2, 1)) );
131 sal_Int32 startPos=0;
138 if (
collator->compareSubstring(rIndexEntry, startPos, len,
143 sal_Unicode code = startPos < rIndexEntry.getLength() ? rIndexEntry[startPos] : 0;
155 if (!
keys[wgt].desc.isEmpty())
157 else if (
keys[wgt].key > 0)
158 return OUString(&
keys[wgt].key, 1);
162 sal_uInt32 indexChar=rIndexEntry.iterateCodePoints(&
o3tl::temporary(sal_Int32(0)), 0);
163 return OUString(&indexChar, 1);
166#define LOCALE_EN lang::Locale("en", OUString(), OUString())
172 if (keyStr.isEmpty()) {
175 if (keyStr.isEmpty())
177 "Index::makeIndexKeys: No index keys returned by algorithm");
180 sal_Int16 len = sal::static_int_cast<sal_Int16>( keyStr.getLength() );
195 if (key_count <= 0 || i + 1 >= len)
197 "'-' is the last char of KeyString");
205 for (
i++;
i < len && keyStr[
i] !=
']';
i++) {
208 }
else if (keyStr[
i] ==
'_') {
209 for (curr=keyStr[
i-1]+1; curr <= keyStr[
i+1]; curr++)
257void Index::init(
const lang::Locale &rLocale,
const OUString& algorithm)
273 collator->loadCollatorAlgorithm(algorithm, rLocale, CollatorOptions::CollatorOptions_IGNORE_CASE_ACCENT);
const char * implementationName
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_Bool SAL_CALL loadAlgorithm(const css::lang::Locale &rLocale, const OUString &SortAlgorithm, sal_Int32 collatorOptions) override
virtual OUString SAL_CALL getIndexCharacter(const OUString &rIndexEntry, const css::lang::Locale &rLocale, const OUString &rSortAlgorithm) override
const OUString & getEntry(const OUString &IndexEntry, const OUString &PhoneticEntry, const css::lang::Locale &rLocale) const
std::unique_ptr< Index > index
IndexEntrySupplier_Unicode(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
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 ~IndexEntrySupplier_Unicode() override
virtual OUString SAL_CALL getIndexCharacter(const OUString &rIndexEntry, const css::lang::Locale &rLocale, const OUString &rSortAlgorithm) override
virtual sal_Bool SAL_CALL loadAlgorithm(const css::lang::Locale &rLocale, const OUString &SortAlgorithm, sal_Int32 collatorOptions) override
virtual OUString SAL_CALL getIndexKey(const OUString &IndexEntry, const OUString &PhoneticEntry, const css::lang::Locale &rLocale) override
void init(sal_Unicode start_, sal_Unicode end_, IndexKey const *keys, sal_Int16 key_count, Index *index)
OUString getIndexDescription(const OUString &rIndexEntry)
rtl::Reference< CollatorImpl > collator
sal_Int16 getIndexWeight(const OUString &rIndexEntry)
sal_Int16 mkeys[MAX_KEYS]
sal_Int16 compare(sal_Unicode c1, sal_Unicode c2)
void init(const css::lang::Locale &rLocale, const OUString &algorithm)
void makeIndexKeys(const css::lang::Locale &rLocale, std::u16string_view algorithm)
IndexTable tables[MAX_TABLES]
Index(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
static rtl::Reference< LocaleDataImpl > get()
static bool isWhiteSpace(const sal_uInt32 ch)
static sal_Unicode getUnicodeScriptStart(css::i18n::UnicodeScript type)
static sal_Unicode getUnicodeScriptEnd(css::i18n::UnicodeScript type)
const UBlockScript scriptList[]
Constant values shared between i18npool and, for example, the number formatter.
constexpr T & temporary(T &&x)