merge the formfield patch from ooo-build
[ooovba.git] / i18npool / source / transliteration / fullwidthToHalfwidth.cxx
blob1552fc3761e65cd70f870058862718eda2f37fbb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fullwidthToHalfwidth.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_i18npool.hxx"
34 // prevent internal compiler error with MSVC6SP3
35 #include <utility>
37 #include <i18nutil/widthfolding.hxx>
38 #define TRANSLITERATION_fullwidthToHalfwidth
39 #define TRANSLITERATION_fullwidthKatakanaToHalfwidthKatakana
40 #define TRANSLITERATION_fullwidthToHalfwidthLikeASC
41 #include <transliteration_OneToOne.hxx>
43 using namespace com::sun::star::uno;
44 using namespace com::sun::star::lang;
45 using namespace rtl;
47 namespace com { namespace sun { namespace star { namespace i18n {
49 fullwidthToHalfwidth::fullwidthToHalfwidth()
51 func = (TransFunc) 0;
52 table = &widthfolding::getfull2halfTable();
53 transliterationName = "fullwidthToHalfwidth";
54 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH";
57 /**
58 * Transliterate fullwidth to halfwidth.
59 * The output is a reference of OUString. You MUST delete this object when you do not need to use it any more
60 * The output string contains a transliterated string only, not whole string.
62 OUString SAL_CALL
63 fullwidthToHalfwidth::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
64 throw(RuntimeException)
66 // Decomposition: GA --> KA + voice-mark
67 const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
69 // One to One mapping
70 useOffset = sal_False;
71 const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
72 useOffset = sal_True;
73 return tmp;
76 sal_Unicode SAL_CALL
77 fullwidthToHalfwidth::transliterateChar2Char( sal_Unicode inChar)
78 throw(RuntimeException, MultipleCharsOutputException)
80 sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
81 if (newChar == 0xFFFF)
82 throw MultipleCharsOutputException();
83 return transliteration_OneToOne::transliterateChar2Char(inChar);
86 fullwidthKatakanaToHalfwidthKatakana::fullwidthKatakanaToHalfwidthKatakana()
88 func = (TransFunc) 0;
89 table = &widthfolding::getfullKana2halfKanaTable();
90 transliterationName = "fullwidthKatakanaToHalfwidthKatakana";
91 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTHKATAKANA_HALFWIDTHKATAKANA";
94 /**
95 * Transliterate fullwidth katakana to halfwidth katakana.
97 OUString SAL_CALL
98 fullwidthKatakanaToHalfwidthKatakana::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
99 throw(RuntimeException)
101 // Decomposition: GA --> KA + voice-mark
102 const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
104 // One to One mapping
105 useOffset = sal_False;
106 const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
107 useOffset = sal_True;
108 return tmp;
111 sal_Unicode SAL_CALL
112 fullwidthKatakanaToHalfwidthKatakana::transliterateChar2Char( sal_Unicode inChar )
113 throw(RuntimeException, MultipleCharsOutputException)
115 sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
116 if (newChar == 0xFFFF)
117 throw MultipleCharsOutputException();
118 return transliteration_OneToOne::transliterateChar2Char(inChar);
121 fullwidthToHalfwidthLikeASC::fullwidthToHalfwidthLikeASC()
123 func = (TransFunc) 0;
124 table = &widthfolding::getfull2halfTableForASC();
125 transliterationName = "fullwidthToHalfwidthLikeASC";
126 implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH_LIKE_ASC";
130 * Transliterate fullwidth to halfwidth like Excel's ASC function.
132 OUString SAL_CALL
133 fullwidthToHalfwidthLikeASC::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset )
134 throw(RuntimeException)
136 // Decomposition: GA --> KA + voice-mark
137 const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset);
139 // One to One mapping
140 useOffset = sal_False;
141 const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset);
142 useOffset = sal_True;
144 return tmp;
147 sal_Unicode SAL_CALL
148 fullwidthToHalfwidthLikeASC::transliterateChar2Char( sal_Unicode inChar )
149 throw(RuntimeException, MultipleCharsOutputException)
151 sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar);
152 if (newChar == 0xFFFF)
153 throw MultipleCharsOutputException();
154 return transliteration_OneToOne::transliterateChar2Char(inChar);
157 } } } }