Branch data 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 : :
20 : :
21 : : #include <memory>
22 : : #include <new>
23 : :
24 : : #include <string.h>
25 : : #include <sal/types.h>
26 : : #include <osl/endian.h>
27 : : #include <registry/reflread.hxx>
28 : :
29 : : #include "registry/reader.h"
30 : : #include "registry/version.h"
31 : :
32 : : #include "reflcnst.hxx"
33 : :
34 : : #include <cstddef>
35 : :
36 : : static sal_Char NULL_STRING[1] = { 0 };
37 : : static sal_Unicode NULL_WSTRING[1] = { 0 };
38 : :
39 : : const sal_uInt32 magic = 0x12345678;
40 : : const sal_uInt16 minorVersion = 0x0000;
41 : : const sal_uInt16 majorVersion = 0x0001;
42 : :
43 : : /**************************************************************************
44 : :
45 : : class BlopObject
46 : :
47 : : holds any data in a flat memory buffer
48 : :
49 : : **************************************************************************/
50 : :
51 : : class BlopObject
52 : : {
53 : : public:
54 : : const sal_uInt8* m_pBuffer;
55 : : sal_uInt32 m_bufferLen;
56 : : sal_Bool m_isCopied;
57 : :
58 : : BlopObject(const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer);
59 : : // throws std::bad_alloc
60 : :
61 : : ~BlopObject();
62 : :
63 : 1476 : inline sal_uInt8 readBYTE(sal_uInt32 index) const
64 : : {
65 : 1476 : return m_pBuffer[index];
66 : : }
67 : :
68 : 13208 : inline sal_Int16 readINT16(sal_uInt32 index) const
69 : : {
70 : 13208 : return ((m_pBuffer[index] << 8) | (m_pBuffer[index+1] << 0));
71 : : }
72 : :
73 : 14844651 : inline sal_uInt16 readUINT16(sal_uInt32 index) const
74 : : {
75 : 14844651 : return ((m_pBuffer[index] << 8) | (m_pBuffer[index+1] << 0));
76 : : }
77 : :
78 : 73643 : inline sal_Int32 readINT32(sal_uInt32 index) const
79 : : {
80 : : return (
81 : 73643 : (m_pBuffer[index] << 24) |
82 : 73643 : (m_pBuffer[index+1] << 16) |
83 : 73643 : (m_pBuffer[index+2] << 8) |
84 : 73643 : (m_pBuffer[index+3] << 0)
85 : 73643 : );
86 : : }
87 : :
88 : 6557894 : inline sal_uInt32 readUINT32(sal_uInt32 index) const
89 : : {
90 : : return (
91 : 6557894 : (m_pBuffer[index] << 24) |
92 : 6557894 : (m_pBuffer[index+1] << 16) |
93 : 6557894 : (m_pBuffer[index+2] << 8) |
94 : 6557894 : (m_pBuffer[index+3] << 0)
95 : 6557894 : );
96 : : }
97 : :
98 : 178 : inline sal_Int64 readINT64(sal_uInt32 index) const
99 : : {
100 : : return (
101 : 178 : ((sal_Int64)m_pBuffer[index] << 56) |
102 : 178 : ((sal_Int64)m_pBuffer[index+1] << 48) |
103 : 178 : ((sal_Int64)m_pBuffer[index+2] << 40) |
104 : 178 : ((sal_Int64)m_pBuffer[index+3] << 32) |
105 : 178 : ((sal_Int64)m_pBuffer[index+4] << 24) |
106 : 178 : ((sal_Int64)m_pBuffer[index+5] << 16) |
107 : 178 : ((sal_Int64)m_pBuffer[index+6] << 8) |
108 : 178 : ((sal_Int64)m_pBuffer[index+7] << 0)
109 : 178 : );
110 : : }
111 : :
112 : 4 : inline sal_uInt64 readUINT64(sal_uInt32 index) const
113 : : {
114 : : return (
115 : 4 : ((sal_uInt64)m_pBuffer[index] << 56) |
116 : 4 : ((sal_uInt64)m_pBuffer[index+1] << 48) |
117 : 4 : ((sal_uInt64)m_pBuffer[index+2] << 40) |
118 : 4 : ((sal_uInt64)m_pBuffer[index+3] << 32) |
119 : 4 : ((sal_uInt64)m_pBuffer[index+4] << 24) |
120 : 4 : ((sal_uInt64)m_pBuffer[index+5] << 16) |
121 : 4 : ((sal_uInt64)m_pBuffer[index+6] << 8) |
122 : 4 : ((sal_uInt64)m_pBuffer[index+7] << 0)
123 : 4 : );
124 : : }
125 : : };
126 : :
127 : 1964725 : BlopObject::BlopObject(const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer)
128 : : : m_bufferLen(len)
129 : 1964725 : , m_isCopied(copyBuffer)
130 : : {
131 [ + + ]: 1964725 : if (m_isCopied)
132 : : {
133 : 83873 : m_pBuffer = 0;
134 : 83873 : sal_uInt8* newBuffer = new sal_uInt8[len];
135 : 83873 : memcpy(newBuffer, buffer, len);
136 : 83873 : m_pBuffer = newBuffer;
137 : : }
138 : : else
139 : : {
140 : 1880852 : m_pBuffer = buffer;
141 : : }
142 : 1964725 : }
143 : :
144 : 1964725 : BlopObject::~BlopObject()
145 : : {
146 [ + + ]: 1964725 : if (m_isCopied)
147 : : {
148 [ + - ]: 83873 : delete[] const_cast<sal_uInt8*>(m_pBuffer);
149 : : }
150 : 1964725 : }
151 : :
152 : : /**************************************************************************
153 : :
154 : : class StringCache
155 : :
156 : : **************************************************************************/
157 : :
158 : : class StringCache
159 : : {
160 : : public:
161 : : sal_Unicode** m_stringTable;
162 : : sal_uInt16 m_numOfStrings;
163 : : sal_uInt16 m_stringsCopied;
164 : :
165 : : StringCache(sal_uInt16 size); // throws std::bad_alloc
166 : : ~StringCache();
167 : :
168 : : const sal_Unicode* getString(sal_uInt16 index);
169 : : sal_uInt16 createString(const sal_uInt8* buffer); // throws std::bad_alloc
170 : : };
171 : :
172 : 0 : StringCache::StringCache(sal_uInt16 size)
173 : : : m_stringTable(NULL)
174 : : , m_numOfStrings(size)
175 : 0 : , m_stringsCopied(0)
176 : : {
177 : 0 : m_stringTable = new sal_Unicode*[m_numOfStrings];
178 : :
179 [ # # ]: 0 : for (sal_uInt16 i = 0; i < m_numOfStrings; i++)
180 : : {
181 : 0 : m_stringTable[i] = NULL;
182 : : }
183 : 0 : }
184 : :
185 : 0 : StringCache::~StringCache()
186 : : {
187 [ # # ]: 0 : if (m_stringTable)
188 : : {
189 [ # # ]: 0 : for (sal_uInt16 i = 0; i < m_stringsCopied; i++)
190 : : {
191 [ # # ]: 0 : delete[] m_stringTable[i];
192 : : }
193 : :
194 [ # # ]: 0 : delete[] m_stringTable;
195 : : }
196 : 0 : }
197 : :
198 : 0 : const sal_Unicode* StringCache::getString(sal_uInt16 index)
199 : : {
200 [ # # ][ # # ]: 0 : if ((index > 0) && (index <= m_stringsCopied))
201 : 0 : return m_stringTable[index - 1];
202 : : else
203 : 0 : return NULL;
204 : : }
205 : :
206 : 0 : sal_uInt16 StringCache::createString(const sal_uInt8* buffer)
207 : : {
208 [ # # ]: 0 : if (m_stringsCopied < m_numOfStrings)
209 : : {
210 : 0 : sal_uInt32 len = UINT16StringLen(buffer);
211 : :
212 : 0 : m_stringTable[m_stringsCopied] = new sal_Unicode[len + 1];
213 : :
214 : 0 : readString(buffer, m_stringTable[m_stringsCopied], (len + 1) * sizeof(sal_Unicode));
215 : :
216 : 0 : return ++m_stringsCopied;
217 : : }
218 : : else
219 : 0 : return 0;
220 : : }
221 : :
222 : : /**************************************************************************
223 : :
224 : : class ConstantPool
225 : :
226 : : **************************************************************************/
227 : :
228 : : class ConstantPool : public BlopObject
229 : : {
230 : : public:
231 : :
232 : : sal_uInt16 m_numOfEntries;
233 : : sal_Int32* m_pIndex; // index values may be < 0 for cached string constants
234 : :
235 : : StringCache* m_pStringCache;
236 : :
237 : 392945 : ConstantPool(const sal_uInt8* buffer, sal_uInt16 numEntries)
238 : : : BlopObject(buffer, 0, sal_False)
239 : : , m_numOfEntries(numEntries)
240 : : , m_pIndex(NULL)
241 : 392945 : , m_pStringCache(NULL)
242 : : {
243 : 392945 : }
244 : :
245 : : ~ConstantPool();
246 : :
247 : : sal_uInt32 parseIndex(); // throws std::bad_alloc
248 : :
249 : : CPInfoTag readTag(sal_uInt16 index);
250 : :
251 : : const sal_Char* readUTF8NameConstant(sal_uInt16 index);
252 : : sal_Bool readBOOLConstant(sal_uInt16 index);
253 : : sal_Int8 readBYTEConstant(sal_uInt16 index);
254 : : sal_Int16 readINT16Constant(sal_uInt16 index);
255 : : sal_uInt16 readUINT16Constant(sal_uInt16 index);
256 : : sal_Int32 readINT32Constant(sal_uInt16 index);
257 : : sal_uInt32 readUINT32Constant(sal_uInt16 index);
258 : : sal_Int64 readINT64Constant(sal_uInt16 index);
259 : : sal_uInt64 readUINT64Constant(sal_uInt16 index);
260 : : float readFloatConstant(sal_uInt16 index);
261 : : double readDoubleConstant(sal_uInt16 index);
262 : : const sal_Unicode* readStringConstant(sal_uInt16 index);
263 : : // throws std::bad_alloc
264 : : void readUIK(sal_uInt16 index, RTUik* uik);
265 : : };
266 : :
267 : 392945 : ConstantPool::~ConstantPool()
268 : : {
269 [ + - ]: 392945 : delete[] m_pIndex;
270 [ - + ]: 392945 : delete m_pStringCache;
271 : 392945 : }
272 : :
273 : 392945 : sal_uInt32 ConstantPool::parseIndex()
274 : : {
275 [ - + ]: 392945 : if (m_pIndex)
276 : : {
277 [ # # ]: 0 : delete[] m_pIndex;
278 : 0 : m_pIndex = NULL;
279 : : }
280 : :
281 [ - + ]: 392945 : if (m_pStringCache)
282 : : {
283 [ # # ]: 0 : delete m_pStringCache;
284 : 0 : m_pStringCache = NULL;
285 : : }
286 : :
287 : 392945 : sal_uInt32 offset = 0;
288 : 392945 : sal_uInt16 numOfStrings = 0;
289 : :
290 [ + - ]: 392945 : if (m_numOfEntries)
291 : : {
292 : 392945 : m_pIndex = new sal_Int32[m_numOfEntries];
293 : :
294 [ + + ]: 6164591 : for (int i = 0; i < m_numOfEntries; i++)
295 : : {
296 : 5771646 : m_pIndex[i] = offset;
297 : :
298 : 5771646 : offset += readUINT32(offset);
299 : :
300 [ - + ]: 5771646 : if ( ((CPInfoTag) readUINT16(m_pIndex[i] + CP_OFFSET_ENTRY_TAG)) ==
301 : : CP_TAG_CONST_STRING )
302 : : {
303 : 0 : numOfStrings++;
304 : : }
305 : :
306 : : }
307 : : }
308 : :
309 [ - + ]: 392945 : if (numOfStrings)
310 : : {
311 [ # # ]: 0 : m_pStringCache = new StringCache(numOfStrings);
312 : : }
313 : :
314 : 392945 : m_bufferLen = offset;
315 : :
316 : 392945 : return offset;
317 : : }
318 : :
319 : 98639 : CPInfoTag ConstantPool::readTag(sal_uInt16 index)
320 : : {
321 : 98639 : CPInfoTag tag = CP_TAG_INVALID;
322 : :
323 [ + - ][ + + ]: 98639 : if (m_pIndex && (index > 0) && (index <= m_numOfEntries))
[ + - ]
324 : : {
325 : 88871 : tag = (CPInfoTag) readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG);
326 : : }
327 : :
328 : 98639 : return tag;
329 : : }
330 : :
331 : 1480595 : const sal_Char* ConstantPool::readUTF8NameConstant(sal_uInt16 index)
332 : : {
333 : 1480595 : const sal_Char* aName = NULL_STRING;
334 : :
335 [ + - ][ + + ]: 1480595 : if (m_pIndex && (index > 0) && (index <= m_numOfEntries))
[ + - ]
336 : : {
337 [ + - ]: 1476801 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_UTF8_NAME)
338 : : {
339 : 1476801 : aName = (const sal_Char*) (m_pBuffer + m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
340 : : }
341 : : }
342 : :
343 : 1480595 : return aName;
344 : : }
345 : :
346 : 0 : sal_Bool ConstantPool::readBOOLConstant(sal_uInt16 index)
347 : : {
348 : 0 : sal_Bool aBool = sal_False;
349 : :
350 [ # # ][ # # ]: 0 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ # # ]
351 : : {
352 [ # # ]: 0 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_BOOL)
353 : : {
354 : 0 : aBool = (sal_Bool) readBYTE(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
355 : : }
356 : : }
357 : :
358 : 0 : return aBool;
359 : : }
360 : :
361 : 1476 : sal_Int8 ConstantPool::readBYTEConstant(sal_uInt16 index)
362 : : {
363 : 1476 : sal_Int8 aByte = 0;
364 : :
365 [ + - ][ + - ]: 1476 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
366 : : {
367 [ + - ]: 1476 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_BYTE)
368 : : {
369 : : aByte = static_cast< sal_Int8 >(
370 : 1476 : readBYTE(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA));
371 : : }
372 : : }
373 : :
374 : 1476 : return aByte;
375 : : }
376 : :
377 : 13208 : sal_Int16 ConstantPool::readINT16Constant(sal_uInt16 index)
378 : : {
379 : 13208 : sal_Int16 aINT16 = sal_False;
380 : :
381 [ + - ][ + - ]: 13208 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
382 : : {
383 [ + - ]: 13208 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT16)
384 : : {
385 : 13208 : aINT16 = readINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
386 : : }
387 : : }
388 : :
389 : 13208 : return aINT16;
390 : : }
391 : :
392 : 4 : sal_uInt16 ConstantPool::readUINT16Constant(sal_uInt16 index)
393 : : {
394 : 4 : sal_uInt16 asal_uInt16 = sal_False;
395 : :
396 [ + - ][ + - ]: 4 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
397 : : {
398 [ + - ]: 4 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT16)
399 : : {
400 : 4 : asal_uInt16 = readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
401 : : }
402 : : }
403 : :
404 : 4 : return asal_uInt16;
405 : : }
406 : :
407 : 73643 : sal_Int32 ConstantPool::readINT32Constant(sal_uInt16 index)
408 : : {
409 : 73643 : sal_Int32 aINT32 = sal_False;
410 : :
411 [ + - ][ + - ]: 73643 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
412 : : {
413 [ + - ]: 73643 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT32)
414 : : {
415 : 73643 : aINT32 = readINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
416 : : }
417 : : }
418 : :
419 : 73643 : return aINT32;
420 : : }
421 : :
422 : 238 : sal_uInt32 ConstantPool::readUINT32Constant(sal_uInt16 index)
423 : : {
424 : 238 : sal_uInt32 aUINT32 = sal_False;
425 : :
426 [ + - ][ + - ]: 238 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
427 : : {
428 [ + - ]: 238 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT32)
429 : : {
430 : 238 : aUINT32 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
431 : : }
432 : : }
433 : :
434 : 238 : return aUINT32;
435 : : }
436 : :
437 : 178 : sal_Int64 ConstantPool::readINT64Constant(sal_uInt16 index)
438 : : {
439 : 178 : sal_Int64 aINT64 = sal_False;
440 : :
441 [ + - ][ + - ]: 178 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
442 : : {
443 [ + - ]: 178 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_INT64)
444 : : {
445 : 178 : aINT64 = readINT64(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
446 : : }
447 : : }
448 : :
449 : 178 : return aINT64;
450 : : }
451 : :
452 : 4 : sal_uInt64 ConstantPool::readUINT64Constant(sal_uInt16 index)
453 : : {
454 : 4 : sal_uInt64 aUINT64 = sal_False;
455 : :
456 [ + - ][ + - ]: 4 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
457 : : {
458 [ + - ]: 4 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_UINT64)
459 : : {
460 : 4 : aUINT64 = readUINT64(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
461 : : }
462 : : }
463 : :
464 : 4 : return aUINT64;
465 : : }
466 : :
467 : 120 : float ConstantPool::readFloatConstant(sal_uInt16 index)
468 : : {
469 : : union
470 : : {
471 : : float v;
472 : : sal_uInt32 b;
473 : 120 : } x = { 0.0f };
474 : :
475 [ + - ][ + - ]: 120 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ + - ]
476 : : {
477 [ + - ]: 120 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_FLOAT)
478 : : {
479 : : #ifdef REGTYPE_IEEE_NATIVE
480 : 120 : x.b = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
481 : : #else
482 : : # error no IEEE
483 : : #endif
484 : : }
485 : : }
486 : :
487 : 120 : return x.v;
488 : : }
489 : :
490 : 0 : double ConstantPool::readDoubleConstant(sal_uInt16 index)
491 : : {
492 : : union
493 : : {
494 : : double v;
495 : : struct
496 : : {
497 : : sal_uInt32 b1;
498 : : sal_uInt32 b2;
499 : : } b;
500 : 0 : } x = { 0.0 };
501 : :
502 [ # # ][ # # ]: 0 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries))
[ # # ]
503 : : {
504 [ # # ]: 0 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_DOUBLE)
505 : : {
506 : :
507 : : #ifdef REGTYPE_IEEE_NATIVE
508 : : # ifdef OSL_BIGENDIAN
509 : : x.b.b1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
510 : : x.b.b2 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA + sizeof(sal_uInt32));
511 : : # else
512 : 0 : x.b.b1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA + sizeof(sal_uInt32));
513 : 0 : x.b.b2 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
514 : : # endif
515 : : #else
516 : : # error no IEEE
517 : : #endif
518 : : }
519 : : }
520 : :
521 : 0 : return x.v;
522 : : }
523 : :
524 : 0 : const sal_Unicode* ConstantPool::readStringConstant(sal_uInt16 index)
525 : : {
526 : 0 : const sal_Unicode* aString = NULL_WSTRING;
527 : :
528 [ # # ][ # # ]: 0 : if (m_pIndex && (index> 0) && (index <= m_numOfEntries) && m_pStringCache)
[ # # ][ # # ]
529 : : {
530 [ # # ]: 0 : if (m_pIndex[index - 1] >= 0)
531 : : {
532 : : // create cached string now
533 : :
534 [ # # ]: 0 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_CONST_STRING)
535 : : {
536 : 0 : m_pIndex[index - 1] = -1 * m_pStringCache->createString(m_pBuffer + m_pIndex[index - 1] + CP_OFFSET_ENTRY_DATA);
537 : : }
538 : : }
539 : :
540 : 0 : aString = m_pStringCache->getString((sal_uInt16) (m_pIndex[index - 1] * -1));
541 : : }
542 : :
543 : 0 : return aString;
544 : : }
545 : :
546 : 0 : void ConstantPool::readUIK(sal_uInt16 index, RTUik* uik)
547 : : {
548 [ # # ]: 0 : if (index == 0)
549 : : {
550 : 0 : uik->m_Data1 = 0;
551 : 0 : uik->m_Data2 = 0;
552 : 0 : uik->m_Data3 = 0;
553 : 0 : uik->m_Data4 = 0;
554 : 0 : uik->m_Data5 = 0;
555 : : }
556 [ # # ][ # # ]: 0 : else if (m_pIndex && (index <= m_numOfEntries))
557 : : {
558 [ # # ]: 0 : if (readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_TAG) == CP_TAG_UIK)
559 : : {
560 : 0 : uik->m_Data1 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK1);
561 : 0 : uik->m_Data2 = readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK2);
562 : 0 : uik->m_Data3 = readUINT16(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK3);
563 : 0 : uik->m_Data4 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK4);
564 : 0 : uik->m_Data5 = readUINT32(m_pIndex[index - 1] + CP_OFFSET_ENTRY_UIK5);
565 : : }
566 : : }
567 : 0 : }
568 : :
569 : : /**************************************************************************
570 : :
571 : : class FieldList
572 : :
573 : : **************************************************************************/
574 : :
575 : 392945 : class FieldList : public BlopObject
576 : : {
577 : : public:
578 : :
579 : : sal_uInt16 m_numOfEntries;
580 : : sal_uInt16 m_numOfFieldEntries;
581 : : sal_uInt16 m_FIELD_ENTRY_SIZE;
582 : : ConstantPool* m_pCP;
583 : :
584 : 392945 : FieldList(const sal_uInt8* buffer, sal_uInt16 numEntries, ConstantPool* pCP)
585 : : : BlopObject(buffer, 0, sal_False)
586 : : , m_numOfEntries(numEntries)
587 : 392945 : , m_pCP(pCP)
588 : : {
589 [ + + ]: 392945 : if ( m_numOfEntries > 0 )
590 : : {
591 : 99276 : m_numOfFieldEntries = readUINT16(0);
592 : 99276 : m_FIELD_ENTRY_SIZE = m_numOfFieldEntries * sizeof(sal_uInt16);
593 : : } else
594 : : {
595 : 293669 : m_numOfFieldEntries = 0;
596 : 293669 : m_FIELD_ENTRY_SIZE = 0;
597 : : }
598 : 392945 : }
599 : :
600 : : sal_uInt32 parseIndex();
601 : :
602 : : const sal_Char* getFieldName(sal_uInt16 index);
603 : : const sal_Char* getFieldType(sal_uInt16 index);
604 : : RTFieldAccess getFieldAccess(sal_uInt16 index);
605 : : RTValueType getFieldConstValue(sal_uInt16 index, RTConstValueUnion* value);
606 : : // throws std::bad_alloc
607 : : const sal_Char* getFieldDoku(sal_uInt16 index);
608 : : const sal_Char* getFieldFileName(sal_uInt16 index);
609 : : };
610 : :
611 : 392945 : sal_uInt32 FieldList::parseIndex()
612 : : {
613 [ + + ]: 392945 : return ((m_numOfEntries ? sizeof(sal_uInt16) : 0) + (m_numOfEntries * m_FIELD_ENTRY_SIZE));
614 : : }
615 : :
616 : 230887 : const sal_Char* FieldList::getFieldName(sal_uInt16 index)
617 : : {
618 : 230887 : const sal_Char* aName = NULL;
619 : :
620 [ + - ][ + - ]: 230887 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
621 : : {
622 : 230887 : aName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_NAME));
623 : : }
624 : :
625 : 230887 : return aName;
626 : : }
627 : :
628 : 221785 : const sal_Char* FieldList::getFieldType(sal_uInt16 index)
629 : : {
630 : 221785 : const sal_Char* aName = NULL;
631 : :
632 [ + - ][ + - ]: 221785 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
633 : : {
634 : 221785 : aName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_TYPE));
635 : : }
636 : :
637 : 221785 : return aName;
638 : : }
639 : :
640 : 206987 : RTFieldAccess FieldList::getFieldAccess(sal_uInt16 index)
641 : : {
642 : 206987 : RTFieldAccess aAccess = RT_ACCESS_INVALID;
643 : :
644 [ + - ][ + - ]: 206987 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
645 : : {
646 : 206987 : aAccess = (RTFieldAccess) readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_ACCESS);
647 : : }
648 : :
649 : 206987 : return aAccess;
650 : : }
651 : :
652 : 98639 : RTValueType FieldList::getFieldConstValue(sal_uInt16 index, RTConstValueUnion* value)
653 : : {
654 : 98639 : RTValueType ret = RT_TYPE_NONE;
655 : :
656 [ + - ][ + - ]: 98639 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
657 : : {
658 : 98639 : sal_uInt16 cpIndex = readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_VALUE);
659 : :
660 [ - + + + : 98639 : switch (m_pCP->readTag(cpIndex))
+ + + + +
- - + ]
661 : : {
662 : : case CP_TAG_CONST_BOOL:
663 : 0 : value->aBool = m_pCP->readBOOLConstant(cpIndex);
664 : 0 : ret = RT_TYPE_BOOL;
665 : 0 : break;
666 : : case CP_TAG_CONST_BYTE:
667 : 1476 : value->aByte = m_pCP->readBYTEConstant(cpIndex);
668 : 1476 : ret = RT_TYPE_BYTE;
669 : 1476 : break;
670 : : case CP_TAG_CONST_INT16:
671 : 13208 : value->aShort = m_pCP->readINT16Constant(cpIndex);
672 : 13208 : ret = RT_TYPE_INT16;
673 : 13208 : break;
674 : : case CP_TAG_CONST_UINT16:
675 : 4 : value->aUShort = m_pCP->readUINT16Constant(cpIndex);
676 : 4 : ret = RT_TYPE_UINT16;
677 : 4 : break;
678 : : case CP_TAG_CONST_INT32:
679 : 73643 : value->aLong = m_pCP->readINT32Constant(cpIndex);
680 : 73643 : ret = RT_TYPE_INT32;
681 : 73643 : break;
682 : : case CP_TAG_CONST_UINT32:
683 : 238 : value->aULong = m_pCP->readUINT32Constant(cpIndex);
684 : 238 : ret = RT_TYPE_UINT32;
685 : 238 : break;
686 : : case CP_TAG_CONST_INT64:
687 : 178 : value->aHyper = m_pCP->readINT64Constant(cpIndex);
688 : 178 : ret = RT_TYPE_INT64;
689 : 178 : break;
690 : : case CP_TAG_CONST_UINT64:
691 : 4 : value->aUHyper = m_pCP->readUINT64Constant(cpIndex);
692 : 4 : ret = RT_TYPE_UINT64;
693 : 4 : break;
694 : : case CP_TAG_CONST_FLOAT:
695 : 120 : value->aFloat = m_pCP->readFloatConstant(cpIndex);
696 : 120 : ret = RT_TYPE_FLOAT;
697 : 120 : break;
698 : : case CP_TAG_CONST_DOUBLE:
699 : 0 : value->aDouble = m_pCP->readDoubleConstant(cpIndex);
700 : 0 : ret = RT_TYPE_DOUBLE;
701 : 0 : break;
702 : : case CP_TAG_CONST_STRING:
703 : 0 : value->aString = m_pCP->readStringConstant(cpIndex);
704 : 0 : ret = RT_TYPE_STRING;
705 : 0 : break;
706 : : default:
707 : 98639 : break;
708 : : }
709 : : }
710 : :
711 : 98639 : return ret;
712 : : }
713 : :
714 : 0 : const sal_Char* FieldList::getFieldDoku(sal_uInt16 index)
715 : : {
716 : 0 : const sal_Char* aDoku = NULL;
717 : :
718 [ # # ][ # # ]: 0 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
719 : : {
720 : 0 : aDoku = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_DOKU));
721 : : }
722 : :
723 : 0 : return aDoku;
724 : : }
725 : :
726 : 0 : const sal_Char* FieldList::getFieldFileName(sal_uInt16 index)
727 : : {
728 : 0 : const sal_Char* aFileName = NULL;
729 : :
730 [ # # ][ # # ]: 0 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
731 : : {
732 : 0 : aFileName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_FIELD_ENTRY_SIZE) + FIELD_OFFSET_FILENAME));
733 : : }
734 : :
735 : 0 : return aFileName;
736 : : }
737 : :
738 : : /**************************************************************************
739 : :
740 : : class ReferenceList
741 : :
742 : : **************************************************************************/
743 : :
744 : 392945 : class ReferenceList : public BlopObject
745 : : {
746 : : public:
747 : :
748 : : sal_uInt16 m_numOfEntries;
749 : : sal_uInt16 m_numOfReferenceEntries;
750 : : sal_uInt16 m_REFERENCE_ENTRY_SIZE;
751 : : ConstantPool* m_pCP;
752 : :
753 : 392945 : ReferenceList(const sal_uInt8* buffer, sal_uInt16 numEntries, ConstantPool* pCP)
754 : : : BlopObject(buffer, 0, sal_False)
755 : : , m_numOfEntries(numEntries)
756 : 392945 : , m_pCP(pCP)
757 : : {
758 [ + + ]: 392945 : if ( m_numOfEntries > 0 )
759 : : {
760 : 15369 : m_numOfReferenceEntries = readUINT16(0);
761 : 15369 : m_REFERENCE_ENTRY_SIZE = m_numOfReferenceEntries * sizeof(sal_uInt16);
762 : : } else
763 : : {
764 : 377576 : m_numOfReferenceEntries = 0;
765 : 377576 : m_REFERENCE_ENTRY_SIZE = 0;
766 : : }
767 : 392945 : }
768 : :
769 : : sal_uInt32 parseIndex();
770 : :
771 : : const sal_Char* getReferenceName(sal_uInt16 index);
772 : : RTReferenceType getReferenceType(sal_uInt16 index);
773 : : const sal_Char* getReferenceDoku(sal_uInt16 index);
774 : : RTFieldAccess getReferenceAccess(sal_uInt16 index);
775 : : };
776 : :
777 : 392945 : sal_uInt32 ReferenceList::parseIndex()
778 : : {
779 [ + + ]: 392945 : return ((m_numOfEntries ? sizeof(sal_uInt16) : 0) + (m_numOfEntries * m_REFERENCE_ENTRY_SIZE));
780 : : }
781 : :
782 : 13498 : const sal_Char* ReferenceList::getReferenceName(sal_uInt16 index)
783 : : {
784 : 13498 : const sal_Char* aName = NULL;
785 : :
786 [ + - ][ + - ]: 13498 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
787 : : {
788 : 13498 : aName = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_NAME));
789 : : }
790 : :
791 : 13498 : return aName;
792 : : }
793 : :
794 : 12943 : RTReferenceType ReferenceList::getReferenceType(sal_uInt16 index)
795 : : {
796 : 12943 : RTReferenceType refType = RT_REF_INVALID;
797 : :
798 [ + - ][ + - ]: 12943 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
799 : : {
800 : 12943 : refType = (RTReferenceType) readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_TYPE);
801 : : }
802 : :
803 : 12943 : return refType;
804 : : }
805 : :
806 : 0 : const sal_Char* ReferenceList::getReferenceDoku(sal_uInt16 index)
807 : : {
808 : 0 : const sal_Char* aDoku = NULL;
809 : :
810 [ # # ][ # # ]: 0 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
811 : : {
812 : 0 : aDoku = m_pCP->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_DOKU));
813 : : }
814 : :
815 : 0 : return aDoku;
816 : : }
817 : :
818 : 1175 : RTFieldAccess ReferenceList::getReferenceAccess(sal_uInt16 index)
819 : : {
820 : 1175 : RTFieldAccess aAccess = RT_ACCESS_INVALID;
821 : :
822 [ + - ][ + - ]: 1175 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
823 : : {
824 : 1175 : aAccess = (RTFieldAccess) readUINT16(sizeof(sal_uInt16) + (index * m_REFERENCE_ENTRY_SIZE) + REFERENCE_OFFSET_ACCESS);
825 : : }
826 : :
827 : 1175 : return aAccess;
828 : : }
829 : :
830 : : /**************************************************************************
831 : :
832 : : class MethodList
833 : :
834 : : **************************************************************************/
835 : :
836 : : class MethodList : public BlopObject
837 : : {
838 : : public:
839 : :
840 : : sal_uInt16 m_numOfEntries;
841 : : sal_uInt16 m_numOfMethodEntries;
842 : : sal_uInt16 m_numOfParamEntries;
843 : : sal_uInt16 m_PARAM_ENTRY_SIZE;
844 : : sal_uInt32* m_pIndex;
845 : : ConstantPool* m_pCP;
846 : :
847 : 392945 : MethodList(const sal_uInt8* buffer, sal_uInt16 numEntries, ConstantPool* pCP)
848 : : : BlopObject(buffer, 0, sal_False)
849 : : , m_numOfEntries(numEntries)
850 : : , m_pIndex(NULL)
851 : 392945 : , m_pCP(pCP)
852 : : {
853 [ + + ]: 392945 : if ( m_numOfEntries > 0 )
854 : : {
855 : 196779 : m_numOfMethodEntries = readUINT16(0);
856 : 196779 : m_numOfParamEntries = readUINT16(sizeof(sal_uInt16));
857 : 196779 : m_PARAM_ENTRY_SIZE = m_numOfParamEntries * sizeof(sal_uInt16);
858 : : } else
859 : : {
860 : 196166 : m_numOfMethodEntries = 0;
861 : 196166 : m_numOfParamEntries = 0;
862 : 196166 : m_PARAM_ENTRY_SIZE = 0;
863 : : }
864 : 392945 : }
865 : :
866 : : ~MethodList();
867 : :
868 : : sal_uInt32 parseIndex(); // throws std::bad_alloc
869 : :
870 : : const sal_Char* getMethodName(sal_uInt16 index);
871 : : sal_uInt16 getMethodParamCount(sal_uInt16 index);
872 : : const sal_Char* getMethodParamType(sal_uInt16 index, sal_uInt16 paramIndex);
873 : : const sal_Char* getMethodParamName(sal_uInt16 index, sal_uInt16 paramIndex);
874 : : RTParamMode getMethodParamMode(sal_uInt16 index, sal_uInt16 paramIndex);
875 : : sal_uInt16 getMethodExcCount(sal_uInt16 index);
876 : : const sal_Char* getMethodExcType(sal_uInt16 index, sal_uInt16 excIndex);
877 : : const sal_Char* getMethodReturnType(sal_uInt16 index);
878 : : RTMethodMode getMethodMode(sal_uInt16 index);
879 : : const sal_Char* getMethodDoku(sal_uInt16 index);
880 : :
881 : : private:
882 : : sal_uInt16 calcMethodParamIndex( const sal_uInt16 index );
883 : : };
884 : :
885 : 392945 : MethodList::~MethodList()
886 : : {
887 [ + + ][ + - ]: 392945 : if (m_pIndex) delete[] m_pIndex;
888 : 392945 : }
889 : :
890 : 487989 : sal_uInt16 MethodList::calcMethodParamIndex( const sal_uInt16 index )
891 : : {
892 : 487989 : return (METHOD_OFFSET_PARAM_COUNT + sizeof(sal_uInt16) + (index * m_PARAM_ENTRY_SIZE));
893 : : }
894 : :
895 : 392945 : sal_uInt32 MethodList::parseIndex()
896 : : {
897 [ - + ]: 392945 : if (m_pIndex)
898 : : {
899 [ # # ]: 0 : delete[] m_pIndex;
900 : 0 : m_pIndex = NULL;
901 : : }
902 : :
903 : 392945 : sal_uInt32 offset = 0;
904 : :
905 [ + + ]: 392945 : if (m_numOfEntries)
906 : : {
907 : 196779 : offset = 2 * sizeof(sal_uInt16);
908 : 196779 : m_pIndex = new sal_uInt32[m_numOfEntries];
909 : :
910 [ + + ]: 1031214 : for (int i = 0; i < m_numOfEntries; i++)
911 : : {
912 : 834435 : m_pIndex[i] = offset;
913 : :
914 : 834435 : offset += readUINT16(offset);
915 : : }
916 : : }
917 : :
918 : 392945 : return offset;
919 : : }
920 : :
921 : 327644 : const sal_Char* MethodList::getMethodName(sal_uInt16 index)
922 : : {
923 : 327644 : const sal_Char* aName = NULL;
924 : :
925 [ + - ][ + - ]: 327644 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
926 : : {
927 : 327644 : aName = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_NAME));
928 : : }
929 : :
930 : 327644 : return aName;
931 : : }
932 : :
933 : 158634 : sal_uInt16 MethodList::getMethodParamCount(sal_uInt16 index)
934 : : {
935 : 158634 : sal_uInt16 aCount = 0;
936 : :
937 [ + - ][ + - ]: 158634 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
938 : : {
939 : 158634 : aCount = readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT);
940 : : }
941 : :
942 : 158634 : return aCount;
943 : : }
944 : :
945 : 120001 : const sal_Char* MethodList::getMethodParamType(sal_uInt16 index, sal_uInt16 paramIndex)
946 : : {
947 : 120001 : const sal_Char* aName = NULL;
948 : :
949 [ + - ]: 240002 : if ((m_numOfEntries > 0) &&
[ + - + - ]
[ + - ]
950 : : (index <= m_numOfEntries) &&
951 : 120001 : (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)))
952 : : {
953 : : aName = m_pCP->readUTF8NameConstant(
954 : : readUINT16(
955 : 120001 : m_pIndex[index] +
956 : 120001 : calcMethodParamIndex(paramIndex) +
957 : 120001 : PARAM_OFFSET_TYPE));
958 : : }
959 : :
960 : 120001 : return aName;
961 : : }
962 : :
963 : 67476 : const sal_Char* MethodList::getMethodParamName(sal_uInt16 index, sal_uInt16 paramIndex)
964 : : {
965 : 67476 : const sal_Char* aName = NULL;
966 : :
967 [ + - ]: 134952 : if ((m_numOfEntries > 0) &&
[ + - + - ]
[ + - ]
968 : : (index <= m_numOfEntries) &&
969 : 67476 : (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)))
970 : : {
971 : : aName = m_pCP->readUTF8NameConstant(
972 : : readUINT16(
973 : 67476 : m_pIndex[index] +
974 : 67476 : calcMethodParamIndex(paramIndex) +
975 : 67476 : PARAM_OFFSET_NAME));
976 : : }
977 : :
978 : 67476 : return aName;
979 : : }
980 : :
981 : 106251 : RTParamMode MethodList::getMethodParamMode(sal_uInt16 index, sal_uInt16 paramIndex)
982 : : {
983 : 106251 : RTParamMode aMode = RT_PARAM_INVALID;
984 : :
985 [ + - ]: 212502 : if ((m_numOfEntries > 0) &&
[ + - + - ]
[ + - ]
986 : : (index <= m_numOfEntries) &&
987 : 106251 : (paramIndex <= readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)))
988 : : {
989 : : aMode = (RTParamMode) readUINT16(
990 : 106251 : m_pIndex[index] +
991 : 106251 : calcMethodParamIndex(paramIndex) +
992 : 106251 : PARAM_OFFSET_MODE);
993 : : }
994 : :
995 : 106251 : return aMode;
996 : : }
997 : :
998 : 132641 : sal_uInt16 MethodList::getMethodExcCount(sal_uInt16 index)
999 : : {
1000 : 132641 : sal_uInt16 aCount = 0;
1001 : :
1002 [ + - ][ + - ]: 132641 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1003 : : {
1004 : 132641 : aCount = readUINT16(m_pIndex[index] + calcMethodParamIndex(readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT)));
1005 : : }
1006 : :
1007 : 132641 : return aCount;
1008 : : }
1009 : :
1010 : 61620 : const sal_Char* MethodList::getMethodExcType(sal_uInt16 index, sal_uInt16 excIndex)
1011 : : {
1012 : 61620 : const sal_Char* aName = NULL;
1013 : :
1014 [ + - ][ + - ]: 61620 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1015 : : {
1016 : 61620 : sal_uInt32 excOffset = m_pIndex[index] + calcMethodParamIndex(readUINT16(m_pIndex[index] + METHOD_OFFSET_PARAM_COUNT));
1017 : :
1018 [ + - ]: 61620 : if (excIndex <= readUINT16(excOffset))
1019 : : {
1020 : : aName = m_pCP->readUTF8NameConstant(
1021 : : readUINT16(
1022 : : excOffset +
1023 : : sizeof(sal_uInt16) +
1024 : 61620 : (excIndex * sizeof(sal_uInt16))));
1025 : : }
1026 : : }
1027 : :
1028 : 61620 : return aName;
1029 : : }
1030 : :
1031 : 256570 : const sal_Char* MethodList::getMethodReturnType(sal_uInt16 index)
1032 : : {
1033 : 256570 : const sal_Char* aName = NULL;
1034 : :
1035 [ + - ][ + - ]: 256570 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1036 : : {
1037 : 256570 : aName = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_RETURN));
1038 : : }
1039 : :
1040 : 256570 : return aName;
1041 : : }
1042 : :
1043 : 536936 : RTMethodMode MethodList::getMethodMode(sal_uInt16 index)
1044 : : {
1045 : 536936 : RTMethodMode aMode = RT_MODE_INVALID;
1046 : :
1047 [ + - ][ + - ]: 536936 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1048 : : {
1049 : 536936 : aMode = (RTMethodMode) readUINT16(m_pIndex[index] + METHOD_OFFSET_MODE);
1050 : : }
1051 : :
1052 : 536936 : return aMode;
1053 : : }
1054 : :
1055 : 0 : const sal_Char* MethodList::getMethodDoku(sal_uInt16 index)
1056 : : {
1057 : 0 : const sal_Char* aDoku = NULL;
1058 : :
1059 [ # # ][ # # ]: 0 : if ((m_numOfEntries > 0) && (index <= m_numOfEntries))
1060 : : {
1061 : 0 : aDoku = m_pCP->readUTF8NameConstant(readUINT16(m_pIndex[index] + METHOD_OFFSET_DOKU));
1062 : : }
1063 : :
1064 : 0 : return aDoku;
1065 : : }
1066 : :
1067 : : /**************************************************************************
1068 : :
1069 : : class TypeRegistryEntry
1070 : :
1071 : : **************************************************************************/
1072 : :
1073 : : class TypeRegistryEntry: public BlopObject {
1074 : : public:
1075 : : ConstantPool* m_pCP;
1076 : : FieldList* m_pFields;
1077 : : MethodList* m_pMethods;
1078 : : ReferenceList* m_pReferences;
1079 : : sal_uInt32 m_refCount;
1080 : : sal_uInt16 m_nSuperTypes;
1081 : : sal_uInt16 m_offset_SUPERTYPES;
1082 : :
1083 : : TypeRegistryEntry(
1084 : : const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer);
1085 : : // throws std::bad_alloc
1086 : :
1087 : : ~TypeRegistryEntry();
1088 : :
1089 : : typereg_Version getVersion() const;
1090 : : };
1091 : :
1092 : 392945 : TypeRegistryEntry::TypeRegistryEntry(
1093 : : const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer):
1094 : : BlopObject(buffer, len, copyBuffer), m_pCP(NULL), m_pFields(NULL),
1095 : : m_pMethods(NULL), m_pReferences(NULL), m_refCount(1), m_nSuperTypes(0),
1096 : 392945 : m_offset_SUPERTYPES(0)
1097 : : {
1098 : 392945 : std::size_t const entrySize = sizeof(sal_uInt16);
1099 : 392945 : sal_uInt16 nHeaderEntries = readUINT16(OFFSET_N_ENTRIES);
1100 : 392945 : sal_uInt16 offset_N_SUPERTYPES = OFFSET_N_ENTRIES + entrySize + (nHeaderEntries * entrySize);
1101 : 392945 : m_offset_SUPERTYPES = offset_N_SUPERTYPES + entrySize;
1102 : 392945 : m_nSuperTypes = readUINT16(offset_N_SUPERTYPES);
1103 : :
1104 : 392945 : sal_uInt16 offset_CP_SIZE = m_offset_SUPERTYPES + (m_nSuperTypes * entrySize);
1105 : 392945 : sal_uInt16 offset_CP = offset_CP_SIZE + entrySize;
1106 : :
1107 [ + - ][ + - ]: 392945 : m_pCP = new ConstantPool(m_pBuffer + offset_CP, readUINT16(offset_CP_SIZE));
1108 : :
1109 [ + - ]: 392945 : sal_uInt32 offset = offset_CP + m_pCP->parseIndex();
1110 : :
1111 : : m_pFields = new FieldList(
1112 [ + - ][ + - ]: 392945 : m_pBuffer + offset + entrySize, readUINT16(offset), m_pCP);
1113 : :
1114 : 392945 : offset += sizeof(sal_uInt16) + m_pFields->parseIndex();
1115 : :
1116 : : m_pMethods = new MethodList(
1117 [ + - ][ + - ]: 392945 : m_pBuffer + offset + entrySize, readUINT16(offset), m_pCP);
1118 : :
1119 [ + - ]: 392945 : offset += sizeof(sal_uInt16) + m_pMethods->parseIndex();
1120 : :
1121 : : m_pReferences = new ReferenceList(
1122 [ + - ][ + - ]: 392945 : m_pBuffer + offset + entrySize, readUINT16(offset), m_pCP);
1123 : :
1124 : 392945 : m_pReferences->parseIndex();
1125 : 392945 : }
1126 : :
1127 : 392945 : TypeRegistryEntry::~TypeRegistryEntry()
1128 : : {
1129 [ + - ]: 392945 : delete m_pCP;
1130 [ + - ]: 392945 : delete m_pFields;
1131 [ + - ]: 392945 : delete m_pMethods;
1132 [ + - ]: 392945 : delete m_pReferences;
1133 : 392945 : }
1134 : :
1135 : 392945 : typereg_Version TypeRegistryEntry::getVersion() const {
1136 : : // Assumes two's complement arithmetic with modulo-semantics:
1137 : 392945 : return static_cast< typereg_Version >(readUINT32(OFFSET_MAGIC) - magic);
1138 : : }
1139 : :
1140 : : /**************************************************************************
1141 : :
1142 : : C-API
1143 : :
1144 : : **************************************************************************/
1145 : :
1146 : : extern "C" {
1147 : :
1148 : 392945 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_reader_create(
1149 : : void const * buffer, sal_uInt32 length, sal_Bool copy,
1150 : : typereg_Version maxVersion, void ** result)
1151 : : SAL_THROW_EXTERN_C()
1152 : : {
1153 [ - + ]: 392945 : if (length < OFFSET_CP || length > SAL_MAX_UINT32) {
1154 : 0 : *result = 0;
1155 : 0 : return true;
1156 : : }
1157 : 392945 : std::auto_ptr< TypeRegistryEntry > entry;
1158 : : try {
1159 : : entry.reset(
1160 : : new TypeRegistryEntry(
1161 : : static_cast< sal_uInt8 const * >(buffer),
1162 [ + - ][ # # ]: 392945 : static_cast< sal_uInt32 >(length), copy));
[ + - ]
1163 : 0 : } catch (std::bad_alloc &) {
1164 : 0 : return false;
1165 : : }
1166 [ - + ]: 392945 : if (entry->readUINT32(OFFSET_SIZE) != length) {
1167 : 0 : *result = 0;
1168 : 0 : return true;
1169 : : }
1170 : 392945 : typereg_Version version = entry->getVersion();
1171 [ + + ][ + - ]: 392945 : if (version < TYPEREG_VERSION_0 || version > maxVersion) {
1172 : 6699 : *result = 0;
1173 : 6699 : return true;
1174 : : }
1175 : 386246 : *result = entry.release();
1176 : 392945 : return true;
1177 : : }
1178 : :
1179 : 88635 : static TypeReaderImpl TYPEREG_CALLTYPE createEntry(const sal_uInt8* buffer, sal_uInt32 len, sal_Bool copyBuffer)
1180 : : {
1181 : : void * handle;
1182 : 88635 : typereg_reader_create(buffer, len, copyBuffer, TYPEREG_VERSION_0, &handle);
1183 : 88635 : return handle;
1184 : : }
1185 : :
1186 : 108869 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_acquire(void * hEntry) SAL_THROW_EXTERN_C()
1187 : : {
1188 : 108869 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1189 : :
1190 [ + + ]: 108869 : if (pEntry != NULL)
1191 : 107233 : pEntry->m_refCount++;
1192 : 108869 : }
1193 : :
1194 : 859481 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_release(void * hEntry) SAL_THROW_EXTERN_C()
1195 : : {
1196 : 859481 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1197 : :
1198 [ + + ]: 859481 : if (pEntry != NULL)
1199 : : {
1200 [ + + ]: 493479 : if (--pEntry->m_refCount == 0)
1201 [ + - ]: 386246 : delete pEntry;
1202 : : }
1203 : 859481 : }
1204 : :
1205 : 0 : REG_DLLPUBLIC typereg_Version TYPEREG_CALLTYPE typereg_reader_getVersion(void * handle) SAL_THROW_EXTERN_C() {
1206 : : return handle == 0
1207 : : ? TYPEREG_VERSION_0
1208 [ # # ]: 0 : : static_cast< TypeRegistryEntry * >(handle)->getVersion();
1209 : : }
1210 : :
1211 : 0 : static sal_uInt16 TYPEREG_CALLTYPE getMinorVersion(TypeReaderImpl hEntry)
1212 : : {
1213 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1214 : :
1215 [ # # ]: 0 : if (pEntry == NULL) return 0;
1216 : :
1217 : 0 : return pEntry->readUINT16(OFFSET_MINOR_VERSION);
1218 : : }
1219 : :
1220 : 0 : static sal_uInt16 TYPEREG_CALLTYPE getMajorVersion(TypeReaderImpl hEntry)
1221 : : {
1222 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1223 : :
1224 [ # # ]: 0 : if (pEntry == NULL) return 0;
1225 : :
1226 : 0 : return pEntry->readUINT16(OFFSET_MAJOR_VERSION);
1227 : : }
1228 : :
1229 : 374647 : REG_DLLPUBLIC RTTypeClass TYPEREG_CALLTYPE typereg_reader_getTypeClass(void * hEntry) SAL_THROW_EXTERN_C()
1230 : : {
1231 : 374647 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1232 : :
1233 [ + + ]: 374647 : if (pEntry == NULL) return RT_TYPE_INVALID;
1234 : :
1235 : : return (RTTypeClass)
1236 : 374647 : (pEntry->readUINT16(OFFSET_TYPE_CLASS) & ~RT_TYPE_PUBLISHED);
1237 : : }
1238 : :
1239 : 65792 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_reader_isPublished(void * hEntry) SAL_THROW_EXTERN_C()
1240 : : {
1241 : 65792 : TypeRegistryEntry * entry = static_cast< TypeRegistryEntry * >(hEntry);
1242 : : return entry != 0
1243 [ + - ][ + + ]: 65792 : && (entry->readUINT16(OFFSET_TYPE_CLASS) & RT_TYPE_PUBLISHED) != 0;
1244 : : }
1245 : :
1246 : 79005 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getTypeName(void * hEntry, rtl_uString** pTypeName)
1247 : : SAL_THROW_EXTERN_C()
1248 : : {
1249 : 79005 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1250 : :
1251 [ - + ]: 79005 : if (pEntry == NULL)
1252 : : {
1253 : 0 : rtl_uString_new(pTypeName);
1254 : 79005 : return;
1255 : : }
1256 : :
1257 : 79005 : const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_THIS_TYPE));
1258 : : rtl_string2UString(
1259 : : pTypeName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1260 [ + - ]: 79005 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1261 : : }
1262 : :
1263 : :
1264 : 0 : static void TYPEREG_CALLTYPE getSuperTypeName(TypeReaderImpl hEntry, rtl_uString** pSuperTypeName)
1265 : : {
1266 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1267 : :
1268 [ # # ]: 0 : if (pEntry == NULL)
1269 : : {
1270 : 0 : rtl_uString_new(pSuperTypeName);
1271 : 0 : return;
1272 : : }
1273 : :
1274 [ # # ]: 0 : if (pEntry->m_nSuperTypes == 0)
1275 : : {
1276 : 0 : rtl_uString_new(pSuperTypeName);
1277 : 0 : return;
1278 : : }
1279 : :
1280 : 0 : const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(pEntry->m_offset_SUPERTYPES )); //+ (index * sizeof(sal_uInt16))));
1281 : : rtl_string2UString(
1282 : : pSuperTypeName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1283 [ # # ]: 0 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1284 : : }
1285 : :
1286 : 0 : static void TYPEREG_CALLTYPE getUik(TypeReaderImpl hEntry, RTUik* uik)
1287 : : {
1288 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1289 : :
1290 [ # # ]: 0 : if (pEntry != NULL)
1291 : : {
1292 : 0 : pEntry->m_pCP->readUIK(pEntry->readUINT16(OFFSET_UIK), uik);
1293 : : }
1294 : 0 : }
1295 : :
1296 : 0 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getDocumentation(void * hEntry, rtl_uString** pDoku)
1297 : : SAL_THROW_EXTERN_C()
1298 : : {
1299 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1300 : :
1301 [ # # ]: 0 : if (pEntry == NULL)
1302 : : {
1303 : 0 : rtl_uString_new(pDoku);
1304 : 0 : return;
1305 : : }
1306 : :
1307 : 0 : const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_DOKU));
1308 : : rtl_string2UString(
1309 : : pDoku, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1310 [ # # ]: 0 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1311 : : }
1312 : :
1313 : 0 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getFileName(void * hEntry, rtl_uString** pFileName)
1314 : : SAL_THROW_EXTERN_C()
1315 : : {
1316 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1317 : :
1318 [ # # ]: 0 : if (pEntry == NULL)
1319 : : {
1320 : 0 : rtl_uString_new(pFileName);
1321 : 0 : return;
1322 : : }
1323 : :
1324 : 0 : const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(OFFSET_FILENAME));
1325 : : rtl_string2UString(
1326 : : pFileName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1327 [ # # ]: 0 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1328 : : }
1329 : :
1330 : :
1331 : 283271 : REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getFieldCount(void * hEntry) SAL_THROW_EXTERN_C()
1332 : : {
1333 : 283271 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1334 : :
1335 [ - + ]: 283271 : if (pEntry == NULL) return 0;
1336 : :
1337 : 283271 : return pEntry->m_pFields->m_numOfEntries;
1338 : : }
1339 : :
1340 : 77156 : static sal_uInt32 TYPEREG_CALLTYPE getFieldCount(TypeReaderImpl hEntry)
1341 : : {
1342 : 77156 : return typereg_reader_getFieldCount(hEntry);
1343 : : }
1344 : :
1345 : 230887 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getFieldName(void * hEntry, rtl_uString** pFieldName, sal_uInt16 index)
1346 : : SAL_THROW_EXTERN_C()
1347 : : {
1348 : 230887 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1349 : :
1350 [ - + ]: 230887 : if (pEntry == NULL)
1351 : : {
1352 : 0 : rtl_uString_new(pFieldName);
1353 : 230887 : return;
1354 : : }
1355 : 230887 : const sal_Char* pTmp = pEntry->m_pFields->getFieldName(index);
1356 : : rtl_string2UString(
1357 : : pFieldName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1358 [ + - ]: 230887 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1359 : : }
1360 : :
1361 : 221785 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getFieldTypeName(void * hEntry, rtl_uString** pFieldType, sal_uInt16 index)
1362 : : SAL_THROW_EXTERN_C()
1363 : : {
1364 : 221785 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1365 : :
1366 [ - + ]: 221785 : if (pEntry == NULL)
1367 : : {
1368 : 0 : rtl_uString_new(pFieldType);
1369 : 221785 : return;
1370 : : }
1371 : :
1372 : 221785 : const sal_Char* pTmp = pEntry->m_pFields->getFieldType(index);
1373 : : rtl_string2UString(
1374 : : pFieldType, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1375 [ + - ]: 221785 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1376 : : }
1377 : :
1378 : 206987 : REG_DLLPUBLIC RTFieldAccess TYPEREG_CALLTYPE typereg_reader_getFieldFlags(void * hEntry, sal_uInt16 index)
1379 : : SAL_THROW_EXTERN_C()
1380 : : {
1381 : 206987 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1382 : :
1383 [ - + ]: 206987 : if (pEntry == NULL) return RT_ACCESS_INVALID;
1384 : :
1385 : 206987 : return pEntry->m_pFields->getFieldAccess(index);
1386 : : }
1387 : :
1388 : 98639 : REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE typereg_reader_getFieldValue(
1389 : : void * hEntry, sal_uInt16 index, RTValueType * type,
1390 : : RTConstValueUnion * value)
1391 : : SAL_THROW_EXTERN_C()
1392 : : {
1393 : 98639 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1394 : :
1395 [ - + ]: 98639 : if (pEntry == NULL) {
1396 : 0 : *type = RT_TYPE_NONE;
1397 : 0 : return true;
1398 : : }
1399 : :
1400 : : try {
1401 [ + - ]: 98639 : *type = pEntry->m_pFields->getFieldConstValue(index, value);
1402 : 0 : } catch (std::bad_alloc &) {
1403 : 0 : return false;
1404 : : }
1405 [ # # ]: 98639 : return true;
1406 : : }
1407 : :
1408 : 0 : static RTValueType TYPEREG_CALLTYPE getFieldConstValue(TypeReaderImpl hEntry, sal_uInt16 index, RTConstValueUnion* value)
1409 : : {
1410 : 0 : RTValueType t = RT_TYPE_NONE;
1411 : 0 : typereg_reader_getFieldValue(hEntry, index, &t, value);
1412 : 0 : return t;
1413 : : }
1414 : :
1415 : 0 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getFieldDocumentation(void * hEntry, rtl_uString** pDoku, sal_uInt16 index)
1416 : : SAL_THROW_EXTERN_C()
1417 : : {
1418 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1419 : :
1420 [ # # ]: 0 : if (pEntry == NULL)
1421 : : {
1422 : 0 : rtl_uString_new(pDoku);
1423 : 0 : return;
1424 : : }
1425 : :
1426 : 0 : const sal_Char* pTmp = pEntry->m_pFields->getFieldDoku(index);
1427 : : rtl_string2UString(
1428 : : pDoku, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1429 [ # # ]: 0 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1430 : : }
1431 : :
1432 : 0 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getFieldFileName(void * hEntry, rtl_uString** pFieldFileName, sal_uInt16 index)
1433 : : SAL_THROW_EXTERN_C()
1434 : : {
1435 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1436 : :
1437 [ # # ]: 0 : if (pEntry == NULL)
1438 : : {
1439 : 0 : rtl_uString_new(pFieldFileName);
1440 : 0 : return;
1441 : : }
1442 : :
1443 : 0 : const sal_Char* pTmp = pEntry->m_pFields->getFieldFileName(index);
1444 : : rtl_string2UString(
1445 : : pFieldFileName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1446 [ # # ]: 0 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1447 : : }
1448 : :
1449 : :
1450 : 177459 : REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getMethodCount(void * hEntry) SAL_THROW_EXTERN_C()
1451 : : {
1452 : 177459 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1453 : :
1454 [ - + ]: 177459 : if (pEntry == NULL) return 0;
1455 : :
1456 : 177459 : return pEntry->m_pMethods->m_numOfEntries;
1457 : : }
1458 : :
1459 : 0 : static sal_uInt32 TYPEREG_CALLTYPE getMethodCount(TypeReaderImpl hEntry)
1460 : : {
1461 : 0 : return typereg_reader_getMethodCount(hEntry);
1462 : : }
1463 : :
1464 : 327644 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getMethodName(void * hEntry, rtl_uString** pMethodName, sal_uInt16 index)
1465 : : SAL_THROW_EXTERN_C()
1466 : : {
1467 : 327644 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1468 : :
1469 [ - + ]: 327644 : if (pEntry == NULL)
1470 : : {
1471 : 0 : rtl_uString_new(pMethodName);
1472 : 327644 : return;
1473 : : }
1474 : :
1475 : 327644 : const sal_Char* pTmp = pEntry->m_pMethods->getMethodName(index);
1476 : : rtl_string2UString(
1477 : : pMethodName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1478 [ + - ]: 327644 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1479 : : }
1480 : :
1481 : 158634 : REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getMethodParameterCount(
1482 : : void * hEntry, sal_uInt16 index) SAL_THROW_EXTERN_C()
1483 : : {
1484 : 158634 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1485 : :
1486 [ - + ]: 158634 : if (pEntry == NULL) return 0;
1487 : :
1488 : 158634 : return pEntry->m_pMethods->getMethodParamCount(index);
1489 : : }
1490 : :
1491 : 0 : static sal_uInt32 TYPEREG_CALLTYPE getMethodParamCount(TypeReaderImpl hEntry, sal_uInt16 index)
1492 : : {
1493 : 0 : return typereg_reader_getMethodParameterCount(hEntry, index);
1494 : : }
1495 : :
1496 : 120001 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getMethodParameterTypeName(void * hEntry, rtl_uString** pMethodParamType, sal_uInt16 index, sal_uInt16 paramIndex)
1497 : : SAL_THROW_EXTERN_C()
1498 : : {
1499 : 120001 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1500 : :
1501 [ - + ]: 120001 : if (pEntry == NULL)
1502 : : {
1503 : 0 : rtl_uString_new(pMethodParamType);
1504 : 120001 : return;
1505 : : }
1506 : :
1507 : 120001 : const sal_Char* pTmp = pEntry->m_pMethods->getMethodParamType(index, paramIndex);
1508 : : rtl_string2UString(
1509 : : pMethodParamType, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1510 [ + - ]: 120001 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1511 : : }
1512 : :
1513 : 67476 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getMethodParameterName(void * hEntry, rtl_uString** pMethodParamName, sal_uInt16 index, sal_uInt16 paramIndex)
1514 : : SAL_THROW_EXTERN_C()
1515 : : {
1516 : 67476 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1517 : :
1518 [ - + ]: 67476 : if (pEntry == NULL)
1519 : : {
1520 : 0 : rtl_uString_new(pMethodParamName);
1521 : 67476 : return;
1522 : : }
1523 : :
1524 : 67476 : const sal_Char* pTmp = pEntry->m_pMethods->getMethodParamName(index, paramIndex);
1525 : : rtl_string2UString(
1526 : : pMethodParamName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1527 [ + - ]: 67476 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1528 : : }
1529 : :
1530 : 106251 : REG_DLLPUBLIC RTParamMode TYPEREG_CALLTYPE typereg_reader_getMethodParameterFlags(void * hEntry, sal_uInt16 index, sal_uInt16 paramIndex)
1531 : : SAL_THROW_EXTERN_C()
1532 : : {
1533 : 106251 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1534 : :
1535 [ - + ]: 106251 : if (pEntry == NULL) return RT_PARAM_INVALID;
1536 : :
1537 : 106251 : return pEntry->m_pMethods->getMethodParamMode(index, paramIndex);
1538 : : }
1539 : :
1540 : 132641 : REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getMethodExceptionCount(
1541 : : void * hEntry, sal_uInt16 index) SAL_THROW_EXTERN_C()
1542 : : {
1543 : 132641 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1544 : :
1545 [ - + ]: 132641 : if (pEntry == NULL) return 0;
1546 : :
1547 : 132641 : return pEntry->m_pMethods->getMethodExcCount(index);
1548 : : }
1549 : :
1550 : 0 : static sal_uInt32 TYPEREG_CALLTYPE getMethodExcCount(TypeReaderImpl hEntry, sal_uInt16 index)
1551 : : {
1552 : 0 : return typereg_reader_getMethodExceptionCount(hEntry, index);
1553 : : }
1554 : :
1555 : 61620 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getMethodExceptionTypeName(void * hEntry, rtl_uString** pMethodExcpType, sal_uInt16 index, sal_uInt16 excIndex)
1556 : : SAL_THROW_EXTERN_C()
1557 : : {
1558 : 61620 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1559 : :
1560 [ - + ]: 61620 : if (pEntry == NULL)
1561 : : {
1562 : 0 : rtl_uString_new(pMethodExcpType);
1563 : 61620 : return;
1564 : : }
1565 : :
1566 : 61620 : const sal_Char* pTmp = pEntry->m_pMethods->getMethodExcType(index, excIndex);
1567 : : rtl_string2UString(
1568 : : pMethodExcpType, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1569 [ + - ]: 61620 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1570 : : }
1571 : :
1572 : 256570 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getMethodReturnTypeName(void * hEntry, rtl_uString** pMethodReturnType, sal_uInt16 index)
1573 : : SAL_THROW_EXTERN_C()
1574 : : {
1575 : 256570 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1576 : :
1577 [ - + ]: 256570 : if (pEntry == NULL)
1578 : : {
1579 : 0 : rtl_uString_new(pMethodReturnType);
1580 : 256570 : return;
1581 : : }
1582 : :
1583 : 256570 : const sal_Char* pTmp = pEntry->m_pMethods->getMethodReturnType(index);
1584 : : rtl_string2UString(
1585 : : pMethodReturnType, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1586 [ + - ]: 256570 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1587 : : }
1588 : :
1589 : 536936 : REG_DLLPUBLIC RTMethodMode TYPEREG_CALLTYPE typereg_reader_getMethodFlags(void * hEntry, sal_uInt16 index)
1590 : : SAL_THROW_EXTERN_C()
1591 : : {
1592 : 536936 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1593 : :
1594 [ - + ]: 536936 : if (pEntry == NULL) return RT_MODE_INVALID;
1595 : :
1596 : 536936 : return pEntry->m_pMethods->getMethodMode(index);
1597 : : }
1598 : :
1599 : 0 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getMethodDocumentation(void * hEntry, rtl_uString** pMethodDoku, sal_uInt16 index)
1600 : : SAL_THROW_EXTERN_C()
1601 : : {
1602 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1603 : :
1604 [ # # ]: 0 : if (pEntry == NULL)
1605 : : {
1606 : 0 : rtl_uString_new(pMethodDoku);
1607 : 0 : return;
1608 : : }
1609 : :
1610 : 0 : const sal_Char* pTmp = pEntry->m_pMethods->getMethodDoku(index);
1611 : : rtl_string2UString(
1612 : : pMethodDoku, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1613 [ # # ]: 0 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1614 : : }
1615 : :
1616 : 135920 : REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getReferenceCount(void * hEntry) SAL_THROW_EXTERN_C()
1617 : : {
1618 : 135920 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1619 : :
1620 [ - + ]: 135920 : if (pEntry == NULL) return 0;
1621 : :
1622 : 135920 : return pEntry->m_pReferences->m_numOfEntries;
1623 : : }
1624 : :
1625 : 0 : static sal_uInt32 TYPEREG_CALLTYPE getReferenceCount(TypeReaderImpl hEntry)
1626 : : {
1627 : 0 : return typereg_reader_getReferenceCount(hEntry);
1628 : : }
1629 : :
1630 : 13498 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getReferenceTypeName(void * hEntry, rtl_uString** pReferenceName, sal_uInt16 index)
1631 : : SAL_THROW_EXTERN_C()
1632 : : {
1633 : 13498 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1634 : :
1635 [ - + ]: 13498 : if (pEntry == NULL)
1636 : : {
1637 : 0 : rtl_uString_new(pReferenceName);
1638 : 13498 : return;
1639 : : }
1640 : :
1641 : 13498 : const sal_Char* pTmp = pEntry->m_pReferences->getReferenceName(index);
1642 : : rtl_string2UString(
1643 : : pReferenceName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1644 [ + - ]: 13498 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1645 : : }
1646 : :
1647 : 12943 : REG_DLLPUBLIC RTReferenceType TYPEREG_CALLTYPE typereg_reader_getReferenceSort(void * hEntry, sal_uInt16 index)
1648 : : SAL_THROW_EXTERN_C()
1649 : : {
1650 : 12943 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1651 : :
1652 [ - + ]: 12943 : if (pEntry == NULL) return RT_REF_INVALID;
1653 : :
1654 : 12943 : return pEntry->m_pReferences->getReferenceType(index);
1655 : : }
1656 : :
1657 : 0 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getReferenceDocumentation(void * hEntry, rtl_uString** pReferenceDoku, sal_uInt16 index)
1658 : : SAL_THROW_EXTERN_C()
1659 : : {
1660 : 0 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1661 : :
1662 [ # # ]: 0 : if (pEntry == NULL)
1663 : : {
1664 : 0 : rtl_uString_new(pReferenceDoku);
1665 : 0 : return;
1666 : : }
1667 : :
1668 : 0 : const sal_Char* pTmp = pEntry->m_pReferences->getReferenceDoku(index);
1669 : : rtl_string2UString(
1670 : : pReferenceDoku, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1671 [ # # ]: 0 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1672 : : }
1673 : :
1674 : 1175 : REG_DLLPUBLIC RTFieldAccess TYPEREG_CALLTYPE typereg_reader_getReferenceFlags(void * hEntry, sal_uInt16 index)
1675 : : SAL_THROW_EXTERN_C()
1676 : : {
1677 : 1175 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1678 : :
1679 [ - + ]: 1175 : if (pEntry == NULL) return RT_ACCESS_INVALID;
1680 : :
1681 : 1175 : return pEntry->m_pReferences->getReferenceAccess(index);
1682 : : }
1683 : :
1684 : 162682 : REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE typereg_reader_getSuperTypeCount(void * hEntry)
1685 : : SAL_THROW_EXTERN_C()
1686 : : {
1687 : 162682 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1688 : :
1689 [ - + ]: 162682 : if (pEntry == NULL) return 0;
1690 : :
1691 : 162682 : return pEntry->m_nSuperTypes;
1692 : : }
1693 : :
1694 : 102109 : REG_DLLPUBLIC void TYPEREG_CALLTYPE typereg_reader_getSuperTypeName(
1695 : : void * hEntry, rtl_uString ** pSuperTypeName, sal_uInt16 index)
1696 : : SAL_THROW_EXTERN_C()
1697 : : {
1698 : 102109 : TypeRegistryEntry* pEntry = (TypeRegistryEntry*) hEntry;
1699 : :
1700 [ - + ]: 102109 : if (pEntry == NULL)
1701 : : {
1702 : 0 : rtl_uString_new(pSuperTypeName);
1703 : 102109 : return;
1704 : : }
1705 : :
1706 : : OSL_ASSERT(index < pEntry->m_nSuperTypes);
1707 : 102109 : const sal_Char* pTmp = pEntry->m_pCP->readUTF8NameConstant(pEntry->readUINT16(pEntry->m_offset_SUPERTYPES + (index * sizeof(sal_uInt16))));
1708 : : rtl_string2UString(
1709 : : pSuperTypeName, pTmp, pTmp == 0 ? 0 : rtl_str_getLength(pTmp),
1710 [ + - ]: 102109 : RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS);
1711 : : }
1712 : :
1713 : 88635 : REG_DLLPUBLIC RegistryTypeReader_Api* TYPEREG_CALLTYPE initRegistryTypeReader_Api(void)
1714 : : {
1715 : : static RegistryTypeReader_Api aApi= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1716 [ + + ]: 88635 : if (!aApi.acquire)
1717 : : {
1718 : 10 : aApi.createEntry = &createEntry;
1719 : 10 : aApi.acquire = &typereg_reader_acquire;
1720 : 10 : aApi.release = &typereg_reader_release;
1721 : 10 : aApi.getMinorVersion = &getMinorVersion;
1722 : 10 : aApi.getMajorVersion = &getMajorVersion;
1723 : 10 : aApi.getTypeClass = &typereg_reader_getTypeClass;
1724 : 10 : aApi.getTypeName = &typereg_reader_getTypeName;
1725 : 10 : aApi.getSuperTypeName = &getSuperTypeName;
1726 : 10 : aApi.getUik = &getUik;
1727 : 10 : aApi.getDoku = &typereg_reader_getDocumentation;
1728 : 10 : aApi.getFileName = &typereg_reader_getFileName;
1729 : 10 : aApi.getFieldCount = &getFieldCount;
1730 : 10 : aApi.getFieldName = &typereg_reader_getFieldName;
1731 : 10 : aApi.getFieldType = &typereg_reader_getFieldTypeName;
1732 : 10 : aApi.getFieldAccess = &typereg_reader_getFieldFlags;
1733 : 10 : aApi.getFieldConstValue = &getFieldConstValue;
1734 : 10 : aApi.getFieldDoku = &typereg_reader_getFieldDocumentation;
1735 : 10 : aApi.getFieldFileName = &typereg_reader_getFieldFileName;
1736 : 10 : aApi.getMethodCount = &getMethodCount;
1737 : 10 : aApi.getMethodName = &typereg_reader_getMethodName;
1738 : 10 : aApi.getMethodParamCount = &getMethodParamCount;
1739 : 10 : aApi.getMethodParamType = &typereg_reader_getMethodParameterTypeName;
1740 : 10 : aApi.getMethodParamName = &typereg_reader_getMethodParameterName;
1741 : 10 : aApi.getMethodParamMode = &typereg_reader_getMethodParameterFlags;
1742 : 10 : aApi.getMethodExcCount = &getMethodExcCount;
1743 : 10 : aApi.getMethodExcType = &typereg_reader_getMethodExceptionTypeName;
1744 : 10 : aApi.getMethodReturnType = &typereg_reader_getMethodReturnTypeName;
1745 : 10 : aApi.getMethodMode = &typereg_reader_getMethodFlags;
1746 : 10 : aApi.getMethodDoku = &typereg_reader_getMethodDocumentation;
1747 : 10 : aApi.getReferenceCount = &getReferenceCount;
1748 : 10 : aApi.getReferenceName = &typereg_reader_getReferenceTypeName;
1749 : 10 : aApi.getReferenceType = &typereg_reader_getReferenceSort;
1750 : 10 : aApi.getReferenceDoku = &typereg_reader_getReferenceDocumentation;
1751 : 10 : aApi.getReferenceAccess = &typereg_reader_getReferenceFlags;
1752 : :
1753 : 10 : return (&aApi);
1754 : : }
1755 : : else
1756 : : {
1757 : 88635 : return (&aApi);
1758 : : }
1759 : : }
1760 : :
1761 : : }
1762 : :
1763 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|