LibreOffice
LibreOffice 4.2 SDK 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  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_CPPUHELPER_QUERYINTERFACE_HXX
21 #define INCLUDED_CPPUHELPER_QUERYINTERFACE_HXX
22 
23 #include <sal/config.h>
24 #include <com/sun/star/uno/Any.hxx>
26 #include <sal/types.h>
27 
28 namespace cppu
29 {
30 
38 template< class Interface1 >
39 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
40  const ::com::sun::star::uno::Type & rType,
41  Interface1 * p1 )
42  SAL_THROW(())
43 {
44  if (rType == Interface1::static_type())
45  return ::com::sun::star::uno::Any( &p1, rType );
46  else
47  return ::com::sun::star::uno::Any();
48 }
58 template< class Interface1, class Interface2 >
59 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
60  const ::com::sun::star::uno::Type & rType,
61  Interface1 * p1, Interface2 * p2 )
62  SAL_THROW(())
63 {
64  if (rType == Interface1::static_type())
65  return ::com::sun::star::uno::Any( &p1, rType );
66  else if (rType == Interface2::static_type())
67  return ::com::sun::star::uno::Any( &p2, rType );
68  else
69  return ::com::sun::star::uno::Any();
70 }
82 template< class Interface1, class Interface2, class Interface3 >
83 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
84  const ::com::sun::star::uno::Type & rType,
85  Interface1 * p1, Interface2 * p2, Interface3 * p3 )
86  SAL_THROW(())
87 {
88  if (rType == Interface1::static_type())
89  return ::com::sun::star::uno::Any( &p1, rType );
90  else if (rType == Interface2::static_type())
91  return ::com::sun::star::uno::Any( &p2, rType );
92  else if (rType == Interface3::static_type())
93  return ::com::sun::star::uno::Any( &p3, rType );
94  else
95  return ::com::sun::star::uno::Any();
96 }
110 template< class Interface1, class Interface2, class Interface3, class Interface4 >
111 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
112  const ::com::sun::star::uno::Type & rType,
113  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 )
114  SAL_THROW(())
115 {
116  if (rType == Interface1::static_type())
117  return ::com::sun::star::uno::Any( &p1, rType );
118  else if (rType == Interface2::static_type())
119  return ::com::sun::star::uno::Any( &p2, rType );
120  else if (rType == Interface3::static_type())
121  return ::com::sun::star::uno::Any( &p3, rType );
122  else if (rType == Interface4::static_type())
123  return ::com::sun::star::uno::Any( &p4, rType );
124  else
125  return ::com::sun::star::uno::Any();
126 }
142 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 >
143 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
144  const ::com::sun::star::uno::Type & rType,
145  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 )
146  SAL_THROW(())
147 {
148  if (rType == Interface1::static_type())
149  return ::com::sun::star::uno::Any( &p1, rType );
150  else if (rType == Interface2::static_type())
151  return ::com::sun::star::uno::Any( &p2, rType );
152  else if (rType == Interface3::static_type())
153  return ::com::sun::star::uno::Any( &p3, rType );
154  else if (rType == Interface4::static_type())
155  return ::com::sun::star::uno::Any( &p4, rType );
156  else if (rType == Interface5::static_type())
157  return ::com::sun::star::uno::Any( &p5, rType );
158  else
159  return ::com::sun::star::uno::Any();
160 }
178 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
179  class Interface6 >
180 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
181  const ::com::sun::star::uno::Type & rType,
182  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
183  Interface6 * p6 )
184  SAL_THROW(())
185 {
186  if (rType == Interface1::static_type())
187  return ::com::sun::star::uno::Any( &p1, rType );
188  else if (rType == Interface2::static_type())
189  return ::com::sun::star::uno::Any( &p2, rType );
190  else if (rType == Interface3::static_type())
191  return ::com::sun::star::uno::Any( &p3, rType );
192  else if (rType == Interface4::static_type())
193  return ::com::sun::star::uno::Any( &p4, rType );
194  else if (rType == Interface5::static_type())
195  return ::com::sun::star::uno::Any( &p5, rType );
196  else if (rType == Interface6::static_type())
197  return ::com::sun::star::uno::Any( &p6, rType );
198  else
199  return ::com::sun::star::uno::Any();
200 }
220 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
221  class Interface6, class Interface7 >
222 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
223  const ::com::sun::star::uno::Type & rType,
224  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
225  Interface6 * p6, Interface7 * p7 )
226  SAL_THROW(())
227 {
228  if (rType == Interface1::static_type())
229  return ::com::sun::star::uno::Any( &p1, rType );
230  else if (rType == Interface2::static_type())
231  return ::com::sun::star::uno::Any( &p2, rType );
232  else if (rType == Interface3::static_type())
233  return ::com::sun::star::uno::Any( &p3, rType );
234  else if (rType == Interface4::static_type())
235  return ::com::sun::star::uno::Any( &p4, rType );
236  else if (rType == Interface5::static_type())
237  return ::com::sun::star::uno::Any( &p5, rType );
238  else if (rType == Interface6::static_type())
239  return ::com::sun::star::uno::Any( &p6, rType );
240  else if (rType == Interface7::static_type())
241  return ::com::sun::star::uno::Any( &p7, rType );
242  else
243  return ::com::sun::star::uno::Any();
244 }
266 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
267  class Interface6, class Interface7, class Interface8 >
268 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
269  const ::com::sun::star::uno::Type & rType,
270  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
271  Interface6 * p6, Interface7 * p7, Interface8 * p8 )
272  SAL_THROW(())
273 {
274  if (rType == Interface1::static_type())
275  return ::com::sun::star::uno::Any( &p1, rType );
276  else if (rType == Interface2::static_type())
277  return ::com::sun::star::uno::Any( &p2, rType );
278  else if (rType == Interface3::static_type())
279  return ::com::sun::star::uno::Any( &p3, rType );
280  else if (rType == Interface4::static_type())
281  return ::com::sun::star::uno::Any( &p4, rType );
282  else if (rType == Interface5::static_type())
283  return ::com::sun::star::uno::Any( &p5, rType );
284  else if (rType == Interface6::static_type())
285  return ::com::sun::star::uno::Any( &p6, rType );
286  else if (rType == Interface7::static_type())
287  return ::com::sun::star::uno::Any( &p7, rType );
288  else if (rType == Interface8::static_type())
289  return ::com::sun::star::uno::Any( &p8, rType );
290  else
291  return ::com::sun::star::uno::Any();
292 }
316 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
317  class Interface6, class Interface7, class Interface8, class Interface9 >
318 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
319  const ::com::sun::star::uno::Type & rType,
320  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
321  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 )
322  SAL_THROW(())
323 {
324  if (rType == Interface1::static_type())
325  return ::com::sun::star::uno::Any( &p1, rType );
326  else if (rType == Interface2::static_type())
327  return ::com::sun::star::uno::Any( &p2, rType );
328  else if (rType == Interface3::static_type())
329  return ::com::sun::star::uno::Any( &p3, rType );
330  else if (rType == Interface4::static_type())
331  return ::com::sun::star::uno::Any( &p4, rType );
332  else if (rType == Interface5::static_type())
333  return ::com::sun::star::uno::Any( &p5, rType );
334  else if (rType == Interface6::static_type())
335  return ::com::sun::star::uno::Any( &p6, rType );
336  else if (rType == Interface7::static_type())
337  return ::com::sun::star::uno::Any( &p7, rType );
338  else if (rType == Interface8::static_type())
339  return ::com::sun::star::uno::Any( &p8, rType );
340  else if (rType == Interface9::static_type())
341  return ::com::sun::star::uno::Any( &p9, rType );
342  else
343  return ::com::sun::star::uno::Any();
344 }
370 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
371  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 >
372 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
373  const ::com::sun::star::uno::Type & rType,
374  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
375  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 )
376  SAL_THROW(())
377 {
378  if (rType == Interface1::static_type())
379  return ::com::sun::star::uno::Any( &p1, rType );
380  else if (rType == Interface2::static_type())
381  return ::com::sun::star::uno::Any( &p2, rType );
382  else if (rType == Interface3::static_type())
383  return ::com::sun::star::uno::Any( &p3, rType );
384  else if (rType == Interface4::static_type())
385  return ::com::sun::star::uno::Any( &p4, rType );
386  else if (rType == Interface5::static_type())
387  return ::com::sun::star::uno::Any( &p5, rType );
388  else if (rType == Interface6::static_type())
389  return ::com::sun::star::uno::Any( &p6, rType );
390  else if (rType == Interface7::static_type())
391  return ::com::sun::star::uno::Any( &p7, rType );
392  else if (rType == Interface8::static_type())
393  return ::com::sun::star::uno::Any( &p8, rType );
394  else if (rType == Interface9::static_type())
395  return ::com::sun::star::uno::Any( &p9, rType );
396  else if (rType == Interface10::static_type())
397  return ::com::sun::star::uno::Any( &p10, rType );
398  else
399  return ::com::sun::star::uno::Any();
400 }
428 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
429  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
430  class Interface11 >
431 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
432  const ::com::sun::star::uno::Type & rType,
433  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
434  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
435  Interface11 * p11 )
436  SAL_THROW(())
437 {
438  if (rType == Interface1::static_type())
439  return ::com::sun::star::uno::Any( &p1, rType );
440  else if (rType == Interface2::static_type())
441  return ::com::sun::star::uno::Any( &p2, rType );
442  else if (rType == Interface3::static_type())
443  return ::com::sun::star::uno::Any( &p3, rType );
444  else if (rType == Interface4::static_type())
445  return ::com::sun::star::uno::Any( &p4, rType );
446  else if (rType == Interface5::static_type())
447  return ::com::sun::star::uno::Any( &p5, rType );
448  else if (rType == Interface6::static_type())
449  return ::com::sun::star::uno::Any( &p6, rType );
450  else if (rType == Interface7::static_type())
451  return ::com::sun::star::uno::Any( &p7, rType );
452  else if (rType == Interface8::static_type())
453  return ::com::sun::star::uno::Any( &p8, rType );
454  else if (rType == Interface9::static_type())
455  return ::com::sun::star::uno::Any( &p9, rType );
456  else if (rType == Interface10::static_type())
457  return ::com::sun::star::uno::Any( &p10, rType );
458  else if (rType == Interface11::static_type())
459  return ::com::sun::star::uno::Any( &p11, rType );
460  else
461  return ::com::sun::star::uno::Any();
462 }
492 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
493  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
494  class Interface11, class Interface12 >
495 inline ::com::sun::star::uno::Any SAL_CALL queryInterface(
496  const ::com::sun::star::uno::Type & rType,
497  Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
498  Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
499  Interface11 * p11, Interface12 * p12 )
500  SAL_THROW(())
501 {
502  if (rType == Interface1::static_type())
503  return ::com::sun::star::uno::Any( &p1, rType );
504  else if (rType == Interface2::static_type())
505  return ::com::sun::star::uno::Any( &p2, rType );
506  else if (rType == Interface3::static_type())
507  return ::com::sun::star::uno::Any( &p3, rType );
508  else if (rType == Interface4::static_type())
509  return ::com::sun::star::uno::Any( &p4, rType );
510  else if (rType == Interface5::static_type())
511  return ::com::sun::star::uno::Any( &p5, rType );
512  else if (rType == Interface6::static_type())
513  return ::com::sun::star::uno::Any( &p6, rType );
514  else if (rType == Interface7::static_type())
515  return ::com::sun::star::uno::Any( &p7, rType );
516  else if (rType == Interface8::static_type())
517  return ::com::sun::star::uno::Any( &p8, rType );
518  else if (rType == Interface9::static_type())
519  return ::com::sun::star::uno::Any( &p9, rType );
520  else if (rType == Interface10::static_type())
521  return ::com::sun::star::uno::Any( &p10, rType );
522  else if (rType == Interface11::static_type())
523  return ::com::sun::star::uno::Any( &p11, rType );
524  else if (rType == Interface12::static_type())
525  return ::com::sun::star::uno::Any( &p12, rType );
526  else
527  return ::com::sun::star::uno::Any();
528 }
529 
530 }
531 
532 #endif
533 
534 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
inline::com::sun::star::uno::Any queryInterface(const ::com::sun::star::uno::Type &rType, Interface1 *p1)
Compares demanded type to given template argument types.
Definition: queryinterface.hxx:39
#define SAL_THROW(exc)
Definition of function throw clause macros.
Definition: types.h:358