From 0e532488c1a313a6665cae3a05b4b40a90e924d6 Mon Sep 17 00:00:00 2001 From: Vladimir Glazounov Date: Mon, 28 Jan 2008 14:37:42 +0000 Subject: [PATCH] INTEGRATION: CWS i18n39 (1.10.108); FILE MERGED 2007/12/12 22:48:34 khong 1.10.108.1: #i81366# add new Japanese transliterations --- .../transliteration/fullwidthToHalfwidth.cxx | 77 ++++++++++++++++++- .../transliteration/halfwidthToFullwidth.cxx | 66 +++++++++++++++- 2 files changed, 139 insertions(+), 4 deletions(-) diff --git a/i18npool/source/transliteration/fullwidthToHalfwidth.cxx b/i18npool/source/transliteration/fullwidthToHalfwidth.cxx index 7ecbcf5312fe..575b8c4cf70e 100644 --- a/i18npool/source/transliteration/fullwidthToHalfwidth.cxx +++ b/i18npool/source/transliteration/fullwidthToHalfwidth.cxx @@ -4,9 +4,9 @@ * * $RCSfile: fullwidthToHalfwidth.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: obo $ $Date: 2006-09-17 09:24:57 $ + * last change: $Author: vg $ $Date: 2008-01-28 15:37:28 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -41,6 +41,8 @@ #include #define TRANSLITERATION_fullwidthToHalfwidth +#define TRANSLITERATION_fullwidthKatakanaToHalfwidthKatakana +#define TRANSLITERATION_fullwidthToHalfwidthLikeASC #include using namespace com::sun::star::uno; @@ -86,5 +88,76 @@ fullwidthToHalfwidth::transliterateChar2Char( sal_Unicode inChar) return transliteration_OneToOne::transliterateChar2Char(inChar); } +fullwidthKatakanaToHalfwidthKatakana::fullwidthKatakanaToHalfwidthKatakana() +{ + func = (TransFunc) 0; + table = &widthfolding::getfullKana2halfKanaTable(); + transliterationName = "fullwidthKatakanaToHalfwidthKatakana"; + implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTHKATAKANA_HALFWIDTHKATAKANA"; +} + +/** + * Transliterate fullwidth katakana to halfwidth katakana. + */ +OUString SAL_CALL +fullwidthKatakanaToHalfwidthKatakana::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) + throw(RuntimeException) +{ + // Decomposition: GA --> KA + voice-mark + const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset); + + // One to One mapping + useOffset = sal_False; + const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset); + useOffset = sal_True; + return tmp; +} + +sal_Unicode SAL_CALL +fullwidthKatakanaToHalfwidthKatakana::transliterateChar2Char( sal_Unicode inChar ) + throw(RuntimeException, MultipleCharsOutputException) +{ + sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar); + if (newChar == 0xFFFF) + throw MultipleCharsOutputException(); + return transliteration_OneToOne::transliterateChar2Char(inChar); +} + +fullwidthToHalfwidthLikeASC::fullwidthToHalfwidthLikeASC() +{ + func = (TransFunc) 0; + table = &widthfolding::getfull2halfTableForASC(); + transliterationName = "fullwidthToHalfwidthLikeASC"; + implementationName = "com.sun.star.i18n.Transliteration.FULLWIDTH_HALFWIDTH_LIKE_ASC"; +} + +/** + * Transliterate fullwidth to halfwidth like Excel's ASC function. + */ +OUString SAL_CALL +fullwidthToHalfwidthLikeASC::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) + throw(RuntimeException) +{ + // Decomposition: GA --> KA + voice-mark + const OUString& newStr = widthfolding::decompose_ja_voiced_sound_marks (inStr, startPos, nCount, offset, useOffset); + + // One to One mapping + useOffset = sal_False; + const OUString &tmp = transliteration_OneToOne::transliterate( newStr, 0, newStr.getLength(), offset); + useOffset = sal_True; + + return tmp; +} + +sal_Unicode SAL_CALL +fullwidthToHalfwidthLikeASC::transliterateChar2Char( sal_Unicode inChar ) + throw(RuntimeException, MultipleCharsOutputException) +{ + sal_Unicode newChar = widthfolding::decompose_ja_voiced_sound_marksChar2Char (inChar); + if (newChar == 0xFFFF) + throw MultipleCharsOutputException(); + return transliteration_OneToOne::transliterateChar2Char(inChar); +} + } } } } diff --git a/i18npool/source/transliteration/halfwidthToFullwidth.cxx b/i18npool/source/transliteration/halfwidthToFullwidth.cxx index 0ef5f36c444d..04622190b093 100644 --- a/i18npool/source/transliteration/halfwidthToFullwidth.cxx +++ b/i18npool/source/transliteration/halfwidthToFullwidth.cxx @@ -4,9 +4,9 @@ * * $RCSfile: halfwidthToFullwidth.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: obo $ $Date: 2006-09-17 09:25:11 $ + * last change: $Author: vg $ $Date: 2008-01-28 15:37:42 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -41,6 +41,8 @@ #include #define TRANSLITERATION_halfwidthToFullwidth +#define TRANSLITERATION_halfwidthKatakanaToFullwidthKatakana +#define TRANSLITERATION_halfwidthToFullwidthLikeJIS #include using namespace com::sun::star::uno; @@ -78,4 +80,64 @@ halfwidthToFullwidth::transliterateChar2Char( sal_Unicode inChar) return transliteration_OneToOne::transliterateChar2Char(inChar); } + +halfwidthKatakanaToFullwidthKatakana::halfwidthKatakanaToFullwidthKatakana() +{ + func = (TransFunc) 0; + table = &widthfolding::gethalfKana2fullKanaTable(); + transliterationName = "halfwidthKatakanaToFullwidthKatakana"; + implementationName = "com.sun.star.i18n.Transliteration.HALFWIDTHKATAKANA_FULLWIDTHKATAKANA"; +} + +OUString SAL_CALL +halfwidthKatakanaToFullwidthKatakana::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) + throw(RuntimeException) +{ + sal_Bool _useOffset = useOffset; + // One to One mapping + useOffset = sal_False; + const OUString& newStr = transliteration_OneToOne::transliterate( inStr, startPos, nCount, offset); + useOffset = _useOffset; + + // Composition: KA + voice-mark --> GA + return widthfolding::compose_ja_voiced_sound_marks ( newStr, 0, newStr.getLength(), offset, _useOffset ); +} + +sal_Unicode SAL_CALL +halfwidthKatakanaToFullwidthKatakana::transliterateChar2Char( sal_Unicode inChar) + throw(RuntimeException, MultipleCharsOutputException) +{ + return transliteration_OneToOne::transliterateChar2Char(inChar); +} + + +halfwidthToFullwidthLikeJIS::halfwidthToFullwidthLikeJIS() +{ + func = (TransFunc) 0; + table = &widthfolding::gethalf2fullTableForJIS(); + transliterationName = "halfwidthToFullwidthLikeJIS"; + implementationName = "com.sun.star.i18n.Transliteration.HALFWIDTH_FULLWIDTH_LIKE_JIS"; +} + +OUString SAL_CALL +halfwidthToFullwidthLikeJIS::transliterate( const OUString& inStr, sal_Int32 startPos, sal_Int32 nCount, Sequence< sal_Int32 >& offset ) + throw(RuntimeException) +{ + sal_Bool _useOffset = useOffset; + // One to One mapping + useOffset = sal_False; + const OUString& newStr = transliteration_OneToOne::transliterate( inStr, startPos, nCount, offset); + useOffset = _useOffset; + + // Composition: KA + voice-mark --> GA + return widthfolding::compose_ja_voiced_sound_marks ( newStr, 0, newStr.getLength(), offset, _useOffset, WIDTHFOLDNIG_DONT_USE_COMBINED_VU ); +} + +sal_Unicode SAL_CALL +halfwidthToFullwidthLikeJIS::transliterateChar2Char( sal_Unicode inChar) + throw(RuntimeException, MultipleCharsOutputException) +{ + return transliteration_OneToOne::transliterateChar2Char(inChar); +} + } } } }