Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / cppuhelper / source / typeprovider.cxx
blobc4258ef61cc844a3cf0c81a2226e280f59838fdc
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 .
20 #include <cppuhelper/typeprovider.hxx>
22 #include <rtl/uuid.h>
23 #include <osl/mutex.hxx>
25 using namespace osl;
26 using namespace com::sun::star::uno;
28 namespace cppu
32 OImplementationId::~OImplementationId()
34 delete _pSeq;
37 Sequence< sal_Int8 > OImplementationId::getImplementationId() const
39 if (! _pSeq)
41 MutexGuard aGuard( Mutex::getGlobalMutex() );
42 if (! _pSeq)
44 Sequence< sal_Int8 > * pSeq = new Sequence< sal_Int8 >( 16 );
45 ::rtl_createUuid( reinterpret_cast<sal_uInt8 *>(pSeq->getArray()), nullptr, _bUseEthernetAddress );
46 _pSeq = pSeq;
49 return *_pSeq;
53 static void copy( Sequence< Type > & rDest, const Sequence< Type > & rSource, sal_Int32 nOffset )
55 Type * pDest = rDest.getArray();
56 const Type * pSource = rSource.getConstArray();
58 for ( sal_Int32 nPos = rSource.getLength(); nPos--; )
59 pDest[nOffset+ nPos] = pSource[nPos];
63 OTypeCollection::OTypeCollection(
64 const Type & rType1,
65 const Sequence< Type > & rAddTypes )
66 : _aTypes( 1 + rAddTypes.getLength() )
68 _aTypes[0] = rType1;
69 copy( _aTypes, rAddTypes, 1 );
72 OTypeCollection::OTypeCollection(
73 const Type & rType1,
74 const Type & rType2,
75 const Sequence< Type > & rAddTypes )
76 : _aTypes( 2 + rAddTypes.getLength() )
78 _aTypes[0] = rType1;
79 _aTypes[1] = rType2;
80 copy( _aTypes, rAddTypes, 2 );
83 OTypeCollection::OTypeCollection(
84 const Type & rType1,
85 const Type & rType2,
86 const Type & rType3,
87 const Sequence< Type > & rAddTypes )
88 : _aTypes( 3 + rAddTypes.getLength() )
90 _aTypes[0] = rType1;
91 _aTypes[1] = rType2;
92 _aTypes[2] = rType3;
93 copy( _aTypes, rAddTypes, 3 );
96 OTypeCollection::OTypeCollection(
97 const Type & rType1,
98 const Type & rType2,
99 const Type & rType3,
100 const Type & rType4,
101 const Sequence< Type > & rAddTypes )
102 : _aTypes( 4 + rAddTypes.getLength() )
104 _aTypes[0] = rType1;
105 _aTypes[1] = rType2;
106 _aTypes[2] = rType3;
107 _aTypes[3] = rType4;
108 copy( _aTypes, rAddTypes, 4 );
111 OTypeCollection::OTypeCollection(
112 const Type & rType1,
113 const Type & rType2,
114 const Type & rType3,
115 const Type & rType4,
116 const Type & rType5,
117 const Sequence< Type > & rAddTypes )
118 : _aTypes( 5 + rAddTypes.getLength() )
120 _aTypes[0] = rType1;
121 _aTypes[1] = rType2;
122 _aTypes[2] = rType3;
123 _aTypes[3] = rType4;
124 _aTypes[4] = rType5;
125 copy( _aTypes, rAddTypes, 5 );
128 OTypeCollection::OTypeCollection(
129 const Type & rType1,
130 const Type & rType2,
131 const Type & rType3,
132 const Type & rType4,
133 const Type & rType5,
134 const Type & rType6,
135 const Sequence< Type > & rAddTypes )
136 : _aTypes( 6 + rAddTypes.getLength() )
138 _aTypes[0] = rType1;
139 _aTypes[1] = rType2;
140 _aTypes[2] = rType3;
141 _aTypes[3] = rType4;
142 _aTypes[4] = rType5;
143 _aTypes[5] = rType6;
144 copy( _aTypes, rAddTypes, 6 );
147 OTypeCollection::OTypeCollection(
148 const Type & rType1,
149 const Type & rType2,
150 const Type & rType3,
151 const Type & rType4,
152 const Type & rType5,
153 const Type & rType6,
154 const Type & rType7,
155 const Sequence< Type > & rAddTypes )
156 : _aTypes( 7 + rAddTypes.getLength() )
158 _aTypes[0] = rType1;
159 _aTypes[1] = rType2;
160 _aTypes[2] = rType3;
161 _aTypes[3] = rType4;
162 _aTypes[4] = rType5;
163 _aTypes[5] = rType6;
164 _aTypes[6] = rType7;
165 copy( _aTypes, rAddTypes, 7 );
168 OTypeCollection::OTypeCollection(
169 const Type & rType1,
170 const Type & rType2,
171 const Type & rType3,
172 const Type & rType4,
173 const Type & rType5,
174 const Type & rType6,
175 const Type & rType7,
176 const Type & rType8,
177 const Sequence< Type > & rAddTypes )
178 : _aTypes( 8 + rAddTypes.getLength() )
180 _aTypes[0] = rType1;
181 _aTypes[1] = rType2;
182 _aTypes[2] = rType3;
183 _aTypes[3] = rType4;
184 _aTypes[4] = rType5;
185 _aTypes[5] = rType6;
186 _aTypes[6] = rType7;
187 _aTypes[7] = rType8;
188 copy( _aTypes, rAddTypes, 8 );
191 OTypeCollection::OTypeCollection(
192 const Type & rType1,
193 const Type & rType2,
194 const Type & rType3,
195 const Type & rType4,
196 const Type & rType5,
197 const Type & rType6,
198 const Type & rType7,
199 const Type & rType8,
200 const Type & rType9,
201 const Sequence< Type > & rAddTypes )
202 : _aTypes( 9 + rAddTypes.getLength() )
204 _aTypes[0] = rType1;
205 _aTypes[1] = rType2;
206 _aTypes[2] = rType3;
207 _aTypes[3] = rType4;
208 _aTypes[4] = rType5;
209 _aTypes[5] = rType6;
210 _aTypes[6] = rType7;
211 _aTypes[7] = rType8;
212 _aTypes[8] = rType9;
213 copy( _aTypes, rAddTypes, 9 );
216 OTypeCollection::OTypeCollection(
217 const Type & rType1,
218 const Type & rType2,
219 const Type & rType3,
220 const Type & rType4,
221 const Type & rType5,
222 const Type & rType6,
223 const Type & rType7,
224 const Type & rType8,
225 const Type & rType9,
226 const Type & rType10,
227 const Sequence< Type > & rAddTypes )
228 : _aTypes( 10 + rAddTypes.getLength() )
230 _aTypes[0] = rType1;
231 _aTypes[1] = rType2;
232 _aTypes[2] = rType3;
233 _aTypes[3] = rType4;
234 _aTypes[4] = rType5;
235 _aTypes[5] = rType6;
236 _aTypes[6] = rType7;
237 _aTypes[7] = rType8;
238 _aTypes[8] = rType9;
239 _aTypes[9] = rType10;
240 copy( _aTypes, rAddTypes, 10 );
243 OTypeCollection::OTypeCollection(
244 const Type & rType1,
245 const Type & rType2,
246 const Type & rType3,
247 const Type & rType4,
248 const Type & rType5,
249 const Type & rType6,
250 const Type & rType7,
251 const Type & rType8,
252 const Type & rType9,
253 const Type & rType10,
254 const Type & rType11,
255 const Sequence< Type > & rAddTypes )
256 : _aTypes( 11 + rAddTypes.getLength() )
258 _aTypes[0] = rType1;
259 _aTypes[1] = rType2;
260 _aTypes[2] = rType3;
261 _aTypes[3] = rType4;
262 _aTypes[4] = rType5;
263 _aTypes[5] = rType6;
264 _aTypes[6] = rType7;
265 _aTypes[7] = rType8;
266 _aTypes[8] = rType9;
267 _aTypes[9] = rType10;
268 _aTypes[10] = rType11;
269 copy( _aTypes, rAddTypes, 11 );
272 OTypeCollection::OTypeCollection(
273 const Type & rType1,
274 const Type & rType2,
275 const Type & rType3,
276 const Type & rType4,
277 const Type & rType5,
278 const Type & rType6,
279 const Type & rType7,
280 const Type & rType8,
281 const Type & rType9,
282 const Type & rType10,
283 const Type & rType11,
284 const Type & rType12,
285 const Sequence< Type > & rAddTypes )
286 : _aTypes( 12 + rAddTypes.getLength() )
288 _aTypes[0] = rType1;
289 _aTypes[1] = rType2;
290 _aTypes[2] = rType3;
291 _aTypes[3] = rType4;
292 _aTypes[4] = rType5;
293 _aTypes[5] = rType6;
294 _aTypes[6] = rType7;
295 _aTypes[7] = rType8;
296 _aTypes[8] = rType9;
297 _aTypes[9] = rType10;
298 _aTypes[10] = rType11;
299 _aTypes[11] = rType12;
300 copy( _aTypes, rAddTypes, 12 );
305 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */