File: | stoc/source/registry_tdprovider/tdprovider.cxx |
Location: | line 452, column 12 |
Description: | Called C++ object pointer is null |
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" "com.sun.star.reflection.TypeDescriptionProvider" | |||
48 | #define IMPLNAME"com.sun.star.comp.stoc.RegistryTypeDescriptionProvider" "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 | uno::Sequence< OUString > rdbtdp_getSupportedServiceNames() | |||
59 | { | |||
60 | Sequence< OUString > seqNames(1); | |||
61 | seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME)(&("com.sun.star.reflection.TypeDescriptionProvider")[0]) , ((sal_Int32)((sizeof ("com.sun.star.reflection.TypeDescriptionProvider" ) / sizeof (("com.sun.star.reflection.TypeDescriptionProvider" )[0]))-1)), (((rtl_TextEncoding) 11))); | |||
62 | return seqNames; | |||
63 | } | |||
64 | ||||
65 | OUString rdbtdp_getImplementationName() | |||
66 | { | |||
67 | return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME)(&("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider" )[0]), ((sal_Int32)((sizeof ("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider" ) / sizeof (("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider" )[0]))-1)), (((rtl_TextEncoding) 11))); | |||
68 | } | |||
69 | } | |||
70 | ||||
71 | namespace stoc_rdbtdp | |||
72 | { | |||
73 | 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 | 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 | TypeDescriptionManagerWrapper( ProviderImpl * pProvider ) | |||
98 | : m_xTDMgr( pProvider->_xContext->getValueByName( | |||
99 | OUString( RTL_CONSTASCII_USTRINGPARAM((&("/singletons/com.sun.star.reflection." "theTypeDescriptionManager" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.reflection." "theTypeDescriptionManager") / sizeof (("/singletons/com.sun.star.reflection." "theTypeDescriptionManager")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
100 | "/singletons/com.sun.star.reflection."(&("/singletons/com.sun.star.reflection." "theTypeDescriptionManager" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.reflection." "theTypeDescriptionManager") / sizeof (("/singletons/com.sun.star.reflection." "theTypeDescriptionManager")[0]))-1)), (((rtl_TextEncoding) 11 )) | |||
101 | "theTypeDescriptionManager")(&("/singletons/com.sun.star.reflection." "theTypeDescriptionManager" )[0]), ((sal_Int32)((sizeof ("/singletons/com.sun.star.reflection." "theTypeDescriptionManager") / sizeof (("/singletons/com.sun.star.reflection." "theTypeDescriptionManager")[0]))-1)), (((rtl_TextEncoding) 11 )) ) ), | |||
102 | UNO_QUERY_THROW ), | |||
103 | m_xThisProvider( pProvider ) | |||
104 | {} | |||
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 | ProviderImpl::ProviderImpl( const com::sun::star::uno::Reference< XComponentContext > & xContext ) | |||
165 | : WeakComponentImplHelper4< | |||
166 | XServiceInfo, XHierarchicalNameAccess, | |||
167 | XTypeDescriptionEnumerationAccess, XInitialization >( _aComponentMutex ) | |||
168 | , _xContext( xContext ) | |||
169 | { | |||
170 | g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); | |||
171 | } | |||
172 | //__________________________________________________________________________________________________ | |||
173 | ProviderImpl::~ProviderImpl() | |||
174 | { | |||
175 | g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); | |||
176 | } | |||
177 | ||||
178 | //______________________________________________________________________________ | |||
179 | Any ProviderImpl::TypeDescriptionManagerWrapper::getByHierarchicalName( | |||
180 | OUString const & name ) throw (container::NoSuchElementException, | |||
181 | RuntimeException) | |||
182 | { | |||
183 | try | |||
184 | { | |||
185 | // first try tdmgr: | |||
186 | return m_xTDMgr->getByHierarchicalName( name ); | |||
187 | } | |||
188 | catch (container::NoSuchElementException &) | |||
189 | { | |||
190 | // then lookup locally: | |||
191 | return m_xThisProvider->getByHierarchicalName( name ); | |||
192 | } | |||
193 | } | |||
194 | ||||
195 | //______________________________________________________________________________ | |||
196 | sal_Bool ProviderImpl::TypeDescriptionManagerWrapper::hasByHierarchicalName( | |||
197 | OUString const & name ) throw (RuntimeException) | |||
198 | { | |||
199 | return m_xTDMgr->hasByHierarchicalName( name ) || m_xThisProvider->hasByHierarchicalName( name ); | |||
200 | } | |||
201 | ||||
202 | //______________________________________________________________________________ | |||
203 | uno::Reference< reflection::XTypeDescriptionEnumeration > SAL_CALL | |||
204 | 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 | m_xTDMgr, uno::UNO_QUERY_THROW ); | |||
217 | return | |||
218 | xTDEA->createTypeDescriptionEnumeration( moduleName, types, depth ); | |||
219 | } | |||
220 | catch (reflection::NoSuchTypeNameException &) | |||
221 | { | |||
222 | // then lookup locally: | |||
223 | uno::Reference< reflection::XTypeDescriptionEnumerationAccess > xTDEA( | |||
224 | m_xThisProvider, uno::UNO_QUERY_THROW ); | |||
225 | return | |||
226 | xTDEA->createTypeDescriptionEnumeration( moduleName, types, depth ); | |||
227 | } | |||
228 | } | |||
229 | ||||
230 | //__________________________________________________________________________________________________ | |||
231 | 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 | _xTDMgr ); | |||
237 | if (! xTDMgr.is()) | |||
238 | { | |||
239 | xTDMgr.set( new TypeDescriptionManagerWrapper(this) ); | |||
240 | { | |||
241 | MutexGuard guard( _aComponentMutex ); | |||
242 | _xTDMgr = xTDMgr; | |||
243 | } | |||
244 | } | |||
245 | return xTDMgr; | |||
246 | } | |||
247 | ||||
248 | //__________________________________________________________________________________________________ | |||
249 | void ProviderImpl::disposing() | |||
250 | { | |||
251 | _xContext.clear(); | |||
252 | ||||
253 | for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() ); | |||
254 | iPos != _aBaseKeys.end(); ++iPos ) | |||
255 | { | |||
256 | (*iPos)->closeKey(); | |||
257 | } | |||
258 | _aBaseKeys.clear(); | |||
259 | } | |||
260 | ||||
261 | // XInitialization | |||
262 | //__________________________________________________________________________________________________ | |||
263 | void ProviderImpl::initialize( | |||
264 | const Sequence< Any > & args ) | |||
265 | throw (Exception, RuntimeException) | |||
266 | { | |||
267 | // registries to read from | |||
268 | Any const * pRegistries = args.getConstArray(); | |||
269 | for ( sal_Int32 nPos = 0; nPos < args.getLength(); ++nPos ) | |||
270 | { | |||
271 | com::sun::star::uno::Reference< XSimpleRegistry > xRegistry( pRegistries[ nPos ], UNO_QUERY ); | |||
272 | if (xRegistry.is() && xRegistry->isValid()) | |||
273 | { | |||
274 | com::sun::star::uno::Reference< XRegistryKey > xKey( xRegistry->getRootKey()->openKey( | |||
275 | OUString( RTL_CONSTASCII_USTRINGPARAM("/UCR")(&("/UCR")[0]), ((sal_Int32)((sizeof ("/UCR") / sizeof (( "/UCR")[0]))-1)), (((rtl_TextEncoding) 11)) ) ) ); | |||
276 | if (xKey.is() && xKey->isValid()) | |||
277 | { | |||
278 | _aBaseKeys.push_back( xKey ); | |||
279 | } | |||
280 | } | |||
281 | } | |||
282 | } | |||
283 | ||||
284 | // XServiceInfo | |||
285 | //__________________________________________________________________________________________________ | |||
286 | OUString ProviderImpl::getImplementationName() | |||
287 | throw(::com::sun::star::uno::RuntimeException) | |||
288 | { | |||
289 | return stoc_bootstrap::rdbtdp_getImplementationName(); | |||
290 | } | |||
291 | //__________________________________________________________________________________________________ | |||
292 | sal_Bool ProviderImpl::supportsService( const OUString & rServiceName ) | |||
293 | throw(::com::sun::star::uno::RuntimeException) | |||
294 | { | |||
295 | const Sequence< OUString > & rSNL = getSupportedServiceNames(); | |||
296 | const OUString * pArray = rSNL.getConstArray(); | |||
297 | for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) | |||
298 | { | |||
299 | if (pArray[nPos] == rServiceName) | |||
300 | return sal_True((sal_Bool)1); | |||
301 | } | |||
302 | return sal_False((sal_Bool)0); | |||
303 | } | |||
304 | //__________________________________________________________________________________________________ | |||
305 | Sequence< OUString > ProviderImpl::getSupportedServiceNames() | |||
306 | throw(::com::sun::star::uno::RuntimeException) | |||
307 | { | |||
308 | return stoc_bootstrap::rdbtdp_getSupportedServiceNames(); | |||
309 | } | |||
310 | ||||
311 | // XHierarchicalNameAccess | |||
312 | //__________________________________________________________________________________________________ | |||
313 | Any ProviderImpl::getByHierarchicalNameImpl( const OUString & rName ) | |||
314 | { | |||
315 | Any aRet; | |||
316 | ||||
317 | // read from registry | |||
318 | OUString aKey( rName.replace( '.', '/' ) ); | |||
319 | for ( RegistryKeyList::const_iterator iPos( _aBaseKeys.begin() ); | |||
320 | !aRet.hasValue() && iPos != _aBaseKeys.end(); ++iPos ) | |||
321 | { | |||
322 | try | |||
323 | { | |||
324 | com::sun::star::uno::Reference< XRegistryKey > xBaseKey( *iPos ); | |||
325 | com::sun::star::uno::Reference< XRegistryKey > xKey( xBaseKey->openKey( aKey ) ); | |||
326 | if (xKey.is()) | |||
327 | { | |||
328 | // closes key in it's dtor (which is | |||
329 | // called even in case of exceptions). | |||
330 | RegistryKeyCloser aCloser( xKey ); | |||
331 | ||||
332 | if ( xKey->isValid() ) | |||
333 | { | |||
334 | if (xKey->getValueType() == RegistryValueType_BINARY) | |||
335 | { | |||
336 | Sequence< sal_Int8 > aBytes( xKey->getBinaryValue() ); | |||
337 | com::sun::star::uno::Reference< XTypeDescription > xTD( | |||
338 | createTypeDescription( aBytes, | |||
339 | getTDMgr(), | |||
340 | true ) ); | |||
341 | if ( xTD.is() ) | |||
342 | aRet <<= xTD; | |||
343 | } | |||
344 | } | |||
345 | } | |||
346 | else // might be a constant | |||
347 | { | |||
348 | sal_Int32 nIndex = aKey.lastIndexOf( '/' ); | |||
349 | if (nIndex > 0) | |||
350 | { | |||
351 | // open module | |||
352 | com::sun::star::uno::Reference< XRegistryKey > xKey2( xBaseKey->openKey( aKey.copy( 0, nIndex ) ) ); | |||
353 | if (xKey2.is()) | |||
354 | { | |||
355 | // closes key in it's dtor (which is | |||
356 | // called even in case of exceptions). | |||
357 | RegistryKeyCloser aCloser( xKey2 ); | |||
358 | ||||
359 | if ( xKey2->isValid() ) | |||
360 | { | |||
361 | if (xKey2->getValueType() == RegistryValueType_BINARY) | |||
362 | { | |||
363 | Sequence< sal_Int8 > aBytes( xKey2->getBinaryValue() ); | |||
364 | typereg::Reader aReader( | |||
365 | aBytes.getConstArray(), aBytes.getLength(), | |||
366 | false, TYPEREG_VERSION_1); | |||
367 | ||||
368 | if (aReader.getTypeClass() == RT_TYPE_MODULE || | |||
369 | aReader.getTypeClass() == RT_TYPE_CONSTANTS || | |||
370 | aReader.getTypeClass() == RT_TYPE_ENUM) | |||
371 | { | |||
372 | OUString aFieldName( aKey.copy( nIndex+1, aKey.getLength() - nIndex -1 ) ); | |||
373 | sal_Int16 nPos = aReader.getFieldCount(); | |||
374 | while (nPos--) | |||
375 | { | |||
376 | if (aFieldName.equals( | |||
377 | aReader.getFieldName(nPos))) | |||
378 | break; | |||
379 | } | |||
380 | if (nPos >= 0) | |||
381 | aRet = getRTValue( | |||
382 | aReader.getFieldValue(nPos)); | |||
383 | } | |||
384 | } | |||
385 | } | |||
386 | } | |||
387 | } | |||
388 | } | |||
389 | } | |||
390 | catch ( InvalidRegistryException const & ) | |||
391 | { | |||
392 | OSL_FAIL( "ProviderImpl::getByHierarchicalName "do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "393" ": "), "%s", "ProviderImpl::getByHierarchicalName " "- Caught InvalidRegistryException!"); } } while (false) | |||
393 | "- Caught InvalidRegistryException!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "393" ": "), "%s", "ProviderImpl::getByHierarchicalName " "- Caught InvalidRegistryException!"); } } while (false); | |||
394 | ||||
395 | // openKey, closeKey, getValueType, getBinaryValue, isValid | |||
396 | ||||
397 | // Don't stop iteration in this case. | |||
398 | } | |||
399 | catch ( NoSuchElementException const & ) | |||
400 | { | |||
401 | } | |||
402 | } | |||
403 | return aRet; | |||
404 | } | |||
405 | ||||
406 | Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName ) | |||
407 | throw(::com::sun::star::uno::RuntimeException, com::sun::star::container::NoSuchElementException) | |||
408 | { | |||
409 | Any aRet( getByHierarchicalNameImpl( rName ) ); | |||
410 | ||||
411 | if ( !aRet.hasValue() ) | |||
412 | throw NoSuchElementException( | |||
413 | rName, static_cast< cppu::OWeakObject * >( this ) ); | |||
414 | ||||
415 | return aRet; | |||
416 | } | |||
417 | ||||
418 | //__________________________________________________________________________________________________ | |||
419 | sal_Bool ProviderImpl::hasByHierarchicalName( const OUString & rName ) | |||
420 | throw(::com::sun::star::uno::RuntimeException) | |||
421 | { | |||
422 | return getByHierarchicalNameImpl( rName ).hasValue(); | |||
423 | } | |||
424 | ||||
425 | // XTypeDescriptionEnumerationAccess | |||
426 | //__________________________________________________________________________________________________ | |||
427 | // virtual | |||
428 | com::sun::star::uno::Reference< XTypeDescriptionEnumeration > SAL_CALL | |||
429 | 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 | _aBaseKeys ).get() ); | |||
443 | } | |||
444 | ||||
445 | //__________________________________________________________________________________________________ | |||
446 | // global helper function | |||
447 | ||||
448 | com::sun::star::uno::Reference< XTypeDescription > resolveTypedefs( | |||
449 | com::sun::star::uno::Reference< XTypeDescription > const & type) | |||
450 | { | |||
451 | com::sun::star::uno::Reference< XTypeDescription > resolved(type); | |||
452 | while (resolved->getTypeClass() == TypeClass_TYPEDEF) { | |||
| ||||
| ||||
453 | resolved = com::sun::star::uno::Reference< XIndirectTypeDescription >( | |||
454 | resolved, UNO_QUERY_THROW)->getReferencedType(); | |||
455 | } | |||
456 | return resolved; | |||
457 | } | |||
458 | ||||
459 | 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 | rData.getConstArray(), rData.getLength(), false, TYPEREG_VERSION_1); | |||
466 | ||||
467 | OUString aName( aReader.getTypeName().replace( '/', '.' ) ); | |||
468 | ||||
469 | switch (aReader.getTypeClass()) | |||
470 | { | |||
471 | case RT_TYPE_INTERFACE: | |||
472 | { | |||
473 | sal_uInt16 n = aReader.getSuperTypeCount(); | |||
474 | com::sun::star::uno::Sequence< rtl::OUString > aBaseTypeNames(n); | |||
475 | {for (sal_uInt16 i = 0; i < n; ++i) { | |||
476 | aBaseTypeNames[i] = aReader.getSuperTypeName(i).replace( | |||
477 | '/', '.'); | |||
478 | }} | |||
479 | sal_uInt16 n2 = aReader.getReferenceCount(); | |||
480 | com::sun::star::uno::Sequence< rtl::OUString > | |||
481 | aOptionalBaseTypeNames(n2); | |||
482 | {for (sal_uInt16 i = 0; i < n2; ++i) { | |||
483 | OSL_ASSERT(do { if (true && (!(aReader.getReferenceSort(i) == RT_REF_SUPPORTS && aReader.getReferenceFlags(i) == 0x0002))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "485" ": "), "OSL_ASSERT: %s", "aReader.getReferenceSort(i) == RT_REF_SUPPORTS && aReader.getReferenceFlags(i) == RT_ACCESS_OPTIONAL" ); } } while (false) | |||
484 | aReader.getReferenceSort(i) == RT_REF_SUPPORTSdo { if (true && (!(aReader.getReferenceSort(i) == RT_REF_SUPPORTS && aReader.getReferenceFlags(i) == 0x0002))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "485" ": "), "OSL_ASSERT: %s", "aReader.getReferenceSort(i) == RT_REF_SUPPORTS && aReader.getReferenceFlags(i) == RT_ACCESS_OPTIONAL" ); } } while (false) | |||
485 | && aReader.getReferenceFlags(i) == RT_ACCESS_OPTIONAL)do { if (true && (!(aReader.getReferenceSort(i) == RT_REF_SUPPORTS && aReader.getReferenceFlags(i) == 0x0002))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "485" ": "), "OSL_ASSERT: %s", "aReader.getReferenceSort(i) == RT_REF_SUPPORTS && aReader.getReferenceFlags(i) == RT_ACCESS_OPTIONAL" ); } } while (false); | |||
486 | 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 | aReader.isPublished() ) ); | |||
495 | } | |||
496 | ||||
497 | case RT_TYPE_MODULE: | |||
498 | { | |||
499 | com::sun::star::uno::Reference< | |||
500 | XTypeDescriptionEnumerationAccess > xTDEA( | |||
501 | xNameAccess, UNO_QUERY ); | |||
502 | ||||
503 | OSL_ENSURE( xTDEA.is(),do { if (true && (!(xTDEA.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "504" ": "), "%s", "No XTypeDescriptionEnumerationAccess!" ); } } while (false) | |||
504 | "No XTypeDescriptionEnumerationAccess!" )do { if (true && (!(xTDEA.is()))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "504" ": "), "%s", "No XTypeDescriptionEnumerationAccess!" ); } } while (false); | |||
505 | ||||
506 | return com::sun::star::uno::Reference< XTypeDescription >( | |||
507 | new ModuleTypeDescriptionImpl( xTDEA, aName ) ); | |||
508 | } | |||
509 | ||||
510 | case RT_TYPE_STRUCT: | |||
511 | { | |||
512 | rtl::OUString superTypeName; | |||
513 | if (aReader.getSuperTypeCount() == 1) { | |||
514 | superTypeName = aReader.getSuperTypeName(0).replace( | |||
515 | '/', '.'); | |||
516 | } | |||
517 | return com::sun::star::uno::Reference< XTypeDescription >( | |||
518 | new stoc::registry_tdprovider::StructTypeDescription( | |||
519 | xNameAccess, aName, superTypeName, rData, | |||
520 | 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 | aReader.getFieldValue( 0 ) ), | |||
529 | rData, aReader.isPublished() ) ); | |||
530 | ||||
531 | case RT_TYPE_EXCEPTION: | |||
532 | { | |||
533 | rtl::OUString superTypeName; | |||
534 | if (aReader.getSuperTypeCount() == 1) { | |||
535 | superTypeName = aReader.getSuperTypeName(0).replace( | |||
536 | '/', '.'); | |||
537 | } | |||
538 | return com::sun::star::uno::Reference< XTypeDescription >( | |||
539 | new CompoundTypeDescriptionImpl( | |||
540 | xNameAccess, TypeClass_EXCEPTION, aName, superTypeName, | |||
541 | 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 | aReader.isPublished() ) ); | |||
551 | case RT_TYPE_SERVICE: | |||
552 | return com::sun::star::uno::Reference< XTypeDescription >( | |||
553 | new ServiceTypeDescriptionImpl( | |||
554 | xNameAccess, aName, rData, aReader.isPublished() ) ); | |||
555 | ||||
556 | case RT_TYPE_CONSTANTS: | |||
557 | return com::sun::star::uno::Reference< XTypeDescription >( | |||
558 | new ConstantsTypeDescriptionImpl( | |||
559 | 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 | 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!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "571" ": "), "%s", "createTypeDescription - Unsupported Type!" ); } } while (false); | |||
572 | break; | |||
573 | ||||
574 | default: | |||
575 | OSL_FAIL( "createTypeDescription - Unknown Type!" )do { if (true && (((sal_Bool)1))) { sal_detail_logFormat ((SAL_DETAIL_LOG_LEVEL_WARN), ("legacy.osl"), ("/usr/local/src/libreoffice/stoc/source/registry_tdprovider/tdprovider.cxx" ":" "575" ": "), "%s", "createTypeDescription - Unknown Type!" ); } } while (false); | |||
576 | break; | |||
577 | } | |||
578 | ||||
579 | // Unknown type. | |||
580 | ||||
581 | if ( bReturnEmptyRefForUnknownType ) | |||
582 | return com::sun::star::uno::Reference< XTypeDescription >(); | |||
583 | ||||
584 | return com::sun::star::uno::Reference< XTypeDescription >( | |||
585 | new TypeDescriptionImpl( TypeClass_UNKNOWN, aName ) ); | |||
586 | } | |||
587 | ||||
588 | } | |||
589 | ||||
590 | namespace stoc_bootstrap | |||
591 | { | |||
592 | //================================================================================================== | |||
593 | 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 | return com::sun::star::uno::Reference< XInterface >( *new stoc_rdbtdp::ProviderImpl( xContext ) ); | |||
598 | } | |||
599 | } | |||
600 | ||||
601 | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |