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 .
21 // prevent internal compiler error with MSVC6SP3
24 #include <i18nutil/widthfolding.hxx>
25 #define TRANSLITERATION_fullwidthToHalfwidth
26 #define TRANSLITERATION_fullwidthKatakanaToHalfwidthKatakana
27 #define TRANSLITERATION_fullwidthToHalfwidthLikeASC
28 #include <transliteration_OneToOne.hxx>
30 using namespace com::sun::star::uno
;
31 using namespace com::sun::star::lang
;
34 namespace com
{ namespace sun
{ namespace star
{ namespace i18n
{
36 fullwidthToHalfwidth::fullwidthToHalfwidth()
39 table
= &widthfolding::getfull2halfTable();
40 transliterationName
= "fullwidthToHalfwidth";
41 implementationName
= "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH";
45 * Transliterate fullwidth to halfwidth.
46 * The output is a reference of OUString. You MUST delete this object when you do not need to use it any more
47 * The output string contains a transliterated string only, not whole string.
50 fullwidthToHalfwidth::transliterate( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
)
51 throw(RuntimeException
)
53 // Decomposition: GA --> KA + voice-mark
54 const OUString
& newStr
= widthfolding::decompose_ja_voiced_sound_marks (inStr
, startPos
, nCount
, offset
, useOffset
);
57 useOffset
= sal_False
;
58 const OUString
&tmp
= transliteration_OneToOne::transliterate( newStr
, 0, newStr
.getLength(), offset
);
64 fullwidthToHalfwidth::transliterateChar2Char( sal_Unicode inChar
)
65 throw(RuntimeException
, MultipleCharsOutputException
)
67 sal_Unicode newChar
= widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar
);
68 if (newChar
== 0xFFFF)
69 throw MultipleCharsOutputException();
70 return transliteration_OneToOne::transliterateChar2Char(inChar
);
73 fullwidthKatakanaToHalfwidthKatakana::fullwidthKatakanaToHalfwidthKatakana()
76 table
= &widthfolding::getfullKana2halfKanaTable();
77 transliterationName
= "fullwidthKatakanaToHalfwidthKatakana";
78 implementationName
= "com.sun.star.i18n.Transliteration.FULLWIDTHKATAKANA_HALFWIDTHKATAKANA";
82 * Transliterate fullwidth katakana to halfwidth katakana.
85 fullwidthKatakanaToHalfwidthKatakana::transliterate( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
)
86 throw(RuntimeException
)
88 // Decomposition: GA --> KA + voice-mark
89 const OUString
& newStr
= widthfolding::decompose_ja_voiced_sound_marks (inStr
, startPos
, nCount
, offset
, useOffset
);
92 useOffset
= sal_False
;
93 const OUString
&tmp
= transliteration_OneToOne::transliterate( newStr
, 0, newStr
.getLength(), offset
);
99 fullwidthKatakanaToHalfwidthKatakana::transliterateChar2Char( sal_Unicode inChar
)
100 throw(RuntimeException
, MultipleCharsOutputException
)
102 sal_Unicode newChar
= widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar
);
103 if (newChar
== 0xFFFF)
104 throw MultipleCharsOutputException();
105 return transliteration_OneToOne::transliterateChar2Char(inChar
);
108 fullwidthToHalfwidthLikeASC::fullwidthToHalfwidthLikeASC()
110 func
= (TransFunc
) 0;
111 table
= &widthfolding::getfull2halfTableForASC();
112 transliterationName
= "fullwidthToHalfwidthLikeASC";
113 implementationName
= "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH_LIKE_ASC";
117 * Transliterate fullwidth to halfwidth like Excel's ASC function.
120 fullwidthToHalfwidthLikeASC::transliterate( const OUString
& inStr
, sal_Int32 startPos
, sal_Int32 nCount
, Sequence
< sal_Int32
>& offset
)
121 throw(RuntimeException
)
123 // Decomposition: GA --> KA + voice-mark
124 const OUString
& newStr
= widthfolding::decompose_ja_voiced_sound_marks (inStr
, startPos
, nCount
, offset
, useOffset
);
126 // One to One mapping
127 useOffset
= sal_False
;
128 const OUString
&tmp
= transliteration_OneToOne::transliterate( newStr
, 0, newStr
.getLength(), offset
);
129 useOffset
= sal_True
;
135 fullwidthToHalfwidthLikeASC::transliterateChar2Char( sal_Unicode inChar
)
136 throw(RuntimeException
, MultipleCharsOutputException
)
138 sal_Unicode newChar
= widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar
);
139 if (newChar
== 0xFFFF)
140 throw MultipleCharsOutputException();
141 return transliteration_OneToOne::transliterateChar2Char(inChar
);
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */