1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 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/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 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 . 18 */ 19 #ifndef INCLUDED_SVX_TXENCBOX_HXX 20 #define INCLUDED_SVX_TXENCBOX_HXX 21 22 #include <vcl/weld.hxx> 23 #include <rtl/textenc.h> 24 #include <svx/svxdllapi.h> 25 26 class SVX_DLLPUBLIC SvxTextEncodingBox 27 { 28 private: 29 std::unique_ptr<weld::ComboBox> m_xControl; 30 31 public: 32 SvxTextEncodingBox(std::unique_ptr<weld::ComboBox> pControl); 33 34 ~SvxTextEncodingBox(); 35 36 /** Fill with all known encodings but exclude those matching one or more 37 given flags as defined in rtl/tencinfo.h 38 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> 43 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 55 ); 56 57 /** Fill with all encodings known to the dbtools::OCharsetMap but exclude 58 those matching one or more given flags as defined in rtl/tencinfo.h 59 60 <p> If nButIncludeInfoFlags is given, encodings are included even if they 61 match nExcludeInfoFlags. Thus it is possible to exclude 16/32-bit 62 Unicode with RTL_TEXTENCODING_INFO_UNICODE but to include UTF7 and UTF8 63 with RTL_TEXTENCODING_INFO_MIME </p> 64 65 @param bExcludeImportSubsets 66 If <TRUE/>, some specific encodings are not listed, as they are a 67 subset of another encoding. This is the case for 68 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK, 69 RTL_TEXTENCODING_MS_936, which are covered by 70 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to 71 <TRUE/> whenever the box is used in import dialogs. */ 72 void FillFromDbTextEncodingMap( 73 bool bExcludeImportSubsets, 74 sal_uInt32 nExcludeInfoFlags = 0); 75 76 /** Fill with all known MIME encodings and select the best according to 77 <method>GetBestMimeEncoding</method> 78 */ 79 void FillWithMimeAndSelectBest(); 80 81 void InsertTextEncoding( const rtl_TextEncoding nEnc ); 82 83 void InsertTextEncoding( const rtl_TextEncoding nEnc, 84 const OUString& rEntry ); 85 86 void SelectTextEncoding( const rtl_TextEncoding nEnc ); 87 88 rtl_TextEncoding GetSelectTextEncoding() const; 89 connect_changed(const Link<weld::ComboBox &,void> & rLink)90 void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_xControl->connect_changed(rLink); } set_sensitive(bool bSensitive)91 void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); } grab_focus()92 void grab_focus() { m_xControl->grab_focus(); } get_active() const93 int get_active() const { return m_xControl->get_active(); } set_active(int nActive)94 void set_active(int nActive) { m_xControl->set_active(nActive); } show()95 void show() { m_xControl->show(); } hide()96 void hide() { m_xControl->hide(); } 97 }; 98 99 class SVX_DLLPUBLIC SvxTextEncodingTreeView 100 { 101 private: 102 std::unique_ptr<weld::TreeView> m_xControl; 103 104 public: 105 SvxTextEncodingTreeView(std::unique_ptr<weld::TreeView> pControl); 106 107 ~SvxTextEncodingTreeView(); 108 109 /** Fill with all known encodings but exclude those matching one or more 110 given flags as defined in rtl/tencinfo.h 111 112 @param bExcludeImportSubsets 113 If <TRUE/>, some specific encodings are not listed, as they are a 114 subset of another encoding. This is the case for 115 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK, 116 RTL_TEXTENCODING_MS_936, which are covered by 117 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to 118 <TRUE/> whenever the box is used in import dialogs. */ 119 void FillFromTextEncodingTable( 120 bool bExcludeImportSubsets, 121 sal_uInt32 nExcludeInfoFlags = 0); 122 123 /** Fill with all encodings known to the dbtools::OCharsetMap but exclude 124 those matching one or more given flags as defined in rtl/tencinfo.h 125 126 @param bExcludeImportSubsets 127 If <TRUE/>, some specific encodings are not listed, as they are a 128 subset of another encoding. This is the case for 129 RTL_TEXTENCODING_GB_2312, RTL_TEXTENCODING_GBK, 130 RTL_TEXTENCODING_MS_936, which are covered by 131 RTL_TEXTENCODING_GB_18030. Normally, this flag should be set to 132 <TRUE/> whenever the box is used in import dialogs. */ 133 void FillFromDbTextEncodingMap( 134 bool bExcludeImportSubsets, 135 sal_uInt32 nExcludeInfoFlags = 0); 136 137 void InsertTextEncoding( const rtl_TextEncoding nEnc ); 138 139 void InsertTextEncoding( const rtl_TextEncoding nEnc, 140 const OUString& rEntry ); 141 142 void SelectTextEncoding( const rtl_TextEncoding nEnc ); 143 144 rtl_TextEncoding GetSelectTextEncoding() const; 145 connect_changed(const Link<weld::TreeView &,void> & rLink)146 void connect_changed(const Link<weld::TreeView&, void>& rLink) { m_xControl->connect_changed(rLink); } connect_row_activated(const Link<weld::TreeView &,bool> & rLink)147 void connect_row_activated(const Link<weld::TreeView&, bool>& rLink) { m_xControl->connect_row_activated(rLink); } grab_focus()148 void grab_focus() { m_xControl->grab_focus(); } show()149 void show() { m_xControl->show(); } hide()150 void hide() { m_xControl->hide(); } get_height_rows(int nRows) const151 int get_height_rows(int nRows) const 152 { 153 return m_xControl->get_height_rows(nRows); 154 } set_size_request(int nWidth,int nHeight)155 void set_size_request(int nWidth, int nHeight) 156 { 157 m_xControl->set_size_request(nWidth, nHeight); 158 } 159 }; 160 161 #endif 162 163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 164