summaryrefslogtreecommitdiff
path: root/svx/source/dialog/txencbox.cxx
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2003-04-08 15:12:49 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2003-04-08 15:12:49 +0000
commit88f6f60ed4b5355b1e534563c2007176875a7a5c (patch)
tree08e9f31aca2a88c4a4ba03fe71224170e99a3029 /svx/source/dialog/txencbox.cxx
parent8ec1484860cb7d61165605a7240bb0b9a6938cc9 (diff)
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.cxx42
1 files changed, 38 insertions, 4 deletions
diff --git a/svx/source/dialog/txencbox.cxx b/svx/source/dialog/txencbox.cxx
index 3e4ec3c798..205ec9b088 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 );
}