tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / i18npool / source / transliteration / ignoreKiKuFollowedBySa_ja_JP.cxx
blob293ff03b2bb8d834698046cab17b7c87c9a06b24
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 <transliteration_Ignore.hxx>
22 #include <numeric>
24 using namespace com::sun::star::uno;
26 namespace i18npool {
28 OUString
29 ignoreKiKuFollowedBySa_ja_JP::foldingImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >* pOffset )
31 // Create a string buffer which can hold nCount + 1 characters.
32 // The reference count is 1 now.
33 rtl_uString * newStr = rtl_uString_alloc(nCount);
34 sal_Unicode * dst = newStr->buffer;
35 const sal_Unicode * src = inStr.getStr() + startPos;
37 if (pOffset) {
38 // Allocate nCount length to offset argument.
39 pOffset->realloc( nCount );
40 auto [begin, end] = asNonConstRange(*pOffset);
41 std::iota(begin, end, startPos);
45 sal_Unicode previousChar = *src ++;
46 sal_Unicode currentChar;
48 // Translation
49 while (-- nCount > 0) {
50 currentChar = *src ++;
52 // KU + Sa-So --> KI + Sa-So
53 if (previousChar == 0x30AF ) { // KATAKANA LETTER KU
54 if (0x30B5 <= currentChar && // KATAKANA LETTER SA
55 currentChar <= 0x30BE) { // KATAKANA LETTER ZO
56 *dst ++ = 0x30AD; // KATAKANA LETTER KI
57 *dst ++ = currentChar;
58 previousChar = *src ++;
59 nCount --;
60 continue;
64 *dst ++ = previousChar;
65 previousChar = currentChar;
68 if (nCount == 0) {
69 *dst ++ = previousChar;
72 *dst = u'\0';
74 newStr->length = sal_Int32(dst - newStr->buffer);
75 if (pOffset)
76 pOffset->realloc(newStr->length);
77 return OUString(newStr, SAL_NO_ACQUIRE); // take ownership
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */