1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_i18npool.hxx"
26
27 // prevent internal compiler error with MSVC6SP3
28 #include <utility>
29
30 #include <transliteration_OneToOne.hxx>
31
32 using namespace com::sun::star::uno;
33 using namespace rtl;
34
35 namespace com { namespace sun { namespace star { namespace i18n {
36
getType()37 sal_Int16 SAL_CALL transliteration_OneToOne::getType() throw(RuntimeException)
38 {
39 // This type is also defined in com/sun/star/util/TransliterationType.hdl
40 return TransliterationType::ONE_TO_ONE;
41 }
42
43 OUString SAL_CALL
folding(const OUString &,sal_Int32,sal_Int32,Sequence<sal_Int32> &)44 transliteration_OneToOne::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/,
45 sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/) throw(RuntimeException)
46 {
47 throw RuntimeException();
48 }
49
50 sal_Bool SAL_CALL
equals(const OUString &,sal_Int32,sal_Int32,sal_Int32 &,const OUString &,sal_Int32,sal_Int32,sal_Int32 &)51 transliteration_OneToOne::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 /*nCount1*/,
52 sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 /*nCount2*/, sal_Int32& /*nMatch2*/ )
53 throw(RuntimeException)
54 {
55 throw RuntimeException();
56 }
57
58 Sequence< OUString > SAL_CALL
transliterateRange(const OUString &,const OUString &)59 transliteration_OneToOne::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
60 throw(RuntimeException)
61 {
62 throw RuntimeException();
63 }
64
65 OUString SAL_CALL
transliterate(const OUString & inStr,sal_Int32 startPos,sal_Int32 nCount,Sequence<sal_Int32> & offset)66 transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startPos,
67 sal_Int32 nCount, Sequence< sal_Int32 >& offset)
68 throw(RuntimeException)
69 {
70 // Create a string buffer which can hold nCount + 1 characters.
71 // The reference count is 0 now.
72 rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h
73 sal_Unicode * dst = newStr->buffer;
74 const sal_Unicode * src = inStr.getStr() + startPos;
75
76 // Allocate nCount length to offset argument.
77 sal_Int32 *p = 0;
78 sal_Int32 position = 0;
79 if (useOffset) {
80 offset.realloc( nCount );
81 p = offset.getArray();
82 position = startPos;
83 }
84
85 // Translation
86 while (nCount -- > 0) {
87 sal_Unicode c = *src++;
88 *dst ++ = func ? func( c) : (*table)[ c ];
89 if (useOffset)
90 *p ++ = position ++;
91 }
92 *dst = (sal_Unicode) 0;
93
94 return OUString( newStr, SAL_NO_ACQUIRE ); // take over ownership of <newStr>
95 }
96
97 sal_Unicode SAL_CALL
transliterateChar2Char(sal_Unicode inChar)98 transliteration_OneToOne::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException)
99 {
100 return func ? func( inChar) : (*table)[ inChar ];
101 }
102
103 } } } }
104
105