1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _I18N_INDEXENTRYSUPPLIER_DEFAULT_HXX_
28 #define _I18N_INDEXENTRYSUPPLIER_DEFAULT_HXX_
29 
30 #include <indexentrysupplier_common.hxx>
31 
32 namespace com { namespace sun { namespace star { namespace i18n {
33 
34 class Index;
35 
36 //	----------------------------------------------------
37 //	class IndexEntrySupplier_Unicode
38 //	----------------------------------------------------
39 class IndexEntrySupplier_Unicode : public IndexEntrySupplier_Common {
40 public:
41 	IndexEntrySupplier_Unicode( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
42 	~IndexEntrySupplier_Unicode();
43 
44 	virtual sal_Bool SAL_CALL loadAlgorithm(
45 		const com::sun::star::lang::Locale& rLocale,
46 		const rtl::OUString& SortAlgorithm, sal_Int32 collatorOptions )
47 		throw (com::sun::star::uno::RuntimeException);
48 
49 	virtual rtl::OUString SAL_CALL getIndexKey( const rtl::OUString& IndexEntry,
50 		const rtl::OUString& PhoneticEntry, const com::sun::star::lang::Locale& rLocale )
51 		throw (com::sun::star::uno::RuntimeException);
52 
53 	virtual sal_Int16 SAL_CALL compareIndexEntry( const rtl::OUString& IndexEntry1,
54 		const rtl::OUString& PhoneticEntry1, const com::sun::star::lang::Locale& rLocale1,
55 		const rtl::OUString& IndexEntry2, const ::rtl::OUString& PhoneticEntry2,
56 		const com::sun::star::lang::Locale& rLocale2 )
57 		throw (com::sun::star::uno::RuntimeException);
58 
59 	virtual rtl::OUString SAL_CALL getIndexCharacter( const rtl::OUString& rIndexEntry,
60 		const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rSortAlgorithm )
61 		throw (com::sun::star::uno::RuntimeException);
62 
63 private:
64     Index *index;
65 };
66 
67 struct IndexKey {
68     sal_Unicode key;
69     rtl::OUString mkey;
70     rtl::OUString desc;
71 };
72 
73 class IndexTable
74 {
75 public:
76     IndexTable();
77     ~IndexTable();
78 
79     void init(sal_Unicode start_, sal_Unicode end_, IndexKey* keys, sal_Int16 key_count, Index *index);
80 
81     sal_Unicode start;
82     sal_Unicode end;
83     sal_uInt8 *table;
84 };
85 
86 #define MAX_KEYS 0xff
87 #define MAX_TABLES 20
88 
89 class Index
90 {
91 public:
92     Index(const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF);
93     ~Index();
94 
95     void init(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& algorithm) throw (com::sun::star::uno::RuntimeException);
96 
97     void makeIndexKeys(const com::sun::star::lang::Locale &rLocale, const rtl::OUString &algorithm) throw (com::sun::star::uno::RuntimeException);
98     sal_Int16 getIndexWeight(const rtl::OUString& rIndexEntry);
99     rtl::OUString getIndexDescription(const rtl::OUString& rIndexEntry);
100 
101     IndexTable tables[MAX_TABLES];
102     sal_Int16 table_count;
103     IndexKey keys[MAX_KEYS];
104     sal_Int16 key_count;
105     sal_Int16 mkeys[MAX_KEYS];
106     sal_Int16 mkey_count;
107     rtl::OUString skipping_chars;
108     CollatorImpl *collator;
109     sal_Int16 compare(sal_Unicode c1, sal_Unicode c2);
110 };
111 
112 } } } }
113 
114 #endif
115