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_ONETOONE_H_
24 #define _I18N_TRANSLITERATION_TRANSLITERATION_ONETOONE_H_
25 
26 #include <transliteration_commonclass.hxx>
27 #include <i18nutil/oneToOneMapping.hxx>
28 
29 namespace com { namespace sun { namespace star { namespace i18n {
30 
31 typedef sal_Unicode (*TransFunc)(const sal_Unicode);
32 
33 class transliteration_OneToOne : public transliteration_commonclass
34 {
35 public:
36         rtl::OUString SAL_CALL
37         transliterate( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset  )
38         throw(com::sun::star::uno::RuntimeException);
39 
40         sal_Unicode SAL_CALL
41         transliterateChar2Char( sal_Unicode inChar)
42         throw(com::sun::star::uno::RuntimeException,
43         com::sun::star::i18n::MultipleCharsOutputException);
44 
45         // Methods which are shared.
46         sal_Int16 SAL_CALL getType() throw(com::sun::star::uno::RuntimeException);
47 
48         rtl::OUString SAL_CALL
49         folding( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset)
50         throw(com::sun::star::uno::RuntimeException);
51 
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         com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
58         transliterateRange( const rtl::OUString& str1, const rtl::OUString& str2 )
59         throw(com::sun::star::uno::RuntimeException);
60 
61 protected:
62         TransFunc func;
63         oneToOneMapping *table;
64 };
65 
66 #define TRANSLITERATION_ONETOONE( name ) \
67 class name : public transliteration_OneToOne \
68 { \
69 public: \
70     name (); \
71     rtl::OUString SAL_CALL \
72     transliterate( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset ) \
73     throw(com::sun::star::uno::RuntimeException); \
74     sal_Unicode SAL_CALL \
75     transliterateChar2Char( sal_Unicode inChar) \
76     throw(com::sun::star::uno::RuntimeException, \
77         com::sun::star::i18n::MultipleCharsOutputException); \
78 };
79 
80 #if defined( TRANSLITERATION_fullwidthToHalfwidth ) || defined( TRANSLITERATION_ALL )
81 TRANSLITERATION_ONETOONE( fullwidthToHalfwidth )
82 #endif
83 #if defined( TRANSLITERATION_halfwidthToFullwidth ) || defined( TRANSLITERATION_ALL )
84 TRANSLITERATION_ONETOONE(halfwidthToFullwidth)
85 #endif
86 #if defined( TRANSLITERATION_fullwidthKatakanaToHalfwidthKatakana ) || defined( TRANSLITERATION_ALL )
87 TRANSLITERATION_ONETOONE( fullwidthKatakanaToHalfwidthKatakana )
88 #endif
89 #if defined( TRANSLITERATION_halfwidthKatakanaToFullwidthKatakana ) || defined( TRANSLITERATION_ALL )
90 TRANSLITERATION_ONETOONE(halfwidthKatakanaToFullwidthKatakana)
91 #endif
92 #if defined( TRANSLITERATION_fullwidthToHalfwidthLikeASC ) || defined( TRANSLITERATION_ALL )
93 TRANSLITERATION_ONETOONE( fullwidthToHalfwidthLikeASC )
94 #endif
95 #if defined( TRANSLITERATION_halfwidthToFullwidthLikeJIS ) || defined( TRANSLITERATION_ALL )
96 TRANSLITERATION_ONETOONE( halfwidthToFullwidthLikeJIS )
97 #endif
98 #undef TRANSLITERATION_ONETOONE
99 
100 #define TRANSLITERATION_ONETOONE( name ) \
101 class name : public transliteration_OneToOne \
102 { \
103 public: \
104     name (); \
105 };
106 
107 #if defined( TRANSLITERATION_hiraganaToKatakana ) || defined( TRANSLITERATION_ALL )
108 TRANSLITERATION_ONETOONE(hiraganaToKatakana)
109 #endif
110 #if defined( TRANSLITERATION_katakanaToHiragana ) || defined( TRANSLITERATION_ALL )
111 TRANSLITERATION_ONETOONE(katakanaToHiragana)
112 #endif
113 #if defined( TRANSLITERATION_largeToSmall_ja_JP ) || defined( TRANSLITERATION_ALL )
114 TRANSLITERATION_ONETOONE(largeToSmall_ja_JP)
115 #endif
116 #if defined( TRANSLITERATION_smallToLarge_ja_JP ) || defined( TRANSLITERATION_ALL )
117 TRANSLITERATION_ONETOONE(smallToLarge_ja_JP)
118 #endif
119 #undef TRANSLITERATION_ONETOONE
120 
121 } } } }
122 
123 #endif // _I18N_TRANSLITERATION_TRANSLITERATION_ONETOONE_H_
124