xref: /trunk/main/ucbhelper/inc/ucbhelper/macros.hxx (revision b3b486c3)
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 _UCBHELPER_MACROS_HXX
25 #define _UCBHELPER_MACROS_HXX
26 
27 #include <sal/types.h>
28 #include <cppuhelper/queryinterface.hxx>
29 #include <cppuhelper/factory.hxx>
30 #include <cppuhelper/weakref.hxx>
31 #include <cppuhelper/typeprovider.hxx>
32 
33 #include "osl/mutex.hxx"
34 
35 //=========================================================================
36 
37 #define CPPU_TYPE( T ) 		getCppuType( static_cast< T * >( 0 ) )
38 #define CPPU_TYPE_REF( T ) 	CPPU_TYPE( com::sun::star::uno::Reference< T > )
39 
40 //=========================================================================
41 //
42 // XInterface decl.
43 //
44 //=========================================================================
45 
46 #define XINTERFACE_DECL()													\
47     virtual com::sun::star::uno::Any SAL_CALL                				\
48 	queryInterface( const com::sun::star::uno::Type & rType )               \
49 		throw( com::sun::star::uno::RuntimeException );                     \
50     virtual void SAL_CALL                               					\
51 	acquire()                                           					\
52 		throw();                                                            \
53     virtual void SAL_CALL                                                   \
54 	release()                                                               \
55 		throw();
56 
57 //=========================================================================
58 //
59 // XInterface impl. internals.
60 //
61 //=========================================================================
62 
63 #define XINTERFACE_COMMON_IMPL( Class )										\
64 void SAL_CALL Class::acquire()                                              \
65 	throw()                                                                 \
66 {                                                                           \
67 	OWeakObject::acquire();                                 				\
68 }                                                                           \
69 																			\
70 void SAL_CALL Class::release()                                              \
71 	throw()                                                                 \
72 {                                                                           \
73 	OWeakObject::release();                                 				\
74 }
75 
76 #define QUERYINTERFACE_IMPL_START( Class )									\
77 com::sun::star::uno::Any SAL_CALL Class::queryInterface(                    \
78 								const com::sun::star::uno::Type & rType )   \
79 	throw( com::sun::star::uno::RuntimeException )                          \
80 {                                                                           \
81 	com::sun::star::uno::Any aRet = cppu::queryInterface( rType,
82 
83 #define QUERYINTERFACE_IMPL_END                                             \
84 					);                                                      \
85 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); 	\
86 }
87 
88 //=========================================================================
89 //
90 // XInterface impl.
91 //
92 //=========================================================================
93 
94 // 1 interface implemented
95 #define XINTERFACE_IMPL_1( Class, Ifc1 )									\
96 XINTERFACE_COMMON_IMPL( Class )                                             \
97 QUERYINTERFACE_IMPL_START( Class )                                          \
98 	SAL_STATIC_CAST( Ifc1*, this )                                          \
99 QUERYINTERFACE_IMPL_END
100 
101 // 2 interfaces implemented
102 #define XINTERFACE_IMPL_2( Class, Ifc1, Ifc2 )								\
103 XINTERFACE_COMMON_IMPL( Class )                                             \
104 QUERYINTERFACE_IMPL_START( Class )                                          \
105 	SAL_STATIC_CAST( Ifc1*, this ),                                         \
106 	SAL_STATIC_CAST( Ifc2*, this )                                          \
107 QUERYINTERFACE_IMPL_END
108 
109 // 3 interfaces implemented
110 #define XINTERFACE_IMPL_3( Class, Ifc1, Ifc2, Ifc3 )						\
111 XINTERFACE_COMMON_IMPL( Class )                                             \
112 QUERYINTERFACE_IMPL_START( Class )                                          \
113 	SAL_STATIC_CAST( Ifc1*, this ),                                         \
114 	SAL_STATIC_CAST( Ifc2*, this ),                                         \
115 	SAL_STATIC_CAST( Ifc3*, this )                                          \
116 QUERYINTERFACE_IMPL_END
117 
118 // 4 interfaces implemented
119 #define XINTERFACE_IMPL_4( Class, Ifc1, Ifc2, Ifc3, Ifc4 )					\
120 XINTERFACE_COMMON_IMPL( Class )                                             \
121 QUERYINTERFACE_IMPL_START( Class )                                          \
122 	SAL_STATIC_CAST( Ifc1*, this ),                                         \
123 	SAL_STATIC_CAST( Ifc2*, this ),                                         \
124 	SAL_STATIC_CAST( Ifc3*, this ),                                         \
125 	SAL_STATIC_CAST( Ifc4*, this )                                          \
126 QUERYINTERFACE_IMPL_END
127 
128 // 5 interfaces implemented
129 #define XINTERFACE_IMPL_5( Class, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5 )			\
130 XINTERFACE_COMMON_IMPL( Class )                                             \
131 QUERYINTERFACE_IMPL_START( Class )                                          \
132 	SAL_STATIC_CAST( Ifc1*, this ),                                         \
133 	SAL_STATIC_CAST( Ifc2*, this ),                                         \
134 	SAL_STATIC_CAST( Ifc3*, this ),                                         \
135 	SAL_STATIC_CAST( Ifc4*, this ),                                         \
136 	SAL_STATIC_CAST( Ifc5*, this )                                          \
137 QUERYINTERFACE_IMPL_END
138 
139 // 6 interfaces implemented
140 #define XINTERFACE_IMPL_6( Class,I1,I2,I3,I4,I5,I6 )						\
141 XINTERFACE_COMMON_IMPL( Class )                                             \
142 QUERYINTERFACE_IMPL_START( Class )                                          \
143 	SAL_STATIC_CAST( I1*, this ),                                         	\
144 	SAL_STATIC_CAST( I2*, this ),                                         	\
145 	SAL_STATIC_CAST( I3*, this ),                                         	\
146 	SAL_STATIC_CAST( I4*, this ),                                         	\
147 	SAL_STATIC_CAST( I5*, this ),                                         	\
148 	SAL_STATIC_CAST( I6*, this )                                         	\
149 QUERYINTERFACE_IMPL_END
150 
151 // 7 interfaces implemented
152 #define XINTERFACE_IMPL_7( Class,I1,I2,I3,I4,I5,I6,I7 )						\
153 XINTERFACE_COMMON_IMPL( Class )                                             \
154 QUERYINTERFACE_IMPL_START( Class )                                          \
155 	SAL_STATIC_CAST( I1*, this ),                                         	\
156 	SAL_STATIC_CAST( I2*, this ),                                         	\
157 	SAL_STATIC_CAST( I3*, this ),                                         	\
158 	SAL_STATIC_CAST( I4*, this ),                                         	\
159 	SAL_STATIC_CAST( I5*, this ),                                         	\
160 	SAL_STATIC_CAST( I6*, this ),                                         	\
161 	SAL_STATIC_CAST( I7*, this )                                         	\
162 QUERYINTERFACE_IMPL_END
163 
164 // 8 interfaces implemented
165 #define XINTERFACE_IMPL_8( Class,I1,I2,I3,I4,I5,I6,I7,I8 )					\
166 XINTERFACE_COMMON_IMPL( Class )                                             \
167 QUERYINTERFACE_IMPL_START( Class )                                          \
168 	SAL_STATIC_CAST( I1*, this ),                                         	\
169 	SAL_STATIC_CAST( I2*, this ),                                         	\
170 	SAL_STATIC_CAST( I3*, this ),                                         	\
171 	SAL_STATIC_CAST( I4*, this ),                                         	\
172 	SAL_STATIC_CAST( I5*, this ),                                         	\
173 	SAL_STATIC_CAST( I6*, this ),                                         	\
174 	SAL_STATIC_CAST( I7*, this ),                                         	\
175 	SAL_STATIC_CAST( I8*, this )                                         	\
176 QUERYINTERFACE_IMPL_END
177 
178 // 9 interfaces implemented
179 #define XINTERFACE_IMPL_9( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9 )				\
180 XINTERFACE_COMMON_IMPL( Class )                                             \
181 QUERYINTERFACE_IMPL_START( Class )                                          \
182 	SAL_STATIC_CAST( I1*, this ),                                         	\
183 	SAL_STATIC_CAST( I2*, this ),                                         	\
184 	SAL_STATIC_CAST( I3*, this ),                                         	\
185 	SAL_STATIC_CAST( I4*, this ),                                         	\
186 	SAL_STATIC_CAST( I5*, this ),                                         	\
187 	SAL_STATIC_CAST( I6*, this ),                                         	\
188 	SAL_STATIC_CAST( I7*, this ),                                         	\
189 	SAL_STATIC_CAST( I8*, this ),                                         	\
190 	SAL_STATIC_CAST( I9*, this )                                         	\
191 QUERYINTERFACE_IMPL_END
192 
193 // 10 interfaces implemented
194 #define XINTERFACE_IMPL_10( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10 )			\
195 XINTERFACE_COMMON_IMPL( Class )                                             \
196 QUERYINTERFACE_IMPL_START( Class )                                          \
197 	SAL_STATIC_CAST( I1*, this ),                                         	\
198 	SAL_STATIC_CAST( I2*, this ),                                         	\
199 	SAL_STATIC_CAST( I3*, this ),                                         	\
200 	SAL_STATIC_CAST( I4*, this ),                                         	\
201 	SAL_STATIC_CAST( I5*, this ),                                         	\
202 	SAL_STATIC_CAST( I6*, this ),                                         	\
203 	SAL_STATIC_CAST( I7*, this ),                                         	\
204 	SAL_STATIC_CAST( I8*, this ),                                         	\
205 	SAL_STATIC_CAST( I9*, this ),                                         	\
206 	SAL_STATIC_CAST( I10*, this )                                         	\
207 QUERYINTERFACE_IMPL_END
208 
209 // 11 interfaces implemented
210 #define XINTERFACE_IMPL_11( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11 )		\
211 XINTERFACE_COMMON_IMPL( Class )                                             \
212 QUERYINTERFACE_IMPL_START( Class )                                          \
213 	SAL_STATIC_CAST( I1*, this ),                                         	\
214 	SAL_STATIC_CAST( I2*, this ),                                         	\
215 	SAL_STATIC_CAST( I3*, this ),                                         	\
216 	SAL_STATIC_CAST( I4*, this ),                                         	\
217 	SAL_STATIC_CAST( I5*, this ),                                         	\
218 	SAL_STATIC_CAST( I6*, this ),                                         	\
219 	SAL_STATIC_CAST( I7*, this ),                                         	\
220 	SAL_STATIC_CAST( I8*, this ),                                         	\
221 	SAL_STATIC_CAST( I9*, this ),                                         	\
222 	SAL_STATIC_CAST( I10*, this ),                                         	\
223 	SAL_STATIC_CAST( I11*, this )                                         	\
224 QUERYINTERFACE_IMPL_END
225 
226 // 12 interfaces implemented
227 #define XINTERFACE_IMPL_12( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12 )	\
228 XINTERFACE_COMMON_IMPL( Class )                                             \
229 QUERYINTERFACE_IMPL_START( Class )                                          \
230 	SAL_STATIC_CAST( I1*, this ),                                         	\
231 	SAL_STATIC_CAST( I2*, this ),                                         	\
232 	SAL_STATIC_CAST( I3*, this ),                                         	\
233 	SAL_STATIC_CAST( I4*, this ),                                         	\
234 	SAL_STATIC_CAST( I5*, this ),                                         	\
235 	SAL_STATIC_CAST( I6*, this ),                                         	\
236 	SAL_STATIC_CAST( I7*, this ),                                         	\
237 	SAL_STATIC_CAST( I8*, this ),                                         	\
238 	SAL_STATIC_CAST( I9*, this ),                                         	\
239 	SAL_STATIC_CAST( I10*, this ),                                         	\
240 	SAL_STATIC_CAST( I11*, this ),                                         	\
241 	SAL_STATIC_CAST( I12*, this )                                         	\
242 QUERYINTERFACE_IMPL_END
243 
244 // 13 interfaces implemented
245 #define XINTERFACE_IMPL_13( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13 ) \
246 XINTERFACE_COMMON_IMPL( Class )                                             \
247 QUERYINTERFACE_IMPL_START( Class )                                          \
248 	SAL_STATIC_CAST( I1*, this ),                                         	\
249 	SAL_STATIC_CAST( I2*, this ),                                         	\
250 	SAL_STATIC_CAST( I3*, this ),                                         	\
251 	SAL_STATIC_CAST( I4*, this ),                                         	\
252 	SAL_STATIC_CAST( I5*, this ),                                         	\
253 	SAL_STATIC_CAST( I6*, this ),                                         	\
254 	SAL_STATIC_CAST( I7*, this ),                                         	\
255 	SAL_STATIC_CAST( I8*, this ),                                         	\
256 	SAL_STATIC_CAST( I9*, this ),                                         	\
257 	SAL_STATIC_CAST( I10*, this ),                                         	\
258 	SAL_STATIC_CAST( I11*, this ),                                         	\
259 	SAL_STATIC_CAST( I12*, this ),                                         	\
260 	SAL_STATIC_CAST( I13*, this )                                          	\
261 QUERYINTERFACE_IMPL_END
262 
263 // 14 interfaces implemented
264 #define XINTERFACE_IMPL_14( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14 )	\
265 XINTERFACE_COMMON_IMPL( Class )                                             \
266 QUERYINTERFACE_IMPL_START( Class )                                          \
267 	SAL_STATIC_CAST( I1*, this ),                                         	\
268 	SAL_STATIC_CAST( I2*, this ),                                         	\
269 	SAL_STATIC_CAST( I3*, this ),                                         	\
270 	SAL_STATIC_CAST( I4*, this ),                                         	\
271 	SAL_STATIC_CAST( I5*, this ),                                         	\
272 	SAL_STATIC_CAST( I6*, this ),                                         	\
273 	SAL_STATIC_CAST( I7*, this ),                                         	\
274 	SAL_STATIC_CAST( I8*, this ),                                         	\
275 	SAL_STATIC_CAST( I9*, this ),                                         	\
276 	SAL_STATIC_CAST( I10*, this ),                                         	\
277 	SAL_STATIC_CAST( I11*, this ),                                         	\
278 	SAL_STATIC_CAST( I12*, this ),                                         	\
279 	SAL_STATIC_CAST( I13*, this ),                                         	\
280 	SAL_STATIC_CAST( I14*, this )                                          	\
281 QUERYINTERFACE_IMPL_END
282 
283 // 15 interfaces implemented
284 #define XINTERFACE_IMPL_15( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14,I15 )	\
285 XINTERFACE_COMMON_IMPL( Class )                                             \
286 QUERYINTERFACE_IMPL_START( Class )                                          \
287 	SAL_STATIC_CAST( I1*, this ),                                         	\
288 	SAL_STATIC_CAST( I2*, this ),                                         	\
289 	SAL_STATIC_CAST( I3*, this ),                                         	\
290 	SAL_STATIC_CAST( I4*, this ),                                         	\
291 	SAL_STATIC_CAST( I5*, this ),                                         	\
292 	SAL_STATIC_CAST( I6*, this ),                                         	\
293 	SAL_STATIC_CAST( I7*, this ),                                         	\
294 	SAL_STATIC_CAST( I8*, this ),                                         	\
295 	SAL_STATIC_CAST( I9*, this ),                                         	\
296 	SAL_STATIC_CAST( I10*, this ),                                         	\
297 	SAL_STATIC_CAST( I11*, this ),                                         	\
298 	SAL_STATIC_CAST( I12*, this ),                                         	\
299 	SAL_STATIC_CAST( I13*, this ),                                         	\
300 	SAL_STATIC_CAST( I14*, this ),                                         	\
301 	SAL_STATIC_CAST( I15*, this )                                          	\
302 QUERYINTERFACE_IMPL_END
303 
304 //=========================================================================
305 //
306 // XTypeProvider decl.
307 //
308 //=========================================================================
309 
310 #define XTYPEPROVIDER_DECL()										  		\
311     virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL              \
312 	getImplementationId()                                                   \
313 		throw( com::sun::star::uno::RuntimeException );						\
314     virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL \
315 	getTypes()         														\
316 		throw( com::sun::star::uno::RuntimeException );
317 
318 //=========================================================================
319 //
320 // XTypeProvider impl. internals
321 //
322 //=========================================================================
323 
324 #define XTYPEPROVIDER_COMMON_IMPL( Class )									\
325 com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL                          \
326 Class::getImplementationId()                                                \
327 	throw( com::sun::star::uno::RuntimeException )                          \
328 {                                                                           \
329 	static cppu::OImplementationId* pId = NULL;                             \
330   	if ( !pId )                                                             \
331   	{                                                                       \
332 		osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );    \
333 	  	if ( !pId )                                                         \
334 	  	{                                                                   \
335 		  	static cppu::OImplementationId id( sal_False );                 \
336 		  	pId = &id;                                                      \
337 	  	}                                                                   \
338   	}                                                                       \
339   	return (*pId).getImplementationId();                                    \
340 }
341 
342 #define GETTYPES_IMPL_START( Class )										\
343 com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL         \
344 Class::getTypes()                                                           \
345 	throw( com::sun::star::uno::RuntimeException )                          \
346 {                                                                           \
347 	static cppu::OTypeCollection* pCollection = NULL;						\
348   	if ( !pCollection )                                                     \
349   	{                                                                       \
350 		osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );    \
351 		if ( !pCollection )                                                 \
352 		{                                                                   \
353 			static cppu::OTypeCollection collection(
354 
355 #define GETTYPES_IMPL_END													\
356 				);                                                          \
357 			pCollection = &collection;                                      \
358 		}                                                                   \
359 	}                                                                       \
360 	return (*pCollection).getTypes();                                       \
361 }
362 
363 //=========================================================================
364 //
365 // XTypeProvider impl.
366 //
367 //=========================================================================
368 
369 // 1 interface supported
370 #define XTYPEPROVIDER_IMPL_1( Class, I1 )									\
371 XTYPEPROVIDER_COMMON_IMPL( Class )											\
372 GETTYPES_IMPL_START( Class )                                  				\
373 	CPPU_TYPE_REF( I1 )													\
374 GETTYPES_IMPL_END
375 
376 // 2 interfaces supported
377 #define XTYPEPROVIDER_IMPL_2( Class, I1,I2 )  								\
378 XTYPEPROVIDER_COMMON_IMPL( Class )											\
379 GETTYPES_IMPL_START( Class )                                  				\
380 	CPPU_TYPE_REF( I1 ),													\
381 	CPPU_TYPE_REF( I2 )             										\
382 GETTYPES_IMPL_END
383 
384 // 3 interfaces supported
385 #define XTYPEPROVIDER_IMPL_3( Class, I1,I2,I3 )  							\
386 XTYPEPROVIDER_COMMON_IMPL( Class )											\
387 GETTYPES_IMPL_START( Class )                                  				\
388 	CPPU_TYPE_REF( I1 ),													\
389 	CPPU_TYPE_REF( I2 ),             										\
390 	CPPU_TYPE_REF( I3 )             										\
391 GETTYPES_IMPL_END
392 
393 // 4 interfaces supported
394 #define XTYPEPROVIDER_IMPL_4( Class, I1,I2,I3,I4 )  						\
395 XTYPEPROVIDER_COMMON_IMPL( Class )											\
396 GETTYPES_IMPL_START( Class )                                  				\
397 	CPPU_TYPE_REF( I1 ),													\
398 	CPPU_TYPE_REF( I2 ),             										\
399 	CPPU_TYPE_REF( I3 ),             										\
400 	CPPU_TYPE_REF( I4 )             										\
401 GETTYPES_IMPL_END
402 
403 // 5 interfaces supported
404 #define XTYPEPROVIDER_IMPL_5( Class, I1,I2,I3,I4,I5 )  						\
405 XTYPEPROVIDER_COMMON_IMPL( Class )											\
406 GETTYPES_IMPL_START( Class )                                  				\
407 	CPPU_TYPE_REF( I1 ),													\
408 	CPPU_TYPE_REF( I2 ),             										\
409 	CPPU_TYPE_REF( I3 ),             										\
410 	CPPU_TYPE_REF( I4 ),             										\
411 	CPPU_TYPE_REF( I5 )             										\
412 GETTYPES_IMPL_END
413 
414 // 6 interfaces supported
415 #define XTYPEPROVIDER_IMPL_6( Class, I1,I2,I3,I4,I5,I6 )  					\
416 XTYPEPROVIDER_COMMON_IMPL( Class )											\
417 GETTYPES_IMPL_START( Class )                                  				\
418 	CPPU_TYPE_REF( I1 ),													\
419 	CPPU_TYPE_REF( I2 ),             										\
420 	CPPU_TYPE_REF( I3 ),             										\
421 	CPPU_TYPE_REF( I4 ),             										\
422 	CPPU_TYPE_REF( I5 ),             										\
423 	CPPU_TYPE_REF( I6 )	            										\
424 GETTYPES_IMPL_END
425 
426 // 7 interfaces supported
427 #define XTYPEPROVIDER_IMPL_7( Class, I1,I2,I3,I4,I5,I6,I7 )   				\
428 XTYPEPROVIDER_COMMON_IMPL( Class )											\
429 GETTYPES_IMPL_START( Class )                                  				\
430 	CPPU_TYPE_REF( I1 ),													\
431 	CPPU_TYPE_REF( I2 ),             										\
432 	CPPU_TYPE_REF( I3 ),             										\
433 	CPPU_TYPE_REF( I4 ),             										\
434 	CPPU_TYPE_REF( I5 ),             										\
435 	CPPU_TYPE_REF( I6 ),            										\
436 	CPPU_TYPE_REF( I7 )             										\
437 GETTYPES_IMPL_END
438 
439 // 8 interfaces supported
440 #define XTYPEPROVIDER_IMPL_8( Class, I1,I2,I3,I4,I5,I6,I7,I8 )				\
441 XTYPEPROVIDER_COMMON_IMPL( Class )											\
442 GETTYPES_IMPL_START( Class )                                  				\
443 	CPPU_TYPE_REF( I1 ),													\
444 	CPPU_TYPE_REF( I2 ),             										\
445 	CPPU_TYPE_REF( I3 ),             										\
446 	CPPU_TYPE_REF( I4 ),             										\
447 	CPPU_TYPE_REF( I5 ),             										\
448 	CPPU_TYPE_REF( I6 ),            										\
449 	CPPU_TYPE_REF( I7 ),             										\
450 	CPPU_TYPE_REF( I8 )             										\
451 GETTYPES_IMPL_END
452 
453 // 9 interfaces supported
454 #define XTYPEPROVIDER_IMPL_9( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9 )			\
455 XTYPEPROVIDER_COMMON_IMPL( Class )											\
456 GETTYPES_IMPL_START( Class )                                  				\
457 	CPPU_TYPE_REF( I1 ),													\
458 	CPPU_TYPE_REF( I2 ),             										\
459 	CPPU_TYPE_REF( I3 ),             										\
460 	CPPU_TYPE_REF( I4 ),             										\
461 	CPPU_TYPE_REF( I5 ),             										\
462 	CPPU_TYPE_REF( I6 ),            										\
463 	CPPU_TYPE_REF( I7 ),             										\
464 	CPPU_TYPE_REF( I8 ),             										\
465 	CPPU_TYPE_REF( I9 )             										\
466 GETTYPES_IMPL_END
467 
468 // 10 interfaces supported
469 #define XTYPEPROVIDER_IMPL_10( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10 )		\
470 XTYPEPROVIDER_COMMON_IMPL( Class )											\
471 GETTYPES_IMPL_START( Class )                                  				\
472 	CPPU_TYPE_REF( I1 ),													\
473 	CPPU_TYPE_REF( I2 ),             										\
474 	CPPU_TYPE_REF( I3 ),             										\
475 	CPPU_TYPE_REF( I4 ),             										\
476 	CPPU_TYPE_REF( I5 ),             										\
477 	CPPU_TYPE_REF( I6 ),            										\
478 	CPPU_TYPE_REF( I7 ),             										\
479 	CPPU_TYPE_REF( I8 ),             										\
480 	CPPU_TYPE_REF( I9 ),             										\
481 	CPPU_TYPE_REF( I10 )            										\
482 GETTYPES_IMPL_END
483 
484 // 11 interfaces supported
485 #define XTYPEPROVIDER_IMPL_11( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11 )	\
486 XTYPEPROVIDER_COMMON_IMPL( Class )											\
487 GETTYPES_IMPL_START( Class )                                  				\
488 	CPPU_TYPE_REF( I1 ),													\
489 	CPPU_TYPE_REF( I2 ),             										\
490 	CPPU_TYPE_REF( I3 ),             										\
491 	CPPU_TYPE_REF( I4 ),             										\
492 	CPPU_TYPE_REF( I5 ),             										\
493 	CPPU_TYPE_REF( I6 ),            										\
494 	CPPU_TYPE_REF( I7 ),             										\
495 	CPPU_TYPE_REF( I8 ),             										\
496 	CPPU_TYPE_REF( I9 ),             										\
497 	CPPU_TYPE_REF( I10 ),            										\
498 	CPPU_TYPE_REF( I11 )            										\
499 GETTYPES_IMPL_END
500 
501 // 12 interfaces supported
502 #define XTYPEPROVIDER_IMPL_12( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12 )	\
503 XTYPEPROVIDER_COMMON_IMPL( Class )											\
504 GETTYPES_IMPL_START( Class )                                  				\
505 	CPPU_TYPE_REF( I1 ),													\
506 	CPPU_TYPE_REF( I2 ),             										\
507 	CPPU_TYPE_REF( I3 ),             										\
508 	CPPU_TYPE_REF( I4 ),             										\
509 	CPPU_TYPE_REF( I5 ),             										\
510 	CPPU_TYPE_REF( I6 ),            										\
511 	CPPU_TYPE_REF( I7 ),             										\
512 	CPPU_TYPE_REF( I8 ),             										\
513 	CPPU_TYPE_REF( I9 ),             										\
514 	CPPU_TYPE_REF( I10 ),            										\
515 	CPPU_TYPE_REF( I11 ),            										\
516 	CPPU_TYPE_REF( I12 )            										\
517 GETTYPES_IMPL_END
518 
519 // 13 interfaces supported
520 #define XTYPEPROVIDER_IMPL_13( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13 )	\
521 XTYPEPROVIDER_COMMON_IMPL( Class )											\
522 GETTYPES_IMPL_START( Class )                                  				\
523 	CPPU_TYPE_REF( I1 ),													\
524 	CPPU_TYPE_REF( I2 ),             										\
525 	CPPU_TYPE_REF( I3 ),             										\
526 	CPPU_TYPE_REF( I4 ),             										\
527 	CPPU_TYPE_REF( I5 ),             										\
528 	CPPU_TYPE_REF( I6 ),            										\
529 	CPPU_TYPE_REF( I7 ),             										\
530 	CPPU_TYPE_REF( I8 ),             										\
531 	CPPU_TYPE_REF( I9 ),             										\
532 	CPPU_TYPE_REF( I10 ),            										\
533 	CPPU_TYPE_REF( I11 ),            										\
534 	CPPU_TYPE_REF( I12 ),            										\
535 	CPPU_TYPE_REF( I13 )            										\
536 GETTYPES_IMPL_END
537 
538 // 14 interfaces supported
539 #define XTYPEPROVIDER_IMPL_14( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14 )	\
540 XTYPEPROVIDER_COMMON_IMPL( Class )											\
541 GETTYPES_IMPL_START( Class )                                  				\
542 	CPPU_TYPE_REF( I1 ),													\
543 	CPPU_TYPE_REF( I2 ),             										\
544 	CPPU_TYPE_REF( I3 ),             										\
545 	CPPU_TYPE_REF( I4 ),             										\
546 	CPPU_TYPE_REF( I5 ),             										\
547 	CPPU_TYPE_REF( I6 ),            										\
548 	CPPU_TYPE_REF( I7 ),             										\
549 	CPPU_TYPE_REF( I8 ),             										\
550 	CPPU_TYPE_REF( I9 ),             										\
551 	CPPU_TYPE_REF( I10 ),            										\
552 	CPPU_TYPE_REF( I11 ),            										\
553 	CPPU_TYPE_REF( I12 ),            										\
554 	CPPU_TYPE_REF( I13 ),            										\
555 	CPPU_TYPE_REF( I14 )            										\
556 GETTYPES_IMPL_END
557 
558 // 15 interfaces supported
559 #define XTYPEPROVIDER_IMPL_15( Class, I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14,I15 )	\
560 XTYPEPROVIDER_COMMON_IMPL( Class )											\
561 GETTYPES_IMPL_START( Class )                                  				\
562 	CPPU_TYPE_REF( I1 ),													\
563 	CPPU_TYPE_REF( I2 ),             										\
564 	CPPU_TYPE_REF( I3 ),             										\
565 	CPPU_TYPE_REF( I4 ),             										\
566 	CPPU_TYPE_REF( I5 ),             										\
567 	CPPU_TYPE_REF( I6 ),            										\
568 	CPPU_TYPE_REF( I7 ),             										\
569 	CPPU_TYPE_REF( I8 ),             										\
570 	CPPU_TYPE_REF( I9 ),             										\
571 	CPPU_TYPE_REF( I10 ),            										\
572 	CPPU_TYPE_REF( I11 ),            										\
573 	CPPU_TYPE_REF( I12 ),            										\
574 	CPPU_TYPE_REF( I13 ),            										\
575 	CPPU_TYPE_REF( I14 ),            										\
576 	CPPU_TYPE_REF( I15 )             										\
577 GETTYPES_IMPL_END
578 
579 //=========================================================================
580 //
581 // XServiceInfo decl.
582 //
583 //=========================================================================
584 
585 #define XSERVICEINFO_NOFACTORY_DECL()										\
586     virtual rtl::OUString SAL_CALL											\
587 	getImplementationName()                                                 \
588 		throw( com::sun::star::uno::RuntimeException );                     \
589     virtual sal_Bool SAL_CALL                                               \
590 	supportsService( const rtl::OUString& ServiceName )                   	\
591 		throw( com::sun::star::uno::RuntimeException );                     \
592     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL         \
593 	getSupportedServiceNames()                                              \
594 		throw( com::sun::star::uno::RuntimeException );                     \
595 																			\
596     static rtl::OUString                                                  	\
597 	getImplementationName_Static();                                         \
598     static com::sun::star::uno::Sequence< rtl::OUString >                   \
599 	getSupportedServiceNames_Static();
600 
601 #define XSERVICEINFO_DECL()													\
602 	XSERVICEINFO_NOFACTORY_DECL()											\
603 																			\
604 	static com::sun::star::uno::Reference<                                  \
605 			com::sun::star::lang::XSingleServiceFactory >                   \
606 	createServiceFactory( const com::sun::star::uno::Reference<             \
607 			com::sun::star::lang::XMultiServiceFactory >& rxServiceMgr );
608 
609 //=========================================================================
610 //
611 // XServiceInfo impl. internals
612 //
613 //=========================================================================
614 
615 #define XSERVICEINFO_COMMOM_IMPL( Class, ImplName )							\
616 rtl::OUString SAL_CALL Class::getImplementationName()						\
617 	throw( com::sun::star::uno::RuntimeException )                         	\
618 {                                                                           \
619 	return getImplementationName_Static();                                  \
620 }                                                                           \
621 																			\
622 rtl::OUString Class::getImplementationName_Static()                       	\
623 {                                                                           \
624 	return ImplName;                                                        \
625 }                                                                           \
626 																			\
627 sal_Bool SAL_CALL                                                           \
628 Class::supportsService(	const rtl::OUString& ServiceName )                	\
629 	throw( com::sun::star::uno::RuntimeException )                          \
630 {                                                                           \
631 	com::sun::star::uno::Sequence< rtl::OUString > aSNL =                   \
632 										getSupportedServiceNames();         \
633 	const rtl::OUString* pArray = aSNL.getArray();                       	\
634 	for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )                       \
635 	{                                                                       \
636 		if( pArray[ i ] == ServiceName )                                    \
637 			return sal_True;                                                \
638 	}                                                                       \
639 																			\
640 	return sal_False;                                                       \
641 }                                                                           \
642 																			\
643 com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL                     \
644 Class::getSupportedServiceNames()                                           \
645 	throw( com::sun::star::uno::RuntimeException )                          \
646 {                                                                           \
647 	return getSupportedServiceNames_Static();                               \
648 }
649 
650 #define XSERVICEINFO_CREATE_INSTANCE_IMPL( Class )							\
651 static com::sun::star::uno::Reference<										\
652 								com::sun::star::uno::XInterface > SAL_CALL	\
653 Class##_CreateInstance( const com::sun::star::uno::Reference<               \
654 				com::sun::star::lang::XMultiServiceFactory> & rSMgr )       \
655 	throw( com::sun::star::uno::Exception )                                 \
656 {                                                                           \
657 	com::sun::star::lang::XServiceInfo* pX =                                \
658 				(com::sun::star::lang::XServiceInfo*)new Class( rSMgr );    \
659 	return com::sun::star::uno::Reference<                                  \
660 							com::sun::star::uno::XInterface >::query( pX ); \
661 }
662 
663 //=========================================================================
664 //
665 // XServiceInfo impl.
666 //
667 //=========================================================================
668 
669 #define ONE_INSTANCE_SERVICE_FACTORY_IMPL( Class )	  						\
670 com::sun::star::uno::Reference<                                             \
671 						com::sun::star::lang::XSingleServiceFactory >    	\
672 Class::createServiceFactory( const com::sun::star::uno::Reference<         	\
673 			com::sun::star::lang::XMultiServiceFactory >& rxServiceMgr )    \
674 {                                                                           \
675 	return com::sun::star::uno::Reference<                					\
676 		com::sun::star::lang::XSingleServiceFactory >(                      \
677 			cppu::createOneInstanceFactory(                               	\
678 				rxServiceMgr,                                               \
679 				Class::getImplementationName_Static(),                      \
680 				Class##_CreateInstance,                                     \
681 				Class::getSupportedServiceNames_Static() ) );               \
682 }
683 
684 #define SINGLE_SERVICE_FACTORY_IMPL( Class )							   	\
685 com::sun::star::uno::Reference< 											\
686 						com::sun::star::lang::XSingleServiceFactory >    	\
687 Class::createServiceFactory( const com::sun::star::uno::Reference<         	\
688 			com::sun::star::lang::XMultiServiceFactory >& rxServiceMgr )    \
689 {                                                                           \
690 	return com::sun::star::uno::Reference<                 					\
691 		com::sun::star::lang::XSingleServiceFactory >(                      \
692 			cppu::createSingleFactory(                               		\
693 				rxServiceMgr,                                               \
694 				Class::getImplementationName_Static(),                      \
695 				Class##_CreateInstance,                                     \
696 				Class::getSupportedServiceNames_Static() ) );               \
697 }
698 
699 // Service without service factory.
700 
701 // Own implementation of getSupportedServiceNames_Static().
702 #define XSERVICEINFO_NOFACTORY_IMPL_0( Class, ImplName )					\
703 XSERVICEINFO_COMMOM_IMPL( Class, ImplName )									\
704 																			\
705 com::sun::star::uno::Sequence< rtl::OUString >                              \
706 Class::getSupportedServiceNames_Static()
707 
708 // 1 service name
709 #define XSERVICEINFO_NOFACTORY_IMPL_1( Class, ImplName, Service1 )			\
710 XSERVICEINFO_COMMOM_IMPL( Class, ImplName )									\
711 																			\
712 com::sun::star::uno::Sequence< rtl::OUString >                              \
713 Class::getSupportedServiceNames_Static()                                    \
714 {                                                                           \
715 	com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 );               \
716 	aSNS.getArray()[ 0 ] = Service1;                                        \
717 	return aSNS;                                                            \
718 }
719 
720 // Service with service factory.
721 
722 // Own implementation of getSupportedServiceNames_Static().
723 #define XSERVICEINFO_IMPL_0( Class, ImplName )								\
724 XSERVICEINFO_COMMOM_IMPL( Class, ImplName )									\
725 XSERVICEINFO_CREATE_INSTANCE_IMPL( Class )									\
726 																			\
727 com::sun::star::uno::Sequence< rtl::OUString >                              \
728 Class::getSupportedServiceNames_Static()
729 
730 // 1 service name
731 #define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 )					\
732 XSERVICEINFO_COMMOM_IMPL( Class, ImplName )									\
733 XSERVICEINFO_CREATE_INSTANCE_IMPL( Class )									\
734 																			\
735 com::sun::star::uno::Sequence< rtl::OUString >                              \
736 Class::getSupportedServiceNames_Static()                                    \
737 {                                                                           \
738 	com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 );               \
739 	aSNS.getArray()[ 0 ] = Service1;                                        \
740 	return aSNS;                                                            \
741 }
742 
743 #endif /* !_UCBHELPER_MACROS_HXX */
744