xref: /AOO41X/main/cppu/inc/com/sun/star/uno/Reference.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
28*cdf0e10cSrcweir #define _COM_SUN_STAR_UNO_REFERENCE_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
31*cdf0e10cSrcweir #include <com/sun/star/uno/RuntimeException.hpp>
32*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UNO_XINTERFACE_HDL_
33*cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hdl>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir #include <com/sun/star/uno/genfunc.hxx>
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir namespace com
38*cdf0e10cSrcweir {
39*cdf0e10cSrcweir namespace sun
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir namespace star
42*cdf0e10cSrcweir {
43*cdf0e10cSrcweir namespace uno
44*cdf0e10cSrcweir {
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir //__________________________________________________________________________________________________
47*cdf0e10cSrcweir inline XInterface * BaseReference::iquery(
48*cdf0e10cSrcweir 	XInterface * pInterface, const Type & rType )
49*cdf0e10cSrcweir     SAL_THROW( (RuntimeException) )
50*cdf0e10cSrcweir {
51*cdf0e10cSrcweir 	if (pInterface)
52*cdf0e10cSrcweir 	{
53*cdf0e10cSrcweir 		Any aRet( pInterface->queryInterface( rType ) );
54*cdf0e10cSrcweir 		if (typelib_TypeClass_INTERFACE == aRet.pType->eTypeClass)
55*cdf0e10cSrcweir 		{
56*cdf0e10cSrcweir 			XInterface * pRet = static_cast< XInterface * >( aRet.pReserved );
57*cdf0e10cSrcweir 			aRet.pReserved = 0;
58*cdf0e10cSrcweir 			return pRet;
59*cdf0e10cSrcweir 		}
60*cdf0e10cSrcweir 	}
61*cdf0e10cSrcweir 	return 0;
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir //__________________________________________________________________________________________________
64*cdf0e10cSrcweir template< class interface_type >
65*cdf0e10cSrcweir inline XInterface * Reference< interface_type >::iquery(
66*cdf0e10cSrcweir 	XInterface * pInterface ) SAL_THROW( (RuntimeException) )
67*cdf0e10cSrcweir {
68*cdf0e10cSrcweir     return BaseReference::iquery(pInterface, interface_type::static_type());
69*cdf0e10cSrcweir }
70*cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
71*cdf0e10cSrcweir extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iquery_msg(
72*cdf0e10cSrcweir     typelib_TypeDescriptionReference * pType )
73*cdf0e10cSrcweir     SAL_THROW_EXTERN_C();
74*cdf0e10cSrcweir extern "C" rtl_uString * SAL_CALL cppu_unsatisfied_iset_msg(
75*cdf0e10cSrcweir     typelib_TypeDescriptionReference * pType )
76*cdf0e10cSrcweir     SAL_THROW_EXTERN_C();
77*cdf0e10cSrcweir //__________________________________________________________________________________________________
78*cdf0e10cSrcweir inline XInterface * BaseReference::iquery_throw(
79*cdf0e10cSrcweir 	XInterface * pInterface, const Type & rType )
80*cdf0e10cSrcweir     SAL_THROW( (RuntimeException) )
81*cdf0e10cSrcweir {
82*cdf0e10cSrcweir     XInterface * pQueried = iquery( pInterface, rType );
83*cdf0e10cSrcweir 	if (pQueried)
84*cdf0e10cSrcweir         return pQueried;
85*cdf0e10cSrcweir     throw RuntimeException(
86*cdf0e10cSrcweir         ::rtl::OUString( cppu_unsatisfied_iquery_msg( rType.getTypeLibType() ), SAL_NO_ACQUIRE ),
87*cdf0e10cSrcweir         Reference< XInterface >( pInterface ) );
88*cdf0e10cSrcweir }
89*cdf0e10cSrcweir //__________________________________________________________________________________________________
90*cdf0e10cSrcweir template< class interface_type >
91*cdf0e10cSrcweir inline XInterface * Reference< interface_type >::iquery_throw(
92*cdf0e10cSrcweir 	XInterface * pInterface ) SAL_THROW( (RuntimeException) )
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir     return BaseReference::iquery_throw(
95*cdf0e10cSrcweir         pInterface, interface_type::static_type());
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir //__________________________________________________________________________________________________
98*cdf0e10cSrcweir template< class interface_type >
99*cdf0e10cSrcweir inline interface_type * Reference< interface_type >::iset_throw(
100*cdf0e10cSrcweir 	interface_type * pInterface ) SAL_THROW( (RuntimeException) )
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir     if (pInterface)
103*cdf0e10cSrcweir     {
104*cdf0e10cSrcweir         pInterface->acquire();
105*cdf0e10cSrcweir         return pInterface;
106*cdf0e10cSrcweir     }
107*cdf0e10cSrcweir     throw RuntimeException(
108*cdf0e10cSrcweir         ::rtl::OUString( cppu_unsatisfied_iset_msg( interface_type::static_type().getTypeLibType() ), SAL_NO_ACQUIRE ),
109*cdf0e10cSrcweir         NULL );
110*cdf0e10cSrcweir }
111*cdf0e10cSrcweir #endif
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir //__________________________________________________________________________________________________
114*cdf0e10cSrcweir template< class interface_type >
115*cdf0e10cSrcweir inline Reference< interface_type >::~Reference() SAL_THROW( () )
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir 	if (_pInterface)
118*cdf0e10cSrcweir 		_pInterface->release();
119*cdf0e10cSrcweir }
120*cdf0e10cSrcweir //__________________________________________________________________________________________________
121*cdf0e10cSrcweir template< class interface_type >
122*cdf0e10cSrcweir inline Reference< interface_type >::Reference() SAL_THROW( () )
123*cdf0e10cSrcweir {
124*cdf0e10cSrcweir 	_pInterface = 0;
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir //__________________________________________________________________________________________________
127*cdf0e10cSrcweir template< class interface_type >
128*cdf0e10cSrcweir inline Reference< interface_type >::Reference( const Reference< interface_type > & rRef ) SAL_THROW( () )
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir 	_pInterface = rRef._pInterface;
131*cdf0e10cSrcweir 	if (_pInterface)
132*cdf0e10cSrcweir 		_pInterface->acquire();
133*cdf0e10cSrcweir }
134*cdf0e10cSrcweir //__________________________________________________________________________________________________
135*cdf0e10cSrcweir template< class interface_type >
136*cdf0e10cSrcweir inline Reference< interface_type >::Reference( interface_type * pInterface ) SAL_THROW( () )
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 	_pInterface = castToXInterface(pInterface);
139*cdf0e10cSrcweir 	if (_pInterface)
140*cdf0e10cSrcweir 		_pInterface->acquire();
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir //__________________________________________________________________________________________________
143*cdf0e10cSrcweir template< class interface_type >
144*cdf0e10cSrcweir inline Reference< interface_type >::Reference( interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () )
145*cdf0e10cSrcweir {
146*cdf0e10cSrcweir 	_pInterface = castToXInterface(pInterface);
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir //__________________________________________________________________________________________________
149*cdf0e10cSrcweir template< class interface_type >
150*cdf0e10cSrcweir inline Reference< interface_type >::Reference( interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () )
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir 	_pInterface = castToXInterface(pInterface);
153*cdf0e10cSrcweir }
154*cdf0e10cSrcweir //__________________________________________________________________________________________________
155*cdf0e10cSrcweir template< class interface_type >
156*cdf0e10cSrcweir inline Reference< interface_type >::Reference( const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) )
157*cdf0e10cSrcweir {
158*cdf0e10cSrcweir 	_pInterface = iquery( rRef.get() );
159*cdf0e10cSrcweir }
160*cdf0e10cSrcweir //__________________________________________________________________________________________________
161*cdf0e10cSrcweir template< class interface_type >
162*cdf0e10cSrcweir inline Reference< interface_type >::Reference( XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) )
163*cdf0e10cSrcweir {
164*cdf0e10cSrcweir 	_pInterface = iquery( pInterface );
165*cdf0e10cSrcweir }
166*cdf0e10cSrcweir //__________________________________________________________________________________________________
167*cdf0e10cSrcweir template< class interface_type >
168*cdf0e10cSrcweir inline Reference< interface_type >::Reference( const Any & rAny, UnoReference_Query ) SAL_THROW( (RuntimeException) )
169*cdf0e10cSrcweir {
170*cdf0e10cSrcweir     _pInterface = (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
171*cdf0e10cSrcweir                    ? iquery( static_cast< XInterface * >( rAny.pReserved ) ) : 0);
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
174*cdf0e10cSrcweir //__________________________________________________________________________________________________
175*cdf0e10cSrcweir template< class interface_type >
176*cdf0e10cSrcweir inline Reference< interface_type >::Reference( const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
177*cdf0e10cSrcweir {
178*cdf0e10cSrcweir 	_pInterface = iquery_throw( rRef.get() );
179*cdf0e10cSrcweir }
180*cdf0e10cSrcweir //__________________________________________________________________________________________________
181*cdf0e10cSrcweir template< class interface_type >
182*cdf0e10cSrcweir inline Reference< interface_type >::Reference( XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
183*cdf0e10cSrcweir {
184*cdf0e10cSrcweir 	_pInterface = iquery_throw( pInterface );
185*cdf0e10cSrcweir }
186*cdf0e10cSrcweir //__________________________________________________________________________________________________
187*cdf0e10cSrcweir template< class interface_type >
188*cdf0e10cSrcweir inline Reference< interface_type >::Reference( const Any & rAny, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
189*cdf0e10cSrcweir {
190*cdf0e10cSrcweir     _pInterface = iquery_throw( typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass
191*cdf0e10cSrcweir                                 ? static_cast< XInterface * >( rAny.pReserved ) : 0 );
192*cdf0e10cSrcweir }
193*cdf0e10cSrcweir //__________________________________________________________________________________________________
194*cdf0e10cSrcweir template< class interface_type >
195*cdf0e10cSrcweir inline Reference< interface_type >::Reference( const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
196*cdf0e10cSrcweir {
197*cdf0e10cSrcweir     _pInterface = iset_throw( rRef.get() );
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir //__________________________________________________________________________________________________
200*cdf0e10cSrcweir template< class interface_type >
201*cdf0e10cSrcweir inline Reference< interface_type >::Reference( interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir     _pInterface = iset_throw( pInterface );
204*cdf0e10cSrcweir }
205*cdf0e10cSrcweir #endif
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir //__________________________________________________________________________________________________
208*cdf0e10cSrcweir template< class interface_type >
209*cdf0e10cSrcweir inline void Reference< interface_type >::clear() SAL_THROW( () )
210*cdf0e10cSrcweir {
211*cdf0e10cSrcweir 	if (_pInterface)
212*cdf0e10cSrcweir 	{
213*cdf0e10cSrcweir         XInterface * const pOld = _pInterface;
214*cdf0e10cSrcweir 		_pInterface = 0;
215*cdf0e10cSrcweir 		pOld->release();
216*cdf0e10cSrcweir 	}
217*cdf0e10cSrcweir }
218*cdf0e10cSrcweir //__________________________________________________________________________________________________
219*cdf0e10cSrcweir template< class interface_type >
220*cdf0e10cSrcweir inline sal_Bool Reference< interface_type >::set(
221*cdf0e10cSrcweir 	interface_type * pInterface ) SAL_THROW( () )
222*cdf0e10cSrcweir {
223*cdf0e10cSrcweir 	if (pInterface)
224*cdf0e10cSrcweir 		castToXInterface(pInterface)->acquire();
225*cdf0e10cSrcweir     XInterface * const pOld = _pInterface;
226*cdf0e10cSrcweir 	_pInterface = castToXInterface(pInterface);
227*cdf0e10cSrcweir 	if (pOld)
228*cdf0e10cSrcweir 		pOld->release();
229*cdf0e10cSrcweir 	return (0 != pInterface);
230*cdf0e10cSrcweir }
231*cdf0e10cSrcweir //__________________________________________________________________________________________________
232*cdf0e10cSrcweir template< class interface_type >
233*cdf0e10cSrcweir inline sal_Bool Reference< interface_type >::set(
234*cdf0e10cSrcweir 	interface_type * pInterface, __sal_NoAcquire ) SAL_THROW( () )
235*cdf0e10cSrcweir {
236*cdf0e10cSrcweir     XInterface * const pOld = _pInterface;
237*cdf0e10cSrcweir 	_pInterface = castToXInterface(pInterface);
238*cdf0e10cSrcweir 	if (pOld)
239*cdf0e10cSrcweir 		pOld->release();
240*cdf0e10cSrcweir 	return (0 != pInterface);
241*cdf0e10cSrcweir }
242*cdf0e10cSrcweir //__________________________________________________________________________________________________
243*cdf0e10cSrcweir template< class interface_type >
244*cdf0e10cSrcweir inline sal_Bool Reference< interface_type >::set(
245*cdf0e10cSrcweir 	interface_type * pInterface, UnoReference_NoAcquire ) SAL_THROW( () )
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir 	return set( pInterface, SAL_NO_ACQUIRE );
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir //__________________________________________________________________________________________________
251*cdf0e10cSrcweir template< class interface_type >
252*cdf0e10cSrcweir inline sal_Bool Reference< interface_type >::set(
253*cdf0e10cSrcweir 	const Reference< interface_type > & rRef ) SAL_THROW( () )
254*cdf0e10cSrcweir {
255*cdf0e10cSrcweir 	return set( castFromXInterface( rRef._pInterface ) );
256*cdf0e10cSrcweir }
257*cdf0e10cSrcweir //__________________________________________________________________________________________________
258*cdf0e10cSrcweir template< class interface_type >
259*cdf0e10cSrcweir inline sal_Bool Reference< interface_type >::set(
260*cdf0e10cSrcweir 	XInterface * pInterface, UnoReference_Query ) SAL_THROW( (RuntimeException) )
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir 	return set( castFromXInterface(iquery( pInterface )), SAL_NO_ACQUIRE );
263*cdf0e10cSrcweir }
264*cdf0e10cSrcweir //__________________________________________________________________________________________________
265*cdf0e10cSrcweir template< class interface_type >
266*cdf0e10cSrcweir inline sal_Bool Reference< interface_type >::set(
267*cdf0e10cSrcweir 	const BaseReference & rRef, UnoReference_Query ) SAL_THROW( (RuntimeException) )
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir 	return set( castFromXInterface(iquery( rRef.get() )), SAL_NO_ACQUIRE );
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir //______________________________________________________________________________
273*cdf0e10cSrcweir template< class interface_type >
274*cdf0e10cSrcweir inline bool Reference< interface_type >::set(
275*cdf0e10cSrcweir     Any const & rAny, UnoReference_Query )
276*cdf0e10cSrcweir {
277*cdf0e10cSrcweir 	return set(
278*cdf0e10cSrcweir         castFromXInterface(
279*cdf0e10cSrcweir             iquery(
280*cdf0e10cSrcweir                 rAny.pType->eTypeClass == typelib_TypeClass_INTERFACE
281*cdf0e10cSrcweir                 ? static_cast< XInterface * >( rAny.pReserved ) : 0 )),
282*cdf0e10cSrcweir         SAL_NO_ACQUIRE );
283*cdf0e10cSrcweir }
284*cdf0e10cSrcweir 
285*cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
286*cdf0e10cSrcweir //__________________________________________________________________________________________________
287*cdf0e10cSrcweir template< class interface_type >
288*cdf0e10cSrcweir inline void Reference< interface_type >::set(
289*cdf0e10cSrcweir 	XInterface * pInterface, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
290*cdf0e10cSrcweir {
291*cdf0e10cSrcweir 	set( castFromXInterface(iquery_throw( pInterface )), SAL_NO_ACQUIRE );
292*cdf0e10cSrcweir }
293*cdf0e10cSrcweir //__________________________________________________________________________________________________
294*cdf0e10cSrcweir template< class interface_type >
295*cdf0e10cSrcweir inline void Reference< interface_type >::set(
296*cdf0e10cSrcweir 	const BaseReference & rRef, UnoReference_QueryThrow ) SAL_THROW( (RuntimeException) )
297*cdf0e10cSrcweir {
298*cdf0e10cSrcweir 	set( castFromXInterface(iquery_throw( rRef.get() )), SAL_NO_ACQUIRE );
299*cdf0e10cSrcweir }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir //______________________________________________________________________________
302*cdf0e10cSrcweir template< class interface_type >
303*cdf0e10cSrcweir inline void Reference< interface_type >::set(
304*cdf0e10cSrcweir     Any const & rAny, UnoReference_QueryThrow )
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir 	set( castFromXInterface(
307*cdf0e10cSrcweir              iquery_throw(
308*cdf0e10cSrcweir                  rAny.pType->eTypeClass == typelib_TypeClass_INTERFACE
309*cdf0e10cSrcweir                  ? static_cast< XInterface * >( rAny.pReserved ) : 0 )),
310*cdf0e10cSrcweir          SAL_NO_ACQUIRE );
311*cdf0e10cSrcweir }
312*cdf0e10cSrcweir //__________________________________________________________________________________________________
313*cdf0e10cSrcweir template< class interface_type >
314*cdf0e10cSrcweir inline void Reference< interface_type >::set(
315*cdf0e10cSrcweir 	interface_type * pInterface, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
316*cdf0e10cSrcweir {
317*cdf0e10cSrcweir     set( iset_throw( pInterface ), SAL_NO_ACQUIRE );
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir //__________________________________________________________________________________________________
320*cdf0e10cSrcweir template< class interface_type >
321*cdf0e10cSrcweir inline void Reference< interface_type >::set(
322*cdf0e10cSrcweir 	const Reference< interface_type > & rRef, UnoReference_SetThrow ) SAL_THROW( (RuntimeException) )
323*cdf0e10cSrcweir {
324*cdf0e10cSrcweir     set( rRef.get(), UNO_SET_THROW );
325*cdf0e10cSrcweir }
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir #endif
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir //__________________________________________________________________________________________________
330*cdf0e10cSrcweir template< class interface_type >
331*cdf0e10cSrcweir inline Reference< interface_type > & Reference< interface_type >::operator = (
332*cdf0e10cSrcweir 	interface_type * pInterface ) SAL_THROW( () )
333*cdf0e10cSrcweir {
334*cdf0e10cSrcweir 	set( pInterface );
335*cdf0e10cSrcweir 	return *this;
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir //__________________________________________________________________________________________________
338*cdf0e10cSrcweir template< class interface_type >
339*cdf0e10cSrcweir inline Reference< interface_type > & Reference< interface_type >::operator = (
340*cdf0e10cSrcweir 	const Reference< interface_type > & rRef ) SAL_THROW( () )
341*cdf0e10cSrcweir {
342*cdf0e10cSrcweir 	set( castFromXInterface( rRef._pInterface ) );
343*cdf0e10cSrcweir 	return *this;
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir //__________________________________________________________________________________________________
347*cdf0e10cSrcweir template< class interface_type >
348*cdf0e10cSrcweir inline Reference< interface_type > Reference< interface_type >::query(
349*cdf0e10cSrcweir 	const BaseReference & rRef ) SAL_THROW( (RuntimeException) )
350*cdf0e10cSrcweir {
351*cdf0e10cSrcweir 	return Reference< interface_type >(
352*cdf0e10cSrcweir         castFromXInterface(iquery( rRef.get() )), SAL_NO_ACQUIRE );
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir //__________________________________________________________________________________________________
355*cdf0e10cSrcweir template< class interface_type >
356*cdf0e10cSrcweir inline Reference< interface_type > Reference< interface_type >::query(
357*cdf0e10cSrcweir 	XInterface * pInterface ) SAL_THROW( (RuntimeException) )
358*cdf0e10cSrcweir {
359*cdf0e10cSrcweir 	return Reference< interface_type >(
360*cdf0e10cSrcweir         castFromXInterface(iquery( pInterface )), SAL_NO_ACQUIRE );
361*cdf0e10cSrcweir }
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir //##################################################################################################
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir //__________________________________________________________________________________________________
366*cdf0e10cSrcweir inline sal_Bool BaseReference::operator == ( XInterface * pInterface ) const SAL_THROW( () )
367*cdf0e10cSrcweir {
368*cdf0e10cSrcweir 	if (_pInterface == pInterface)
369*cdf0e10cSrcweir 		return sal_True;
370*cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
371*cdf0e10cSrcweir     try
372*cdf0e10cSrcweir     {
373*cdf0e10cSrcweir #endif
374*cdf0e10cSrcweir         // only the query to XInterface must return the same pointer if they belong to same objects
375*cdf0e10cSrcweir         Reference< XInterface > x1( _pInterface, UNO_QUERY );
376*cdf0e10cSrcweir         Reference< XInterface > x2( pInterface, UNO_QUERY );
377*cdf0e10cSrcweir         return (x1._pInterface == x2._pInterface);
378*cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
379*cdf0e10cSrcweir     }
380*cdf0e10cSrcweir     catch (RuntimeException &)
381*cdf0e10cSrcweir     {
382*cdf0e10cSrcweir         return sal_False;
383*cdf0e10cSrcweir     }
384*cdf0e10cSrcweir #endif
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir //______________________________________________________________________________
388*cdf0e10cSrcweir inline sal_Bool BaseReference::operator < (
389*cdf0e10cSrcweir     const BaseReference & rRef ) const SAL_THROW( () )
390*cdf0e10cSrcweir {
391*cdf0e10cSrcweir     if (_pInterface == rRef._pInterface)
392*cdf0e10cSrcweir         return sal_False;
393*cdf0e10cSrcweir #if ! defined EXCEPTIONS_OFF
394*cdf0e10cSrcweir     try
395*cdf0e10cSrcweir     {
396*cdf0e10cSrcweir #endif
397*cdf0e10cSrcweir         // only the query to XInterface must return the same pointer:
398*cdf0e10cSrcweir         Reference< XInterface > x1( _pInterface, UNO_QUERY );
399*cdf0e10cSrcweir         Reference< XInterface > x2( rRef, UNO_QUERY );
400*cdf0e10cSrcweir         return (x1._pInterface < x2._pInterface);
401*cdf0e10cSrcweir #if ! defined EXCEPTIONS_OFF
402*cdf0e10cSrcweir     }
403*cdf0e10cSrcweir     catch (RuntimeException &)
404*cdf0e10cSrcweir     {
405*cdf0e10cSrcweir         return sal_False;
406*cdf0e10cSrcweir     }
407*cdf0e10cSrcweir #endif
408*cdf0e10cSrcweir }
409*cdf0e10cSrcweir 
410*cdf0e10cSrcweir //__________________________________________________________________________________________________
411*cdf0e10cSrcweir inline sal_Bool BaseReference::operator != ( XInterface * pInterface ) const SAL_THROW( () )
412*cdf0e10cSrcweir {
413*cdf0e10cSrcweir 	return (! operator == ( pInterface ));
414*cdf0e10cSrcweir }
415*cdf0e10cSrcweir //__________________________________________________________________________________________________
416*cdf0e10cSrcweir inline sal_Bool BaseReference::operator == ( const BaseReference & rRef ) const SAL_THROW( () )
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir 	return operator == ( rRef._pInterface );
419*cdf0e10cSrcweir }
420*cdf0e10cSrcweir //__________________________________________________________________________________________________
421*cdf0e10cSrcweir inline sal_Bool BaseReference::operator != ( const BaseReference & rRef ) const SAL_THROW( () )
422*cdf0e10cSrcweir {
423*cdf0e10cSrcweir 	return (! operator == ( rRef._pInterface ));
424*cdf0e10cSrcweir }
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir }
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir }
430*cdf0e10cSrcweir 
431*cdf0e10cSrcweir #endif
432