merge the formfield patch from ooo-build
[ooovba.git] / vcl / unx / source / gdi / salcvt.hxx
blobee86dcf704a8a0135f80029866a4bfbca8834140
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salcvt.hxx,v $
10 * $Revision: 1.5 $
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 ************************************************************************/
30 #ifndef SAL_CONVERTER_CACHE_HXX_
31 #define SAL_CONVERTER_CACHE_HXX_
33 #include <salunx.h>
34 #include <rtl/tencinfo.h>
35 #include <rtl/textcvt.h>
37 #include <map>
39 extern "C" const char*
40 pGetEncodingName( rtl_TextEncoding nEncoding );
43 // Cache TextToUnicode and UnicodeToText converter and conversion info which is
44 // used in DrawXYZ routines and in the Event loop
45 //
47 class SalConverterCache {
49 public:
50 SalConverterCache();
51 ~SalConverterCache();
52 Bool EncodingHasChar(
53 rtl_TextEncoding nEncoding, sal_Unicode nChar );
54 rtl_UnicodeToTextConverter
55 GetU2TConverter( rtl_TextEncoding nEncoding );
56 rtl_TextToUnicodeConverter
57 GetT2UConverter( rtl_TextEncoding nEncoding );
58 Bool IsSingleByteEncoding( rtl_TextEncoding nEncoding );
59 sal_Size ConvertStringUTF16( const sal_Unicode *pText, int nTextLen,
60 sal_Char *pBuffer, sal_Size nBufferSize,
61 rtl_TextEncoding nEncoding);
63 static SalConverterCache*
64 GetInstance ();
66 private:
68 struct ConverterT {
69 rtl_UnicodeToTextConverter mpU2T;
70 rtl_TextToUnicodeConverter mpT2U;
71 Bool mbSingleByteEncoding;
72 Bool mbValid;
73 ConverterT() :
74 mpU2T( NULL ),
75 mpT2U( NULL ),
76 mbSingleByteEncoding( False ),
77 mbValid( False )
80 ~ConverterT()
82 if( mpU2T )
83 rtl_destroyUnicodeToTextConverter( mpU2T );
84 if( mpT2U )
85 rtl_destroyTextToUnicodeConverter( mpT2U );
89 std::map< rtl_TextEncoding, ConverterT > m_aConverters;
94 #endif /* SAL_CONVERTER_CACHE_HXX_ */