Line data Source code
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 :
21 : #include <utility>
22 : #include <comphelper/string.hxx>
23 : #include <transliteration_OneToOne.hxx>
24 :
25 : using namespace com::sun::star::uno;
26 :
27 :
28 : namespace com { namespace sun { namespace star { namespace i18n {
29 :
30 0 : sal_Int16 SAL_CALL transliteration_OneToOne::getType() throw(RuntimeException, std::exception)
31 : {
32 : // This type is also defined in com/sun/star/util/TransliterationType.hdl
33 0 : return TransliterationType::ONE_TO_ONE;
34 : }
35 :
36 : OUString SAL_CALL
37 0 : transliteration_OneToOne::folding( const OUString& /*inStr*/, sal_Int32 /*startPos*/,
38 : sal_Int32 /*nCount*/, Sequence< sal_Int32 >& /*offset*/) throw(RuntimeException, std::exception)
39 : {
40 0 : throw RuntimeException();
41 : }
42 :
43 : sal_Bool SAL_CALL
44 0 : 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*/ )
46 : throw(RuntimeException, std::exception)
47 : {
48 0 : throw RuntimeException();
49 : }
50 :
51 : Sequence< OUString > SAL_CALL
52 0 : transliteration_OneToOne::transliterateRange( const OUString& /*str1*/, const OUString& /*str2*/ )
53 : throw(RuntimeException, std::exception)
54 : {
55 0 : throw RuntimeException();
56 : }
57 :
58 : OUString SAL_CALL
59 0 : transliteration_OneToOne::transliterate( const OUString& inStr, sal_Int32 startPos,
60 : sal_Int32 nCount, Sequence< sal_Int32 >& offset)
61 : throw(RuntimeException, std::exception)
62 : {
63 : // Create a string buffer which can hold nCount + 1 characters.
64 : // The reference count is 1 now.
65 0 : rtl_uString * newStr = rtl_uString_alloc(nCount);
66 0 : sal_Unicode * dst = newStr->buffer;
67 0 : const sal_Unicode * src = inStr.getStr() + startPos;
68 :
69 : // Allocate nCount length to offset argument.
70 0 : sal_Int32 *p = 0;
71 0 : sal_Int32 position = 0;
72 0 : if (useOffset) {
73 0 : offset.realloc( nCount );
74 0 : p = offset.getArray();
75 0 : position = startPos;
76 : }
77 :
78 : // Translation
79 0 : while (nCount -- > 0) {
80 0 : sal_Unicode c = *src++;
81 0 : *dst ++ = func ? func( c) : (*table)[ c ];
82 0 : if (useOffset)
83 0 : *p ++ = position ++;
84 : }
85 0 : *dst = (sal_Unicode) 0;
86 :
87 0 : return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
88 : }
89 :
90 : sal_Unicode SAL_CALL
91 0 : transliteration_OneToOne::transliterateChar2Char( sal_Unicode inChar) throw(RuntimeException, MultipleCharsOutputException, std::exception)
92 : {
93 0 : return func ? func( inChar) : (*table)[ inChar ];
94 : }
95 :
96 : } } } }
97 :
98 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|