Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / cppuhelper / queryinterface.hxx
blobdf9c9916cf8e179e5a590af1aba6cb4e7a4d5690
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 .
21 * This file is part of LibreOffice published API.
24 #ifndef INCLUDED_CPPUHELPER_QUERYINTERFACE_HXX
25 #define INCLUDED_CPPUHELPER_QUERYINTERFACE_HXX
27 #include "sal/config.h"
28 #include "com/sun/star/uno/Any.hxx"
29 #include "com/sun/star/uno/Type.h"
30 #include "sal/types.h"
32 namespace cppu
35 /** Compares demanded type to given template argument types.
37 @tparam Interface1 interface type
38 @param rType demanded type
39 @param p1 interface pointer
40 @return acquired interface of demanded type or empty Any
42 template< class Interface1 >
43 inline css::uno::Any SAL_CALL queryInterface(
44 const css::uno::Type & rType,
45 Interface1 * p1 )
47 if (rType == Interface1::static_type())
48 return css::uno::Any( &p1, rType );
49 else
50 return css::uno::Any();
52 /** Compares demanded type to given template argument types.
54 @tparam Interface1 interface type
55 @tparam Interface2 interface type
56 @param rType demanded type
57 @param p1 interface pointer
58 @param p2 interface pointer
59 @return acquired interface of demanded type or empty Any
61 template< class Interface1, class Interface2 >
62 inline css::uno::Any SAL_CALL queryInterface(
63 const css::uno::Type & rType,
64 Interface1 * p1, Interface2 * p2 )
66 if (rType == Interface1::static_type())
67 return css::uno::Any( &p1, rType );
68 else if (rType == Interface2::static_type())
69 return css::uno::Any( &p2, rType );
70 else
71 return css::uno::Any();
73 /** Compares demanded type to given template argument types.
75 @tparam Interface1 interface type
76 @tparam Interface2 interface type
77 @tparam Interface3 interface type
78 @param rType demanded type
79 @param p1 interface pointer
80 @param p2 interface pointer
81 @param p3 interface pointer
82 @return acquired interface of demanded type or empty Any
84 template< class Interface1, class Interface2, class Interface3 >
85 inline css::uno::Any SAL_CALL queryInterface(
86 const css::uno::Type & rType,
87 Interface1 * p1, Interface2 * p2, Interface3 * p3 )
89 if (rType == Interface1::static_type())
90 return css::uno::Any( &p1, rType );
91 else if (rType == Interface2::static_type())
92 return css::uno::Any( &p2, rType );
93 else if (rType == Interface3::static_type())
94 return css::uno::Any( &p3, rType );
95 else
96 return css::uno::Any();
98 /** Compares demanded type to given template argument types.
100 @tparam Interface1 interface type
101 @tparam Interface2 interface type
102 @tparam Interface3 interface type
103 @tparam Interface4 interface type
104 @param rType demanded type
105 @param p1 interface pointer
106 @param p2 interface pointer
107 @param p3 interface pointer
108 @param p4 interface pointer
109 @return acquired interface of demanded type or empty Any
111 template< class Interface1, class Interface2, class Interface3, class Interface4 >
112 inline css::uno::Any SAL_CALL queryInterface(
113 const css::uno::Type & rType,
114 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 )
116 if (rType == Interface1::static_type())
117 return css::uno::Any( &p1, rType );
118 else if (rType == Interface2::static_type())
119 return css::uno::Any( &p2, rType );
120 else if (rType == Interface3::static_type())
121 return css::uno::Any( &p3, rType );
122 else if (rType == Interface4::static_type())
123 return css::uno::Any( &p4, rType );
124 else
125 return css::uno::Any();
127 /** Compares demanded type to given template argument types.
129 @tparam Interface1 interface type
130 @tparam Interface2 interface type
131 @tparam Interface3 interface type
132 @tparam Interface4 interface type
133 @tparam Interface5 interface type
134 @param rType demanded type
135 @param p1 interface pointer
136 @param p2 interface pointer
137 @param p3 interface pointer
138 @param p4 interface pointer
139 @param p5 interface pointer
140 @return acquired interface of demanded type or empty Any
142 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 >
143 inline css::uno::Any SAL_CALL queryInterface(
144 const css::uno::Type & rType,
145 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 )
147 if (rType == Interface1::static_type())
148 return css::uno::Any( &p1, rType );
149 else if (rType == Interface2::static_type())
150 return css::uno::Any( &p2, rType );
151 else if (rType == Interface3::static_type())
152 return css::uno::Any( &p3, rType );
153 else if (rType == Interface4::static_type())
154 return css::uno::Any( &p4, rType );
155 else if (rType == Interface5::static_type())
156 return css::uno::Any( &p5, rType );
157 else
158 return css::uno::Any();
160 /** Compares demanded type to given template argument types.
162 @tparam Interface1 interface type
163 @tparam Interface2 interface type
164 @tparam Interface3 interface type
165 @tparam Interface4 interface type
166 @tparam Interface5 interface type
167 @tparam Interface6 interface type
168 @param rType demanded type
169 @param p1 interface pointer
170 @param p2 interface pointer
171 @param p3 interface pointer
172 @param p4 interface pointer
173 @param p5 interface pointer
174 @param p6 interface pointer
175 @return acquired interface of demanded type or empty Any
177 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
178 class Interface6 >
179 inline css::uno::Any SAL_CALL queryInterface(
180 const css::uno::Type & rType,
181 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
182 Interface6 * p6 )
184 if (rType == Interface1::static_type())
185 return css::uno::Any( &p1, rType );
186 else if (rType == Interface2::static_type())
187 return css::uno::Any( &p2, rType );
188 else if (rType == Interface3::static_type())
189 return css::uno::Any( &p3, rType );
190 else if (rType == Interface4::static_type())
191 return css::uno::Any( &p4, rType );
192 else if (rType == Interface5::static_type())
193 return css::uno::Any( &p5, rType );
194 else if (rType == Interface6::static_type())
195 return css::uno::Any( &p6, rType );
196 else
197 return css::uno::Any();
199 /** Compares demanded type to given template argument types.
201 @tparam Interface1 interface type
202 @tparam Interface2 interface type
203 @tparam Interface3 interface type
204 @tparam Interface4 interface type
205 @tparam Interface5 interface type
206 @tparam Interface6 interface type
207 @tparam Interface7 interface type
208 @param rType demanded type
209 @param p1 interface pointer
210 @param p2 interface pointer
211 @param p3 interface pointer
212 @param p4 interface pointer
213 @param p5 interface pointer
214 @param p6 interface pointer
215 @param p7 interface pointer
216 @return acquired interface of demanded type or empty Any
218 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
219 class Interface6, class Interface7 >
220 inline css::uno::Any SAL_CALL queryInterface(
221 const css::uno::Type & rType,
222 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
223 Interface6 * p6, Interface7 * p7 )
225 if (rType == Interface1::static_type())
226 return css::uno::Any( &p1, rType );
227 else if (rType == Interface2::static_type())
228 return css::uno::Any( &p2, rType );
229 else if (rType == Interface3::static_type())
230 return css::uno::Any( &p3, rType );
231 else if (rType == Interface4::static_type())
232 return css::uno::Any( &p4, rType );
233 else if (rType == Interface5::static_type())
234 return css::uno::Any( &p5, rType );
235 else if (rType == Interface6::static_type())
236 return css::uno::Any( &p6, rType );
237 else if (rType == Interface7::static_type())
238 return css::uno::Any( &p7, rType );
239 else
240 return css::uno::Any();
242 /** Compares demanded type to given template argument types.
244 @tparam Interface1 interface type
245 @tparam Interface2 interface type
246 @tparam Interface3 interface type
247 @tparam Interface4 interface type
248 @tparam Interface5 interface type
249 @tparam Interface6 interface type
250 @tparam Interface7 interface type
251 @tparam Interface8 interface type
252 @param rType demanded type
253 @param p1 interface pointer
254 @param p2 interface pointer
255 @param p3 interface pointer
256 @param p4 interface pointer
257 @param p5 interface pointer
258 @param p6 interface pointer
259 @param p7 interface pointer
260 @param p8 interface pointer
261 @return acquired interface of demanded type or empty Any
263 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
264 class Interface6, class Interface7, class Interface8 >
265 inline css::uno::Any SAL_CALL queryInterface(
266 const css::uno::Type & rType,
267 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
268 Interface6 * p6, Interface7 * p7, Interface8 * p8 )
270 if (rType == Interface1::static_type())
271 return css::uno::Any( &p1, rType );
272 else if (rType == Interface2::static_type())
273 return css::uno::Any( &p2, rType );
274 else if (rType == Interface3::static_type())
275 return css::uno::Any( &p3, rType );
276 else if (rType == Interface4::static_type())
277 return css::uno::Any( &p4, rType );
278 else if (rType == Interface5::static_type())
279 return css::uno::Any( &p5, rType );
280 else if (rType == Interface6::static_type())
281 return css::uno::Any( &p6, rType );
282 else if (rType == Interface7::static_type())
283 return css::uno::Any( &p7, rType );
284 else if (rType == Interface8::static_type())
285 return css::uno::Any( &p8, rType );
286 else
287 return css::uno::Any();
289 /** Compares demanded type to given template argument types.
291 @tparam Interface1 interface type
292 @tparam Interface2 interface type
293 @tparam Interface3 interface type
294 @tparam Interface4 interface type
295 @tparam Interface5 interface type
296 @tparam Interface6 interface type
297 @tparam Interface7 interface type
298 @tparam Interface8 interface type
299 @tparam Interface9 interface type
300 @param rType demanded type
301 @param p1 interface pointer
302 @param p2 interface pointer
303 @param p3 interface pointer
304 @param p4 interface pointer
305 @param p5 interface pointer
306 @param p6 interface pointer
307 @param p7 interface pointer
308 @param p8 interface pointer
309 @param p9 interface pointer
310 @return acquired interface of demanded type or empty Any
312 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
313 class Interface6, class Interface7, class Interface8, class Interface9 >
314 inline css::uno::Any SAL_CALL queryInterface(
315 const css::uno::Type & rType,
316 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
317 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 )
319 if (rType == Interface1::static_type())
320 return css::uno::Any( &p1, rType );
321 else if (rType == Interface2::static_type())
322 return css::uno::Any( &p2, rType );
323 else if (rType == Interface3::static_type())
324 return css::uno::Any( &p3, rType );
325 else if (rType == Interface4::static_type())
326 return css::uno::Any( &p4, rType );
327 else if (rType == Interface5::static_type())
328 return css::uno::Any( &p5, rType );
329 else if (rType == Interface6::static_type())
330 return css::uno::Any( &p6, rType );
331 else if (rType == Interface7::static_type())
332 return css::uno::Any( &p7, rType );
333 else if (rType == Interface8::static_type())
334 return css::uno::Any( &p8, rType );
335 else if (rType == Interface9::static_type())
336 return css::uno::Any( &p9, rType );
337 else
338 return css::uno::Any();
340 /** Compares demanded type to given template argument types.
342 @tparam Interface1 interface type
343 @tparam Interface2 interface type
344 @tparam Interface3 interface type
345 @tparam Interface4 interface type
346 @tparam Interface5 interface type
347 @tparam Interface6 interface type
348 @tparam Interface7 interface type
349 @tparam Interface8 interface type
350 @tparam Interface9 interface type
351 @tparam Interface10 interface type
352 @param rType demanded type
353 @param p1 interface pointer
354 @param p2 interface pointer
355 @param p3 interface pointer
356 @param p4 interface pointer
357 @param p5 interface pointer
358 @param p6 interface pointer
359 @param p7 interface pointer
360 @param p8 interface pointer
361 @param p9 interface pointer
362 @param p10 interface pointer
363 @return acquired interface of demanded type or empty Any
365 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
366 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 >
367 inline css::uno::Any SAL_CALL queryInterface(
368 const css::uno::Type & rType,
369 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
370 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 )
372 if (rType == Interface1::static_type())
373 return css::uno::Any( &p1, rType );
374 else if (rType == Interface2::static_type())
375 return css::uno::Any( &p2, rType );
376 else if (rType == Interface3::static_type())
377 return css::uno::Any( &p3, rType );
378 else if (rType == Interface4::static_type())
379 return css::uno::Any( &p4, rType );
380 else if (rType == Interface5::static_type())
381 return css::uno::Any( &p5, rType );
382 else if (rType == Interface6::static_type())
383 return css::uno::Any( &p6, rType );
384 else if (rType == Interface7::static_type())
385 return css::uno::Any( &p7, rType );
386 else if (rType == Interface8::static_type())
387 return css::uno::Any( &p8, rType );
388 else if (rType == Interface9::static_type())
389 return css::uno::Any( &p9, rType );
390 else if (rType == Interface10::static_type())
391 return css::uno::Any( &p10, rType );
392 else
393 return css::uno::Any();
395 /** Compares demanded type to given template argument types.
397 @tparam Interface1 interface type
398 @tparam Interface2 interface type
399 @tparam Interface3 interface type
400 @tparam Interface4 interface type
401 @tparam Interface5 interface type
402 @tparam Interface6 interface type
403 @tparam Interface7 interface type
404 @tparam Interface8 interface type
405 @tparam Interface9 interface type
406 @tparam Interface10 interface type
407 @tparam Interface11 interface type
408 @param rType demanded type
409 @param p1 interface pointer
410 @param p2 interface pointer
411 @param p3 interface pointer
412 @param p4 interface pointer
413 @param p5 interface pointer
414 @param p6 interface pointer
415 @param p7 interface pointer
416 @param p8 interface pointer
417 @param p9 interface pointer
418 @param p10 interface pointer
419 @param p11 interface pointer
420 @return acquired interface of demanded type or empty Any
422 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
423 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
424 class Interface11 >
425 inline css::uno::Any SAL_CALL queryInterface(
426 const css::uno::Type & rType,
427 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
428 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
429 Interface11 * p11 )
431 if (rType == Interface1::static_type())
432 return css::uno::Any( &p1, rType );
433 else if (rType == Interface2::static_type())
434 return css::uno::Any( &p2, rType );
435 else if (rType == Interface3::static_type())
436 return css::uno::Any( &p3, rType );
437 else if (rType == Interface4::static_type())
438 return css::uno::Any( &p4, rType );
439 else if (rType == Interface5::static_type())
440 return css::uno::Any( &p5, rType );
441 else if (rType == Interface6::static_type())
442 return css::uno::Any( &p6, rType );
443 else if (rType == Interface7::static_type())
444 return css::uno::Any( &p7, rType );
445 else if (rType == Interface8::static_type())
446 return css::uno::Any( &p8, rType );
447 else if (rType == Interface9::static_type())
448 return css::uno::Any( &p9, rType );
449 else if (rType == Interface10::static_type())
450 return css::uno::Any( &p10, rType );
451 else if (rType == Interface11::static_type())
452 return css::uno::Any( &p11, rType );
453 else
454 return css::uno::Any();
456 /** Compares demanded type to given template argument types.
458 @tparam Interface1 interface type
459 @tparam Interface2 interface type
460 @tparam Interface3 interface type
461 @tparam Interface4 interface type
462 @tparam Interface5 interface type
463 @tparam Interface6 interface type
464 @tparam Interface7 interface type
465 @tparam Interface8 interface type
466 @tparam Interface9 interface type
467 @tparam Interface10 interface type
468 @tparam Interface11 interface type
469 @tparam Interface12 interface type
470 @param rType demanded type
471 @param p1 interface pointer
472 @param p2 interface pointer
473 @param p3 interface pointer
474 @param p4 interface pointer
475 @param p5 interface pointer
476 @param p6 interface pointer
477 @param p7 interface pointer
478 @param p8 interface pointer
479 @param p9 interface pointer
480 @param p10 interface pointer
481 @param p11 interface pointer
482 @param p12 interface pointer
483 @return acquired interface of demanded type or empty Any
485 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
486 class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
487 class Interface11, class Interface12 >
488 inline css::uno::Any SAL_CALL queryInterface(
489 const css::uno::Type & rType,
490 Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
491 Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
492 Interface11 * p11, Interface12 * p12 )
494 if (rType == Interface1::static_type())
495 return css::uno::Any( &p1, rType );
496 else if (rType == Interface2::static_type())
497 return css::uno::Any( &p2, rType );
498 else if (rType == Interface3::static_type())
499 return css::uno::Any( &p3, rType );
500 else if (rType == Interface4::static_type())
501 return css::uno::Any( &p4, rType );
502 else if (rType == Interface5::static_type())
503 return css::uno::Any( &p5, rType );
504 else if (rType == Interface6::static_type())
505 return css::uno::Any( &p6, rType );
506 else if (rType == Interface7::static_type())
507 return css::uno::Any( &p7, rType );
508 else if (rType == Interface8::static_type())
509 return css::uno::Any( &p8, rType );
510 else if (rType == Interface9::static_type())
511 return css::uno::Any( &p9, rType );
512 else if (rType == Interface10::static_type())
513 return css::uno::Any( &p10, rType );
514 else if (rType == Interface11::static_type())
515 return css::uno::Any( &p11, rType );
516 else if (rType == Interface12::static_type())
517 return css::uno::Any( &p12, rType );
518 else
519 return css::uno::Any();
524 #endif
526 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */