1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_i18npool.hxx" 30 31 // prevent internal compiler error with MSVC6SP3 32 #include <utility> 33 34 #include <i18nutil/oneToOneMapping.hxx> 35 #define TRANSLITERATION_IandEfollowedByYa_ja_JP 36 #include <transliteration_Ignore.hxx> 37 38 using namespace com::sun::star::uno; 39 using namespace com::sun::star::lang; 40 using namespace rtl; 41 42 namespace com { namespace sun { namespace star { namespace i18n { 43 44 OneToOneMappingTable_t IandE[] = { 45 MAKE_PAIR( 0x30A3, 0x0000 ), // KATAKANA LETTER SMALL I 46 MAKE_PAIR( 0x30A4, 0x0000 ), // KATAKANA LETTER I 47 MAKE_PAIR( 0x30A7, 0x0000 ), // KATAKANA LETTER SMALL E 48 MAKE_PAIR( 0x30A8, 0x0000 ), // KATAKANA LETTER E 49 MAKE_PAIR( 0x30AD, 0x0000 ), // KATAKANA LETTER KI 50 MAKE_PAIR( 0x30AE, 0x0000 ), // KATAKANA LETTER GI 51 MAKE_PAIR( 0x30B1, 0x0000 ), // KATAKANA LETTER KE 52 MAKE_PAIR( 0x30B2, 0x0000 ), // KATAKANA LETTER GE 53 MAKE_PAIR( 0x30B7, 0x0000 ), // KATAKANA LETTER SI 54 MAKE_PAIR( 0x30B8, 0x0000 ), // KATAKANA LETTER ZI 55 MAKE_PAIR( 0x30BB, 0x0000 ), // KATAKANA LETTER SE 56 MAKE_PAIR( 0x30BC, 0x0000 ), // KATAKANA LETTER ZE 57 MAKE_PAIR( 0x30C1, 0x0000 ), // KATAKANA LETTER TI 58 MAKE_PAIR( 0x30C2, 0x0000 ), // KATAKANA LETTER DI 59 MAKE_PAIR( 0x30C6, 0x0000 ), // KATAKANA LETTER TE 60 MAKE_PAIR( 0x30C7, 0x0000 ), // KATAKANA LETTER DE 61 MAKE_PAIR( 0x30CB, 0x0000 ), // KATAKANA LETTER NI 62 MAKE_PAIR( 0x30CD, 0x0000 ), // KATAKANA LETTER NE 63 MAKE_PAIR( 0x30D2, 0x0000 ), // KATAKANA LETTER HI 64 MAKE_PAIR( 0x30D3, 0x0000 ), // KATAKANA LETTER BI 65 MAKE_PAIR( 0x30D4, 0x0000 ), // KATAKANA LETTER PI 66 MAKE_PAIR( 0x30D8, 0x0000 ), // KATAKANA LETTER HE 67 MAKE_PAIR( 0x30D9, 0x0000 ), // KATAKANA LETTER BE 68 MAKE_PAIR( 0x30DA, 0x0000 ), // KATAKANA LETTER PE 69 MAKE_PAIR( 0x30DF, 0x0000 ), // KATAKANA LETTER MI 70 MAKE_PAIR( 0x30E1, 0x0000 ), // KATAKANA LETTER ME 71 MAKE_PAIR( 0x30EA, 0x0000 ), // KATAKANA LETTER RI 72 MAKE_PAIR( 0x30EC, 0x0000 ), // KATAKANA LETTER RE 73 MAKE_PAIR( 0x30F0, 0x0000 ), // KATAKANA LETTER WI 74 MAKE_PAIR( 0x30F1, 0x0000 ), // KATAKANA LETTER WE 75 MAKE_PAIR( 0x30F6, 0x0000 ), // KATAKANA LETTER SMALL KE 76 MAKE_PAIR( 0x30F8, 0x0000 ), // KATAKANA LETTER VI 77 MAKE_PAIR( 0x30F9, 0x0000 ) // KATAKANA LETTER VE 78 }; 79 80 81 82 83 OUString SAL_CALL 84 ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) 85 throw(RuntimeException) 86 { 87 // Create a string buffer which can hold nCount + 1 characters. 88 // The reference count is 0 now. 89 rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h 90 sal_Unicode * dst = newStr->buffer; 91 const sal_Unicode * src = inStr.getStr() + startPos; 92 93 sal_Int32 *p = 0; 94 sal_Int32 position = 0; 95 if (useOffset) { 96 // Allocate nCount length to offset argument. 97 offset.realloc( nCount ); 98 p = offset.getArray(); 99 position = startPos; 100 } 101 102 // 103 sal_Unicode previousChar = *src ++; 104 sal_Unicode currentChar; 105 106 // One to one mapping 107 oneToOneMapping aTable(IandE, sizeof(IandE)); 108 109 // Translation 110 while (-- nCount > 0) { 111 currentChar = *src ++; 112 113 // the character listed in above table + YA --> the character + A 114 if (currentChar == 0x30E3 || // KATAKANA LETTER SMALL YA 115 currentChar == 0x30E4) { // KATAKANA LETTER YA 116 if (aTable[ previousChar ] != previousChar) { 117 if (useOffset) { 118 *p ++ = position++; 119 *p ++ = position++; 120 } 121 *dst ++ = previousChar; 122 *dst ++ = 0x30A2; // KATAKANA LETTER A 123 previousChar = *src ++; 124 nCount --; 125 continue; 126 } 127 } 128 129 if (useOffset) 130 *p ++ = position++; 131 *dst ++ = previousChar; 132 previousChar = currentChar; 133 } 134 135 if (nCount == 0) { 136 if (useOffset) 137 *p = position; 138 *dst ++ = previousChar; 139 } 140 141 *dst = (sal_Unicode) 0; 142 143 newStr->length = sal_Int32(dst - newStr->buffer); 144 if (useOffset) 145 offset.realloc(newStr->length); 146 return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1. 147 } 148 149 } } } } 150