diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2017-04-17 21:35:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-04-26 08:50:54 +0200 |
commit | c70d49c7c888da8cfd73db8585e7be1f37fc398a (patch) | |
tree | c0e540401850018464ca76300536faf9aa7e27d2 /svtools | |
parent | cd4344d3bdef631b3e64ac12a9e64bc9670c1b7c (diff) |
use strong_int for LanguageType
Change-Id: If99a944f7032180355da291ad283b4cfcea4f448
Reviewed-on: https://gerrit.libreoffice.org/36629
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/misc/langtab.cxx | 12 | ||||
-rw-r--r-- | svtools/source/misc/sampletext.cxx | 192 | ||||
-rw-r--r-- | svtools/source/svhtml/htmlout.cxx | 4 |
3 files changed, 86 insertions, 122 deletions
diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx index 74497609e08d..bfbbad62bb23 100644 --- a/svtools/source/misc/langtab.cxx +++ b/svtools/source/misc/langtab.cxx @@ -150,9 +150,9 @@ SvtLanguageTableImpl::SvtLanguageTableImpl() : LanguageType nLangType = aLang.getLanguageType(); if (nType <= LanguageTag::ScriptType::RTL && nType > LanguageTag::ScriptType::UNKNOWN) aLang.setScriptType(LanguageTag::ScriptType(nType)); - sal_uInt32 nPos = FindIndex(nLangType); + sal_uInt32 nPos = FindIndex((sal_uInt16)nLangType); if (nPos == RESARRAY_INDEX_NOTFOUND) - AddItem((aName.isEmpty() ? rElementNames[i] : aName), nLangType); + AddItem((aName.isEmpty() ? rElementNames[i] : aName), (sal_uInt16)nLangType); } } } @@ -165,7 +165,7 @@ SvtLanguageTableImpl::~SvtLanguageTableImpl() bool SvtLanguageTableImpl::HasType( const LanguageType eType ) const { LanguageType eLang = MsLangId::getReplacementForObsoleteLanguage( eType ); - sal_uInt32 nPos = FindIndex( eLang ); + sal_uInt32 nPos = FindIndex( (sal_uInt16)eLang ); return RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count(); } @@ -190,7 +190,7 @@ OUString lcl_getDescription( const OUString& rBcp47 ) const OUString SvtLanguageTableImpl::GetString( const LanguageType eType ) const { LanguageType eLang = MsLangId::getReplacementForObsoleteLanguage( eType ); - sal_uInt32 nPos = FindIndex( eLang ); + sal_uInt32 nPos = FindIndex( (sal_uInt16)eLang ); if ( RESARRAY_INDEX_NOTFOUND != nPos && nPos < Count() ) return ResStringArray::GetString( nPos ); @@ -205,7 +205,7 @@ const OUString SvtLanguageTableImpl::GetString( const LanguageType eType ) const // And add it to the table if it is an on-the-fly-id, which it usually is, // so it is available in all subsequent language boxes. if (LanguageTag::isOnTheFlyID( eType)) - const_cast<SvtLanguageTableImpl*>(this)->AddItem( sLangTag, eType); + const_cast<SvtLanguageTableImpl*>(this)->AddItem( sLangTag, (sal_uInt16)eType); return sLangTag; } @@ -265,7 +265,7 @@ LanguageType SvtLanguageTable::GetLanguageTypeAtIndex( sal_uInt32 nIndex ) sal_uInt32 SvtLanguageTable::AddLanguageTag( const LanguageTag& rLanguageTag, const OUString& rString ) { return theLanguageTable::get().AddItem( (rString.isEmpty() ? lcl_getDescription(rLanguageTag.getBcp47()) : rString), - rLanguageTag.getLanguageType()); + (sal_uInt16)rLanguageTag.getLanguageType()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/misc/sampletext.cxx b/svtools/source/misc/sampletext.cxx index 75014b031cfb..cb131e28d85c 100644 --- a/svtools/source/misc/sampletext.cxx +++ b/svtools/source/misc/sampletext.cxx @@ -618,121 +618,85 @@ OUString makeMinimalTextForScript(UScriptCode eScript) OUString makeRepresentativeTextForLanguage(LanguageType eLang) { OUString sRet; - switch( eLang & LANGUAGE_MASK_PRIMARY ) + LanguageType pri = primary(eLang); + if( pri == primary(LANGUAGE_ARMENIAN) ) + sRet = makeRepresentativeTextForScript(USCRIPT_ARMENIAN); + else if( pri == primary(LANGUAGE_CHINESE) ) + sRet = makeRepresentativeTextForScript(USCRIPT_HAN); + else if( pri == primary(LANGUAGE_GREEK) ) + sRet = makeRepresentativeTextForScript(USCRIPT_GREEK); + else if( pri.anyOf( + primary(LANGUAGE_HEBREW), + primary(LANGUAGE_YIDDISH)) ) + sRet = makeRepresentativeTextForScript(USCRIPT_HEBREW); + else if( pri == primary(LANGUAGE_ARABIC_SAUDI_ARABIA) ) + sRet = makeRepresentativeTextForScript(USCRIPT_ARABIC); + else if( pri == primary(LANGUAGE_HINDI) ) + sRet = makeRepresentativeTextForScript(USCRIPT_DEVANAGARI); + else if( pri == primary(LANGUAGE_ASSAMESE) ) { - case LANGUAGE_ARMENIAN & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_ARMENIAN); - break; - case LANGUAGE_CHINESE & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_HAN); - break; - case LANGUAGE_GREEK & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_GREEK); - break; - case LANGUAGE_HEBREW & LANGUAGE_MASK_PRIMARY: - case LANGUAGE_YIDDISH & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_HEBREW); - break; - case LANGUAGE_ARABIC_SAUDI_ARABIA & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_ARABIC); - break; - case LANGUAGE_HINDI & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_DEVANAGARI); - break; - case LANGUAGE_ASSAMESE & LANGUAGE_MASK_PRIMARY: - { - static const sal_Unicode aAs[] = { - 0x0985, 0x09B8, 0x09AE, 0x09C0, 0x09AF, 0x09BC, 0x09BE, - 0x0020, 0x0986, 0x0996, 0x09F0 - }; - sRet = OUString(aAs, SAL_N_ELEMENTS(aAs)); - break; - } - case LANGUAGE_BENGALI & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_BENGALI); - break; - case LANGUAGE_PUNJABI & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_GURMUKHI); - break; - case LANGUAGE_GUJARATI & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_GUJARATI); - break; - case LANGUAGE_ODIA & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_ORIYA); - break; - case LANGUAGE_TAMIL & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_TAMIL); - break; - case LANGUAGE_TELUGU & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_TELUGU); - break; - case LANGUAGE_KANNADA & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_KANNADA); - break; - case LANGUAGE_MALAYALAM & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_MALAYALAM); - break; - case LANGUAGE_THAI & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_THAI); - break; - case LANGUAGE_LAO & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_LAO); - break; - case LANGUAGE_GEORGIAN & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_GEORGIAN); - break; - case LANGUAGE_KOREAN & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_KOREAN); - break; - case LANGUAGE_TIBETAN & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_TIBETAN); - break; - case LANGUAGE_SYRIAC & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_SYRIAC); - break; - case LANGUAGE_SINHALESE_SRI_LANKA & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_SINHALA); - break; - case LANGUAGE_BURMESE & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_MYANMAR); - break; - case LANGUAGE_AMHARIC_ETHIOPIA & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_ETHIOPIC); - break; - case LANGUAGE_CHEROKEE_UNITED_STATES & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_CHEROKEE); - break; - case LANGUAGE_KHMER & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_KHMER); - break; - case LANGUAGE_MONGOLIAN_MONGOLIAN_LSO & LANGUAGE_MASK_PRIMARY: - switch (eLang) - { - case LANGUAGE_MONGOLIAN_MONGOLIAN_MONGOLIA: - case LANGUAGE_MONGOLIAN_MONGOLIAN_CHINA: - case LANGUAGE_MONGOLIAN_MONGOLIAN_LSO: - sRet = makeRepresentativeTextForScript(USCRIPT_MONGOLIAN); - break; - default: - break; - } - break; - case LANGUAGE_JAPANESE & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_JAPANESE); - break; - case LANGUAGE_YI & LANGUAGE_MASK_PRIMARY: - sRet = makeRepresentativeTextForScript(USCRIPT_YI); - break; - case LANGUAGE_GAELIC_IRELAND & LANGUAGE_MASK_PRIMARY: - { - static const sal_Unicode aGa[] = { - 'T', 0x00E9, 'a', 'c', 's', ' ', 'S', 'a', 'm', 'p', 'l', 'a', 'c', 'h' - }; - sRet = OUString(aGa, SAL_N_ELEMENTS(aGa)); - break; - } - default: - break; + static const sal_Unicode aAs[] = { + 0x0985, 0x09B8, 0x09AE, 0x09C0, 0x09AF, 0x09BC, 0x09BE, + 0x0020, 0x0986, 0x0996, 0x09F0 + }; + sRet = OUString(aAs, SAL_N_ELEMENTS(aAs)); + } + else if( pri == primary(LANGUAGE_BENGALI) ) + sRet = makeRepresentativeTextForScript(USCRIPT_BENGALI); + else if( pri == primary(LANGUAGE_PUNJABI) ) + sRet = makeRepresentativeTextForScript(USCRIPT_GURMUKHI); + else if( pri == primary(LANGUAGE_GUJARATI) ) + sRet = makeRepresentativeTextForScript(USCRIPT_GUJARATI); + else if( pri == primary(LANGUAGE_ODIA) ) + sRet = makeRepresentativeTextForScript(USCRIPT_ORIYA); + else if( pri == primary(LANGUAGE_TAMIL) ) + sRet = makeRepresentativeTextForScript(USCRIPT_TAMIL); + else if( pri == primary(LANGUAGE_TELUGU) ) + sRet = makeRepresentativeTextForScript(USCRIPT_TELUGU); + else if( pri == primary(LANGUAGE_KANNADA) ) + sRet = makeRepresentativeTextForScript(USCRIPT_KANNADA); + else if( pri == primary(LANGUAGE_MALAYALAM) ) + sRet = makeRepresentativeTextForScript(USCRIPT_MALAYALAM); + else if( pri == primary(LANGUAGE_THAI) ) + sRet = makeRepresentativeTextForScript(USCRIPT_THAI); + else if( pri == primary(LANGUAGE_LAO) ) + sRet = makeRepresentativeTextForScript(USCRIPT_LAO); + else if( pri == primary(LANGUAGE_GEORGIAN) ) + sRet = makeRepresentativeTextForScript(USCRIPT_GEORGIAN); + else if( pri == primary(LANGUAGE_KOREAN) ) + sRet = makeRepresentativeTextForScript(USCRIPT_KOREAN); + else if( pri == primary(LANGUAGE_TIBETAN) ) + sRet = makeRepresentativeTextForScript(USCRIPT_TIBETAN); + else if( pri == primary(LANGUAGE_SYRIAC) ) + sRet = makeRepresentativeTextForScript(USCRIPT_SYRIAC); + else if( pri == primary(LANGUAGE_SINHALESE_SRI_LANKA) ) + sRet = makeRepresentativeTextForScript(USCRIPT_SINHALA); + else if( pri == primary(LANGUAGE_BURMESE) ) + sRet = makeRepresentativeTextForScript(USCRIPT_MYANMAR); + else if( pri == primary(LANGUAGE_AMHARIC_ETHIOPIA) ) + sRet = makeRepresentativeTextForScript(USCRIPT_ETHIOPIC); + else if( pri == primary(LANGUAGE_CHEROKEE_UNITED_STATES) ) + sRet = makeRepresentativeTextForScript(USCRIPT_CHEROKEE); + else if( pri == primary(LANGUAGE_KHMER) ) + sRet = makeRepresentativeTextForScript(USCRIPT_KHMER); + else if( pri == primary(LANGUAGE_MONGOLIAN_MONGOLIAN_LSO) ) + { + if (eLang.anyOf( + LANGUAGE_MONGOLIAN_MONGOLIAN_MONGOLIA, + LANGUAGE_MONGOLIAN_MONGOLIAN_CHINA, + LANGUAGE_MONGOLIAN_MONGOLIAN_LSO)) + sRet = makeRepresentativeTextForScript(USCRIPT_MONGOLIAN); + } + else if( pri == primary(LANGUAGE_JAPANESE) ) + sRet = makeRepresentativeTextForScript(USCRIPT_JAPANESE); + else if( pri == primary(LANGUAGE_YI) ) + sRet = makeRepresentativeTextForScript(USCRIPT_YI); + else if( pri == primary(LANGUAGE_GAELIC_IRELAND) ) + { + static const sal_Unicode aGa[] = { + 'T', 0x00E9, 'a', 'c', 's', ' ', 'S', 'a', 'm', 'p', 'l', 'a', 'c', 'h' + }; + sRet = OUString(aGa, SAL_N_ELEMENTS(aGa)); } return sRet; diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx index 1038b6f4a42a..ccfd5da20a82 100644 --- a/svtools/source/svhtml/htmlout.cxx +++ b/svtools/source/svhtml/htmlout.cxx @@ -955,7 +955,7 @@ OString HTMLOutFuncs::CreateTableDataOptionsValNum( aStrTD.append(' '). append(OOO_STRING_SVTOOLS_HTML_O_SDnum). append("=\""). - append(static_cast<sal_Int32>( + append((sal_Int32)static_cast<sal_uInt16>( Application::GetSettings().GetLanguageTag().getLanguageType())). append(';'); // Language for Format 0 if ( nFormat ) @@ -971,7 +971,7 @@ OString HTMLOutFuncs::CreateTableDataOptionsValNum( } else nLang = LANGUAGE_SYSTEM; - aStrTD.append(static_cast<sal_Int32>(nLang)).append(';'). + aStrTD.append((sal_Int32)static_cast<sal_uInt16>(nLang)).append(';'). append(aNumStr); } aStrTD.append('\"'); |