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_TRANSLITERATION_TRANSLITERATION_IGNORE_H_
28 #define _I18N_TRANSLITERATION_TRANSLITERATION_IGNORE_H_
29 
30 #include <transliteration_commonclass.hxx>
31 #include <i18nutil/oneToOneMapping.hxx>
32 
33 typedef sal_Unicode (*TransFunc)(const sal_Unicode);
34 
35 typedef struct {
36     sal_Unicode previousChar;
37     sal_Unicode currentChar;
38     sal_Unicode replaceChar;
39     sal_Bool two2one;
40 } Mapping;
41 
42 namespace com { namespace sun { namespace star { namespace i18n {
43 
44 class transliteration_Ignore : public transliteration_commonclass
45 {
46 public:
47         virtual rtl::OUString SAL_CALL
48         folding( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset)
49         throw(com::sun::star::uno::RuntimeException);
50 
51         // This method is shared.
52         sal_Bool SAL_CALL
53         equals( const rtl::OUString& str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32& nMatch1,
54             const rtl::OUString& str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32& nMatch2 )
55         throw(com::sun::star::uno::RuntimeException);
56 
57         // This method is implemented in sub class if needed. Otherwise, the method implemented in this class will be used.
58         com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
59         transliterateRange( const rtl::OUString& str1, const rtl::OUString& str2 )
60         throw(com::sun::star::uno::RuntimeException);
61 
62 
63         // Methods which are shared.
64         sal_Int16 SAL_CALL getType(  ) throw(com::sun::star::uno::RuntimeException);
65 
66         rtl::OUString SAL_CALL
67         transliterate( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset  )
68         throw(com::sun::star::uno::RuntimeException);
69 
70         virtual sal_Unicode SAL_CALL
71         transliterateChar2Char( sal_Unicode inChar)
72         throw(com::sun::star::uno::RuntimeException,
73             com::sun::star::i18n::MultipleCharsOutputException);
74 
75         com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
76         transliterateRange( const rtl::OUString& str1, const rtl::OUString& str2, XTransliteration& t1, XTransliteration& t2 )
77         throw(com::sun::star::uno::RuntimeException);
78 
79 protected:
80         TransFunc func;
81         oneToOneMapping *table;
82         Mapping *map;
83 };
84 
85 #define TRANSLITERATION_IGNORE( name ) \
86 class ignore##name : public transliteration_Ignore {\
87 public:\
88         ignore##name ();\
89 };
90 
91 #if defined( TRANSLITERATION_BaFa_ja_JP ) || defined( TRANSLITERATION_ALL )
92 TRANSLITERATION_IGNORE(BaFa_ja_JP)
93 #endif
94 #if defined( TRANSLITERATION_HyuByu_ja_JP ) || defined( TRANSLITERATION_ALL )
95 TRANSLITERATION_IGNORE(HyuByu_ja_JP)
96 #endif
97 #if defined( TRANSLITERATION_SeZe_ja_JP ) || defined( TRANSLITERATION_ALL )
98 TRANSLITERATION_IGNORE(SeZe_ja_JP)
99 #endif
100 #if defined( TRANSLITERATION_TiJi_ja_JP ) || defined( TRANSLITERATION_ALL )
101 TRANSLITERATION_IGNORE(TiJi_ja_JP)
102 #endif
103 #if defined( TRANSLITERATION_MiddleDot_ja_JP ) || defined( TRANSLITERATION_ALL )
104 TRANSLITERATION_IGNORE(MiddleDot_ja_JP)
105 #endif
106 #if defined( TRANSLITERATION_MinusSign_ja_JP ) || defined( TRANSLITERATION_ALL )
107 TRANSLITERATION_IGNORE(MinusSign_ja_JP)
108 #endif
109 #if defined( TRANSLITERATION_Separator_ja_JP ) || defined( TRANSLITERATION_ALL )
110 TRANSLITERATION_IGNORE(Separator_ja_JP)
111 #endif
112 #if defined( TRANSLITERATION_Space_ja_JP ) || defined( TRANSLITERATION_ALL )
113 TRANSLITERATION_IGNORE(Space_ja_JP)
114 #endif
115 #if defined( TRANSLITERATION_TraditionalKana_ja_JP ) || defined( TRANSLITERATION_ALL )
116 TRANSLITERATION_IGNORE(TraditionalKana_ja_JP)
117 #endif
118 #if defined( TRANSLITERATION_TraditionalKanji_ja_JP ) || defined( TRANSLITERATION_ALL )
119 TRANSLITERATION_IGNORE(TraditionalKanji_ja_JP)
120 #endif
121 #if defined( TRANSLITERATION_ZiZu_ja_JP ) || defined( TRANSLITERATION_ALL )
122 TRANSLITERATION_IGNORE(ZiZu_ja_JP)
123 #endif
124 #undef TRANSLITERATION_IGNORE
125 
126 #define TRANSLITERATION_IGNORE( name ) \
127 class ignore##name : public transliteration_Ignore {\
128 public:\
129         ignore##name () {\
130             func = (TransFunc) 0;\
131             table = 0;\
132             map = 0;\
133             transliterationName = "ignore"#name;\
134             implementationName = "com.sun.star.i18n.Transliteration.ignore"#name;\
135         };\
136         rtl::OUString SAL_CALL folding( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, \
137                 com::sun::star::uno::Sequence< sal_Int32 >& offset) throw(com::sun::star::uno::RuntimeException); \
138 };
139 
140 #if defined( TRANSLITERATION_KiKuFollowedBySa_ja_JP ) || defined( TRANSLITERATION_ALL )
141 TRANSLITERATION_IGNORE(KiKuFollowedBySa_ja_JP)
142 #endif
143 #if defined( TRANSLITERATION_IandEfollowedByYa_ja_JP ) || defined( TRANSLITERATION_ALL )
144 TRANSLITERATION_IGNORE(IandEfollowedByYa_ja_JP)
145 #endif
146 #if defined( TRANSLITERATION_IterationMark_ja_JP ) || defined( TRANSLITERATION_ALL )
147 TRANSLITERATION_IGNORE(IterationMark_ja_JP)
148 #endif
149 #if defined( TRANSLITERATION_ProlongedSoundMark_ja_JP ) || defined( TRANSLITERATION_ALL )
150 TRANSLITERATION_IGNORE(ProlongedSoundMark_ja_JP)
151 #endif
152 #undef TRANSLITERATION_IGNORE
153 
154 #define TRANSLITERATION_IGNORE( name ) \
155 class ignore##name : public transliteration_Ignore {\
156 public:\
157         ignore##name () {\
158             func = (TransFunc) 0;\
159             table = 0;\
160             map = 0;\
161             transliterationName = "ignore"#name;\
162             implementationName = "com.sun.star.i18n.Transliteration.ignore"#name;\
163         };\
164         rtl::OUString SAL_CALL folding( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, \
165                 com::sun::star::uno::Sequence< sal_Int32 >& offset) throw(com::sun::star::uno::RuntimeException); \
166         using transliteration_Ignore::transliterateRange;\
167         com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL transliterateRange( const rtl::OUString& str1, \
168                 const rtl::OUString& str2 ) throw(com::sun::star::uno::RuntimeException); \
169         sal_Unicode SAL_CALL \
170         transliterateChar2Char( sal_Unicode inChar) \
171         throw(com::sun::star::uno::RuntimeException,\
172             com::sun::star::i18n::MultipleCharsOutputException);\
173 };
174 
175 #if defined( TRANSLITERATION_Kana ) || defined( TRANSLITERATION_ALL )
176 TRANSLITERATION_IGNORE(Kana)
177 #endif
178 #if defined( TRANSLITERATION_Width ) || defined( TRANSLITERATION_ALL )
179 TRANSLITERATION_IGNORE(Width)
180 #endif
181 #if defined( TRANSLITERATION_Size_ja_JP ) || defined( TRANSLITERATION_ALL )
182 TRANSLITERATION_IGNORE(Size_ja_JP)
183 #endif
184 #undef TRANSLITERATION_IGNORE
185 
186 } } } }
187 
188 #endif // _I18N_TRANSLITERATION_TRANSLITERATION_IGNORE_H_
189