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 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_i18npool.hxx" 26 27 // prevent internal compiler error with MSVC6SP3 28 #include <utility> 29 30 #include <i18nutil/oneToOneMapping.hxx> 31 #define TRANSLITERATION_IterationMark_ja_JP 32 #include <transliteration_Ignore.hxx> 33 34 using namespace com::sun::star::uno; 35 using namespace com::sun::star::lang; 36 using namespace rtl; 37 38 namespace com { namespace sun { namespace star { namespace i18n { 39 40 OneToOneMappingTable_t ignoreIterationMark_ja_JP_mappingTable[] = { 41 MAKE_PAIR( 0x3046, 0x3094 ), // HIRAGANA LETTER U --> HIRAGANA LETTER VU 42 MAKE_PAIR( 0x304B, 0x304C ), // HIRAGANA LETTER KA --> HIRAGANA LETTER GA 43 MAKE_PAIR( 0x304D, 0x304E ), // HIRAGANA LETTER KI --> HIRAGANA LETTER GI 44 MAKE_PAIR( 0x304F, 0x3050 ), // HIRAGANA LETTER KU --> HIRAGANA LETTER GU 45 MAKE_PAIR( 0x3051, 0x3052 ), // HIRAGANA LETTER KE --> HIRAGANA LETTER GE 46 MAKE_PAIR( 0x3053, 0x3054 ), // HIRAGANA LETTER KO --> HIRAGANA LETTER GO 47 MAKE_PAIR( 0x3055, 0x3056 ), // HIRAGANA LETTER SA --> HIRAGANA LETTER ZA 48 MAKE_PAIR( 0x3057, 0x3058 ), // HIRAGANA LETTER SI --> HIRAGANA LETTER ZI 49 MAKE_PAIR( 0x3059, 0x305A ), // HIRAGANA LETTER SU --> HIRAGANA LETTER ZU 50 MAKE_PAIR( 0x305B, 0x305C ), // HIRAGANA LETTER SE --> HIRAGANA LETTER ZE 51 MAKE_PAIR( 0x305D, 0x305E ), // HIRAGANA LETTER SO --> HIRAGANA LETTER ZO 52 MAKE_PAIR( 0x305F, 0x3060 ), // HIRAGANA LETTER TA --> HIRAGANA LETTER DA 53 MAKE_PAIR( 0x3061, 0x3062 ), // HIRAGANA LETTER TI --> HIRAGANA LETTER DI 54 MAKE_PAIR( 0x3064, 0x3065 ), // HIRAGANA LETTER TU --> HIRAGANA LETTER DU 55 MAKE_PAIR( 0x3066, 0x3067 ), // HIRAGANA LETTER TE --> HIRAGANA LETTER DE 56 MAKE_PAIR( 0x3068, 0x3069 ), // HIRAGANA LETTER TO --> HIRAGANA LETTER DO 57 MAKE_PAIR( 0x306F, 0x3070 ), // HIRAGANA LETTER HA --> HIRAGANA LETTER BA 58 MAKE_PAIR( 0x3072, 0x3073 ), // HIRAGANA LETTER HI --> HIRAGANA LETTER BI 59 MAKE_PAIR( 0x3075, 0x3076 ), // HIRAGANA LETTER HU --> HIRAGANA LETTER BU 60 MAKE_PAIR( 0x3078, 0x3079 ), // HIRAGANA LETTER HE --> HIRAGANA LETTER BE 61 MAKE_PAIR( 0x307B, 0x307C ), // HIRAGANA LETTER HO --> HIRAGANA LETTER BO 62 MAKE_PAIR( 0x309D, 0x309E ), // HIRAGANA ITERATION MARK --> HIRAGANA VOICED ITERATION MARK 63 MAKE_PAIR( 0x30A6, 0x30F4 ), // KATAKANA LETTER U --> KATAKANA LETTER VU 64 MAKE_PAIR( 0x30AB, 0x30AC ), // KATAKANA LETTER KA --> KATAKANA LETTER GA 65 MAKE_PAIR( 0x30AD, 0x30AE ), // KATAKANA LETTER KI --> KATAKANA LETTER GI 66 MAKE_PAIR( 0x30AF, 0x30B0 ), // KATAKANA LETTER KU --> KATAKANA LETTER GU 67 MAKE_PAIR( 0x30B1, 0x30B2 ), // KATAKANA LETTER KE --> KATAKANA LETTER GE 68 MAKE_PAIR( 0x30B3, 0x30B4 ), // KATAKANA LETTER KO --> KATAKANA LETTER GO 69 MAKE_PAIR( 0x30B5, 0x30B6 ), // KATAKANA LETTER SA --> KATAKANA LETTER ZA 70 MAKE_PAIR( 0x30B7, 0x30B8 ), // KATAKANA LETTER SI --> KATAKANA LETTER ZI 71 MAKE_PAIR( 0x30B9, 0x30BA ), // KATAKANA LETTER SU --> KATAKANA LETTER ZU 72 MAKE_PAIR( 0x30BB, 0x30BC ), // KATAKANA LETTER SE --> KATAKANA LETTER ZE 73 MAKE_PAIR( 0x30BD, 0x30BE ), // KATAKANA LETTER SO --> KATAKANA LETTER ZO 74 MAKE_PAIR( 0x30BF, 0x30C0 ), // KATAKANA LETTER TA --> KATAKANA LETTER DA 75 MAKE_PAIR( 0x30C1, 0x30C2 ), // KATAKANA LETTER TI --> KATAKANA LETTER DI 76 MAKE_PAIR( 0x30C4, 0x30C5 ), // KATAKANA LETTER TU --> KATAKANA LETTER DU 77 MAKE_PAIR( 0x30C6, 0x30C7 ), // KATAKANA LETTER TE --> KATAKANA LETTER DE 78 MAKE_PAIR( 0x30C8, 0x30C9 ), // KATAKANA LETTER TO --> KATAKANA LETTER DO 79 MAKE_PAIR( 0x30CF, 0x30D0 ), // KATAKANA LETTER HA --> KATAKANA LETTER BA 80 MAKE_PAIR( 0x30D2, 0x30D3 ), // KATAKANA LETTER HI --> KATAKANA LETTER BI 81 MAKE_PAIR( 0x30D5, 0x30D6 ), // KATAKANA LETTER HU --> KATAKANA LETTER BU 82 MAKE_PAIR( 0x30D8, 0x30D9 ), // KATAKANA LETTER HE --> KATAKANA LETTER BE 83 MAKE_PAIR( 0x30DB, 0x30DC ), // KATAKANA LETTER HO --> KATAKANA LETTER BO 84 MAKE_PAIR( 0x30EF, 0x30F7 ), // KATAKANA LETTER WA --> KATAKANA LETTER VA 85 MAKE_PAIR( 0x30F0, 0x30F8 ), // KATAKANA LETTER WI --> KATAKANA LETTER VI 86 MAKE_PAIR( 0x30F1, 0x30F9 ), // KATAKANA LETTER WE --> KATAKANA LETTER VE 87 MAKE_PAIR( 0x30F2, 0x30FA ), // KATAKANA LETTER WO --> KATAKANA LETTER VO 88 MAKE_PAIR( 0x30FD, 0x30FE ) // KATAKANA ITERATION MARK --> KATAKANA VOICED ITERATION MARK 89 }; 90 91 92 OUString SAL_CALL 93 ignoreIterationMark_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) 94 throw(RuntimeException) 95 { 96 oneToOneMapping aTable(ignoreIterationMark_ja_JP_mappingTable, sizeof(ignoreIterationMark_ja_JP_mappingTable)); 97 98 // Create a string buffer which can hold nCount + 1 characters. 99 // The reference count is 0 now. 100 rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h 101 sal_Unicode * dst = newStr->buffer; 102 const sal_Unicode * src = inStr.getStr() + startPos; 103 104 sal_Int32 * p = 0; 105 sal_Int32 position = 0; 106 if (useOffset) { 107 // Allocate nCount length to offset argument. 108 offset.realloc( nCount ); 109 p = offset.getArray(); 110 position = startPos; 111 } 112 113 // 114 sal_Unicode previousChar = *src ++; 115 sal_Unicode currentChar; 116 117 // Conversion 118 while (-- nCount > 0) { 119 currentChar = *src ++; 120 121 switch ( currentChar ) { 122 case 0x30fd: // KATAKANA ITERATION MARK 123 case 0x309d: // HIRAGANA ITERATION MARK 124 case 0x3005: // IDEOGRAPHIC ITERATION MARK 125 currentChar = previousChar; 126 break; 127 case 0x30fe: // KATAKANA VOICED ITERATION MARK 128 case 0x309e: // HIRAGANA VOICED ITERATION MARK 129 currentChar = aTable[ previousChar ]; 130 break; 131 } 132 if (useOffset) 133 *p ++ = position ++; 134 *dst ++ = previousChar; 135 previousChar = currentChar; 136 } 137 138 if (nCount == 0) { 139 if (useOffset) 140 *p = position; 141 *dst ++ = previousChar; 142 } 143 144 *dst = (sal_Unicode) 0; 145 146 newStr->length = sal_Int32(dst - newStr->buffer); 147 if (useOffset) 148 offset.realloc(newStr->length); 149 return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1. 150 151 } 152 153 } } } } 154