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