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