diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-06-19 13:48:45 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-06-19 14:11:50 +0100 |
commit | d9e4c74811855de15f1bf2045c2c9b061a2d4dc6 (patch) | |
tree | 895cbcd595094e9fd2621a943fc83bb004b429c9 /vcl | |
parent | 2a598619d7fbc992f1903a745fd536ddf5e45c81 (diff) |
merge together hand-crafted traditional/simplified chinese tests
merge together a gadzillion hand-crafted
isSimpleChinese/isTraditionalChinese/isKoreanVariants/isCJK
implementations which should fix a goodly amount of them
add a MsLangId::isFamilyNameFirst for locales where
family name appears first while I'm at it.
Change-Id: I65377793be037d16fe7250cd7450b28aec689e83
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/generic/glyphs/gcach_ftyp.cxx | 23 | ||||
-rw-r--r-- | vcl/generic/print/genpspgraphics.cxx | 46 | ||||
-rw-r--r-- | vcl/inc/langboost.hxx | 18 | ||||
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 41 | ||||
-rw-r--r-- | vcl/source/window/mnemonic.cxx | 19 | ||||
-rw-r--r-- | vcl/source/window/window.cxx | 17 | ||||
-rw-r--r-- | vcl/win/source/gdi/salgdi3.cxx | 18 |
7 files changed, 65 insertions, 117 deletions
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); |