1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tenccvt.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_tools.hxx"
33 #include <rtl/tencinfo.h>
34 #include <tools/tenccvt.hxx>
36 // =======================================================================
38 rtl_TextEncoding
GetExtendedCompatibilityTextEncoding( rtl_TextEncoding eEncoding
)
41 if ( eEncoding
== RTL_TEXTENCODING_ISO_8859_1
)
42 return RTL_TEXTENCODING_MS_1252
;
44 else if ( eEncoding
== RTL_TEXTENCODING_ISO_8859_9
)
45 return RTL_TEXTENCODING_MS_1254
;
50 // -----------------------------------------------------------------------
52 rtl_TextEncoding
GetExtendedTextEncoding( rtl_TextEncoding eEncoding
)
55 if ( eEncoding
== RTL_TEXTENCODING_ISO_8859_5
)
56 return RTL_TEXTENCODING_MS_1251
;
57 // Greek (2 Characters different: A1 (0x2018/0x0385), A2 (0x2019/0x0386) -
58 // so it is handled in this function and not in GetExtendedCompatibilityTextEncoding)
59 else if ( eEncoding
== RTL_TEXTENCODING_ISO_8859_7
)
60 return RTL_TEXTENCODING_MS_1253
;
61 // East-Europe - Latin2
62 else if ( eEncoding
== RTL_TEXTENCODING_ISO_8859_2
)
63 return RTL_TEXTENCODING_MS_1250
;
64 // Latin-15 - Latin 1 mit Euro-Sign
65 else if ( eEncoding
== RTL_TEXTENCODING_ISO_8859_15
)
66 return RTL_TEXTENCODING_MS_1252
;
68 return GetExtendedCompatibilityTextEncoding( eEncoding
);
71 // -----------------------------------------------------------------------
73 rtl_TextEncoding
GetOneByteTextEncoding( rtl_TextEncoding eEncoding
)
75 rtl_TextEncodingInfo aTextEncInfo
;
76 aTextEncInfo
.StructSize
= sizeof( aTextEncInfo
);
77 if ( rtl_getTextEncodingInfo( eEncoding
, &aTextEncInfo
) )
79 if ( aTextEncInfo
.MaximumCharSize
> 1 )
80 return RTL_TEXTENCODING_MS_1252
;
85 return RTL_TEXTENCODING_MS_1252
;
88 // -----------------------------------------------------------------------
90 rtl_TextEncoding
GetSOLoadTextEncoding( rtl_TextEncoding eEncoding
, USHORT
/* nVersion = SOFFICE_FILEFORMAT_50 */ )
92 return GetExtendedCompatibilityTextEncoding( GetOneByteTextEncoding( eEncoding
) );
95 // -----------------------------------------------------------------------
97 rtl_TextEncoding
GetSOStoreTextEncoding( rtl_TextEncoding eEncoding
, USHORT
/* nVersion = SOFFICE_FILEFORMAT_50 */ )
99 return GetExtendedTextEncoding( GetOneByteTextEncoding( eEncoding
) );