diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-30 12:43:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-03-31 06:58:26 +0000 |
commit | 97844a113fcaf7e2a0c52203e6792c71e2389f39 (patch) | |
tree | 8e2404052912959edb41d08562eef3e3c8d1bdf7 /i18nutil | |
parent | a5a571307fb3306b74ab46b085cde6388270a770 (diff) |
use actual UNO enums in i18nutil
Change-Id: I959b26471fe69c4ee8ecb7e2fd57a53e24187112
Reviewed-on: https://gerrit.libreoffice.org/35905
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'i18nutil')
-rw-r--r-- | i18nutil/source/utility/scripttypedetector.cxx | 10 | ||||
-rw-r--r-- | i18nutil/source/utility/unicode.cxx | 293 |
2 files changed, 22 insertions, 281 deletions
diff --git a/i18nutil/source/utility/scripttypedetector.cxx b/i18nutil/source/utility/scripttypedetector.cxx index 83826e308c6e..884bc304cd01 100644 --- a/i18nutil/source/utility/scripttypedetector.cxx +++ b/i18nutil/source/utility/scripttypedetector.cxx @@ -84,11 +84,11 @@ sal_Int32 ScriptTypeDetector::endOfScriptDirection( const OUString& Text, sal_In sal_Int16 ScriptTypeDetector::getCTLScriptType( const OUString& Text, sal_Int32 nPos ) { static const ScriptTypeList typeList[] = { - { UnicodeScript_kHebrew, UnicodeScript_kHebrew, CTLScriptType::CTL_HEBREW }, // 10 - { UnicodeScript_kArabic, UnicodeScript_kArabic, CTLScriptType::CTL_ARABIC }, // 11 - { UnicodeScript_kDevanagari, UnicodeScript_kDevanagari, CTLScriptType::CTL_INDIC }, // 14 - { UnicodeScript_kThai, UnicodeScript_kThai, CTLScriptType::CTL_THAI }, // 24 - { UnicodeScript_kScriptCount, UnicodeScript_kScriptCount, CTLScriptType::CTL_UNKNOWN } // 88 + { UnicodeScript_kHebrew, UnicodeScript_kHebrew, CTLScriptType::CTL_HEBREW }, // 10 + { UnicodeScript_kArabic, UnicodeScript_kArabic, CTLScriptType::CTL_ARABIC }, // 11 + { UnicodeScript_kDevanagari, UnicodeScript_kDevanagari, CTLScriptType::CTL_INDIC }, // 14 + { UnicodeScript_kThai, UnicodeScript_kThai, CTLScriptType::CTL_THAI }, // 24 + { UnicodeScript_kScriptCount, UnicodeScript_kScriptCount, CTLScriptType::CTL_UNKNOWN } // 88 }; return unicode::getUnicodeScriptType(Text[nPos], typeList); diff --git a/i18nutil/source/utility/unicode.cxx b/i18nutil/source/utility/unicode.cxx index 53fb973ca400..b2dd1d7be08b 100644 --- a/i18nutil/source/utility/unicode.cxx +++ b/i18nutil/source/utility/unicode.cxx @@ -37,299 +37,40 @@ using namespace ::com::sun::star::i18n; -static const ScriptTypeList defaultTypeList[] = { - { UnicodeScript_kBasicLatin, - UnicodeScript_kBasicLatin, - UnicodeScript_kBasicLatin }, // 0, - { UnicodeScript_kLatin1Supplement, - UnicodeScript_kLatin1Supplement, - UnicodeScript_kLatin1Supplement },// 1, - { UnicodeScript_kLatinExtendedA, - UnicodeScript_kLatinExtendedA, - UnicodeScript_kLatinExtendedA }, // 2, - { UnicodeScript_kLatinExtendedB, - UnicodeScript_kLatinExtendedB, - UnicodeScript_kLatinExtendedB }, // 3, - { UnicodeScript_kIPAExtension, - UnicodeScript_kIPAExtension, - UnicodeScript_kIPAExtension }, // 4, - { UnicodeScript_kSpacingModifier, - UnicodeScript_kSpacingModifier, - UnicodeScript_kSpacingModifier }, // 5, - { UnicodeScript_kCombiningDiacritical, - UnicodeScript_kCombiningDiacritical, - UnicodeScript_kCombiningDiacritical }, // 6, - { UnicodeScript_kGreek, - UnicodeScript_kGreek, - UnicodeScript_kGreek }, // 7, - { UnicodeScript_kCyrillic, - UnicodeScript_kCyrillic, - UnicodeScript_kCyrillic }, // 8, - { UnicodeScript_kArmenian, - UnicodeScript_kArmenian, - UnicodeScript_kArmenian }, // 9, - { UnicodeScript_kHebrew, - UnicodeScript_kHebrew, - UnicodeScript_kHebrew }, // 10, - { UnicodeScript_kArabic, - UnicodeScript_kArabic, - UnicodeScript_kArabic }, // 11, - { UnicodeScript_kSyriac, - UnicodeScript_kSyriac, - UnicodeScript_kSyriac }, // 12, - { UnicodeScript_kThaana, - UnicodeScript_kThaana, - UnicodeScript_kThaana }, // 13, - { UnicodeScript_kDevanagari, - UnicodeScript_kDevanagari, - UnicodeScript_kDevanagari }, // 14, - { UnicodeScript_kBengali, - UnicodeScript_kBengali, - UnicodeScript_kBengali }, // 15, - { UnicodeScript_kGurmukhi, - UnicodeScript_kGurmukhi, - UnicodeScript_kGurmukhi }, // 16, - { UnicodeScript_kGujarati, - UnicodeScript_kGujarati, - UnicodeScript_kGujarati }, // 17, - { UnicodeScript_kOriya, - UnicodeScript_kOriya, - UnicodeScript_kOriya }, // 18, - { UnicodeScript_kTamil, - UnicodeScript_kTamil, - UnicodeScript_kTamil }, // 19, - { UnicodeScript_kTelugu, - UnicodeScript_kTelugu, - UnicodeScript_kTelugu }, // 20, - { UnicodeScript_kKannada, - UnicodeScript_kKannada, - UnicodeScript_kKannada }, // 21, - { UnicodeScript_kMalayalam, - UnicodeScript_kMalayalam, - UnicodeScript_kMalayalam }, // 22, - { UnicodeScript_kSinhala, - UnicodeScript_kSinhala, - UnicodeScript_kSinhala }, // 23, - { UnicodeScript_kThai, - UnicodeScript_kThai, - UnicodeScript_kThai }, // 24, - { UnicodeScript_kLao, - UnicodeScript_kLao, - UnicodeScript_kLao }, // 25, - { UnicodeScript_kTibetan, - UnicodeScript_kTibetan, - UnicodeScript_kTibetan }, // 26, - { UnicodeScript_kMyanmar, - UnicodeScript_kMyanmar, - UnicodeScript_kMyanmar }, // 27, - { UnicodeScript_kGeorgian, - UnicodeScript_kGeorgian, - UnicodeScript_kGeorgian }, // 28, - { UnicodeScript_kHangulJamo, - UnicodeScript_kHangulJamo, - UnicodeScript_kHangulJamo }, // 29, - { UnicodeScript_kEthiopic, - UnicodeScript_kEthiopic, - UnicodeScript_kEthiopic }, // 30, - { UnicodeScript_kCherokee, - UnicodeScript_kCherokee, - UnicodeScript_kCherokee }, // 31, - { UnicodeScript_kUnifiedCanadianAboriginalSyllabics, - UnicodeScript_kUnifiedCanadianAboriginalSyllabics, - UnicodeScript_kUnifiedCanadianAboriginalSyllabics }, // 32, - { UnicodeScript_kOgham, - UnicodeScript_kOgham, - UnicodeScript_kOgham }, // 33, - { UnicodeScript_kRunic, - UnicodeScript_kRunic, - UnicodeScript_kRunic }, // 34, - { UnicodeScript_kKhmer, - UnicodeScript_kKhmer, - UnicodeScript_kKhmer }, // 35, - { UnicodeScript_kMongolian, - UnicodeScript_kMongolian, - UnicodeScript_kMongolian }, // 36, - { UnicodeScript_kLatinExtendedAdditional, - UnicodeScript_kLatinExtendedAdditional, - UnicodeScript_kLatinExtendedAdditional }, // 37, - { UnicodeScript_kGreekExtended, - UnicodeScript_kGreekExtended, - UnicodeScript_kGreekExtended }, // 38, - { UnicodeScript_kGeneralPunctuation, - UnicodeScript_kGeneralPunctuation, - UnicodeScript_kGeneralPunctuation }, // 39, - { UnicodeScript_kSuperSubScript, - UnicodeScript_kSuperSubScript, - UnicodeScript_kSuperSubScript }, // 40, - { UnicodeScript_kCurrencySymbolScript, - UnicodeScript_kCurrencySymbolScript, - UnicodeScript_kCurrencySymbolScript }, // 41, - { UnicodeScript_kSymbolCombiningMark, - UnicodeScript_kSymbolCombiningMark, - UnicodeScript_kSymbolCombiningMark }, // 42, - { UnicodeScript_kLetterlikeSymbol, - UnicodeScript_kLetterlikeSymbol, - UnicodeScript_kLetterlikeSymbol }, // 43, - { UnicodeScript_kNumberForm, - UnicodeScript_kNumberForm, - UnicodeScript_kNumberForm }, // 44, - { UnicodeScript_kArrow, - UnicodeScript_kArrow, - UnicodeScript_kArrow }, // 45, - { UnicodeScript_kMathOperator, - UnicodeScript_kMathOperator, - UnicodeScript_kMathOperator }, // 46, - { UnicodeScript_kMiscTechnical, - UnicodeScript_kMiscTechnical, - UnicodeScript_kMiscTechnical }, // 47, - { UnicodeScript_kControlPicture, - UnicodeScript_kControlPicture, - UnicodeScript_kControlPicture }, // 48, - { UnicodeScript_kOpticalCharacter, - UnicodeScript_kOpticalCharacter, - UnicodeScript_kOpticalCharacter }, // 49, - { UnicodeScript_kEnclosedAlphanumeric, - UnicodeScript_kEnclosedAlphanumeric, - UnicodeScript_kEnclosedAlphanumeric }, // 50, - { UnicodeScript_kBoxDrawing, - UnicodeScript_kBoxDrawing, - UnicodeScript_kBoxDrawing }, // 51, - { UnicodeScript_kBlockElement, - UnicodeScript_kBlockElement, - UnicodeScript_kBlockElement }, // 52, - { UnicodeScript_kGeometricShape, - UnicodeScript_kGeometricShape, - UnicodeScript_kGeometricShape }, // 53, - { UnicodeScript_kMiscSymbol, - UnicodeScript_kMiscSymbol, - UnicodeScript_kMiscSymbol }, // 54, - { UnicodeScript_kDingbat, - UnicodeScript_kDingbat, - UnicodeScript_kDingbat }, // 55, - { UnicodeScript_kBraillePatterns, - UnicodeScript_kBraillePatterns, - UnicodeScript_kBraillePatterns }, // 56, - { UnicodeScript_kCJKRadicalsSupplement, - UnicodeScript_kCJKRadicalsSupplement, - UnicodeScript_kCJKRadicalsSupplement }, // 57, - { UnicodeScript_kKangxiRadicals, - UnicodeScript_kKangxiRadicals, - UnicodeScript_kKangxiRadicals }, // 58, - { UnicodeScript_kIdeographicDescriptionCharacters, - UnicodeScript_kIdeographicDescriptionCharacters, - UnicodeScript_kIdeographicDescriptionCharacters }, // 59, - { UnicodeScript_kCJKSymbolPunctuation, - UnicodeScript_kCJKSymbolPunctuation, - UnicodeScript_kCJKSymbolPunctuation }, // 60, - { UnicodeScript_kHiragana, - UnicodeScript_kHiragana, - UnicodeScript_kHiragana }, // 61, - { UnicodeScript_kKatakana, - UnicodeScript_kKatakana, - UnicodeScript_kKatakana }, // 62, - { UnicodeScript_kBopomofo, - UnicodeScript_kBopomofo, - UnicodeScript_kBopomofo }, // 63, - { UnicodeScript_kHangulCompatibilityJamo, - UnicodeScript_kHangulCompatibilityJamo, - UnicodeScript_kHangulCompatibilityJamo }, // 64, - { UnicodeScript_kKanbun, - UnicodeScript_kKanbun, - UnicodeScript_kKanbun }, // 65, - { UnicodeScript_kBopomofoExtended, - UnicodeScript_kBopomofoExtended, - UnicodeScript_kBopomofoExtended }, // 66, - { UnicodeScript_kEnclosedCJKLetterMonth, - UnicodeScript_kEnclosedCJKLetterMonth, - UnicodeScript_kEnclosedCJKLetterMonth }, // 67, - { UnicodeScript_kCJKCompatibility, - UnicodeScript_kCJKCompatibility, - UnicodeScript_kCJKCompatibility }, // 68, - { UnicodeScript_k_CJKUnifiedIdeographsExtensionA, - UnicodeScript_k_CJKUnifiedIdeographsExtensionA, - UnicodeScript_k_CJKUnifiedIdeographsExtensionA }, // 69, - { UnicodeScript_kCJKUnifiedIdeograph, - UnicodeScript_kCJKUnifiedIdeograph, - UnicodeScript_kCJKUnifiedIdeograph }, // 70, - { UnicodeScript_kYiSyllables, - UnicodeScript_kYiSyllables, - UnicodeScript_kYiSyllables }, // 71, - { UnicodeScript_kYiRadicals, - UnicodeScript_kYiRadicals, - UnicodeScript_kYiRadicals }, // 72, - { UnicodeScript_kHangulSyllable, - UnicodeScript_kHangulSyllable, - UnicodeScript_kHangulSyllable }, // 73, - { UnicodeScript_kHighSurrogate, - UnicodeScript_kHighSurrogate, - UnicodeScript_kHighSurrogate }, // 74, - { UnicodeScript_kHighPrivateUseSurrogate, - UnicodeScript_kHighPrivateUseSurrogate, - UnicodeScript_kHighPrivateUseSurrogate }, // 75, - { UnicodeScript_kLowSurrogate, - UnicodeScript_kLowSurrogate, - UnicodeScript_kLowSurrogate }, // 76, - { UnicodeScript_kPrivateUse, - UnicodeScript_kPrivateUse, - UnicodeScript_kPrivateUse }, // 77, - { UnicodeScript_kCJKCompatibilityIdeograph, - UnicodeScript_kCJKCompatibilityIdeograph, - UnicodeScript_kCJKCompatibilityIdeograph }, // 78, - { UnicodeScript_kAlphabeticPresentation, - UnicodeScript_kAlphabeticPresentation, - UnicodeScript_kAlphabeticPresentation }, // 79, - { UnicodeScript_kArabicPresentationA, - UnicodeScript_kArabicPresentationA, - UnicodeScript_kArabicPresentationA }, // 80, - { UnicodeScript_kCombiningHalfMark, - UnicodeScript_kCombiningHalfMark, - UnicodeScript_kCombiningHalfMark }, // 81, - { UnicodeScript_kCJKCompatibilityForm, - UnicodeScript_kCJKCompatibilityForm, - UnicodeScript_kCJKCompatibilityForm }, // 82, - { UnicodeScript_kSmallFormVariant, - UnicodeScript_kSmallFormVariant, - UnicodeScript_kSmallFormVariant }, // 83, - { UnicodeScript_kArabicPresentationB, - UnicodeScript_kArabicPresentationB, - UnicodeScript_kArabicPresentationB }, // 84, - { UnicodeScript_kNoScript, - UnicodeScript_kNoScript, - UnicodeScript_kNoScript }, // 85, - { UnicodeScript_kHalfwidthFullwidthForm, - UnicodeScript_kHalfwidthFullwidthForm, - UnicodeScript_kHalfwidthFullwidthForm }, // 86, - { UnicodeScript_kScriptCount, - UnicodeScript_kScriptCount, - UnicodeScript_kNoScript } // 87, +struct DefaultScriptTypeList { + com::sun::star::i18n::UnicodeScript from; + com::sun::star::i18n::UnicodeScript to; + com::sun::star::i18n::UnicodeScript value; }; -sal_Int16 SAL_CALL -unicode::getUnicodeScriptType( const sal_Unicode ch, const ScriptTypeList* typeList, sal_Int16 unknownType ) { - if (!typeList) { - typeList = defaultTypeList; - unknownType = UnicodeScript_kNoScript; - } +template<class L, typename T> +T getScriptType( const sal_Unicode ch, const L* typeList, T unknownType ) { - sal_Int16 i = 0, type = typeList[0].to; - while (type < UnicodeScript_kScriptCount && ch > UnicodeScriptType[type][UnicodeScriptTypeTo]) { + sal_Int16 i = 0; + css::i18n::UnicodeScript type = typeList[0].to; + while (type < UnicodeScript_kScriptCount && ch > UnicodeScriptType[(int)type][UnicodeScriptTypeTo]) { type = typeList[++i].to; } return (type < UnicodeScript_kScriptCount && - ch >= UnicodeScriptType[typeList[i].from][UnicodeScriptTypeFrom]) ? + ch >= UnicodeScriptType[static_cast<int>(typeList[i].from)][(int)UnicodeScriptTypeFrom]) ? typeList[i].value : unknownType; } +sal_Int16 SAL_CALL +unicode::getUnicodeScriptType( const sal_Unicode ch, const ScriptTypeList* typeList, sal_Int16 unknownType ) { + return getScriptType(ch, typeList, unknownType); +} + sal_Unicode SAL_CALL unicode::getUnicodeScriptStart( UnicodeScript type) { - return UnicodeScriptType[type][UnicodeScriptTypeFrom]; + return UnicodeScriptType[(int)type][UnicodeScriptTypeFrom]; } sal_Unicode SAL_CALL unicode::getUnicodeScriptEnd( UnicodeScript type) { - return UnicodeScriptType[type][UnicodeScriptTypeTo]; + return UnicodeScriptType[(int)type][UnicodeScriptTypeTo]; } sal_Int16 SAL_CALL |