28 #ifndef _CPPUHELPER_IMPLBASE_HXX_
29 #define _CPPUHELPER_IMPLBASE_HXX_
36 #include <com/sun/star/lang/XTypeProvider.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
71 sal_Int32 nType2Offset;
97 ClassDataBase( sal_Int32 nClassCode )
SAL_THROW(());
100 ~ClassDataBase() SAL_THROW(());
112 Type_Offset arType2Offset[1];
116 void SAL_CALL initTypeProvider() SAL_THROW(());
122 void SAL_CALL writeTypeOffset( const ::com::sun::star::uno::Type & rType, sal_Int32 nOffset )
131 ::com::sun::star::uno::Any SAL_CALL query(
132 const ::com::sun::star::uno::Type & rType, ::com::sun::star::lang::XTypeProvider * pBase )
138 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
144 ::com::sun::star::uno::Sequence<
sal_Int8 > SAL_CALL getImplementationId()
160 #if defined _MSC_VER // public -> protected changes mangled names there
161 #define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED public
163 #define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED protected
179 #define __DEF_IMPLHELPER_PRE( N ) \
182 struct ClassData##N : public ClassDataBase \
184 Type_Offset arType2Offset[ N ]; \
185 ClassData##N( sal_Int32 nInClassCode ) SAL_THROW(()) \
186 : ClassDataBase( nInClassCode ) \
189 template< __CLASS_IFC##N > \
190 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelperBase##N \
191 : public ::com::sun::star::lang::XTypeProvider \
194 CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \
195 ~ImplHelperBase##N() throw () {} \
197 ClassData & SAL_CALL getClassData( ClassDataBase & s_aCD ) SAL_THROW(()) \
199 ClassData & rCD = * static_cast< ClassData * >( &s_aCD ); \
200 if (! rCD.bOffsetsInit) \
202 ::osl::MutexGuard aGuard( getImplHelperInitMutex() ); \
203 if (! rCD.bOffsetsInit) \
205 char * pBase = (char *)this;
208 #define __IFC_WRITEOFFSET( N ) \
209 rCD.writeTypeOffset( ::getCppuType( (const ::com::sun::star::uno::Reference< Ifc##N > *)0 ), \
210 (char *)(Ifc##N *)this - pBase );
213 #define __DEF_IMPLHELPER_POST_A( N ) \
214 rCD.bOffsetsInit = sal_True; \
220 template< __CLASS_IFC##N > \
221 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper##N \
222 : public ImplHelperBase##N< __IFC##N > \
224 static ClassData##N s_aCD; \
226 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
227 { return this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ); } \
228 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
229 { return this->getClassData( s_aCD ).getTypes(); } \
230 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
231 { return this->getClassData( s_aCD ).getImplementationId(); } \
232 CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \
233 ~ImplHelper##N() throw () {} \
235 template< __CLASS_IFC##N > \
236 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper##N \
237 : public ::cppu::OWeakObject \
238 , public ImplHelperBase##N< __IFC##N > \
240 static ClassData##N s_aCD; \
242 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
244 ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
245 return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); \
247 virtual void SAL_CALL acquire() throw () \
248 { OWeakObject::acquire(); } \
249 virtual void SAL_CALL release() throw () \
250 { OWeakObject::release(); } \
251 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
252 { return this->getClassData( s_aCD ).getTypes(); } \
253 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
254 { return this->getClassData( s_aCD ).getImplementationId(); } \
256 template< __CLASS_IFC##N > \
257 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper##N \
258 : public ::cppu::OWeakAggObject \
259 , public ImplHelperBase##N< __IFC##N > \
261 static ClassData##N s_aCD; \
263 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
264 { return OWeakAggObject::queryInterface( rType ); } \
265 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \
267 ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \
268 return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType )); \
270 virtual void SAL_CALL acquire() throw () \
271 { OWeakAggObject::acquire(); } \
272 virtual void SAL_CALL release() throw () \
273 { OWeakAggObject::release(); } \
274 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \
275 { return this->getClassData( s_aCD ).getTypes(); } \
276 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \
277 { return this->getClassData( s_aCD ).getImplementationId(); } \
282 #define __DEF_IMPLHELPER_POST_B( N ) \
283 template< __CLASS_IFC##N > \
284 ClassData##N ImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 0 ); \
285 template< __CLASS_IFC##N > \
286 ClassData##N WeakImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 1 ); \
287 template< __CLASS_IFC##N > \
288 ClassData##N WeakAggImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 2 );
291 #define __DEF_IMPLHELPER_POST_C( N ) \
296 #define __DEF_IMPLHELPER_POST( N ) \
297 __DEF_IMPLHELPER_POST_A( N ) \
298 __DEF_IMPLHELPER_POST_B( N ) \
299 __DEF_IMPLHELPER_POST_C( N )