diff options
28 files changed, 208 insertions, 236 deletions
diff --git a/cui/source/options/optasian.cxx b/cui/source/options/optasian.cxx index 035aa7fa0fad..914923d71fed 100644 --- a/cui/source/options/optasian.cxx +++ b/cui/source/options/optasian.cxx @@ -33,6 +33,7 @@ #include <optasian.hrc> #include <dialmgr.hxx> #include <cuires.hrc> +#include <i18npool/mslangid.hxx> #include <tools/shl.hxx> #include <svl/asiancfg.hxx> #include <com/sun/star/lang/Locale.hpp> @@ -301,17 +302,10 @@ void SvxAsianLayoutPage::Reset( const SfxItemSet& ) { eLastUsedLanguageTypeForForbiddenCharacters = SvxLocaleToLanguage( Application::GetSettings().GetLocale() ); - switch(eLastUsedLanguageTypeForForbiddenCharacters) - { - case LANGUAGE_CHINESE : - case LANGUAGE_CHINESE_SINGAPORE : - eLastUsedLanguageTypeForForbiddenCharacters = LANGUAGE_CHINESE_SIMPLIFIED; - break; - case LANGUAGE_CHINESE_HONGKONG : - case LANGUAGE_CHINESE_MACAU : - eLastUsedLanguageTypeForForbiddenCharacters = LANGUAGE_CHINESE_TRADITIONAL; - break; - } + if (MsLangId::isSimplifiedChinese(eLastUsedLanguageTypeForForbiddenCharacters)) + eLastUsedLanguageTypeForForbiddenCharacters = LANGUAGE_CHINESE_SIMPLIFIED; + else if (MsLangId::isTraditionalChinese(eLastUsedLanguageTypeForForbiddenCharacters)) + eLastUsedLanguageTypeForForbiddenCharacters = LANGUAGE_CHINESE_TRADITIONAL; } aLanguageLB.SelectLanguage( eLastUsedLanguageTypeForForbiddenCharacters ); LanguageHdl(&aLanguageLB); diff --git a/cui/source/options/optgenrl.cxx b/cui/source/options/optgenrl.cxx index 2454f17725fe..6645a2e66c9a 100644 --- a/cui/source/options/optgenrl.cxx +++ b/cui/source/options/optgenrl.cxx @@ -27,6 +27,7 @@ ************************************************************************/ #include <comphelper/string.hxx> +#include <i18npool/mslangid.hxx> #include <tools/shl.hxx> #include <vcl/svapp.hxx> #include <vcl/msgbox.hxx> @@ -162,11 +163,7 @@ SvxGeneralTabPage::SvxGeneralTabPage( Window* pParent, const SfxItemSet& rCoreSe aFirstName.SetZOrder( &aName, WINDOW_ZORDER_BEHIND ); aFatherName.SetZOrder( &aFirstName, WINDOW_ZORDER_BEHIND ); } - else if ( LANGUAGE_JAPANESE == eLang || - LANGUAGE_KOREAN == eLang || - LANGUAGE_HUNGARIAN == eLang || - LANGUAGE_CHINESE_TRADITIONAL == eLang || - LANGUAGE_CHINESE_SIMPLIFIED == eLang) + else if (MsLangId::isFamilyNameFirst(eLang)) { aUsCityEdit.Hide(); aUsStateEdit.Hide(); diff --git a/editeng/inc/editeng/hangulhanja.hxx b/editeng/inc/editeng/hangulhanja.hxx index b952530158c7..0b10bd52ae16 100644 --- a/editeng/inc/editeng/hangulhanja.hxx +++ b/editeng/inc/editeng/hangulhanja.hxx @@ -34,6 +34,7 @@ #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/uno/Sequence.hxx> #include "editeng/editengdllapi.h" +#include <i18npool/mslangid.hxx> //............................................................................. namespace editeng @@ -275,20 +276,17 @@ namespace editeng sal_Bool HangulHanjaConversion::IsSimplified( LanguageType nLang ) { - return nLang == LANGUAGE_CHINESE_SIMPLIFIED || - nLang == LANGUAGE_CHINESE_SINGAPORE; + return MsLangId::isSimplifiedChinese(nLang); } sal_Bool HangulHanjaConversion::IsTraditional( LanguageType nLang ) { - return nLang == LANGUAGE_CHINESE_TRADITIONAL || - nLang == LANGUAGE_CHINESE_HONGKONG || - nLang == LANGUAGE_CHINESE_MACAU; + return MsLangId::isTraditionalChinese(nLang); } sal_Bool HangulHanjaConversion::IsChinese( LanguageType nLang ) { - return IsTraditional( nLang ) || IsSimplified( nLang ); + return MsLangId::isChinese(nLang); } //............................................................................. } // namespace svx diff --git a/i18npool/inc/i18npool/mslangid.hxx b/i18npool/inc/i18npool/mslangid.hxx index f1da9814cf11..7fb3d8dbfd2b 100644 --- a/i18npool/inc/i18npool/mslangid.hxx +++ b/i18npool/inc/i18npool/mslangid.hxx @@ -184,6 +184,29 @@ public: /** Whether locale has a Right-To-Left orientation. */ static bool isRightToLeft( LanguageType nLang ); + /** Whether locale is a CJK locale */ + static bool isCJK( LanguageType nLang ); + + /** Whether locale is a chinese locale */ + static bool isChinese( LanguageType nLang ); + + /** Whether locale is a simplified chinese locale */ + static bool isSimplifiedChinese( LanguageType nLang ); + + /** Whether locale is a traditional chinese locale */ + static bool isTraditionalChinese( LanguageType nLang ); + + /** Whether locale is a korean locale */ + static bool isKorean( LanguageType nLang ); + + /** Whether locale is a simplified chinese locale */ + static bool isSimplifiedChinese( const ::com::sun::star::lang::Locale & rLocale ); + + /** Whether locale is a traditional chinese locale */ + static bool isTraditionalChinese( const ::com::sun::star::lang::Locale & rLocale ); + + /** Whether locale is one where family name comes first, e.g. Japan, Hungary, Samoa */ + static bool isFamilyNameFirst( LanguageType nLang ); /** Whether there are "forbidden characters at start or end of line" in this locale. CJK locales. diff --git a/i18npool/source/characterclassification/characterclassificationImpl.cxx b/i18npool/source/characterclassification/characterclassificationImpl.cxx index 70d1683055fa..df4abe461408 100644 --- a/i18npool/source/characterclassification/characterclassificationImpl.cxx +++ b/i18npool/source/characterclassification/characterclassificationImpl.cxx @@ -178,7 +178,6 @@ CharacterClassificationImpl::getLocaleSpecificCharacterClassification(const Loca } static sal_Unicode under = (sal_Unicode)'_'; - static OUString tw("TW"); sal_Int32 l = rLocale.Language.getLength(); sal_Int32 c = rLocale.Country.getLength(); sal_Int32 v = rLocale.Variant.getLength(); @@ -197,7 +196,7 @@ CharacterClassificationImpl::getLocaleSpecificCharacterClassification(const Loca rLocale.Country.compareToAscii("MO") == 0) && // if the country code is HK or MO, one more step to try TW. createLocaleSpecificCharacterClassification(aBuf.append(rLocale.Language).append(under).append( - tw).makeStringAndClear(), rLocale)) || + "TW").makeStringAndClear(), rLocale)) || (l > 0 && // load service with name <base>_<lang> createLocaleSpecificCharacterClassification(rLocale.Language, rLocale))) { diff --git a/i18npool/source/collator/collatorImpl.cxx b/i18npool/source/collator/collatorImpl.cxx index 93cc2a6a930d..b76bea6ef853 100644 --- a/i18npool/source/collator/collatorImpl.cxx +++ b/i18npool/source/collator/collatorImpl.cxx @@ -195,8 +195,6 @@ CollatorImpl::loadCachedCollator(const lang::Locale& rLocale, const OUString& rS } static sal_Unicode under = (sal_Unicode) '_'; - static OUString tw("TW"); - static OUString unicode("Unicode"); sal_Int32 l = rLocale.Language.getLength(); sal_Int32 c = rLocale.Country.getLength(); @@ -215,7 +213,7 @@ CollatorImpl::loadCachedCollator(const lang::Locale& rLocale, const OUString& rS under).append(rSortAlgorithm).makeStringAndClear(), rSortAlgorithm)) || (l > 0 && c > 0 && a > 0 && rLocale.Language == "zh" && (rLocale.Country == "HK" || rLocale.Country == "MO") && // if the country code is HK or MO, one more step to try TW. - createCollator(rLocale, aBuf.append(rLocale.Language).append(under).append(tw).append(under).append( + createCollator(rLocale, aBuf.append(rLocale.Language).append(under).append("TW").append(under).append( rSortAlgorithm).makeStringAndClear(), rSortAlgorithm)) || (l > 0 && a > 0 && // load service with name <base>_<lang>_<algorithm> @@ -225,7 +223,7 @@ CollatorImpl::loadCachedCollator(const lang::Locale& rLocale, const OUString& rS (a > 0 && createCollator(rLocale, rSortAlgorithm, rSortAlgorithm)) || // load default service with name <base>_Unicode - createCollator(rLocale, unicode, rSortAlgorithm)) { + createCollator(rLocale, "Unicode", rSortAlgorithm)) { return; } else { cachedItem = NULL; diff --git a/i18npool/source/isolang/mslangid.cxx b/i18npool/source/isolang/mslangid.cxx index 3cd877e4c91b..206a8c71aa41 100644 --- a/i18npool/source/isolang/mslangid.cxx +++ b/i18npool/source/isolang/mslangid.cxx @@ -249,9 +249,54 @@ bool MsLangId::isRightToLeft( LanguageType nLang ) return false; } +// static +bool MsLangId::isSimplifiedChinese( LanguageType nLang ) +{ + return isChinese(nLang) && !isTraditionalChinese(nLang); +} // static -bool MsLangId::hasForbiddenCharacters( LanguageType nLang ) +bool MsLangId::isSimplifiedChinese( const ::com::sun::star::lang::Locale & rLocale ) +{ + return rLocale.Language == "zh" && !isTraditionalChinese(rLocale); +} + +// static +bool MsLangId::isTraditionalChinese( LanguageType nLang ) +{ + bool bRet = false; + switch (nLang) + { + case LANGUAGE_CHINESE_TRADITIONAL: + case LANGUAGE_CHINESE_HONGKONG: + case LANGUAGE_CHINESE_MACAU: + bRet = true; + default: + break; + } + return bRet; +} + +// static +bool MsLangId::isTraditionalChinese( const ::com::sun::star::lang::Locale & rLocale ) +{ + return rLocale.Language == "zh" && (rLocale.Country == "TW" || rLocale.Country == "HK" || rLocale.Country == "MO"); +} + +//static +bool MsLangId::isChinese( LanguageType nLang ) +{ + return MsLangId::getPrimaryLanguage(nLang) == LANGUAGE_CHINESE; +} + +//static +bool MsLangId::isKorean( LanguageType nLang ) +{ + return MsLangId::getPrimaryLanguage(nLang) == LANGUAGE_KOREAN; +} + +// static +bool MsLangId::isCJK( LanguageType nLang ) { switch (nLang & LANGUAGE_MASK_PRIMARY) { @@ -265,6 +310,18 @@ bool MsLangId::hasForbiddenCharacters( LanguageType nLang ) return false; } +// static +bool MsLangId::isFamilyNameFirst( LanguageType nLang ) +{ + return isCJK(nLang) || nLang == LANGUAGE_HUNGARIAN; +} + +// static +bool MsLangId::hasForbiddenCharacters( LanguageType nLang ) +{ + return isCJK(nLang); +} + // static bool MsLangId::needsSequenceChecking( LanguageType nLang ) diff --git a/i18npool/source/nativenumber/nativenumbersupplier.cxx b/i18npool/source/nativenumber/nativenumbersupplier.cxx index 2d09dabbfa63..cd3d2ca756e3 100644 --- a/i18npool/source/nativenumber/nativenumbersupplier.cxx +++ b/i18npool/source/nativenumber/nativenumbersupplier.cxx @@ -26,7 +26,7 @@ * ************************************************************************/ - +#include <i18npool/mslangid.hxx> #include <rtl/ustrbuf.hxx> #include <sal/macros.h> #include <nativenumbersupplier.hxx> @@ -526,7 +526,7 @@ static sal_Int16 sizeof_natnum2 = SAL_N_ELEMENTS(natnum2); static sal_Int16 SAL_CALL getLanguageNumber( const Locale& rLocale) { // return zh_TW for TW, HK and MO, return zh_CN for other zh locales. - if (isLang("zh")) return (isCtry("TW") || isCtry("HK") || isCtry("MO")) ? 1 : 0; + if (isLang("zh")) return MsLangId::isTraditionalChinese(rLocale) ? 1 : 0; for (sal_Int16 i = 2; i < nbOfLocale; i++) if (isLang(natnum1Locales[i])) diff --git a/reportdesign/source/core/api/ReportComponent.cxx b/reportdesign/source/core/api/ReportComponent.cxx index 38b80c859b12..4045db843562 100644 --- a/reportdesign/source/core/api/ReportComponent.cxx +++ b/reportdesign/source/core/api/ReportComponent.cxx @@ -58,13 +58,8 @@ void lcl_getDefaultFonts( Font& rLatinFont, Font& rCJKFont, Font& rCTLFont,Langu // be queried for Korean, too (the Latin language from the document can't be Korean). // This is the same logic as in SwDocShell::InitNew. LanguageType eUiLanguage = Application::GetSettings().GetUILanguage(); - switch( eUiLanguage ) - { - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - eLatin = eUiLanguage; - break; - } + if (MsLangId::isKorean(eUiLanguage)) + eLatin = eUiLanguage; rLatinFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION, eLatin, DEFAULTFONT_FLAGS_ONLYONE ); rCJKFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION, _eCJK, DEFAULTFONT_FLAGS_ONLYONE ); diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 39649384e935..dbe0a9d61544 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -51,6 +51,7 @@ #include <svx/svdograf.hxx> #include <svx/svdoole2.hxx> #include <svx/svdundo.hxx> +#include <i18npool/mslangid.hxx> #include <editeng/unolingu.hxx> #include <svx/drawitem.hxx> #include <editeng/fhgtitem.hxx> @@ -259,8 +260,7 @@ ScDrawLayer::ScDrawLayer( ScDocument* pDocument, const String& rName ) : // default for script spacing depends on locale, see SdDrawDocument ctor in sd LanguageType eOfficeLanguage = Application::GetSettings().GetLanguage(); - if ( eOfficeLanguage == LANGUAGE_KOREAN || eOfficeLanguage == LANGUAGE_KOREAN_JOHAB || - eOfficeLanguage == LANGUAGE_JAPANESE ) + if (MsLangId::isKorean(eOfficeLanguage) || eOfficeLanguage == LANGUAGE_JAPANESE) { // secondary is edit engine pool rPool.GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( false, EE_PARA_ASIANCJKSPACING ) ); diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx index 45ebdc41bff7..96e7cfbaaf1d 100644 --- a/sc/source/core/data/stlpool.cxx +++ b/sc/source/core/data/stlpool.cxx @@ -28,6 +28,7 @@ #include "scitems.hxx" #include <editeng/eeitem.hxx> +#include <i18npool/mslangid.hxx> #include <svx/algitem.hxx> #include <editeng/boxitem.hxx> #include <editeng/brshitem.hxx> @@ -291,13 +292,8 @@ void ScStyleSheetPool::CreateStandardStyles() // be queried for Korean, too (the Latin language from the document can't be Korean). // This is the same logic as in SwDocShell::InitNew. LanguageType eUiLanguage = Application::GetSettings().GetUILanguage(); - switch( eUiLanguage ) - { - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - eLatin = eUiLanguage; - break; - } + if (MsLangId::isKorean(eUiLanguage)) + eLatin = eUiLanguage; lcl_CheckFont( *pSet, eLatin, DEFAULTFONT_LATIN_SPREADSHEET, ATTR_FONT ); lcl_CheckFont( *pSet, eCjk, DEFAULTFONT_CJK_SPREADSHEET, ATTR_CJK_FONT ); diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index 4c7c98985ab9..d88383f117cd 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -242,7 +242,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) } // for korean and japanese languages we have a different default for apply spacing between asian, latin and ctl text - if( ( LANGUAGE_KOREAN == eRealCTLLanguage ) || ( LANGUAGE_KOREAN_JOHAB == eRealCTLLanguage ) || ( LANGUAGE_JAPANESE == eRealCTLLanguage ) ) + if (MsLangId::isKorean(eRealCTLLanguage) || (LANGUAGE_JAPANESE == eRealCTLLanguage)) { GetPool().GetSecondaryPool()->SetPoolDefaultItem( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) ); } diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 6fce9ca1a991..100bae141d5d 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -29,7 +29,7 @@ #include <com/sun/star/style/XStyle.hpp> #include <com/sun/star/container/XNameAccess.hpp> - +#include <i18npool/mslangid.hxx> #include <sfx2/docfile.hxx> #include <sfx2/dispatch.hxx> #include "Outliner.hxx" @@ -1389,13 +1389,8 @@ void SdDrawDocument::getDefaultFonts( Font& rLatinFont, Font& rCJKFont, Font& rC // be queried for Korean, too (the Latin language from the document can't be Korean). // This is the same logic as in SwDocShell::InitNew. LanguageType eUiLanguage = Application::GetSettings().GetUILanguage(); - switch( eUiLanguage ) - { - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - eLatin = eUiLanguage; - break; - } + if (MsLangId::isKorean(eUiLanguage)) + eLatin = eUiLanguage; rLatinFont = OutputDevice::GetDefaultFont( DEFAULTFONT_LATIN_PRESENTATION, eLatin, DEFAULTFONT_FLAGS_ONLYONE ); rCJKFont = OutputDevice::GetDefaultFont( DEFAULTFONT_CJK_PRESENTATION, GetLanguage( EE_CHAR_LANGUAGE_CJK ), DEFAULTFONT_FLAGS_ONLYONE ); diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx index e14b698c654d..3c8ff6c00862 100644 --- a/svtools/source/control/ctrltool.cxx +++ b/svtools/source/control/ctrltool.cxx @@ -895,22 +895,17 @@ FontSizeNames::FontSizeNames( LanguageType eLanguage ) if ( eLanguage == LANGUAGE_SYSTEM ) eLanguage = MsLangId::getSystemUILanguage(); - switch( eLanguage ) + if (MsLangId::isSimplifiedChinese(eLanguage)) { - case LANGUAGE_CHINESE: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_SINGAPORE: - mpArray = aImplSimplifiedChinese; - mnElem = SAL_N_ELEMENTS(aImplSimplifiedChinese); - break; - // equivalent for traditional chinese disabled by popular request, #i89077# - - default: - mpArray = NULL; - mnElem = 0; - break; - }; + mpArray = aImplSimplifiedChinese; + mnElem = SAL_N_ELEMENTS(aImplSimplifiedChinese); + } + else + { + mpArray = NULL; + mnElem = 0; + } } //------------------------------------------------------------------------ diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 5bcd3e331a34..6cb66ce90449 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -29,6 +29,7 @@ #include <ctype.h> #include <com/sun/star/i18n/ScriptType.hdl> +#include <i18npool/mslangid.hxx> #include <hintids.hxx> // CH_TXTATR #include <SwPortionHandler.hxx> #include <porlay.hxx> @@ -101,7 +102,7 @@ sal_uInt16 lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, LanguageType aLang = rInf.GetTxtFrm()->GetTxtNode()->GetLang( rInf.GetIdx(), 1, nScript ); - if ( LANGUAGE_KOREAN != aLang && LANGUAGE_KOREAN_JOHAB != aLang ) + if (MsLangId::isKorean(aLang)) { const SwLinePortion* pPor = rPor.GetPortion(); if ( pPor && ( pPor->IsKernPortion() || @@ -209,7 +210,7 @@ sal_uInt16 lcl_AddSpace( const SwTxtSizeInfo &rInf, const XubString* pStr, LanguageType aLang = rInf.GetTxtFrm()->GetTxtNode()->GetLang( nPos, 1, nNextScript ); - if ( LANGUAGE_KOREAN != aLang && LANGUAGE_KOREAN_JOHAB != aLang ) + if (MsLangId::isKorean(aLang)) ++nCnt; } } diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 7aec18cf412f..3db14e6487de 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include <i18npool/mslangid.hxx> #include <vcl/outdev.hxx> #include <vcl/print.hxx> #include <vcl/lineinfo.hxx> @@ -1093,7 +1094,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) if ( ( SW_CJK == nActual || SW_LATIN == nActual ) && nSpaceAdd ) { LanguageType aLang = rInf.GetFont()->GetLanguage( SW_CJK ); - if ( LANGUAGE_KOREAN != aLang && LANGUAGE_KOREAN_JOHAB != aLang) + if (MsLangId::isKorean(aLang)) { long nSpaceSum = nSpaceAdd; for ( sal_uInt16 nI = 0; nI < rInf.GetLen(); ++nI ) @@ -1269,7 +1270,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) { LanguageType aLang = rInf.GetFont()->GetLanguage( SW_CJK ); - if ( LANGUAGE_KOREAN != aLang && LANGUAGE_KOREAN_JOHAB != aLang ) + if (MsLangId::isKorean(aLang)) { long nSpaceSum = nSpaceAdd; for ( sal_uInt16 nI = 0; nI < rInf.GetLen(); ++nI ) @@ -1480,7 +1481,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf ) { LanguageType aLang = rInf.GetFont()->GetLanguage( SW_CJK ); - if ( LANGUAGE_KOREAN != aLang && LANGUAGE_KOREAN_JOHAB != aLang ) + if (MsLangId::isKorean(aLang)) { long nSpaceSum = nSpaceAdd; for ( sal_uInt16 nI = 0; nI < rInf.GetLen(); ++nI ) @@ -2050,7 +2051,7 @@ xub_StrLen SwFntObj::GetCrsrOfst( SwDrawTextInfo &rInf ) { LanguageType aLang = rInf.GetFont()->GetLanguage( SW_CJK ); - if ( LANGUAGE_KOREAN != aLang && LANGUAGE_KOREAN_JOHAB != aLang ) + if (MsLangId::isKorean(aLang)) { long nSpaceSum = nSpaceAdd; for ( sal_uInt16 nI = 0; nI < rInf.GetLen(); ++nI ) diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 6d7954840303..9df457c02b0d 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -75,6 +75,7 @@ #include <editeng/pgrditem.hxx> #include <editeng/frmdiritem.hxx> #include <editeng/charhiddenitem.hxx> +#include <i18npool/mslangid.hxx> #include <fmtpdsc.hxx> #include <node.hxx> #include <ndtxt.hxx> // SwTxtNode, siehe unten: JoinNode() @@ -4365,10 +4366,7 @@ void SwWW8ImplReader::Read_Emphasis( sal_uInt16, const sal_uInt8* pData, short n nVal = EMPHASISMARK_NONE; break; case 2: - if ((nLang == LANGUAGE_CHINESE_HONGKONG) || - (nLang == LANGUAGE_CHINESE_MACAU) || - (nLang == LANGUAGE_CHINESE_TRADITIONAL) || - (nLang == LANGUAGE_KOREAN)) + if (MsLangId::isKorean(nLang) || MsLangId::isTraditionalChinese(nLang)) nVal = EMPHASISMARK_CIRCLE_ABOVE; else if (nLang == LANGUAGE_JAPANESE) nVal = EMPHASISMARK_SIDE_DOTS; @@ -4382,8 +4380,7 @@ void SwWW8ImplReader::Read_Emphasis( sal_uInt16, const sal_uInt8* pData, short n nVal = EMPHASISMARK_DOTS_BELOW; break; case 1: - if ((nLang == LANGUAGE_CHINESE_SIMPLIFIED) || - (nLang == LANGUAGE_CHINESE_SINGAPORE)) + if (MsLangId::isSimplifiedChinese(nLang)) nVal = EMPHASISMARK_DOTS_BELOW; else nVal = EMPHASISMARK_DOTS_ABOVE; diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index 178483b57ab8..cd5d1ff76572 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -31,7 +31,8 @@ #include <functional> #include <algorithm> -#include <string.h> // memset() +#include <string.h> +#include <i18npool/mslangid.hxx> #include <rtl/tencinfo.h> #include <sal/macros.h> @@ -5582,25 +5583,11 @@ WW8Fib::WW8Fib(sal_uInt8 nVer) lid = 0x409; // LANGUAGE_ENGLISH_US LanguageType nLang = Application::GetSettings().GetLanguage(); - switch( nLang ) - { - case LANGUAGE_CHINESE: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_HONGKONG: - case LANGUAGE_CHINESE_SINGAPORE: - case LANGUAGE_CHINESE_MACAU: - case LANGUAGE_CHINESE_TRADITIONAL: - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - case LANGUAGE_JAPANESE: - lidFE = nLang; - fFarEast = true; - break; - default: - lidFE = lid; - fFarEast = false; - break; - }; + fFarEast = MsLangId::isCJK(nLang); + if (fFarEast) + lidFE = nLang; + else + lidFE = lid; Locale aTempLocale; SvxLanguageToLocale( aTempLocale, lid ); diff --git a/sw/source/ui/app/docshini.cxx b/sw/source/ui/app/docshini.cxx index a860c3ba67f7..383b4a3e4292 100644 --- a/sw/source/ui/app/docshini.cxx +++ b/sw/source/ui/app/docshini.cxx @@ -214,13 +214,8 @@ sal_Bool SwDocShell::InitNew( const uno::Reference < embed::XStorage >& xStor ) if ( i == 0 ) { LanguageType eUiLanguage = Application::GetSettings().GetUILanguage(); - switch( eUiLanguage ) - { - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - eLanguage = eUiLanguage; - break; - } + if (MsLangId::isKorean(eUiLanguage)) + eLanguage = eUiLanguage; } Font aLangDefFont = OutputDevice::GetDefaultFont( diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index b13fe320f60e..5c889369b229 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include <i18npool/mslangid.hxx> #include <unotools/fontcfg.hxx> #include <unotools/fontdefs.hxx> #include <comphelper/processfactory.hxx> @@ -325,13 +326,10 @@ OUString DefaultFontConfiguration::getUserInterfaceFont( const Locale& rLocale ) { return rtl::OUString(FALLBACKFONT_UI_SANS_LATIN2); } - else if ( aLocale.Language == "zh" ) - { - if( ! aLocale.Country.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "cn" ) ) ) - return rtl::OUString(FALLBACKFONT_UI_SANS_CHINTRD); - else - return rtl::OUString(FALLBACKFONT_UI_SANS_CHINSIM); - } + else if (MsLangId::isTraditionalChinese(aLocale)) + return rtl::OUString(FALLBACKFONT_UI_SANS_CHINTRD); + else if (MsLangId::isSimplifiedChinese(aLocale)) + return rtl::OUString(FALLBACKFONT_UI_SANS_CHINSIM); else if ( aLocale.Language == "ja" ) { // we need localized names for japanese fonts diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx index 5e60a3d4d797..286932e68aae 100644 --- a/unotools/source/config/lingucfg.cxx +++ b/unotools/source/config/lingucfg.cxx @@ -639,9 +639,7 @@ sal_Bool SvtLinguConfigItem::LoadOptions( const uno::Sequence< OUString > &rProp if( ! (rVal >>= rOpt.bIsDirectionToSimplified) ) { //default is locale dependent: - if( rOpt.nDefaultLanguage_CJK == LANGUAGE_CHINESE_HONGKONG - || rOpt.nDefaultLanguage_CJK == LANGUAGE_CHINESE_MACAU - || rOpt.nDefaultLanguage_CJK == LANGUAGE_CHINESE_TRADITIONAL ) + if (MsLangId::isTraditionalChinese(rOpt.nDefaultLanguage_CJK)) { rOpt.bIsDirectionToSimplified = sal_False; } diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx index 7c4bc21202bb..9cd88a47c3ab 100644 --- a/vcl/generic/glyphs/gcach_ftyp.cxx +++ b/vcl/generic/glyphs/gcach_ftyp.cxx @@ -50,6 +50,7 @@ #include "osl/file.hxx" #include "osl/thread.hxx" +#include "langboost.hxx" #include "sft.hxx" #include <ft2build.h> @@ -177,27 +178,7 @@ FtFontFile::FtFontFile( const ::rtl::OString& rNativeFileName ) if( bOnce ) { bOnce = false; - LanguageType aLang = Application::GetSettings().GetUILanguage(); - switch( aLang ) - { - case LANGUAGE_JAPANESE: - pLangBoost = "jan"; - break; - case LANGUAGE_CHINESE: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_SINGAPORE: - pLangBoost = "zhs"; - break; - case LANGUAGE_CHINESE_TRADITIONAL: - case LANGUAGE_CHINESE_HONGKONG: - case LANGUAGE_CHINESE_MACAU: - pLangBoost = "zht"; - break; - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - pLangBoost = "kor"; - break; - } + pLangBoost = vcl::getLangBoost(); } if( pLangBoost && !strncasecmp( pLangBoost, &maNativeFileName.getStr()[nPos+1], 3 ) ) diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index 29c0610c53d1..95aed990e218 100644 --- a/vcl/generic/print/genpspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -54,13 +54,15 @@ #include "fontsubset.hxx" #include "salprn.hxx" #include "region.h" +#include "langboost.hxx" #ifdef ENABLE_GRAPHITE #include <graphite_layout.hxx> #include <graphite_serverfont.hxx> #endif -#include "comphelper/string.hxx" +#include <comphelper/string.hxx> +#include <i18npool/mslangid.hxx> using namespace psp; @@ -1178,6 +1180,26 @@ ImplDevFontAttributes GenPspGraphics::Info2DevFontAttributes( const psp::FastPri return aDFA; } +namespace vcl +{ + const char* getLangBoost() + { + const char* pLangBoost; + const LanguageType eLang = Application::GetSettings().GetUILanguage(); + if (eLang == LANGUAGE_JAPANESE) + pLangBoost = "jan"; + else if (MsLangId::isKorean(eLang)) + pLangBoost = "kor"; + else if (MsLangId::isSimplifiedChinese(eLang)) + pLangBoost = "zhs"; + else if (MsLangId::isTraditionalChinese(eLang)) + pLangBoost = "zht"; + else + pLangBoost = NULL; + return pLangBoost; + } +} + // ----------------------------------------------------------------------- void GenPspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastPrintFontInfo& aInfo ) @@ -1199,27 +1221,7 @@ void GenPspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastP if( bOnce ) { bOnce = false; - const LanguageType aLang = Application::GetSettings().GetUILanguage(); - switch( aLang ) - { - case LANGUAGE_JAPANESE: - pLangBoost = "jan"; - break; - case LANGUAGE_CHINESE: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_SINGAPORE: - pLangBoost = "zhs"; - break; - case LANGUAGE_CHINESE_TRADITIONAL: - case LANGUAGE_CHINESE_HONGKONG: - case LANGUAGE_CHINESE_MACAU: - pLangBoost = "zht"; - break; - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - pLangBoost = "kor"; - break; - } + pLangBoost = vcl::getLangBoost(); } if( pLangBoost ) diff --git a/vcl/inc/langboost.hxx b/vcl/inc/langboost.hxx new file mode 100644 index 000000000000..f612cbaa1ddb --- /dev/null +++ b/vcl/inc/langboost.hxx @@ -0,0 +1,18 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +#ifndef _VCL_LANGBOOST_HXX +#define _VCL_LANGBOOST_HXX + +namespace vcl +{ + const char* getLangBoost(); +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index daddd9096e64..948fcc38ce84 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -2734,30 +2734,19 @@ ImplDevFontListData* ImplDevFontList::ImplFindByFont( FontSelectPattern& rFSD, } // if still needed use the font request's attributes to find a good match - switch( rFSD.meLanguage ) + if (MsLangId::isSimplifiedChinese(rFSD.meLanguage)) + nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_SC; + else if (MsLangId::isTraditionalChinese(rFSD.meLanguage)) + nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_TC; + else if (MsLangId::isKorean(rFSD.meLanguage)) + nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_KR; + else if (rFSD.meLanguage == LANGUAGE_JAPANESE) + nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_JP; + else { - case LANGUAGE_CHINESE: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_SINGAPORE: - nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_SC; - break; - case LANGUAGE_CHINESE_TRADITIONAL: - case LANGUAGE_CHINESE_HONGKONG: - case LANGUAGE_CHINESE_MACAU: - nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_TC; - break; - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_KR; - break; - case LANGUAGE_JAPANESE: - nSearchType |= IMPL_FONT_ATTR_CJK | IMPL_FONT_ATTR_CJK_JP; - break; - default: - nSearchType |= ImplIsCJKFont( rFSD.maName ); - if( rFSD.IsSymbolFont() ) - nSearchType |= IMPL_FONT_ATTR_SYMBOL; - break; + nSearchType |= ImplIsCJKFont( rFSD.maName ); + if( rFSD.IsSymbolFont() ) + nSearchType |= IMPL_FONT_ATTR_SYMBOL; } ImplCalcType( nSearchType, eSearchWeight, eSearchWidth, rFSD.meFamily, pFontAttr ); @@ -2936,15 +2925,13 @@ FontEmphasisMark OutputDevice::ImplGetEmphasisMarkStyle( const Font& rFont ) { LanguageType eLang = rFont.GetLanguage(); // In Chinese Simplified the EmphasisMarks are below/left - if ( (eLang == LANGUAGE_CHINESE_SIMPLIFIED) || - (eLang == LANGUAGE_CHINESE_SINGAPORE) ) + if (MsLangId::isSimplifiedChinese(eLang)) nEmphasisMark |= EMPHASISMARK_POS_BELOW; else { eLang = rFont.GetCJKContextLanguage(); // In Chinese Simplified the EmphasisMarks are below/left - if ( (eLang == LANGUAGE_CHINESE_SIMPLIFIED) || - (eLang == LANGUAGE_CHINESE_SINGAPORE) ) + if (MsLangId::isSimplifiedChinese(eLang)) nEmphasisMark |= EMPHASISMARK_POS_BELOW; else nEmphasisMark |= EMPHASISMARK_POS_ABOVE; diff --git a/vcl/source/window/mnemonic.cxx b/vcl/source/window/mnemonic.cxx index daeae8ba3b04..4d9acb9972d0 100644 --- a/vcl/source/window/mnemonic.cxx +++ b/vcl/source/window/mnemonic.cxx @@ -34,6 +34,7 @@ #include <vcl/unohelp.hxx> #include <com/sun/star/i18n/XCharacterClassification.hpp> +#include <i18npool/mslangid.hxx> using namespace ::com::sun::star; @@ -148,22 +149,8 @@ sal_Bool MnemonicGenerator::CreateMnemonic( XubString& rKey ) sal_Bool bChanged = sal_False; xub_StrLen nLen = aKey.Len(); - sal_Bool bCJK = sal_False; - switch( Application::GetSettings().GetUILanguage() ) - { - case LANGUAGE_JAPANESE: - case LANGUAGE_CHINESE_TRADITIONAL: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_HONGKONG: - case LANGUAGE_CHINESE_SINGAPORE: - case LANGUAGE_CHINESE_MACAU: - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - bCJK = sal_True; - break; - default: - break; - } + bool bCJK = MsLangId::isCJK(Application::GetSettings().GetUILanguage()); + // #107889# in CJK versions ALL strings (even those that contain latin characters) // will get mnemonics in the form: xyz (M) // thus steps 1) and 2) are skipped for CJK locales diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx index b0d10a16be54..8cb1a5213e12 100644 --- a/vcl/source/window/window.cxx +++ b/vcl/source/window/window.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include <i18npool/mslangid.hxx> #include "tools/time.hxx" #include "tools/debug.hxx" @@ -405,21 +406,9 @@ void Window::ImplUpdateGlobalSettings( AllSettings& rSettings, sal_Bool bCallHdl // if the UI is korean, chinese or another locale // where the system font size is kown to be often too small to // generate readable fonts enforce a minimum font size of 9 points - bool bBrokenLangFontHeight = false; - static const LanguageType eBrokenSystemFontSizeLanguages[] = - { LANGUAGE_KOREAN, LANGUAGE_KOREAN_JOHAB, - LANGUAGE_CHINESE_HONGKONG, LANGUAGE_CHINESE_MACAU, LANGUAGE_CHINESE_SIMPLIFIED, LANGUAGE_CHINESE_SINGAPORE, LANGUAGE_CHINESE_TRADITIONAL - }; - static std::set< LanguageType > aBrokenSystemFontSizeLanguagesSet( - eBrokenSystemFontSizeLanguages, - eBrokenSystemFontSizeLanguages + SAL_N_ELEMENTS(eBrokenSystemFontSizeLanguages) - ); - LanguageType aLang = Application::GetSettings().GetUILanguage(); - if( aBrokenSystemFontSizeLanguagesSet.find( aLang ) != aBrokenSystemFontSizeLanguagesSet.end() ) - { + bool bBrokenLangFontHeight = MsLangId::isCJK(Application::GetSettings().GetUILanguage()); + if (bBrokenLangFontHeight) defFontheight = Max(9, defFontheight); - bBrokenLangFontHeight = true; - } // i22098, toolfont will be scaled differently to avoid bloated rulers and status bars for big fonts int toolfontheight = defFontheight; diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index dfb3d3d89a3c..59ee078a1e93 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -428,23 +428,7 @@ LanguageType MapCharToLanguage( sal_UCS4 uChar ) if( !nDefaultLang ) nDefaultLang = Application::GetSettings().GetUILanguage(); - LanguageType nDefaultCJK = LANGUAGE_CHINESE; - switch( nDefaultLang ) - { - case LANGUAGE_JAPANESE: - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_TRADITIONAL: - case LANGUAGE_CHINESE_SINGAPORE: - case LANGUAGE_CHINESE_HONGKONG: - case LANGUAGE_CHINESE_MACAU: - nDefaultCJK = nDefaultLang; - break; - default: - nDefaultCJK = LANGUAGE_CHINESE; - break; - } + LanguageType nDefaultCJK = MsLangId::isCJK(nDefaultLang) ? nDefaultLang : LANGUAGE_CHINESE; // change the marked entries to prefered language static const int nCount = SAL_N_ELEMENTS(aLangFromCodeChart); |