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_IMPLBASE4_HXX_
24 #define _CPPUHELPER_IMPLBASE4_HXX_
25 
26 #include <cppuhelper/implbase_ex.hxx>
27 #include <rtl/instance.hxx>
28 
29 namespace cppu
30 {
31     /** @internal */
32     struct class_data4
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[ 4 + 1 ];
39     };
40 
41     /** @internal */
42     template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Impl >
43         struct ImplClassData4
44     {
operator ()cppu::ImplClassData445         class_data* operator ()()
46         {
47             static class_data4 s_cd =
48             {
49                 4 +1, sal_False, sal_False,
50                 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
51                 {
52 					{ { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
53 					{ { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 },
54 					{ { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 },
55 					{ { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 },
56 					{ { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
57                 }
58             };
59             return reinterpret_cast< class_data * >(&s_cd);
60         }
61     };
62 
63     /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider
64         and method XInterface::queryInterface(), but no reference counting.
65 
66         @derive
67         Inherit from this class giving your interface(s) to be implemented as template argument(s).
68         Your sub class defines method implementations for these interface(s) including acquire()/
69         release() and delegates incoming queryInterface() calls to this base class.
70     */
71     template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
72     class SAL_NO_VTABLE ImplHelper4
73         : public ::com::sun::star::lang::XTypeProvider
74         , public Ifc1, public Ifc2, public Ifc3, public Ifc4
75     {
76         /** @internal */
77         struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
78     public:
queryInterface(::com::sun::star::uno::Type const & rType)79         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
80             { return ImplHelper_query( rType, cd::get(), this ); }
getTypes()81         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
82             { return ImplHelper_getTypes( cd::get() ); }
getImplementationId()83         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
84             { return ImplHelper_getImplementationId( cd::get() ); }
85     };
86     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
87         ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
88         (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
89 
90         @derive
91         Inherit from this class giving your interface(s) to be implemented as template argument(s).
92         Your sub class defines method implementations for these interface(s).
93     */
94     template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
95     class SAL_NO_VTABLE WeakImplHelper4
96         : public OWeakObject
97         , public ::com::sun::star::lang::XTypeProvider
98         , public Ifc1, public Ifc2, public Ifc3, public Ifc4
99     {
100         /** @internal */
101         struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
102     public:
queryInterface(::com::sun::star::uno::Type const & rType)103         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
104             { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
acquire()105         virtual void SAL_CALL acquire() throw ()
106             { OWeakObject::acquire(); }
release()107         virtual void SAL_CALL release() throw ()
108             { OWeakObject::release(); }
getTypes()109         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
110             { return WeakImplHelper_getTypes( cd::get() ); }
getImplementationId()111         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
112             { return ImplHelper_getImplementationId( cd::get() ); }
113     };
114     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
115         ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
116         (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
117         In addition, it supports also aggregation meaning object of this class can be aggregated
118         (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
119         If a delegator is set (this object is aggregated), then incoming queryInterface()
120         calls are delegated to the delegator object. If the delegator does not support the
121         demanded interface, it calls queryAggregation() on its aggregated objects.
122 
123         @derive
124         Inherit from this class giving your interface(s) to be implemented as template argument(s).
125         Your sub class defines method implementations for these interface(s).
126     */
127     template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
128     class SAL_NO_VTABLE WeakAggImplHelper4
129         : public OWeakAggObject
130         , public ::com::sun::star::lang::XTypeProvider
131         , public Ifc1, public Ifc2, public Ifc3, public Ifc4
132     {
133         /** @internal */
134         struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakAggImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {};
135     public:
queryInterface(::com::sun::star::uno::Type const & rType)136         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
137             { return OWeakAggObject::queryInterface( rType ); }
queryAggregation(::com::sun::star::uno::Type const & rType)138         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
139             { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
acquire()140         virtual void SAL_CALL acquire() throw ()
141             { OWeakAggObject::acquire(); }
release()142         virtual void SAL_CALL release() throw ()
143             { OWeakAggObject::release(); }
getTypes()144         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
145             { return WeakAggImplHelper_getTypes( cd::get() ); }
getImplementationId()146         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
147             { return ImplHelper_getImplementationId( cd::get() ); }
148     };
149     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
150         ::com::sun::star::uno::XInterface inherting from a BaseClass.
151         All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
152         if a demanded interface is not supported by this class directly, the request is
153         delegated to the BaseClass.
154 
155         @attention
156         The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface
157         and ::com::sun::star::lang::XTypeProvider are implemented properly.  The
158         BaseClass must have at least one ctor that can be called with six or
159         fewer arguments, of which none is of non-const reference type.
160 
161         @derive
162         Inherit from this class giving your additional interface(s) to be implemented as
163         template argument(s). Your sub class defines method implementations for these interface(s).
164     */
165     template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
166     class SAL_NO_VTABLE ImplInheritanceHelper4
167         : public BaseClass
168         , public Ifc1, public Ifc2, public Ifc3, public Ifc4
169     {
170         /** @internal */
171         struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {};
172     protected:
173         template< typename T1 >
ImplInheritanceHelper4(T1 const & arg1)174         explicit ImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {}
175         template< typename T1, typename T2 >
ImplInheritanceHelper4(T1 const & arg1,T2 const & arg2)176         ImplInheritanceHelper4(T1 const & arg1, T2 const & arg2):
177             BaseClass(arg1, arg2) {}
178         template< typename T1, typename T2, typename T3 >
ImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3)179         ImplInheritanceHelper4(
180             T1 const & arg1, T2 const & arg2, T3 const & arg3):
181             BaseClass(arg1, arg2, arg3) {}
182         template< typename T1, typename T2, typename T3, typename T4 >
ImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4)183         ImplInheritanceHelper4(
184             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
185             BaseClass(arg1, arg2, arg3, arg4) {}
186         template<
187             typename T1, typename T2, typename T3, typename T4, typename T5 >
ImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5)188         ImplInheritanceHelper4(
189             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
190             T5 const & arg5):
191             BaseClass(arg1, arg2, arg3, arg4, arg5) {}
192         template<
193             typename T1, typename T2, typename T3, typename T4, typename T5,
194             typename T6 >
ImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5,T6 const & arg6)195         ImplInheritanceHelper4(
196             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
197             T5 const & arg5, T6 const & arg6):
198             BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
199     public:
ImplInheritanceHelper4()200         ImplInheritanceHelper4() {}
queryInterface(::com::sun::star::uno::Type const & rType)201         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
202             {
203                 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
204                 if (aRet.hasValue())
205                     return aRet;
206                 return BaseClass::queryInterface( rType );
207             }
acquire()208         virtual void SAL_CALL acquire() throw ()
209             { BaseClass::acquire(); }
release()210         virtual void SAL_CALL release() throw ()
211             { BaseClass::release(); }
getTypes()212         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
213             { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
getImplementationId()214         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
215             { return ImplHelper_getImplementationId( cd::get() ); }
216     };
217     /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and
218         ::com::sun::star::uno::XInterface inherting from a BaseClass.
219         All acquire(),  release() and queryInterface() calls are delegated to the BaseClass.
220         Upon queryAggregation(), if a demanded interface is not supported by this class directly,
221         the request is delegated to the BaseClass.
222 
223         @attention
224         The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface,
225         ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider
226         are implemented properly.  The BaseClass must have at least one ctor
227         that can be called with six or fewer arguments, of which none is of
228         non-const reference type.
229 
230         @derive
231         Inherit from this class giving your additional interface(s) to be implemented as
232         template argument(s). Your sub class defines method implementations for these interface(s).
233     */
234     template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 >
235     class SAL_NO_VTABLE AggImplInheritanceHelper4
236         : public BaseClass
237         , public Ifc1, public Ifc2, public Ifc3, public Ifc4
238     {
239         /** @internal */
240         struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, AggImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {};
241     protected:
242         template< typename T1 >
AggImplInheritanceHelper4(T1 const & arg1)243         explicit AggImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {}
244         template< typename T1, typename T2 >
AggImplInheritanceHelper4(T1 const & arg1,T2 const & arg2)245         AggImplInheritanceHelper4(T1 const & arg1, T2 const & arg2):
246             BaseClass(arg1, arg2) {}
247         template< typename T1, typename T2, typename T3 >
AggImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3)248         AggImplInheritanceHelper4(
249             T1 const & arg1, T2 const & arg2, T3 const & arg3):
250             BaseClass(arg1, arg2, arg3) {}
251         template< typename T1, typename T2, typename T3, typename T4 >
AggImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4)252         AggImplInheritanceHelper4(
253             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
254             BaseClass(arg1, arg2, arg3, arg4) {}
255         template<
256             typename T1, typename T2, typename T3, typename T4, typename T5 >
AggImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5)257         AggImplInheritanceHelper4(
258             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
259             T5 const & arg5):
260             BaseClass(arg1, arg2, arg3, arg4, arg5) {}
261         template<
262             typename T1, typename T2, typename T3, typename T4, typename T5,
263             typename T6 >
AggImplInheritanceHelper4(T1 const & arg1,T2 const & arg2,T3 const & arg3,T4 const & arg4,T5 const & arg5,T6 const & arg6)264         AggImplInheritanceHelper4(
265             T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
266             T5 const & arg5, T6 const & arg6):
267             BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
268     public:
AggImplInheritanceHelper4()269         AggImplInheritanceHelper4() {}
queryInterface(::com::sun::star::uno::Type const & rType)270         virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
271             { return BaseClass::queryInterface( rType ); }
queryAggregation(::com::sun::star::uno::Type const & rType)272         virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException)
273             {
274                 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
275                 if (aRet.hasValue())
276                     return aRet;
277                 return BaseClass::queryAggregation( rType );
278             }
acquire()279         virtual void SAL_CALL acquire() throw ()
280             { BaseClass::acquire(); }
release()281         virtual void SAL_CALL release() throw ()
282             { BaseClass::release(); }
getTypes()283         virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException)
284             { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
getImplementationId()285         virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException)
286             { return ImplHelper_getImplementationId( cd::get() ); }
287     };
288 }
289 
290 #endif
291