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: transliteration_OneToOne.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 <transliteration_OneToOne.hxx>
39 using namespace com::sun::star::uno
;
42 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
44 sal_Int16 SAL_CALL
transliteration_OneToOne::getType() throw(RuntimeException
)
46 // This type is also defined in com/sun/star/util/TransliterationType.hdl
47 return TransliterationType::ONE_TO_ONE
;
51 transliteration_OneToOne::folding( const OUString
& /*inStr*/, sal_Int32
/*startPos*/,
52 sal_Int32
/*nCount*/, Sequence
< sal_Int32
>& /*offset*/) throw(RuntimeException
)
54 throw RuntimeException();
58 transliteration_OneToOne::equals( const OUString
& /*str1*/, sal_Int32
/*pos1*/, sal_Int32
/*nCount1*/,
59 sal_Int32
& /*nMatch1*/, const OUString
& /*str2*/, sal_Int32
/*pos2*/, sal_Int32
/*nCount2*/, sal_Int32
& /*nMatch2*/ )
60 throw(RuntimeException
)
62 throw RuntimeException();
65 Sequence
< OUString
> SAL_CALL
66 transliteration_OneToOne::transliterateRange( const OUString
& /*str1*/, const OUString
& /*str2*/ )
67 throw(RuntimeException
)
69 throw RuntimeException();
73 transliteration_OneToOne::transliterate( const OUString
& inStr
, sal_Int32 startPos
,
74 sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
)
75 throw(RuntimeException
)
77 // Create a string buffer which can hold nCount + 1 characters.
78 // The reference count is 0 now.
79 rtl_uString
* newStr
= x_rtl_uString_new_WithLength( nCount
); // defined in x_rtl_ustring.h
80 sal_Unicode
* dst
= newStr
->buffer
;
81 const sal_Unicode
* src
= inStr
.getStr() + startPos
;
83 // Allocate nCount length to offset argument.
85 sal_Int32 position
= 0;
87 offset
.realloc( nCount
);
88 p
= offset
.getArray();
93 while (nCount
-- > 0) {
94 sal_Unicode c
= *src
++;
95 *dst
++ = func
? func( c
) : (*table
)[ c
];
99 *dst
= (sal_Unicode
) 0;
101 return OUString( newStr
); // defined in rtl/usrting. The reference count is increased from 0 to 1.
105 transliteration_OneToOne::transliterateChar2Char( sal_Unicode inChar
) throw(RuntimeException
, MultipleCharsOutputException
)
107 return func
? func( inChar
) : (*table
)[ inChar
];