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