Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _CPPUHELPER_IMPLBASE1_HXX_
20 : #define _CPPUHELPER_IMPLBASE1_HXX_
21 :
22 : #include <cppuhelper/implbase_ex.hxx>
23 : #include <rtl/instance.hxx>
24 : #include <com/sun/star/uno/XComponentContext.hpp>
25 :
26 : namespace cppu
27 : {
28 : /// @cond INTERNAL
29 :
30 : struct class_data1
31 : {
32 : sal_Int16 m_nTypes;
33 : sal_Bool m_storedTypeRefs;
34 : sal_Bool m_storedId;
35 : sal_Int8 m_id[ 16 ];
36 : type_entry m_typeEntries[ 1 + 1 ];
37 : };
38 :
39 : template< typename Ifc1, typename Impl > struct ImplClassData1
40 : {
41 1093 : class_data* operator ()()
42 : {
43 : static class_data1 s_cd =
44 : {
45 : 1 +1, sal_False, sal_False,
46 : { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
47 : {
48 : { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 },
49 : { { com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 }
50 : }
51 : };
52 1093 : return reinterpret_cast< class_data * >(&s_cd);
53 : }
54 : };
55 :
56 : /// @endcond
57 :
58 : /** Implementation helper implementing interface com::sun::star::lang::XTypeProvider
59 : and method XInterface::queryInterface(), but no reference counting.
60 :
61 : @derive
62 : Inherit from this class giving your interface(s) to be implemented as template argument(s).
63 : Your sub class defines method implementations for these interface(s) including acquire()/
64 : release() and delegates incoming queryInterface() calls to this base class.
65 : */
66 : template< class Ifc1 >
67 4708 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper1
68 : : public com::sun::star::lang::XTypeProvider
69 : , public Ifc1
70 : {
71 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData1 < Ifc1, ImplHelper1<Ifc1> > > {};
72 : public:
73 54523 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
74 54523 : { return ImplHelper_query( rType, cd::get(), this ); }
75 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
76 0 : { return ImplHelper_getTypes( cd::get() ); }
77 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
78 0 : { return ImplHelper_getImplementationId( cd::get() ); }
79 :
80 : #if !defined _MSC_VER // public -> protected changes mangled names there
81 : protected:
82 : #endif
83 3659 : ~ImplHelper1() throw () {}
84 : };
85 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
86 : com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
87 : (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakObject).
88 :
89 : @derive
90 : Inherit from this class giving your interface(s) to be implemented as template argument(s).
91 : Your sub class defines method implementations for these interface(s).
92 :
93 : These classes are used when you implement your UNO component.
94 : WeakImplHelper1 till WeakImplHelper12 can be used when you want
95 : to implement 1 till 12 interfaces in your component.
96 : */
97 : template< class Ifc1 >
98 493208 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper1
99 : : public OWeakObject
100 : , public com::sun::star::lang::XTypeProvider
101 : , public Ifc1
102 : {
103 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakImplHelper1< Ifc1 > > > {};
104 : public:
105 75857 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
106 75857 : { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); }
107 1564613 : virtual void SAL_CALL acquire() throw ()
108 1564613 : { OWeakObject::acquire(); }
109 1547820 : virtual void SAL_CALL release() throw ()
110 1547820 : { OWeakObject::release(); }
111 1 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
112 1 : { return WeakImplHelper_getTypes( cd::get() ); }
113 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
114 0 : { return ImplHelper_getImplementationId( cd::get() ); }
115 : };
116 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
117 : com::sun::star::uno::XInterface which supports weak mechanism to be held weakly
118 : (supporting com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject).
119 : In addition, it supports also aggregation meaning object of this class can be aggregated
120 : (com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject).
121 : If a delegator is set (this object is aggregated), then incoming queryInterface()
122 : calls are delegated to the delegator object. If the delegator does not support the
123 : demanded interface, it calls queryAggregation() on its aggregated objects.
124 :
125 : @derive
126 : Inherit from this class giving your interface(s) to be implemented as template argument(s).
127 : Your sub class defines method implementations for these interface(s).
128 : */
129 : template< class Ifc1 >
130 9832 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper1
131 : : public OWeakAggObject
132 : , public com::sun::star::lang::XTypeProvider
133 : , public Ifc1
134 : {
135 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakAggImplHelper1< Ifc1 > > > {};
136 : public:
137 288 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
138 288 : { return OWeakAggObject::queryInterface( rType ); }
139 288 : virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
140 288 : { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); }
141 1844 : virtual void SAL_CALL acquire() throw ()
142 1844 : { OWeakAggObject::acquire(); }
143 1844 : virtual void SAL_CALL release() throw ()
144 1844 : { OWeakAggObject::release(); }
145 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
146 0 : { return WeakAggImplHelper_getTypes( cd::get() ); }
147 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
148 0 : { return ImplHelper_getImplementationId( cd::get() ); }
149 : };
150 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
151 : com::sun::star::uno::XInterface inherting from a BaseClass.
152 : All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
153 : if a demanded interface is not supported by this class directly, the request is
154 : delegated to the BaseClass.
155 :
156 : @attention
157 : The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface
158 : and com::sun::star::lang::XTypeProvider are implemented properly. The
159 : BaseClass must have at least one ctor that can be called with six or
160 : fewer arguments, of which none is of non-const reference type.
161 :
162 : @derive
163 : Inherit from this class giving your additional interface(s) to be implemented as
164 : template argument(s). Your sub class defines method implementations for these interface(s).
165 : */
166 : template< class BaseClass, class Ifc1 >
167 69732 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper1
168 : : public BaseClass
169 : , public Ifc1
170 : {
171 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, ImplInheritanceHelper1< BaseClass, Ifc1 > > > {};
172 : protected:
173 : #if (defined __SUNPRO_CC && __SUNPRO_CC <= 0x550)
174 : // Hack, to get comphelper::service_decl to work for non-trivial impl classes
175 : ImplInheritanceHelper1( com::sun::star::uno::Sequence<com::sun::star::uno::Any> const& args,
176 : com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const& xContext ) : BaseClass(args,xContext) {}
177 : #endif
178 : template< typename T1 >
179 255 : explicit ImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {}
180 : template< typename T1, typename T2 >
181 39 : ImplInheritanceHelper1(T1 const & arg1, T2 const & arg2):
182 39 : BaseClass(arg1, arg2) {}
183 : template< typename T1, typename T2, typename T3 >
184 1 : ImplInheritanceHelper1(
185 : T1 const & arg1, T2 const & arg2, T3 const & arg3):
186 1 : BaseClass(arg1, arg2, arg3) {}
187 : template< typename T1, typename T2, typename T3, typename T4 >
188 21245 : ImplInheritanceHelper1(
189 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
190 21245 : BaseClass(arg1, arg2, arg3, arg4) {}
191 : template<
192 : typename T1, typename T2, typename T3, typename T4, typename T5 >
193 0 : ImplInheritanceHelper1(
194 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
195 : T5 const & arg5):
196 0 : BaseClass(arg1, arg2, arg3, arg4, arg5) {}
197 : template<
198 : typename T1, typename T2, typename T3, typename T4, typename T5,
199 : typename T6 >
200 0 : ImplInheritanceHelper1(
201 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
202 : T5 const & arg5, T6 const & arg6):
203 0 : BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
204 : public:
205 49050 : ImplInheritanceHelper1() {}
206 266267 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
207 : {
208 266267 : com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
209 266267 : if (aRet.hasValue())
210 104997 : return aRet;
211 161270 : return BaseClass::queryInterface( rType );
212 : }
213 968938 : virtual void SAL_CALL acquire() throw ()
214 968938 : { BaseClass::acquire(); }
215 968036 : virtual void SAL_CALL release() throw ()
216 968036 : { BaseClass::release(); }
217 1 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
218 1 : { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
219 1 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
220 1 : { return ImplHelper_getImplementationId( cd::get() ); }
221 : };
222 : /** Implementation helper implementing interfaces com::sun::star::lang::XTypeProvider and
223 : com::sun::star::uno::XInterface inherting from a BaseClass.
224 : All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
225 : Upon queryAggregation(), if a demanded interface is not supported by this class directly,
226 : the request is delegated to the BaseClass.
227 :
228 : @attention
229 : The BaseClass has to be complete in a sense, that com::sun::star::uno::XInterface,
230 : com::sun::star::uno::XAggregation and com::sun::star::lang::XTypeProvider
231 : are implemented properly. The BaseClass must have at least one ctor
232 : that can be called with six or fewer arguments, of which none is of
233 : non-const reference type.
234 :
235 : @derive
236 : Inherit from this class giving your additional interface(s) to be implemented as
237 : template argument(s). Your sub class defines method implementations for these interface(s).
238 : */
239 : template< class BaseClass, class Ifc1 >
240 0 : class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper1
241 : : public BaseClass
242 : , public Ifc1
243 : {
244 : struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, AggImplInheritanceHelper1< BaseClass, Ifc1 > > > {};
245 : protected:
246 : template< typename T1 >
247 0 : explicit AggImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {}
248 : template< typename T1, typename T2 >
249 : AggImplInheritanceHelper1(T1 const & arg1, T2 const & arg2):
250 : BaseClass(arg1, arg2) {}
251 : template< typename T1, typename T2, typename T3 >
252 : AggImplInheritanceHelper1(
253 : T1 const & arg1, T2 const & arg2, T3 const & arg3):
254 : BaseClass(arg1, arg2, arg3) {}
255 : template< typename T1, typename T2, typename T3, typename T4 >
256 : AggImplInheritanceHelper1(
257 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
258 : BaseClass(arg1, arg2, arg3, arg4) {}
259 : template<
260 : typename T1, typename T2, typename T3, typename T4, typename T5 >
261 : AggImplInheritanceHelper1(
262 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
263 : T5 const & arg5):
264 : BaseClass(arg1, arg2, arg3, arg4, arg5) {}
265 : template<
266 : typename T1, typename T2, typename T3, typename T4, typename T5,
267 : typename T6 >
268 : AggImplInheritanceHelper1(
269 : T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
270 : T5 const & arg5, T6 const & arg6):
271 : BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
272 : public:
273 : AggImplInheritanceHelper1() {}
274 0 : virtual com::sun::star::uno::Any SAL_CALL queryInterface( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
275 0 : { return BaseClass::queryInterface( rType ); }
276 0 : virtual com::sun::star::uno::Any SAL_CALL queryAggregation( com::sun::star::uno::Type const & rType ) throw (com::sun::star::uno::RuntimeException)
277 : {
278 0 : com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
279 0 : if (aRet.hasValue())
280 0 : return aRet;
281 0 : return BaseClass::queryAggregation( rType );
282 : }
283 0 : virtual void SAL_CALL acquire() throw ()
284 0 : { BaseClass::acquire(); }
285 0 : virtual void SAL_CALL release() throw ()
286 0 : { BaseClass::release(); }
287 0 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes() throw (com::sun::star::uno::RuntimeException)
288 0 : { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
289 0 : virtual com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (com::sun::star::uno::RuntimeException)
290 0 : { return ImplHelper_getImplementationId( cd::get() ); }
291 : };
292 : }
293 :
294 : #endif
295 :
296 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|