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