1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <i18nutil/widthfolding.hxx>
22 #include <transliteration_OneToOne.hxx>
24 using namespace com::sun::star::uno
;
25 using namespace com::sun::star::lang
;
27 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
29 fullwidthToHalfwidth::fullwidthToHalfwidth()
32 table
= &widthfolding::getfull2halfTable();
33 transliterationName
= "fullwidthToHalfwidth";
34 implementationName
= "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH";
38 * Transliterate fullwidth to halfwidth.
39 * The output is a reference of OUString. You MUST delete this object when you do not need to use it any more
40 * The output string contains a transliterated string only, not whole string.
43 fullwidthToHalfwidth::transliterate( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
)
44 throw(RuntimeException
, std::exception
)
46 // Decomposition: GA --> KA + voice-mark
47 const OUString
& newStr
= widthfolding::decompose_ja_voiced_sound_marks (inStr
, startPos
, nCount
, offset
, useOffset
);
51 const OUString
&tmp
= transliteration_OneToOne::transliterate( newStr
, 0, newStr
.getLength(), offset
);
57 fullwidthToHalfwidth::transliterateChar2Char( sal_Unicode inChar
)
58 throw(RuntimeException
, MultipleCharsOutputException
, std::exception
)
60 sal_Unicode newChar
= widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar
);
61 if (newChar
== 0xFFFF)
62 throw MultipleCharsOutputException();
63 return transliteration_OneToOne::transliterateChar2Char(inChar
);
66 fullwidthKatakanaToHalfwidthKatakana::fullwidthKatakanaToHalfwidthKatakana()
69 table
= &widthfolding::getfullKana2halfKanaTable();
70 transliterationName
= "fullwidthKatakanaToHalfwidthKatakana";
71 implementationName
= "com.sun.star.i18n.Transliteration.FULLWIDTHKATAKANA_HALFWIDTHKATAKANA";
75 * Transliterate fullwidth katakana to halfwidth katakana.
78 fullwidthKatakanaToHalfwidthKatakana::transliterate( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
)
79 throw(RuntimeException
, std::exception
)
81 // Decomposition: GA --> KA + voice-mark
82 const OUString
& newStr
= widthfolding::decompose_ja_voiced_sound_marks (inStr
, startPos
, nCount
, offset
, useOffset
);
86 const OUString
&tmp
= transliteration_OneToOne::transliterate( newStr
, 0, newStr
.getLength(), offset
);
92 fullwidthKatakanaToHalfwidthKatakana::transliterateChar2Char( sal_Unicode inChar
)
93 throw(RuntimeException
, MultipleCharsOutputException
, std::exception
)
95 sal_Unicode newChar
= 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
= (TransFunc
) 0;
104 table
= &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.
113 fullwidthToHalfwidthLikeASC::transliterate( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
)
114 throw(RuntimeException
, std::exception
)
116 // Decomposition: GA --> KA + voice-mark
117 const OUString
& newStr
= widthfolding::decompose_ja_voiced_sound_marks (inStr
, startPos
, nCount
, offset
, useOffset
);
119 // One to One mapping
121 const OUString
&tmp
= transliteration_OneToOne::transliterate( newStr
, 0, newStr
.getLength(), offset
);
128 fullwidthToHalfwidthLikeASC::transliterateChar2Char( sal_Unicode inChar
)
129 throw(RuntimeException
, MultipleCharsOutputException
, std::exception
)
131 sal_Unicode newChar
= widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar
);
132 if (newChar
== 0xFFFF)
133 throw MultipleCharsOutputException();
134 return transliteration_OneToOne::transliterateChar2Char(inChar
);
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */