1*2e2212a7SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*2e2212a7SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*2e2212a7SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*2e2212a7SAndrew Rist * distributed with this work for additional information 6*2e2212a7SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*2e2212a7SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*2e2212a7SAndrew Rist * "License"); you may not use this file except in compliance 9*2e2212a7SAndrew Rist * with the License. You may obtain a copy of the License at 10*2e2212a7SAndrew Rist * 11*2e2212a7SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*2e2212a7SAndrew Rist * 13*2e2212a7SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*2e2212a7SAndrew Rist * software distributed under the License is distributed on an 15*2e2212a7SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*2e2212a7SAndrew Rist * KIND, either express or implied. See the License for the 17*2e2212a7SAndrew Rist * specific language governing permissions and limitations 18*2e2212a7SAndrew Rist * under the License. 19*2e2212a7SAndrew Rist * 20*2e2212a7SAndrew Rist *************************************************************/ 21*2e2212a7SAndrew Rist 22*2e2212a7SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _DBAUI_CHARSETS_HXX_ 25cdf0e10cSrcweir #define _DBAUI_CHARSETS_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #ifndef _STRING_HXX 28cdf0e10cSrcweir #include <tools/string.hxx> 29cdf0e10cSrcweir #endif 30cdf0e10cSrcweir #ifndef _TOOLS_RC_HXX 31cdf0e10cSrcweir #include <tools/rc.hxx> 32cdf0e10cSrcweir #endif 33cdf0e10cSrcweir #ifndef _DBHELPER_DBCHARSET_HXX_ 34cdf0e10cSrcweir #include <connectivity/dbcharset.hxx> 35cdf0e10cSrcweir #endif 36cdf0e10cSrcweir #ifndef _SVX_TXENCTAB_HXX 37cdf0e10cSrcweir #include <svx/txenctab.hxx> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir 40cdf0e10cSrcweir //......................................................................... 41cdf0e10cSrcweir namespace dbaui 42cdf0e10cSrcweir { 43cdf0e10cSrcweir //......................................................................... 44cdf0e10cSrcweir 45cdf0e10cSrcweir //========================================================================= 46cdf0e10cSrcweir //= OCharsetDisplay 47cdf0e10cSrcweir //========================================================================= 48cdf0e10cSrcweir typedef ::dbtools::OCharsetMap OCharsetDisplay_Base; 49cdf0e10cSrcweir class OCharsetDisplay 50cdf0e10cSrcweir :protected OCharsetDisplay_Base 51cdf0e10cSrcweir ,protected SvxTextEncodingTable 52cdf0e10cSrcweir { 53cdf0e10cSrcweir protected: 54cdf0e10cSrcweir ::rtl::OUString m_aSystemDisplayName; 55cdf0e10cSrcweir 56cdf0e10cSrcweir public: 57cdf0e10cSrcweir class ExtendedCharsetIterator; 58cdf0e10cSrcweir friend class OCharsetDisplay::ExtendedCharsetIterator; 59cdf0e10cSrcweir 60cdf0e10cSrcweir typedef ExtendedCharsetIterator iterator; 61cdf0e10cSrcweir typedef ExtendedCharsetIterator const_iterator; 62cdf0e10cSrcweir 63cdf0e10cSrcweir OCharsetDisplay(); 64cdf0e10cSrcweir 65cdf0e10cSrcweir // various find operations 66cdf0e10cSrcweir const_iterator findEncoding(const rtl_TextEncoding _eEncoding) const; 67cdf0e10cSrcweir const_iterator findIanaName(const ::rtl::OUString& _rIanaName) const; 68cdf0e10cSrcweir const_iterator findDisplayName(const ::rtl::OUString& _rDisplayName) const; 69cdf0e10cSrcweir 70cdf0e10cSrcweir /// get access to the first element of the charset collection 71cdf0e10cSrcweir const_iterator begin() const; 72cdf0e10cSrcweir /// get access to the (last + 1st) element of the charset collection 73cdf0e10cSrcweir const_iterator end() const; 74cdf0e10cSrcweir // size of the map size() const75cdf0e10cSrcweir sal_Int32 size() const { return OCharsetDisplay_Base::size(); } 76cdf0e10cSrcweir 77cdf0e10cSrcweir protected: 78cdf0e10cSrcweir virtual sal_Bool approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const; 79cdf0e10cSrcweir 80cdf0e10cSrcweir private: 81cdf0e10cSrcweir using OCharsetDisplay_Base::find; 82cdf0e10cSrcweir }; 83cdf0e10cSrcweir 84cdf0e10cSrcweir //------------------------------------------------------------------------- 85cdf0e10cSrcweir //- CharsetDisplayDerefHelper 86cdf0e10cSrcweir //------------------------------------------------------------------------- 87cdf0e10cSrcweir typedef ::dbtools::CharsetIteratorDerefHelper CharsetDisplayDerefHelper_Base; 88cdf0e10cSrcweir class CharsetDisplayDerefHelper : protected CharsetDisplayDerefHelper_Base 89cdf0e10cSrcweir { 90cdf0e10cSrcweir friend class OCharsetDisplay::ExtendedCharsetIterator; 91cdf0e10cSrcweir 92cdf0e10cSrcweir ::rtl::OUString m_sDisplayName; 93cdf0e10cSrcweir 94cdf0e10cSrcweir public: 95cdf0e10cSrcweir CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource); 96cdf0e10cSrcweir getEncoding() const97cdf0e10cSrcweir rtl_TextEncoding getEncoding() const { return CharsetDisplayDerefHelper_Base::getEncoding(); } getIanaName() const98cdf0e10cSrcweir ::rtl::OUString getIanaName() const { return CharsetDisplayDerefHelper_Base::getIanaName(); } getDisplayName() const99cdf0e10cSrcweir ::rtl::OUString getDisplayName() const { return m_sDisplayName; } 100cdf0e10cSrcweir 101cdf0e10cSrcweir protected: 102cdf0e10cSrcweir CharsetDisplayDerefHelper(const ::dbtools::CharsetIteratorDerefHelper& _rBase, const ::rtl::OUString& _rDisplayName); 103cdf0e10cSrcweir }; 104cdf0e10cSrcweir 105cdf0e10cSrcweir //------------------------------------------------------------------------- 106cdf0e10cSrcweir //- OCharsetDisplay::ExtendedCharsetIterator 107cdf0e10cSrcweir //------------------------------------------------------------------------- 108cdf0e10cSrcweir class OCharsetDisplay::ExtendedCharsetIterator 109cdf0e10cSrcweir { 110cdf0e10cSrcweir friend class OCharsetDisplay; 111cdf0e10cSrcweir 112cdf0e10cSrcweir friend bool operator==(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs); operator !=(const ExtendedCharsetIterator & lhs,const ExtendedCharsetIterator & rhs)113cdf0e10cSrcweir friend bool operator!=(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs) { return !(lhs == rhs); } 114cdf0e10cSrcweir 115cdf0e10cSrcweir typedef ::dbtools::OCharsetMap container; 116cdf0e10cSrcweir typedef container::CharsetIterator base_iterator; 117cdf0e10cSrcweir 118cdf0e10cSrcweir protected: 119cdf0e10cSrcweir const OCharsetDisplay* m_pContainer; 120cdf0e10cSrcweir base_iterator m_aPosition; 121cdf0e10cSrcweir 122cdf0e10cSrcweir public: 123cdf0e10cSrcweir ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource); 124cdf0e10cSrcweir 125cdf0e10cSrcweir CharsetDisplayDerefHelper operator*() const; 126cdf0e10cSrcweir 127cdf0e10cSrcweir /// prefix increment 128cdf0e10cSrcweir const ExtendedCharsetIterator& operator++(); 129cdf0e10cSrcweir /// postfix increment operator ++(int)130cdf0e10cSrcweir const ExtendedCharsetIterator operator++(int) { ExtendedCharsetIterator hold(*this); ++*this; return hold; } 131cdf0e10cSrcweir 132cdf0e10cSrcweir /// prefix decrement 133cdf0e10cSrcweir const ExtendedCharsetIterator& operator--(); 134cdf0e10cSrcweir /// postfix decrement operator --(int)135cdf0e10cSrcweir const ExtendedCharsetIterator operator--(int) { ExtendedCharsetIterator hold(*this); --*this; return hold; } 136cdf0e10cSrcweir 137cdf0e10cSrcweir protected: 138cdf0e10cSrcweir ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition ); 139cdf0e10cSrcweir }; 140cdf0e10cSrcweir 141cdf0e10cSrcweir //......................................................................... 142cdf0e10cSrcweir } // namespace dbaui 143cdf0e10cSrcweir //......................................................................... 144cdf0e10cSrcweir 145cdf0e10cSrcweir #endif // _DBAUI_CHARSETS_HXX_ 146cdf0e10cSrcweir 147