1*449ab281SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*449ab281SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*449ab281SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*449ab281SAndrew Rist  * distributed with this work for additional information
6*449ab281SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*449ab281SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*449ab281SAndrew Rist  * "License"); you may not use this file except in compliance
9*449ab281SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*449ab281SAndrew Rist  *
11*449ab281SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*449ab281SAndrew Rist  *
13*449ab281SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*449ab281SAndrew Rist  * software distributed under the License is distributed on an
15*449ab281SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*449ab281SAndrew Rist  * KIND, either express or implied.  See the License for the
17*449ab281SAndrew Rist  * specific language governing permissions and limitations
18*449ab281SAndrew Rist  * under the License.
19*449ab281SAndrew Rist  *
20*449ab281SAndrew Rist  *************************************************************/
21*449ab281SAndrew Rist 
22*449ab281SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_i18npool.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // prevent internal compiler error with MSVC6SP3
28cdf0e10cSrcweir #include <utility>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <i18nutil/oneToOneMapping.hxx>
31cdf0e10cSrcweir #define TRANSLITERATION_IandEfollowedByYa_ja_JP
32cdf0e10cSrcweir #include <transliteration_Ignore.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir using namespace com::sun::star::uno;
35cdf0e10cSrcweir using namespace com::sun::star::lang;
36cdf0e10cSrcweir using namespace rtl;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n {
39cdf0e10cSrcweir 
40cdf0e10cSrcweir OneToOneMappingTable_t IandE[] = {
41cdf0e10cSrcweir     MAKE_PAIR( 0x30A3, 0x0000 ),  // KATAKANA LETTER SMALL I
42cdf0e10cSrcweir     MAKE_PAIR( 0x30A4, 0x0000 ),  // KATAKANA LETTER I
43cdf0e10cSrcweir     MAKE_PAIR( 0x30A7, 0x0000 ),  // KATAKANA LETTER SMALL E
44cdf0e10cSrcweir     MAKE_PAIR( 0x30A8, 0x0000 ),  // KATAKANA LETTER E
45cdf0e10cSrcweir     MAKE_PAIR( 0x30AD, 0x0000 ),  // KATAKANA LETTER KI
46cdf0e10cSrcweir     MAKE_PAIR( 0x30AE, 0x0000 ),  // KATAKANA LETTER GI
47cdf0e10cSrcweir     MAKE_PAIR( 0x30B1, 0x0000 ),  // KATAKANA LETTER KE
48cdf0e10cSrcweir     MAKE_PAIR( 0x30B2, 0x0000 ),  // KATAKANA LETTER GE
49cdf0e10cSrcweir     MAKE_PAIR( 0x30B7, 0x0000 ),  // KATAKANA LETTER SI
50cdf0e10cSrcweir     MAKE_PAIR( 0x30B8, 0x0000 ),  // KATAKANA LETTER ZI
51cdf0e10cSrcweir     MAKE_PAIR( 0x30BB, 0x0000 ),  // KATAKANA LETTER SE
52cdf0e10cSrcweir     MAKE_PAIR( 0x30BC, 0x0000 ),  // KATAKANA LETTER ZE
53cdf0e10cSrcweir     MAKE_PAIR( 0x30C1, 0x0000 ),  // KATAKANA LETTER TI
54cdf0e10cSrcweir     MAKE_PAIR( 0x30C2, 0x0000 ),  // KATAKANA LETTER DI
55cdf0e10cSrcweir     MAKE_PAIR( 0x30C6, 0x0000 ),  // KATAKANA LETTER TE
56cdf0e10cSrcweir     MAKE_PAIR( 0x30C7, 0x0000 ),  // KATAKANA LETTER DE
57cdf0e10cSrcweir     MAKE_PAIR( 0x30CB, 0x0000 ),  // KATAKANA LETTER NI
58cdf0e10cSrcweir     MAKE_PAIR( 0x30CD, 0x0000 ),  // KATAKANA LETTER NE
59cdf0e10cSrcweir     MAKE_PAIR( 0x30D2, 0x0000 ),  // KATAKANA LETTER HI
60cdf0e10cSrcweir     MAKE_PAIR( 0x30D3, 0x0000 ),  // KATAKANA LETTER BI
61cdf0e10cSrcweir     MAKE_PAIR( 0x30D4, 0x0000 ),  // KATAKANA LETTER PI
62cdf0e10cSrcweir     MAKE_PAIR( 0x30D8, 0x0000 ),  // KATAKANA LETTER HE
63cdf0e10cSrcweir     MAKE_PAIR( 0x30D9, 0x0000 ),  // KATAKANA LETTER BE
64cdf0e10cSrcweir     MAKE_PAIR( 0x30DA, 0x0000 ),  // KATAKANA LETTER PE
65cdf0e10cSrcweir     MAKE_PAIR( 0x30DF, 0x0000 ),  // KATAKANA LETTER MI
66cdf0e10cSrcweir     MAKE_PAIR( 0x30E1, 0x0000 ),  // KATAKANA LETTER ME
67cdf0e10cSrcweir     MAKE_PAIR( 0x30EA, 0x0000 ),  // KATAKANA LETTER RI
68cdf0e10cSrcweir     MAKE_PAIR( 0x30EC, 0x0000 ),  // KATAKANA LETTER RE
69cdf0e10cSrcweir     MAKE_PAIR( 0x30F0, 0x0000 ),  // KATAKANA LETTER WI
70cdf0e10cSrcweir     MAKE_PAIR( 0x30F1, 0x0000 ),  // KATAKANA LETTER WE
71cdf0e10cSrcweir     MAKE_PAIR( 0x30F6, 0x0000 ),  // KATAKANA LETTER SMALL KE
72cdf0e10cSrcweir     MAKE_PAIR( 0x30F8, 0x0000 ),  // KATAKANA LETTER VI
73cdf0e10cSrcweir     MAKE_PAIR( 0x30F9, 0x0000 )   // KATAKANA LETTER VE
74cdf0e10cSrcweir };
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 
79cdf0e10cSrcweir OUString SAL_CALL
80cdf0e10cSrcweir ignoreIandEfollowedByYa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
81cdf0e10cSrcweir   throw(RuntimeException)
82cdf0e10cSrcweir {
83cdf0e10cSrcweir     // Create a string buffer which can hold nCount + 1 characters.
84cdf0e10cSrcweir     // The reference count is 0 now.
85cdf0e10cSrcweir     rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
86cdf0e10cSrcweir     sal_Unicode * dst = newStr->buffer;
87cdf0e10cSrcweir     const sal_Unicode * src = inStr.getStr() + startPos;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir     sal_Int32 *p = 0;
90cdf0e10cSrcweir 	sal_Int32 position = 0;
91cdf0e10cSrcweir     if (useOffset) {
92cdf0e10cSrcweir         // Allocate nCount length to offset argument.
93cdf0e10cSrcweir         offset.realloc( nCount );
94cdf0e10cSrcweir         p = offset.getArray();
95cdf0e10cSrcweir         position = startPos;
96cdf0e10cSrcweir     }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir     //
99cdf0e10cSrcweir     sal_Unicode previousChar = *src ++;
100cdf0e10cSrcweir     sal_Unicode currentChar;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir     // One to one mapping
103cdf0e10cSrcweir     oneToOneMapping aTable(IandE, sizeof(IandE));
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     // Translation
106cdf0e10cSrcweir     while (-- nCount > 0) {
107cdf0e10cSrcweir         currentChar = *src ++;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir         // the character listed in above table + YA --> the character + A
110cdf0e10cSrcweir         if (currentChar == 0x30E3 ||   // KATAKANA LETTER SMALL YA
111cdf0e10cSrcweir                 currentChar == 0x30E4) {   // KATAKANA LETTER YA
112cdf0e10cSrcweir             if (aTable[ previousChar ] != previousChar) {
113cdf0e10cSrcweir                 if (useOffset) {
114cdf0e10cSrcweir                     *p ++ = position++;
115cdf0e10cSrcweir                     *p ++ = position++;
116cdf0e10cSrcweir                 }
117cdf0e10cSrcweir                 *dst ++ = previousChar;
118cdf0e10cSrcweir                 *dst ++ = 0x30A2;          // KATAKANA LETTER A
119cdf0e10cSrcweir                 previousChar = *src ++;
120cdf0e10cSrcweir                 nCount --;
121cdf0e10cSrcweir                 continue;
122cdf0e10cSrcweir             }
123cdf0e10cSrcweir         }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         if (useOffset)
126cdf0e10cSrcweir             *p ++ = position++;
127cdf0e10cSrcweir         *dst ++ = previousChar;
128cdf0e10cSrcweir         previousChar = currentChar;
129cdf0e10cSrcweir     }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir     if (nCount == 0) {
132cdf0e10cSrcweir         if (useOffset)
133cdf0e10cSrcweir             *p = position;
134cdf0e10cSrcweir         *dst ++ = previousChar;
135cdf0e10cSrcweir     }
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     *dst = (sal_Unicode) 0;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     newStr->length = sal_Int32(dst - newStr->buffer);
140cdf0e10cSrcweir     if (useOffset)
141cdf0e10cSrcweir         offset.realloc(newStr->length);
142cdf0e10cSrcweir     return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1.
143cdf0e10cSrcweir }
144cdf0e10cSrcweir 
145cdf0e10cSrcweir } } } }
146