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