summaryrefslogtreecommitdiff
path: root/dtrans/source/win32/misc/ImplHelper.cxx
diff options
context:
space:
mode:
authorTino Rachui <tra@openoffice.org>2001-03-09 07:48:25 +0000
committerTino Rachui <tra@openoffice.org>2001-03-09 07:48:25 +0000
commitc10bbac5c52003114f57307a094db1503162d563 (patch)
tree2738f3fd48f22cbaacbda2887d1b705e207c1d19 /dtrans/source/win32/misc/ImplHelper.cxx
parentd31f1064a5c100c650202fd994bcb70d0ecde67e (diff)
*** empty log message ***
Diffstat (limited to 'dtrans/source/win32/misc/ImplHelper.cxx')
-rw-r--r--dtrans/source/win32/misc/ImplHelper.cxx97
1 files changed, 61 insertions, 36 deletions
diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx
index 9f8bc8f10a69..ee8a427eb651 100644
--- a/dtrans/source/win32/misc/ImplHelper.cxx
+++ b/dtrans/source/win32/misc/ImplHelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ImplHelper.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-02 12:44:41 $
+ * last change: $Author: tra $ $Date: 2001-03-09 08:48:25 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -101,47 +101,75 @@ using ::rtl::OUString;
using ::rtl::OString;
//------------------------------------------------------------------------
-// converts a codepage into its string representation
+// returns a windows codepage appropriate to the
+// given mime charset parameter value
//------------------------------------------------------------------------
-OUString SAL_CALL CodePageToString( sal_Int32 codepage )
+sal_uInt32 SAL_CALL getWinCPFromMimeCharset( const OUString& charset )
{
- OSL_ASSERT( IsValidCodePage( codepage ) );
+ OString osCharset( charset.getStr( ), charset.getLength( ), CP_ACP );
- sal_Unicode cpStr[6];
- _itow( codepage, cpStr, 10 );
- return OUString( cpStr, wcslen( cpStr ) );
+ rtl_TextEncoding textEnc =
+ rtl_getTextEncodingFromMimeCharset( osCharset.getStr( ) );
+
+ return rtl_getBestPCCodePageFromTextEncoding( textEnc );
}
-//------------------------------------------------------------------------
-// convert a mime charset into a windows codepage
-//------------------------------------------------------------------------
+//--------------------------------------------------
+// returns a windows codepage appropriate to the
+// given locale and locale type
+//--------------------------------------------------
-sal_Int32 SAL_CALL getWinCodePageFromMimeCharset( const OUString& charset )
+OUString SAL_CALL getWinCPFromLocaleId( LCID lcid, LCTYPE lctype )
{
- OString osCharset( charset.getStr( ), charset.getLength( ), CP_ACP );
+ OSL_ASSERT( IsValidLocale( lcid, LCID_SUPPORTED ) );
- rtl_TextEncoding textEnc = rtl_getTextEncodingFromMimeCharset( osCharset.getStr( ) );
- return rtl_getBestPCCodePageFromTextEncoding( textEnc );
+ // we use the GetLocaleInfoA because don't want to provide
+ // a unicode wrapper function for Win9x in sal/systools
+ char buff[6];
+ GetLocaleInfoA( lcid, lctype, buff, sizeof( buff ) );
+ rtl_TextEncoding tenc = rtl_getTextEncodingFromPCCodePage( CP_ACP );
+
+ return OUString( buff, rtl_str_getLength( buff ), tenc );
+}
+
+//--------------------------------------------------
+// returns a mime charset parameter value appropriate
+// to the given codepage, optional a prefix can be
+// given, e.g. "windows-" or "cp"
+//--------------------------------------------------
+
+OUString SAL_CALL getMimeCharsetFromWinCP( sal_uInt32 cp, const OUString& aPrefix )
+{
+ return aPrefix + cptostr( cp );
+}
+
+//--------------------------------------------------
+// returns a mime charset parameter value appropriate
+// to the given locale id and locale type, optional a
+// prefix can be given, e.g. "windows-" or "cp"
+//--------------------------------------------------
+
+OUString SAL_CALL getMimeCharsetFromLocaleId( LCID lcid, LCTYPE lctype, const OUString& aPrefix )
+{
+ OUString charset = getWinCPFromLocaleId( lcid, lctype );
+ return aPrefix + charset;
}
//------------------------------------------------------------------------
// IsOEMCP
//------------------------------------------------------------------------
-sal_Bool SAL_CALL IsOEMCP( UINT codepage )
+sal_Bool SAL_CALL IsOEMCP( sal_uInt32 codepage )
{
- UINT arrOEMCP[] = { 437, 708, 709,
- 710, 720, 737,
- 775, 850, 852,
- 855, 857, 860,
- 861, 862, 863,
- 864, 865, 866,
- 869, 874, 932,
- 936, 949, 950,
- 1361 };
-
- for ( sal_Int8 i = 0; i < ( sizeof( arrOEMCP )/sizeof( UINT ) ); ++i )
+ OSL_ASSERT( IsValidCodePage( codepage ) );
+
+ sal_uInt32 arrOEMCP[] = { 437, 708, 709, 710, 720, 737,
+ 775, 850, 852, 855, 857, 860,
+ 861, 862, 863, 864, 865, 866,
+ 869, 874, 932, 936, 949, 950, 1361 };
+
+ for ( sal_Int8 i = 0; i < ( sizeof( arrOEMCP )/sizeof( sal_uInt32 ) ); ++i )
if ( arrOEMCP[i] == codepage )
return sal_True;
@@ -149,21 +177,18 @@ sal_Bool SAL_CALL IsOEMCP( UINT codepage )
}
//------------------------------------------------------------------------
-// a '==' operator for DataFlavors
-// we compare only MimeType and DataType
+// converts a codepage into its string representation
//------------------------------------------------------------------------
-sal_Bool SAL_CALL operator==( const DataFlavor& lhs, const DataFlavor& rhs )
+OUString SAL_CALL cptostr( sal_uInt32 codepage )
{
-#pragma message( "******************************************" )
-#pragma message( "**************** fix this ****************" )
-#pragma message( "******************************************" )
+ OSL_ASSERT( IsValidCodePage( codepage ) );
- return ( ( lhs.MimeType == rhs.MimeType ) &&
- ( lhs.DataType == rhs.DataType ) );
+ sal_Unicode cpStr[6];
+ _itow( codepage, cpStr, 10 );
+ return OUString( cpStr, wcslen( cpStr ) );
}
-
//-------------------------------------------------------------------------
// OleStdDeleteTargetDevice()
//