1449ab281SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3449ab281SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4449ab281SAndrew Rist * or more contributor license agreements. See the NOTICE file
5449ab281SAndrew Rist * distributed with this work for additional information
6449ab281SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7449ab281SAndrew Rist * to you under the Apache License, Version 2.0 (the
8449ab281SAndrew Rist * "License"); you may not use this file except in compliance
9449ab281SAndrew Rist * with the License. You may obtain a copy of the License at
10449ab281SAndrew Rist *
11449ab281SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12449ab281SAndrew Rist *
13449ab281SAndrew Rist * Unless required by applicable law or agreed to in writing,
14449ab281SAndrew Rist * software distributed under the License is distributed on an
15449ab281SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16449ab281SAndrew Rist * KIND, either express or implied. See the License for the
17449ab281SAndrew Rist * specific language governing permissions and limitations
18449ab281SAndrew Rist * under the License.
19449ab281SAndrew Rist *
20449ab281SAndrew Rist *************************************************************/
21449ab281SAndrew Rist
22449ab281SAndrew 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 #define TRANSLITERATION_KiKuFollowedBySa_ja_JP
31cdf0e10cSrcweir #include <transliteration_Ignore.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir using namespace com::sun::star::uno;
34cdf0e10cSrcweir using namespace com::sun::star::lang;
35cdf0e10cSrcweir using namespace rtl;
36cdf0e10cSrcweir
37cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace i18n {
38cdf0e10cSrcweir
39cdf0e10cSrcweir OUString SAL_CALL
folding(const OUString & inStr,sal_Int32 startPos,sal_Int32 nCount,Sequence<sal_Int32> & offset)40cdf0e10cSrcweir ignoreKiKuFollowedBySa_ja_JP::folding( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
41cdf0e10cSrcweir throw(RuntimeException)
42cdf0e10cSrcweir {
43cdf0e10cSrcweir // Create a string buffer which can hold nCount + 1 characters.
44cdf0e10cSrcweir // The reference count is 0 now.
45cdf0e10cSrcweir rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
46cdf0e10cSrcweir sal_Unicode * dst = newStr->buffer;
47cdf0e10cSrcweir const sal_Unicode * src = inStr.getStr() + startPos;
48cdf0e10cSrcweir
49cdf0e10cSrcweir sal_Int32 *p = 0;
50cdf0e10cSrcweir sal_Int32 position = 0;
51cdf0e10cSrcweir if (useOffset) {
52cdf0e10cSrcweir // Allocate nCount length to offset argument.
53cdf0e10cSrcweir offset.realloc( nCount );
54cdf0e10cSrcweir p = offset.getArray();
55cdf0e10cSrcweir position = startPos;
56cdf0e10cSrcweir }
57cdf0e10cSrcweir
58cdf0e10cSrcweir //
59cdf0e10cSrcweir sal_Unicode previousChar = *src ++;
60cdf0e10cSrcweir sal_Unicode currentChar;
61cdf0e10cSrcweir
62cdf0e10cSrcweir // Translation
63cdf0e10cSrcweir while (-- nCount > 0) {
64cdf0e10cSrcweir currentChar = *src ++;
65cdf0e10cSrcweir
66cdf0e10cSrcweir // KU + Sa-So --> KI + Sa-So
67cdf0e10cSrcweir if (previousChar == 0x30AF ) { // KATAKANA LETTER KU
68cdf0e10cSrcweir if (0x30B5 <= currentChar && // KATAKANA LETTER SA
69cdf0e10cSrcweir currentChar <= 0x30BE) { // KATAKANA LETTER ZO
70cdf0e10cSrcweir if (useOffset) {
71cdf0e10cSrcweir *p ++ = position++;
72cdf0e10cSrcweir *p ++ = position++;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir *dst ++ = 0x30AD; // KATAKANA LETTER KI
75cdf0e10cSrcweir *dst ++ = currentChar;
76cdf0e10cSrcweir previousChar = *src ++;
77cdf0e10cSrcweir nCount --;
78cdf0e10cSrcweir continue;
79cdf0e10cSrcweir }
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir if (useOffset)
83cdf0e10cSrcweir *p ++ = position++;
84cdf0e10cSrcweir *dst ++ = previousChar;
85cdf0e10cSrcweir previousChar = currentChar;
86cdf0e10cSrcweir }
87cdf0e10cSrcweir
88cdf0e10cSrcweir if (nCount == 0) {
89cdf0e10cSrcweir if (useOffset)
90cdf0e10cSrcweir *p = position;
91cdf0e10cSrcweir *dst ++ = previousChar;
92cdf0e10cSrcweir }
93cdf0e10cSrcweir
94cdf0e10cSrcweir *dst = (sal_Unicode) 0;
95cdf0e10cSrcweir
96cdf0e10cSrcweir newStr->length = sal_Int32(dst - newStr->buffer);
97cdf0e10cSrcweir if (useOffset)
98cdf0e10cSrcweir offset.realloc(newStr->length);
99*4674bdb9SOliver-Rainer Wittmann return OUString( newStr, SAL_NO_ACQUIRE ); // take over ownership of <newStr>
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir } } } }
103