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 <osl/diagnose.h>
21 : : #include <osl/mutex.hxx>
22 : : #include <uno/dispatcher.h>
23 : : #include <uno/mapping.hxx>
24 : : #include <cppuhelper/factory.hxx>
25 : : #include <cppuhelper/compbase4.hxx>
26 : : #include <cppuhelper/implbase2.hxx>
27 : : #include <cppuhelper/typeprovider.hxx>
28 : :
29 : : #include <cppuhelper/weakref.hxx>
30 : :
31 : : #include <com/sun/star/lang/XServiceInfo.hpp>
32 : : #include <com/sun/star/lang/XComponent.hpp>
33 : : #include <com/sun/star/lang/XTypeProvider.hpp>
34 : : #include <com/sun/star/lang/XInitialization.hpp>
35 : : #include <com/sun/star/registry/XSimpleRegistry.hpp>
36 : : #include <com/sun/star/registry/XRegistryKey.hpp>
37 : : #include <com/sun/star/beans/XPropertySet.hpp>
38 : : #include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp>
39 : : #include "com/sun/star/uno/RuntimeException.hpp"
40 : :
41 : : #include "registry/reader.hxx"
42 : : #include "registry/version.h"
43 : : #include "base.hxx"
44 : : #include "rdbtdp_tdenumeration.hxx"
45 : : #include "structtypedescription.hxx"
46 : :
47 : : #define SERVICENAME "com.sun.star.reflection.TypeDescriptionProvider"
48 : : #define IMPLNAME "com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"
49 : :
50 : : using namespace com::sun::star;
51 : : using namespace com::sun::star::beans;
52 : : using namespace com::sun::star::registry;
53 : :
54 : : extern rtl_StandardModuleCount g_moduleCount;
55 : :
56 : : namespace stoc_bootstrap
57 : : {
58 : 756 : uno::Sequence< OUString > rdbtdp_getSupportedServiceNames()
59 : : {
60 : 756 : Sequence< OUString > seqNames(1);
61 [ + - ][ + - ]: 756 : seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
62 : 756 : return seqNames;
63 : : }
64 : :
65 : 10036 : OUString rdbtdp_getImplementationName()
66 : : {
67 : 10036 : return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME));
68 : : }
69 : : }
70 : :
71 : : namespace stoc_rdbtdp
72 : : {
73 : 1004 : struct MutexHolder
74 : : {
75 : : Mutex _aComponentMutex;
76 : : };
77 : : //==================================================================================================
78 : : class ProviderImpl
79 : : : public MutexHolder
80 : : , public WeakComponentImplHelper4< XServiceInfo,
81 : : XHierarchicalNameAccess,
82 : : XTypeDescriptionEnumerationAccess,
83 : : XInitialization >
84 : : {
85 : : // XHierarchicalNameAccess + XTypeDescriptionEnumerationAccess wrapper
86 : : // first asking the tdmgr instance, then looking up locally
87 [ - + ]: 464 : class TypeDescriptionManagerWrapper
88 : : : public ::cppu::WeakImplHelper2<
89 : : container::XHierarchicalNameAccess,
90 : : reflection::XTypeDescriptionEnumerationAccess>
91 : : {
92 : : com::sun::star::uno::Reference<container::XHierarchicalNameAccess>
93 : : m_xTDMgr;
94 : : com::sun::star::uno::Reference<container::XHierarchicalNameAccess>
95 : : m_xThisProvider;
96 : : public:
97 : 348 : TypeDescriptionManagerWrapper( ProviderImpl * pProvider )
98 [ + - ]: 348 : : m_xTDMgr( pProvider->_xContext->getValueByName(
99 : : OUString( RTL_CONSTASCII_USTRINGPARAM(
100 : : "/singletons/com.sun.star.reflection."
101 : 348 : "theTypeDescriptionManager") ) ),
102 : : UNO_QUERY_THROW ),
103 [ + - ][ + - ]: 696 : m_xThisProvider( pProvider )
[ + - ][ + - ]
[ + - ]
104 : 348 : {}
105 : : // XHierarchicalNameAccess
106 : : virtual Any SAL_CALL getByHierarchicalName( OUString const & name )
107 : : throw (container::NoSuchElementException, RuntimeException);
108 : : virtual sal_Bool SAL_CALL hasByHierarchicalName( OUString const & name )
109 : : throw (RuntimeException);
110 : :
111 : : // XTypeDescriptionEnumerationAccess
112 : : virtual uno::Reference<
113 : : reflection::XTypeDescriptionEnumeration > SAL_CALL
114 : : createTypeDescriptionEnumeration(
115 : : const ::rtl::OUString& moduleName,
116 : : const uno::Sequence< uno::TypeClass >& types,
117 : : reflection::TypeDescriptionSearchDepth depth )
118 : : throw ( reflection::NoSuchTypeNameException,
119 : : reflection::InvalidTypeNameException,
120 : : uno::RuntimeException );
121 : : };
122 : : friend class TypeDescriptionManagerWrapper;
123 : :
124 : : com::sun::star::uno::Reference< XComponentContext > _xContext;
125 : : com::sun::star::uno::WeakReference<XHierarchicalNameAccess> _xTDMgr;
126 : : com::sun::star::uno::Reference< XHierarchicalNameAccess > getTDMgr() SAL_THROW(());
127 : :
128 : : RegistryKeyList _aBaseKeys;
129 : :
130 : : protected:
131 : : virtual void SAL_CALL disposing();
132 : :
133 : : public:
134 : : ProviderImpl( const com::sun::star::uno::Reference< XComponentContext > & xContext );
135 : : virtual ~ProviderImpl();
136 : :
137 : : // XInitialization
138 : : virtual void SAL_CALL initialize( const Sequence< Any > & args ) throw (Exception, RuntimeException);
139 : :
140 : : // XServiceInfo
141 : : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
142 : : virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
143 : : virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
144 : :
145 : : // XHierarchicalNameAccess
146 : : Any getByHierarchicalNameImpl( const OUString & rName );
147 : :
148 : : virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
149 : : virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
150 : :
151 : : // XTypeDescriptionEnumerationAccess
152 : : virtual ::com::sun::star::uno::Reference<
153 : : ::com::sun::star::reflection::XTypeDescriptionEnumeration > SAL_CALL
154 : : createTypeDescriptionEnumeration(
155 : : const ::rtl::OUString& moduleName,
156 : : const ::com::sun::star::uno::Sequence<
157 : : ::com::sun::star::uno::TypeClass >& types,
158 : : ::com::sun::star::reflection::TypeDescriptionSearchDepth depth )
159 : : throw ( ::com::sun::star::reflection::NoSuchTypeNameException,
160 : : ::com::sun::star::reflection::InvalidTypeNameException,
161 : : ::com::sun::star::uno::RuntimeException );
162 : : };
163 : : //__________________________________________________________________________________________________
164 : 758 : ProviderImpl::ProviderImpl( const com::sun::star::uno::Reference< XComponentContext > & xContext )
165 : : : WeakComponentImplHelper4<
166 : : XServiceInfo, XHierarchicalNameAccess,
167 : : XTypeDescriptionEnumerationAccess, XInitialization >( _aComponentMutex )
168 [ + - ][ + - ]: 758 : , _xContext( xContext )
169 : : {
170 [ + - ]: 758 : g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
171 : 758 : }
172 : : //__________________________________________________________________________________________________
173 [ + - ][ + - ]: 246 : ProviderImpl::~ProviderImpl()
174 : : {
175 [ + - ]: 246 : g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
176 [ - + ]: 492 : }
177 : :
178 : : //______________________________________________________________________________
179 : 159702 : Any ProviderImpl::TypeDescriptionManagerWrapper::getByHierarchicalName(
180 : : OUString const & name ) throw (container::NoSuchElementException,
181 : : RuntimeException)
182 : : {
183 : : try
184 : : {
185 : : // first try tdmgr:
186 [ + - ][ + - ]: 159702 : return m_xTDMgr->getByHierarchicalName( name );
187 : : }
188 [ # # ]: 0 : catch (container::NoSuchElementException &)
189 : : {
190 : : // then lookup locally:
191 [ # # # # ]: 0 : return m_xThisProvider->getByHierarchicalName( name );
192 : : }
193 : : }
194 : :
195 : : //______________________________________________________________________________
196 : 0 : sal_Bool ProviderImpl::TypeDescriptionManagerWrapper::hasByHierarchicalName(
197 : : OUString const & name ) throw (RuntimeException)
198 : : {
199 [ # # ][ # # ]: 0 : return m_xTDMgr->hasByHierarchicalName( name ) || m_xThisProvider->hasByHierarchicalName( name );
200 : : }
201 : :
202 : : //______________________________________________________________________________
203 : : uno::Reference< reflection::XTypeDescriptionEnumeration > SAL_CALL
204 : 0 : ProviderImpl::TypeDescriptionManagerWrapper::createTypeDescriptionEnumeration(
205 : : const ::rtl::OUString& moduleName,
206 : : const uno::Sequence< uno::TypeClass >& types,
207 : : reflection::TypeDescriptionSearchDepth depth )
208 : : throw ( reflection::NoSuchTypeNameException,
209 : : reflection::InvalidTypeNameException,
210 : : uno::RuntimeException )
211 : : {
212 : : try
213 : : {
214 : : // first try tdmgr:
215 : : uno::Reference< reflection::XTypeDescriptionEnumerationAccess > xTDEA(
216 [ # # ]: 0 : m_xTDMgr, uno::UNO_QUERY_THROW );
217 : : return
218 [ # # ][ # # ]: 0 : xTDEA->createTypeDescriptionEnumeration( moduleName, types, depth );
219 : : }
220 [ # # ]: 0 : catch (reflection::NoSuchTypeNameException &)
221 : : {
222 : : // then lookup locally:
223 : : uno::Reference< reflection::XTypeDescriptionEnumerationAccess > xTDEA(
224 [ # # ]: 0 : m_xThisProvider, uno::UNO_QUERY_THROW );
225 : : return
226 [ # # # # ]: 0 : xTDEA->createTypeDescriptionEnumeration( moduleName, types, depth );
227 : : }
228 : : }
229 : :
230 : : //__________________________________________________________________________________________________
231 : 64134 : com::sun::star::uno::Reference< XHierarchicalNameAccess > ProviderImpl::getTDMgr()
232 : : SAL_THROW(())
233 : : {
234 : : // harden weak reference:
235 : : com::sun::star::uno::Reference<container::XHierarchicalNameAccess> xTDMgr(
236 : 64134 : _xTDMgr );
237 [ + + ]: 64134 : if (! xTDMgr.is())
238 : : {
239 [ + - ][ + - ]: 348 : xTDMgr.set( new TypeDescriptionManagerWrapper(this) );
[ + - ]
240 : : {
241 [ + - ]: 348 : MutexGuard guard( _aComponentMutex );
242 [ + - ][ + - ]: 348 : _xTDMgr = xTDMgr;
243 : : }
244 : : }
245 : 64134 : return xTDMgr;
246 : : }
247 : :
248 : : //__________________________________________________________________________________________________
249 : 246 : void ProviderImpl::disposing()
250 : : {
251 : 246 : _xContext.clear();
252 : :
253 [ + + ]: 980 : for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() );
254 : 490 : iPos != _aBaseKeys.end(); ++iPos )
255 : : {
256 [ + - ][ + - ]: 244 : (*iPos)->closeKey();
257 : : }
258 : 246 : _aBaseKeys.clear();
259 : 246 : }
260 : :
261 : : // XInitialization
262 : : //__________________________________________________________________________________________________
263 : 756 : void ProviderImpl::initialize(
264 : : const Sequence< Any > & args )
265 : : throw (Exception, RuntimeException)
266 : : {
267 : : // registries to read from
268 : 756 : Any const * pRegistries = args.getConstArray();
269 [ + + ]: 1512 : for ( sal_Int32 nPos = 0; nPos < args.getLength(); ++nPos )
270 : : {
271 [ + - ]: 756 : com::sun::star::uno::Reference< XSimpleRegistry > xRegistry( pRegistries[ nPos ], UNO_QUERY );
272 [ + - ][ + - ]: 756 : if (xRegistry.is() && xRegistry->isValid())
[ + - ][ + - ]
[ + - ]
273 : : {
274 [ + - ][ + - ]: 1512 : com::sun::star::uno::Reference< XRegistryKey > xKey( xRegistry->getRootKey()->openKey(
[ + - ]
275 [ + - ][ + - ]: 756 : OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR") ) ) );
276 [ + - ][ + - ]: 756 : if (xKey.is() && xKey->isValid())
[ + - ][ + - ]
[ + - ]
277 : : {
278 [ + - ]: 756 : _aBaseKeys.push_back( xKey );
279 : 756 : }
280 : : }
281 : 756 : }
282 : 756 : }
283 : :
284 : : // XServiceInfo
285 : : //__________________________________________________________________________________________________
286 : 0 : OUString ProviderImpl::getImplementationName()
287 : : throw(::com::sun::star::uno::RuntimeException)
288 : : {
289 : 0 : return stoc_bootstrap::rdbtdp_getImplementationName();
290 : : }
291 : : //__________________________________________________________________________________________________
292 : 0 : sal_Bool ProviderImpl::supportsService( const OUString & rServiceName )
293 : : throw(::com::sun::star::uno::RuntimeException)
294 : : {
295 : 0 : const Sequence< OUString > & rSNL = getSupportedServiceNames();
296 : 0 : const OUString * pArray = rSNL.getConstArray();
297 [ # # ]: 0 : for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
298 : : {
299 [ # # ]: 0 : if (pArray[nPos] == rServiceName)
300 : 0 : return sal_True;
301 : : }
302 : 0 : return sal_False;
303 : : }
304 : : //__________________________________________________________________________________________________
305 : 0 : Sequence< OUString > ProviderImpl::getSupportedServiceNames()
306 : : throw(::com::sun::star::uno::RuntimeException)
307 : : {
308 : 0 : return stoc_bootstrap::rdbtdp_getSupportedServiceNames();
309 : : }
310 : :
311 : : // XHierarchicalNameAccess
312 : : //__________________________________________________________________________________________________
313 : 65790 : Any ProviderImpl::getByHierarchicalNameImpl( const OUString & rName )
314 : : {
315 : 65790 : Any aRet;
316 : :
317 : : // read from registry
318 : 65790 : OUString aKey( rName.replace( '.', '/' ) );
319 [ + + + + ]: 460623 : for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() );
[ + + ]
320 [ + + ][ + + ]: 329043 : !aRet.hasValue() && iPos != _aBaseKeys.end(); ++iPos )
321 : : {
322 : : try
323 : : {
324 : 65790 : com::sun::star::uno::Reference< XRegistryKey > xBaseKey( *iPos );
325 [ + - ][ + - ]: 65790 : com::sun::star::uno::Reference< XRegistryKey > xKey( xBaseKey->openKey( aKey ) );
326 [ + + ]: 65790 : if (xKey.is())
327 : : {
328 : : // closes key in it's dtor (which is
329 : : // called even in case of exceptions).
330 [ + - ]: 64127 : RegistryKeyCloser aCloser( xKey );
331 : :
332 [ + - ][ + - ]: 64127 : if ( xKey->isValid() )
[ + - ]
333 : : {
334 [ + - ][ + - ]: 64127 : if (xKey->getValueType() == RegistryValueType_BINARY)
[ + - ]
335 : : {
336 [ + - ][ + - ]: 64127 : Sequence< sal_Int8 > aBytes( xKey->getBinaryValue() );
337 : : com::sun::star::uno::Reference< XTypeDescription > xTD(
338 : : createTypeDescription( aBytes,
339 : : getTDMgr(),
340 [ + - ][ + - ]: 64127 : true ) );
341 [ + - ]: 64127 : if ( xTD.is() )
342 [ + - ][ + - ]: 64127 : aRet <<= xTD;
343 : : }
344 [ + - ]: 64127 : }
345 : : }
346 : : else // might be a constant
347 : : {
348 : 1663 : sal_Int32 nIndex = aKey.lastIndexOf( '/' );
349 [ + + ]: 1663 : if (nIndex > 0)
350 : : {
351 : : // open module
352 [ + - ][ + - ]: 1570 : com::sun::star::uno::Reference< XRegistryKey > xKey2( xBaseKey->openKey( aKey.copy( 0, nIndex ) ) );
353 [ + - ]: 1570 : if (xKey2.is())
354 : : {
355 : : // closes key in it's dtor (which is
356 : : // called even in case of exceptions).
357 [ + - ]: 1570 : RegistryKeyCloser aCloser( xKey2 );
358 : :
359 [ + - ][ + - ]: 1570 : if ( xKey2->isValid() )
[ + - ]
360 : : {
361 [ + - ][ + - ]: 1570 : if (xKey2->getValueType() == RegistryValueType_BINARY)
[ + - ]
362 : : {
363 [ + - ][ + - ]: 1570 : Sequence< sal_Int8 > aBytes( xKey2->getBinaryValue() );
364 : : typereg::Reader aReader(
365 : 1570 : aBytes.getConstArray(), aBytes.getLength(),
366 [ + - ]: 1570 : false, TYPEREG_VERSION_1);
367 : :
368 [ + - + + : 3476 : if (aReader.getTypeClass() == RT_TYPE_MODULE ||
+ - ][ + - ]
369 : 1570 : aReader.getTypeClass() == RT_TYPE_CONSTANTS ||
370 : 336 : aReader.getTypeClass() == RT_TYPE_ENUM)
371 : : {
372 : 1570 : OUString aFieldName( aKey.copy( nIndex+1, aKey.getLength() - nIndex -1 ) );
373 : 1570 : sal_Int16 nPos = aReader.getFieldCount();
374 [ + - ]: 8514 : while (nPos--)
375 : : {
376 [ + + ]: 8514 : if (aFieldName.equals(
377 [ + - ]: 8514 : aReader.getFieldName(nPos)))
378 : 1570 : break;
379 : : }
380 [ + - ]: 1570 : if (nPos >= 0)
381 : : aRet = getRTValue(
382 [ + - ][ + - ]: 1570 : aReader.getFieldValue(nPos));
383 [ + - ]: 1570 : }
384 : : }
385 [ + - ]: 1570 : }
386 : 1570 : }
387 : : }
388 [ # # # ]: 65790 : }
389 : : }
390 [ # # ]: 0 : catch ( InvalidRegistryException const & )
391 : : {
392 : : OSL_FAIL( "ProviderImpl::getByHierarchicalName "
393 : : "- Caught InvalidRegistryException!" );
394 : :
395 : : // openKey, closeKey, getValueType, getBinaryValue, isValid
396 : :
397 : : // Don't stop iteration in this case.
398 : : }
399 [ # # ]: 0 : catch ( NoSuchElementException const & )
400 : : {
401 : : }
402 : : }
403 : 65790 : return aRet;
404 : : }
405 : :
406 : 65790 : Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName )
407 : : throw(::com::sun::star::uno::RuntimeException, com::sun::star::container::NoSuchElementException)
408 : : {
409 : 65790 : Any aRet( getByHierarchicalNameImpl( rName ) );
410 : :
411 [ + + ]: 65790 : if ( !aRet.hasValue() )
412 : : throw NoSuchElementException(
413 [ + - ][ + - ]: 93 : rName, static_cast< cppu::OWeakObject * >( this ) );
414 : :
415 : 65790 : return aRet;
416 : : }
417 : :
418 : : //__________________________________________________________________________________________________
419 : 0 : sal_Bool ProviderImpl::hasByHierarchicalName( const OUString & rName )
420 : : throw(::com::sun::star::uno::RuntimeException)
421 : : {
422 : 0 : return getByHierarchicalNameImpl( rName ).hasValue();
423 : : }
424 : :
425 : : // XTypeDescriptionEnumerationAccess
426 : : //__________________________________________________________________________________________________
427 : : // virtual
428 : : com::sun::star::uno::Reference< XTypeDescriptionEnumeration > SAL_CALL
429 : 7 : ProviderImpl::createTypeDescriptionEnumeration(
430 : : const OUString & moduleName,
431 : : const Sequence< TypeClass > & types,
432 : : TypeDescriptionSearchDepth depth )
433 : : throw ( NoSuchTypeNameException,
434 : : InvalidTypeNameException,
435 : : RuntimeException )
436 : : {
437 : : return com::sun::star::uno::Reference< XTypeDescriptionEnumeration >(
438 : : TypeDescriptionEnumerationImpl::createInstance( getTDMgr(),
439 : : moduleName,
440 : : types,
441 : : depth,
442 [ + + ][ + - ]: 7 : _aBaseKeys ).get() );
[ + - ]
443 : : }
444 : :
445 : : //__________________________________________________________________________________________________
446 : : // global helper function
447 : :
448 : 127412 : com::sun::star::uno::Reference< XTypeDescription > resolveTypedefs(
449 : : com::sun::star::uno::Reference< XTypeDescription > const & type)
450 : : {
451 : 127412 : com::sun::star::uno::Reference< XTypeDescription > resolved(type);
452 [ + - ][ + - ]: 127412 : while (resolved->getTypeClass() == TypeClass_TYPEDEF) {
[ - + ]
453 : : resolved = com::sun::star::uno::Reference< XIndirectTypeDescription >(
454 [ # # ][ # # ]: 0 : resolved, UNO_QUERY_THROW)->getReferencedType();
[ # # ][ # # ]
455 : : }
456 : 127412 : return resolved;
457 : : }
458 : :
459 : 65779 : com::sun::star::uno::Reference< XTypeDescription > createTypeDescription(
460 : : const Sequence< sal_Int8 > & rData,
461 : : const com::sun::star::uno::Reference< XHierarchicalNameAccess > & xNameAccess,
462 : : bool bReturnEmptyRefForUnknownType )
463 : : {
464 : : typereg::Reader aReader(
465 [ + - ]: 65779 : rData.getConstArray(), rData.getLength(), false, TYPEREG_VERSION_1);
466 : :
467 [ + - ]: 65779 : OUString aName( aReader.getTypeName().replace( '/', '.' ) );
468 : :
469 [ + + + + : 65779 : switch (aReader.getTypeClass())
+ + - + -
- - ]
470 : : {
471 : : case RT_TYPE_INTERFACE:
472 : : {
473 : 49945 : sal_uInt16 n = aReader.getSuperTypeCount();
474 [ + - ]: 49945 : com::sun::star::uno::Sequence< rtl::OUString > aBaseTypeNames(n);
475 [ + + ]: 101915 : {for (sal_uInt16 i = 0; i < n; ++i) {
476 [ + - ]: 51970 : aBaseTypeNames[i] = aReader.getSuperTypeName(i).replace(
477 [ + - ]: 103940 : '/', '.');
478 : : }}
479 : 49945 : sal_uInt16 n2 = aReader.getReferenceCount();
480 : : com::sun::star::uno::Sequence< rtl::OUString >
481 [ + - ]: 49945 : aOptionalBaseTypeNames(n2);
482 [ + + ]: 49964 : {for (sal_uInt16 i = 0; i < n2; ++i) {
483 : : OSL_ASSERT(
484 : : aReader.getReferenceSort(i) == RT_REF_SUPPORTS
485 : : && aReader.getReferenceFlags(i) == RT_ACCESS_OPTIONAL);
486 [ + - ][ + - ]: 19 : aOptionalBaseTypeNames[i] = aReader.getReferenceTypeName(i);
487 : : }}
488 : : return com::sun::star::uno::Reference< XTypeDescription >(
489 : : new InterfaceTypeDescriptionImpl( xNameAccess,
490 : : aName,
491 : : aBaseTypeNames,
492 : : aOptionalBaseTypeNames,
493 : : rData,
494 [ + - ][ + - ]: 49945 : aReader.isPublished() ) );
[ + - ][ + - ]
[ + - ]
495 : : }
496 : :
497 : : case RT_TYPE_MODULE:
498 : : {
499 : : com::sun::star::uno::Reference<
500 : : XTypeDescriptionEnumerationAccess > xTDEA(
501 [ + - ]: 8 : xNameAccess, UNO_QUERY );
502 : :
503 : : OSL_ENSURE( xTDEA.is(),
504 : : "No XTypeDescriptionEnumerationAccess!" );
505 : :
506 : : return com::sun::star::uno::Reference< XTypeDescription >(
507 [ + - ][ + - ]: 8 : new ModuleTypeDescriptionImpl( xTDEA, aName ) );
[ + - ]
508 : : }
509 : :
510 : : case RT_TYPE_STRUCT:
511 : : {
512 : 7741 : rtl::OUString superTypeName;
513 [ + + ]: 7741 : if (aReader.getSuperTypeCount() == 1) {
514 : : superTypeName = aReader.getSuperTypeName(0).replace(
515 [ + - ]: 672 : '/', '.');
516 : : }
517 : : return com::sun::star::uno::Reference< XTypeDescription >(
518 : : new stoc::registry_tdprovider::StructTypeDescription(
519 : : xNameAccess, aName, superTypeName, rData,
520 [ + - ][ + - ]: 7741 : aReader.isPublished()));
[ + - ]
521 : : }
522 : :
523 : : case RT_TYPE_ENUM:
524 : : return com::sun::star::uno::Reference< XTypeDescription >(
525 : : new EnumTypeDescriptionImpl( xNameAccess,
526 : : aName,
527 : : getRTValueAsInt32(
528 [ + - ]: 3302 : aReader.getFieldValue( 0 ) ),
529 [ + - ][ + - ]: 1651 : rData, aReader.isPublished() ) );
[ + - ]
530 : :
531 : : case RT_TYPE_EXCEPTION:
532 : : {
533 : 4042 : rtl::OUString superTypeName;
534 [ + + ]: 4042 : if (aReader.getSuperTypeCount() == 1) {
535 : : superTypeName = aReader.getSuperTypeName(0).replace(
536 [ + - ]: 3763 : '/', '.');
537 : : }
538 : : return com::sun::star::uno::Reference< XTypeDescription >(
539 : : new CompoundTypeDescriptionImpl(
540 : : xNameAccess, TypeClass_EXCEPTION, aName, superTypeName,
541 [ + - ][ + - ]: 4042 : rData, aReader.isPublished()));
[ + - ]
542 : : }
543 : :
544 : : case RT_TYPE_TYPEDEF:
545 : : return com::sun::star::uno::Reference< XTypeDescription >(
546 : : new TypedefTypeDescriptionImpl( xNameAccess,
547 : : aName,
548 : : aReader.getSuperTypeName(0)
549 : : .replace( '/', '.' ),
550 [ + - ][ + - ]: 290 : aReader.isPublished() ) );
[ + - ][ + - ]
551 : : case RT_TYPE_SERVICE:
552 : : return com::sun::star::uno::Reference< XTypeDescription >(
553 : : new ServiceTypeDescriptionImpl(
554 [ # # ][ # # ]: 0 : xNameAccess, aName, rData, aReader.isPublished() ) );
[ # # ]
555 : :
556 : : case RT_TYPE_CONSTANTS:
557 : : return com::sun::star::uno::Reference< XTypeDescription >(
558 : : new ConstantsTypeDescriptionImpl(
559 [ + - ][ + - ]: 2102 : aName, rData, aReader.isPublished() ) );
[ + - ]
560 : :
561 : : case RT_TYPE_SINGLETON:
562 : : return com::sun::star::uno::Reference< XTypeDescription >(
563 : : new SingletonTypeDescriptionImpl( xNameAccess,
564 : : aName,
565 : : aReader.getSuperTypeName(0)
566 : : .replace( '/', '.' ),
567 [ # # ][ # # ]: 0 : aReader.isPublished() ) );
[ # # ][ # # ]
568 : : case RT_TYPE_INVALID:
569 : : case RT_TYPE_OBJECT: // deprecated and not used
570 : : case RT_TYPE_UNION: // deprecated and not used
571 : : OSL_FAIL( "createTypeDescription - Unsupported Type!" );
572 : 0 : break;
573 : :
574 : : default:
575 : : OSL_FAIL( "createTypeDescription - Unknown Type!" );
576 : 0 : break;
577 : : }
578 : :
579 : : // Unknown type.
580 : :
581 [ # # ]: 0 : if ( bReturnEmptyRefForUnknownType )
582 : 0 : return com::sun::star::uno::Reference< XTypeDescription >();
583 : :
584 : : return com::sun::star::uno::Reference< XTypeDescription >(
585 [ # # ][ # # ]: 65779 : new TypeDescriptionImpl( TypeClass_UNKNOWN, aName ) );
[ # # ]
586 : : }
587 : :
588 : : }
589 : :
590 : : namespace stoc_bootstrap
591 : : {
592 : : //==================================================================================================
593 : 758 : com::sun::star::uno::Reference< XInterface > SAL_CALL ProviderImpl_create(
594 : : com::sun::star::uno::Reference< XComponentContext > const & xContext )
595 : : throw(::com::sun::star::uno::Exception)
596 : : {
597 [ + - ]: 758 : return com::sun::star::uno::Reference< XInterface >( *new stoc_rdbtdp::ProviderImpl( xContext ) );
598 : : }
599 : : }
600 : :
601 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|