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