1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _I18N_INDEXENTRYSUPPLIER_DEFAULT_HXX_
24 #define _I18N_INDEXENTRYSUPPLIER_DEFAULT_HXX_
25 
26 #include <indexentrysupplier_common.hxx>
27 
28 namespace com { namespace sun { namespace star { namespace i18n {
29 
30 class Index;
31 
32 //	----------------------------------------------------
33 //	class IndexEntrySupplier_Unicode
34 //	----------------------------------------------------
35 class IndexEntrySupplier_Unicode : public IndexEntrySupplier_Common {
36 public:
37 	IndexEntrySupplier_Unicode( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
38 	~IndexEntrySupplier_Unicode();
39 
40 	virtual sal_Bool SAL_CALL loadAlgorithm(
41 		const com::sun::star::lang::Locale& rLocale,
42 		const rtl::OUString& SortAlgorithm, sal_Int32 collatorOptions )
43 		throw (com::sun::star::uno::RuntimeException);
44 
45 	virtual rtl::OUString SAL_CALL getIndexKey( const rtl::OUString& IndexEntry,
46 		const rtl::OUString& PhoneticEntry, const com::sun::star::lang::Locale& rLocale )
47 		throw (com::sun::star::uno::RuntimeException);
48 
49 	virtual sal_Int16 SAL_CALL compareIndexEntry( const rtl::OUString& IndexEntry1,
50 		const rtl::OUString& PhoneticEntry1, const com::sun::star::lang::Locale& rLocale1,
51 		const rtl::OUString& IndexEntry2, const ::rtl::OUString& PhoneticEntry2,
52 		const com::sun::star::lang::Locale& rLocale2 )
53 		throw (com::sun::star::uno::RuntimeException);
54 
55 	virtual rtl::OUString SAL_CALL getIndexCharacter( const rtl::OUString& rIndexEntry,
56 		const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rSortAlgorithm )
57 		throw (com::sun::star::uno::RuntimeException);
58 
59 private:
60     Index *index;
61 };
62 
63 struct IndexKey {
64     sal_Unicode key;
65     rtl::OUString mkey;
66     rtl::OUString desc;
67 };
68 
69 class IndexTable
70 {
71 public:
72     IndexTable();
73     ~IndexTable();
74 
75     void init(sal_Unicode start_, sal_Unicode end_, IndexKey* keys, sal_Int16 key_count, Index *index);
76 
77     sal_Unicode start;
78     sal_Unicode end;
79     sal_uInt8 *table;
80 };
81 
82 #define MAX_KEYS 0xff
83 #define MAX_TABLES 20
84 
85 class Index
86 {
87 public:
88     Index(const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF);
89     ~Index();
90 
91     void init(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& algorithm) throw (com::sun::star::uno::RuntimeException);
92 
93     void makeIndexKeys(const com::sun::star::lang::Locale &rLocale, const rtl::OUString &algorithm) throw (com::sun::star::uno::RuntimeException);
94     sal_Int16 getIndexWeight(const rtl::OUString& rIndexEntry);
95     rtl::OUString getIndexDescription(const rtl::OUString& rIndexEntry);
96 
97     IndexTable tables[MAX_TABLES];
98     sal_Int16 table_count;
99     IndexKey keys[MAX_KEYS];
100     sal_Int16 key_count;
101     sal_Int16 mkeys[MAX_KEYS];
102     sal_Int16 mkey_count;
103     rtl::OUString skipping_chars;
104     CollatorImpl *collator;
105     sal_Int16 compare(sal_Unicode c1, sal_Unicode c2);
106 };
107 
108 } } } }
109 
110 #endif
111