My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
queryinterface.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_
30 #define _CPPUHELPER_QUERYINTERFACE_HXX_
31 
32 #include "sal/config.h"
33 #include "com/sun/star/uno/Any.hxx"
35 #include "sal/types.h"
36 
37 namespace cppu
38 {
39 
47 template< class Interface1 >
48 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
49  const ::com::sun::star::uno::Type & rType,
50  Interface1 * p1 )
51  SAL_THROW(())
52 {
53  if (rType == Interface1::static_type())
54  return ::com::sun::star::uno::Any( &p1, rType );
55  else
56  return ::com::sun::star::uno::Any();
57 }
67 template< class Interface1, class Interface2 >
68 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
69  const ::com::sun::star::uno::Type & rType,
70  Interface1 * p1, Interface2 * p2 )
71  SAL_THROW(())
72 {
73  if (rType == Interface1::static_type())
74  return ::com::sun::star::uno::Any( &p1, rType );
75  else if (rType == Interface2::static_type())
76  return ::com::sun::star::uno::Any( &p2, rType );
77  else
78  return ::com::sun::star::uno::Any();
79 }
91 template< class Interface1, class Interface2, class Interface3 >
92 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
93  const ::com::sun::star::uno::Type & rType,
94  Interface1 * p1, Interface2 * p2, Interface3 * p3 )
95  SAL_THROW(())
96 {
97  if (rType == Interface1::static_type())
98  return ::com::sun::star::uno::Any( &p1, rType );
99  else if (rType == Interface2::static_type())
100  return ::com::sun::star::uno::Any( &p2, rType );
101  else if (rType == Interface3::static_type())
102  return ::com::sun::star::uno::Any( &p3, rType );
103  else
104  return ::com::sun::star::uno::Any();
105 }
119 template< class Interface1, class Interface2, class Interface3, class Interface4 >
120 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
121  const ::com::sun::star::uno::Type & rType,
122  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 )
123  SAL_THROW(())
124 {
125  if (rType == Interface1::static_type())
126  return ::com::sun::star::uno::Any( &p1, rType );
127  else if (rType == Interface2::static_type())
128  return ::com::sun::star::uno::Any( &p2, rType );
129  else if (rType == Interface3::static_type())
130  return ::com::sun::star::uno::Any( &p3, rType );
131  else if (rType == Interface4::static_type())
132  return ::com::sun::star::uno::Any( &p4, rType );
133  else
134  return ::com::sun::star::uno::Any();
135 }
151 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 >
152 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
153  const ::com::sun::star::uno::Type & rType,
154  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 )
155  SAL_THROW(())
156 {
157  if (rType == Interface1::static_type())
158  return ::com::sun::star::uno::Any( &p1, rType );
159  else if (rType == Interface2::static_type())
160  return ::com::sun::star::uno::Any( &p2, rType );
161  else if (rType == Interface3::static_type())
162  return ::com::sun::star::uno::Any( &p3, rType );
163  else if (rType == Interface4::static_type())
164  return ::com::sun::star::uno::Any( &p4, rType );
165  else if (rType == Interface5::static_type())
166  return ::com::sun::star::uno::Any( &p5, rType );
167  else
168  return ::com::sun::star::uno::Any();
169 }
187 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
188  class Interface6 >
189 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
190  const ::com::sun::star::uno::Type & rType,
191  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
192  Interface6 * p6 )
193  SAL_THROW(())
194 {
195  if (rType == Interface1::static_type())
196  return ::com::sun::star::uno::Any( &p1, rType );
197  else if (rType == Interface2::static_type())
198  return ::com::sun::star::uno::Any( &p2, rType );
199  else if (rType == Interface3::static_type())
200  return ::com::sun::star::uno::Any( &p3, rType );
201  else if (rType == Interface4::static_type())
202  return ::com::sun::star::uno::Any( &p4, rType );
203  else if (rType == Interface5::static_type())
204  return ::com::sun::star::uno::Any( &p5, rType );
205  else if (rType == Interface6::static_type())
206  return ::com::sun::star::uno::Any( &p6, rType );
207  else
208  return ::com::sun::star::uno::Any();
209 }
229 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
230  class Interface6, class Interface7 >
231 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
232  const ::com::sun::star::uno::Type & rType,
233  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
234  Interface6 * p6, Interface7 * p7 )
235  SAL_THROW(())
236 {
237  if (rType == Interface1::static_type())
238  return ::com::sun::star::uno::Any( &p1, rType );
239  else if (rType == Interface2::static_type())
240  return ::com::sun::star::uno::Any( &p2, rType );
241  else if (rType == Interface3::static_type())
242  return ::com::sun::star::uno::Any( &p3, rType );
243  else if (rType == Interface4::static_type())
244  return ::com::sun::star::uno::Any( &p4, rType );
245  else if (rType == Interface5::static_type())
246  return ::com::sun::star::uno::Any( &p5, rType );
247  else if (rType == Interface6::static_type())
248  return ::com::sun::star::uno::Any( &p6, rType );
249  else if (rType == Interface7::static_type())
250  return ::com::sun::star::uno::Any( &p7, rType );
251  else
252  return ::com::sun::star::uno::Any();
253 }
275 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
276  class Interface6, class Interface7, class Interface8 >
277 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
278  const ::com::sun::star::uno::Type & rType,
279  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
280  Interface6 * p6, Interface7 * p7, Interface8 * p8 )
281  SAL_THROW(())
282 {
283  if (rType == Interface1::static_type())
284  return ::com::sun::star::uno::Any( &p1, rType );
285  else if (rType == Interface2::static_type())
286  return ::com::sun::star::uno::Any( &p2, rType );
287  else if (rType == Interface3::static_type())
288  return ::com::sun::star::uno::Any( &p3, rType );
289  else if (rType == Interface4::static_type())
290  return ::com::sun::star::uno::Any( &p4, rType );
291  else if (rType == Interface5::static_type())
292  return ::com::sun::star::uno::Any( &p5, rType );
293  else if (rType == Interface6::static_type())
294  return ::com::sun::star::uno::Any( &p6, rType );
295  else if (rType == Interface7::static_type())
296  return ::com::sun::star::uno::Any( &p7, rType );
297  else if (rType == Interface8::static_type())
298  return ::com::sun::star::uno::Any( &p8, rType );
299  else
300  return ::com::sun::star::uno::Any();
301 }
325 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
326  class Interface6, class Interface7, class Interface8, class Interface9 >
327 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
328  const ::com::sun::star::uno::Type & rType,
329  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
330  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 )
331  SAL_THROW(())
332 {
333  if (rType == Interface1::static_type())
334  return ::com::sun::star::uno::Any( &p1, rType );
335  else if (rType == Interface2::static_type())
336  return ::com::sun::star::uno::Any( &p2, rType );
337  else if (rType == Interface3::static_type())
338  return ::com::sun::star::uno::Any( &p3, rType );
339  else if (rType == Interface4::static_type())
340  return ::com::sun::star::uno::Any( &p4, rType );
341  else if (rType == Interface5::static_type())
342  return ::com::sun::star::uno::Any( &p5, rType );
343  else if (rType == Interface6::static_type())
344  return ::com::sun::star::uno::Any( &p6, rType );
345  else if (rType == Interface7::static_type())
346  return ::com::sun::star::uno::Any( &p7, rType );
347  else if (rType == Interface8::static_type())
348  return ::com::sun::star::uno::Any( &p8, rType );
349  else if (rType == Interface9::static_type())
350  return ::com::sun::star::uno::Any( &p9, rType );
351  else
352  return ::com::sun::star::uno::Any();
353 }
379 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
380  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 >
381 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
382  const ::com::sun::star::uno::Type & rType,
383  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
384  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 )
385  SAL_THROW(())
386 {
387  if (rType == Interface1::static_type())
388  return ::com::sun::star::uno::Any( &p1, rType );
389  else if (rType == Interface2::static_type())
390  return ::com::sun::star::uno::Any( &p2, rType );
391  else if (rType == Interface3::static_type())
392  return ::com::sun::star::uno::Any( &p3, rType );
393  else if (rType == Interface4::static_type())
394  return ::com::sun::star::uno::Any( &p4, rType );
395  else if (rType == Interface5::static_type())
396  return ::com::sun::star::uno::Any( &p5, rType );
397  else if (rType == Interface6::static_type())
398  return ::com::sun::star::uno::Any( &p6, rType );
399  else if (rType == Interface7::static_type())
400  return ::com::sun::star::uno::Any( &p7, rType );
401  else if (rType == Interface8::static_type())
402  return ::com::sun::star::uno::Any( &p8, rType );
403  else if (rType == Interface9::static_type())
404  return ::com::sun::star::uno::Any( &p9, rType );
405  else if (rType == Interface10::static_type())
406  return ::com::sun::star::uno::Any( &p10, rType );
407  else
408  return ::com::sun::star::uno::Any();
409 }
437 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
438  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
439  class Interface11 >
440 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
441  const ::com::sun::star::uno::Type & rType,
442  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
443  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
444  Interface11 * p11 )
445  SAL_THROW(())
446 {
447  if (rType == Interface1::static_type())
448  return ::com::sun::star::uno::Any( &p1, rType );
449  else if (rType == Interface2::static_type())
450  return ::com::sun::star::uno::Any( &p2, rType );
451  else if (rType == Interface3::static_type())
452  return ::com::sun::star::uno::Any( &p3, rType );
453  else if (rType == Interface4::static_type())
454  return ::com::sun::star::uno::Any( &p4, rType );
455  else if (rType == Interface5::static_type())
456  return ::com::sun::star::uno::Any( &p5, rType );
457  else if (rType == Interface6::static_type())
458  return ::com::sun::star::uno::Any( &p6, rType );
459  else if (rType == Interface7::static_type())
460  return ::com::sun::star::uno::Any( &p7, rType );
461  else if (rType == Interface8::static_type())
462  return ::com::sun::star::uno::Any( &p8, rType );
463  else if (rType == Interface9::static_type())
464  return ::com::sun::star::uno::Any( &p9, rType );
465  else if (rType == Interface10::static_type())
466  return ::com::sun::star::uno::Any( &p10, rType );
467  else if (rType == Interface11::static_type())
468  return ::com::sun::star::uno::Any( &p11, rType );
469  else
470  return ::com::sun::star::uno::Any();
471 }
501 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
502  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
503  class Interface11, class Interface12 >
504 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
505  const ::com::sun::star::uno::Type & rType,
506  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
507  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
508  Interface11 * p11, Interface12 * p12 )
509  SAL_THROW(())
510 {
511  if (rType == Interface1::static_type())
512  return ::com::sun::star::uno::Any( &p1, rType );
513  else if (rType == Interface2::static_type())
514  return ::com::sun::star::uno::Any( &p2, rType );
515  else if (rType == Interface3::static_type())
516  return ::com::sun::star::uno::Any( &p3, rType );
517  else if (rType == Interface4::static_type())
518  return ::com::sun::star::uno::Any( &p4, rType );
519  else if (rType == Interface5::static_type())
520  return ::com::sun::star::uno::Any( &p5, rType );
521  else if (rType == Interface6::static_type())
522  return ::com::sun::star::uno::Any( &p6, rType );
523  else if (rType == Interface7::static_type())
524  return ::com::sun::star::uno::Any( &p7, rType );
525  else if (rType == Interface8::static_type())
526  return ::com::sun::star::uno::Any( &p8, rType );
527  else if (rType == Interface9::static_type())
528  return ::com::sun::star::uno::Any( &p9, rType );
529  else if (rType == Interface10::static_type())
530  return ::com::sun::star::uno::Any( &p10, rType );
531  else if (rType == Interface11::static_type())
532  return ::com::sun::star::uno::Any( &p11, rType );
533  else if (rType == Interface12::static_type())
534  return ::com::sun::star::uno::Any( &p12, rType );
535  else
536  return ::com::sun::star::uno::Any();
537 }
538 
539 }
540 
541 #endif
542 
543 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */