1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
25 #include <sal/types.h>
26 #include <osl/endian.h>
27 #include <registry/reflread.hxx>
29 #include "registry/reader.h"
30 #include "registry/version.h"
32 #include "reflcnst.hxx"
36 static const sal_Char NULL_STRING
[1] = { 0 };
37 static const sal_Unicode NULL_WSTRING
[1] = { 0 };
39 const sal_uInt32 magic
= 0x12345678;
40 const sal_uInt16 minorVersion
= 0x0000;
41 const sal_uInt16 majorVersion
= 0x0001;
43 /**************************************************************************
47 holds any data in a flat memory buffer
49 **************************************************************************/
54 const sal_uInt8
* m_pBuffer
;
55 sal_uInt32 m_bufferLen
;
58 BlopObject(const sal_uInt8
* buffer
, sal_uInt32 len
, bool copyBuffer
);
59 // throws std::bad_alloc
63 inline sal_uInt8
readBYTE(sal_uInt32 index
) const
65 return m_pBuffer
[index
];
68 inline sal_Int16
readINT16(sal_uInt32 index
) const
70 return ((m_pBuffer
[index
] << 8) | (m_pBuffer
[index
+1] << 0));
73 inline sal_uInt16
readUINT16(sal_uInt32 index
) const
75 return ((m_pBuffer
[index
] << 8) | (m_pBuffer
[index
+1] << 0));
78 inline sal_Int32
readINT32(sal_uInt32 index
) const
81 (m_pBuffer
[index
] << 24) |
82 (m_pBuffer
[index
+1] << 16) |
83 (m_pBuffer
[index
+2] << 8) |
84 (m_pBuffer
[index
+3] << 0)
88 inline sal_uInt32
readUINT32(sal_uInt32 index
) const
91 (m_pBuffer
[index
] << 24) |
92 (m_pBuffer
[index
+1] << 16) |
93 (m_pBuffer
[index
+2] << 8) |
94 (m_pBuffer
[index
+3] << 0)
98 inline sal_Int64
readINT64(sal_uInt32 index
) const
101 ((sal_Int64
)m_pBuffer
[index
] << 56) |
102 ((sal_Int64
)m_pBuffer
[index
+1] << 48) |
103 ((sal_Int64
)m_pBuffer
[index
+2] << 40) |
104 ((sal_Int64
)m_pBuffer
[index
+3] << 32) |
105 ((sal_Int64
)m_pBuffer
[index
+4] << 24) |
106 ((sal_Int64
)m_pBuffer
[index
+5] << 16) |
107 ((sal_Int64
)m_pBuffer
[index
+6] << 8) |
108 ((sal_Int64
)m_pBuffer
[index
+7] << 0)
112 inline sal_uInt64
readUINT64(sal_uInt32 index
) const
115 ((sal_uInt64
)m_pBuffer
[index
] << 56) |
116 ((sal_uInt64
)m_pBuffer
[index
+1] << 48) |
117 ((sal_uInt64
)m_pBuffer
[index
+2] << 40) |
118 ((sal_uInt64
)m_pBuffer
[index
+3] << 32) |
119 ((sal_uInt64
)m_pBuffer
[index
+4] << 24) |
120 ((sal_uInt64
)m_pBuffer
[index
+5] << 16) |
121 ((sal_uInt64
)m_pBuffer
[index
+6] << 8) |
122 ((sal_uInt64
)m_pBuffer
[index
+7] << 0)
127 BlopObject::BlopObject(const sal_uInt8
* buffer
, sal_uInt32 len
, bool copyBuffer
)
129 , m_isCopied(copyBuffer
)
134 sal_uInt8
* newBuffer
= new sal_uInt8
[len
];
135 memcpy(newBuffer
, buffer
, len
);
136 m_pBuffer
= newBuffer
;
144 BlopObject::~BlopObject()
148 delete[] const_cast<sal_uInt8
*>(m_pBuffer
);
152 /**************************************************************************
156 **************************************************************************/
161 sal_Unicode
** m_stringTable
;
162 sal_uInt16 m_numOfStrings
;
163 sal_uInt16 m_stringsCopied
;
165 StringCache(sal_uInt16 size
); // throws std::bad_alloc
168 const sal_Unicode
* getString(sal_uInt16 index
);
169 sal_uInt16
createString(const sal_uInt8
* buffer
); // throws std::bad_alloc
172 StringCache::StringCache(sal_uInt16 size
)
173 : m_stringTable(NULL
)
174 , m_numOfStrings(size
)
177 m_stringTable
= new sal_Unicode
*[m_numOfStrings
];
179 for (sal_uInt16 i
= 0; i
< m_numOfStrings
; i
++)
181 m_stringTable
[i
] = NULL
;
185 StringCache::~StringCache()
189 for (sal_uInt16 i
= 0; i
< m_stringsCopied
; i
++)
191 delete[] m_stringTable
[i
];
194 delete[] m_stringTable
;
198 const sal_Unicode
* StringCache::getString(sal_uInt16 index
)
200 if ((index
> 0) && (index
<= m_stringsCopied
))
201 return m_stringTable
[index
- 1];
206 sal_uInt16
StringCache::createString(const sal_uInt8
* buffer
)
208 if (m_stringsCopied
< m_numOfStrings
)
210 sal_uInt32 len
= UINT16StringLen(buffer
);
212 m_stringTable
[m_stringsCopied
] = new sal_Unicode
[len
+ 1];
214 readString(buffer
, m_stringTable
[m_stringsCopied
], (len
+ 1) * sizeof(sal_Unicode
));
216 return ++m_stringsCopied
;
222 /**************************************************************************
226 **************************************************************************/
228 class ConstantPool
: public BlopObject
232 sal_uInt16 m_numOfEntries
;
233 sal_Int32
* m_pIndex
; // index values may be < 0 for cached string constants
235 StringCache
* m_pStringCache
;
237 ConstantPool(const sal_uInt8
* buffer
, sal_uInt16 numEntries
)
238 : BlopObject(buffer
, 0, sal_False
)
239 , m_numOfEntries(numEntries
)
241 , m_pStringCache(NULL
)
247 sal_uInt32
parseIndex(); // throws std::bad_alloc
249 CPInfoTag
readTag(sal_uInt16 index
);
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
);
267 ConstantPool::~ConstantPool()
270 delete m_pStringCache
;
273 sal_uInt32
ConstantPool::parseIndex()
283 delete m_pStringCache
;
284 m_pStringCache
= NULL
;
287 sal_uInt32 offset
= 0;
288 sal_uInt16 numOfStrings
= 0;
292 m_pIndex
= new sal_Int32
[m_numOfEntries
];
294 for (int i
= 0; i
< m_numOfEntries
; i
++)
296 m_pIndex
[i
] = offset
;
298 offset
+= readUINT32(offset
);
300 if ( ((CPInfoTag
) readUINT16(m_pIndex
[i
] + CP_OFFSET_ENTRY_TAG
)) ==
301 CP_TAG_CONST_STRING
)
311 m_pStringCache
= new StringCache(numOfStrings
);
314 m_bufferLen
= offset
;
319 CPInfoTag
ConstantPool::readTag(sal_uInt16 index
)
321 CPInfoTag tag
= CP_TAG_INVALID
;
323 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
325 tag
= (CPInfoTag
) readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
);
331 const sal_Char
* ConstantPool::readUTF8NameConstant(sal_uInt16 index
)
333 const sal_Char
* aName
= NULL_STRING
;
335 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
337 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_UTF8_NAME
)
339 aName
= (const sal_Char
*) (m_pBuffer
+ m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
346 sal_Bool
ConstantPool::readBOOLConstant(sal_uInt16 index
)
348 sal_Bool aBool
= sal_False
;
350 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
352 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_BOOL
)
354 aBool
= (sal_Bool
) readBYTE(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
361 sal_Int8
ConstantPool::readBYTEConstant(sal_uInt16 index
)
365 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
367 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_BYTE
)
369 aByte
= static_cast< sal_Int8
>(
370 readBYTE(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
));
377 sal_Int16
ConstantPool::readINT16Constant(sal_uInt16 index
)
379 sal_Int16 aINT16
= 0;
381 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
383 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_INT16
)
385 aINT16
= readINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
392 sal_uInt16
ConstantPool::readUINT16Constant(sal_uInt16 index
)
394 sal_uInt16 asal_uInt16
= 0;
396 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
398 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_UINT16
)
400 asal_uInt16
= readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
407 sal_Int32
ConstantPool::readINT32Constant(sal_uInt16 index
)
409 sal_Int32 aINT32
= 0;
411 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
413 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_INT32
)
415 aINT32
= readINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
422 sal_uInt32
ConstantPool::readUINT32Constant(sal_uInt16 index
)
424 sal_uInt32 aUINT32
= 0;
426 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
428 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_UINT32
)
430 aUINT32
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
437 sal_Int64
ConstantPool::readINT64Constant(sal_uInt16 index
)
439 sal_Int64 aINT64
= 0;
441 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
443 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_INT64
)
445 aINT64
= readINT64(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
452 sal_uInt64
ConstantPool::readUINT64Constant(sal_uInt16 index
)
454 sal_uInt64 aUINT64
= 0;
456 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
458 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_UINT64
)
460 aUINT64
= readUINT64(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
467 float ConstantPool::readFloatConstant(sal_uInt16 index
)
475 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
477 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_FLOAT
)
479 #ifdef REGTYPE_IEEE_NATIVE
480 x
.b
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
490 double ConstantPool::readDoubleConstant(sal_uInt16 index
)
502 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
504 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_DOUBLE
)
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
));
512 x
.b
.b1
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
+ sizeof(sal_uInt32
));
513 x
.b
.b2
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
524 const sal_Unicode
* ConstantPool::readStringConstant(sal_uInt16 index
)
526 const sal_Unicode
* aString
= NULL_WSTRING
;
528 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
) && m_pStringCache
)
530 if (m_pIndex
[index
- 1] >= 0)
532 // create cached string now
534 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_STRING
)
536 m_pIndex
[index
- 1] = -1 * m_pStringCache
->createString(m_pBuffer
+ m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
540 aString
= m_pStringCache
->getString((sal_uInt16
) (m_pIndex
[index
- 1] * -1));
546 void ConstantPool::readUIK(sal_uInt16 index
, RTUik
* uik
)
556 else if (m_pIndex
&& (index
<= m_numOfEntries
))
558 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_UIK
)
560 uik
->m_Data1
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK1
);
561 uik
->m_Data2
= readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK2
);
562 uik
->m_Data3
= readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK3
);
563 uik
->m_Data4
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK4
);
564 uik
->m_Data5
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK5
);
569 /**************************************************************************
573 **************************************************************************/
575 class FieldList
: public BlopObject
579 sal_uInt16 m_numOfEntries
;
580 sal_uInt16 m_numOfFieldEntries
;
581 sal_uInt16 m_FIELD_ENTRY_SIZE
;
584 FieldList(const sal_uInt8
* buffer
, sal_uInt16 numEntries
, ConstantPool
* pCP
)
585 : BlopObject(buffer
, 0, sal_False
)
586 , m_numOfEntries(numEntries
)
589 if ( m_numOfEntries
> 0 )
591 m_numOfFieldEntries
= readUINT16(0);
592 m_FIELD_ENTRY_SIZE
= m_numOfFieldEntries
* sizeof(sal_uInt16
);
595 m_numOfFieldEntries
= 0;
596 m_FIELD_ENTRY_SIZE
= 0;
600 sal_uInt32
parseIndex();
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
);
611 sal_uInt32
FieldList::parseIndex()
613 return ((m_numOfEntries
? sizeof(sal_uInt16
) : 0) + (m_numOfEntries
* m_FIELD_ENTRY_SIZE
));
616 const sal_Char
* FieldList::getFieldName(sal_uInt16 index
)
618 const sal_Char
* aName
= NULL
;
620 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
622 aName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_NAME
));
628 const sal_Char
* FieldList::getFieldType(sal_uInt16 index
)
630 const sal_Char
* aName
= NULL
;
632 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
634 aName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_TYPE
));
640 RTFieldAccess
FieldList::getFieldAccess(sal_uInt16 index
)
642 RTFieldAccess aAccess
= RT_ACCESS_INVALID
;
644 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
646 aAccess
= (RTFieldAccess
) readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_ACCESS
);
652 RTValueType
FieldList::getFieldConstValue(sal_uInt16 index
, RTConstValueUnion
* value
)
654 RTValueType ret
= RT_TYPE_NONE
;
656 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
658 sal_uInt16 cpIndex
= readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_VALUE
);
660 switch (m_pCP
->readTag(cpIndex
))
662 case CP_TAG_CONST_BOOL
:
663 value
->aBool
= m_pCP
->readBOOLConstant(cpIndex
);
666 case CP_TAG_CONST_BYTE
:
667 value
->aByte
= m_pCP
->readBYTEConstant(cpIndex
);
670 case CP_TAG_CONST_INT16
:
671 value
->aShort
= m_pCP
->readINT16Constant(cpIndex
);
674 case CP_TAG_CONST_UINT16
:
675 value
->aUShort
= m_pCP
->readUINT16Constant(cpIndex
);
676 ret
= RT_TYPE_UINT16
;
678 case CP_TAG_CONST_INT32
:
679 value
->aLong
= m_pCP
->readINT32Constant(cpIndex
);
682 case CP_TAG_CONST_UINT32
:
683 value
->aULong
= m_pCP
->readUINT32Constant(cpIndex
);
684 ret
= RT_TYPE_UINT32
;
686 case CP_TAG_CONST_INT64
:
687 value
->aHyper
= m_pCP
->readINT64Constant(cpIndex
);
690 case CP_TAG_CONST_UINT64
:
691 value
->aUHyper
= m_pCP
->readUINT64Constant(cpIndex
);
692 ret
= RT_TYPE_UINT64
;
694 case CP_TAG_CONST_FLOAT
:
695 value
->aFloat
= m_pCP
->readFloatConstant(cpIndex
);
698 case CP_TAG_CONST_DOUBLE
:
699 value
->aDouble
= m_pCP
->readDoubleConstant(cpIndex
);
700 ret
= RT_TYPE_DOUBLE
;
702 case CP_TAG_CONST_STRING
:
703 value
->aString
= m_pCP
->readStringConstant(cpIndex
);
704 ret
= RT_TYPE_STRING
;
714 const sal_Char
* FieldList::getFieldDoku(sal_uInt16 index
)
716 const sal_Char
* aDoku
= NULL
;
718 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
720 aDoku
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_DOKU
));
726 const sal_Char
* FieldList::getFieldFileName(sal_uInt16 index
)
728 const sal_Char
* aFileName
= NULL
;
730 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
732 aFileName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_FILENAME
));
738 /**************************************************************************
742 **************************************************************************/
744 class ReferenceList
: public BlopObject
748 sal_uInt16 m_numOfEntries
;
749 sal_uInt16 m_numOfReferenceEntries
;
750 sal_uInt16 m_REFERENCE_ENTRY_SIZE
;
753 ReferenceList(const sal_uInt8
* buffer
, sal_uInt16 numEntries
, ConstantPool
* pCP
)
754 : BlopObject(buffer
, 0, sal_False
)
755 , m_numOfEntries(numEntries
)
758 if ( m_numOfEntries
> 0 )
760 m_numOfReferenceEntries
= readUINT16(0);
761 m_REFERENCE_ENTRY_SIZE
= m_numOfReferenceEntries
* sizeof(sal_uInt16
);
764 m_numOfReferenceEntries
= 0;
765 m_REFERENCE_ENTRY_SIZE
= 0;
769 sal_uInt32
parseIndex();
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
);
777 sal_uInt32
ReferenceList::parseIndex()
779 return ((m_numOfEntries
? sizeof(sal_uInt16
) : 0) + (m_numOfEntries
* m_REFERENCE_ENTRY_SIZE
));
782 const sal_Char
* ReferenceList::getReferenceName(sal_uInt16 index
)
784 const sal_Char
* aName
= NULL
;
786 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
788 aName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_NAME
));
794 RTReferenceType
ReferenceList::getReferenceType(sal_uInt16 index
)
796 RTReferenceType refType
= RT_REF_INVALID
;
798 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
800 refType
= (RTReferenceType
) readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_TYPE
);
806 const sal_Char
* ReferenceList::getReferenceDoku(sal_uInt16 index
)
808 const sal_Char
* aDoku
= NULL
;
810 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
812 aDoku
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_DOKU
));
818 RTFieldAccess
ReferenceList::getReferenceAccess(sal_uInt16 index
)
820 RTFieldAccess aAccess
= RT_ACCESS_INVALID
;
822 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
824 aAccess
= (RTFieldAccess
) readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_ACCESS
);
830 /**************************************************************************
834 **************************************************************************/
836 class MethodList
: public BlopObject
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
;
847 MethodList(const sal_uInt8
* buffer
, sal_uInt16 numEntries
, ConstantPool
* pCP
)
848 : BlopObject(buffer
, 0, sal_False
)
849 , m_numOfEntries(numEntries
)
853 if ( m_numOfEntries
> 0 )
855 m_numOfMethodEntries
= readUINT16(0);
856 m_numOfParamEntries
= readUINT16(sizeof(sal_uInt16
));
857 m_PARAM_ENTRY_SIZE
= m_numOfParamEntries
* sizeof(sal_uInt16
);
860 m_numOfMethodEntries
= 0;
861 m_numOfParamEntries
= 0;
862 m_PARAM_ENTRY_SIZE
= 0;
868 sal_uInt32
parseIndex(); // throws std::bad_alloc
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
);
882 sal_uInt16
calcMethodParamIndex( const sal_uInt16 index
);
885 MethodList::~MethodList()
887 if (m_pIndex
) delete[] m_pIndex
;
890 sal_uInt16
MethodList::calcMethodParamIndex( const sal_uInt16 index
)
892 return (METHOD_OFFSET_PARAM_COUNT
+ sizeof(sal_uInt16
) + (index
* m_PARAM_ENTRY_SIZE
));
895 sal_uInt32
MethodList::parseIndex()
903 sal_uInt32 offset
= 0;
907 offset
= 2 * sizeof(sal_uInt16
);
908 m_pIndex
= new sal_uInt32
[m_numOfEntries
];
910 for (int i
= 0; i
< m_numOfEntries
; i
++)
912 m_pIndex
[i
] = offset
;
914 offset
+= readUINT16(offset
);
921 const sal_Char
* MethodList::getMethodName(sal_uInt16 index
)
923 const sal_Char
* aName
= NULL
;
925 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
927 aName
= m_pCP
->readUTF8NameConstant(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_NAME
));
933 sal_uInt16
MethodList::getMethodParamCount(sal_uInt16 index
)
935 sal_uInt16 aCount
= 0;
937 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
939 aCount
= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
);
945 const sal_Char
* MethodList::getMethodParamType(sal_uInt16 index
, sal_uInt16 paramIndex
)
947 const sal_Char
* aName
= NULL
;
949 if ((m_numOfEntries
> 0) &&
950 (index
<= m_numOfEntries
) &&
951 (paramIndex
<= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)))
953 aName
= m_pCP
->readUTF8NameConstant(
956 calcMethodParamIndex(paramIndex
) +
963 const sal_Char
* MethodList::getMethodParamName(sal_uInt16 index
, sal_uInt16 paramIndex
)
965 const sal_Char
* aName
= NULL
;
967 if ((m_numOfEntries
> 0) &&
968 (index
<= m_numOfEntries
) &&
969 (paramIndex
<= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)))
971 aName
= m_pCP
->readUTF8NameConstant(
974 calcMethodParamIndex(paramIndex
) +
981 RTParamMode
MethodList::getMethodParamMode(sal_uInt16 index
, sal_uInt16 paramIndex
)
983 RTParamMode aMode
= RT_PARAM_INVALID
;
985 if ((m_numOfEntries
> 0) &&
986 (index
<= m_numOfEntries
) &&
987 (paramIndex
<= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)))
989 aMode
= (RTParamMode
) readUINT16(
991 calcMethodParamIndex(paramIndex
) +
998 sal_uInt16
MethodList::getMethodExcCount(sal_uInt16 index
)
1000 sal_uInt16 aCount
= 0;
1002 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1004 aCount
= readUINT16(m_pIndex
[index
] + calcMethodParamIndex(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)));
1010 const sal_Char
* MethodList::getMethodExcType(sal_uInt16 index
, sal_uInt16 excIndex
)
1012 const sal_Char
* aName
= NULL
;
1014 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1016 sal_uInt32 excOffset
= m_pIndex
[index
] + calcMethodParamIndex(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
));
1018 if (excIndex
<= readUINT16(excOffset
))
1020 aName
= m_pCP
->readUTF8NameConstant(
1023 sizeof(sal_uInt16
) +
1024 (excIndex
* sizeof(sal_uInt16
))));
1031 const sal_Char
* MethodList::getMethodReturnType(sal_uInt16 index
)
1033 const sal_Char
* aName
= NULL
;
1035 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1037 aName
= m_pCP
->readUTF8NameConstant(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_RETURN
));
1043 RTMethodMode
MethodList::getMethodMode(sal_uInt16 index
)
1045 RTMethodMode aMode
= RT_MODE_INVALID
;
1047 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1049 aMode
= (RTMethodMode
) readUINT16(m_pIndex
[index
] + METHOD_OFFSET_MODE
);
1055 const sal_Char
* MethodList::getMethodDoku(sal_uInt16 index
)
1057 const sal_Char
* aDoku
= NULL
;
1059 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1061 aDoku
= m_pCP
->readUTF8NameConstant(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_DOKU
));
1067 /**************************************************************************
1069 class TypeRegistryEntry
1071 **************************************************************************/
1073 class TypeRegistryEntry
: public BlopObject
{
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
;
1084 const sal_uInt8
* buffer
, sal_uInt32 len
, sal_Bool copyBuffer
);
1085 // throws std::bad_alloc
1087 ~TypeRegistryEntry();
1089 typereg_Version
getVersion() const;
1092 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 m_offset_SUPERTYPES(0)
1098 std::size_t const entrySize
= sizeof(sal_uInt16
);
1099 sal_uInt16 nHeaderEntries
= readUINT16(OFFSET_N_ENTRIES
);
1100 sal_uInt16 offset_N_SUPERTYPES
= OFFSET_N_ENTRIES
+ entrySize
+ (nHeaderEntries
* entrySize
);
1101 m_offset_SUPERTYPES
= offset_N_SUPERTYPES
+ entrySize
;
1102 m_nSuperTypes
= readUINT16(offset_N_SUPERTYPES
);
1104 sal_uInt16 offset_CP_SIZE
= m_offset_SUPERTYPES
+ (m_nSuperTypes
* entrySize
);
1105 sal_uInt16 offset_CP
= offset_CP_SIZE
+ entrySize
;
1107 m_pCP
= new ConstantPool(m_pBuffer
+ offset_CP
, readUINT16(offset_CP_SIZE
));
1109 sal_uInt32 offset
= offset_CP
+ m_pCP
->parseIndex();
1111 m_pFields
= new FieldList(
1112 m_pBuffer
+ offset
+ entrySize
, readUINT16(offset
), m_pCP
);
1114 offset
+= sizeof(sal_uInt16
) + m_pFields
->parseIndex();
1116 m_pMethods
= new MethodList(
1117 m_pBuffer
+ offset
+ entrySize
, readUINT16(offset
), m_pCP
);
1119 offset
+= sizeof(sal_uInt16
) + m_pMethods
->parseIndex();
1121 m_pReferences
= new ReferenceList(
1122 m_pBuffer
+ offset
+ entrySize
, readUINT16(offset
), m_pCP
);
1124 m_pReferences
->parseIndex();
1127 TypeRegistryEntry::~TypeRegistryEntry()
1132 delete m_pReferences
;
1135 typereg_Version
TypeRegistryEntry::getVersion() const {
1136 // Assumes two's complement arithmetic with modulo-semantics:
1137 return static_cast< typereg_Version
>(readUINT32(OFFSET_MAGIC
) - magic
);
1140 /**************************************************************************
1144 **************************************************************************/
1148 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()
1153 if (length
< OFFSET_CP
|| length
> SAL_MAX_UINT32
) {
1157 std::auto_ptr
< TypeRegistryEntry
> entry
;
1160 new TypeRegistryEntry(
1161 static_cast< sal_uInt8
const * >(buffer
),
1162 static_cast< sal_uInt32
>(length
), copy
));
1163 } catch (std::bad_alloc
&) {
1166 if (entry
->readUINT32(OFFSET_SIZE
) != length
) {
1170 typereg_Version version
= entry
->getVersion();
1171 if (version
< TYPEREG_VERSION_0
|| version
> maxVersion
) {
1175 *result
= entry
.release();
1179 static TypeReaderImpl TYPEREG_CALLTYPE
createEntry(const sal_uInt8
* buffer
, sal_uInt32 len
, sal_Bool copyBuffer
)
1182 typereg_reader_create(buffer
, len
, copyBuffer
, TYPEREG_VERSION_1
, &handle
);
1186 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_acquire(void * hEntry
) SAL_THROW_EXTERN_C()
1188 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1191 pEntry
->m_refCount
++;
1194 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_release(void * hEntry
) SAL_THROW_EXTERN_C()
1196 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1200 if (--pEntry
->m_refCount
== 0)
1205 REG_DLLPUBLIC typereg_Version TYPEREG_CALLTYPE
typereg_reader_getVersion(void * handle
) SAL_THROW_EXTERN_C() {
1208 : static_cast< TypeRegistryEntry
* >(handle
)->getVersion();
1211 static sal_uInt16 TYPEREG_CALLTYPE
getMinorVersion(TypeReaderImpl hEntry
)
1213 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1215 if (pEntry
== NULL
) return 0;
1217 return pEntry
->readUINT16(OFFSET_MINOR_VERSION
);
1220 static sal_uInt16 TYPEREG_CALLTYPE
getMajorVersion(TypeReaderImpl hEntry
)
1222 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1224 if (pEntry
== NULL
) return 0;
1226 return pEntry
->readUINT16(OFFSET_MAJOR_VERSION
);
1229 REG_DLLPUBLIC RTTypeClass TYPEREG_CALLTYPE
typereg_reader_getTypeClass(void * hEntry
) SAL_THROW_EXTERN_C()
1231 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1233 if (pEntry
== NULL
) return RT_TYPE_INVALID
;
1235 return (RTTypeClass
)
1236 (pEntry
->readUINT16(OFFSET_TYPE_CLASS
) & ~RT_TYPE_PUBLISHED
);
1239 REG_DLLPUBLIC sal_Bool TYPEREG_CALLTYPE
typereg_reader_isPublished(void * hEntry
) SAL_THROW_EXTERN_C()
1241 TypeRegistryEntry
* entry
= static_cast< TypeRegistryEntry
* >(hEntry
);
1243 && (entry
->readUINT16(OFFSET_TYPE_CLASS
) & RT_TYPE_PUBLISHED
) != 0;
1246 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getTypeName(void * hEntry
, rtl_uString
** pTypeName
)
1247 SAL_THROW_EXTERN_C()
1249 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1253 rtl_uString_new(pTypeName
);
1257 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(OFFSET_THIS_TYPE
));
1259 pTypeName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1260 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1264 static void TYPEREG_CALLTYPE
getSuperTypeName(TypeReaderImpl hEntry
, rtl_uString
** pSuperTypeName
)
1266 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1270 rtl_uString_new(pSuperTypeName
);
1274 if (pEntry
->m_nSuperTypes
== 0)
1276 rtl_uString_new(pSuperTypeName
);
1280 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(pEntry
->m_offset_SUPERTYPES
)); //+ (index * sizeof(sal_uInt16))));
1282 pSuperTypeName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1283 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1286 static void TYPEREG_CALLTYPE
getUik(TypeReaderImpl hEntry
, RTUik
* uik
)
1288 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1292 pEntry
->m_pCP
->readUIK(pEntry
->readUINT16(OFFSET_UIK
), uik
);
1296 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getDocumentation(void * hEntry
, rtl_uString
** pDoku
)
1297 SAL_THROW_EXTERN_C()
1299 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1303 rtl_uString_new(pDoku
);
1307 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(OFFSET_DOKU
));
1309 pDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1310 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1313 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getFileName(void * hEntry
, rtl_uString
** pFileName
)
1314 SAL_THROW_EXTERN_C()
1316 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1320 rtl_uString_new(pFileName
);
1324 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(OFFSET_FILENAME
));
1326 pFileName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1327 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1331 REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE
typereg_reader_getFieldCount(void * hEntry
) SAL_THROW_EXTERN_C()
1333 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1335 if (pEntry
== NULL
) return 0;
1337 return pEntry
->m_pFields
->m_numOfEntries
;
1340 static sal_uInt32 TYPEREG_CALLTYPE
getFieldCount(TypeReaderImpl hEntry
)
1342 return typereg_reader_getFieldCount(hEntry
);
1345 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getFieldName(void * hEntry
, rtl_uString
** pFieldName
, sal_uInt16 index
)
1346 SAL_THROW_EXTERN_C()
1348 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1352 rtl_uString_new(pFieldName
);
1355 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldName(index
);
1357 pFieldName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1358 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1361 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getFieldTypeName(void * hEntry
, rtl_uString
** pFieldType
, sal_uInt16 index
)
1362 SAL_THROW_EXTERN_C()
1364 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1368 rtl_uString_new(pFieldType
);
1372 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldType(index
);
1374 pFieldType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1375 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1378 REG_DLLPUBLIC RTFieldAccess TYPEREG_CALLTYPE
typereg_reader_getFieldFlags(void * hEntry
, sal_uInt16 index
)
1379 SAL_THROW_EXTERN_C()
1381 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1383 if (pEntry
== NULL
) return RT_ACCESS_INVALID
;
1385 return pEntry
->m_pFields
->getFieldAccess(index
);
1388 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()
1393 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1395 if (pEntry
== NULL
) {
1396 *type
= RT_TYPE_NONE
;
1401 *type
= pEntry
->m_pFields
->getFieldConstValue(index
, value
);
1402 } catch (std::bad_alloc
&) {
1408 static RTValueType TYPEREG_CALLTYPE
getFieldConstValue(TypeReaderImpl hEntry
, sal_uInt16 index
, RTConstValueUnion
* value
)
1410 RTValueType t
= RT_TYPE_NONE
;
1411 typereg_reader_getFieldValue(hEntry
, index
, &t
, value
);
1415 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getFieldDocumentation(void * hEntry
, rtl_uString
** pDoku
, sal_uInt16 index
)
1416 SAL_THROW_EXTERN_C()
1418 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1422 rtl_uString_new(pDoku
);
1426 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldDoku(index
);
1428 pDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1429 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1432 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getFieldFileName(void * hEntry
, rtl_uString
** pFieldFileName
, sal_uInt16 index
)
1433 SAL_THROW_EXTERN_C()
1435 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1439 rtl_uString_new(pFieldFileName
);
1443 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldFileName(index
);
1445 pFieldFileName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1446 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1450 REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE
typereg_reader_getMethodCount(void * hEntry
) SAL_THROW_EXTERN_C()
1452 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1454 if (pEntry
== NULL
) return 0;
1456 return pEntry
->m_pMethods
->m_numOfEntries
;
1459 static sal_uInt32 TYPEREG_CALLTYPE
getMethodCount(TypeReaderImpl hEntry
)
1461 return typereg_reader_getMethodCount(hEntry
);
1464 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getMethodName(void * hEntry
, rtl_uString
** pMethodName
, sal_uInt16 index
)
1465 SAL_THROW_EXTERN_C()
1467 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1471 rtl_uString_new(pMethodName
);
1475 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodName(index
);
1477 pMethodName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1478 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1481 REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE
typereg_reader_getMethodParameterCount(
1482 void * hEntry
, sal_uInt16 index
) SAL_THROW_EXTERN_C()
1484 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1486 if (pEntry
== NULL
) return 0;
1488 return pEntry
->m_pMethods
->getMethodParamCount(index
);
1491 static sal_uInt32 TYPEREG_CALLTYPE
getMethodParamCount(TypeReaderImpl hEntry
, sal_uInt16 index
)
1493 return typereg_reader_getMethodParameterCount(hEntry
, index
);
1496 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getMethodParameterTypeName(void * hEntry
, rtl_uString
** pMethodParamType
, sal_uInt16 index
, sal_uInt16 paramIndex
)
1497 SAL_THROW_EXTERN_C()
1499 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1503 rtl_uString_new(pMethodParamType
);
1507 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodParamType(index
, paramIndex
);
1509 pMethodParamType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1510 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1513 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getMethodParameterName(void * hEntry
, rtl_uString
** pMethodParamName
, sal_uInt16 index
, sal_uInt16 paramIndex
)
1514 SAL_THROW_EXTERN_C()
1516 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1520 rtl_uString_new(pMethodParamName
);
1524 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodParamName(index
, paramIndex
);
1526 pMethodParamName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1527 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1530 REG_DLLPUBLIC RTParamMode TYPEREG_CALLTYPE
typereg_reader_getMethodParameterFlags(void * hEntry
, sal_uInt16 index
, sal_uInt16 paramIndex
)
1531 SAL_THROW_EXTERN_C()
1533 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1535 if (pEntry
== NULL
) return RT_PARAM_INVALID
;
1537 return pEntry
->m_pMethods
->getMethodParamMode(index
, paramIndex
);
1540 REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE
typereg_reader_getMethodExceptionCount(
1541 void * hEntry
, sal_uInt16 index
) SAL_THROW_EXTERN_C()
1543 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1545 if (pEntry
== NULL
) return 0;
1547 return pEntry
->m_pMethods
->getMethodExcCount(index
);
1550 static sal_uInt32 TYPEREG_CALLTYPE
getMethodExcCount(TypeReaderImpl hEntry
, sal_uInt16 index
)
1552 return typereg_reader_getMethodExceptionCount(hEntry
, index
);
1555 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getMethodExceptionTypeName(void * hEntry
, rtl_uString
** pMethodExcpType
, sal_uInt16 index
, sal_uInt16 excIndex
)
1556 SAL_THROW_EXTERN_C()
1558 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1562 rtl_uString_new(pMethodExcpType
);
1566 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodExcType(index
, excIndex
);
1568 pMethodExcpType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1569 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1572 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getMethodReturnTypeName(void * hEntry
, rtl_uString
** pMethodReturnType
, sal_uInt16 index
)
1573 SAL_THROW_EXTERN_C()
1575 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1579 rtl_uString_new(pMethodReturnType
);
1583 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodReturnType(index
);
1585 pMethodReturnType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1586 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1589 REG_DLLPUBLIC RTMethodMode TYPEREG_CALLTYPE
typereg_reader_getMethodFlags(void * hEntry
, sal_uInt16 index
)
1590 SAL_THROW_EXTERN_C()
1592 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1594 if (pEntry
== NULL
) return RT_MODE_INVALID
;
1596 return pEntry
->m_pMethods
->getMethodMode(index
);
1599 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getMethodDocumentation(void * hEntry
, rtl_uString
** pMethodDoku
, sal_uInt16 index
)
1600 SAL_THROW_EXTERN_C()
1602 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1606 rtl_uString_new(pMethodDoku
);
1610 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodDoku(index
);
1612 pMethodDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1613 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1616 REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE
typereg_reader_getReferenceCount(void * hEntry
) SAL_THROW_EXTERN_C()
1618 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1620 if (pEntry
== NULL
) return 0;
1622 return pEntry
->m_pReferences
->m_numOfEntries
;
1625 static sal_uInt32 TYPEREG_CALLTYPE
getReferenceCount(TypeReaderImpl hEntry
)
1627 return typereg_reader_getReferenceCount(hEntry
);
1630 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getReferenceTypeName(void * hEntry
, rtl_uString
** pReferenceName
, sal_uInt16 index
)
1631 SAL_THROW_EXTERN_C()
1633 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1637 rtl_uString_new(pReferenceName
);
1641 const sal_Char
* pTmp
= pEntry
->m_pReferences
->getReferenceName(index
);
1643 pReferenceName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1644 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1647 REG_DLLPUBLIC RTReferenceType TYPEREG_CALLTYPE
typereg_reader_getReferenceSort(void * hEntry
, sal_uInt16 index
)
1648 SAL_THROW_EXTERN_C()
1650 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1652 if (pEntry
== NULL
) return RT_REF_INVALID
;
1654 return pEntry
->m_pReferences
->getReferenceType(index
);
1657 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getReferenceDocumentation(void * hEntry
, rtl_uString
** pReferenceDoku
, sal_uInt16 index
)
1658 SAL_THROW_EXTERN_C()
1660 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1664 rtl_uString_new(pReferenceDoku
);
1668 const sal_Char
* pTmp
= pEntry
->m_pReferences
->getReferenceDoku(index
);
1670 pReferenceDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1671 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1674 REG_DLLPUBLIC RTFieldAccess TYPEREG_CALLTYPE
typereg_reader_getReferenceFlags(void * hEntry
, sal_uInt16 index
)
1675 SAL_THROW_EXTERN_C()
1677 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1679 if (pEntry
== NULL
) return RT_ACCESS_INVALID
;
1681 return pEntry
->m_pReferences
->getReferenceAccess(index
);
1684 REG_DLLPUBLIC sal_uInt16 TYPEREG_CALLTYPE
typereg_reader_getSuperTypeCount(void * hEntry
)
1685 SAL_THROW_EXTERN_C()
1687 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1689 if (pEntry
== NULL
) return 0;
1691 return pEntry
->m_nSuperTypes
;
1694 REG_DLLPUBLIC
void TYPEREG_CALLTYPE
typereg_reader_getSuperTypeName(
1695 void * hEntry
, rtl_uString
** pSuperTypeName
, sal_uInt16 index
)
1696 SAL_THROW_EXTERN_C()
1698 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1702 rtl_uString_new(pSuperTypeName
);
1706 OSL_ASSERT(index
< pEntry
->m_nSuperTypes
);
1707 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(pEntry
->m_offset_SUPERTYPES
+ (index
* sizeof(sal_uInt16
))));
1709 pSuperTypeName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1710 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1713 REG_DLLPUBLIC RegistryTypeReader_Api
* TYPEREG_CALLTYPE
initRegistryTypeReader_Api(void)
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};
1718 aApi
.createEntry
= &createEntry
;
1719 aApi
.acquire
= &typereg_reader_acquire
;
1720 aApi
.release
= &typereg_reader_release
;
1721 aApi
.getMinorVersion
= &getMinorVersion
;
1722 aApi
.getMajorVersion
= &getMajorVersion
;
1723 aApi
.getTypeClass
= &typereg_reader_getTypeClass
;
1724 aApi
.getTypeName
= &typereg_reader_getTypeName
;
1725 aApi
.getSuperTypeName
= &getSuperTypeName
;
1726 aApi
.getUik
= &getUik
;
1727 aApi
.getDoku
= &typereg_reader_getDocumentation
;
1728 aApi
.getFileName
= &typereg_reader_getFileName
;
1729 aApi
.getFieldCount
= &getFieldCount
;
1730 aApi
.getFieldName
= &typereg_reader_getFieldName
;
1731 aApi
.getFieldType
= &typereg_reader_getFieldTypeName
;
1732 aApi
.getFieldAccess
= &typereg_reader_getFieldFlags
;
1733 aApi
.getFieldConstValue
= &getFieldConstValue
;
1734 aApi
.getFieldDoku
= &typereg_reader_getFieldDocumentation
;
1735 aApi
.getFieldFileName
= &typereg_reader_getFieldFileName
;
1736 aApi
.getMethodCount
= &getMethodCount
;
1737 aApi
.getMethodName
= &typereg_reader_getMethodName
;
1738 aApi
.getMethodParamCount
= &getMethodParamCount
;
1739 aApi
.getMethodParamType
= &typereg_reader_getMethodParameterTypeName
;
1740 aApi
.getMethodParamName
= &typereg_reader_getMethodParameterName
;
1741 aApi
.getMethodParamMode
= &typereg_reader_getMethodParameterFlags
;
1742 aApi
.getMethodExcCount
= &getMethodExcCount
;
1743 aApi
.getMethodExcType
= &typereg_reader_getMethodExceptionTypeName
;
1744 aApi
.getMethodReturnType
= &typereg_reader_getMethodReturnTypeName
;
1745 aApi
.getMethodMode
= &typereg_reader_getMethodFlags
;
1746 aApi
.getMethodDoku
= &typereg_reader_getMethodDocumentation
;
1747 aApi
.getReferenceCount
= &getReferenceCount
;
1748 aApi
.getReferenceName
= &typereg_reader_getReferenceTypeName
;
1749 aApi
.getReferenceType
= &typereg_reader_getReferenceSort
;
1750 aApi
.getReferenceDoku
= &typereg_reader_getReferenceDocumentation
;
1751 aApi
.getReferenceAccess
= &typereg_reader_getReferenceFlags
;
1763 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */