xref: /trunk/main/unotools/inc/unotools/querydeep.hxx (revision bae3752e)
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 _UNOTOOLS_QUERYDEEPINTERFACE_HXX
25 #define _UNOTOOLS_QUERYDEEPINTERFACE_HXX
26 
27 #include <com/sun/star/uno/XInterface.hpp>
28 #include <com/sun/star/uno/Reference.hxx>
29 #include <com/sun/star/uno/Type.hxx>
30 
31 /** */ //for docpp
32 namespace utl
33 {
34 
35 //--------------------------------------------------------------------------------------------------------
36 /**
37  * Inspect interfaces types whether they are related by inheritance.
38  *<BR>
39  * @return		true if rType is derived from rBaseType
40  * @param		rBaseType	a <type>Type</type> of an interface.
41  * @param		rType		a <type>Type</type> of an interface.
42  */
43 sal_Bool isDerivedFrom(
44 	const ::com::sun::star::uno::Type & rBaseType,
45 	const ::com::sun::star::uno::Type & rType );
46 
47 //--------------------------------------------------------------------------------------------------------
48 /**
49  * Inspect interface types whether they are related by inheritance.
50  *<BR>
51  * @return		true if p is of a type derived from rBaseType
52  * @param		rBaseType	a <type>Type</type> of an interface.
53  * @param		p			a pointer to an interface.
54  */
55 template <class Interface>
isDerivedFrom(const::com::sun::star::uno::Type & rBaseType,Interface *)56 inline sal_Bool isDerivedFrom(
57 	const ::com::sun::star::uno::Type& rBaseType,
58 	Interface* /*p*/)
59 {
60 	return isDerivedFrom(
61 				rBaseType,
62 				::getCppuType(static_cast<const ::com::sun::star::uno::Reference<Interface> *>(0)));
63 }
64 
65 //--------------------------------------------------------------------------------------------------------
66 // possible optimization ?
67 //	Any aRet(::cppu::queryInterface(rType, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12));
68 //	if (aRet.hasValue())
69 //		return aRet;
70 
71 /**
72  * Inspect types and choose return proper interface.
73  *<BR>
74  * @param		p1		a pointer to an interface.
75  */
76 template< class Interface1 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1)77 inline ::com::sun::star::uno::Any queryDeepInterface(
78 	const ::com::sun::star::uno::Type & rType,
79 	Interface1 * p1 )
80 {
81 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
82 		return ::com::sun::star::uno::Any( &p1, rType );
83 	else
84 		return ::com::sun::star::uno::Any();
85 }
86 
87 /**
88  * Inspect types and choose return proper interface.
89  *<BR>
90  * @param		p1		a pointer to an interface.
91  * @param		p2		a pointer to an interface.
92  */
93 template< class Interface1, class Interface2 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2)94 inline ::com::sun::star::uno::Any queryDeepInterface(
95 	const ::com::sun::star::uno::Type & rType,
96 	Interface1 * p1, Interface2 * p2 )
97 {
98 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
99 		return ::com::sun::star::uno::Any( &p1, rType );
100 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
101 		return ::com::sun::star::uno::Any( &p2, rType );
102 	else
103 		return ::com::sun::star::uno::Any();
104 }
105 
106 /**
107  * Inspect types and choose return proper interface.
108  *<BR>
109  * @param		p1		a pointer to an interface.
110  * @param		p2		a pointer to an interface.
111  * @param		p3		a pointer to an interface.
112  */
113 template< class Interface1, class Interface2, class Interface3 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3)114 inline ::com::sun::star::uno::Any queryDeepInterface(
115 	const ::com::sun::star::uno::Type & rType,
116 	Interface1 * p1, Interface2 * p2, Interface3 * p3 )
117 {
118 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
119 		return ::com::sun::star::uno::Any( &p1, rType );
120 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
121 		return ::com::sun::star::uno::Any( &p2, rType );
122 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
123 		return ::com::sun::star::uno::Any( &p3, rType );
124 	else
125 		return ::com::sun::star::uno::Any();
126 }
127 
128 /**
129  * Inspect types and choose return proper interface.
130  *<BR>
131  * @param		p1		a pointer to an interface.
132  * @param		p2		a pointer to an interface.
133  * @param		p3		a pointer to an interface.
134  * @param		p4		a pointer to an interface.
135  */
136 template< class Interface1, class Interface2, class Interface3, class Interface4 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4)137 inline ::com::sun::star::uno::Any queryDeepInterface(
138 	const ::com::sun::star::uno::Type & rType,
139 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 )
140 {
141 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
142 		return ::com::sun::star::uno::Any( &p1, rType );
143 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
144 		return ::com::sun::star::uno::Any( &p2, rType );
145 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
146 		return ::com::sun::star::uno::Any( &p3, rType );
147 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
148 		return ::com::sun::star::uno::Any( &p4, rType );
149 	else
150 		return ::com::sun::star::uno::Any();
151 }
152 
153 /**
154  * Inspect types and choose return proper interface.
155  *<BR>
156  * @param		p1		a pointer to an interface.
157  * @param		p2		a pointer to an interface.
158  * @param		p3		a pointer to an interface.
159  * @param		p4		a pointer to an interface.
160  * @param		p5		a pointer to an interface.
161  */
162 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5)163 inline ::com::sun::star::uno::Any queryDeepInterface(
164 	const ::com::sun::star::uno::Type & rType,
165 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 )
166 {
167 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
168 		return ::com::sun::star::uno::Any( &p1, rType );
169 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
170 		return ::com::sun::star::uno::Any( &p2, rType );
171 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
172 		return ::com::sun::star::uno::Any( &p3, rType );
173 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
174 		return ::com::sun::star::uno::Any( &p4, rType );
175 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
176 		return ::com::sun::star::uno::Any( &p5, rType );
177 	else
178 		return ::com::sun::star::uno::Any();
179 }
180 
181 /**
182  * Inspect types and choose return proper interface.
183  *<BR>
184  * @param		p1		a pointer to an interface.
185  * @param		p2		a pointer to an interface.
186  * @param		p3		a pointer to an interface.
187  * @param		p4		a pointer to an interface.
188  * @param		p5		a pointer to an interface.
189  * @param		p6		a pointer to an interface.
190  */
191 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
192 		  class Interface6 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5,Interface6 * p6)193 inline ::com::sun::star::uno::Any queryDeepInterface(
194 	const ::com::sun::star::uno::Type & rType,
195 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
196 	Interface6 * p6 )
197 {
198 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
199 		return ::com::sun::star::uno::Any( &p1, rType );
200 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
201 		return ::com::sun::star::uno::Any( &p2, rType );
202 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
203 		return ::com::sun::star::uno::Any( &p3, rType );
204 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
205 		return ::com::sun::star::uno::Any( &p4, rType );
206 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
207 		return ::com::sun::star::uno::Any( &p5, rType );
208 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface6 > *>(0))))
209 		return ::com::sun::star::uno::Any( &p6, rType );
210 	else
211 		return ::com::sun::star::uno::Any();
212 }
213 
214 /**
215  * Inspect types and choose return proper interface.
216  *<BR>
217  * @param		p1		a pointer to an interface.
218  * @param		p2		a pointer to an interface.
219  * @param		p3		a pointer to an interface.
220  * @param		p4		a pointer to an interface.
221  * @param		p5		a pointer to an interface.
222  * @param		p6		a pointer to an interface.
223  * @param		p7		a pointer to an interface.
224  */
225 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
226 		  class Interface6, class Interface7 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5,Interface6 * p6,Interface7 * p7)227 inline ::com::sun::star::uno::Any queryDeepInterface(
228 	const ::com::sun::star::uno::Type & rType,
229 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
230 	Interface6 * p6, Interface7 * p7 )
231 {
232 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
233 		return ::com::sun::star::uno::Any( &p1, rType );
234 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
235 		return ::com::sun::star::uno::Any( &p2, rType );
236 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
237 		return ::com::sun::star::uno::Any( &p3, rType );
238 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
239 		return ::com::sun::star::uno::Any( &p4, rType );
240 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
241 		return ::com::sun::star::uno::Any( &p5, rType );
242 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface6 > *>(0))))
243 		return ::com::sun::star::uno::Any( &p6, rType );
244 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface7 > *>(0))))
245 		return ::com::sun::star::uno::Any( &p7, rType );
246 	else
247 		return ::com::sun::star::uno::Any();
248 }
249 
250 /**
251  * Inspect types and choose return proper interface.
252  *<BR>
253  * @param		p1		a pointer to an interface.
254  * @param		p2		a pointer to an interface.
255  * @param		p3		a pointer to an interface.
256  * @param		p4		a pointer to an interface.
257  * @param		p5		a pointer to an interface.
258  * @param		p6		a pointer to an interface.
259  * @param		p7		a pointer to an interface.
260  * @param		p8		a pointer to an interface.
261  */
262 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
263 		  class Interface6, class Interface7, class Interface8 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5,Interface6 * p6,Interface7 * p7,Interface8 * p8)264 inline ::com::sun::star::uno::Any queryDeepInterface(
265 	const ::com::sun::star::uno::Type & rType,
266 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
267 	Interface6 * p6, Interface7 * p7, Interface8 * p8 )
268 {
269 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
270 		return ::com::sun::star::uno::Any( &p1, rType );
271 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
272 		return ::com::sun::star::uno::Any( &p2, rType );
273 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
274 		return ::com::sun::star::uno::Any( &p3, rType );
275 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
276 		return ::com::sun::star::uno::Any( &p4, rType );
277 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
278 		return ::com::sun::star::uno::Any( &p5, rType );
279 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface6 > *>(0))))
280 		return ::com::sun::star::uno::Any( &p6, rType );
281 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface7 > *>(0))))
282 		return ::com::sun::star::uno::Any( &p7, rType );
283 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface8 > *>(0))))
284 		return ::com::sun::star::uno::Any( &p8, rType );
285 	else
286 		return ::com::sun::star::uno::Any();
287 }
288 
289 /**
290  * Inspect types and choose return proper interface.
291  *<BR>
292  * @param		p1		a pointer to an interface.
293  * @param		p2		a pointer to an interface.
294  * @param		p3		a pointer to an interface.
295  * @param		p4		a pointer to an interface.
296  * @param		p5		a pointer to an interface.
297  * @param		p6		a pointer to an interface.
298  * @param		p7		a pointer to an interface.
299  * @param		p8		a pointer to an interface.
300  * @param		p9		a pointer to an interface.
301  */
302 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
303 		  class Interface6, class Interface7, class Interface8, class Interface9 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5,Interface6 * p6,Interface7 * p7,Interface8 * p8,Interface9 * p9)304 inline ::com::sun::star::uno::Any queryDeepInterface(
305 	const ::com::sun::star::uno::Type & rType,
306 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
307 	Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 )
308 {
309 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
310 		return ::com::sun::star::uno::Any( &p1, rType );
311 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
312 		return ::com::sun::star::uno::Any( &p2, rType );
313 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
314 		return ::com::sun::star::uno::Any( &p3, rType );
315 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
316 		return ::com::sun::star::uno::Any( &p4, rType );
317 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
318 		return ::com::sun::star::uno::Any( &p5, rType );
319 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface6 > *>(0))))
320 		return ::com::sun::star::uno::Any( &p6, rType );
321 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface7 > *>(0))))
322 		return ::com::sun::star::uno::Any( &p7, rType );
323 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface8 > *>(0))))
324 		return ::com::sun::star::uno::Any( &p8, rType );
325 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface9 > *>(0))))
326 		return ::com::sun::star::uno::Any( &p9, rType );
327 	else
328 		return ::com::sun::star::uno::Any();
329 }
330 
331 /**
332  * Inspect types and choose return proper interface.
333  *<BR>
334  * @param		p1		a pointer to an interface.
335  * @param		p2		a pointer to an interface.
336  * @param		p3		a pointer to an interface.
337  * @param		p4		a pointer to an interface.
338  * @param		p5		a pointer to an interface.
339  * @param		p6		a pointer to an interface.
340  * @param		p7		a pointer to an interface.
341  * @param		p8		a pointer to an interface.
342  * @param		p9		a pointer to an interface.
343  * @param		p10		a pointer to an interface.
344  */
345 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
346 		  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5,Interface6 * p6,Interface7 * p7,Interface8 * p8,Interface9 * p9,Interface10 * p10)347 inline ::com::sun::star::uno::Any queryDeepInterface(
348 	const ::com::sun::star::uno::Type & rType,
349 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
350 	Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 )
351 {
352 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
353 		return ::com::sun::star::uno::Any( &p1, rType );
354 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
355 		return ::com::sun::star::uno::Any( &p2, rType );
356 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
357 		return ::com::sun::star::uno::Any( &p3, rType );
358 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
359 		return ::com::sun::star::uno::Any( &p4, rType );
360 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
361 		return ::com::sun::star::uno::Any( &p5, rType );
362 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface6 > *>(0))))
363 		return ::com::sun::star::uno::Any( &p6, rType );
364 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface7 > *>(0))))
365 		return ::com::sun::star::uno::Any( &p7, rType );
366 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface8 > *>(0))))
367 		return ::com::sun::star::uno::Any( &p8, rType );
368 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface9 > *>(0))))
369 		return ::com::sun::star::uno::Any( &p9, rType );
370 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface10 > *>(0))))
371 		return ::com::sun::star::uno::Any( &p10, rType );
372 	else
373 		return ::com::sun::star::uno::Any();
374 }
375 
376 /**
377  * Inspect types and choose return proper interface.
378  *<BR>
379  * @param		p1		a pointer to an interface.
380  * @param		p2		a pointer to an interface.
381  * @param		p3		a pointer to an interface.
382  * @param		p4		a pointer to an interface.
383  * @param		p5		a pointer to an interface.
384  * @param		p6		a pointer to an interface.
385  * @param		p7		a pointer to an interface.
386  * @param		p8		a pointer to an interface.
387  * @param		p9		a pointer to an interface.
388  * @param		p10		a pointer to an interface.
389  * @param		p11		a pointer to an interface.
390  */
391 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
392 		  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
393 		  class Interface11 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5,Interface6 * p6,Interface7 * p7,Interface8 * p8,Interface9 * p9,Interface10 * p10,Interface11 * p11)394 inline ::com::sun::star::uno::Any queryDeepInterface(
395 	const ::com::sun::star::uno::Type & rType,
396 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
397 	Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
398 	Interface11 * p11 )
399 {
400 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
401 		return ::com::sun::star::uno::Any( &p1, rType );
402 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
403 		return ::com::sun::star::uno::Any( &p2, rType );
404 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
405 		return ::com::sun::star::uno::Any( &p3, rType );
406 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
407 		return ::com::sun::star::uno::Any( &p4, rType );
408 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
409 		return ::com::sun::star::uno::Any( &p5, rType );
410 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface6 > *>(0))))
411 		return ::com::sun::star::uno::Any( &p6, rType );
412 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface7 > *>(0))))
413 		return ::com::sun::star::uno::Any( &p7, rType );
414 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface8 > *>(0))))
415 		return ::com::sun::star::uno::Any( &p8, rType );
416 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface9 > *>(0))))
417 		return ::com::sun::star::uno::Any( &p9, rType );
418 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface10 > *>(0))))
419 		return ::com::sun::star::uno::Any( &p10, rType );
420 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface11 > *>(0))))
421 		return ::com::sun::star::uno::Any( &p11, rType );
422 	else
423 		return ::com::sun::star::uno::Any();
424 }
425 
426 /**
427  * Inspect types and choose return proper interface.
428  *<BR>
429  * @param		p1		a pointer to an interface.
430  * @param		p2		a pointer to an interface.
431  * @param		p3		a pointer to an interface.
432  * @param		p4		a pointer to an interface.
433  * @param		p5		a pointer to an interface.
434  * @param		p6		a pointer to an interface.
435  * @param		p7		a pointer to an interface.
436  * @param		p8		a pointer to an interface.
437  * @param		p9		a pointer to an interface.
438  * @param		p10		a pointer to an interface.
439  * @param		p11		a pointer to an interface.
440  * @param		p12		a pointer to an interface.
441  */
442 template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5,
443 		  class Interface6, class Interface7, class Interface8, class Interface9, class Interface10,
444 		  class Interface11, class Interface12 >
queryDeepInterface(const::com::sun::star::uno::Type & rType,Interface1 * p1,Interface2 * p2,Interface3 * p3,Interface4 * p4,Interface5 * p5,Interface6 * p6,Interface7 * p7,Interface8 * p8,Interface9 * p9,Interface10 * p10,Interface11 * p11,Interface12 * p12)445 inline ::com::sun::star::uno::Any queryDeepInterface(
446 	const ::com::sun::star::uno::Type & rType,
447 	Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5,
448 	Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10,
449 	Interface11 * p11, Interface12 * p12 )
450 {
451 	if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface1 > *>(0))))
452 		return ::com::sun::star::uno::Any( &p1, rType );
453 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface2 > *>(0))))
454 		return ::com::sun::star::uno::Any( &p2, rType );
455 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface3 > *>(0))))
456 		return ::com::sun::star::uno::Any( &p3, rType );
457 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface4 > *>(0))))
458 		return ::com::sun::star::uno::Any( &p4, rType );
459 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface5 > *>(0))))
460 		return ::com::sun::star::uno::Any( &p5, rType );
461 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface6 > *>(0))))
462 		return ::com::sun::star::uno::Any( &p6, rType );
463 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface7 > *>(0))))
464 		return ::com::sun::star::uno::Any( &p7, rType );
465 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface8 > *>(0))))
466 		return ::com::sun::star::uno::Any( &p8, rType );
467 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface9 > *>(0))))
468 		return ::com::sun::star::uno::Any( &p9, rType );
469 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface10 > *>(0))))
470 		return ::com::sun::star::uno::Any( &p10, rType );
471 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface11 > *>(0))))
472 		return ::com::sun::star::uno::Any( &p11, rType );
473 	else if (isDerivedFrom(rType, ::getCppuType(static_cast<const ::com::sun::star::uno::Reference< Interface12 > *>(0))))
474 		return ::com::sun::star::uno::Any( &p12, rType );
475 	else
476 		return ::com::sun::star::uno::Any();
477 }
478 
479 } // namespace utl
480 
481 #endif // _UNOTOOLS_QUERYDEEPINTERFACE_HXX
482 
483