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 39 sal_Unicode SAL_CALL 40 transliterateChar2Char( sal_Unicode inChar); 41 42 // Methods which are shared. 43 sal_Int16 SAL_CALL getType(); 44 45 rtl::OUString SAL_CALL 46 folding( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset); 47 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 52 com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 53 transliterateRange( const rtl::OUString& str1, const rtl::OUString& str2 ); 54 55 protected: 56 TransFunc func; 57 oneToOneMapping *table; 58 }; 59 60 #define TRANSLITERATION_ONETOONE( name ) \ 61 class name : public transliteration_OneToOne \ 62 { \ 63 public: \ 64 name (); \ 65 rtl::OUString SAL_CALL \ 66 transliterate( const rtl::OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, com::sun::star::uno::Sequence< sal_Int32 >& offset ) \ 67 ; \ 68 sal_Unicode SAL_CALL \ 69 transliterateChar2Char( sal_Unicode inChar) \ 70 ; \ 71 }; 72 73 #if defined( TRANSLITERATION_fullwidthToHalfwidth ) || defined( TRANSLITERATION_ALL ) 74 TRANSLITERATION_ONETOONE( fullwidthToHalfwidth ) 75 #endif 76 #if defined( TRANSLITERATION_halfwidthToFullwidth ) || defined( TRANSLITERATION_ALL ) 77 TRANSLITERATION_ONETOONE(halfwidthToFullwidth) 78 #endif 79 #if defined( TRANSLITERATION_fullwidthKatakanaToHalfwidthKatakana ) || defined( TRANSLITERATION_ALL ) 80 TRANSLITERATION_ONETOONE( fullwidthKatakanaToHalfwidthKatakana ) 81 #endif 82 #if defined( TRANSLITERATION_halfwidthKatakanaToFullwidthKatakana ) || defined( TRANSLITERATION_ALL ) 83 TRANSLITERATION_ONETOONE(halfwidthKatakanaToFullwidthKatakana) 84 #endif 85 #if defined( TRANSLITERATION_fullwidthToHalfwidthLikeASC ) || defined( TRANSLITERATION_ALL ) 86 TRANSLITERATION_ONETOONE( fullwidthToHalfwidthLikeASC ) 87 #endif 88 #if defined( TRANSLITERATION_halfwidthToFullwidthLikeJIS ) || defined( TRANSLITERATION_ALL ) 89 TRANSLITERATION_ONETOONE( halfwidthToFullwidthLikeJIS ) 90 #endif 91 #undef TRANSLITERATION_ONETOONE 92 93 #define TRANSLITERATION_ONETOONE( name ) \ 94 class name : public transliteration_OneToOne \ 95 { \ 96 public: \ 97 name (); \ 98 }; 99 100 #if defined( TRANSLITERATION_hiraganaToKatakana ) || defined( TRANSLITERATION_ALL ) 101 TRANSLITERATION_ONETOONE(hiraganaToKatakana) 102 #endif 103 #if defined( TRANSLITERATION_katakanaToHiragana ) || defined( TRANSLITERATION_ALL ) 104 TRANSLITERATION_ONETOONE(katakanaToHiragana) 105 #endif 106 #if defined( TRANSLITERATION_largeToSmall_ja_JP ) || defined( TRANSLITERATION_ALL ) 107 TRANSLITERATION_ONETOONE(largeToSmall_ja_JP) 108 #endif 109 #if defined( TRANSLITERATION_smallToLarge_ja_JP ) || defined( TRANSLITERATION_ALL ) 110 TRANSLITERATION_ONETOONE(smallToLarge_ja_JP) 111 #endif 112 #undef TRANSLITERATION_ONETOONE 113 114 } } } } 115 116 #endif // _I18N_TRANSLITERATION_TRANSLITERATION_ONETOONE_H_ 117