xref: /trunk/main/dbaccess/source/inc/apitools.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*2e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2e2212a7SAndrew Rist  * distributed with this work for additional information
6*2e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
9*2e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2e2212a7SAndrew Rist  * software distributed under the License is distributed on an
15*2e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2e2212a7SAndrew Rist  * specific language governing permissions and limitations
18*2e2212a7SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2e2212a7SAndrew Rist  *************************************************************/
21*2e2212a7SAndrew Rist 
22*2e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DBASHARED_APITOOLS_HXX_
25cdf0e10cSrcweir #define _DBASHARED_APITOOLS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _CPPUHELPER_COMPONENT_HXX_
28cdf0e10cSrcweir #include <cppuhelper/component.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _OSL_MUTEX_HXX_
31cdf0e10cSrcweir #include <osl/mutex.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
34cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _OSL_DIAGNOSE_H_
37cdf0e10cSrcweir #include <osl/diagnose.h>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_
40cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
43cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _COMPHELPER_SEQUENCE_HXX_
46cdf0e10cSrcweir #include <comphelper/sequence.hxx>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir 
49cdf0e10cSrcweir //==================================================================================
50cdf0e10cSrcweir //= various typedefs
51cdf0e10cSrcweir //==================================================================================
52cdf0e10cSrcweir DECLARE_STL_VECTOR(::com::sun::star::uno::WeakReferenceHelper, OWeakRefArray);
53cdf0e10cSrcweir 
54cdf0e10cSrcweir //==================================================================================
55cdf0e10cSrcweir //= OSubComponent - a component which holds a hard ref to it's parent
56cdf0e10cSrcweir //=                 and is been hold itself (by the parent) with a weak ref
57cdf0e10cSrcweir //==================================================================================
58cdf0e10cSrcweir class OSubComponent : public ::cppu::OComponentHelper
59cdf0e10cSrcweir {
60cdf0e10cSrcweir protected:
61cdf0e10cSrcweir     // the parent must support the tunnel implementation
62cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
63cdf0e10cSrcweir     virtual ~OSubComponent();
64cdf0e10cSrcweir 
65cdf0e10cSrcweir public:
66cdf0e10cSrcweir     OSubComponent(::osl::Mutex& _rMutex,
67cdf0e10cSrcweir                   const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent);
68cdf0e10cSrcweir 
69cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
70cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
73cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType )
74cdf0e10cSrcweir             throw(::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw();
76cdf0e10cSrcweir     virtual void SAL_CALL release() throw();
77cdf0e10cSrcweir 
operator ::com::sun::star::uno::Reference<::com::sun::star::uno::XInterface>() const78cdf0e10cSrcweir     inline operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () const
79cdf0e10cSrcweir         { return (::com::sun::star::uno::XWeak *)this; }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir //==================================================================================
84cdf0e10cSrcweir //= helper for implementing the XServiceInfo interface
85cdf0e10cSrcweir 
86cdf0e10cSrcweir //----------------------------------------------------------------------------------
87cdf0e10cSrcweir // (internal - not to be used outside - usually)
88cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname)   \
89cdf0e10cSrcweir     ::rtl::OUString SAL_CALL classname::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)   \
90cdf0e10cSrcweir     {   \
91cdf0e10cSrcweir         return ::rtl::OUString::createFromAscii(implasciiname); \
92cdf0e10cSrcweir     }   \
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(classname, implasciiname)    \
95cdf0e10cSrcweir     ::rtl::OUString SAL_CALL classname::getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException)   \
96cdf0e10cSrcweir     {   \
97cdf0e10cSrcweir         return getImplementationName_Static();  \
98cdf0e10cSrcweir     }   \
99cdf0e10cSrcweir     ::rtl::OUString SAL_CALL classname::getImplementationName_Static(  ) throw (::com::sun::star::uno::RuntimeException)    \
100cdf0e10cSrcweir     {   \
101cdf0e10cSrcweir         return ::rtl::OUString::createFromAscii(implasciiname); \
102cdf0e10cSrcweir     }   \
103cdf0e10cSrcweir 
104cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
105cdf0e10cSrcweir     sal_Bool SAL_CALL classname::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException) \
106cdf0e10cSrcweir     {   \
107cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());  \
108cdf0e10cSrcweir         const ::rtl::OUString* pSupported = aSupported.getConstArray(); \
109cdf0e10cSrcweir         for (sal_Int32 i=0; i<aSupported.getLength(); ++i, ++pSupported)    \
110cdf0e10cSrcweir             if (pSupported->equals(_rServiceName))  \
111cdf0e10cSrcweir                 return sal_True;    \
112cdf0e10cSrcweir     \
113cdf0e10cSrcweir         return sal_False;   \
114cdf0e10cSrcweir     }   \
115cdf0e10cSrcweir 
116cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_GETSUPPORTED1(classname, serviceasciiname)   \
117cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)  \
118cdf0e10cSrcweir     {   \
119cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);   \
120cdf0e10cSrcweir         aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname); \
121cdf0e10cSrcweir         return aSupported;  \
122cdf0e10cSrcweir     }   \
123cdf0e10cSrcweir 
124cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(classname, serviceasciiname)    \
125cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)  \
126cdf0e10cSrcweir     {   \
127cdf0e10cSrcweir         return getSupportedServiceNames_Static();   \
128cdf0e10cSrcweir     }   \
129cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames_Static(  ) throw(::com::sun::star::uno::RuntimeException)   \
130cdf0e10cSrcweir     {   \
131cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1);   \
132cdf0e10cSrcweir         aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname); \
133cdf0e10cSrcweir         return aSupported;  \
134cdf0e10cSrcweir     }   \
135cdf0e10cSrcweir 
136cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_GETSUPPORTED2_STATIC(classname, serviceasciiname1, serviceasciiname2)    \
137cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)  \
138cdf0e10cSrcweir     {   \
139cdf0e10cSrcweir         return getSupportedServiceNames_Static();   \
140cdf0e10cSrcweir     }   \
141cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames_Static(  ) throw(::com::sun::star::uno::RuntimeException)   \
142cdf0e10cSrcweir     {   \
143cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2);   \
144cdf0e10cSrcweir         aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname1);    \
145cdf0e10cSrcweir         aSupported[1] = ::rtl::OUString::createFromAscii(serviceasciiname2);    \
146cdf0e10cSrcweir         return aSupported;  \
147cdf0e10cSrcweir     }   \
148cdf0e10cSrcweir 
149cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_GETSUPPORTED2(classname, serviceasciiname1, serviceasciiname2)   \
150cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)  \
151cdf0e10cSrcweir     {   \
152cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2);   \
153cdf0e10cSrcweir         aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname1);    \
154cdf0e10cSrcweir         aSupported[1] = ::rtl::OUString::createFromAscii(serviceasciiname2);    \
155cdf0e10cSrcweir         return aSupported;  \
156cdf0e10cSrcweir     }   \
157cdf0e10cSrcweir 
158cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_GETSUPPORTED3(classname, serviceasciiname1, serviceasciiname2, serviceasciiname3)    \
159cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException)  \
160cdf0e10cSrcweir     {   \
161cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(3);   \
162cdf0e10cSrcweir         aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname1);    \
163cdf0e10cSrcweir         aSupported[1] = ::rtl::OUString::createFromAscii(serviceasciiname2);    \
164cdf0e10cSrcweir         aSupported[2] = ::rtl::OUString::createFromAscii(serviceasciiname3);    \
165cdf0e10cSrcweir         return aSupported;  \
166cdf0e10cSrcweir     }   \
167cdf0e10cSrcweir 
168cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO_CREATE_STATIC(classname) \
169cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >   \
170cdf0e10cSrcweir         SAL_CALL classname::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)  \
171cdf0e10cSrcweir     {   \
172cdf0e10cSrcweir         return static_cast< XServiceInfo* >(new classname(_rxORB)); \
173cdf0e10cSrcweir     }   \
174cdf0e10cSrcweir 
175cdf0e10cSrcweir //----------------------------------------------------------------------------------
176cdf0e10cSrcweir // declare service info methods - no getImplementationName, so the class is abstract
177cdf0e10cSrcweir #define DECLARE_SERVICE_INFO_ABSTRACT() \
178cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); \
179cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException) \
180cdf0e10cSrcweir 
181cdf0e10cSrcweir //----------------------------------------------------------------------------------
182cdf0e10cSrcweir // declare service info methods
183cdf0e10cSrcweir #define DECLARE_SERVICE_INFO()  \
184cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException); \
185cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); \
186cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException) \
187cdf0e10cSrcweir 
188cdf0e10cSrcweir #define DECLARE_SERVICE_INFO_STATIC()   \
189cdf0e10cSrcweir     DECLARE_SERVICE_INFO(); \
190cdf0e10cSrcweir     static ::rtl::OUString SAL_CALL getImplementationName_Static(  ) throw (::com::sun::star::uno::RuntimeException);   \
191cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static(  ) throw(::com::sun::star::uno::RuntimeException);  \
192cdf0e10cSrcweir     static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >    \
193cdf0e10cSrcweir         SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)    \
194cdf0e10cSrcweir 
195cdf0e10cSrcweir //----------------------------------------------------------------------------------
196cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO1(classname, implasciiname, serviceasciiname) \
197cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname)   \
198cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
199cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_GETSUPPORTED1(classname, serviceasciiname)   \
200cdf0e10cSrcweir 
201cdf0e10cSrcweir //----------------------------------------------------------------------------------
202cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO1_STATIC(classname, implasciiname, serviceasciiname)  \
203cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(classname, implasciiname)    \
204cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
205cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(classname, serviceasciiname)    \
206cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_CREATE_STATIC(classname) \
207cdf0e10cSrcweir 
208cdf0e10cSrcweir //----------------------------------------------------------------------------------
209cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO2(classname, implasciiname, serviceasciiname1, serviceasciiname2) \
210cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname)   \
211cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
212cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_GETSUPPORTED2(classname, serviceasciiname1, serviceasciiname2)
213cdf0e10cSrcweir 
214cdf0e10cSrcweir //----------------------------------------------------------------------------------
215cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO2_STATIC(classname, implasciiname, serviceasciiname1, serviceasciiname2)  \
216cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(classname, implasciiname)    \
217cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
218cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_GETSUPPORTED2_STATIC(classname, serviceasciiname1,serviceasciiname2) \
219cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_CREATE_STATIC(classname) \
220cdf0e10cSrcweir 
221cdf0e10cSrcweir //----------------------------------------------------------------------------------
222cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO3(classname, implasciiname, serviceasciiname1, serviceasciiname2, serviceasciiname3)  \
223cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_IMPLNAME(classname, implasciiname)   \
224cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
225cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_GETSUPPORTED3(classname, serviceasciiname1, serviceasciiname2, serviceasciiname3)    \
226cdf0e10cSrcweir 
227cdf0e10cSrcweir //----------------------------------------------------------------------------------
228cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO1_ABSTRACT(classname, serviceasciiname)   \
229cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
230cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_GETSUPPORTED1(classname, serviceasciiname)   \
231cdf0e10cSrcweir 
232cdf0e10cSrcweir //----------------------------------------------------------------------------------
233cdf0e10cSrcweir #define IMPLEMENT_SERVICE_INFO2_ABSTRACT(classname, serviceasciiname1, serviceasciiname2)   \
234cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_SUPPORTS(classname)  \
235cdf0e10cSrcweir     IMPLEMENT_SERVICE_INFO_GETSUPPORTED2(classname, serviceasciiname1, serviceasciiname2)   \
236cdf0e10cSrcweir 
237cdf0e10cSrcweir //==================================================================================
238cdf0e10cSrcweir //= XTypeProvider helpers
239cdf0e10cSrcweir 
240cdf0e10cSrcweir //--------------------------------------------------------------------------
241cdf0e10cSrcweir #define DECLARE_IMPLEMENTATION_ID( )    \
242cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId(  ) throw(::com::sun::star::uno::RuntimeException);  \
243cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence< sal_Int8 >  getUnoTunnelImplementationId() \
244cdf0e10cSrcweir 
245cdf0e10cSrcweir //--------------------------------------------------------------------------
246cdf0e10cSrcweir #define DECLARE_GETTYPES( ) \
247cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw (::com::sun::star::uno::RuntimeException);
248cdf0e10cSrcweir 
249cdf0e10cSrcweir //--------------------------------------------------------------------------
250cdf0e10cSrcweir #define DECLARE_TYPEPROVIDER( ) \
251cdf0e10cSrcweir     DECLARE_GETTYPES( ) \
252cdf0e10cSrcweir     DECLARE_IMPLEMENTATION_ID( )
253cdf0e10cSrcweir 
254cdf0e10cSrcweir //--------------------------------------------------------------------------
255cdf0e10cSrcweir #define IMPLEMENT_IMPLEMENTATION_ID( classname )    \
256cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > classname::getUnoTunnelImplementationId() \
257cdf0e10cSrcweir {   \
258cdf0e10cSrcweir     static ::cppu::OImplementationId* pId = 0;  \
259cdf0e10cSrcweir     if ( !pId ) \
260cdf0e10cSrcweir     {   \
261cdf0e10cSrcweir         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); \
262cdf0e10cSrcweir         if ( !pId ) \
263cdf0e10cSrcweir         {   \
264cdf0e10cSrcweir             static ::cppu::OImplementationId aId;   \
265cdf0e10cSrcweir             pId = &aId; \
266cdf0e10cSrcweir         }   \
267cdf0e10cSrcweir     }   \
268cdf0e10cSrcweir     return pId->getImplementationId();  \
269cdf0e10cSrcweir } \
270cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > classname::getImplementationId() throw (::com::sun::star::uno::RuntimeException)    \
271cdf0e10cSrcweir {   \
272cdf0e10cSrcweir     return classname::getUnoTunnelImplementationId(); \
273cdf0e10cSrcweir }
274cdf0e10cSrcweir 
275cdf0e10cSrcweir //--------------------------------------------------------------------------
276cdf0e10cSrcweir #define IMPLEMENT_GETTYPES2( classname, baseclass1, baseclass2 )    \
277cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > classname::getTypes() throw (::com::sun::star::uno::RuntimeException)    \
278cdf0e10cSrcweir     {   \
279cdf0e10cSrcweir         return  ::comphelper::concatSequences(  \
280cdf0e10cSrcweir             baseclass1::getTypes( ),    \
281cdf0e10cSrcweir             baseclass2::getTypes( ) \
282cdf0e10cSrcweir         );  \
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir //--------------------------------------------------------------------------
286cdf0e10cSrcweir #define IMPLEMENT_GETTYPES3( classname, baseclass1, baseclass2, baseclass3 )    \
287cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > classname::getTypes() throw (::com::sun::star::uno::RuntimeException)    \
288cdf0e10cSrcweir     {   \
289cdf0e10cSrcweir         return  ::comphelper::concatSequences(  \
290cdf0e10cSrcweir             baseclass1::getTypes( ),    \
291cdf0e10cSrcweir             baseclass2::getTypes( ),    \
292cdf0e10cSrcweir             baseclass3::getTypes( ) \
293cdf0e10cSrcweir         );  \
294cdf0e10cSrcweir     }
295cdf0e10cSrcweir 
296cdf0e10cSrcweir //--------------------------------------------------------------------------
297cdf0e10cSrcweir #define IMPLEMENT_TYPEPROVIDER2( classname, baseclass1, baseclass2 )    \
298cdf0e10cSrcweir     IMPLEMENT_IMPLEMENTATION_ID( classname) \
299cdf0e10cSrcweir     IMPLEMENT_GETTYPES2( classname, baseclass1, baseclass2 )
300cdf0e10cSrcweir 
301cdf0e10cSrcweir //--------------------------------------------------------------------------
302cdf0e10cSrcweir #define IMPLEMENT_TYPEPROVIDER3( classname, baseclass1, baseclass2, baseclass3 )    \
303cdf0e10cSrcweir     IMPLEMENT_IMPLEMENTATION_ID( classname) \
304cdf0e10cSrcweir     IMPLEMENT_GETTYPES3(classname, baseclass1, baseclass2, baseclass3 )
305cdf0e10cSrcweir 
306cdf0e10cSrcweir //==================================================================================
307cdf0e10cSrcweir //= helper for declaring/implementing classes based on the OPropertyContainer and an OPropertyArrayUsageHelper
308cdf0e10cSrcweir //----------------------------------------------------------------------------------
309cdf0e10cSrcweir #define DECLARE_PROPERTYCONTAINER_DEFAULTS( )   \
310cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo>  SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); \
311cdf0e10cSrcweir     virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); \
312cdf0e10cSrcweir     virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const
313cdf0e10cSrcweir 
314cdf0e10cSrcweir //----------------------------------------------------------------------------------
315cdf0e10cSrcweir #define IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2( classname , baseclass1)  \
316cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >  SAL_CALL classname::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException)  \
317cdf0e10cSrcweir     {   \
318cdf0e10cSrcweir         Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );    \
319cdf0e10cSrcweir         return xInfo;   \
320cdf0e10cSrcweir     }   \
321cdf0e10cSrcweir     ::cppu::IPropertyArrayHelper& classname::getInfoHelper()    \
322cdf0e10cSrcweir     {   \
323cdf0e10cSrcweir     return *baseclass1::getArrayHelper();   \
324cdf0e10cSrcweir     }   \
325cdf0e10cSrcweir     ::cppu::IPropertyArrayHelper* classname::createArrayHelper( ) const \
326cdf0e10cSrcweir     {   \
327cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aProps;    \
328cdf0e10cSrcweir         describeProperties(aProps); \
329cdf0e10cSrcweir         return new ::cppu::OPropertyArrayHelper(aProps);    \
330cdf0e10cSrcweir     }
331cdf0e10cSrcweir //----------------------------------------------------------------------------------
332cdf0e10cSrcweir #define IMPLEMENT_PROPERTYCONTAINER_DEFAULTS( classname )   \
333cdf0e10cSrcweir     IMPLEMENT_PROPERTYCONTAINER_DEFAULTS2( classname, classname )
334cdf0e10cSrcweir 
335cdf0e10cSrcweir //==================================================================================
336cdf0e10cSrcweir //= helper for implementing the createArrayHelper
337cdf0e10cSrcweir //----------------------------------------------------------------------------------
338cdf0e10cSrcweir #define BEGIN_PROPERTY_SEQUENCE(count)  \
339cdf0e10cSrcweir     ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property> aDescriptor(count); \
340cdf0e10cSrcweir     ::com::sun::star::beans::Property* pDesc = aDescriptor.getArray();                  \
341cdf0e10cSrcweir     sal_Int32 nPos = 0;                                             \
342cdf0e10cSrcweir 
343cdf0e10cSrcweir //----------------------------------------------------------------------------------
344cdf0e10cSrcweir #define BEGIN_PROPERTY_HELPER(count)                            \
345cdf0e10cSrcweir     BEGIN_PROPERTY_SEQUENCE(count)
346cdf0e10cSrcweir 
347cdf0e10cSrcweir //----------------------------------------------------------------------------------
348cdf0e10cSrcweir #define DECL_PROP_IMPL(varname, cpputype) \
349cdf0e10cSrcweir     pDesc[nPos++] = ::com::sun::star::beans::Property(PROPERTY_##varname, PROPERTY_ID_##varname, cpputype,
350cdf0e10cSrcweir 
351cdf0e10cSrcweir //----------------------------------------------------------------------------------
352cdf0e10cSrcweir #define DECL_PROP0(varname, type)   \
353cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) 0)
354cdf0e10cSrcweir //----------------------------------------------------------------------------------
355cdf0e10cSrcweir #define DECL_PROP0_BOOL(varname)    \
356cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getBooleanCppuType()) 0)
357cdf0e10cSrcweir //----------------------------------------------------------------------------------
358cdf0e10cSrcweir #define DECL_PROP0_IFACE(varname, iface)    \
359cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getCppuType(static_cast< ::com::sun::star::uno::Reference< iface >* >(NULL))) 0)
360cdf0e10cSrcweir 
361cdf0e10cSrcweir //----------------------------------------------------------------------------------
362cdf0e10cSrcweir #define DECL_PROP1(varname, type, attrib1)  \
363cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) ::com::sun::star::beans::PropertyAttribute::attrib1)
364cdf0e10cSrcweir //----------------------------------------------------------------------------------
365cdf0e10cSrcweir #define DECL_PROP1_BOOL(varname, attrib1)   \
366cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getBooleanCppuType()) ::com::sun::star::beans::PropertyAttribute::attrib1)
367cdf0e10cSrcweir //----------------------------------------------------------------------------------
368cdf0e10cSrcweir #define DECL_PROP1_IFACE(varname, iface, attrib1)   \
369cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getCppuType(static_cast< ::com::sun::star::uno::Reference< iface >* >(NULL))) ::com::sun::star::beans::PropertyAttribute::attrib1)
370cdf0e10cSrcweir //----------------------------------------------------------------------------------
371cdf0e10cSrcweir #define DECL_PROP2_IFACE(varname, iface, attrib1, attrib2)  \
372cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getCppuType(static_cast< ::com::sun::star::uno::Reference< iface >* >(NULL))) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2)
373cdf0e10cSrcweir 
374cdf0e10cSrcweir //----------------------------------------------------------------------------------
375cdf0e10cSrcweir #define DECL_PROP2(varname, type, attrib1, attrib2) \
376cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2)
377cdf0e10cSrcweir //----------------------------------------------------------------------------------
378cdf0e10cSrcweir #define DECL_PROP2_BOOL(varname, attrib1, attrib2)  \
379cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getBooleanCppuType()) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2)
380cdf0e10cSrcweir 
381cdf0e10cSrcweir //----------------------------------------------------------------------------------
382cdf0e10cSrcweir #define DECL_PROP3(varname, type, attrib1, attrib2, attrib3)    \
383cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getCppuType((const type *)0)) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2 | ::com::sun::star::beans::PropertyAttribute::attrib3)
384cdf0e10cSrcweir //----------------------------------------------------------------------------------
385cdf0e10cSrcweir #define DECL_PROP3_BOOL(varname, attrib1, attrib2, attrib3) \
386cdf0e10cSrcweir     DECL_PROP_IMPL(varname, ::getBooleanCppuType()) ::com::sun::star::beans::PropertyAttribute::attrib1 | ::com::sun::star::beans::PropertyAttribute::attrib2 | ::com::sun::star::beans::PropertyAttribute::attrib3)
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 
389cdf0e10cSrcweir //----------------------------------------------------------------------------------
390cdf0e10cSrcweir #define END_PROPERTY_SEQUENCE()                             \
391cdf0e10cSrcweir     OSL_ENSURE(nPos == aDescriptor.getLength(), "forgot to adjust the count ?");    \
392cdf0e10cSrcweir 
393cdf0e10cSrcweir //----------------------------------------------------------------------------------
394cdf0e10cSrcweir #define END_PROPERTY_HELPER()                               \
395cdf0e10cSrcweir     END_PROPERTY_SEQUENCE() \
396cdf0e10cSrcweir     return new ::cppu::OPropertyArrayHelper(aDescriptor);
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 
399cdf0e10cSrcweir #define NOTIFY_LISTERNERS(_rListeners,T,method)                                   \
400cdf0e10cSrcweir     Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
401cdf0e10cSrcweir                                                                                   \
402cdf0e10cSrcweir     const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray();     \
403cdf0e10cSrcweir     const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
404cdf0e10cSrcweir                                                                                   \
405cdf0e10cSrcweir     _rGuard.clear();                                                              \
406cdf0e10cSrcweir     while( pxInt > pxIntBegin )                                                   \
407cdf0e10cSrcweir     {                                                                             \
408cdf0e10cSrcweir         try                                                                       \
409cdf0e10cSrcweir         {                                                                         \
410cdf0e10cSrcweir             while( pxInt > pxIntBegin )                                           \
411cdf0e10cSrcweir             {                                                                     \
412cdf0e10cSrcweir                 --pxInt;                                                          \
413cdf0e10cSrcweir                 static_cast< T* >( pxInt->get() )->method(aEvt);                  \
414cdf0e10cSrcweir             }                                                                     \
415cdf0e10cSrcweir         }                                                                         \
416cdf0e10cSrcweir         catch( RuntimeException& )                                                \
417cdf0e10cSrcweir         {                                                                         \
418cdf0e10cSrcweir         }                                                                         \
419cdf0e10cSrcweir     }                                                                             \
420cdf0e10cSrcweir     _rGuard.reset();
421cdf0e10cSrcweir 
422cdf0e10cSrcweir #define NOTIFY_LISTERNERS1(_rListeners,T,method,arg1)                             \
423cdf0e10cSrcweir     Sequence< Reference< XInterface > > aListenerSeq = _rListeners.getElements(); \
424cdf0e10cSrcweir                                                                                   \
425cdf0e10cSrcweir     const Reference< XInterface >* pxIntBegin = aListenerSeq.getConstArray();     \
426cdf0e10cSrcweir     const Reference< XInterface >* pxInt = pxIntBegin + aListenerSeq.getLength(); \
427cdf0e10cSrcweir                                                                                   \
428cdf0e10cSrcweir     _rGuard.clear();                                                              \
429cdf0e10cSrcweir     while( pxInt > pxIntBegin )                                                   \
430cdf0e10cSrcweir     {                                                                             \
431cdf0e10cSrcweir         try                                                                       \
432cdf0e10cSrcweir         {                                                                         \
433cdf0e10cSrcweir             while( pxInt > pxIntBegin )                                           \
434cdf0e10cSrcweir             {                                                                     \
435cdf0e10cSrcweir                 --pxInt;                                                          \
436cdf0e10cSrcweir                 static_cast< T* >( pxInt->get() )->method(aEvt,arg1);             \
437cdf0e10cSrcweir             }                                                                     \
438cdf0e10cSrcweir         }                                                                         \
439cdf0e10cSrcweir         catch( RuntimeException& )                                                \
440cdf0e10cSrcweir         {                                                                         \
441cdf0e10cSrcweir         }                                                                         \
442cdf0e10cSrcweir     }                                                                             \
443cdf0e10cSrcweir     _rGuard.reset();
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 
446cdf0e10cSrcweir //==================================================================================
447cdf0e10cSrcweir // miscellaneous
448cdf0e10cSrcweir #define UNUSED(x)   x;
449cdf0e10cSrcweir 
450cdf0e10cSrcweir #endif // _DBASHARED_APITOOLS_HXX_
451