bump product version to 6.3.0.0.beta1
[LibreOffice.git] / i18npool / source / transliteration / transliteration_OneToOne.cxx
blob484a34db0b0ff35ac590fd73c861e8d06eb71861
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/i18n/TransliterationType.hpp>
22 #include <transliteration_OneToOne.hxx>
23 #include <i18nutil/oneToOneMapping.hxx>
25 using namespace com::sun::star::i18n;
26 using namespace com::sun::star::uno;
28 namespace i18npool {
30 sal_Int16 SAL_CALL transliteration_OneToOne::getType()
32 // This type is also defined in com/sun/star/util/TransliterationType.hdl
33 return TransliterationType::ONE_TO_ONE;
36 OUString
37 transliteration_OneToOne::foldingImpl( const OUString& /*inStr*/, sal_Int32 /*startPos*/,
38 sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/, bool)
40 throw RuntimeException();
43 sal_Bool SAL_CALL
44 transliteration_OneToOne::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 /*nCount1*/,
45 sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 /*nCount2*/, sal_Int32& /*nMatch2*/ )
47 throw RuntimeException();
50 Sequence< OUString > SAL_CALL
51 transliteration_OneToOne::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
53 throw RuntimeException();
56 OUString
57 transliteration_OneToOne::transliterateImpl( const OUString& inStr, sal_Int32 startPos,
58 sal_Int32 nCount, Sequence< sal_Int32 >& offset, bool useOffset)
60 // Create a string buffer which can hold nCount + 1 characters.
61 // The reference count is 1 now.
62 rtl_uString * newStr = rtl_uString_alloc(nCount);
63 sal_Unicode * dst = newStr->buffer;
64 const sal_Unicode * src = inStr.getStr() + startPos;
66 // Allocate nCount length to offset argument.
67 sal_Int32 *p = nullptr;
68 sal_Int32 position = 0;
69 if (useOffset) {
70 offset.realloc( nCount );
71 p = offset.getArray();
72 position = startPos;
75 // Translation
76 while (nCount -- > 0) {
77 sal_Unicode c = *src++;
78 *dst ++ = func ? func( c) : (*table)[ c ];
79 if (useOffset)
80 *p ++ = position ++;
82 *dst = u'\0';
84 return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
87 sal_Unicode SAL_CALL
88 transliteration_OneToOne::transliterateChar2Char( sal_Unicode inChar)
90 return func ? func( inChar) : (*table)[ inChar ];
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */