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_INC_SHAREDUNOCOMPONENT_HXX
25cdf0e10cSrcweir #define UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "unotoolsdllapi.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
30cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx>
31cdf0e10cSrcweir #include <rtl/ref.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace com { namespace sun { namespace star {
34cdf0e10cSrcweir     namespace lang {
35cdf0e10cSrcweir         class XComponent;
36cdf0e10cSrcweir     }
37cdf0e10cSrcweir } } }
38cdf0e10cSrcweir //............................................................................
39cdf0e10cSrcweir namespace utl
40cdf0e10cSrcweir {
41cdf0e10cSrcweir //............................................................................
42cdf0e10cSrcweir 
43cdf0e10cSrcweir     //========================================================================
44cdf0e10cSrcweir     //= DisposableComponent
45cdf0e10cSrcweir     //========================================================================
46cdf0e10cSrcweir     /** is a class which controls lifetime of an UNO component via ->XComponent::dispose
47cdf0e10cSrcweir 
48cdf0e10cSrcweir         You'll usually never use this class directly, but only as parameter for a
49cdf0e10cSrcweir         ->SharedUNOComponent class.
50cdf0e10cSrcweir     */
51cdf0e10cSrcweir     class UNOTOOLS_DLLPUBLIC DisposableComponent
52cdf0e10cSrcweir     {
53cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
54cdf0e10cSrcweir             m_xComponent;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     public:
57cdf0e10cSrcweir         /** constructs a ->DisposableComponent instance
58cdf0e10cSrcweir 
59cdf0e10cSrcweir         @param _rxComponent
60cdf0e10cSrcweir             the component whose life time should be controlled by the instance. Must not be <NULL/>.
61cdf0e10cSrcweir         */
62cdf0e10cSrcweir         DisposableComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
63cdf0e10cSrcweir 
64cdf0e10cSrcweir         /** disposes the component represented by the instance
65cdf0e10cSrcweir 
66cdf0e10cSrcweir             The component is queried for ->XComponent(which <em>must</em> be supported),
67cdf0e10cSrcweir             and ->XComponent::dispose is invoked. A failure of this invocation (e.g. a thrown
68cdf0e10cSrcweir             exception) is silenced in release builds, and reported in debug builds.
69cdf0e10cSrcweir         */
70cdf0e10cSrcweir         ~DisposableComponent();
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     private:
73cdf0e10cSrcweir         DisposableComponent();                                          // never implemented
74cdf0e10cSrcweir         DisposableComponent( const DisposableComponent& );              // never implemented
75cdf0e10cSrcweir         DisposableComponent& operator=( const DisposableComponent& );   // never implemented
76cdf0e10cSrcweir     };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir     //========================================================================
79cdf0e10cSrcweir     //= CloseableComponent
80cdf0e10cSrcweir     //========================================================================
81cdf0e10cSrcweir     class CloseableComponentImpl;
82cdf0e10cSrcweir     /** is a class which controls lifetime of an UNO component via ->XCloseable::close
83cdf0e10cSrcweir 
84cdf0e10cSrcweir         You'll usually never use this class directly, but only as parameter for a
85cdf0e10cSrcweir         ->SharedUNOComponent class.
86cdf0e10cSrcweir     */
87cdf0e10cSrcweir     class UNOTOOLS_DLLPUBLIC CloseableComponent
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir     private:
90cdf0e10cSrcweir         /** Our IMPL class.
91cdf0e10cSrcweir         */
92cdf0e10cSrcweir         ::rtl::Reference< CloseableComponentImpl >  m_pImpl;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir     public:
95cdf0e10cSrcweir         /** constructs a ->CloseableComponent instance
96cdf0e10cSrcweir 
97cdf0e10cSrcweir         @param _rxComponent
98cdf0e10cSrcweir             the component whose life time should be controlled by the instance. Must not be <NULL/>.
99cdf0e10cSrcweir         */
100cdf0e10cSrcweir         CloseableComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         /** destroys resources associated with this instance, and disposes the component
103cdf0e10cSrcweir 
104cdf0e10cSrcweir             The component is queried for ->XCloseable (which <em>must</em> be supported),
105cdf0e10cSrcweir             and ->XCloseable::close is invoked, with delivering the ownership.
106cdf0e10cSrcweir             If the invocation fails with a ->CloseVetoException, this is ignored, since in
107cdf0e10cSrcweir             this case the vetoing instance took the ownership.
108cdf0e10cSrcweir 
109cdf0e10cSrcweir             Any other failure will be reported in a debug version via assertion mechanisms,
110cdf0e10cSrcweir             and silenced in release builds.
111cdf0e10cSrcweir         */
112cdf0e10cSrcweir         ~CloseableComponent();
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     private:
115cdf0e10cSrcweir         CloseableComponent();                                           // never implemented
116cdf0e10cSrcweir         CloseableComponent( const CloseableComponent& );                // never implemented
117cdf0e10cSrcweir         CloseableComponent& operator=( const CloseableComponent& );     // never implemented
118cdf0e10cSrcweir     };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     //========================================================================
121cdf0e10cSrcweir     //= SharedUNOComponent
122cdf0e10cSrcweir     //========================================================================
123cdf0e10cSrcweir     /** is a helper class for sharing ownership of a UNO component
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         If you need to share an UNO component, which normally needs a dedicated owner,
126cdf0e10cSrcweir         and is lifetime controlled by an explicit disposal action (not necessarily ->XComponent::dispose,
127cdf0e10cSrcweir         but <em>any</em> explicit method call, after which the object is considered
128cdf0e10cSrcweir         to be disposed), between different classes, ->SharedUNOComponent is what you need.
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         Instead of passing around a <code>Reference&lt; XFoo &gt;</code>, and bothering
131cdf0e10cSrcweir         with ownership and disposal, you just use a <code>SharedUNOComponent&lt; XFoo &gt;</code>.
132cdf0e10cSrcweir         This instance can be passed around, including copying, and in nearly all respects behaves
133cdf0e10cSrcweir         like the original <code>Reference&lt; XFoo &gt;</code>. However, when the last
134cdf0e10cSrcweir         ->SharedUNOComponent referencing a certain <code>Reference&lt; XFoo &gt;</code> dies, it
135cdf0e10cSrcweir         will automatically get rid of the object held by this reference.
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     @param INTERFACE
138cdf0e10cSrcweir         the UNO interface type as which the component should be held
139cdf0e10cSrcweir 
140cdf0e10cSrcweir     @param COMPONENT_HOLDER
141cdf0e10cSrcweir         a class which can be used to represent and dispose a UNO component.
142cdf0e10cSrcweir         The class must support (maybe explicit only) construction from a
143cdf0e10cSrcweir         <code>Reference&lt; INTERFACE &gt;</code>, and destruction. Upon destruction,
144cdf0e10cSrcweir         the class must dispose (by any suitable means) the component instance it was
145cdf0e10cSrcweir         constructed with.
146cdf0e10cSrcweir     */
147cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT = DisposableComponent >
148cdf0e10cSrcweir     class SharedUNOComponent
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir     private:
151cdf0e10cSrcweir         typedef COMPONENT                           Component;
152cdf0e10cSrcweir         typedef ::boost::shared_ptr< Component >    ComponentPointer;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir     private:
155cdf0e10cSrcweir         ComponentPointer                                m_pComponent;
156cdf0e10cSrcweir         ::com::sun::star::uno::Reference< INTERFACE >   m_xTypedComponent;
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     public:
159cdf0e10cSrcweir         enum AssignmentMode
160cdf0e10cSrcweir         {
161cdf0e10cSrcweir             TakeOwnership,
162cdf0e10cSrcweir             NoTakeOwnership
163cdf0e10cSrcweir         };
164cdf0e10cSrcweir 
165cdf0e10cSrcweir     public:
SharedUNOComponent()166cdf0e10cSrcweir         inline  SharedUNOComponent()
167cdf0e10cSrcweir         {
168cdf0e10cSrcweir         }
169cdf0e10cSrcweir 
SharedUNOComponent(const::com::sun::star::uno::Reference<INTERFACE> & _rxComponent,AssignmentMode eMode=TakeOwnership)170cdf0e10cSrcweir         explicit inline  SharedUNOComponent( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode eMode = TakeOwnership )
171cdf0e10cSrcweir         {
172cdf0e10cSrcweir             reset( _rxComponent, eMode );
173cdf0e10cSrcweir         }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
SharedUNOComponent(const::com::sun::star::uno::XInterface * _pInterface,::com::sun::star::uno::UnoReference_QueryThrow _queryThrow)176cdf0e10cSrcweir         inline SharedUNOComponent( const ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow )
177cdf0e10cSrcweir         {
178cdf0e10cSrcweir             set( _pInterface, _queryThrow );
179cdf0e10cSrcweir         }
180cdf0e10cSrcweir 
SharedUNOComponent(const::com::sun::star::uno::BaseReference & _rRef,::com::sun::star::uno::UnoReference_QueryThrow _queryThrow)181cdf0e10cSrcweir         inline SharedUNOComponent( const ::com::sun::star::uno::BaseReference & _rRef, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow )
182cdf0e10cSrcweir         {
183cdf0e10cSrcweir             set( _rRef, _queryThrow );
184cdf0e10cSrcweir         }
185cdf0e10cSrcweir 
SharedUNOComponent(const::com::sun::star::uno::Any & _rAny,::com::sun::star::uno::UnoReference_QueryThrow _queryThrow)186cdf0e10cSrcweir         inline SharedUNOComponent( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow )
187cdf0e10cSrcweir         {
188cdf0e10cSrcweir             set( _rAny, _queryThrow );
189cdf0e10cSrcweir         }
190cdf0e10cSrcweir 
SharedUNOComponent(const SharedUNOComponent & _rxComponent,::com::sun::star::uno::UnoReference_SetThrow _setThrow)191cdf0e10cSrcweir         inline  SharedUNOComponent( const SharedUNOComponent& _rxComponent, ::com::sun::star::uno::UnoReference_SetThrow _setThrow )
192cdf0e10cSrcweir         {
193cdf0e10cSrcweir             set( _rxComponent, _setThrow );
194cdf0e10cSrcweir         }
195cdf0e10cSrcweir #endif
196cdf0e10cSrcweir 
197cdf0e10cSrcweir //        SharedUNOComponent& operator=( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent );
198cdf0e10cSrcweir         // this operator is not implemented by intention. There is no canonic ownership after this operatoer
199cdf0e10cSrcweir         // would hvae been applied: Should the SharedUNOComponent have the ownership of the component,
200cdf0e10cSrcweir         // or shouldn't it? Hard to guess, and probably wrong in 50 percent of all cases, anyway. So,
201cdf0e10cSrcweir         // instead of tempting clients of this class to use such a dangerous operator, we do
202cdf0e10cSrcweir         // not offer it at all. If you need to assign a Reference< INTERFACE > to your SharedUNOComponent,
203cdf0e10cSrcweir         // use the ->reset method.
204cdf0e10cSrcweir 
205cdf0e10cSrcweir         /** assigns a new component, and releases the old one
206cdf0e10cSrcweir         */
207cdf0e10cSrcweir         void reset( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode _eMode = TakeOwnership );
208cdf0e10cSrcweir 
209cdf0e10cSrcweir         inline bool set( ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_Query _query );
210cdf0e10cSrcweir         inline bool set( const ::com::sun::star::uno::BaseReference& _rRef, ::com::sun::star::uno::UnoReference_Query _query );
211cdf0e10cSrcweir         inline bool set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_Query _query );
212cdf0e10cSrcweir 
213cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
214cdf0e10cSrcweir         inline void set( const ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow );
215cdf0e10cSrcweir         inline void set( const ::com::sun::star::uno::BaseReference & _rRef, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow );
216cdf0e10cSrcweir         inline void set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir         inline void set( const INTERFACE* _pInterface, ::com::sun::star::uno::UnoReference_SetThrow _setThrow );
219cdf0e10cSrcweir         inline void set( const ::com::sun::star::uno::Reference< INTERFACE >& _rRef, ::com::sun::star::uno::UnoReference_SetThrow _setThrow );
220cdf0e10cSrcweir         inline void set( const SharedUNOComponent& _rComp, ::com::sun::star::uno::UnoReference_SetThrow _setThrow );
221cdf0e10cSrcweir #endif
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	    INTERFACE* SAL_CALL operator->() const;
224cdf0e10cSrcweir 
225cdf0e10cSrcweir         inline operator const ::com::sun::star::uno::Reference< INTERFACE >&() const
226cdf0e10cSrcweir         {
227cdf0e10cSrcweir             return m_xTypedComponent;
228cdf0e10cSrcweir         }
229cdf0e10cSrcweir 
getTyped() const230cdf0e10cSrcweir         inline const ::com::sun::star::uno::Reference< INTERFACE >& getTyped() const
231cdf0e10cSrcweir         {
232cdf0e10cSrcweir             return m_xTypedComponent;
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir 
is() const235cdf0e10cSrcweir         inline bool is() const
236cdf0e10cSrcweir         {
237cdf0e10cSrcweir             return m_xTypedComponent.is();
238cdf0e10cSrcweir         }
239cdf0e10cSrcweir 
clear()240cdf0e10cSrcweir         inline void clear()
241cdf0e10cSrcweir         {
242cdf0e10cSrcweir             m_pComponent.reset();
243cdf0e10cSrcweir             m_xTypedComponent.clear();
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir     };
246cdf0e10cSrcweir 
247cdf0e10cSrcweir     //-------------------------------------------------------------------------
248cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
operator ->() const249cdf0e10cSrcweir     INTERFACE* SAL_CALL SharedUNOComponent< INTERFACE, COMPONENT >::operator->() const
250cdf0e10cSrcweir     {
251cdf0e10cSrcweir         return m_xTypedComponent.operator->();
252cdf0e10cSrcweir     }
253cdf0e10cSrcweir 
254cdf0e10cSrcweir     //-------------------------------------------------------------------------
255cdf0e10cSrcweir     // assignments
256cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
reset(const::com::sun::star::uno::Reference<INTERFACE> & _rxComponent,AssignmentMode _eMode)257cdf0e10cSrcweir     void SharedUNOComponent< INTERFACE, COMPONENT >::reset( const ::com::sun::star::uno::Reference< INTERFACE >& _rxComponent, AssignmentMode _eMode )
258cdf0e10cSrcweir     {
259cdf0e10cSrcweir         m_pComponent.reset( _eMode == TakeOwnership ? new COMPONENT( _rxComponent ) : NULL );
260cdf0e10cSrcweir         m_xTypedComponent = _rxComponent;
261cdf0e10cSrcweir     }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     //-------------------------------------------------------------------------
264cdf0e10cSrcweir     // comparison operators
265cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
operator ==(const::com::sun::star::uno::Reference<INTERFACE> & _rLHS,const SharedUNOComponent<INTERFACE,COMPONENT> & _rRHS)266cdf0e10cSrcweir     bool operator==( const ::com::sun::star::uno::Reference< INTERFACE >& _rLHS, const SharedUNOComponent< INTERFACE, COMPONENT >& _rRHS )
267cdf0e10cSrcweir     {
268cdf0e10cSrcweir         return _rLHS == _rRHS.getTyped();
269cdf0e10cSrcweir     }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
operator ==(const SharedUNOComponent<INTERFACE,COMPONENT> & _rLHS,const::com::sun::star::uno::Reference<INTERFACE> & _rRHS)272cdf0e10cSrcweir     bool operator==( const SharedUNOComponent< INTERFACE, COMPONENT >& _rLHS, const ::com::sun::star::uno::Reference< INTERFACE >& _rRHS )
273cdf0e10cSrcweir     {
274cdf0e10cSrcweir         return _rLHS.getTyped() == _rRHS;
275cdf0e10cSrcweir     }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     //-------------------------------------------------------------------------
278cdf0e10cSrcweir     // conversion to Any
279cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
operator <<=(::com::sun::star::uno::Any & rAny,const SharedUNOComponent<INTERFACE,COMPONENT> & value)280cdf0e10cSrcweir     inline void SAL_CALL operator <<= ( ::com::sun::star::uno::Any & rAny, const SharedUNOComponent< INTERFACE, COMPONENT >& value ) SAL_THROW( () )
281cdf0e10cSrcweir     {
282cdf0e10cSrcweir         rAny <<= value.getTyped();
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     //-------------------------------------------------------------------------
286cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
makeAny(const SharedUNOComponent<INTERFACE,COMPONENT> & value)287cdf0e10cSrcweir     inline ::com::sun::star::uno::Any SAL_CALL makeAny( const SharedUNOComponent< INTERFACE, COMPONENT >& value ) SAL_THROW( () )
288cdf0e10cSrcweir     {
289cdf0e10cSrcweir         return makeAny( value.getTyped() );
290cdf0e10cSrcweir     }
291cdf0e10cSrcweir 
292cdf0e10cSrcweir #ifndef EXCEPTIONS_OFF
293cdf0e10cSrcweir     //-------------------------------------------------------------------------
294cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const::com::sun::star::uno::XInterface * _pInterface,::com::sun::star::uno::UnoReference_QueryThrow _queryThrow)295cdf0e10cSrcweir     void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow )
296cdf0e10cSrcweir     {
297cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _pInterface, _queryThrow ), TakeOwnership );
298cdf0e10cSrcweir     }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     //-------------------------------------------------------------------------
301cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const::com::sun::star::uno::BaseReference & _rRef,::com::sun::star::uno::UnoReference_QueryThrow _queryThrow)302cdf0e10cSrcweir     void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::BaseReference & _rRef, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow )
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _rRef, _queryThrow ), TakeOwnership );
305cdf0e10cSrcweir     }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     //-------------------------------------------------------------------------
308cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const::com::sun::star::uno::Any & _rAny,::com::sun::star::uno::UnoReference_QueryThrow _queryThrow)309cdf0e10cSrcweir     void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_QueryThrow _queryThrow )
310cdf0e10cSrcweir     {
311cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _rAny, _queryThrow ), TakeOwnership );
312cdf0e10cSrcweir     }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir     //-------------------------------------------------------------------------
315cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const INTERFACE * _pInterface,::com::sun::star::uno::UnoReference_SetThrow _setThrow)316cdf0e10cSrcweir     void SharedUNOComponent< INTERFACE, COMPONENT >::set( const INTERFACE* _pInterface, ::com::sun::star::uno::UnoReference_SetThrow _setThrow )
317cdf0e10cSrcweir     {
318cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _pInterface, _setThrow ), TakeOwnership );
319cdf0e10cSrcweir     }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     //-------------------------------------------------------------------------
322cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const::com::sun::star::uno::Reference<INTERFACE> & _rRef,::com::sun::star::uno::UnoReference_SetThrow _setThrow)323cdf0e10cSrcweir     void SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::Reference< INTERFACE >& _rRef, ::com::sun::star::uno::UnoReference_SetThrow _setThrow )
324cdf0e10cSrcweir     {
325cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _rRef, _setThrow ), TakeOwnership );
326cdf0e10cSrcweir     }
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     //-------------------------------------------------------------------------
329cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const SharedUNOComponent & _rComp,::com::sun::star::uno::UnoReference_SetThrow _setThrow)330cdf0e10cSrcweir     void SharedUNOComponent< INTERFACE, COMPONENT >::set( const SharedUNOComponent& _rComp, ::com::sun::star::uno::UnoReference_SetThrow _setThrow )
331cdf0e10cSrcweir     {
332cdf0e10cSrcweir         *this = _rComp;
333cdf0e10cSrcweir         // provoke an exception in case the component is NULL
334cdf0e10cSrcweir         m_xTypedComponent.set( m_xTypedComponent, _setThrow );
335cdf0e10cSrcweir     }
336cdf0e10cSrcweir #endif
337cdf0e10cSrcweir 
338cdf0e10cSrcweir     //-------------------------------------------------------------------------
339cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(::com::sun::star::uno::XInterface * _pInterface,::com::sun::star::uno::UnoReference_Query _query)340cdf0e10cSrcweir     bool SharedUNOComponent< INTERFACE, COMPONENT >::set( ::com::sun::star::uno::XInterface* _pInterface, ::com::sun::star::uno::UnoReference_Query _query )
341cdf0e10cSrcweir     {
342cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _pInterface, _query ) );
343cdf0e10cSrcweir         return is();
344cdf0e10cSrcweir     }
345cdf0e10cSrcweir 
346cdf0e10cSrcweir     //-------------------------------------------------------------------------
347cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const::com::sun::star::uno::BaseReference & _rRef,::com::sun::star::uno::UnoReference_Query _query)348cdf0e10cSrcweir     bool SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::BaseReference& _rRef, ::com::sun::star::uno::UnoReference_Query _query )
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _rRef, _query ) );
351cdf0e10cSrcweir         return is();
352cdf0e10cSrcweir     }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir     //-------------------------------------------------------------------------
355cdf0e10cSrcweir     template < class INTERFACE, class COMPONENT >
set(const::com::sun::star::uno::Any & _rAny,::com::sun::star::uno::UnoReference_Query _query)356cdf0e10cSrcweir     bool SharedUNOComponent< INTERFACE, COMPONENT >::set( const ::com::sun::star::uno::Any& _rAny, ::com::sun::star::uno::UnoReference_Query _query )
357cdf0e10cSrcweir     {
358cdf0e10cSrcweir         reset( ::com::sun::star::uno::Reference< INTERFACE >( _rAny, _query ) );
359cdf0e10cSrcweir         return is();
360cdf0e10cSrcweir     }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir //............................................................................
363cdf0e10cSrcweir }   // namespace utl
364cdf0e10cSrcweir //............................................................................
365cdf0e10cSrcweir 
366cdf0e10cSrcweir #endif // UNOTOOLS_INC_SHAREDUNOCOMPONENT_HXX
367