1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CPPUHELPER_IMPLBASE2_HXX_
24 #define _CPPUHELPER_IMPLBASE2_HXX_
25 
26 #include <cppuhelper/implbase_ex.hxx>
27 #include <rtl/instance.hxx>
28 
29 namespace cppu
30 {
31     /** @internal */
32     struct class_data2
33     {
34         sal_Int16 m_nTypes;
35         sal_Bool m_storedTypeRefs;
36         sal_Bool m_storedId;
37         sal_Int8 m_id[ 16 ];
38         type_entry m_typeEntries[ 2 + 1 ];
39     };
40 
41     /** @internal */
42     template< typename Ifc1, typename Ifc2, typename Impl > struct ImplClassData2
43     {
operator ()cppu::ImplClassData244         class_data* operator ()()
45         {
46             static class_data2 s_cd =
47             {
48                 2 +1, sal_False, sal_False,
49                 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
50                 {
51 					{ { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
52 					{ { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
53 					{ { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
54                 }
55             };
56             return reinterpret_cast< class_data * >(&s_cd);
57         }
58     };
59 
60     /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider
61         and queryInterface(), but no reference counting.
62 
63         @derive
64         Inherit from this class giving your interface(s) to be implemented as template argument(s).
65         Your base class defines method implementations, acquire(), release() and delegates incoming
66         queryInterface() calls to this base class.
67     */
68     template< class Ifc1, class Ifc2 >
69     class SAL_NO_VTABLE ImplHelper2
70         : public ::com::sun::star::lang::XTypeProvider
71         , public Ifc1, public Ifc2
72     {
73         /** @internal */
74         struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplHelper2<Ifc1, Ifc2> > > {};
75     public:
queryInterface(::com::sun::star::uno::Type const & rType)76         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
77             { return ImplHelper_query( rType, cd::get(), this ); }
getTypes()78         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
79             { return ImplHelper_getTypes( cd::get() ); }
getImplementationId()80         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
81             { return ImplHelper_getImplementationId( cd::get() ); }
82     };
83     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
84         ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
85         (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
86 
87         @derive
88         Inherit from this class giving your interface(s) to be implemented as template argument(s).
89         Your sub class defines method implementations for these interface(s).
90     */
91     template< class Ifc1, class Ifc2 >
92     class SAL_DLLPUBLIC_EXPORT SAL_NO_VTABLE WeakImplHelper2
93         : public OWeakObject
94         , public ::com::sun::star::lang::XTypeProvider
95         , public Ifc1, public Ifc2
96     {
97         /** @internal */
98         struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakImplHelper2<Ifc1, Ifc2> > > {};
99     public:
queryInterface(::com::sun::star::uno::Type const & rType)100         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
101             { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
acquire()102         virtual void SAL_CALL acquire() throw ()
103             { OWeakObject::acquire(); }
release()104         virtual void SAL_CALL release() throw ()
105             { OWeakObject::release(); }
getTypes()106         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
107             { return WeakImplHelper_getTypes( cd::get() ); }
getImplementationId()108         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
109             { return ImplHelper_getImplementationId( cd::get() ); }
110     };
111     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
112         ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
113         (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
114         In addition, it supports also aggregation meaning object of this class can be aggregated
115         (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
116         If a delegator is set (this object is aggregated), then incoming queryInterface()
117         calls are delegated to the delegator object. If the delegator does not support the
118         demanded interface, it calls queryAggregation() on its aggregated objects.
119 
120         @derive
121         Inherit from this class giving your interface(s) to be implemented as template argument(s).
122         Your sub class defines method implementations for these interface(s).
123     */
124     template< class Ifc1, class Ifc2 >
125     class SAL_NO_VTABLE WeakAggImplHelper2
126         : public OWeakAggObject
127         , public ::com::sun::star::lang::XTypeProvider
128         , public Ifc1, public Ifc2
129     {
130         /** @internal */
131         struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakAggImplHelper2<Ifc1, Ifc2> > > {};
132     public:
queryInterface(::com::sun::star::uno::Type const & rType)133         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
134             { return OWeakAggObject::queryInterface( rType ); }
queryAggregation(::com::sun::star::uno::Type const & rType)135         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
136             { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
acquire()137         virtual void SAL_CALL acquire() throw ()
138             { OWeakAggObject::acquire(); }
release()139         virtual void SAL_CALL release() throw ()
140             { OWeakAggObject::release(); }
getTypes()141         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
142             { return WeakAggImplHelper_getTypes( cd::get() ); }
getImplementationId()143         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
144             { return ImplHelper_getImplementationId( cd::get() ); }
145     };
146     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
147         ::com::sun::star::uno::XInterface inherting from a BaseClass.
148         All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
149         if a demanded interface is not supported by this class directly, the request is
150         delegated to the BaseClass.
151 
152         @attention
153         The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface
154         and ::com::sun::star::lang::XTypeProvider are implemented properly.  The
155         BaseClass must have at least one ctor that can be called with six or
156         fewer arguments, of which none is of non-const reference type.
157 
158         @derive
159         Inherit from this class giving your additional interface(s) to be implemented as
160         template argument(s). Your sub class defines method implementations for these interface(s).
161     */
162     template< class BaseClass, class Ifc1, class Ifc2 >
163     class SAL_NO_VTABLE ImplInheritanceHelper2
164         : public BaseClass
165         , public Ifc1, public Ifc2
166     {
167         /** @internal */
168         struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
169     protected:
170         template< typename T1 >
ImplInheritanceHelper2(T1 const & arg1)171         explicit ImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
172         template< typename T1, typename T2 >
ImplInheritanceHelper2(T1 const & arg1,T2 const & arg2)173         ImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
174             BaseClass(arg1, arg2) {}
175         template< typename T1, typename T2, typename T3 >
ImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3)176         ImplInheritanceHelper2(
177             T1 const & arg1, T2 const & arg2, T3 const & arg3):
178             BaseClass(arg1, arg2, arg3) {}
179         template< typename T1, typename T2, typename T3, typename T4 >
ImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4)180         ImplInheritanceHelper2(
181             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
182             BaseClass(arg1, arg2, arg3, arg4) {}
183         template<
184             typename T1, typename T2, typename T3, typename T4, typename T5 >
ImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5)185         ImplInheritanceHelper2(
186             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
187             T5 const & arg5):
188             BaseClass(arg1, arg2, arg3, arg4, arg5) {}
189         template<
190             typename T1, typename T2, typename T3, typename T4, typename T5,
191             typename T6 >
ImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5,T6 const & arg6)192         ImplInheritanceHelper2(
193             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
194             T5 const & arg5, T6 const & arg6):
195             BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
196     public:
ImplInheritanceHelper2()197         ImplInheritanceHelper2() {}
queryInterface(::com::sun::star::uno::Type const & rType)198         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
199             {
200                 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
201                 if (aRet.hasValue())
202                     return aRet;
203                 return BaseClass::queryInterface( rType );
204             }
acquire()205         virtual void SAL_CALL acquire() throw ()
206             { BaseClass::acquire(); }
release()207         virtual void SAL_CALL release() throw ()
208             { BaseClass::release(); }
getTypes()209         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
210             { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
getImplementationId()211         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
212             { return ImplHelper_getImplementationId( cd::get() ); }
213     };
214     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
215         ::com::sun::star::uno::XInterface inherting from a BaseClass.
216         All acquire(),  release() and queryInterface() calls are delegated to the BaseClass.
217         Upon queryAggregation(), if a demanded interface is not supported by this class directly,
218         the request is delegated to the BaseClass.
219 
220         @attention
221         The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface,
222         ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider
223         are implemented properly.  The BaseClass must have at least one ctor
224         that can be called with six or fewer arguments, of which none is of
225         non-const reference type.
226 
227         @derive
228         Inherit from this class giving your additional interface(s) to be implemented as
229         template argument(s). Your sub class defines method implementations for these interface(s).
230     */
231     template< class BaseClass, class Ifc1, class Ifc2 >
232     class SAL_NO_VTABLE AggImplInheritanceHelper2
233         : public BaseClass
234         , public Ifc1, public Ifc2
235     {
236         /** @internal */
237         struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, AggImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {};
238     protected:
239         template< typename T1 >
AggImplInheritanceHelper2(T1 const & arg1)240         explicit AggImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {}
241         template< typename T1, typename T2 >
AggImplInheritanceHelper2(T1 const & arg1,T2 const & arg2)242         AggImplInheritanceHelper2(T1 const & arg1, T2 const & arg2):
243             BaseClass(arg1, arg2) {}
244         template< typename T1, typename T2, typename T3 >
AggImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3)245         AggImplInheritanceHelper2(
246             T1 const & arg1, T2 const & arg2, T3 const & arg3):
247             BaseClass(arg1, arg2, arg3) {}
248         template< typename T1, typename T2, typename T3, typename T4 >
AggImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4)249         AggImplInheritanceHelper2(
250             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
251             BaseClass(arg1, arg2, arg3, arg4) {}
252         template<
253             typename T1, typename T2, typename T3, typename T4, typename T5 >
AggImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5)254         AggImplInheritanceHelper2(
255             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
256             T5 const & arg5):
257             BaseClass(arg1, arg2, arg3, arg4, arg5) {}
258         template<
259             typename T1, typename T2, typename T3, typename T4, typename T5,
260             typename T6 >
AggImplInheritanceHelper2(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5,T6 const & arg6)261         AggImplInheritanceHelper2(
262             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
263             T5 const & arg5, T6 const & arg6):
264             BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
265     public:
AggImplInheritanceHelper2()266         AggImplInheritanceHelper2() {}
queryInterface(::com::sun::star::uno::Type const & rType)267         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
268             { return BaseClass::queryInterface( rType ); }
queryAggregation(::com::sun::star::uno::Type const & rType)269         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
270             {
271                 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
272                 if (aRet.hasValue())
273                     return aRet;
274                 return BaseClass::queryAggregation( rType );
275             }
acquire()276         virtual void SAL_CALL acquire() throw ()
277             { BaseClass::acquire(); }
release()278         virtual void SAL_CALL release() throw ()
279             { BaseClass::release(); }
getTypes()280         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
281             { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
getImplementationId()282         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
283             { return ImplHelper_getImplementationId( cd::get() ); }
284     };
285 }
286 
287 #endif
288