1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _CPPUHELPER_IMPLBASE3_HXX_ 28 #define _CPPUHELPER_IMPLBASE3_HXX_ 29 30 #include <cppuhelper/implbase_ex.hxx> 31 #include <rtl/instance.hxx> 32 33 namespace cppu 34 { 35 /** @internal */ 36 struct class_data3 37 { 38 sal_Int16 m_nTypes; 39 sal_Bool m_storedTypeRefs; 40 sal_Bool m_storedId; 41 sal_Int8 m_id[ 16 ]; 42 type_entry m_typeEntries[ 3 + 1 ]; 43 }; 44 45 /** @internal */ 46 template< typename Ifc1, typename Ifc2, typename Ifc3, typename Impl > struct ImplClassData3 47 { 48 class_data* operator ()() 49 { 50 static class_data3 s_cd = 51 { 52 3 +1, sal_False, sal_False, 53 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 54 { 55 { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, 56 { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, 57 { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, 58 { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } 59 } 60 }; 61 return reinterpret_cast< class_data * >(&s_cd); 62 } 63 }; 64 65 /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider 66 and method XInterface::queryInterface(), but no reference counting. 67 68 @derive 69 Inherit from this class giving your interface(s) to be implemented as template argument(s). 70 Your sub class defines method implementations for these interface(s) including acquire()/ 71 release() and delegates incoming queryInterface() calls to this base class. 72 */ 73 template< class Ifc1, class Ifc2, class Ifc3 > 74 class SAL_NO_VTABLE ImplHelper3 75 : public ::com::sun::star::lang::XTypeProvider 76 , public Ifc1, public Ifc2, public Ifc3 77 { 78 /** @internal */ 79 struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; 80 public: 81 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) 82 { return ImplHelper_query( rType, cd::get(), this ); } 83 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) 84 { return ImplHelper_getTypes( cd::get() ); } 85 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) 86 { return ImplHelper_getImplementationId( cd::get() ); } 87 }; 88 /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and 89 ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly 90 (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). 91 92 @derive 93 Inherit from this class giving your interface(s) to be implemented as template argument(s). 94 Your sub class defines method implementations for these interface(s). 95 */ 96 template< class Ifc1, class Ifc2, class Ifc3 > 97 class SAL_NO_VTABLE WeakImplHelper3 98 : public OWeakObject 99 , public ::com::sun::star::lang::XTypeProvider 100 , public Ifc1, public Ifc2, public Ifc3 101 { 102 /** @internal */ 103 struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; 104 public: 105 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) 106 { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } 107 virtual void SAL_CALL acquire() throw () 108 { OWeakObject::acquire(); } 109 virtual void SAL_CALL release() throw () 110 { OWeakObject::release(); } 111 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) 112 { return WeakImplHelper_getTypes( cd::get() ); } 113 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) 114 { 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, class Ifc2, class Ifc3 > 130 class SAL_NO_VTABLE WeakAggImplHelper3 131 : public OWeakAggObject 132 , public ::com::sun::star::lang::XTypeProvider 133 , public Ifc1, public Ifc2, public Ifc3 134 { 135 /** @internal */ 136 struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakAggImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; 137 public: 138 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) 139 { return OWeakAggObject::queryInterface( rType ); } 140 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) 141 { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } 142 virtual void SAL_CALL acquire() throw () 143 { OWeakAggObject::acquire(); } 144 virtual void SAL_CALL release() throw () 145 { OWeakAggObject::release(); } 146 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) 147 { return WeakAggImplHelper_getTypes( cd::get() ); } 148 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) 149 { return ImplHelper_getImplementationId( cd::get() ); } 150 }; 151 /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and 152 ::com::sun::star::uno::XInterface inherting from a BaseClass. 153 All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), 154 if a demanded interface is not supported by this class directly, the request is 155 delegated to the BaseClass. 156 157 @attention 158 The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface 159 and ::com::sun::star::lang::XTypeProvider are implemented properly. The 160 BaseClass must have at least one ctor that can be called with six or 161 fewer arguments, of which none is of non-const reference type. 162 also has to have a default ctor. 163 164 @derive 165 Inherit from this class giving your additional interface(s) to be implemented as 166 template argument(s). Your sub class defines method implementations for these interface(s). 167 */ 168 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 > 169 class SAL_NO_VTABLE ImplInheritanceHelper3 170 : public BaseClass 171 , public Ifc1, public Ifc2, public Ifc3 172 { 173 /** @internal */ 174 struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {}; 175 protected: 176 template< typename T1 > 177 explicit ImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {} 178 template< typename T1, typename T2 > 179 ImplInheritanceHelper3(T1 const & arg1, T2 const & arg2): 180 BaseClass(arg1, arg2) {} 181 template< typename T1, typename T2, typename T3 > 182 ImplInheritanceHelper3( 183 T1 const & arg1, T2 const & arg2, T3 const & arg3): 184 BaseClass(arg1, arg2, arg3) {} 185 template< typename T1, typename T2, typename T3, typename T4 > 186 ImplInheritanceHelper3( 187 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): 188 BaseClass(arg1, arg2, arg3, arg4) {} 189 template< 190 typename T1, typename T2, typename T3, typename T4, typename T5 > 191 ImplInheritanceHelper3( 192 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, 193 T5 const & arg5): 194 BaseClass(arg1, arg2, arg3, arg4, arg5) {} 195 template< 196 typename T1, typename T2, typename T3, typename T4, typename T5, 197 typename T6 > 198 ImplInheritanceHelper3( 199 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, 200 T5 const & arg5, T6 const & arg6): 201 BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} 202 public: 203 ImplInheritanceHelper3() {} 204 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) 205 { 206 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); 207 if (aRet.hasValue()) 208 return aRet; 209 return BaseClass::queryInterface( rType ); 210 } 211 virtual void SAL_CALL acquire() throw () 212 { BaseClass::acquire(); } 213 virtual void SAL_CALL release() throw () 214 { BaseClass::release(); } 215 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) 216 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } 217 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) 218 { return ImplHelper_getImplementationId( cd::get() ); } 219 }; 220 /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and 221 ::com::sun::star::uno::XInterface inherting from a BaseClass. 222 All acquire(), release() and queryInterface() calls are delegated to the BaseClass. 223 Upon queryAggregation(), if a demanded interface is not supported by this class directly, 224 the request is delegated to the BaseClass. 225 226 @attention 227 The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, 228 ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider 229 are implemented properly. The BaseClass must have at least one ctor 230 that can be called with six or fewer arguments, of which none is of 231 non-const reference type. 232 233 @derive 234 Inherit from this class giving your additional interface(s) to be implemented as 235 template argument(s). Your sub class defines method implementations for these interface(s). 236 */ 237 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 > 238 class SAL_NO_VTABLE AggImplInheritanceHelper3 239 : public BaseClass 240 , public Ifc1, public Ifc2, public Ifc3 241 { 242 /** @internal */ 243 struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, AggImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {}; 244 protected: 245 template< typename T1 > 246 explicit AggImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {} 247 template< typename T1, typename T2 > 248 AggImplInheritanceHelper3(T1 const & arg1, T2 const & arg2): 249 BaseClass(arg1, arg2) {} 250 template< typename T1, typename T2, typename T3 > 251 AggImplInheritanceHelper3( 252 T1 const & arg1, T2 const & arg2, T3 const & arg3): 253 BaseClass(arg1, arg2, arg3) {} 254 template< typename T1, typename T2, typename T3, typename T4 > 255 AggImplInheritanceHelper3( 256 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): 257 BaseClass(arg1, arg2, arg3, arg4) {} 258 template< 259 typename T1, typename T2, typename T3, typename T4, typename T5 > 260 AggImplInheritanceHelper3( 261 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, 262 T5 const & arg5): 263 BaseClass(arg1, arg2, arg3, arg4, arg5) {} 264 template< 265 typename T1, typename T2, typename T3, typename T4, typename T5, 266 typename T6 > 267 AggImplInheritanceHelper3( 268 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, 269 T5 const & arg5, T6 const & arg6): 270 BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} 271 public: 272 AggImplInheritanceHelper3() {} 273 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) 274 { return BaseClass::queryInterface( rType ); } 275 virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) 276 { 277 ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); 278 if (aRet.hasValue()) 279 return aRet; 280 return BaseClass::queryAggregation( rType ); 281 } 282 virtual void SAL_CALL acquire() throw () 283 { BaseClass::acquire(); } 284 virtual void SAL_CALL release() throw () 285 { BaseClass::release(); } 286 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) 287 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } 288 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) 289 { return ImplHelper_getImplementationId( cd::get() ); } 290 }; 291 } 292 293 #endif 294