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_IandEfollowedByYa_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 IandE[] = { 41 MAKE_PAIR( 0x30A3, 0x0000 ), // KATAKANA LETTER SMALL I 42 MAKE_PAIR( 0x30A4, 0x0000 ), // KATAKANA LETTER I 43 MAKE_PAIR( 0x30A7, 0x0000 ), // KATAKANA LETTER SMALL E 44 MAKE_PAIR( 0x30A8, 0x0000 ), // KATAKANA LETTER E 45 MAKE_PAIR( 0x30AD, 0x0000 ), // KATAKANA LETTER KI 46 MAKE_PAIR( 0x30AE, 0x0000 ), // KATAKANA LETTER GI 47 MAKE_PAIR( 0x30B1, 0x0000 ), // KATAKANA LETTER KE 48 MAKE_PAIR( 0x30B2, 0x0000 ), // KATAKANA LETTER GE 49 MAKE_PAIR( 0x30B7, 0x0000 ), // KATAKANA LETTER SI 50 MAKE_PAIR( 0x30B8, 0x0000 ), // KATAKANA LETTER ZI 51 MAKE_PAIR( 0x30BB, 0x0000 ), // KATAKANA LETTER SE 52 MAKE_PAIR( 0x30BC, 0x0000 ), // KATAKANA LETTER ZE 53 MAKE_PAIR( 0x30C1, 0x0000 ), // KATAKANA LETTER TI 54 MAKE_PAIR( 0x30C2, 0x0000 ), // KATAKANA LETTER DI 55 MAKE_PAIR( 0x30C6, 0x0000 ), // KATAKANA LETTER TE 56 MAKE_PAIR( 0x30C7, 0x0000 ), // KATAKANA LETTER DE 57 MAKE_PAIR( 0x30CB, 0x0000 ), // KATAKANA LETTER NI 58 MAKE_PAIR( 0x30CD, 0x0000 ), // KATAKANA LETTER NE 59 MAKE_PAIR( 0x30D2, 0x0000 ), // KATAKANA LETTER HI 60 MAKE_PAIR( 0x30D3, 0x0000 ), // KATAKANA LETTER BI 61 MAKE_PAIR( 0x30D4, 0x0000 ), // KATAKANA LETTER PI 62 MAKE_PAIR( 0x30D8, 0x0000 ), // KATAKANA LETTER HE 63 MAKE_PAIR( 0x30D9, 0x0000 ), // KATAKANA LETTER BE 64 MAKE_PAIR( 0x30DA, 0x0000 ), // KATAKANA LETTER PE 65 MAKE_PAIR( 0x30DF, 0x0000 ), // KATAKANA LETTER MI 66 MAKE_PAIR( 0x30E1, 0x0000 ), // KATAKANA LETTER ME 67 MAKE_PAIR( 0x30EA, 0x0000 ), // KATAKANA LETTER RI 68 MAKE_PAIR( 0x30EC, 0x0000 ), // KATAKANA LETTER RE 69 MAKE_PAIR( 0x30F0, 0x0000 ), // KATAKANA LETTER WI 70 MAKE_PAIR( 0x30F1, 0x0000 ), // KATAKANA LETTER WE 71 MAKE_PAIR( 0x30F6, 0x0000 ), // KATAKANA LETTER SMALL KE 72 MAKE_PAIR( 0x30F8, 0x0000 ), // KATAKANA LETTER VI 73 MAKE_PAIR( 0x30F9, 0x0000 ) // KATAKANA LETTER VE 74 }; 75 76 77 78 79 OUString SAL_CALL 80 ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) 81 throw(RuntimeException) 82 { 83 // Create a string buffer which can hold nCount + 1 characters. 84 // The reference count is 0 now. 85 rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h 86 sal_Unicode * dst = newStr->buffer; 87 const sal_Unicode * src = inStr.getStr() + startPos; 88 89 sal_Int32 *p = 0; 90 sal_Int32 position = 0; 91 if (useOffset) { 92 // Allocate nCount length to offset argument. 93 offset.realloc( nCount ); 94 p = offset.getArray(); 95 position = startPos; 96 } 97 98 // 99 sal_Unicode previousChar = *src ++; 100 sal_Unicode currentChar; 101 102 // One to one mapping 103 oneToOneMapping aTable(IandE, sizeof(IandE)); 104 105 // Translation 106 while (-- nCount > 0) { 107 currentChar = *src ++; 108 109 // the character listed in above table + YA --> the character + A 110 if (currentChar == 0x30E3 || // KATAKANA LETTER SMALL YA 111 currentChar == 0x30E4) { // KATAKANA LETTER YA 112 if (aTable[ previousChar ] != previousChar) { 113 if (useOffset) { 114 *p ++ = position++; 115 *p ++ = position++; 116 } 117 *dst ++ = previousChar; 118 *dst ++ = 0x30A2; // KATAKANA LETTER A 119 previousChar = *src ++; 120 nCount --; 121 continue; 122 } 123 } 124 125 if (useOffset) 126 *p ++ = position++; 127 *dst ++ = previousChar; 128 previousChar = currentChar; 129 } 130 131 if (nCount == 0) { 132 if (useOffset) 133 *p = position; 134 *dst ++ = previousChar; 135 } 136 137 *dst = (sal_Unicode) 0; 138 139 newStr->length = sal_Int32(dst - newStr->buffer); 140 if (useOffset) 141 offset.realloc(newStr->length); 142 return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1. 143 } 144 145 } } } } 146