22 #include <rtl/ustrbuf.hxx>
23 #include <typelib/typedescription.h>
24 #include <com/sun/star/lang/XServiceInfo.hpp>
32 OUStringBuffer & buf, typelib_TypeDescriptionReference * typeRef )
34 buf.append(
"<cannot get type description of type " );
35 buf.append( OUString::unacquired( &typeRef->pTypeName ) );
39 void appendChar( OUStringBuffer & buf,
sal_Unicode c )
41 if (c < ' ' || c >
'~') {
44 OUString::number( static_cast< sal_Int32 >(c), 16 ) );
45 for ( sal_Int32 f = 4 - s.getLength();
f > 0; --
f )
55 void appendValue( OUStringBuffer & buf,
56 void const * val, typelib_TypeDescriptionReference * typeRef,
59 if (typeRef->eTypeClass == typelib_TypeClass_VOID) {
66 typeRef->eTypeClass != typelib_TypeClass_STRING &&
67 typeRef->eTypeClass != typelib_TypeClass_CHAR &&
68 typeRef->eTypeClass != typelib_TypeClass_BOOLEAN)
71 buf.append( OUString::unacquired( &typeRef->pTypeName ) );
75 switch (typeRef->eTypeClass) {
76 case typelib_TypeClass_INTERFACE: {
78 buf.append( reinterpret_cast< sal_Int64 >(
79 *static_cast< void * const * >(val) ), 16 );
80 uno::Reference< lang::XServiceInfo > xServiceInfo(
81 *static_cast< uno::XInterface * const * >(val),
83 if (xServiceInfo.is()) {
84 buf.append(
" (ImplementationName = \"" );
85 buf.append( xServiceInfo->getImplementationName() );
90 case typelib_TypeClass_STRUCT:
91 case typelib_TypeClass_EXCEPTION: {
96 appendTypeError( buf, typeRef );
99 typelib_CompoundTypeDescription * compType =
100 reinterpret_cast< typelib_CompoundTypeDescription *
>(
102 sal_Int32 nDescr = compType->nMembers;
104 if (compType->pBaseTypeDescription) {
106 buf, val,
reinterpret_cast<
108 compType->pBaseTypeDescription)->pWeakRef,
false );
113 typelib_TypeDescriptionReference ** ppTypeRefs =
114 compType->ppTypeRefs;
115 sal_Int32 * memberOffsets = compType->pMemberOffsets;
116 rtl_uString ** ppMemberNames = compType->ppMemberNames;
118 for ( sal_Int32 nPos = 0;
nPos < nDescr; ++
nPos )
120 buf.append( ppMemberNames[ nPos ] );
123 TYPELIB_DANGER_GET( &memberType, ppTypeRefs[ nPos ] );
124 if (memberType ==
nullptr) {
125 appendTypeError( buf, ppTypeRefs[ nPos ] );
129 static_cast< char const * >(
130 val ) + memberOffsets[ nPos ],
131 memberType->pWeakRef,
true );
132 TYPELIB_DANGER_RELEASE( memberType );
134 if (nPos < (nDescr - 1))
139 if (typeDescr !=
nullptr)
143 case typelib_TypeClass_SEQUENCE: {
145 TYPELIB_DANGER_GET( &typeDescr, typeRef );
146 if (typeDescr ==
nullptr) {
147 appendTypeError( buf,typeRef );
150 typelib_TypeDescriptionReference * elementTypeRef =
152 typelib_IndirectTypeDescription *
>(typeDescr)->pType;
154 TYPELIB_DANGER_GET( &elementTypeDescr, elementTypeRef );
155 if (elementTypeDescr ==
nullptr)
157 appendTypeError( buf, elementTypeRef );
161 sal_Int32 nElementSize = elementTypeDescr->nSize;
163 *
static_cast< uno_Sequence *
const *
>(val);
169 char const * pElements = seq->elements;
170 for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos )
173 buf, pElements + (nElementSize * nPos),
174 elementTypeDescr->pWeakRef,
false );
175 if (nPos < (nElements - 1))
184 TYPELIB_DANGER_RELEASE( elementTypeDescr );
186 TYPELIB_DANGER_RELEASE( typeDescr );
190 case typelib_TypeClass_ANY: {
193 appendValue( buf, pAny->pData, pAny->pType,
true );
197 case typelib_TypeClass_TYPE:
198 buf.append( (*
static_cast<
199 typelib_TypeDescriptionReference *
const *
>(val)
202 case typelib_TypeClass_STRING: {
204 OUString
const & str = OUString::unacquired(
205 static_cast< rtl_uString * const * >(val) );
206 sal_Int32 len = str.getLength();
207 for ( sal_Int32 pos = 0;
pos < len; ++
pos )
211 buf.append(
"\\\"" );
213 buf.append(
"\\\\" );
215 appendChar( buf, c );
220 case typelib_TypeClass_ENUM: {
224 appendTypeError( buf, typeRef );
229 reinterpret_cast< typelib_EnumTypeDescription *
>(
230 typeDescr )->pEnumValues;
231 sal_Int32 nPos =
reinterpret_cast< typelib_EnumTypeDescription *
>(
232 typeDescr )->nEnumValues;
235 if (pValues[ nPos ] == *static_cast< int const * >(val))
240 buf.append( reinterpret_cast< typelib_EnumTypeDescription * >(
241 typeDescr )->ppEnumNames[ nPos ] );
245 buf.append(
"?unknown enum value?" );
248 if (typeDescr !=
nullptr)
252 case typelib_TypeClass_BOOLEAN:
253 if (*static_cast< sal_Bool const * >(val))
254 buf.append(
"true" );
256 buf.append(
"false" );
258 case typelib_TypeClass_CHAR: {
262 buf.append(
"\\\'" );
264 buf.append(
"\\\\" );
266 appendChar( buf, c );
270 case typelib_TypeClass_FLOAT:
271 buf.append( *static_cast< float const * >(val) );
273 case typelib_TypeClass_DOUBLE:
274 buf.append( *static_cast< double const * >(val) );
276 case typelib_TypeClass_BYTE:
277 buf.append( static_cast< sal_Int32 >(
278 *static_cast< sal_Int8 const * >(val) ) );
280 case typelib_TypeClass_SHORT:
281 buf.append( static_cast< sal_Int32 >(
282 *static_cast< sal_Int16 const * >(val) ) );
284 case typelib_TypeClass_UNSIGNED_SHORT:
285 buf.append( static_cast< sal_Int32 >(
286 *static_cast< sal_uInt16 const * >(val) ) );
288 case typelib_TypeClass_LONG:
289 buf.append( *static_cast< sal_Int32 const * >(val) );
291 case typelib_TypeClass_UNSIGNED_LONG:
292 buf.append( static_cast< sal_Int64 >(
293 *static_cast< sal_uInt32 const * >(val) ) );
295 case typelib_TypeClass_HYPER:
296 case typelib_TypeClass_UNSIGNED_HYPER:
297 buf.append( *static_cast< sal_Int64 const * >(val) );
314 appendValue( buf, value.getValue(), value.getValueTypeRef(), true );
315 return buf.makeStringAndClear();
void SAL_CALL typelib_typedescriptionreference_getDescription(typelib_TypeDescription **ppRet, typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
sal_Bool SAL_CALL typelib_typedescription_complete(typelib_TypeDescription **ppTypeDescr) SAL_THROW_EXTERN_C()
struct _typelib_TypeDescription typelib_TypeDescription
void SAL_CALL typelib_typedescription_release(typelib_TypeDescription *pTD) SAL_THROW_EXTERN_C()
const PropertyValue * pValues
void(* f)(TrueTypeTable *)
OUString anyToString(uno::Any const &value)