Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include <rtl/alloc.h>
21 : : #include <registry/reflwrit.hxx>
22 : : #include <cppuhelper/servicefactory.hxx>
23 : : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
24 : : #include <com/sun/star/reflection/XInterfaceTypeDescription.hpp>
25 : : #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
26 : : #include <com/sun/star/reflection/XConstantTypeDescription.hpp>
27 : : #include <com/sun/star/reflection/XModuleTypeDescription.hpp>
28 : : #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp>
29 : : #include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp>
30 : : #include <com/sun/star/reflection/XMethodParameter.hpp>
31 : : #include <com/sun/star/reflection/XCompoundTypeDescription.hpp>
32 : : #include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
33 : : #include <com/sun/star/reflection/XEnumTypeDescription.hpp>
34 : : #include <com/sun/star/beans/XPropertySet.hpp>
35 : : #include <com/sun/star/uno/XComponentContext.hpp>
36 : : #include <codemaker/global.hxx>
37 : :
38 : : using namespace com::sun::star;
39 : : using namespace com::sun::star::uno;
40 : : using namespace com::sun::star::reflection;
41 : : using namespace com::sun::star::lang;
42 : : using namespace com::sun::star::container;
43 : : using namespace cppu;
44 : :
45 : : using ::rtl::OUString;
46 : :
47 : 1 : static Reference< XHierarchicalNameAccess > xNameAccess;
48 : :
49 : 0 : void writeConstantData( RegistryTypeWriter& rWriter, sal_uInt16 fieldIndex,
50 : : const Reference< XConstantTypeDescription >& xConstant)
51 : :
52 : : {
53 : 0 : RTConstValue constValue;
54 : 0 : OUString uConstTypeName;
55 [ # # ][ # # ]: 0 : OUString uConstName = xConstant->getName();
56 [ # # ][ # # ]: 0 : Any aConstantAny = xConstant->getConstantValue();
57 : :
58 [ # # # # : 0 : switch ( aConstantAny.getValueTypeClass() )
# # # # #
# ]
59 : : {
60 : : case TypeClass_BOOLEAN:
61 : : {
62 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("boolean") );
63 : 0 : constValue.m_type = RT_TYPE_BOOL;
64 : 0 : aConstantAny >>= constValue.m_value.aBool;
65 : : }
66 : 0 : break;
67 : : case TypeClass_BYTE:
68 : : {
69 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("byte") );
70 : 0 : constValue.m_type = RT_TYPE_BYTE;
71 : 0 : aConstantAny >>= constValue.m_value.aByte;
72 : : }
73 : 0 : break;
74 : : case TypeClass_SHORT:
75 : : {
76 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("short") );
77 : 0 : constValue.m_type = RT_TYPE_INT16;
78 : 0 : aConstantAny >>= constValue.m_value.aShort;
79 : : }
80 : 0 : break;
81 : : case TypeClass_UNSIGNED_SHORT:
82 : : {
83 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned short") );
84 : 0 : constValue.m_type = RT_TYPE_UINT16;
85 : 0 : aConstantAny >>= constValue.m_value.aUShort;
86 : : }
87 : 0 : break;
88 : : case TypeClass_LONG:
89 : : {
90 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("long") );
91 : 0 : constValue.m_type = RT_TYPE_INT32;
92 : 0 : aConstantAny >>= constValue.m_value.aLong;
93 : : }
94 : 0 : break;
95 : : case TypeClass_UNSIGNED_LONG:
96 : : {
97 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("unsigned long") );
98 : 0 : constValue.m_type = RT_TYPE_UINT32;
99 : 0 : aConstantAny >>= constValue.m_value.aULong;
100 : : }
101 : 0 : break;
102 : : case TypeClass_FLOAT:
103 : : {
104 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("float") );
105 : 0 : constValue.m_type = RT_TYPE_FLOAT;
106 : 0 : aConstantAny >>= constValue.m_value.aFloat;
107 : : }
108 : 0 : break;
109 : : case TypeClass_DOUBLE:
110 : : {
111 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("double") );
112 : 0 : constValue.m_type = RT_TYPE_DOUBLE;
113 : 0 : aConstantAny >>= constValue.m_value.aDouble;
114 : : }
115 : 0 : break;
116 : : case TypeClass_STRING:
117 : : {
118 [ # # ]: 0 : uConstTypeName = OUString( RTL_CONSTASCII_USTRINGPARAM("string") );
119 : 0 : constValue.m_type = RT_TYPE_STRING;
120 : 0 : constValue.m_value.aString = ((OUString*)aConstantAny.getValue())->getStr();
121 : : }
122 : 0 : break;
123 : : default:
124 : : OSL_ASSERT(false);
125 : 0 : break;
126 : : }
127 : :
128 : : rWriter.setFieldData(fieldIndex, uConstName, uConstTypeName, OUString(),
129 [ # # ]: 0 : OUString(), RT_ACCESS_CONST, constValue);
130 : 0 : }
131 : :
132 : 0 : sal_uInt32 getInheritedMemberCount( Reference< XTypeDescription >& xType )
133 : : {
134 : 0 : sal_uInt32 memberCount = 0;
135 [ # # ]: 0 : if ( xType->getTypeClass() == TypeClass_INTERFACE )
136 : : {
137 [ # # ]: 0 : Reference< XInterfaceTypeDescription > xIFace(xType, UNO_QUERY);
138 : :
139 [ # # ]: 0 : if ( !xIFace.is() )
140 : 0 : return memberCount;
141 : :
142 [ # # ][ # # ]: 0 : Reference< XTypeDescription > xSuperType = xIFace->getBaseType();
143 : :
144 [ # # ]: 0 : if ( xSuperType.is() )
145 [ # # ]: 0 : memberCount = getInheritedMemberCount( xSuperType );
146 : :
147 [ # # ][ # # ]: 0 : memberCount += xIFace->getMembers().getLength();
[ # # ][ # # ]
148 : : }
149 : :
150 : 0 : return memberCount;
151 : : }
152 : :
153 : 0 : void writeMethodData( RegistryTypeWriter& rWriter, sal_uInt32 calculatedMemberOffset,
154 : : const Reference< XInterfaceMemberTypeDescription >& xMember,
155 : : const Reference< XInterfaceMethodTypeDescription >& xMethod )
156 : : {
157 : 0 : RTMethodMode methodMode = RT_MODE_TWOWAY;
158 [ # # ][ # # ]: 0 : if ( xMethod->isOneway() )
[ # # ]
159 : : {
160 : 0 : methodMode = RT_MODE_ONEWAY;
161 : : }
162 : :
163 [ # # ][ # # ]: 0 : Sequence< Reference< XMethodParameter > > parameters( xMethod->getParameters() );
164 [ # # ][ # # ]: 0 : Sequence< Reference< XTypeDescription > > exceptions( xMethod->getExceptions() );
165 [ # # ][ # # ]: 0 : sal_uInt16 methodIndex = (sal_uInt16)(xMember->getPosition() - calculatedMemberOffset);
166 : 0 : sal_uInt16 paramCount = (sal_uInt16)parameters.getLength();
167 : 0 : sal_uInt16 exceptionCount = (sal_uInt16)exceptions.getLength();
168 : :
169 [ # # ]: 0 : rWriter.setMethodData(methodIndex, xMember->getMemberName(),
170 [ # # ][ # # ]: 0 : xMethod->getReturnType()->getName().replace('.', '/'),
[ # # ]
171 [ # # ][ # # ]: 0 : methodMode, paramCount, exceptionCount, OUString());
[ # # ]
172 : :
173 : 0 : RTParamMode paramMode = RT_PARAM_IN;
174 : : sal_uInt16 i;
175 : :
176 [ # # ]: 0 : for ( i=0; i < paramCount; i++)
177 : : {
178 [ # # ]: 0 : Reference< XMethodParameter > xParam = parameters[i];
179 [ # # ][ # # ]: 0 : if ( xParam->isIn() && xParam->isOut())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
180 : : {
181 : 0 : paramMode = RT_PARAM_INOUT;
182 : : } else
183 [ # # ][ # # ]: 0 : if ( xParam->isIn() )
[ # # ]
184 : : {
185 : 0 : paramMode = RT_PARAM_IN;
186 : : } else
187 [ # # ][ # # ]: 0 : if ( xParam->isOut() )
[ # # ]
188 : : {
189 : 0 : paramMode = RT_PARAM_OUT;
190 : : }
191 : :
192 [ # # ][ # # ]: 0 : rWriter.setParamData(methodIndex, (sal_uInt16)xParam->getPosition(), xParam->getType()->getName().replace('.', '/'),
[ # # # # ]
[ # # ]
193 [ # # ][ # # ]: 0 : xParam->getName(), paramMode);
[ # # ][ # # ]
194 : 0 : }
195 : :
196 [ # # ]: 0 : for (i=0; i < exceptionCount; i++)
197 : : {
198 [ # # ][ # # ]: 0 : rWriter.setExcData(methodIndex, i, exceptions[i]->getName().replace('.', '/'));
[ # # ][ # # ]
199 [ # # ][ # # ]: 0 : }
200 : 0 : }
201 : :
202 : : extern "C"
203 : : {
204 : :
205 : 0 : sal_Bool SAL_CALL initTypeMapper( const sal_Char* pRegName )
206 : : {
207 : : try
208 : : {
209 [ # # ]: 0 : if (!pRegName)
210 : 0 : return sal_False;
211 : :
212 [ # # ][ # # ]: 0 : Reference< XMultiServiceFactory > xSMgr( createRegistryServiceFactory( convertToFileUrl(pRegName) ) );
213 : :
214 [ # # ]: 0 : if ( !xSMgr.is() )
215 : 0 : return sal_False;
216 : :
217 : 0 : Reference< XHierarchicalNameAccess > xNAccess;
218 : :
219 [ # # ]: 0 : Reference< beans::XPropertySet > xProps( xSMgr, UNO_QUERY );
220 [ # # ]: 0 : if (xProps.is())
221 : : {
222 : : try
223 : : {
224 : 0 : Reference< XComponentContext > xContext;
225 [ # # ][ # # ]: 0 : if (xProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext)
[ # # ][ # # ]
[ # # ]
226 : : {
227 [ # # ]: 0 : xContext->getValueByName(
228 [ # # ][ # # ]: 0 : OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theTypeDescriptionManager") ) ) >>= xNAccess;
[ # # ]
229 [ # # ]: 0 : }
230 : : }
231 [ # # ]: 0 : catch (beans::UnknownPropertyException &)
232 : : {
233 : : }
234 : : }
235 : :
236 [ # # ]: 0 : if ( !xNAccess.is() )
237 : 0 : return sal_False;
238 : :
239 [ # # ][ # # ]: 0 : xNameAccess = xNAccess;
[ # # ]
[ # # # # ]
240 : : }
241 : 0 : catch( Exception& )
242 : : {
243 : 0 : return sal_False;
244 : : }
245 : :
246 : 0 : return sal_True;
247 : : }
248 : :
249 : 0 : sal_uInt32 SAL_CALL getTypeBlop(const sal_Char* pTypeName, sal_uInt8** pBlop)
250 : : {
251 : 0 : sal_uInt32 length = 0;
252 : :
253 [ # # ]: 0 : if ( !pTypeName )
254 : 0 : return length;
255 : :
256 : 0 : OUString uTypeName( OUString::createFromAscii(pTypeName).replace('/', '.') );
257 : : try
258 : : {
259 [ # # ][ # # ]: 0 : Any aTypeAny( xNameAccess->getByHierarchicalName( uTypeName ) );
260 : :
261 [ # # ]: 0 : if ( !aTypeAny.hasValue() )
262 : 0 : return length;
263 : :
264 : 0 : Reference< XTypeDescription > xType;
265 [ # # ]: 0 : aTypeAny >>= xType;
266 : :
267 [ # # ]: 0 : if ( !xType.is() )
268 : 0 : return length;
269 : :
270 [ # # ][ # # ]: 0 : switch (xType->getTypeClass())
[ # # # #
# # # ]
271 : : {
272 : : case TypeClass_CONSTANTS:
273 : : {
274 [ # # ]: 0 : Reference< XConstantsTypeDescription > xCFace(xType, UNO_QUERY);
275 : :
276 [ # # ]: 0 : if ( !xCFace.is() )
277 : 0 : return length;
278 : :
279 [ # # ][ # # ]: 0 : Sequence< Reference< XConstantTypeDescription > > constTypes( xCFace->getConstants());
280 : 0 : sal_uInt16 constCount = (sal_uInt16)constTypes.getLength();
281 : :
282 : : RegistryTypeWriter writer(RT_TYPE_MODULE, uTypeName.replace('.', '/'),
283 [ # # ]: 0 : OUString(), constCount, 0, 0);
284 : :
285 [ # # ]: 0 : for (sal_uInt16 i=0; i < constCount; i++)
286 [ # # ][ # # ]: 0 : writeConstantData(writer, i, constTypes[i]);
287 : :
288 [ # # ]: 0 : length = writer.getBlopSize();
289 : 0 : *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
290 [ # # ][ # # ]: 0 : rtl_copyMemory(*pBlop, writer.getBlop(), length);
[ # # ][ # # ]
[ # # ]
291 : : }
292 : 0 : break;
293 : : case TypeClass_MODULE:
294 : : {
295 [ # # ]: 0 : Reference< XModuleTypeDescription > xMFace(xType, UNO_QUERY);
296 : :
297 [ # # ]: 0 : if ( !xMFace.is() )
298 : 0 : return length;
299 : :
300 [ # # ][ # # ]: 0 : Sequence< Reference< XTypeDescription > > memberTypes( xMFace->getMembers());
301 : :
302 : 0 : sal_uInt16 memberCount = (sal_uInt16)memberTypes.getLength();
303 : 0 : sal_uInt16 constCount = 0;
304 : : sal_Int16 i;
305 : :
306 [ # # ]: 0 : for ( i=0; i < memberCount; i++)
307 : : {
308 [ # # ][ # # ]: 0 : if ( TypeClass_CONSTANT == memberTypes[i]->getTypeClass() )
[ # # ][ # # ]
309 : 0 : constCount++;
310 : : }
311 : :
312 : : RegistryTypeWriter writer(RT_TYPE_MODULE, uTypeName.replace('.', '/'),
313 [ # # ]: 0 : OUString(), constCount, 0, 0);
314 : :
315 [ # # ]: 0 : if ( 0 < constCount )
316 : : {
317 : 0 : Reference< XConstantTypeDescription > xConst;
318 : 0 : sal_uInt16 fieldIndex = 0;
319 [ # # ]: 0 : for (i=0; i < memberCount; i++)
320 : : {
321 [ # # ][ # # ]: 0 : if ( TypeClass_CONSTANT == memberTypes[i]->getTypeClass() )
[ # # ][ # # ]
322 : : {
323 [ # # ][ # # ]: 0 : xConst = Reference< XConstantTypeDescription >(memberTypes[i], UNO_QUERY);
[ # # ]
324 : :
325 [ # # ]: 0 : writeConstantData(writer, ++fieldIndex, xConst);
326 : : }
327 : 0 : }
328 : : }
329 : :
330 [ # # ]: 0 : length = writer.getBlopSize();
331 : 0 : *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
332 [ # # ][ # # ]: 0 : rtl_copyMemory(*pBlop, writer.getBlop(), length);
[ # # ][ # # ]
[ # # ]
333 : : }
334 : 0 : break;
335 : : case TypeClass_INTERFACE:
336 : : {
337 [ # # ]: 0 : Reference< XInterfaceTypeDescription > xIFace(xType, UNO_QUERY);
338 : :
339 [ # # ]: 0 : if ( !xIFace.is() )
340 : 0 : return length;
341 : :
342 : 0 : Reference< XInterfaceAttributeTypeDescription > xAttr;
343 : 0 : Reference< XInterfaceMethodTypeDescription > xMethod;
344 [ # # ][ # # ]: 0 : Sequence< Reference< XInterfaceMemberTypeDescription > > memberTypes( xIFace->getMembers());
345 : 0 : sal_uInt16 memberCount = (sal_uInt16)memberTypes.getLength();
346 : 0 : sal_uInt16 attrCount = 0;
347 : 0 : sal_uInt16 inheritedMemberCount = 0;
348 : : sal_Int32 i;
349 : :
350 [ # # ]: 0 : for ( i=0; i < memberCount; i++)
351 : : {
352 [ # # ][ # # ]: 0 : xAttr = Reference< XInterfaceAttributeTypeDescription >(memberTypes[i], UNO_QUERY);
[ # # ]
353 [ # # ]: 0 : if ( xAttr.is() )
354 : : {
355 : 0 : attrCount++;
356 : : }
357 : : }
358 : :
359 : 0 : OUString uSuperType;
360 [ # # ][ # # ]: 0 : Reference< XTypeDescription > xSuperType = xIFace->getBaseType();
361 [ # # ]: 0 : if ( xSuperType.is() )
362 : : {
363 [ # # ][ # # ]: 0 : uSuperType = xSuperType->getName().replace('.','/');
364 [ # # ]: 0 : inheritedMemberCount = (sal_uInt16)getInheritedMemberCount( xSuperType );
365 : : }
366 : :
367 : : RegistryTypeWriter writer(RT_TYPE_INTERFACE, uTypeName.replace('.', '/'),
368 [ # # ]: 0 : uSuperType, attrCount, memberCount-attrCount, 0);
369 : :
370 [ # # ][ # # ]: 0 : Uik uik = xIFace->getUik();
371 : 0 : RTUik rtUik = { uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5 };
372 [ # # ]: 0 : writer.setUik( rtUik );
373 : :
374 : 0 : RTFieldAccess attrAccess = RT_ACCESS_READWRITE;
375 : : // reset attrCount, used for method index calculation
376 : 0 : attrCount = 0;
377 : :
378 [ # # ]: 0 : for (i=0; i < memberCount; i++)
379 : : {
380 [ # # ][ # # ]: 0 : xAttr = Reference< XInterfaceAttributeTypeDescription >(memberTypes[i], UNO_QUERY);
[ # # ]
381 [ # # ]: 0 : if ( xAttr.is() )
382 : : {
383 : 0 : ++attrCount;
384 [ # # ][ # # ]: 0 : if (xAttr->isReadOnly())
[ # # ]
385 : : {
386 : 0 : attrAccess = RT_ACCESS_READONLY;
387 : : } else
388 : : {
389 : 0 : attrAccess = RT_ACCESS_READWRITE;
390 : : }
391 [ # # ][ # # ]: 0 : writer.setFieldData(sal::static_int_cast< sal_uInt16 >(memberTypes[i]->getPosition() - inheritedMemberCount),
[ # # ]
392 [ # # ][ # # ]: 0 : memberTypes[i]->getMemberName(),
393 [ # # ][ # # ]: 0 : xAttr->getType()->getName().replace('.', '/'),
[ # # ]
394 [ # # ]: 0 : OUString(), OUString(), attrAccess);
[ # # # # ]
395 : 0 : continue;
396 : : }
397 : :
398 [ # # ][ # # ]: 0 : xMethod = Reference< XInterfaceMethodTypeDescription >(memberTypes[i], UNO_QUERY);
[ # # ]
399 [ # # ]: 0 : if ( xMethod.is() )
400 : : {
401 [ # # ][ # # ]: 0 : writeMethodData( writer, attrCount+inheritedMemberCount, memberTypes[i], xMethod );
402 : : }
403 : : }
404 : :
405 [ # # ]: 0 : length = writer.getBlopSize();
406 : 0 : *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
407 [ # # ][ # # ]: 0 : rtl_copyMemory(*pBlop, writer.getBlop(), length);
[ # # ][ # # ]
[ # # ]
408 : : }
409 : 0 : break;
410 : : case TypeClass_STRUCT:
411 : : case TypeClass_EXCEPTION:
412 : : {
413 : 0 : RTTypeClass rtTypeClass = RT_TYPE_STRUCT;
414 [ # # ][ # # ]: 0 : if (xType->getTypeClass() == TypeClass_EXCEPTION)
[ # # ]
415 : : {
416 : 0 : rtTypeClass = RT_TYPE_EXCEPTION;
417 : : }
418 : : #include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
419 : :
420 [ # # ]: 0 : Reference< XCompoundTypeDescription > xComp(xType, UNO_QUERY);
421 : :
422 [ # # ]: 0 : if ( !xComp.is() )
423 : 0 : return length;
424 : :
425 [ # # ][ # # ]: 0 : Sequence< OUString > memberNames( xComp->getMemberNames());
426 [ # # ][ # # ]: 0 : Sequence< Reference< XTypeDescription > > memberTypes( xComp->getMemberTypes());
427 : 0 : sal_uInt16 memberCount = (sal_uInt16)memberNames.getLength();
428 : :
429 : 0 : OUString uSuperType;
430 [ # # ][ # # ]: 0 : Reference< XTypeDescription > xSuperType = xComp->getBaseType();
431 [ # # ]: 0 : if ( xSuperType.is() )
432 : : {
433 [ # # ][ # # ]: 0 : uSuperType = xSuperType->getName().replace('.','/');
434 : : }
435 : :
436 : : RegistryTypeWriter writer(rtTypeClass, uTypeName.replace('.', '/'),
437 [ # # ]: 0 : uSuperType, memberCount, 0, 0);
438 : :
439 [ # # ]: 0 : for (sal_Int16 i=0; i < memberCount; i++)
440 : : {
441 [ # # # # ]: 0 : writer.setFieldData(i , memberNames[i], memberTypes[i]->getName().replace('.', '/'),
[ # # ]
442 [ # # ][ # # ]: 0 : OUString(), OUString(), RT_ACCESS_READWRITE);
443 : : }
444 : :
445 [ # # ]: 0 : length = writer.getBlopSize();
446 : 0 : *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
447 [ # # ][ # # ]: 0 : rtl_copyMemory(*pBlop, writer.getBlop(), length);
[ # # ][ # # ]
[ # # ][ # # ]
448 : : }
449 : 0 : break;
450 : : case TypeClass_ENUM:
451 : : {
452 [ # # ]: 0 : Reference< XEnumTypeDescription > xEnum(xType, UNO_QUERY);
453 : :
454 [ # # ]: 0 : if ( !xEnum.is() )
455 : 0 : return length;
456 : :
457 [ # # ][ # # ]: 0 : Sequence< OUString > enumNames( xEnum->getEnumNames());
458 [ # # ][ # # ]: 0 : Sequence< sal_Int32 > enumValues( xEnum->getEnumValues());
459 : 0 : sal_uInt16 enumCount = (sal_uInt16)enumNames.getLength();
460 : :
461 : : RegistryTypeWriter writer(RT_TYPE_ENUM, uTypeName.replace('.', '/'),
462 [ # # ]: 0 : OUString(), enumCount, 0, 0);
463 : :
464 : 0 : RTConstValue constValue;
465 [ # # ]: 0 : for (sal_Int16 i=0; i < enumCount; i++)
466 : : {
467 : 0 : constValue.m_type = RT_TYPE_INT32;
468 [ # # ]: 0 : constValue.m_value.aLong = enumValues[i];
469 : :
470 [ # # ]: 0 : writer.setFieldData(i, enumNames[i], OUString(), OUString(), OUString(),
471 [ # # ]: 0 : RT_ACCESS_CONST, constValue);
472 : : }
473 : :
474 [ # # ]: 0 : length = writer.getBlopSize();
475 : 0 : *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
476 [ # # ][ # # ]: 0 : rtl_copyMemory(*pBlop, writer.getBlop(), length);
[ # # ][ # # ]
[ # # ][ # # ]
477 : : }
478 : 0 : break;
479 : : case TypeClass_TYPEDEF:
480 : : {
481 [ # # ]: 0 : Reference< XIndirectTypeDescription > xTD(xType, UNO_QUERY);
482 : :
483 [ # # ]: 0 : if ( !xTD.is() )
484 : 0 : return length;
485 : :
486 : : RegistryTypeWriter writer(RT_TYPE_TYPEDEF, uTypeName.replace('.', '/'),
487 [ # # ][ # # ]: 0 : xTD->getReferencedType()->getName().replace('.', '/'),
[ # # ]
488 [ # # ][ # # ]: 0 : 0, 0, 0);
489 [ # # ]: 0 : length = writer.getBlopSize();
490 : 0 : *pBlop = (sal_uInt8*)rtl_allocateMemory( length );
491 [ # # ][ # # ]: 0 : rtl_copyMemory(*pBlop, writer.getBlop(), length);
[ # # ][ # # ]
492 : : }
493 : 0 : break;
494 : : default:
495 : : OSL_ASSERT(false);
496 : 0 : break;
497 [ # # ][ # # ]: 0 : }
[ # # ]
498 : :
499 : : }
500 [ # # ]: 0 : catch( Exception& )
501 : : {
502 : : }
503 : :
504 : 0 : return length;
505 : : }
506 : :
507 [ + - ][ + - ]: 3 : } // extern "C"
508 : :
509 : :
510 : :
511 : :
512 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|