1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: charsets.hxx,v $
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_
35 #include <tools/string.hxx>
38 #include <tools/rc.hxx>
40 #ifndef _DBHELPER_DBCHARSET_HXX_
41 #include <connectivity/dbcharset.hxx>
43 #ifndef _SVX_TXENCTAB_HXX
44 #include <svx/txenctab.hxx>
47 //.........................................................................
50 //.........................................................................
52 //=========================================================================
54 //=========================================================================
55 typedef ::dbtools::OCharsetMap OCharsetDisplay_Base
;
57 :protected OCharsetDisplay_Base
58 ,protected SvxTextEncodingTable
61 ::rtl::OUString m_aSystemDisplayName
;
64 class ExtendedCharsetIterator
;
65 friend class OCharsetDisplay::ExtendedCharsetIterator
;
67 typedef ExtendedCharsetIterator iterator
;
68 typedef ExtendedCharsetIterator const_iterator
;
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;
82 sal_Int32
size() const { return OCharsetDisplay_Base::size(); }
85 virtual sal_Bool
approveEncoding( const rtl_TextEncoding _eEncoding
, const rtl_TextEncodingInfo
& _rInfo
) const;
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
;
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
; }
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
;
126 const OCharsetDisplay
* m_pContainer
;
127 base_iterator m_aPosition
;
130 ExtendedCharsetIterator(const ExtendedCharsetIterator
& _rSource
);
132 CharsetDisplayDerefHelper
operator*() const;
135 const ExtendedCharsetIterator
& operator++();
136 /// postfix increment
137 const ExtendedCharsetIterator
operator++(int) { ExtendedCharsetIterator
hold(*this); ++*this; return hold
; }
140 const ExtendedCharsetIterator
& operator--();
141 /// postfix decrement
142 const ExtendedCharsetIterator
operator--(int) { ExtendedCharsetIterator
hold(*this); --*this; return hold
; }
145 ExtendedCharsetIterator( const OCharsetDisplay
* _pContainer
, const base_iterator
& _rPosition
);
148 //.........................................................................
150 //.........................................................................
152 #endif // _DBAUI_CHARSETS_HXX_