xref: /aoo4110/main/svx/inc/svx/txencbox.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_TXENCBOX_HXX
24 #define _SVX_TXENCBOX_HXX
25 
26 // include ---------------------------------------------------------------
27 
28 #ifndef _LSTBOX_HXX //autogen
29 #include <vcl/lstbox.hxx>
30 #endif
31 #include <rtl/textenc.h>
32 #include "svx/svxdllapi.h"
33 
34 class SvxTextEncodingTable;
35 
36 class SVX_DLLPUBLIC SvxTextEncodingBox : public ListBox
37 {
38 private:
39 	const SvxTextEncodingTable*		m_pEncTable;
40 
41 	SVX_DLLPRIVATE sal_uInt16				EncodingToPos_Impl( rtl_TextEncoding nEnc ) const;
42 
43 public:
44 						SvxTextEncodingBox( Window* pParent, const ResId& rResId );
45 						~SvxTextEncodingBox();
46 
47 	/** Fill with all known encodings but exclude those matching one or more
48 		given flags as defined in rtl/tencinfo.h
49 
50 	 	<p> If nButIncludeInfoFlags is given, encodings are included even if they
51 	 	match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
52 	 	Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
53 	 	with RTL_TEXTENCODING_INFO_MIME </p>
54 
55         @param bExcludeImportSubsets
56             If <TRUE/>, some specific encodings are not listed, as they are a
57             subset of another encoding. This is the case for
58             RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
59             RTL_TEXTENCODING_MS_936, which are covered by
60             RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
61             <TRUE/> whenever the box is used in import dialogs. */
62 	void				FillFromTextEncodingTable(
63                             sal_Bool bExcludeImportSubsets = sal_False,
64 							sal_uInt32 nExcludeInfoFlags = 0,
65 							sal_uInt32 nButIncludeInfoFlags = 0
66 							);
67 
68     /** Fill with all encodings known to the dbtools::OCharsetMap but exclude
69         those matching one or more given flags as defined in rtl/tencinfo.h
70 
71 	 	<p> If nButIncludeInfoFlags is given, encodings are included even if they
72 	 	match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
73 	 	Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
74 	 	with RTL_TEXTENCODING_INFO_MIME </p>
75 
76         @param bExcludeImportSubsets
77             If <TRUE/>, some specific encodings are not listed, as they are a
78             subset of another encoding. This is the case for
79             RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
80             RTL_TEXTENCODING_MS_936, which are covered by
81             RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
82             <TRUE/> whenever the box is used in import dialogs. */
83     void                FillFromDbTextEncodingMap(
84                             sal_Bool bExcludeImportSubsets = sal_False,
85 							sal_uInt32 nExcludeInfoFlags = 0,
86 							sal_uInt32 nButIncludeInfoFlags = 0
87 							);
88 
89     /** Fill with all known MIME encodings and select the best according to
90         <method>GetBestMimeEncoding</method>
91 	 */
92 	void				FillWithMimeAndSelectBest();
93 
GetTextEncodingTable() const94 	const SvxTextEncodingTable*		GetTextEncodingTable() const
95 							{ return m_pEncTable; }
96 
97 	void				InsertTextEncoding( const rtl_TextEncoding nEnc,
98 							sal_uInt16 nPos = LISTBOX_APPEND );
99 
100 	void				InsertTextEncoding( const rtl_TextEncoding nEnc,
101 							const String& rEntry,
102 							sal_uInt16 nPos = LISTBOX_APPEND );
103 
104 	void				RemoveTextEncoding( const rtl_TextEncoding nEnc );
105 
106 	void				SelectTextEncoding( const rtl_TextEncoding nEnc,
107 							sal_Bool bSelect = sal_True );
108 
109 	rtl_TextEncoding	GetSelectTextEncoding() const;
110 
111 	const String&		GetSelectTextString() const;
112 
113 	sal_Bool				IsTextEncodingSelected( const rtl_TextEncoding nEnc ) const;
114 };
115 
116 #endif
117 
118