1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_i18npool.hxx" 30 31 // prevent internal compiler error with MSVC6SP3 32 #include <utility> 33 34 #include <transliteration_OneToOne.hxx> 35 36 using namespace com::sun::star::uno; 37 using namespace rtl; 38 39 namespace com { namespace sun { namespace star { namespace i18n { 40 41 sal_Int16 SAL_CALL transliteration_OneToOne::getType() throw(RuntimeException) 42 { 43 // This type is also defined in com/sun/star/util/TransliterationType.hdl 44 return TransliterationType::ONE_TO_ONE; 45 } 46 47 OUString SAL_CALL 48 transliteration_OneToOne::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/, 49 sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/) throw(RuntimeException) 50 { 51 throw RuntimeException(); 52 } 53 54 sal_Bool SAL_CALL 55 transliteration_OneToOne::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 /*nCount1*/, 56 sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 /*nCount2*/, sal_Int32& /*nMatch2*/ ) 57 throw(RuntimeException) 58 { 59 throw RuntimeException(); 60 } 61 62 Sequence< OUString > SAL_CALL 63 transliteration_OneToOne::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ ) 64 throw(RuntimeException) 65 { 66 throw RuntimeException(); 67 } 68 69 OUString SAL_CALL 70 transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startPos, 71 sal_Int32 nCount, Sequence< sal_Int32 >& offset) 72 throw(RuntimeException) 73 { 74 // Create a string buffer which can hold nCount + 1 characters. 75 // The reference count is 0 now. 76 rtl_uString * newStr = x_rtl_uString_new_WithLength( nCount ); // defined in x_rtl_ustring.h 77 sal_Unicode * dst = newStr->buffer; 78 const sal_Unicode * src = inStr.getStr() + startPos; 79 80 // Allocate nCount length to offset argument. 81 sal_Int32 *p = 0; 82 sal_Int32 position = 0; 83 if (useOffset) { 84 offset.realloc( nCount ); 85 p = offset.getArray(); 86 position = startPos; 87 } 88 89 // Translation 90 while (nCount -- > 0) { 91 sal_Unicode c = *src++; 92 *dst ++ = func ? func( c) : (*table)[ c ]; 93 if (useOffset) 94 *p ++ = position ++; 95 } 96 *dst = (sal_Unicode) 0; 97 98 return OUString( newStr ); // defined in rtl/usrting. The reference count is increased from 0 to 1. 99 } 100 101 sal_Unicode SAL_CALL 102 transliteration_OneToOne::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException) 103 { 104 return func ? func( inChar) : (*table)[ inChar ]; 105 } 106 107 } } } } 108 109