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