1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef DBACCESS_IMAGEPROVIDER_HXX
25 #define DBACCESS_IMAGEPROVIDER_HXX
26 
27 #ifndef _SV_IMAGE_HXX
28 #include <vcl/image.hxx>
29 #endif
30 
31 /** === begin UNO includes === **/
32 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
33 #include <com/sun/star/sdbc/XConnection.hpp>
34 #endif
35 #ifndef _COM_SUN_STAR_SDB_APPLICATION_DATABASEOBJECT_HPP_
36 #include <com/sun/star/sdb/application/DatabaseObject.hpp>
37 #endif
38 /** === end UNO includes === **/
39 
40 #include <boost/shared_ptr.hpp>
41 
42 //........................................................................
43 namespace dbaui
44 {
45 //........................................................................
46 
47     // for convenience of our clients
48     namespace DatabaseObject = ::com::sun::star::sdb::application::DatabaseObject;
49 
50 	//====================================================================
51 	//= ImageProvider
52 	//====================================================================
53     struct ImageProvider_Data;
54     /** provides images for database objects such as tables, queries, forms, reports ...
55 
56         At the moment, this class cares for small icons only, that is, icons which can be used
57         in a tree control. On the medium term, we should extend it with support for different-sized
58         icons.
59     */
60 	class ImageProvider
61 	{
62     private:
63         ::boost::shared_ptr< ImageProvider_Data >   m_pData;
64 
65     public:
66         /** creates a semi-functional ImageProvider instance
67 
68             The resulting instance is not able to provide any concrete object images,
69             but only default images.
70         */
71         ImageProvider();
72 
73         /** creates an ImageProvider instance
74 
75             @param  _rxConnection
76                 denotes the connection to work for. Must not be <NULL/>.
77         */
78         ImageProvider(
79             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection
80         );
81 
82         /** returns the image to be used for a database object with the given name
83 
84             @param  _nDatabaseObjectType
85                 the type of the object. Must be one of the css.sdb.application.DatabaseObject
86                 constants.
87             @param  _rName
88                 the name of the object
89             @param  _out_rImage
90                 the normal image to use for the object
91             @param  _out_rImageHC
92                 the high-contrast version of the image to use for the object
93             @return
94                 the image to be used for the object.
95         */
96         void getImages(
97             const String& _rName,
98             const sal_Int32 _nDatabaseObjectType,
99             Image& _out_rImage,
100             Image& _out_rImageHC
101         );
102 
103         /** returns the default image to be used for a database object
104 
105             In opposite to getImages, this method does not check the concrete object
106             for its image, but returns a default image to be used for all objects of the given
107             type.
108 
109             @param  _nDatabaseObjectType
110                 the type of the object. Must be one of the css.sdb.application.DatabaseObject
111                 constants.
112             @param  _bHighContrast
113                 indicates whether High-Contrast icons should be used.
114                 Note that normally, this would be some application-wide setting. However,
115                 in current OOo, HC support is decided on a per-control basis, means every
116                 control decides itself whether its images must be HC versions or not.
117                 Thus callers need to specify this flag.
118             @return
119                 the image to be used for the object type.
120         */
121         Image getDefaultImage(
122             sal_Int32 _nDatabaseObjectType,
123             bool _bHighContrast
124         );
125 
126         /** returns the resource ID for the default image to be used for a database object
127 
128             In opposite to getImages, this method does not check the concrete object
129             for its image, but returns a default image to be used for all objects of the given
130             type.
131 
132             @param  _nDatabaseObjectType
133                 the type of the object. Must be one of the css.sdb.application.DatabaseObject
134                 constants.
135             @param  _bHighContrast
136                 indicates whether High-Contrast icons should be used.
137                 Note that normally, this would be some application-wide setting. However,
138                 in current OOo, HC support is decided on a per-control basis, means every
139                 control decides itself whether its images must be HC versions or not.
140                 Thus callers need to specify this flag.
141             @return
142                 the resource ID image to be used for the object type. Must be fed into a
143                 ModuleRes instance to actually load the image.
144         */
145         sal_uInt16 getDefaultImageResourceID(
146             sal_Int32 _nDatabaseObjectType,
147             bool _bHighContrast
148         );
149 
150         /** retrieves the image to be used for folders of database objects
151             @param  _nDatabaseObjectType
152                 the type of the object. Must be one of the css.sdb.application.DatabaseObject
153                 constants.
154             @param  _rName
155                 the name of the object
156             @param  _bHighContrast
157                 indicates whether High-Contrast icons should be used.
158                 Note that normally, this would be some application-wide setting. However,
159                 in current OOo, HC support is decided on a per-control basis, means every
160                 control decides itself whether its images must be HC versions or not.
161                 Thus callers need to specify this flag.
162             @return
163                 the image to be used for folders of the given type
164         */
165         Image getFolderImage(
166             sal_Int32 _nDatabaseObjectType,
167             bool _bHighContrast
168         );
169 
170         /** retrieves the image to be used for a database as a whole.
171             @param  _bHighContrast
172                 indicates whether High-Contrast icons should be used.
173                 Note that normally, this would be some application-wide setting. However,
174                 in current OOo, HC support is decided on a per-control basis, means every
175                 control decides itself whether its images must be HC versions or not.
176                 Thus callers need to specify this flag.
177             @return
178                 the image to be used for folders of this type
179         */
180         Image getDatabaseImage( bool _bHighContrast );
181 	};
182 
183 //........................................................................
184 } // namespace dbaui
185 //........................................................................
186 
187 #endif // DBACCESS_IMAGEPROVIDER_HXX
188 
189