Branch data Line data Source code
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 : :
20 : : #ifndef _DBAUI_CHARSETS_HXX_
21 : : #define _DBAUI_CHARSETS_HXX_
22 : :
23 : : #include <connectivity/dbcharset.hxx>
24 : : #include <rtl/ustring.hxx>
25 : : #include <svx/txenctab.hxx>
26 : :
27 : : //.........................................................................
28 : : namespace dbaui
29 : : {
30 : : //.........................................................................
31 : :
32 : : //=========================================================================
33 : : //= OCharsetDisplay
34 : : //=========================================================================
35 : : typedef ::dbtools::OCharsetMap OCharsetDisplay_Base;
36 [ # # ][ # # ]: 0 : class OCharsetDisplay
37 : : :protected OCharsetDisplay_Base
38 : : ,protected SvxTextEncodingTable
39 : : {
40 : : protected:
41 : : ::rtl::OUString m_aSystemDisplayName;
42 : :
43 : : public:
44 : : class ExtendedCharsetIterator;
45 : : friend class OCharsetDisplay::ExtendedCharsetIterator;
46 : :
47 : : typedef ExtendedCharsetIterator iterator;
48 : : typedef ExtendedCharsetIterator const_iterator;
49 : :
50 : : OCharsetDisplay();
51 : :
52 : : // various find operations
53 : : const_iterator findEncoding(const rtl_TextEncoding _eEncoding) const;
54 : : const_iterator findIanaName(const ::rtl::OUString& _rIanaName) const;
55 : : const_iterator findDisplayName(const ::rtl::OUString& _rDisplayName) const;
56 : :
57 : : /// get access to the first element of the charset collection
58 : : const_iterator begin() const;
59 : : /// get access to the (last + 1st) element of the charset collection
60 : : const_iterator end() const;
61 : : // size of the map
62 : : sal_Int32 size() const { return OCharsetDisplay_Base::size(); }
63 : :
64 : : protected:
65 : : virtual sal_Bool approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const;
66 : :
67 : : private:
68 : : using OCharsetDisplay_Base::find;
69 : : };
70 : :
71 : : //-------------------------------------------------------------------------
72 : : //- CharsetDisplayDerefHelper
73 : : //-------------------------------------------------------------------------
74 : : typedef ::dbtools::CharsetIteratorDerefHelper CharsetDisplayDerefHelper_Base;
75 : 0 : class CharsetDisplayDerefHelper : protected CharsetDisplayDerefHelper_Base
76 : : {
77 : : friend class OCharsetDisplay::ExtendedCharsetIterator;
78 : :
79 : : ::rtl::OUString m_sDisplayName;
80 : :
81 : : public:
82 : : CharsetDisplayDerefHelper(const CharsetDisplayDerefHelper& _rSource);
83 : :
84 : : rtl_TextEncoding getEncoding() const { return CharsetDisplayDerefHelper_Base::getEncoding(); }
85 : 0 : ::rtl::OUString getIanaName() const { return CharsetDisplayDerefHelper_Base::getIanaName(); }
86 : 0 : ::rtl::OUString getDisplayName() const { return m_sDisplayName; }
87 : :
88 : : protected:
89 : : CharsetDisplayDerefHelper(const ::dbtools::CharsetIteratorDerefHelper& _rBase, const ::rtl::OUString& _rDisplayName);
90 : : };
91 : :
92 : : //-------------------------------------------------------------------------
93 : : //- OCharsetDisplay::ExtendedCharsetIterator
94 : : //-------------------------------------------------------------------------
95 : 0 : class OCharsetDisplay::ExtendedCharsetIterator
96 : : {
97 : : friend class OCharsetDisplay;
98 : :
99 : : friend bool operator==(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs);
100 : 0 : friend bool operator!=(const ExtendedCharsetIterator& lhs, const ExtendedCharsetIterator& rhs) { return !(lhs == rhs); }
101 : :
102 : : typedef ::dbtools::OCharsetMap container;
103 : : typedef container::CharsetIterator base_iterator;
104 : :
105 : : protected:
106 : : const OCharsetDisplay* m_pContainer;
107 : : base_iterator m_aPosition;
108 : :
109 : : public:
110 : : ExtendedCharsetIterator(const ExtendedCharsetIterator& _rSource);
111 : :
112 : : CharsetDisplayDerefHelper operator*() const;
113 : :
114 : : /// prefix increment
115 : : const ExtendedCharsetIterator& operator++();
116 : : /// postfix increment
117 : : const ExtendedCharsetIterator operator++(int) { ExtendedCharsetIterator hold(*this); ++*this; return hold; }
118 : :
119 : : /// prefix decrement
120 : : const ExtendedCharsetIterator& operator--();
121 : : /// postfix decrement
122 : : const ExtendedCharsetIterator operator--(int) { ExtendedCharsetIterator hold(*this); --*this; return hold; }
123 : :
124 : : protected:
125 : : ExtendedCharsetIterator( const OCharsetDisplay* _pContainer, const base_iterator& _rPosition );
126 : : };
127 : :
128 : : //.........................................................................
129 : : } // namespace dbaui
130 : : //.........................................................................
131 : :
132 : : #endif // _DBAUI_CHARSETS_HXX_
133 : :
134 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|