diff options
author | RĂ¼diger Timm <rt@openoffice.org> | 2003-04-08 15:12:49 +0000 |
---|---|---|
committer | RĂ¼diger Timm <rt@openoffice.org> | 2003-04-08 15:12:49 +0000 |
commit | 4e5fac244122a1545262eb50908cb7b18624387f (patch) | |
tree | 817d1997a05f340ef60c74033f56f8d8197004a4 /svx/source/dialog/txencbox.cxx | |
parent | INTEGRATION: CWS calc06 (1.4.148); FILE MERGED (diff) | |
download | core-4e5fac244122a1545262eb50908cb7b18624387f.tar.gz core-4e5fac244122a1545262eb50908cb7b18624387f.zip |
INTEGRATION: CWS calc06 (1.5.146); FILE MERGED
2003/03/18 15:46:10 er 1.5.146.1: #i11797# GetBestMimeEncoding() even if locale unknown, take UI locale, or UTF8 fallback
Diffstat (limited to 'svx/source/dialog/txencbox.cxx')
-rw-r--r-- | svx/source/dialog/txencbox.cxx | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/svx/source/dialog/txencbox.cxx b/svx/source/dialog/txencbox.cxx index b9d452fd2620..62257795864a 100644 --- a/svx/source/dialog/txencbox.cxx +++ b/svx/source/dialog/txencbox.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txencbox.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: er $ $Date: 2002-07-29 15:09:37 $ + * last change: $Author: rt $ $Date: 2003-04-08 16:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,9 +70,18 @@ #ifndef SVX_DBCHARSETHELPER_HXX #include "dbcharsethelper.hxx" #endif +#ifndef _SV_SVAPP_HXX +#include <vcl/svapp.hxx> +#endif #ifndef _RTL_TENCINFO_H #include <rtl/tencinfo.h> #endif +#ifndef _RTL_LOCALE_H_ +#include <rtl/locale.h> +#endif +#ifndef _OSL_NLSUPPORT_H_ +#include <osl/nlsupport.h> +#endif //======================================================================== // class SvxTextEncodingBox @@ -212,11 +221,36 @@ void SvxTextEncodingBox::FillFromDbTextEncodingMap( //------------------------------------------------------------------------ +// static +rtl_TextEncoding SvxTextEncodingBox::GetBestMimeEncoding() +{ + const sal_Char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( + gsl_getSystemTextEncoding() ); + if ( !pCharSet ) + { + // If the system locale is unknown to us, e.g. LC_ALL=xx, match the UI + // language if possible. + ::com::sun::star::lang::Locale aLocale( + Application::GetSettings().GetUILocale() ); + rtl_Locale * pLocale = rtl_locale_register( aLocale.Language.getStr(), + aLocale.Country.getStr(), aLocale.Variant.getStr() ); + rtl_TextEncoding nEnc = osl_getTextEncodingFromLocale( pLocale ); + pCharSet = rtl_getBestMimeCharsetFromTextEncoding( nEnc ); + } + rtl_TextEncoding nRet; + if ( pCharSet ) + nRet = rtl_getTextEncodingFromMimeCharset( pCharSet ); + else + nRet = RTL_TEXTENCODING_UTF8; + return nRet; +} + +//------------------------------------------------------------------------ + void SvxTextEncodingBox::FillWithMimeAndSelectBest() { FillFromTextEncodingTable( sal_False, 0xffffffff, RTL_TEXTENCODING_INFO_MIME ); - const sal_Char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding( gsl_getSystemTextEncoding() ); - rtl_TextEncoding nEnc = rtl_getTextEncodingFromMimeCharset( pCharSet ); + rtl_TextEncoding nEnc = GetBestMimeEncoding(); SelectTextEncoding( nEnc ); } |