1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SVX_TXENCBOX_HXX
20 #define INCLUDED_SVX_TXENCBOX_HXX
22 #include <vcl/lstbox.hxx>
23 #include <vcl/weld.hxx>
24 #include <rtl/textenc.h>
25 #include <svx/svxdllapi.h>
27 class SVX_DLLPUBLIC SvxTextEncodingBox
: public ListBox
30 SVX_DLLPRIVATE sal_Int32
EncodingToPos_Impl( rtl_TextEncoding nEnc
) const;
33 SvxTextEncodingBox( vcl::Window
* pParent
, WinBits nBits
);
34 virtual ~SvxTextEncodingBox() override
;
36 /** Fill with all known encodings but exclude those matching one or more
37 given flags as defined in rtl/tencinfo.h
39 <p> If nButIncludeInfoFlags is given, encodings are included even if they
40 match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
41 Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
42 with RTL_TEXTENCODING_INFO_MIME </p>
44 @param bExcludeImportSubsets
45 If <TRUE/>, some specific encodings are not listed, as they are a
46 subset of another encoding. This is the case for
47 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
48 RTL_TEXTENCODING_MS_936, which are covered by
49 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
50 <TRUE/> whenever the box is used in import dialogs. */
51 void FillFromTextEncodingTable(
52 bool bExcludeImportSubsets
,
53 sal_uInt32 nExcludeInfoFlags
= 0,
54 sal_uInt32 nButIncludeInfoFlags
= 0
57 /** Fill with all known MIME encodings and select the best according to
58 <method>GetBestMimeEncoding</method>
60 void FillWithMimeAndSelectBest();
62 void InsertTextEncoding( const rtl_TextEncoding nEnc
,
63 const OUString
& rEntry
);
65 void SelectTextEncoding( const rtl_TextEncoding nEnc
);
67 rtl_TextEncoding
GetSelectTextEncoding() const;
70 class SVX_DLLPUBLIC TextEncodingBox
73 std::unique_ptr
<weld::ComboBox
> m_xControl
;
76 TextEncodingBox(std::unique_ptr
<weld::ComboBox
> pControl
);
80 /** Fill with all known encodings but exclude those matching one or more
81 given flags as defined in rtl/tencinfo.h
83 <p> If nButIncludeInfoFlags is given, encodings are included even if they
84 match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
85 Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
86 with RTL_TEXTENCODING_INFO_MIME </p>
88 @param bExcludeImportSubsets
89 If <TRUE/>, some specific encodings are not listed, as they are a
90 subset of another encoding. This is the case for
91 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
92 RTL_TEXTENCODING_MS_936, which are covered by
93 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
94 <TRUE/> whenever the box is used in import dialogs. */
95 void FillFromTextEncodingTable(
96 bool bExcludeImportSubsets
,
97 sal_uInt32 nExcludeInfoFlags
= 0);
99 /** Fill with all encodings known to the dbtools::OCharsetMap but exclude
100 those matching one or more given flags as defined in rtl/tencinfo.h
102 <p> If nButIncludeInfoFlags is given, encodings are included even if they
103 match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
104 Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
105 with RTL_TEXTENCODING_INFO_MIME </p>
107 @param bExcludeImportSubsets
108 If <TRUE/>, some specific encodings are not listed, as they are a
109 subset of another encoding. This is the case for
110 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
111 RTL_TEXTENCODING_MS_936, which are covered by
112 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
113 <TRUE/> whenever the box is used in import dialogs. */
114 void FillFromDbTextEncodingMap(
115 bool bExcludeImportSubsets
,
116 sal_uInt32 nExcludeInfoFlags
= 0);
118 void InsertTextEncoding( const rtl_TextEncoding nEnc
);
120 void InsertTextEncoding( const rtl_TextEncoding nEnc
,
121 const OUString
& rEntry
);
123 void SelectTextEncoding( const rtl_TextEncoding nEnc
);
125 rtl_TextEncoding
GetSelectTextEncoding() const;
127 void connect_changed(const Link
<weld::ComboBox
&, void>& rLink
) { m_xControl
->connect_changed(rLink
); }
128 void grab_focus() { m_xControl
->grab_focus(); }
129 void show() { m_xControl
->show(); }
130 void hide() { m_xControl
->hide(); }
133 class SVX_DLLPUBLIC TextEncodingTreeView
136 std::unique_ptr
<weld::TreeView
> m_xControl
;
139 TextEncodingTreeView(std::unique_ptr
<weld::TreeView
> pControl
);
141 ~TextEncodingTreeView();
143 /** Fill with all known encodings but exclude those matching one or more
144 given flags as defined in rtl/tencinfo.h
146 <p> If nButIncludeInfoFlags is given, encodings are included even if they
147 match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
148 Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
149 with RTL_TEXTENCODING_INFO_MIME </p>
151 @param bExcludeImportSubsets
152 If <TRUE/>, some specific encodings are not listed, as they are a
153 subset of another encoding. This is the case for
154 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
155 RTL_TEXTENCODING_MS_936, which are covered by
156 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
157 <TRUE/> whenever the box is used in import dialogs. */
158 void FillFromTextEncodingTable(
159 bool bExcludeImportSubsets
,
160 sal_uInt32 nExcludeInfoFlags
= 0);
162 /** Fill with all encodings known to the dbtools::OCharsetMap but exclude
163 those matching one or more given flags as defined in rtl/tencinfo.h
165 <p> If nButIncludeInfoFlags is given, encodings are included even if they
166 match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit
167 Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8
168 with RTL_TEXTENCODING_INFO_MIME </p>
170 @param bExcludeImportSubsets
171 If <TRUE/>, some specific encodings are not listed, as they are a
172 subset of another encoding. This is the case for
173 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK,
174 RTL_TEXTENCODING_MS_936, which are covered by
175 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to
176 <TRUE/> whenever the box is used in import dialogs. */
177 void FillFromDbTextEncodingMap(
178 bool bExcludeImportSubsets
,
179 sal_uInt32 nExcludeInfoFlags
= 0);
181 void InsertTextEncoding( const rtl_TextEncoding nEnc
);
183 void InsertTextEncoding( const rtl_TextEncoding nEnc
,
184 const OUString
& rEntry
);
186 void SelectTextEncoding( const rtl_TextEncoding nEnc
);
188 rtl_TextEncoding
GetSelectTextEncoding() const;
190 void connect_changed(const Link
<weld::TreeView
&, void>& rLink
) { m_xControl
->connect_changed(rLink
); }
191 void connect_row_activated(const Link
<weld::TreeView
&, void>& rLink
) { m_xControl
->connect_row_activated(rLink
); }
192 void grab_focus() { m_xControl
->grab_focus(); }
193 void show() { m_xControl
->show(); }
194 void hide() { m_xControl
->hide(); }
195 int get_height_rows(int nRows
) const
197 return m_xControl
->get_height_rows(nRows
);
199 void set_size_request(int nWidth
, int nHeight
)
201 m_xControl
->set_size_request(nWidth
, nHeight
);
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */