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 37 sal_Int16 SAL_CALL transliteration_OneToOne::getType() 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 44 transliteration_OneToOne::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/, 45 sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/) 46 { 47 throw RuntimeException(); 48 } 49 50 sal_Bool SAL_CALL 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 { 54 throw RuntimeException(); 55 } 56 57 Sequence< OUString > SAL_CALL 58 transliteration_OneToOne::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ ) 59 { 60 throw RuntimeException(); 61 } 62 63 OUString SAL_CALL 64 transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startPos, 65 sal_Int32 nCount, Sequence< sal_Int32 >& offset) 66 { 67 // Create a string buffer which can hold nCount + 1 characters. 68 // The reference count is 0 now. 69 rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h 70 sal_Unicode * dst = newStr->buffer; 71 const sal_Unicode * src = inStr.getStr() + startPos; 72 73 // Allocate nCount length to offset argument. 74 sal_Int32 *p = 0; 75 sal_Int32 position = 0; 76 if (useOffset) { 77 offset.realloc( nCount ); 78 p = offset.getArray(); 79 position = startPos; 80 } 81 82 // Translation 83 while (nCount -- > 0) { 84 sal_Unicode c = *src++; 85 *dst ++ = func ? func( c) : (*table)[ c ]; 86 if (useOffset) 87 *p ++ = position ++; 88 } 89 *dst = (sal_Unicode) 0; 90 91 return OUString( newStr, SAL_NO_ACQUIRE ); // take over ownership of <newStr> 92 } 93 94 sal_Unicode SAL_CALL 95 transliteration_OneToOne::transliterateChar2Char( sal_Unicode inChar) 96 { 97 return func ? func( inChar) : (*table)[ inChar ]; 98 } 99 100 } } } } 101