tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / i18npool / source / transliteration / fullwidthToHalfwidth.cxx
blobbdab67d3314f60616b088898d982738f37086961
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;
30 namespace i18npool {
32 fullwidthToHalfwidth::fullwidthToHalfwidth()
34 func = nullptr;
35 table = &i18nutil::widthfolding::getfull2halfTable();
36 transliterationName = "fullwidthToHalfwidth";
37 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH";
40 /**
41 * Transliterate fullwidth to halfwidth.
42 * The output is a reference of OUString. You MUST delete this object when you do not need to use it any more
43 * The output string contains a transliterated string only, not whole string.
45 OUString
46 fullwidthToHalfwidth::transliterateImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >* pOffset )
48 // Decomposition: GA --> KA + voice-mark
49 const OUString newStr = i18nutil::widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, pOffset);
51 // One to One mapping
52 return transliteration_OneToOne::transliterateImpl( newStr, 0, newStr.getLength(), nullptr);
55 sal_Unicode SAL_CALL
56 fullwidthToHalfwidth::transliterateChar2Char( sal_Unicode inChar)
58 sal_Unicode newChar = i18nutil::widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
59 if (newChar == 0xFFFF)
60 throw MultipleCharsOutputException();
61 return transliteration_OneToOne::transliterateChar2Char(inChar);
64 FULLWIDTHKATAKANA_HALFWIDTHKATAKANA::FULLWIDTHKATAKANA_HALFWIDTHKATAKANA()
66 func = nullptr;
67 table = &i18nutil::widthfolding::getfullKana2halfKanaTable();
68 transliterationName = "fullwidthKatakanaToHalfwidthKatakana";
69 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTHKATAKANA_HALFWIDTHKATAKANA";
72 /**
73 * Transliterate fullwidth katakana to halfwidth katakana.
75 OUString
76 FULLWIDTHKATAKANA_HALFWIDTHKATAKANA::transliterateImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >* pOffset )
78 // Decomposition: GA --> KA + voice-mark
79 const OUString newStr = i18nutil::widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, pOffset);
81 // One to One mapping
82 return transliteration_OneToOne::transliterateImpl( newStr, 0, newStr.getLength(), nullptr);
85 sal_Unicode SAL_CALL
86 FULLWIDTHKATAKANA_HALFWIDTHKATAKANA::transliterateChar2Char( sal_Unicode inChar )
88 sal_Unicode newChar = i18nutil::widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
89 if (newChar == 0xFFFF)
90 throw MultipleCharsOutputException();
91 return transliteration_OneToOne::transliterateChar2Char(inChar);
94 FULLWIDTH_HALFWIDTH_LIKE_ASC::FULLWIDTH_HALFWIDTH_LIKE_ASC()
96 func = nullptr;
97 table = &i18nutil::widthfolding::getfull2halfTableForASC();
98 transliterationName = "fullwidthToHalfwidthLikeASC";
99 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH_LIKE_ASC";
103 * Transliterate fullwidth to halfwidth like Excel's ASC function.
105 OUString
106 FULLWIDTH_HALFWIDTH_LIKE_ASC::transliterateImpl( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >* pOffset )
108 // Decomposition: GA --> KA + voice-mark
109 const OUString newStr = i18nutil::widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, pOffset);
111 // One to One mapping
112 return transliteration_OneToOne::transliterateImpl( newStr, 0, newStr.getLength(), nullptr);
115 sal_Unicode SAL_CALL
116 FULLWIDTH_HALFWIDTH_LIKE_ASC::transliterateChar2Char( sal_Unicode inChar )
118 sal_Unicode newChar = i18nutil::widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
119 if (newChar == 0xFFFF)
120 throw MultipleCharsOutputException();
121 return transliteration_OneToOne::transliterateChar2Char(inChar);
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */