1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ 29 #define _CPPUHELPER_QUERYINTERFACE_HXX_ 30 31 #include "sal/config.h" 32 #include "com/sun/star/uno/Any.hxx" 33 #include "com/sun/star/uno/Type.hxx" 34 #include "sal/types.h" 35 36 namespace cppu 37 { 38 39 /** Compares demanded type to given template argument types. 40 41 @tplparam Interface1 interface type 42 @param rType demanded type 43 @param p1 interface pointer 44 @return acquired interface of demanded type or empty Any 45 */ 46 template< class Interface1 > 47 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 48 const ::com::sun::star::uno::Type & rType, 49 Interface1 * p1 ) 50 SAL_THROW( () ) 51 { 52 if (rType == Interface1::static_type()) 53 return ::com::sun::star::uno::Any( &p1, rType ); 54 else 55 return ::com::sun::star::uno::Any(); 56 } 57 /** Compares demanded type to given template argument types. 58 59 @tplparam Interface1 interface type 60 @tplparam Interface2 interface type 61 @param rType demanded type 62 @param p1 interface pointer 63 @param p2 interface pointer 64 @return acquired interface of demanded type or empty Any 65 */ 66 template< class Interface1, class Interface2 > 67 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 68 const ::com::sun::star::uno::Type & rType, 69 Interface1 * p1, Interface2 * p2 ) 70 SAL_THROW( () ) 71 { 72 if (rType == Interface1::static_type()) 73 return ::com::sun::star::uno::Any( &p1, rType ); 74 else if (rType == Interface2::static_type()) 75 return ::com::sun::star::uno::Any( &p2, rType ); 76 else 77 return ::com::sun::star::uno::Any(); 78 } 79 /** Compares demanded type to given template argument types. 80 81 @tplparam Interface1 interface type 82 @tplparam Interface2 interface type 83 @tplparam Interface3 interface type 84 @param rType demanded type 85 @param p1 interface pointer 86 @param p2 interface pointer 87 @param p3 interface pointer 88 @return acquired interface of demanded type or empty Any 89 */ 90 template< class Interface1, class Interface2, class Interface3 > 91 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 92 const ::com::sun::star::uno::Type & rType, 93 Interface1 * p1, Interface2 * p2, Interface3 * p3 ) 94 SAL_THROW( () ) 95 { 96 if (rType == Interface1::static_type()) 97 return ::com::sun::star::uno::Any( &p1, rType ); 98 else if (rType == Interface2::static_type()) 99 return ::com::sun::star::uno::Any( &p2, rType ); 100 else if (rType == Interface3::static_type()) 101 return ::com::sun::star::uno::Any( &p3, rType ); 102 else 103 return ::com::sun::star::uno::Any(); 104 } 105 /** Compares demanded type to given template argument types. 106 107 @tplparam Interface1 interface type 108 @tplparam Interface2 interface type 109 @tplparam Interface3 interface type 110 @tplparam Interface4 interface type 111 @param rType demanded type 112 @param p1 interface pointer 113 @param p2 interface pointer 114 @param p3 interface pointer 115 @param p4 interface pointer 116 @return acquired interface of demanded type or empty Any 117 */ 118 template< class Interface1, class Interface2, class Interface3, class Interface4 > 119 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 120 const ::com::sun::star::uno::Type & rType, 121 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 ) 122 SAL_THROW( () ) 123 { 124 if (rType == Interface1::static_type()) 125 return ::com::sun::star::uno::Any( &p1, rType ); 126 else if (rType == Interface2::static_type()) 127 return ::com::sun::star::uno::Any( &p2, rType ); 128 else if (rType == Interface3::static_type()) 129 return ::com::sun::star::uno::Any( &p3, rType ); 130 else if (rType == Interface4::static_type()) 131 return ::com::sun::star::uno::Any( &p4, rType ); 132 else 133 return ::com::sun::star::uno::Any(); 134 } 135 /** Compares demanded type to given template argument types. 136 137 @tplparam Interface1 interface type 138 @tplparam Interface2 interface type 139 @tplparam Interface3 interface type 140 @tplparam Interface4 interface type 141 @tplparam Interface5 interface type 142 @param rType demanded type 143 @param p1 interface pointer 144 @param p2 interface pointer 145 @param p3 interface pointer 146 @param p4 interface pointer 147 @param p5 interface pointer 148 @return acquired interface of demanded type or empty Any 149 */ 150 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 > 151 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 152 const ::com::sun::star::uno::Type & rType, 153 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 ) 154 SAL_THROW( () ) 155 { 156 if (rType == Interface1::static_type()) 157 return ::com::sun::star::uno::Any( &p1, rType ); 158 else if (rType == Interface2::static_type()) 159 return ::com::sun::star::uno::Any( &p2, rType ); 160 else if (rType == Interface3::static_type()) 161 return ::com::sun::star::uno::Any( &p3, rType ); 162 else if (rType == Interface4::static_type()) 163 return ::com::sun::star::uno::Any( &p4, rType ); 164 else if (rType == Interface5::static_type()) 165 return ::com::sun::star::uno::Any( &p5, rType ); 166 else 167 return ::com::sun::star::uno::Any(); 168 } 169 /** Compares demanded type to given template argument types. 170 171 @tplparam Interface1 interface type 172 @tplparam Interface2 interface type 173 @tplparam Interface3 interface type 174 @tplparam Interface4 interface type 175 @tplparam Interface5 interface type 176 @tplparam Interface6 interface type 177 @param rType demanded type 178 @param p1 interface pointer 179 @param p2 interface pointer 180 @param p3 interface pointer 181 @param p4 interface pointer 182 @param p5 interface pointer 183 @param p6 interface pointer 184 @return acquired interface of demanded type or empty Any 185 */ 186 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, 187 class Interface6 > 188 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 189 const ::com::sun::star::uno::Type & rType, 190 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, 191 Interface6 * p6 ) 192 SAL_THROW( () ) 193 { 194 if (rType == Interface1::static_type()) 195 return ::com::sun::star::uno::Any( &p1, rType ); 196 else if (rType == Interface2::static_type()) 197 return ::com::sun::star::uno::Any( &p2, rType ); 198 else if (rType == Interface3::static_type()) 199 return ::com::sun::star::uno::Any( &p3, rType ); 200 else if (rType == Interface4::static_type()) 201 return ::com::sun::star::uno::Any( &p4, rType ); 202 else if (rType == Interface5::static_type()) 203 return ::com::sun::star::uno::Any( &p5, rType ); 204 else if (rType == Interface6::static_type()) 205 return ::com::sun::star::uno::Any( &p6, rType ); 206 else 207 return ::com::sun::star::uno::Any(); 208 } 209 /** Compares demanded type to given template argument types. 210 211 @tplparam Interface1 interface type 212 @tplparam Interface2 interface type 213 @tplparam Interface3 interface type 214 @tplparam Interface4 interface type 215 @tplparam Interface5 interface type 216 @tplparam Interface6 interface type 217 @tplparam Interface7 interface type 218 @param rType demanded type 219 @param p1 interface pointer 220 @param p2 interface pointer 221 @param p3 interface pointer 222 @param p4 interface pointer 223 @param p5 interface pointer 224 @param p6 interface pointer 225 @param p7 interface pointer 226 @return acquired interface of demanded type or empty Any 227 */ 228 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, 229 class Interface6, class Interface7 > 230 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 231 const ::com::sun::star::uno::Type & rType, 232 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, 233 Interface6 * p6, Interface7 * p7 ) 234 SAL_THROW( () ) 235 { 236 if (rType == Interface1::static_type()) 237 return ::com::sun::star::uno::Any( &p1, rType ); 238 else if (rType == Interface2::static_type()) 239 return ::com::sun::star::uno::Any( &p2, rType ); 240 else if (rType == Interface3::static_type()) 241 return ::com::sun::star::uno::Any( &p3, rType ); 242 else if (rType == Interface4::static_type()) 243 return ::com::sun::star::uno::Any( &p4, rType ); 244 else if (rType == Interface5::static_type()) 245 return ::com::sun::star::uno::Any( &p5, rType ); 246 else if (rType == Interface6::static_type()) 247 return ::com::sun::star::uno::Any( &p6, rType ); 248 else if (rType == Interface7::static_type()) 249 return ::com::sun::star::uno::Any( &p7, rType ); 250 else 251 return ::com::sun::star::uno::Any(); 252 } 253 /** Compares demanded type to given template argument types. 254 255 @tplparam Interface1 interface type 256 @tplparam Interface2 interface type 257 @tplparam Interface3 interface type 258 @tplparam Interface4 interface type 259 @tplparam Interface5 interface type 260 @tplparam Interface6 interface type 261 @tplparam Interface7 interface type 262 @tplparam Interface8 interface type 263 @param rType demanded type 264 @param p1 interface pointer 265 @param p2 interface pointer 266 @param p3 interface pointer 267 @param p4 interface pointer 268 @param p5 interface pointer 269 @param p6 interface pointer 270 @param p7 interface pointer 271 @param p8 interface pointer 272 @return acquired interface of demanded type or empty Any 273 */ 274 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, 275 class Interface6, class Interface7, class Interface8 > 276 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 277 const ::com::sun::star::uno::Type & rType, 278 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, 279 Interface6 * p6, Interface7 * p7, Interface8 * p8 ) 280 SAL_THROW( () ) 281 { 282 if (rType == Interface1::static_type()) 283 return ::com::sun::star::uno::Any( &p1, rType ); 284 else if (rType == Interface2::static_type()) 285 return ::com::sun::star::uno::Any( &p2, rType ); 286 else if (rType == Interface3::static_type()) 287 return ::com::sun::star::uno::Any( &p3, rType ); 288 else if (rType == Interface4::static_type()) 289 return ::com::sun::star::uno::Any( &p4, rType ); 290 else if (rType == Interface5::static_type()) 291 return ::com::sun::star::uno::Any( &p5, rType ); 292 else if (rType == Interface6::static_type()) 293 return ::com::sun::star::uno::Any( &p6, rType ); 294 else if (rType == Interface7::static_type()) 295 return ::com::sun::star::uno::Any( &p7, rType ); 296 else if (rType == Interface8::static_type()) 297 return ::com::sun::star::uno::Any( &p8, rType ); 298 else 299 return ::com::sun::star::uno::Any(); 300 } 301 /** Compares demanded type to given template argument types. 302 303 @tplparam Interface1 interface type 304 @tplparam Interface2 interface type 305 @tplparam Interface3 interface type 306 @tplparam Interface4 interface type 307 @tplparam Interface5 interface type 308 @tplparam Interface6 interface type 309 @tplparam Interface7 interface type 310 @tplparam Interface8 interface type 311 @tplparam Interface9 interface type 312 @param rType demanded type 313 @param p1 interface pointer 314 @param p2 interface pointer 315 @param p3 interface pointer 316 @param p4 interface pointer 317 @param p5 interface pointer 318 @param p6 interface pointer 319 @param p7 interface pointer 320 @param p8 interface pointer 321 @param p9 interface pointer 322 @return acquired interface of demanded type or empty Any 323 */ 324 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, 325 class Interface6, class Interface7, class Interface8, class Interface9 > 326 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 327 const ::com::sun::star::uno::Type & rType, 328 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, 329 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 ) 330 SAL_THROW( () ) 331 { 332 if (rType == Interface1::static_type()) 333 return ::com::sun::star::uno::Any( &p1, rType ); 334 else if (rType == Interface2::static_type()) 335 return ::com::sun::star::uno::Any( &p2, rType ); 336 else if (rType == Interface3::static_type()) 337 return ::com::sun::star::uno::Any( &p3, rType ); 338 else if (rType == Interface4::static_type()) 339 return ::com::sun::star::uno::Any( &p4, rType ); 340 else if (rType == Interface5::static_type()) 341 return ::com::sun::star::uno::Any( &p5, rType ); 342 else if (rType == Interface6::static_type()) 343 return ::com::sun::star::uno::Any( &p6, rType ); 344 else if (rType == Interface7::static_type()) 345 return ::com::sun::star::uno::Any( &p7, rType ); 346 else if (rType == Interface8::static_type()) 347 return ::com::sun::star::uno::Any( &p8, rType ); 348 else if (rType == Interface9::static_type()) 349 return ::com::sun::star::uno::Any( &p9, rType ); 350 else 351 return ::com::sun::star::uno::Any(); 352 } 353 /** Compares demanded type to given template argument types. 354 355 @tplparam Interface1 interface type 356 @tplparam Interface2 interface type 357 @tplparam Interface3 interface type 358 @tplparam Interface4 interface type 359 @tplparam Interface5 interface type 360 @tplparam Interface6 interface type 361 @tplparam Interface7 interface type 362 @tplparam Interface8 interface type 363 @tplparam Interface9 interface type 364 @tplparam Interface10 interface type 365 @param rType demanded type 366 @param p1 interface pointer 367 @param p2 interface pointer 368 @param p3 interface pointer 369 @param p4 interface pointer 370 @param p5 interface pointer 371 @param p6 interface pointer 372 @param p7 interface pointer 373 @param p8 interface pointer 374 @param p9 interface pointer 375 @param p10 interface pointer 376 @return acquired interface of demanded type or empty Any 377 */ 378 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, 379 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 > 380 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 381 const ::com::sun::star::uno::Type & rType, 382 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, 383 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 ) 384 SAL_THROW( () ) 385 { 386 if (rType == Interface1::static_type()) 387 return ::com::sun::star::uno::Any( &p1, rType ); 388 else if (rType == Interface2::static_type()) 389 return ::com::sun::star::uno::Any( &p2, rType ); 390 else if (rType == Interface3::static_type()) 391 return ::com::sun::star::uno::Any( &p3, rType ); 392 else if (rType == Interface4::static_type()) 393 return ::com::sun::star::uno::Any( &p4, rType ); 394 else if (rType == Interface5::static_type()) 395 return ::com::sun::star::uno::Any( &p5, rType ); 396 else if (rType == Interface6::static_type()) 397 return ::com::sun::star::uno::Any( &p6, rType ); 398 else if (rType == Interface7::static_type()) 399 return ::com::sun::star::uno::Any( &p7, rType ); 400 else if (rType == Interface8::static_type()) 401 return ::com::sun::star::uno::Any( &p8, rType ); 402 else if (rType == Interface9::static_type()) 403 return ::com::sun::star::uno::Any( &p9, rType ); 404 else if (rType == Interface10::static_type()) 405 return ::com::sun::star::uno::Any( &p10, rType ); 406 else 407 return ::com::sun::star::uno::Any(); 408 } 409 /** Compares demanded type to given template argument types. 410 411 @tplparam Interface1 interface type 412 @tplparam Interface2 interface type 413 @tplparam Interface3 interface type 414 @tplparam Interface4 interface type 415 @tplparam Interface5 interface type 416 @tplparam Interface6 interface type 417 @tplparam Interface7 interface type 418 @tplparam Interface8 interface type 419 @tplparam Interface9 interface type 420 @tplparam Interface10 interface type 421 @tplparam Interface11 interface type 422 @param rType demanded type 423 @param p1 interface pointer 424 @param p2 interface pointer 425 @param p3 interface pointer 426 @param p4 interface pointer 427 @param p5 interface pointer 428 @param p6 interface pointer 429 @param p7 interface pointer 430 @param p8 interface pointer 431 @param p9 interface pointer 432 @param p10 interface pointer 433 @param p11 interface pointer 434 @return acquired interface of demanded type or empty Any 435 */ 436 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, 437 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10, 438 class Interface11 > 439 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 440 const ::com::sun::star::uno::Type & rType, 441 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, 442 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10, 443 Interface11 * p11 ) 444 SAL_THROW( () ) 445 { 446 if (rType == Interface1::static_type()) 447 return ::com::sun::star::uno::Any( &p1, rType ); 448 else if (rType == Interface2::static_type()) 449 return ::com::sun::star::uno::Any( &p2, rType ); 450 else if (rType == Interface3::static_type()) 451 return ::com::sun::star::uno::Any( &p3, rType ); 452 else if (rType == Interface4::static_type()) 453 return ::com::sun::star::uno::Any( &p4, rType ); 454 else if (rType == Interface5::static_type()) 455 return ::com::sun::star::uno::Any( &p5, rType ); 456 else if (rType == Interface6::static_type()) 457 return ::com::sun::star::uno::Any( &p6, rType ); 458 else if (rType == Interface7::static_type()) 459 return ::com::sun::star::uno::Any( &p7, rType ); 460 else if (rType == Interface8::static_type()) 461 return ::com::sun::star::uno::Any( &p8, rType ); 462 else if (rType == Interface9::static_type()) 463 return ::com::sun::star::uno::Any( &p9, rType ); 464 else if (rType == Interface10::static_type()) 465 return ::com::sun::star::uno::Any( &p10, rType ); 466 else if (rType == Interface11::static_type()) 467 return ::com::sun::star::uno::Any( &p11, rType ); 468 else 469 return ::com::sun::star::uno::Any(); 470 } 471 /** Compares demanded type to given template argument types. 472 473 @tplparam Interface1 interface type 474 @tplparam Interface2 interface type 475 @tplparam Interface3 interface type 476 @tplparam Interface4 interface type 477 @tplparam Interface5 interface type 478 @tplparam Interface6 interface type 479 @tplparam Interface7 interface type 480 @tplparam Interface8 interface type 481 @tplparam Interface9 interface type 482 @tplparam Interface10 interface type 483 @tplparam Interface11 interface type 484 @tplparam Interface12 interface type 485 @param rType demanded type 486 @param p1 interface pointer 487 @param p2 interface pointer 488 @param p3 interface pointer 489 @param p4 interface pointer 490 @param p5 interface pointer 491 @param p6 interface pointer 492 @param p7 interface pointer 493 @param p8 interface pointer 494 @param p9 interface pointer 495 @param p10 interface pointer 496 @param p11 interface pointer 497 @param p12 interface pointer 498 @return acquired interface of demanded type or empty Any 499 */ 500 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, 501 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10, 502 class Interface11, class Interface12 > 503 inline ::com::sun::star::uno::Any SAL_CALL queryInterface( 504 const ::com::sun::star::uno::Type & rType, 505 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, 506 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10, 507 Interface11 * p11, Interface12 * p12 ) 508 SAL_THROW( () ) 509 { 510 if (rType == Interface1::static_type()) 511 return ::com::sun::star::uno::Any( &p1, rType ); 512 else if (rType == Interface2::static_type()) 513 return ::com::sun::star::uno::Any( &p2, rType ); 514 else if (rType == Interface3::static_type()) 515 return ::com::sun::star::uno::Any( &p3, rType ); 516 else if (rType == Interface4::static_type()) 517 return ::com::sun::star::uno::Any( &p4, rType ); 518 else if (rType == Interface5::static_type()) 519 return ::com::sun::star::uno::Any( &p5, rType ); 520 else if (rType == Interface6::static_type()) 521 return ::com::sun::star::uno::Any( &p6, rType ); 522 else if (rType == Interface7::static_type()) 523 return ::com::sun::star::uno::Any( &p7, rType ); 524 else if (rType == Interface8::static_type()) 525 return ::com::sun::star::uno::Any( &p8, rType ); 526 else if (rType == Interface9::static_type()) 527 return ::com::sun::star::uno::Any( &p9, rType ); 528 else if (rType == Interface10::static_type()) 529 return ::com::sun::star::uno::Any( &p10, rType ); 530 else if (rType == Interface11::static_type()) 531 return ::com::sun::star::uno::Any( &p11, rType ); 532 else if (rType == Interface12::static_type()) 533 return ::com::sun::star::uno::Any( &p12, rType ); 534 else 535 return ::com::sun::star::uno::Any(); 536 } 537 538 } 539 540 #endif 541 542