LibreOffice Module i18npool (master) 1
transliteration_OneToOne.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/i18n/TransliterationType.hpp>
21
24
25#include <numeric>
26
27using namespace com::sun::star::i18n;
28using namespace com::sun::star::uno;
29
30namespace i18npool {
31
33{
34 // This type is also defined in com/sun/star/util/TransliterationType.hdl
35 return TransliterationType::ONE_TO_ONE;
36}
37
38OUString
39transliteration_OneToOne::foldingImpl( const OUString& /*inStr*/, sal_Int32 /*startPos*/,
40 sal_Int32 /*nCount*/, Sequence< sal_Int32 >* /*pOffset*/)
41{
42 throw RuntimeException();
43}
44
45sal_Bool SAL_CALL
46transliteration_OneToOne::equals( const OUString& /*str1*/, sal_Int32 /*pos1*/, sal_Int32 /*nCount1*/,
47 sal_Int32& /*nMatch1*/, const OUString& /*str2*/, sal_Int32 /*pos2*/, sal_Int32 /*nCount2*/, sal_Int32& /*nMatch2*/ )
48{
49 throw RuntimeException();
50}
51
53transliteration_OneToOne::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
54{
55 throw RuntimeException();
56}
57
58OUString
59transliteration_OneToOne::transliterateImpl( const OUString& inStr, sal_Int32 startPos,
60 sal_Int32 nCount, Sequence< sal_Int32 >* pOffset)
61{
62 // Create a string buffer which can hold nCount + 1 characters.
63 // The reference count is 1 now.
64 rtl_uString * newStr = rtl_uString_alloc(nCount);
65 sal_Unicode * dst = newStr->buffer;
66 const sal_Unicode * src = inStr.getStr() + startPos;
67
68 // Allocate nCount length to offset argument.
69 if (pOffset) {
70 pOffset->realloc( nCount );
71 auto [begin, end] = asNonConstRange(*pOffset);
72 std::iota(begin, end, startPos);
73 }
74
75 // Translation
76 while (nCount -- > 0) {
77 sal_Unicode c = *src++;
78 *dst ++ = func ? func( c) : (*table)[ c ];
79 }
80 *dst = u'\0';
81
82 return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
83}
84
85sal_Unicode SAL_CALL
87{
88 return func ? func( inChar) : (*table)[ inChar ];
89}
90
91}
92
93/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Bool SAL_CALL equals(const OUString &str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32 &nMatch1, const OUString &str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32 &nMatch2) override
css::uno::Sequence< OUString > SAL_CALL transliterateRange(const OUString &str1, const OUString &str2) override
OUString foldingImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
sal_Unicode SAL_CALL transliterateChar2Char(sal_Unicode inChar) override
OUString transliterateImpl(const OUString &inStr, sal_Int32 startPos, sal_Int32 nCount, css::uno::Sequence< sal_Int32 > *pOffset) override
int nCount
float u
Constant values shared between i18npool and, for example, the number formatter.
enumrange< T >::Iterator begin(enumrange< T >)
end
unsigned char sal_Bool
sal_uInt16 sal_Unicode