1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _DBAUI_CHARSETS_HXX_ 29 #define _DBAUI_CHARSETS_HXX_ 30 31 #ifndef _STRING_HXX 32 #include <tools/string.hxx> 33 #endif 34 #ifndef _TOOLS_RC_HXX 35 #include <tools/rc.hxx> 36 #endif 37 #ifndef _DBHELPER_DBCHARSET_HXX_ 38 #include <connectivity/dbcharset.hxx> 39 #endif 40 #ifndef _SVX_TXENCTAB_HXX 41 #include <svx/txenctab.hxx> 42 #endif 43 44 //......................................................................... 45 namespace dbaui 46 { 47 //......................................................................... 48 49 //========================================================================= 50 //= OCharsetDisplay 51 //========================================================================= 52 typedef ::dbtools::OCharsetMap OCharsetDisplay_Base; 53 class OCharsetDisplay 54 :protected OCharsetDisplay_Base 55 ,protected SvxTextEncodingTable 56 { 57 protected: 58 ::rtl::OUString m_aSystemDisplayName; 59 60 public: 61 class ExtendedCharsetIterator; 62 friend class OCharsetDisplay::ExtendedCharsetIterator; 63 64 typedef ExtendedCharsetIterator iterator; 65 typedef ExtendedCharsetIterator const_iterator; 66 67 OCharsetDisplay(); 68 69 // various find operations 70 const_iterator findEncoding(const rtl_TextEncoding _eEncoding) const; 71 const_iterator findIanaName(const ::rtl::OUString& _rIanaName) const; 72 const_iterator findDisplayName(const ::rtl::OUString& _rDisplayName) const; 73 74 /// get access to the first element of the charset collection 75 const_iterator begin() const; 76 /// get access to the (last + 1st) element of the charset collection 77 const_iterator end() const; 78 // size of the map 79 sal_Int32 size() const { return OCharsetDisplay_Base::size(); } 80 81 protected: 82 virtual sal_Bool approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const; 83 84 private: 85 using OCharsetDisplay_Base::find; 86 }; 87 88 //------------------------------------------------------------------------- 89 //- CharsetDisplayDerefHelper 90 //------------------------------------------------------------------------- 91 typedef ::dbtools::CharsetIteratorDerefHelper CharsetDisplayDerefHelper_Base; 92 class CharsetDisplayDerefHelper : protected CharsetDisplayDerefHelper_Base 93 { 94 friend class OCharsetDisplay::ExtendedCharsetIterator; 95 96 ::rtl::OUString m_sDisplayName; 97 98 public: 99 CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource); 100 101 rtl_TextEncoding getEncoding() const { return CharsetDisplayDerefHelper_Base::getEncoding(); } 102 ::rtl::OUString getIanaName() const { return CharsetDisplayDerefHelper_Base::getIanaName(); } 103 ::rtl::OUString getDisplayName() const { return m_sDisplayName; } 104 105 protected: 106 CharsetDisplayDerefHelper(const ::dbtools::CharsetIteratorDerefHelper& _rBase, const ::rtl::OUString& _rDisplayName); 107 }; 108 109 //------------------------------------------------------------------------- 110 //- OCharsetDisplay::ExtendedCharsetIterator 111 //------------------------------------------------------------------------- 112 class OCharsetDisplay::ExtendedCharsetIterator 113 { 114 friend class OCharsetDisplay; 115 116 friend bool operator==(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs); 117 friend bool operator!=(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs) { return !(lhs == rhs); } 118 119 typedef ::dbtools::OCharsetMap container; 120 typedef container::CharsetIterator base_iterator; 121 122 protected: 123 const OCharsetDisplay* m_pContainer; 124 base_iterator m_aPosition; 125 126 public: 127 ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource); 128 129 CharsetDisplayDerefHelper operator*() const; 130 131 /// prefix increment 132 const ExtendedCharsetIterator& operator++(); 133 /// postfix increment 134 const ExtendedCharsetIterator operator++(int) { ExtendedCharsetIterator hold(*this); ++*this; return hold; } 135 136 /// prefix decrement 137 const ExtendedCharsetIterator& operator--(); 138 /// postfix decrement 139 const ExtendedCharsetIterator operator--(int) { ExtendedCharsetIterator hold(*this); --*this; return hold; } 140 141 protected: 142 ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition ); 143 }; 144 145 //......................................................................... 146 } // namespace dbaui 147 //......................................................................... 148 149 #endif // _DBAUI_CHARSETS_HXX_ 150 151