Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / cppuhelper / implbase5.hxx
blob4a8c15dd1c9b9eecadfa37a7ba0addf701a9d8d2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 * This file is part of LibreOffice published API.
23 #ifndef INCLUDED_CPPUHELPER_IMPLBASE5_HXX
24 #define INCLUDED_CPPUHELPER_IMPLBASE5_HXX
26 #include "cppuhelper/implbase_ex.hxx"
27 #include "rtl/instance.hxx"
28 #include "cppuhelper/weak.hxx"
29 #include "cppuhelper/weakagg.hxx"
30 #include "com/sun/star/lang/XTypeProvider.hpp"
32 namespace cppu
34 /// @cond INTERNAL
36 struct class_data5
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[ 5 + 1 ];
45 template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Impl >
46 struct SAL_WARN_UNUSED ImplClassData5
48 class_data* operator ()()
50 static class_data5 s_cd =
52 5 +1, false, false,
53 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
55 CPPUHELPER_DETAIL_TYPEENTRY(Ifc1),
56 CPPUHELPER_DETAIL_TYPEENTRY(Ifc2),
57 CPPUHELPER_DETAIL_TYPEENTRY(Ifc3),
58 CPPUHELPER_DETAIL_TYPEENTRY(Ifc4),
59 CPPUHELPER_DETAIL_TYPEENTRY(Ifc5),
60 CPPUHELPER_DETAIL_TYPEENTRY(css::lang::XTypeProvider)
63 return reinterpret_cast< class_data * >(&s_cd);
67 /// @endcond
69 /** Implementation helper implementing interface css::lang::XTypeProvider
70 and method XInterface::queryInterface(), but no reference counting.
72 @derive
73 Inherit from this class giving your interface(s) to be implemented as template argument(s).
74 Your sub class defines method implementations for these interface(s) including acquire()/
75 release() and delegates incoming queryInterface() calls to this base class.
77 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
78 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper5
79 : public css::lang::XTypeProvider
80 , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
82 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, ImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
83 public:
84 #if defined LIBO_INTERNAL_ONLY
85 ImplHelper5() = default;
86 ImplHelper5(ImplHelper5 const &) = default;
87 ImplHelper5(ImplHelper5 &&) = default;
88 ImplHelper5 & operator =(ImplHelper5 const &) = default;
89 ImplHelper5 & operator =(ImplHelper5 &&) = default;
90 #endif
92 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) SAL_OVERRIDE
93 { return ImplHelper_query( rType, cd::get(), this ); }
94 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
95 { return ImplHelper_getTypes( cd::get() ); }
96 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() SAL_OVERRIDE
97 { return ImplHelper_getImplementationId( cd::get() ); }
99 #if !defined _MSC_VER // public -> protected changes mangled names there
100 protected:
101 #endif
102 ~ImplHelper5() SAL_NOEXCEPT {}
104 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
105 css::uno::XInterface which supports weak mechanism to be held weakly
106 (supporting css::uno::XWeak thru ::cppu::OWeakObject).
108 @derive
109 Inherit from this class giving your interface(s) to be implemented as template argument(s).
110 Your sub class defines method implementations for these interface(s).
112 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
113 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper5
114 : public OWeakObject
115 , public css::lang::XTypeProvider
116 , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
118 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
119 public:
120 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) SAL_OVERRIDE
121 { return WeakImplHelper_query( rType, cd::get(), this, static_cast<OWeakObject *>(this) ); }
122 virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
123 { OWeakObject::acquire(); }
124 virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
125 { OWeakObject::release(); }
126 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
127 { return WeakImplHelper_getTypes( cd::get() ); }
128 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() SAL_OVERRIDE
129 { return ImplHelper_getImplementationId( cd::get() ); }
131 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
132 css::uno::XInterface which supports weak mechanism to be held weakly
133 (supporting css::uno::XWeak thru ::cppu::OWeakAggObject).
134 In addition, it supports also aggregation meaning object of this class can be aggregated
135 (css::uno::XAggregation thru ::cppu::OWeakAggObject).
136 If a delegator is set (this object is aggregated), then incoming queryInterface()
137 calls are delegated to the delegator object. If the delegator does not support the
138 demanded interface, it calls queryAggregation() on its aggregated objects.
140 @derive
141 Inherit from this class giving your interface(s) to be implemented as template argument(s).
142 Your sub class defines method implementations for these interface(s).
144 template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
145 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper5
146 : public OWeakAggObject
147 , public css::lang::XTypeProvider
148 , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
150 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakAggImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
151 public:
152 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) SAL_OVERRIDE
153 { return OWeakAggObject::queryInterface( rType ); }
154 virtual css::uno::Any SAL_CALL queryAggregation( css::uno::Type const & rType ) SAL_OVERRIDE
155 { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, static_cast<OWeakAggObject *>(this) ); }
156 virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
157 { OWeakAggObject::acquire(); }
158 virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
159 { OWeakAggObject::release(); }
160 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
161 { return WeakAggImplHelper_getTypes( cd::get() ); }
162 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() SAL_OVERRIDE
163 { return ImplHelper_getImplementationId( cd::get() ); }
165 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
166 css::uno::XInterface inheriting from a BaseClass.
167 All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(),
168 if a demanded interface is not supported by this class directly, the request is
169 delegated to the BaseClass.
171 @attention
172 The BaseClass has to be complete in a sense, that css::uno::XInterface
173 and css::lang::XTypeProvider are implemented properly. The
174 BaseClass must have at least one ctor that can be called with six or
175 fewer arguments, of which none is of non-const reference type.
177 @derive
178 Inherit from this class giving your additional interface(s) to be implemented as
179 template argument(s). Your sub class defines method implementations for these interface(s).
181 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
182 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper5
183 : public BaseClass
184 , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
186 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, ImplInheritanceHelper5<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
187 protected:
188 template< typename T1 >
189 explicit ImplInheritanceHelper5(T1 const & arg1): BaseClass(arg1) {}
190 template< typename T1, typename T2 >
191 ImplInheritanceHelper5(T1 const & arg1, T2 const & arg2):
192 BaseClass(arg1, arg2) {}
193 template< typename T1, typename T2, typename T3 >
194 ImplInheritanceHelper5(
195 T1 const & arg1, T2 const & arg2, T3 const & arg3):
196 BaseClass(arg1, arg2, arg3) {}
197 template< typename T1, typename T2, typename T3, typename T4 >
198 ImplInheritanceHelper5(
199 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
200 BaseClass(arg1, arg2, arg3, arg4) {}
201 template<
202 typename T1, typename T2, typename T3, typename T4, typename T5 >
203 ImplInheritanceHelper5(
204 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
205 T5 const & arg5):
206 BaseClass(arg1, arg2, arg3, arg4, arg5) {}
207 template<
208 typename T1, typename T2, typename T3, typename T4, typename T5,
209 typename T6 >
210 ImplInheritanceHelper5(
211 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
212 T5 const & arg5, T6 const & arg6):
213 BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
214 public:
215 ImplInheritanceHelper5() {}
216 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) SAL_OVERRIDE
218 css::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
219 if (aRet.hasValue())
220 return aRet;
221 return BaseClass::queryInterface( rType );
223 virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
224 { BaseClass::acquire(); }
225 virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
226 { BaseClass::release(); }
227 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
228 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
229 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() SAL_OVERRIDE
230 { return ImplHelper_getImplementationId( cd::get() ); }
232 /** Implementation helper implementing interfaces css::lang::XTypeProvider and
233 css::uno::XInterface inheriting from a BaseClass.
234 All acquire(), release() and queryInterface() calls are delegated to the BaseClass.
235 Upon queryAggregation(), if a demanded interface is not supported by this class directly,
236 the request is delegated to the BaseClass.
238 @attention
239 The BaseClass has to be complete in a sense, that css::uno::XInterface,
240 css::uno::XAggregation and css::lang::XTypeProvider
241 are implemented properly. The BaseClass must have at least one ctor
242 that can be called with six or fewer arguments, of which none is of
243 non-const reference type.
245 @derive
246 Inherit from this class giving your additional interface(s) to be implemented as
247 template argument(s). Your sub class defines method implementations for these interface(s).
249 template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 >
250 class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper5
251 : public BaseClass
252 , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5
254 struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, AggImplInheritanceHelper5<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {};
255 protected:
256 template< typename T1 >
257 explicit AggImplInheritanceHelper5(T1 const & arg1): BaseClass(arg1) {}
258 template< typename T1, typename T2 >
259 AggImplInheritanceHelper5(T1 const & arg1, T2 const & arg2):
260 BaseClass(arg1, arg2) {}
261 template< typename T1, typename T2, typename T3 >
262 AggImplInheritanceHelper5(
263 T1 const & arg1, T2 const & arg2, T3 const & arg3):
264 BaseClass(arg1, arg2, arg3) {}
265 template< typename T1, typename T2, typename T3, typename T4 >
266 AggImplInheritanceHelper5(
267 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4):
268 BaseClass(arg1, arg2, arg3, arg4) {}
269 template<
270 typename T1, typename T2, typename T3, typename T4, typename T5 >
271 AggImplInheritanceHelper5(
272 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
273 T5 const & arg5):
274 BaseClass(arg1, arg2, arg3, arg4, arg5) {}
275 template<
276 typename T1, typename T2, typename T3, typename T4, typename T5,
277 typename T6 >
278 AggImplInheritanceHelper5(
279 T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4,
280 T5 const & arg5, T6 const & arg6):
281 BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {}
282 public:
283 AggImplInheritanceHelper5() {}
284 virtual css::uno::Any SAL_CALL queryInterface( css::uno::Type const & rType ) SAL_OVERRIDE
285 { return BaseClass::queryInterface( rType ); }
286 virtual css::uno::Any SAL_CALL queryAggregation( css::uno::Type const & rType ) SAL_OVERRIDE
288 css::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) );
289 if (aRet.hasValue())
290 return aRet;
291 return BaseClass::queryAggregation( rType );
293 virtual void SAL_CALL acquire() SAL_NOEXCEPT SAL_OVERRIDE
294 { BaseClass::acquire(); }
295 virtual void SAL_CALL release() SAL_NOEXCEPT SAL_OVERRIDE
296 { BaseClass::release(); }
297 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() SAL_OVERRIDE
298 { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); }
299 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() SAL_OVERRIDE
300 { return ImplHelper_getImplementationId( cd::get() ); }
304 #endif
306 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */