1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ignoreIandEfollowedByYa_ja_JP.cxx,v $
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
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
;
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
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
;
97 sal_Int32 position
= 0;
99 // Allocate nCount length to offset argument.
100 offset
.realloc( nCount
);
101 p
= offset
.getArray();
106 sal_Unicode previousChar
= *src
++;
107 sal_Unicode currentChar
;
109 // One to one mapping
110 oneToOneMapping
aTable(IandE
, sizeof(IandE
));
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
) {
124 *dst
++ = previousChar
;
125 *dst
++ = 0x30A2; // KATAKANA LETTER A
126 previousChar
= *src
++;
134 *dst
++ = previousChar
;
135 previousChar
= currentChar
;
141 *dst
++ = previousChar
;
144 *dst
= (sal_Unicode
) 0;
146 newStr
->length
= sal_Int32(dst
- newStr
->buffer
);
148 offset
.realloc(newStr
->length
);
149 return OUString( newStr
); // defined in rtl/usrting. The reference count is increased from 0 to 1.