1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: reflread.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_registry.hxx"
38 #include <sal/types.h>
39 #include <osl/endian.h>
40 #include <registry/reflread.hxx>
42 #include "registry/reader.h"
43 #include "registry/version.h"
45 #include "reflcnst.hxx"
49 static sal_Char NULL_STRING
[1] = { 0 };
50 static sal_Unicode NULL_WSTRING
[1] = { 0 };
52 const sal_uInt32 magic
= 0x12345678;
53 const sal_uInt16 minorVersion
= 0x0000;
54 const sal_uInt16 majorVersion
= 0x0001;
56 #if defined ( GCC ) && ( defined ( SCO ) )
57 ORealDynamicLoader
* ODynamicLoader
<RegistryTypeReader_Api
>::m_pLoader
= NULL
;
60 /**************************************************************************
64 holds any data in a flat memory buffer
66 **************************************************************************/
71 const sal_uInt8
* m_pBuffer
;
72 sal_uInt32 m_bufferLen
;
75 BlopObject(const sal_uInt8
* buffer
, sal_uInt32 len
, sal_Bool copyBuffer
);
76 // throws std::bad_alloc
80 inline sal_uInt8
readBYTE(sal_uInt32 index
) const
82 return m_pBuffer
[index
];
85 inline sal_Int16
readINT16(sal_uInt32 index
) const
87 return ((m_pBuffer
[index
] << 8) | (m_pBuffer
[index
+1] << 0));
90 inline sal_uInt16
readUINT16(sal_uInt32 index
) const
92 return ((m_pBuffer
[index
] << 8) | (m_pBuffer
[index
+1] << 0));
95 inline sal_Int32
readINT32(sal_uInt32 index
) const
98 (m_pBuffer
[index
] << 24) |
99 (m_pBuffer
[index
+1] << 16) |
100 (m_pBuffer
[index
+2] << 8) |
101 (m_pBuffer
[index
+3] << 0)
105 inline sal_uInt32
readUINT32(sal_uInt32 index
) const
108 (m_pBuffer
[index
] << 24) |
109 (m_pBuffer
[index
+1] << 16) |
110 (m_pBuffer
[index
+2] << 8) |
111 (m_pBuffer
[index
+3] << 0)
115 inline sal_Int64
readINT64(sal_uInt32 index
) const
118 ((sal_Int64
)m_pBuffer
[index
] << 56) |
119 ((sal_Int64
)m_pBuffer
[index
+1] << 48) |
120 ((sal_Int64
)m_pBuffer
[index
+2] << 40) |
121 ((sal_Int64
)m_pBuffer
[index
+3] << 32) |
122 ((sal_Int64
)m_pBuffer
[index
+4] << 24) |
123 ((sal_Int64
)m_pBuffer
[index
+5] << 16) |
124 ((sal_Int64
)m_pBuffer
[index
+6] << 8) |
125 ((sal_Int64
)m_pBuffer
[index
+7] << 0)
129 inline sal_uInt64
readUINT64(sal_uInt32 index
) const
132 ((sal_uInt64
)m_pBuffer
[index
] << 56) |
133 ((sal_uInt64
)m_pBuffer
[index
+1] << 48) |
134 ((sal_uInt64
)m_pBuffer
[index
+2] << 40) |
135 ((sal_uInt64
)m_pBuffer
[index
+3] << 32) |
136 ((sal_uInt64
)m_pBuffer
[index
+4] << 24) |
137 ((sal_uInt64
)m_pBuffer
[index
+5] << 16) |
138 ((sal_uInt64
)m_pBuffer
[index
+6] << 8) |
139 ((sal_uInt64
)m_pBuffer
[index
+7] << 0)
144 BlopObject::BlopObject(const sal_uInt8
* buffer
, sal_uInt32 len
, sal_Bool copyBuffer
)
146 , m_isCopied(copyBuffer
)
151 sal_uInt8
* newBuffer
= new sal_uInt8
[len
];
152 memcpy(newBuffer
, buffer
, len
);
153 m_pBuffer
= newBuffer
;
161 BlopObject::~BlopObject()
165 delete[] const_cast<sal_uInt8
*>(m_pBuffer
);
169 /**************************************************************************
173 **************************************************************************/
178 sal_Unicode
** m_stringTable
;
179 sal_uInt16 m_numOfStrings
;
180 sal_uInt16 m_stringsCopied
;
182 StringCache(sal_uInt16 size
); // throws std::bad_alloc
185 const sal_Unicode
* getString(sal_uInt16 index
);
186 sal_uInt16
createString(const sal_uInt8
* buffer
); // throws std::bad_alloc
189 StringCache::StringCache(sal_uInt16 size
)
190 : m_stringTable(NULL
)
191 , m_numOfStrings(size
)
194 m_stringTable
= new sal_Unicode
*[m_numOfStrings
];
196 for (sal_uInt16 i
= 0; i
< m_numOfStrings
; i
++)
198 m_stringTable
[i
] = NULL
;
202 StringCache::~StringCache()
206 for (sal_uInt16 i
= 0; i
< m_stringsCopied
; i
++)
208 delete[] m_stringTable
[i
];
211 delete[] m_stringTable
;
215 const sal_Unicode
* StringCache::getString(sal_uInt16 index
)
217 if ((index
> 0) && (index
<= m_stringsCopied
))
218 return m_stringTable
[index
- 1];
223 sal_uInt16
StringCache::createString(const sal_uInt8
* buffer
)
225 if (m_stringsCopied
< m_numOfStrings
)
227 sal_uInt32 len
= UINT16StringLen(buffer
);
229 m_stringTable
[m_stringsCopied
] = new sal_Unicode
[len
+ 1];
231 readString(buffer
, m_stringTable
[m_stringsCopied
], (len
+ 1) * sizeof(sal_Unicode
));
233 return ++m_stringsCopied
;
239 /**************************************************************************
243 **************************************************************************/
245 class ConstantPool
: public BlopObject
249 sal_uInt16 m_numOfEntries
;
250 sal_Int32
* m_pIndex
; // index values may be < 0 for cached string constants
252 StringCache
* m_pStringCache
;
254 ConstantPool(const sal_uInt8
* buffer
, sal_uInt16 numEntries
)
255 : BlopObject(buffer
, 0, sal_False
)
256 , m_numOfEntries(numEntries
)
258 , m_pStringCache(NULL
)
264 sal_uInt32
parseIndex(); // throws std::bad_alloc
266 CPInfoTag
readTag(sal_uInt16 index
);
268 const sal_Char
* readUTF8NameConstant(sal_uInt16 index
);
269 sal_Bool
readBOOLConstant(sal_uInt16 index
);
270 sal_uInt8
readBYTEConstant(sal_uInt16 index
);
271 sal_Int16
readINT16Constant(sal_uInt16 index
);
272 sal_uInt16
readUINT16Constant(sal_uInt16 index
);
273 sal_Int32
readINT32Constant(sal_uInt16 index
);
274 sal_uInt32
readUINT32Constant(sal_uInt16 index
);
275 sal_Int64
readINT64Constant(sal_uInt16 index
);
276 sal_uInt64
readUINT64Constant(sal_uInt16 index
);
277 float readFloatConstant(sal_uInt16 index
);
278 double readDoubleConstant(sal_uInt16 index
);
279 const sal_Unicode
* readStringConstant(sal_uInt16 index
);
280 // throws std::bad_alloc
281 void readUIK(sal_uInt16 index
, RTUik
* uik
);
284 ConstantPool::~ConstantPool()
287 delete m_pStringCache
;
290 sal_uInt32
ConstantPool::parseIndex()
300 delete m_pStringCache
;
301 m_pStringCache
= NULL
;
304 sal_uInt32 offset
= 0;
305 sal_uInt16 numOfStrings
= 0;
309 m_pIndex
= new sal_Int32
[m_numOfEntries
];
311 for (int i
= 0; i
< m_numOfEntries
; i
++)
313 m_pIndex
[i
] = offset
;
315 offset
+= readUINT32(offset
);
317 if ( ((CPInfoTag
) readUINT16(m_pIndex
[i
] + CP_OFFSET_ENTRY_TAG
)) ==
318 CP_TAG_CONST_STRING
)
328 m_pStringCache
= new StringCache(numOfStrings
);
331 m_bufferLen
= offset
;
336 CPInfoTag
ConstantPool::readTag(sal_uInt16 index
)
338 CPInfoTag tag
= CP_TAG_INVALID
;
340 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
342 tag
= (CPInfoTag
) readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
);
348 const sal_Char
* ConstantPool::readUTF8NameConstant(sal_uInt16 index
)
350 const sal_Char
* aName
= NULL_STRING
;
352 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
354 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_UTF8_NAME
)
356 aName
= (const sal_Char
*) (m_pBuffer
+ m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
363 sal_Bool
ConstantPool::readBOOLConstant(sal_uInt16 index
)
365 sal_Bool aBool
= sal_False
;
367 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
369 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_BOOL
)
371 aBool
= (sal_Bool
) readBYTE(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
378 sal_uInt8
ConstantPool::readBYTEConstant(sal_uInt16 index
)
380 sal_uInt8 aByte
= sal_False
;
382 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
384 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_BYTE
)
386 aByte
= readBYTE(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
393 sal_Int16
ConstantPool::readINT16Constant(sal_uInt16 index
)
395 sal_Int16 aINT16
= sal_False
;
397 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
399 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_INT16
)
401 aINT16
= readINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
408 sal_uInt16
ConstantPool::readUINT16Constant(sal_uInt16 index
)
410 sal_uInt16 asal_uInt16
= sal_False
;
412 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
414 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_UINT16
)
416 asal_uInt16
= readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
423 sal_Int32
ConstantPool::readINT32Constant(sal_uInt16 index
)
425 sal_Int32 aINT32
= sal_False
;
427 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
429 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_INT32
)
431 aINT32
= readINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
438 sal_uInt32
ConstantPool::readUINT32Constant(sal_uInt16 index
)
440 sal_uInt32 aUINT32
= sal_False
;
442 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
444 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_UINT32
)
446 aUINT32
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
453 sal_Int64
ConstantPool::readINT64Constant(sal_uInt16 index
)
455 sal_Int64 aINT64
= sal_False
;
457 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
459 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_INT64
)
461 aINT64
= readINT64(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
468 sal_uInt64
ConstantPool::readUINT64Constant(sal_uInt16 index
)
470 sal_uInt64 aUINT64
= sal_False
;
472 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
474 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_UINT64
)
476 aUINT64
= readUINT64(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
483 float ConstantPool::readFloatConstant(sal_uInt16 index
)
491 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
493 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_FLOAT
)
495 #ifdef REGTYPE_IEEE_NATIVE
496 x
.b
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
506 double ConstantPool::readDoubleConstant(sal_uInt16 index
)
518 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
))
520 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_DOUBLE
)
523 #ifdef REGTYPE_IEEE_NATIVE
524 # ifdef OSL_BIGENDIAN
525 x
.b
.b1
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
526 x
.b
.b2
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
+ sizeof(sal_uInt32
));
528 x
.b
.b1
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
+ sizeof(sal_uInt32
));
529 x
.b
.b2
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
540 const sal_Unicode
* ConstantPool::readStringConstant(sal_uInt16 index
)
542 const sal_Unicode
* aString
= NULL_WSTRING
;
544 if (m_pIndex
&& (index
> 0) && (index
<= m_numOfEntries
) && m_pStringCache
)
546 if (m_pIndex
[index
- 1] >= 0)
548 // create cached string now
550 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_CONST_STRING
)
552 m_pIndex
[index
- 1] = -1 * m_pStringCache
->createString(m_pBuffer
+ m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_DATA
);
556 aString
= m_pStringCache
->getString((sal_uInt16
) (m_pIndex
[index
- 1] * -1));
562 void ConstantPool::readUIK(sal_uInt16 index
, RTUik
* uik
)
572 else if (m_pIndex
&& (index
<= m_numOfEntries
))
574 if (readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_TAG
) == CP_TAG_UIK
)
576 uik
->m_Data1
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK1
);
577 uik
->m_Data2
= readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK2
);
578 uik
->m_Data3
= readUINT16(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK3
);
579 uik
->m_Data4
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK4
);
580 uik
->m_Data5
= readUINT32(m_pIndex
[index
- 1] + CP_OFFSET_ENTRY_UIK5
);
585 /**************************************************************************
589 **************************************************************************/
591 class FieldList
: public BlopObject
595 sal_uInt16 m_numOfEntries
;
596 sal_uInt16 m_numOfFieldEntries
;
597 sal_uInt16 m_FIELD_ENTRY_SIZE
;
600 FieldList(const sal_uInt8
* buffer
, sal_uInt16 numEntries
, ConstantPool
* pCP
)
601 : BlopObject(buffer
, 0, sal_False
)
602 , m_numOfEntries(numEntries
)
605 if ( m_numOfEntries
> 0 )
607 m_numOfFieldEntries
= readUINT16(0);
608 m_FIELD_ENTRY_SIZE
= m_numOfFieldEntries
* sizeof(sal_uInt16
);
611 m_numOfFieldEntries
= 0;
612 m_FIELD_ENTRY_SIZE
= 0;
616 sal_uInt32
parseIndex();
618 const sal_Char
* getFieldName(sal_uInt16 index
);
619 const sal_Char
* getFieldType(sal_uInt16 index
);
620 RTFieldAccess
getFieldAccess(sal_uInt16 index
);
621 RTValueType
getFieldConstValue(sal_uInt16 index
, RTConstValueUnion
* value
);
622 // throws std::bad_alloc
623 const sal_Char
* getFieldDoku(sal_uInt16 index
);
624 const sal_Char
* getFieldFileName(sal_uInt16 index
);
627 sal_uInt32
FieldList::parseIndex()
629 return ((m_numOfEntries
? sizeof(sal_uInt16
) : 0) + (m_numOfEntries
* m_FIELD_ENTRY_SIZE
));
632 const sal_Char
* FieldList::getFieldName(sal_uInt16 index
)
634 const sal_Char
* aName
= NULL
;
636 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
638 aName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_NAME
));
644 const sal_Char
* FieldList::getFieldType(sal_uInt16 index
)
646 const sal_Char
* aName
= NULL
;
648 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
650 aName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_TYPE
));
656 RTFieldAccess
FieldList::getFieldAccess(sal_uInt16 index
)
658 RTFieldAccess aAccess
= RT_ACCESS_INVALID
;
660 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
662 aAccess
= (RTFieldAccess
) readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_ACCESS
);
668 RTValueType
FieldList::getFieldConstValue(sal_uInt16 index
, RTConstValueUnion
* value
)
670 RTValueType ret
= RT_TYPE_NONE
;
672 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
674 sal_uInt16 cpIndex
= readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_VALUE
);
676 switch (m_pCP
->readTag(cpIndex
))
678 case CP_TAG_CONST_BOOL
:
679 value
->aBool
= m_pCP
->readBOOLConstant(cpIndex
);
682 case CP_TAG_CONST_BYTE
:
683 value
->aByte
= m_pCP
->readBYTEConstant(cpIndex
);
686 case CP_TAG_CONST_INT16
:
687 value
->aShort
= m_pCP
->readINT16Constant(cpIndex
);
690 case CP_TAG_CONST_UINT16
:
691 value
->aUShort
= m_pCP
->readUINT16Constant(cpIndex
);
692 ret
= RT_TYPE_UINT16
;
694 case CP_TAG_CONST_INT32
:
695 value
->aLong
= m_pCP
->readINT32Constant(cpIndex
);
698 case CP_TAG_CONST_UINT32
:
699 value
->aULong
= m_pCP
->readUINT32Constant(cpIndex
);
700 ret
= RT_TYPE_UINT32
;
702 case CP_TAG_CONST_INT64
:
703 value
->aHyper
= m_pCP
->readINT64Constant(cpIndex
);
706 case CP_TAG_CONST_UINT64
:
707 value
->aUHyper
= m_pCP
->readUINT64Constant(cpIndex
);
708 ret
= RT_TYPE_UINT64
;
710 case CP_TAG_CONST_FLOAT
:
711 value
->aFloat
= m_pCP
->readFloatConstant(cpIndex
);
714 case CP_TAG_CONST_DOUBLE
:
715 value
->aDouble
= m_pCP
->readDoubleConstant(cpIndex
);
716 ret
= RT_TYPE_DOUBLE
;
718 case CP_TAG_CONST_STRING
:
719 value
->aString
= m_pCP
->readStringConstant(cpIndex
);
720 ret
= RT_TYPE_STRING
;
730 const sal_Char
* FieldList::getFieldDoku(sal_uInt16 index
)
732 const sal_Char
* aDoku
= NULL
;
734 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
736 aDoku
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_DOKU
));
742 const sal_Char
* FieldList::getFieldFileName(sal_uInt16 index
)
744 const sal_Char
* aFileName
= NULL
;
746 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
748 aFileName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_FIELD_ENTRY_SIZE
) + FIELD_OFFSET_FILENAME
));
754 /**************************************************************************
758 **************************************************************************/
760 class ReferenceList
: public BlopObject
764 sal_uInt16 m_numOfEntries
;
765 sal_uInt16 m_numOfReferenceEntries
;
766 sal_uInt16 m_REFERENCE_ENTRY_SIZE
;
769 ReferenceList(const sal_uInt8
* buffer
, sal_uInt16 numEntries
, ConstantPool
* pCP
)
770 : BlopObject(buffer
, 0, sal_False
)
771 , m_numOfEntries(numEntries
)
774 if ( m_numOfEntries
> 0 )
776 m_numOfReferenceEntries
= readUINT16(0);
777 m_REFERENCE_ENTRY_SIZE
= m_numOfReferenceEntries
* sizeof(sal_uInt16
);
780 m_numOfReferenceEntries
= 0;
781 m_REFERENCE_ENTRY_SIZE
= 0;
785 sal_uInt32
parseIndex();
787 const sal_Char
* getReferenceName(sal_uInt16 index
);
788 RTReferenceType
getReferenceType(sal_uInt16 index
);
789 const sal_Char
* getReferenceDoku(sal_uInt16 index
);
790 RTFieldAccess
getReferenceAccess(sal_uInt16 index
);
793 sal_uInt32
ReferenceList::parseIndex()
795 return ((m_numOfEntries
? sizeof(sal_uInt16
) : 0) + (m_numOfEntries
* m_REFERENCE_ENTRY_SIZE
));
798 const sal_Char
* ReferenceList::getReferenceName(sal_uInt16 index
)
800 const sal_Char
* aName
= NULL
;
802 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
804 aName
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_NAME
));
810 RTReferenceType
ReferenceList::getReferenceType(sal_uInt16 index
)
812 RTReferenceType refType
= RT_REF_INVALID
;
814 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
816 refType
= (RTReferenceType
) readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_TYPE
);
822 const sal_Char
* ReferenceList::getReferenceDoku(sal_uInt16 index
)
824 const sal_Char
* aDoku
= NULL
;
826 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
828 aDoku
= m_pCP
->readUTF8NameConstant(readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_DOKU
));
834 RTFieldAccess
ReferenceList::getReferenceAccess(sal_uInt16 index
)
836 RTFieldAccess aAccess
= RT_ACCESS_INVALID
;
838 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
840 aAccess
= (RTFieldAccess
) readUINT16(sizeof(sal_uInt16
) + (index
* m_REFERENCE_ENTRY_SIZE
) + REFERENCE_OFFSET_ACCESS
);
846 /**************************************************************************
850 **************************************************************************/
852 class MethodList
: public BlopObject
856 sal_uInt16 m_numOfEntries
;
857 sal_uInt16 m_numOfMethodEntries
;
858 sal_uInt16 m_numOfParamEntries
;
859 sal_uInt16 m_PARAM_ENTRY_SIZE
;
860 sal_uInt32
* m_pIndex
;
863 MethodList(const sal_uInt8
* buffer
, sal_uInt16 numEntries
, ConstantPool
* pCP
)
864 : BlopObject(buffer
, 0, sal_False
)
865 , m_numOfEntries(numEntries
)
869 if ( m_numOfEntries
> 0 )
871 m_numOfMethodEntries
= readUINT16(0);
872 m_numOfParamEntries
= readUINT16(sizeof(sal_uInt16
));
873 m_PARAM_ENTRY_SIZE
= m_numOfParamEntries
* sizeof(sal_uInt16
);
876 m_numOfMethodEntries
= 0;
877 m_numOfParamEntries
= 0;
878 m_PARAM_ENTRY_SIZE
= 0;
884 sal_uInt32
parseIndex(); // throws std::bad_alloc
886 const sal_Char
* getMethodName(sal_uInt16 index
);
887 sal_uInt16
getMethodParamCount(sal_uInt16 index
);
888 const sal_Char
* getMethodParamType(sal_uInt16 index
, sal_uInt16 paramIndex
);
889 const sal_Char
* getMethodParamName(sal_uInt16 index
, sal_uInt16 paramIndex
);
890 RTParamMode
getMethodParamMode(sal_uInt16 index
, sal_uInt16 paramIndex
);
891 sal_uInt16
getMethodExcCount(sal_uInt16 index
);
892 const sal_Char
* getMethodExcType(sal_uInt16 index
, sal_uInt16 excIndex
);
893 const sal_Char
* getMethodReturnType(sal_uInt16 index
);
894 RTMethodMode
getMethodMode(sal_uInt16 index
);
895 const sal_Char
* getMethodDoku(sal_uInt16 index
);
898 sal_uInt16
calcMethodParamIndex( const sal_uInt16 index
);
901 MethodList::~MethodList()
903 if (m_pIndex
) delete[] m_pIndex
;
906 sal_uInt16
MethodList::calcMethodParamIndex( const sal_uInt16 index
)
908 return (METHOD_OFFSET_PARAM_COUNT
+ sizeof(sal_uInt16
) + (index
* m_PARAM_ENTRY_SIZE
));
911 sal_uInt32
MethodList::parseIndex()
919 sal_uInt32 offset
= 0;
923 offset
= 2 * sizeof(sal_uInt16
);
924 m_pIndex
= new sal_uInt32
[m_numOfEntries
];
926 for (int i
= 0; i
< m_numOfEntries
; i
++)
928 m_pIndex
[i
] = offset
;
930 offset
+= readUINT16(offset
);
937 const sal_Char
* MethodList::getMethodName(sal_uInt16 index
)
939 const sal_Char
* aName
= NULL
;
941 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
943 aName
= m_pCP
->readUTF8NameConstant(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_NAME
));
949 sal_uInt16
MethodList::getMethodParamCount(sal_uInt16 index
)
951 sal_uInt16 aCount
= 0;
953 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
955 aCount
= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
);
961 const sal_Char
* MethodList::getMethodParamType(sal_uInt16 index
, sal_uInt16 paramIndex
)
963 const sal_Char
* aName
= NULL
;
965 if ((m_numOfEntries
> 0) &&
966 (index
<= m_numOfEntries
) &&
967 (paramIndex
<= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)))
969 aName
= m_pCP
->readUTF8NameConstant(
972 calcMethodParamIndex(paramIndex
) +
979 const sal_Char
* MethodList::getMethodParamName(sal_uInt16 index
, sal_uInt16 paramIndex
)
981 const sal_Char
* aName
= NULL
;
983 if ((m_numOfEntries
> 0) &&
984 (index
<= m_numOfEntries
) &&
985 (paramIndex
<= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)))
987 aName
= m_pCP
->readUTF8NameConstant(
990 calcMethodParamIndex(paramIndex
) +
997 RTParamMode
MethodList::getMethodParamMode(sal_uInt16 index
, sal_uInt16 paramIndex
)
999 RTParamMode aMode
= RT_PARAM_INVALID
;
1001 if ((m_numOfEntries
> 0) &&
1002 (index
<= m_numOfEntries
) &&
1003 (paramIndex
<= readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)))
1005 aMode
= (RTParamMode
) readUINT16(
1007 calcMethodParamIndex(paramIndex
) +
1014 sal_uInt16
MethodList::getMethodExcCount(sal_uInt16 index
)
1016 sal_uInt16 aCount
= 0;
1018 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1020 aCount
= readUINT16(m_pIndex
[index
] + calcMethodParamIndex(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
)));
1026 const sal_Char
* MethodList::getMethodExcType(sal_uInt16 index
, sal_uInt16 excIndex
)
1028 const sal_Char
* aName
= NULL
;
1030 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1032 sal_uInt32 excOffset
= m_pIndex
[index
] + calcMethodParamIndex(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_PARAM_COUNT
));
1034 if (excIndex
<= readUINT16(excOffset
))
1036 aName
= m_pCP
->readUTF8NameConstant(
1039 sizeof(sal_uInt16
) +
1040 (excIndex
* sizeof(sal_uInt16
))));
1047 const sal_Char
* MethodList::getMethodReturnType(sal_uInt16 index
)
1049 const sal_Char
* aName
= NULL
;
1051 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1053 aName
= m_pCP
->readUTF8NameConstant(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_RETURN
));
1059 RTMethodMode
MethodList::getMethodMode(sal_uInt16 index
)
1061 RTMethodMode aMode
= RT_MODE_INVALID
;
1063 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1065 aMode
= (RTMethodMode
) readUINT16(m_pIndex
[index
] + METHOD_OFFSET_MODE
);
1071 const sal_Char
* MethodList::getMethodDoku(sal_uInt16 index
)
1073 const sal_Char
* aDoku
= NULL
;
1075 if ((m_numOfEntries
> 0) && (index
<= m_numOfEntries
))
1077 aDoku
= m_pCP
->readUTF8NameConstant(readUINT16(m_pIndex
[index
] + METHOD_OFFSET_DOKU
));
1083 /**************************************************************************
1085 class TypeRegistryEntry
1087 **************************************************************************/
1089 class TypeRegistryEntry
: public BlopObject
{
1091 ConstantPool
* m_pCP
;
1092 FieldList
* m_pFields
;
1093 MethodList
* m_pMethods
;
1094 ReferenceList
* m_pReferences
;
1095 sal_uInt32 m_refCount
;
1096 sal_uInt16 m_nSuperTypes
;
1097 sal_uInt16 m_offset_SUPERTYPES
;
1100 const sal_uInt8
* buffer
, sal_uInt32 len
, sal_Bool copyBuffer
);
1101 // throws std::bad_alloc
1103 ~TypeRegistryEntry();
1105 typereg_Version
getVersion() const;
1108 TypeRegistryEntry::TypeRegistryEntry(
1109 const sal_uInt8
* buffer
, sal_uInt32 len
, sal_Bool copyBuffer
):
1110 BlopObject(buffer
, len
, copyBuffer
), m_pCP(NULL
), m_pFields(NULL
),
1111 m_pMethods(NULL
), m_pReferences(NULL
), m_refCount(1), m_nSuperTypes(0),
1112 m_offset_SUPERTYPES(0)
1114 std::size_t const entrySize
= sizeof(sal_uInt16
);
1115 sal_uInt16 nHeaderEntries
= readUINT16(OFFSET_N_ENTRIES
);
1116 sal_uInt16 offset_N_SUPERTYPES
= OFFSET_N_ENTRIES
+ entrySize
+ (nHeaderEntries
* entrySize
);
1117 m_offset_SUPERTYPES
= offset_N_SUPERTYPES
+ entrySize
;
1118 m_nSuperTypes
= readUINT16(offset_N_SUPERTYPES
);
1120 sal_uInt16 offset_CP_SIZE
= m_offset_SUPERTYPES
+ (m_nSuperTypes
* entrySize
);
1121 sal_uInt16 offset_CP
= offset_CP_SIZE
+ entrySize
;
1123 m_pCP
= new ConstantPool(m_pBuffer
+ offset_CP
, readUINT16(offset_CP_SIZE
));
1125 sal_uInt32 offset
= offset_CP
+ m_pCP
->parseIndex();
1127 m_pFields
= new FieldList(
1128 m_pBuffer
+ offset
+ entrySize
, readUINT16(offset
), m_pCP
);
1130 offset
+= sizeof(sal_uInt16
) + m_pFields
->parseIndex();
1132 m_pMethods
= new MethodList(
1133 m_pBuffer
+ offset
+ entrySize
, readUINT16(offset
), m_pCP
);
1135 offset
+= sizeof(sal_uInt16
) + m_pMethods
->parseIndex();
1137 m_pReferences
= new ReferenceList(
1138 m_pBuffer
+ offset
+ entrySize
, readUINT16(offset
), m_pCP
);
1140 m_pReferences
->parseIndex();
1143 TypeRegistryEntry::~TypeRegistryEntry()
1148 delete m_pReferences
;
1151 typereg_Version
TypeRegistryEntry::getVersion() const {
1152 // Assumes two's complement arithmetic with modulo-semantics:
1153 return static_cast< typereg_Version
>(readUINT32(OFFSET_MAGIC
) - magic
);
1156 /**************************************************************************
1160 **************************************************************************/
1164 sal_Bool
typereg_reader_create(
1165 void const * buffer
, sal_uInt32 length
, sal_Bool copy
,
1166 typereg_Version maxVersion
, void ** result
)
1167 SAL_THROW_EXTERN_C()
1169 if (length
< OFFSET_CP
|| length
> SAL_MAX_UINT32
) {
1173 std::auto_ptr
< TypeRegistryEntry
> entry
;
1176 new TypeRegistryEntry(
1177 static_cast< sal_uInt8
const * >(buffer
),
1178 static_cast< sal_uInt32
>(length
), copy
));
1179 } catch (std::bad_alloc
&) {
1182 if (entry
->readUINT32(OFFSET_SIZE
) != length
) {
1186 typereg_Version version
= entry
->getVersion();
1187 if (version
< TYPEREG_VERSION_0
|| version
> maxVersion
) {
1191 *result
= entry
.release();
1195 static TypeReaderImpl TYPEREG_CALLTYPE
createEntry(const sal_uInt8
* buffer
, sal_uInt32 len
, sal_Bool copyBuffer
)
1198 typereg_reader_create(buffer
, len
, copyBuffer
, TYPEREG_VERSION_0
, &handle
);
1202 void typereg_reader_acquire(void * hEntry
) SAL_THROW_EXTERN_C()
1204 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1207 pEntry
->m_refCount
++;
1210 void typereg_reader_release(void * hEntry
) SAL_THROW_EXTERN_C()
1212 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1216 if (--pEntry
->m_refCount
== 0)
1221 typereg_Version
typereg_reader_getVersion(void * handle
) SAL_THROW_EXTERN_C() {
1224 : static_cast< TypeRegistryEntry
* >(handle
)->getVersion();
1227 static sal_uInt16 TYPEREG_CALLTYPE
getMinorVersion(TypeReaderImpl hEntry
)
1229 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1231 if (pEntry
== NULL
) return 0;
1233 return pEntry
->readUINT16(OFFSET_MINOR_VERSION
);
1236 static sal_uInt16 TYPEREG_CALLTYPE
getMajorVersion(TypeReaderImpl hEntry
)
1238 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1240 if (pEntry
== NULL
) return 0;
1242 return pEntry
->readUINT16(OFFSET_MAJOR_VERSION
);
1245 RTTypeClass
typereg_reader_getTypeClass(void * hEntry
) SAL_THROW_EXTERN_C()
1247 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1249 if (pEntry
== NULL
) return RT_TYPE_INVALID
;
1251 return (RTTypeClass
)
1252 (pEntry
->readUINT16(OFFSET_TYPE_CLASS
) & ~RT_TYPE_PUBLISHED
);
1255 sal_Bool
typereg_reader_isPublished(void * hEntry
) SAL_THROW_EXTERN_C()
1257 TypeRegistryEntry
* entry
= static_cast< TypeRegistryEntry
* >(hEntry
);
1259 && (entry
->readUINT16(OFFSET_TYPE_CLASS
) & RT_TYPE_PUBLISHED
) != 0;
1262 void typereg_reader_getTypeName(void * hEntry
, rtl_uString
** pTypeName
)
1263 SAL_THROW_EXTERN_C()
1265 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1269 rtl_uString_new(pTypeName
);
1273 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(OFFSET_THIS_TYPE
));
1275 pTypeName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1276 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1280 static void TYPEREG_CALLTYPE
getSuperTypeName(TypeReaderImpl hEntry
, rtl_uString
** pSuperTypeName
)
1282 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1286 rtl_uString_new(pSuperTypeName
);
1290 if (pEntry
->m_nSuperTypes
== 0)
1292 rtl_uString_new(pSuperTypeName
);
1296 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(pEntry
->m_offset_SUPERTYPES
)); //+ (index * sizeof(sal_uInt16))));
1298 pSuperTypeName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1299 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1302 static void TYPEREG_CALLTYPE
getUik(TypeReaderImpl hEntry
, RTUik
* uik
)
1304 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1308 pEntry
->m_pCP
->readUIK(pEntry
->readUINT16(OFFSET_UIK
), uik
);
1312 void typereg_reader_getDocumentation(void * hEntry
, rtl_uString
** pDoku
)
1313 SAL_THROW_EXTERN_C()
1315 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1319 rtl_uString_new(pDoku
);
1323 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(OFFSET_DOKU
));
1325 pDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1326 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1329 void typereg_reader_getFileName(void * hEntry
, rtl_uString
** pFileName
)
1330 SAL_THROW_EXTERN_C()
1332 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1336 rtl_uString_new(pFileName
);
1340 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(OFFSET_FILENAME
));
1342 pFileName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1343 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1347 sal_uInt16
typereg_reader_getFieldCount(void * hEntry
) SAL_THROW_EXTERN_C()
1349 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1351 if (pEntry
== NULL
) return 0;
1353 return pEntry
->m_pFields
->m_numOfEntries
;
1356 static sal_uInt32 TYPEREG_CALLTYPE
getFieldCount(TypeReaderImpl hEntry
)
1358 return typereg_reader_getFieldCount(hEntry
);
1361 void typereg_reader_getFieldName(void * hEntry
, rtl_uString
** pFieldName
, sal_uInt16 index
)
1362 SAL_THROW_EXTERN_C()
1364 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1368 rtl_uString_new(pFieldName
);
1371 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldName(index
);
1373 pFieldName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1374 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1377 void typereg_reader_getFieldTypeName(void * hEntry
, rtl_uString
** pFieldType
, sal_uInt16 index
)
1378 SAL_THROW_EXTERN_C()
1380 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1384 rtl_uString_new(pFieldType
);
1388 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldType(index
);
1390 pFieldType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1391 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1394 RTFieldAccess
typereg_reader_getFieldFlags(void * hEntry
, sal_uInt16 index
)
1395 SAL_THROW_EXTERN_C()
1397 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1399 if (pEntry
== NULL
) return RT_ACCESS_INVALID
;
1401 return pEntry
->m_pFields
->getFieldAccess(index
);
1404 sal_Bool
typereg_reader_getFieldValue(
1405 void * hEntry
, sal_uInt16 index
, RTValueType
* type
,
1406 RTConstValueUnion
* value
)
1407 SAL_THROW_EXTERN_C()
1409 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1411 if (pEntry
== NULL
) {
1412 *type
= RT_TYPE_NONE
;
1417 *type
= pEntry
->m_pFields
->getFieldConstValue(index
, value
);
1418 } catch (std::bad_alloc
&) {
1424 static RTValueType TYPEREG_CALLTYPE
getFieldConstValue(TypeReaderImpl hEntry
, sal_uInt16 index
, RTConstValueUnion
* value
)
1426 RTValueType t
= RT_TYPE_NONE
;
1427 typereg_reader_getFieldValue(hEntry
, index
, &t
, value
);
1431 void typereg_reader_getFieldDocumentation(void * hEntry
, rtl_uString
** pDoku
, sal_uInt16 index
)
1432 SAL_THROW_EXTERN_C()
1434 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1438 rtl_uString_new(pDoku
);
1442 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldDoku(index
);
1444 pDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1445 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1448 void typereg_reader_getFieldFileName(void * hEntry
, rtl_uString
** pFieldFileName
, sal_uInt16 index
)
1449 SAL_THROW_EXTERN_C()
1451 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1455 rtl_uString_new(pFieldFileName
);
1459 const sal_Char
* pTmp
= pEntry
->m_pFields
->getFieldFileName(index
);
1461 pFieldFileName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1462 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1466 sal_uInt16
typereg_reader_getMethodCount(void * hEntry
) SAL_THROW_EXTERN_C()
1468 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1470 if (pEntry
== NULL
) return 0;
1472 return pEntry
->m_pMethods
->m_numOfEntries
;
1475 static sal_uInt32 TYPEREG_CALLTYPE
getMethodCount(TypeReaderImpl hEntry
)
1477 return typereg_reader_getMethodCount(hEntry
);
1480 void typereg_reader_getMethodName(void * hEntry
, rtl_uString
** pMethodName
, sal_uInt16 index
)
1481 SAL_THROW_EXTERN_C()
1483 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1487 rtl_uString_new(pMethodName
);
1491 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodName(index
);
1493 pMethodName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1494 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1497 sal_uInt16
typereg_reader_getMethodParameterCount(
1498 void * hEntry
, sal_uInt16 index
) SAL_THROW_EXTERN_C()
1500 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1502 if (pEntry
== NULL
) return 0;
1504 return pEntry
->m_pMethods
->getMethodParamCount(index
);
1507 static sal_uInt32 TYPEREG_CALLTYPE
getMethodParamCount(TypeReaderImpl hEntry
, sal_uInt16 index
)
1509 return typereg_reader_getMethodParameterCount(hEntry
, index
);
1512 void typereg_reader_getMethodParameterTypeName(void * hEntry
, rtl_uString
** pMethodParamType
, sal_uInt16 index
, sal_uInt16 paramIndex
)
1513 SAL_THROW_EXTERN_C()
1515 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1519 rtl_uString_new(pMethodParamType
);
1523 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodParamType(index
, paramIndex
);
1525 pMethodParamType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1526 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1529 void typereg_reader_getMethodParameterName(void * hEntry
, rtl_uString
** pMethodParamName
, sal_uInt16 index
, sal_uInt16 paramIndex
)
1530 SAL_THROW_EXTERN_C()
1532 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1536 rtl_uString_new(pMethodParamName
);
1540 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodParamName(index
, paramIndex
);
1542 pMethodParamName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1543 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1546 RTParamMode
typereg_reader_getMethodParameterFlags(void * hEntry
, sal_uInt16 index
, sal_uInt16 paramIndex
)
1547 SAL_THROW_EXTERN_C()
1549 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1551 if (pEntry
== NULL
) return RT_PARAM_INVALID
;
1553 return pEntry
->m_pMethods
->getMethodParamMode(index
, paramIndex
);
1556 sal_uInt16
typereg_reader_getMethodExceptionCount(
1557 void * hEntry
, sal_uInt16 index
) SAL_THROW_EXTERN_C()
1559 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1561 if (pEntry
== NULL
) return 0;
1563 return pEntry
->m_pMethods
->getMethodExcCount(index
);
1566 static sal_uInt32 TYPEREG_CALLTYPE
getMethodExcCount(TypeReaderImpl hEntry
, sal_uInt16 index
)
1568 return typereg_reader_getMethodExceptionCount(hEntry
, index
);
1571 void typereg_reader_getMethodExceptionTypeName(void * hEntry
, rtl_uString
** pMethodExcpType
, sal_uInt16 index
, sal_uInt16 excIndex
)
1572 SAL_THROW_EXTERN_C()
1574 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1578 rtl_uString_new(pMethodExcpType
);
1582 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodExcType(index
, excIndex
);
1584 pMethodExcpType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1585 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1588 void typereg_reader_getMethodReturnTypeName(void * hEntry
, rtl_uString
** pMethodReturnType
, sal_uInt16 index
)
1589 SAL_THROW_EXTERN_C()
1591 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1595 rtl_uString_new(pMethodReturnType
);
1599 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodReturnType(index
);
1601 pMethodReturnType
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1602 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1605 RTMethodMode
typereg_reader_getMethodFlags(void * hEntry
, sal_uInt16 index
)
1606 SAL_THROW_EXTERN_C()
1608 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1610 if (pEntry
== NULL
) return RT_MODE_INVALID
;
1612 return pEntry
->m_pMethods
->getMethodMode(index
);
1615 void typereg_reader_getMethodDocumentation(void * hEntry
, rtl_uString
** pMethodDoku
, sal_uInt16 index
)
1616 SAL_THROW_EXTERN_C()
1618 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1622 rtl_uString_new(pMethodDoku
);
1626 const sal_Char
* pTmp
= pEntry
->m_pMethods
->getMethodDoku(index
);
1628 pMethodDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1629 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1632 sal_uInt16
typereg_reader_getReferenceCount(void * hEntry
) SAL_THROW_EXTERN_C()
1634 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1636 if (pEntry
== NULL
) return 0;
1638 return pEntry
->m_pReferences
->m_numOfEntries
;
1641 static sal_uInt32 TYPEREG_CALLTYPE
getReferenceCount(TypeReaderImpl hEntry
)
1643 return typereg_reader_getReferenceCount(hEntry
);
1646 void typereg_reader_getReferenceTypeName(void * hEntry
, rtl_uString
** pReferenceName
, sal_uInt16 index
)
1647 SAL_THROW_EXTERN_C()
1649 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1653 rtl_uString_new(pReferenceName
);
1657 const sal_Char
* pTmp
= pEntry
->m_pReferences
->getReferenceName(index
);
1659 pReferenceName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1660 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1663 RTReferenceType
typereg_reader_getReferenceSort(void * hEntry
, sal_uInt16 index
)
1664 SAL_THROW_EXTERN_C()
1666 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1668 if (pEntry
== NULL
) return RT_REF_INVALID
;
1670 return pEntry
->m_pReferences
->getReferenceType(index
);
1673 void typereg_reader_getReferenceDocumentation(void * hEntry
, rtl_uString
** pReferenceDoku
, sal_uInt16 index
)
1674 SAL_THROW_EXTERN_C()
1676 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1680 rtl_uString_new(pReferenceDoku
);
1684 const sal_Char
* pTmp
= pEntry
->m_pReferences
->getReferenceDoku(index
);
1686 pReferenceDoku
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1687 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1690 RTFieldAccess
typereg_reader_getReferenceFlags(void * hEntry
, sal_uInt16 index
)
1691 SAL_THROW_EXTERN_C()
1693 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1695 if (pEntry
== NULL
) return RT_ACCESS_INVALID
;
1697 return pEntry
->m_pReferences
->getReferenceAccess(index
);
1700 sal_uInt16
typereg_reader_getSuperTypeCount(void * hEntry
)
1701 SAL_THROW_EXTERN_C()
1703 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1705 if (pEntry
== NULL
) return 0;
1707 return pEntry
->m_nSuperTypes
;
1710 void typereg_reader_getSuperTypeName(
1711 void * hEntry
, rtl_uString
** pSuperTypeName
, sal_uInt16 index
)
1712 SAL_THROW_EXTERN_C()
1714 TypeRegistryEntry
* pEntry
= (TypeRegistryEntry
*) hEntry
;
1718 rtl_uString_new(pSuperTypeName
);
1722 OSL_ASSERT(index
< pEntry
->m_nSuperTypes
);
1723 const sal_Char
* pTmp
= pEntry
->m_pCP
->readUTF8NameConstant(pEntry
->readUINT16(pEntry
->m_offset_SUPERTYPES
+ (index
* sizeof(sal_uInt16
))));
1725 pSuperTypeName
, pTmp
, pTmp
== 0 ? 0 : rtl_str_getLength(pTmp
),
1726 RTL_TEXTENCODING_UTF8
, OSTRING_TO_OUSTRING_CVTFLAGS
);
1729 RegistryTypeReader_Api
* TYPEREG_CALLTYPE
initRegistryTypeReader_Api(void)
1731 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};
1734 aApi
.createEntry
= &createEntry
;
1735 aApi
.acquire
= &typereg_reader_acquire
;
1736 aApi
.release
= &typereg_reader_release
;
1737 aApi
.getMinorVersion
= &getMinorVersion
;
1738 aApi
.getMajorVersion
= &getMajorVersion
;
1739 aApi
.getTypeClass
= &typereg_reader_getTypeClass
;
1740 aApi
.getTypeName
= &typereg_reader_getTypeName
;
1741 aApi
.getSuperTypeName
= &getSuperTypeName
;
1742 aApi
.getUik
= &getUik
;
1743 aApi
.getDoku
= &typereg_reader_getDocumentation
;
1744 aApi
.getFileName
= &typereg_reader_getFileName
;
1745 aApi
.getFieldCount
= &getFieldCount
;
1746 aApi
.getFieldName
= &typereg_reader_getFieldName
;
1747 aApi
.getFieldType
= &typereg_reader_getFieldTypeName
;
1748 aApi
.getFieldAccess
= &typereg_reader_getFieldFlags
;
1749 aApi
.getFieldConstValue
= &getFieldConstValue
;
1750 aApi
.getFieldDoku
= &typereg_reader_getFieldDocumentation
;
1751 aApi
.getFieldFileName
= &typereg_reader_getFieldFileName
;
1752 aApi
.getMethodCount
= &getMethodCount
;
1753 aApi
.getMethodName
= &typereg_reader_getMethodName
;
1754 aApi
.getMethodParamCount
= &getMethodParamCount
;
1755 aApi
.getMethodParamType
= &typereg_reader_getMethodParameterTypeName
;
1756 aApi
.getMethodParamName
= &typereg_reader_getMethodParameterName
;
1757 aApi
.getMethodParamMode
= &typereg_reader_getMethodParameterFlags
;
1758 aApi
.getMethodExcCount
= &getMethodExcCount
;
1759 aApi
.getMethodExcType
= &typereg_reader_getMethodExceptionTypeName
;
1760 aApi
.getMethodReturnType
= &typereg_reader_getMethodReturnTypeName
;
1761 aApi
.getMethodMode
= &typereg_reader_getMethodFlags
;
1762 aApi
.getMethodDoku
= &typereg_reader_getMethodDocumentation
;
1763 aApi
.getReferenceCount
= &getReferenceCount
;
1764 aApi
.getReferenceName
= &typereg_reader_getReferenceTypeName
;
1765 aApi
.getReferenceType
= &typereg_reader_getReferenceSort
;
1766 aApi
.getReferenceDoku
= &typereg_reader_getReferenceDocumentation
;
1767 aApi
.getReferenceAccess
= &typereg_reader_getReferenceFlags
;