Bump version to 6.0-36
[LibreOffice.git] / i18npool / source / transliteration / fullwidthToHalfwidth.cxx
blob267ec26a0b600b9a2888fef25cd51a0a697945f8
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 <sal/config.h>
22 #include <com/sun/star/i18n/MultipleCharsOutputException.hpp>
23 #include <i18nutil/widthfolding.hxx>
25 #include <transliteration_OneToOne.hxx>
27 using namespace com::sun::star::uno;
28 using namespace com::sun::star::i18n;
29 using namespace com::sun::star::lang;
31 namespace i18npool {
33 fullwidthToHalfwidth::fullwidthToHalfwidth()
35 func = nullptr;
36 table = &i18nutil::widthfolding::getfull2halfTable();
37 transliterationName = "fullwidthToHalfwidth";
38 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH";
41 /**
42 * Transliterate fullwidth to halfwidth.
43 * The output is a reference of OUString. You MUST delete this object when you do not need to use it any more
44 * The output string contains a transliterated string only, not whole string.
46 OUString SAL_CALL
47 fullwidthToHalfwidth::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
49 // Decomposition: GA --> KA + voice-mark
50 const OUString& newStr = i18nutil::widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
52 // One to One mapping
53 useOffset = false;
54 const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
55 useOffset = true;
56 return tmp;
59 sal_Unicode SAL_CALL
60 fullwidthToHalfwidth::transliterateChar2Char( sal_Unicode inChar)
62 sal_Unicode newChar = i18nutil::widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
63 if (newChar == 0xFFFF)
64 throw MultipleCharsOutputException();
65 return transliteration_OneToOne::transliterateChar2Char(inChar);
68 fullwidthKatakanaToHalfwidthKatakana::fullwidthKatakanaToHalfwidthKatakana()
70 func = nullptr;
71 table = &i18nutil::widthfolding::getfullKana2halfKanaTable();
72 transliterationName = "fullwidthKatakanaToHalfwidthKatakana";
73 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTHKATAKANA_HALFWIDTHKATAKANA";
76 /**
77 * Transliterate fullwidth katakana to halfwidth katakana.
79 OUString SAL_CALL
80 fullwidthKatakanaToHalfwidthKatakana::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
82 // Decomposition: GA --> KA + voice-mark
83 const OUString& newStr = i18nutil::widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
85 // One to One mapping
86 useOffset = false;
87 const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
88 useOffset = true;
89 return tmp;
92 sal_Unicode SAL_CALL
93 fullwidthKatakanaToHalfwidthKatakana::transliterateChar2Char( sal_Unicode inChar )
95 sal_Unicode newChar = i18nutil::widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
96 if (newChar == 0xFFFF)
97 throw MultipleCharsOutputException();
98 return transliteration_OneToOne::transliterateChar2Char(inChar);
101 fullwidthToHalfwidthLikeASC::fullwidthToHalfwidthLikeASC()
103 func = nullptr;
104 table = &i18nutil::widthfolding::getfull2halfTableForASC();
105 transliterationName = "fullwidthToHalfwidthLikeASC";
106 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH_LIKE_ASC";
110 * Transliterate fullwidth to halfwidth like Excel's ASC function.
112 OUString SAL_CALL
113 fullwidthToHalfwidthLikeASC::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
115 // Decomposition: GA --> KA + voice-mark
116 const OUString& newStr = i18nutil::widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
118 // One to One mapping
119 useOffset = false;
120 const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
121 useOffset = true;
123 return tmp;
126 sal_Unicode SAL_CALL
127 fullwidthToHalfwidthLikeASC::transliterateChar2Char( sal_Unicode inChar )
129 sal_Unicode newChar = i18nutil::widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
130 if (newChar == 0xFFFF)
131 throw MultipleCharsOutputException();
132 return transliteration_OneToOne::transliterateChar2Char(inChar);
137 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */