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 ; \ 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 { \ 80 com::sun::star::uno::Any aRet = cppu::queryInterface( rType, 81 82 #define QUERYINTERFACE_IMPL_END \ 83 ); \ 84 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); \ 85 } 86 87 //========================================================================= 88 // 89 // XInterface impl. 90 // 91 //========================================================================= 92 93 // 1 interface implemented 94 #define XINTERFACE_IMPL_1( Class, Ifc1 ) \ 95 XINTERFACE_COMMON_IMPL( Class ) \ 96 QUERYINTERFACE_IMPL_START( Class ) \ 97 SAL_STATIC_CAST( Ifc1*, this ) \ 98 QUERYINTERFACE_IMPL_END 99 100 // 2 interfaces implemented 101 #define XINTERFACE_IMPL_2( Class, Ifc1, Ifc2 ) \ 102 XINTERFACE_COMMON_IMPL( Class ) \ 103 QUERYINTERFACE_IMPL_START( Class ) \ 104 SAL_STATIC_CAST( Ifc1*, this ), \ 105 SAL_STATIC_CAST( Ifc2*, this ) \ 106 QUERYINTERFACE_IMPL_END 107 108 // 3 interfaces implemented 109 #define XINTERFACE_IMPL_3( Class, Ifc1, Ifc2, Ifc3 ) \ 110 XINTERFACE_COMMON_IMPL( Class ) \ 111 QUERYINTERFACE_IMPL_START( Class ) \ 112 SAL_STATIC_CAST( Ifc1*, this ), \ 113 SAL_STATIC_CAST( Ifc2*, this ), \ 114 SAL_STATIC_CAST( Ifc3*, this ) \ 115 QUERYINTERFACE_IMPL_END 116 117 // 4 interfaces implemented 118 #define XINTERFACE_IMPL_4( Class, Ifc1, Ifc2, Ifc3, Ifc4 ) \ 119 XINTERFACE_COMMON_IMPL( Class ) \ 120 QUERYINTERFACE_IMPL_START( Class ) \ 121 SAL_STATIC_CAST( Ifc1*, this ), \ 122 SAL_STATIC_CAST( Ifc2*, this ), \ 123 SAL_STATIC_CAST( Ifc3*, this ), \ 124 SAL_STATIC_CAST( Ifc4*, this ) \ 125 QUERYINTERFACE_IMPL_END 126 127 // 5 interfaces implemented 128 #define XINTERFACE_IMPL_5( Class, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5 ) \ 129 XINTERFACE_COMMON_IMPL( Class ) \ 130 QUERYINTERFACE_IMPL_START( Class ) \ 131 SAL_STATIC_CAST( Ifc1*, this ), \ 132 SAL_STATIC_CAST( Ifc2*, this ), \ 133 SAL_STATIC_CAST( Ifc3*, this ), \ 134 SAL_STATIC_CAST( Ifc4*, this ), \ 135 SAL_STATIC_CAST( Ifc5*, this ) \ 136 QUERYINTERFACE_IMPL_END 137 138 // 6 interfaces implemented 139 #define XINTERFACE_IMPL_6( Class,I1,I2,I3,I4,I5,I6 ) \ 140 XINTERFACE_COMMON_IMPL( Class ) \ 141 QUERYINTERFACE_IMPL_START( Class ) \ 142 SAL_STATIC_CAST( I1*, this ), \ 143 SAL_STATIC_CAST( I2*, this ), \ 144 SAL_STATIC_CAST( I3*, this ), \ 145 SAL_STATIC_CAST( I4*, this ), \ 146 SAL_STATIC_CAST( I5*, this ), \ 147 SAL_STATIC_CAST( I6*, this ) \ 148 QUERYINTERFACE_IMPL_END 149 150 // 7 interfaces implemented 151 #define XINTERFACE_IMPL_7( Class,I1,I2,I3,I4,I5,I6,I7 ) \ 152 XINTERFACE_COMMON_IMPL( Class ) \ 153 QUERYINTERFACE_IMPL_START( Class ) \ 154 SAL_STATIC_CAST( I1*, this ), \ 155 SAL_STATIC_CAST( I2*, this ), \ 156 SAL_STATIC_CAST( I3*, this ), \ 157 SAL_STATIC_CAST( I4*, this ), \ 158 SAL_STATIC_CAST( I5*, this ), \ 159 SAL_STATIC_CAST( I6*, this ), \ 160 SAL_STATIC_CAST( I7*, this ) \ 161 QUERYINTERFACE_IMPL_END 162 163 // 8 interfaces implemented 164 #define XINTERFACE_IMPL_8( Class,I1,I2,I3,I4,I5,I6,I7,I8 ) \ 165 XINTERFACE_COMMON_IMPL( Class ) \ 166 QUERYINTERFACE_IMPL_START( Class ) \ 167 SAL_STATIC_CAST( I1*, this ), \ 168 SAL_STATIC_CAST( I2*, this ), \ 169 SAL_STATIC_CAST( I3*, this ), \ 170 SAL_STATIC_CAST( I4*, this ), \ 171 SAL_STATIC_CAST( I5*, this ), \ 172 SAL_STATIC_CAST( I6*, this ), \ 173 SAL_STATIC_CAST( I7*, this ), \ 174 SAL_STATIC_CAST( I8*, this ) \ 175 QUERYINTERFACE_IMPL_END 176 177 // 9 interfaces implemented 178 #define XINTERFACE_IMPL_9( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9 ) \ 179 XINTERFACE_COMMON_IMPL( Class ) \ 180 QUERYINTERFACE_IMPL_START( Class ) \ 181 SAL_STATIC_CAST( I1*, this ), \ 182 SAL_STATIC_CAST( I2*, this ), \ 183 SAL_STATIC_CAST( I3*, this ), \ 184 SAL_STATIC_CAST( I4*, this ), \ 185 SAL_STATIC_CAST( I5*, this ), \ 186 SAL_STATIC_CAST( I6*, this ), \ 187 SAL_STATIC_CAST( I7*, this ), \ 188 SAL_STATIC_CAST( I8*, this ), \ 189 SAL_STATIC_CAST( I9*, this ) \ 190 QUERYINTERFACE_IMPL_END 191 192 // 10 interfaces implemented 193 #define XINTERFACE_IMPL_10( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10 ) \ 194 XINTERFACE_COMMON_IMPL( Class ) \ 195 QUERYINTERFACE_IMPL_START( Class ) \ 196 SAL_STATIC_CAST( I1*, this ), \ 197 SAL_STATIC_CAST( I2*, this ), \ 198 SAL_STATIC_CAST( I3*, this ), \ 199 SAL_STATIC_CAST( I4*, this ), \ 200 SAL_STATIC_CAST( I5*, this ), \ 201 SAL_STATIC_CAST( I6*, this ), \ 202 SAL_STATIC_CAST( I7*, this ), \ 203 SAL_STATIC_CAST( I8*, this ), \ 204 SAL_STATIC_CAST( I9*, this ), \ 205 SAL_STATIC_CAST( I10*, this ) \ 206 QUERYINTERFACE_IMPL_END 207 208 // 11 interfaces implemented 209 #define XINTERFACE_IMPL_11( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11 ) \ 210 XINTERFACE_COMMON_IMPL( Class ) \ 211 QUERYINTERFACE_IMPL_START( Class ) \ 212 SAL_STATIC_CAST( I1*, this ), \ 213 SAL_STATIC_CAST( I2*, this ), \ 214 SAL_STATIC_CAST( I3*, this ), \ 215 SAL_STATIC_CAST( I4*, this ), \ 216 SAL_STATIC_CAST( I5*, this ), \ 217 SAL_STATIC_CAST( I6*, this ), \ 218 SAL_STATIC_CAST( I7*, this ), \ 219 SAL_STATIC_CAST( I8*, this ), \ 220 SAL_STATIC_CAST( I9*, this ), \ 221 SAL_STATIC_CAST( I10*, this ), \ 222 SAL_STATIC_CAST( I11*, this ) \ 223 QUERYINTERFACE_IMPL_END 224 225 // 12 interfaces implemented 226 #define XINTERFACE_IMPL_12( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12 ) \ 227 XINTERFACE_COMMON_IMPL( Class ) \ 228 QUERYINTERFACE_IMPL_START( Class ) \ 229 SAL_STATIC_CAST( I1*, this ), \ 230 SAL_STATIC_CAST( I2*, this ), \ 231 SAL_STATIC_CAST( I3*, this ), \ 232 SAL_STATIC_CAST( I4*, this ), \ 233 SAL_STATIC_CAST( I5*, this ), \ 234 SAL_STATIC_CAST( I6*, this ), \ 235 SAL_STATIC_CAST( I7*, this ), \ 236 SAL_STATIC_CAST( I8*, this ), \ 237 SAL_STATIC_CAST( I9*, this ), \ 238 SAL_STATIC_CAST( I10*, this ), \ 239 SAL_STATIC_CAST( I11*, this ), \ 240 SAL_STATIC_CAST( I12*, this ) \ 241 QUERYINTERFACE_IMPL_END 242 243 // 13 interfaces implemented 244 #define XINTERFACE_IMPL_13( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13 ) \ 245 XINTERFACE_COMMON_IMPL( Class ) \ 246 QUERYINTERFACE_IMPL_START( Class ) \ 247 SAL_STATIC_CAST( I1*, this ), \ 248 SAL_STATIC_CAST( I2*, this ), \ 249 SAL_STATIC_CAST( I3*, this ), \ 250 SAL_STATIC_CAST( I4*, this ), \ 251 SAL_STATIC_CAST( I5*, this ), \ 252 SAL_STATIC_CAST( I6*, this ), \ 253 SAL_STATIC_CAST( I7*, this ), \ 254 SAL_STATIC_CAST( I8*, this ), \ 255 SAL_STATIC_CAST( I9*, this ), \ 256 SAL_STATIC_CAST( I10*, this ), \ 257 SAL_STATIC_CAST( I11*, this ), \ 258 SAL_STATIC_CAST( I12*, this ), \ 259 SAL_STATIC_CAST( I13*, this ) \ 260 QUERYINTERFACE_IMPL_END 261 262 // 14 interfaces implemented 263 #define XINTERFACE_IMPL_14( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14 ) \ 264 XINTERFACE_COMMON_IMPL( Class ) \ 265 QUERYINTERFACE_IMPL_START( Class ) \ 266 SAL_STATIC_CAST( I1*, this ), \ 267 SAL_STATIC_CAST( I2*, this ), \ 268 SAL_STATIC_CAST( I3*, this ), \ 269 SAL_STATIC_CAST( I4*, this ), \ 270 SAL_STATIC_CAST( I5*, this ), \ 271 SAL_STATIC_CAST( I6*, this ), \ 272 SAL_STATIC_CAST( I7*, this ), \ 273 SAL_STATIC_CAST( I8*, this ), \ 274 SAL_STATIC_CAST( I9*, this ), \ 275 SAL_STATIC_CAST( I10*, this ), \ 276 SAL_STATIC_CAST( I11*, this ), \ 277 SAL_STATIC_CAST( I12*, this ), \ 278 SAL_STATIC_CAST( I13*, this ), \ 279 SAL_STATIC_CAST( I14*, this ) \ 280 QUERYINTERFACE_IMPL_END 281 282 // 15 interfaces implemented 283 #define XINTERFACE_IMPL_15( Class,I1,I2,I3,I4,I5,I6,I7,I8,I9,I10,I11,I12,I13,I14,I15 ) \ 284 XINTERFACE_COMMON_IMPL( Class ) \ 285 QUERYINTERFACE_IMPL_START( Class ) \ 286 SAL_STATIC_CAST( I1*, this ), \ 287 SAL_STATIC_CAST( I2*, this ), \ 288 SAL_STATIC_CAST( I3*, this ), \ 289 SAL_STATIC_CAST( I4*, this ), \ 290 SAL_STATIC_CAST( I5*, this ), \ 291 SAL_STATIC_CAST( I6*, this ), \ 292 SAL_STATIC_CAST( I7*, this ), \ 293 SAL_STATIC_CAST( I8*, this ), \ 294 SAL_STATIC_CAST( I9*, this ), \ 295 SAL_STATIC_CAST( I10*, this ), \ 296 SAL_STATIC_CAST( I11*, this ), \ 297 SAL_STATIC_CAST( I12*, this ), \ 298 SAL_STATIC_CAST( I13*, this ), \ 299 SAL_STATIC_CAST( I14*, this ), \ 300 SAL_STATIC_CAST( I15*, this ) \ 301 QUERYINTERFACE_IMPL_END 302 303 //========================================================================= 304 // 305 // XTypeProvider decl. 306 // 307 //========================================================================= 308 309 #define XTYPEPROVIDER_DECL() \ 310 virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL \ 311 getImplementationId() \ 312 ; \ 313 virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL \ 314 getTypes() \ 315 ; 316 317 //========================================================================= 318 // 319 // XTypeProvider impl. internals 320 // 321 //========================================================================= 322 323 #define XTYPEPROVIDER_COMMON_IMPL( Class ) \ 324 com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL \ 325 Class::getImplementationId() \ 326 { \ 327 static cppu::OImplementationId* pId = NULL; \ 328 if ( !pId ) \ 329 { \ 330 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); \ 331 if ( !pId ) \ 332 { \ 333 static cppu::OImplementationId id( sal_False ); \ 334 pId = &id; \ 335 } \ 336 } \ 337 return (*pId).getImplementationId(); \ 338 } 339 340 #define GETTYPES_IMPL_START( Class ) \ 341 com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL \ 342 Class::getTypes() \ 343 { \ 344 static cppu::OTypeCollection* pCollection = NULL; \ 345 if ( !pCollection ) \ 346 { \ 347 osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() ); \ 348 if ( !pCollection ) \ 349 { \ 350 static cppu::OTypeCollection collection( 351 352 #define GETTYPES_IMPL_END \ 353 ); \ 354 pCollection = &collection; \ 355 } \ 356 } \ 357 return (*pCollection).getTypes(); \ 358 } 359 360 //========================================================================= 361 // 362 // XTypeProvider impl. 363 // 364 //========================================================================= 365 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 372 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 380 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 389 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 399 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 410 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 422 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 435 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 449 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 464 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 480 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 497 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 515 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 534 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 554 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 575 576 //========================================================================= 577 // 578 // XServiceInfo decl. 579 // 580 //========================================================================= 581 582 #define XSERVICEINFO_NOFACTORY_DECL() \ 583 virtual rtl::OUString SAL_CALL \ 584 getImplementationName() \ 585 ; \ 586 virtual sal_Bool SAL_CALL \ 587 supportsService( const rtl::OUString& ServiceName ) \ 588 ; \ 589 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL \ 590 getSupportedServiceNames() \ 591 ; \ 592 \ 593 static rtl::OUString \ 594 getImplementationName_Static(); \ 595 static com::sun::star::uno::Sequence< rtl::OUString > \ 596 getSupportedServiceNames_Static(); 597 598 #define XSERVICEINFO_DECL() \ 599 XSERVICEINFO_NOFACTORY_DECL() \ 600 \ 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 ); 605 606 //========================================================================= 607 // 608 // XServiceInfo impl. internals 609 // 610 //========================================================================= 611 612 #define XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ 613 rtl::OUString SAL_CALL Class::getImplementationName() \ 614 { \ 615 return getImplementationName_Static(); \ 616 } \ 617 \ 618 rtl::OUString Class::getImplementationName_Static() \ 619 { \ 620 return ImplName; \ 621 } \ 622 \ 623 sal_Bool SAL_CALL \ 624 Class::supportsService( const rtl::OUString& ServiceName ) \ 625 { \ 626 com::sun::star::uno::Sequence< rtl::OUString > aSNL = \ 627 getSupportedServiceNames(); \ 628 const rtl::OUString* pArray = aSNL.getArray(); \ 629 for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) \ 630 { \ 631 if( pArray[ i ] == ServiceName ) \ 632 return sal_True; \ 633 } \ 634 \ 635 return sal_False; \ 636 } \ 637 \ 638 com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL \ 639 Class::getSupportedServiceNames() \ 640 { \ 641 return getSupportedServiceNames_Static(); \ 642 } 643 644 #define XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ 645 static com::sun::star::uno::Reference< \ 646 com::sun::star::uno::XInterface > SAL_CALL \ 647 Class##_CreateInstance( const com::sun::star::uno::Reference< \ 648 com::sun::star::lang::XMultiServiceFactory> & rSMgr ) \ 649 { \ 650 com::sun::star::lang::XServiceInfo* pX = \ 651 (com::sun::star::lang::XServiceInfo*)new Class( rSMgr ); \ 652 return com::sun::star::uno::Reference< \ 653 com::sun::star::uno::XInterface >::query( pX ); \ 654 } 655 656 //========================================================================= 657 // 658 // XServiceInfo impl. 659 // 660 //========================================================================= 661 662 #define ONE_INSTANCE_SERVICE_FACTORY_IMPL( Class ) \ 663 com::sun::star::uno::Reference< \ 664 com::sun::star::lang::XSingleServiceFactory > \ 665 Class::createServiceFactory( const com::sun::star::uno::Reference< \ 666 com::sun::star::lang::XMultiServiceFactory >& rxServiceMgr ) \ 667 { \ 668 return com::sun::star::uno::Reference< \ 669 com::sun::star::lang::XSingleServiceFactory >( \ 670 cppu::createOneInstanceFactory( \ 671 rxServiceMgr, \ 672 Class::getImplementationName_Static(), \ 673 Class##_CreateInstance, \ 674 Class::getSupportedServiceNames_Static() ) ); \ 675 } 676 677 #define SINGLE_SERVICE_FACTORY_IMPL( Class ) \ 678 com::sun::star::uno::Reference< \ 679 com::sun::star::lang::XSingleServiceFactory > \ 680 Class::createServiceFactory( const com::sun::star::uno::Reference< \ 681 com::sun::star::lang::XMultiServiceFactory >& rxServiceMgr ) \ 682 { \ 683 return com::sun::star::uno::Reference< \ 684 com::sun::star::lang::XSingleServiceFactory >( \ 685 cppu::createSingleFactory( \ 686 rxServiceMgr, \ 687 Class::getImplementationName_Static(), \ 688 Class##_CreateInstance, \ 689 Class::getSupportedServiceNames_Static() ) ); \ 690 } 691 692 // Service without service factory. 693 694 // Own implementation of getSupportedServiceNames_Static(). 695 #define XSERVICEINFO_NOFACTORY_IMPL_0( Class, ImplName ) \ 696 XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ 697 \ 698 com::sun::star::uno::Sequence< rtl::OUString > \ 699 Class::getSupportedServiceNames_Static() 700 701 // 1 service name 702 #define XSERVICEINFO_NOFACTORY_IMPL_1( Class, ImplName, Service1 ) \ 703 XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ 704 \ 705 com::sun::star::uno::Sequence< rtl::OUString > \ 706 Class::getSupportedServiceNames_Static() \ 707 { \ 708 com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 ); \ 709 aSNS.getArray()[ 0 ] = Service1; \ 710 return aSNS; \ 711 } 712 713 // Service with service factory. 714 715 // Own implementation of getSupportedServiceNames_Static(). 716 #define XSERVICEINFO_IMPL_0( Class, ImplName ) \ 717 XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ 718 XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ 719 \ 720 com::sun::star::uno::Sequence< rtl::OUString > \ 721 Class::getSupportedServiceNames_Static() 722 723 // 1 service name 724 #define XSERVICEINFO_IMPL_1( Class, ImplName, Service1 ) \ 725 XSERVICEINFO_COMMOM_IMPL( Class, ImplName ) \ 726 XSERVICEINFO_CREATE_INSTANCE_IMPL( Class ) \ 727 \ 728 com::sun::star::uno::Sequence< rtl::OUString > \ 729 Class::getSupportedServiceNames_Static() \ 730 { \ 731 com::sun::star::uno::Sequence< rtl::OUString > aSNS( 1 ); \ 732 aSNS.getArray()[ 0 ] = Service1; \ 733 return aSNS; \ 734 } 735 736 #endif /* !_UCBHELPER_MACROS_HXX */ 737