1647a425cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3647a425cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4647a425cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5647a425cSAndrew Rist * distributed with this work for additional information
6647a425cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7647a425cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8647a425cSAndrew Rist * "License"); you may not use this file except in compliance
9647a425cSAndrew Rist * with the License. You may obtain a copy of the License at
10647a425cSAndrew Rist *
11647a425cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12647a425cSAndrew Rist *
13647a425cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14647a425cSAndrew Rist * software distributed under the License is distributed on an
15647a425cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16647a425cSAndrew Rist * KIND, either express or implied. See the License for the
17647a425cSAndrew Rist * specific language governing permissions and limitations
18647a425cSAndrew Rist * under the License.
19647a425cSAndrew Rist *
20647a425cSAndrew Rist *************************************************************/
21647a425cSAndrew Rist
22647a425cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_stoc.hxx"
26cdf0e10cSrcweir #include <osl/diagnose.h>
27cdf0e10cSrcweir #include <osl/mutex.hxx>
28cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
29cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
30cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE5_HXX_
31cdf0e10cSrcweir #include <cppuhelper/compbase5.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
34cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
35cdf0e10cSrcweir #include <cppuhelper/implementationentry.hxx>
36cdf0e10cSrcweir #endif
37cdf0e10cSrcweir #include "tdmgr_common.hxx"
38cdf0e10cSrcweir #include "tdmgr_tdenumeration.hxx"
39cdf0e10cSrcweir #include "lrucache.hxx"
40cdf0e10cSrcweir
41cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
42cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
43cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
44cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
45cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
46cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
47cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
48cdf0e10cSrcweir #include <com/sun/star/container/XSet.hpp>
49cdf0e10cSrcweir #include <com/sun/star/container/XContentEnumerationAccess.hpp>
50cdf0e10cSrcweir #include <com/sun/star/reflection/XTypeDescription.hpp>
51cdf0e10cSrcweir #include <com/sun/star/reflection/XArrayTypeDescription.hpp>
52cdf0e10cSrcweir #include <com/sun/star/reflection/XIndirectTypeDescription.hpp>
53cdf0e10cSrcweir #include <com/sun/star/reflection/XInterfaceTypeDescription.hpp>
54cdf0e10cSrcweir #include "com/sun/star/reflection/XStructTypeDescription.hpp"
55cdf0e10cSrcweir #include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp>
56cdf0e10cSrcweir #include <com/sun/star/registry/XRegistryKey.hpp>
57cdf0e10cSrcweir #include "com/sun/star/uno/RuntimeException.hpp"
58cdf0e10cSrcweir
59cdf0e10cSrcweir #include <algorithm>
60cdf0e10cSrcweir #include <vector>
61cdf0e10cSrcweir
62cdf0e10cSrcweir using namespace std;
63cdf0e10cSrcweir using namespace cppu;
64cdf0e10cSrcweir using namespace rtl;
65cdf0e10cSrcweir using namespace osl;
66cdf0e10cSrcweir using namespace com::sun::star;
67cdf0e10cSrcweir using namespace com::sun::star::uno;
68cdf0e10cSrcweir using namespace com::sun::star::lang;
69cdf0e10cSrcweir using namespace com::sun::star::reflection;
70cdf0e10cSrcweir using namespace com::sun::star::container;
71cdf0e10cSrcweir using namespace com::sun::star::registry;
72cdf0e10cSrcweir
73cdf0e10cSrcweir
74cdf0e10cSrcweir
75cdf0e10cSrcweir static const sal_Int32 CACHE_SIZE = 512;
76cdf0e10cSrcweir
77cdf0e10cSrcweir #define SERVICENAME "com.sun.star.reflection.TypeDescriptionManager"
78cdf0e10cSrcweir #define IMPLNAME "com.sun.star.comp.stoc.TypeDescriptionManager"
79cdf0e10cSrcweir
80cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
81cdf0e10cSrcweir // exported via tdmgr_common.hxx
82cdf0e10cSrcweir extern rtl_StandardModuleCount g_moduleCount;
83cdf0e10cSrcweir
84cdf0e10cSrcweir namespace stoc_bootstrap
85cdf0e10cSrcweir {
tdmgr_getSupportedServiceNames()86cdf0e10cSrcweir Sequence< OUString > SAL_CALL tdmgr_getSupportedServiceNames()
87cdf0e10cSrcweir {
88cdf0e10cSrcweir static Sequence < OUString > *pNames = 0;
89cdf0e10cSrcweir if( ! pNames )
90cdf0e10cSrcweir {
91cdf0e10cSrcweir MutexGuard guard( Mutex::getGlobalMutex() );
92cdf0e10cSrcweir if( !pNames )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir static Sequence< OUString > seqNames(1);
95cdf0e10cSrcweir seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME));
96cdf0e10cSrcweir pNames = &seqNames;
97cdf0e10cSrcweir }
98cdf0e10cSrcweir }
99cdf0e10cSrcweir return *pNames;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
tdmgr_getImplementationName()102cdf0e10cSrcweir OUString SAL_CALL tdmgr_getImplementationName()
103cdf0e10cSrcweir {
104cdf0e10cSrcweir static OUString *pImplName = 0;
105cdf0e10cSrcweir if( ! pImplName )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir MutexGuard guard( Mutex::getGlobalMutex() );
108cdf0e10cSrcweir if( ! pImplName )
109cdf0e10cSrcweir {
110cdf0e10cSrcweir static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) );
111cdf0e10cSrcweir pImplName = &implName;
112cdf0e10cSrcweir }
113cdf0e10cSrcweir }
114cdf0e10cSrcweir return *pImplName;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir }
117cdf0e10cSrcweir
118cdf0e10cSrcweir namespace stoc_tdmgr
119cdf0e10cSrcweir {
120cdf0e10cSrcweir typedef vector< Reference< XHierarchicalNameAccess > > ProviderVector;
121cdf0e10cSrcweir
122cdf0e10cSrcweir class EnumerationImpl;
123cdf0e10cSrcweir class ManagerImpl;
124cdf0e10cSrcweir
125cdf0e10cSrcweir //==================================================================================================
126cdf0e10cSrcweir class EventListenerImpl : public ImplHelper1< XEventListener >
127cdf0e10cSrcweir {
128cdf0e10cSrcweir ManagerImpl * _pMgr;
129cdf0e10cSrcweir
130cdf0e10cSrcweir public:
EventListenerImpl(ManagerImpl * pMgr)131cdf0e10cSrcweir EventListenerImpl( ManagerImpl * pMgr )
132cdf0e10cSrcweir : _pMgr( pMgr )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir ::g_moduleCount.modCnt.acquire( &::g_moduleCount.modCnt );
135cdf0e10cSrcweir }
136cdf0e10cSrcweir virtual ~EventListenerImpl();
137cdf0e10cSrcweir
138cdf0e10cSrcweir // lifetime delegated to manager
139cdf0e10cSrcweir virtual void SAL_CALL acquire() throw();
140cdf0e10cSrcweir virtual void SAL_CALL release() throw();
141cdf0e10cSrcweir
142cdf0e10cSrcweir // XEventListener
143cdf0e10cSrcweir virtual void SAL_CALL disposing( const EventObject & rEvt ) throw(::com::sun::star::uno::RuntimeException);
144cdf0e10cSrcweir };
145cdf0e10cSrcweir
~EventListenerImpl()146cdf0e10cSrcweir EventListenerImpl::~EventListenerImpl()
147cdf0e10cSrcweir {
148cdf0e10cSrcweir ::g_moduleCount.modCnt.release( &::g_moduleCount.modCnt );
149cdf0e10cSrcweir }
150cdf0e10cSrcweir
151cdf0e10cSrcweir //==================================================================================================
152cdf0e10cSrcweir class ManagerImpl
153cdf0e10cSrcweir : public WeakComponentImplHelper5< XServiceInfo,
154cdf0e10cSrcweir XSet,
155cdf0e10cSrcweir XHierarchicalNameAccess,
156cdf0e10cSrcweir XTypeDescriptionEnumerationAccess,
157cdf0e10cSrcweir XInitialization >
158cdf0e10cSrcweir {
159cdf0e10cSrcweir friend class EnumerationImpl;
160cdf0e10cSrcweir friend class EventListenerImpl;
161cdf0e10cSrcweir
162cdf0e10cSrcweir Mutex _aComponentMutex;
163cdf0e10cSrcweir Reference< XComponentContext > _xContext;
164cdf0e10cSrcweir EventListenerImpl _aEventListener;
165cdf0e10cSrcweir
166cdf0e10cSrcweir // elements
167cdf0e10cSrcweir sal_Bool _bCaching;
168cdf0e10cSrcweir LRU_CacheAnyByOUString _aElements;
169cdf0e10cSrcweir // provider chain
170cdf0e10cSrcweir ProviderVector _aProviders;
171cdf0e10cSrcweir
172cdf0e10cSrcweir inline Any getSimpleType( const OUString & rName );
173cdf0e10cSrcweir
174cdf0e10cSrcweir Reference< XTypeDescription > getInstantiatedStruct(OUString const & name);
175cdf0e10cSrcweir
176cdf0e10cSrcweir protected:
177cdf0e10cSrcweir virtual void SAL_CALL disposing();
178cdf0e10cSrcweir
179cdf0e10cSrcweir public:
180cdf0e10cSrcweir ManagerImpl( Reference< XComponentContext > const & xContext, sal_Int32 nCacheSize );
181cdf0e10cSrcweir virtual ~ManagerImpl();
182cdf0e10cSrcweir
183cdf0e10cSrcweir // XInitialization
184cdf0e10cSrcweir virtual void SAL_CALL initialize( const Sequence< Any > & args ) throw (Exception, RuntimeException);
185cdf0e10cSrcweir
186cdf0e10cSrcweir // XServiceInfo
187cdf0e10cSrcweir virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
188cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException);
189cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
190cdf0e10cSrcweir
191cdf0e10cSrcweir // XElementAccess
192cdf0e10cSrcweir virtual Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
193cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
194cdf0e10cSrcweir
195cdf0e10cSrcweir // XEnumerationAccess
196cdf0e10cSrcweir virtual Reference< XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException);
197cdf0e10cSrcweir
198cdf0e10cSrcweir // XSet
199cdf0e10cSrcweir virtual sal_Bool SAL_CALL has( const Any & rElement ) throw(::com::sun::star::uno::RuntimeException);
200cdf0e10cSrcweir virtual void SAL_CALL insert( const Any & rElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
201cdf0e10cSrcweir virtual void SAL_CALL remove( const Any & rElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
202cdf0e10cSrcweir
203cdf0e10cSrcweir // XHierarchicalNameAccess
204cdf0e10cSrcweir virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
205cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException);
206cdf0e10cSrcweir
207cdf0e10cSrcweir // XTypeDescriptionEnumerationAccess
208cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference<
209cdf0e10cSrcweir ::com::sun::star::reflection::XTypeDescriptionEnumeration > SAL_CALL
210cdf0e10cSrcweir createTypeDescriptionEnumeration(
211cdf0e10cSrcweir const ::rtl::OUString& moduleName,
212cdf0e10cSrcweir const ::com::sun::star::uno::Sequence<
213cdf0e10cSrcweir ::com::sun::star::uno::TypeClass >& types,
214cdf0e10cSrcweir ::com::sun::star::reflection::TypeDescriptionSearchDepth depth )
215cdf0e10cSrcweir throw ( ::com::sun::star::reflection::NoSuchTypeNameException,
216cdf0e10cSrcweir ::com::sun::star::reflection::InvalidTypeNameException,
217cdf0e10cSrcweir ::com::sun::star::uno::RuntimeException );
218cdf0e10cSrcweir };
219cdf0e10cSrcweir
220cdf0e10cSrcweir //==================================================================================================
221cdf0e10cSrcweir class EnumerationImpl
222cdf0e10cSrcweir : public WeakImplHelper1< XEnumeration >
223cdf0e10cSrcweir {
224cdf0e10cSrcweir ManagerImpl * _pMgr;
225cdf0e10cSrcweir size_t _nPos;
226cdf0e10cSrcweir
227cdf0e10cSrcweir public:
228cdf0e10cSrcweir EnumerationImpl( ManagerImpl * pManager );
229cdf0e10cSrcweir virtual ~EnumerationImpl();
230cdf0e10cSrcweir
231cdf0e10cSrcweir // XEnumeration
232cdf0e10cSrcweir virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException);
233cdf0e10cSrcweir virtual Any SAL_CALL nextElement() throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
234cdf0e10cSrcweir };
235cdf0e10cSrcweir
236cdf0e10cSrcweir //##################################################################################################
237cdf0e10cSrcweir
238cdf0e10cSrcweir // lifetime delegated to manager
239cdf0e10cSrcweir //__________________________________________________________________________________________________
acquire()240cdf0e10cSrcweir void EventListenerImpl::acquire() throw()
241cdf0e10cSrcweir {
242cdf0e10cSrcweir _pMgr->acquire();
243cdf0e10cSrcweir }
244cdf0e10cSrcweir //__________________________________________________________________________________________________
release()245cdf0e10cSrcweir void EventListenerImpl::release() throw()
246cdf0e10cSrcweir {
247cdf0e10cSrcweir _pMgr->release();
248cdf0e10cSrcweir }
249cdf0e10cSrcweir
250cdf0e10cSrcweir // XEventListener
251cdf0e10cSrcweir //__________________________________________________________________________________________________
disposing(const EventObject & rEvt)252cdf0e10cSrcweir void EventListenerImpl::disposing( const EventObject & rEvt )
253cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
254cdf0e10cSrcweir {
255cdf0e10cSrcweir _pMgr->remove( makeAny( rEvt.Source ) );
256cdf0e10cSrcweir }
257cdf0e10cSrcweir
258cdf0e10cSrcweir //##################################################################################################
259cdf0e10cSrcweir
260cdf0e10cSrcweir //__________________________________________________________________________________________________
EnumerationImpl(ManagerImpl * pManager)261cdf0e10cSrcweir EnumerationImpl::EnumerationImpl( ManagerImpl * pManager )
262cdf0e10cSrcweir : _pMgr( pManager )
263cdf0e10cSrcweir , _nPos( 0 )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir _pMgr->acquire();
266cdf0e10cSrcweir }
267cdf0e10cSrcweir //__________________________________________________________________________________________________
~EnumerationImpl()268cdf0e10cSrcweir EnumerationImpl::~EnumerationImpl()
269cdf0e10cSrcweir {
270cdf0e10cSrcweir _pMgr->release();
271cdf0e10cSrcweir }
272cdf0e10cSrcweir
273cdf0e10cSrcweir // XEnumeration
274cdf0e10cSrcweir //__________________________________________________________________________________________________
hasMoreElements()275cdf0e10cSrcweir sal_Bool EnumerationImpl::hasMoreElements()
276cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
277cdf0e10cSrcweir {
278cdf0e10cSrcweir MutexGuard aGuard( _pMgr->_aComponentMutex );
279cdf0e10cSrcweir return (_nPos < _pMgr->_aProviders.size());
280cdf0e10cSrcweir }
281cdf0e10cSrcweir //__________________________________________________________________________________________________
nextElement()282cdf0e10cSrcweir Any EnumerationImpl::nextElement()
283cdf0e10cSrcweir throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
284cdf0e10cSrcweir {
285cdf0e10cSrcweir MutexGuard aGuard( _pMgr->_aComponentMutex );
286cdf0e10cSrcweir if (_nPos >= _pMgr->_aProviders.size())
287cdf0e10cSrcweir {
288cdf0e10cSrcweir throw NoSuchElementException(
289cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("there is no further element!") ),
290cdf0e10cSrcweir (XWeak *)(OWeakObject *)this );
291cdf0e10cSrcweir }
292cdf0e10cSrcweir return makeAny( _pMgr->_aProviders[_nPos++] );
293cdf0e10cSrcweir }
294cdf0e10cSrcweir
295cdf0e10cSrcweir //##################################################################################################
296cdf0e10cSrcweir
297cdf0e10cSrcweir //__________________________________________________________________________________________________
ManagerImpl(Reference<XComponentContext> const & xContext,sal_Int32 nCacheSize)298cdf0e10cSrcweir ManagerImpl::ManagerImpl(
299cdf0e10cSrcweir Reference< XComponentContext > const & xContext, sal_Int32 nCacheSize )
300cdf0e10cSrcweir : WeakComponentImplHelper5<
301cdf0e10cSrcweir XServiceInfo, XSet, XHierarchicalNameAccess,
302cdf0e10cSrcweir XTypeDescriptionEnumerationAccess, XInitialization >( _aComponentMutex )
303cdf0e10cSrcweir , _xContext( xContext )
304cdf0e10cSrcweir , _aEventListener( this )
305cdf0e10cSrcweir , _bCaching( sal_True )
306cdf0e10cSrcweir , _aElements( nCacheSize )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir ::g_moduleCount.modCnt.acquire( &::g_moduleCount.modCnt );
309cdf0e10cSrcweir }
310cdf0e10cSrcweir //__________________________________________________________________________________________________
~ManagerImpl()311cdf0e10cSrcweir ManagerImpl::~ManagerImpl()
312cdf0e10cSrcweir {
313cdf0e10cSrcweir OSL_ENSURE( _aProviders.size() == 0, "### still providers left!" );
314cdf0e10cSrcweir OSL_TRACE( "> TypeDescriptionManager shut down. <\n" );
315cdf0e10cSrcweir ::g_moduleCount.modCnt.release( &::g_moduleCount.modCnt );
316cdf0e10cSrcweir }
317cdf0e10cSrcweir //__________________________________________________________________________________________________
disposing()318cdf0e10cSrcweir void ManagerImpl::disposing()
319cdf0e10cSrcweir {
320cdf0e10cSrcweir // called on disposing the tdmgr instance (supposedly from context)
321cdf0e10cSrcweir _bCaching = sal_False;
322cdf0e10cSrcweir _aElements.clear();
323cdf0e10cSrcweir _xContext.clear();
324cdf0e10cSrcweir _aProviders.clear();
325cdf0e10cSrcweir }
326cdf0e10cSrcweir
327cdf0e10cSrcweir // XInitialization
328cdf0e10cSrcweir //__________________________________________________________________________________________________
initialize(const Sequence<Any> & args)329cdf0e10cSrcweir void ManagerImpl::initialize(
330cdf0e10cSrcweir const Sequence< Any > & args )
331cdf0e10cSrcweir throw (Exception, RuntimeException)
332cdf0e10cSrcweir {
333cdf0e10cSrcweir // additional providers
334cdf0e10cSrcweir Any const * pProviders = args.getConstArray();
335cdf0e10cSrcweir for ( sal_Int32 nPos = 0; nPos < args.getLength(); ++nPos )
336cdf0e10cSrcweir {
337cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xHA( pProviders[ nPos ], UNO_QUERY );
338cdf0e10cSrcweir OSL_ENSURE( xHA.is(), "### no td provider!" );
339cdf0e10cSrcweir
340cdf0e10cSrcweir if (xHA.is())
341cdf0e10cSrcweir {
342cdf0e10cSrcweir try
343cdf0e10cSrcweir {
344cdf0e10cSrcweir insert( makeAny( xHA ) );
345cdf0e10cSrcweir }
346cdf0e10cSrcweir catch (IllegalArgumentException &)
347cdf0e10cSrcweir {
348cdf0e10cSrcweir }
349cdf0e10cSrcweir catch (ElementExistException &)
350cdf0e10cSrcweir {
351cdf0e10cSrcweir }
352cdf0e10cSrcweir }
353cdf0e10cSrcweir }
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
356cdf0e10cSrcweir // XServiceInfo
357cdf0e10cSrcweir //__________________________________________________________________________________________________
getImplementationName()358cdf0e10cSrcweir OUString ManagerImpl::getImplementationName()
359cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
360cdf0e10cSrcweir {
361cdf0e10cSrcweir return stoc_bootstrap::tdmgr_getImplementationName();
362cdf0e10cSrcweir }
363cdf0e10cSrcweir //__________________________________________________________________________________________________
supportsService(const OUString & rServiceName)364cdf0e10cSrcweir sal_Bool ManagerImpl::supportsService( const OUString & rServiceName )
365cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
366cdf0e10cSrcweir {
367cdf0e10cSrcweir const Sequence< OUString > & rSNL = getSupportedServiceNames();
368cdf0e10cSrcweir const OUString * pArray = rSNL.getConstArray();
369cdf0e10cSrcweir for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir if (pArray[nPos] == rServiceName)
372cdf0e10cSrcweir return sal_True;
373cdf0e10cSrcweir }
374cdf0e10cSrcweir return sal_False;
375cdf0e10cSrcweir }
376cdf0e10cSrcweir //__________________________________________________________________________________________________
getSupportedServiceNames()377cdf0e10cSrcweir Sequence< OUString > ManagerImpl::getSupportedServiceNames()
378cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
379cdf0e10cSrcweir {
380cdf0e10cSrcweir return stoc_bootstrap::tdmgr_getSupportedServiceNames();
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir // XElementAccess
384cdf0e10cSrcweir //__________________________________________________________________________________________________
getElementType()385cdf0e10cSrcweir Type ManagerImpl::getElementType()
386cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir return ::getCppuType( (const Reference< XHierarchicalNameAccess > *)0 );
389cdf0e10cSrcweir }
390cdf0e10cSrcweir //__________________________________________________________________________________________________
hasElements()391cdf0e10cSrcweir sal_Bool ManagerImpl::hasElements()
392cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
393cdf0e10cSrcweir {
394cdf0e10cSrcweir MutexGuard aGuard( _aComponentMutex );
395cdf0e10cSrcweir return (_aProviders.size() > 0);
396cdf0e10cSrcweir }
397cdf0e10cSrcweir
398cdf0e10cSrcweir // XEnumerationAccess
399cdf0e10cSrcweir //__________________________________________________________________________________________________
createEnumeration()400cdf0e10cSrcweir Reference< XEnumeration > ManagerImpl::createEnumeration()
401cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
402cdf0e10cSrcweir {
403cdf0e10cSrcweir return new EnumerationImpl( this );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
406cdf0e10cSrcweir // XSet
407cdf0e10cSrcweir //__________________________________________________________________________________________________
has(const Any & rElement)408cdf0e10cSrcweir sal_Bool SAL_CALL ManagerImpl::has( const Any & rElement )
409cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
410cdf0e10cSrcweir {
411cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xElem;
412cdf0e10cSrcweir if (rElement >>= xElem)
413cdf0e10cSrcweir {
414cdf0e10cSrcweir MutexGuard aGuard( _aComponentMutex );
415cdf0e10cSrcweir return (find( _aProviders.begin(), _aProviders.end(), xElem ) != _aProviders.end());
416cdf0e10cSrcweir }
417cdf0e10cSrcweir return sal_False;
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir //__________________________________________________________________________________________________
insert(const Any & rElement)421cdf0e10cSrcweir void SAL_CALL ManagerImpl::insert( const Any & rElement )
422cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException)
423cdf0e10cSrcweir {
424cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xElem;
425cdf0e10cSrcweir if (! (rElement >>= xElem) || !xElem.is())
426cdf0e10cSrcweir {
427cdf0e10cSrcweir throw IllegalArgumentException(
428cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("no valid type description provider given!") ),
429cdf0e10cSrcweir (XWeak *)(OWeakObject *)this, 0 );
430cdf0e10cSrcweir }
431cdf0e10cSrcweir
432cdf0e10cSrcweir MutexGuard aGuard( _aComponentMutex );
433cdf0e10cSrcweir if (find( _aProviders.begin(), _aProviders.end(), xElem ) != _aProviders.end())
434cdf0e10cSrcweir {
435cdf0e10cSrcweir throw ElementExistException(
436cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("provider already inserted!") ),
437cdf0e10cSrcweir (XWeak *)(OWeakObject *)this );
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir if (! _aProviders.empty())
441cdf0e10cSrcweir {
442cdf0e10cSrcweir // check whether all types are compatible, if possible:
443cdf0e10cSrcweir Reference<reflection::XTypeDescriptionEnumerationAccess> xTDEnumAccess(
444cdf0e10cSrcweir xElem, UNO_QUERY );
445cdf0e10cSrcweir OSL_ENSURE( xTDEnumAccess.is(),
446cdf0e10cSrcweir "### providers ought to implement "
447cdf0e10cSrcweir "reflection::XTypeDescriptionEnumerationAccess!" );
448cdf0e10cSrcweir if (xTDEnumAccess.is())
449cdf0e10cSrcweir {
450cdf0e10cSrcweir try
451cdf0e10cSrcweir {
452cdf0e10cSrcweir TypeClass ar [] = {
453cdf0e10cSrcweir TypeClass_ENUM, TypeClass_TYPEDEF, TypeClass_SEQUENCE,
454cdf0e10cSrcweir TypeClass_STRUCT, TypeClass_EXCEPTION,
455cdf0e10cSrcweir /* TypeClass_UNION, TypeClass_ARRAY not supported */
456cdf0e10cSrcweir TypeClass_INTERFACE,
457cdf0e10cSrcweir TypeClass_SERVICE,
458cdf0e10cSrcweir TypeClass_INTERFACE_METHOD, TypeClass_INTERFACE_ATTRIBUTE,
459cdf0e10cSrcweir TypeClass_PROPERTY, TypeClass_CONSTANT, TypeClass_CONSTANTS,
460cdf0e10cSrcweir TypeClass_SINGLETON
461cdf0e10cSrcweir };
462cdf0e10cSrcweir Reference<reflection::XTypeDescriptionEnumeration> xTDEnum(
463cdf0e10cSrcweir xTDEnumAccess->createTypeDescriptionEnumeration(
464cdf0e10cSrcweir OUString() /* all modules */,
465cdf0e10cSrcweir Sequence<TypeClass>( ar, ARLEN(ar) ),
466cdf0e10cSrcweir reflection::TypeDescriptionSearchDepth_INFINITE ) );
467cdf0e10cSrcweir
468cdf0e10cSrcweir while (xTDEnum->hasMoreElements())
469cdf0e10cSrcweir {
470cdf0e10cSrcweir Reference<reflection::XTypeDescription> xNewTD;
471cdf0e10cSrcweir try
472cdf0e10cSrcweir {
473cdf0e10cSrcweir xNewTD = xTDEnum->nextTypeDescription();
474cdf0e10cSrcweir }
475cdf0e10cSrcweir catch (container::NoSuchElementException & exc)
476cdf0e10cSrcweir {
477cdf0e10cSrcweir throw lang::IllegalArgumentException(
478*86e1cf34SPedro Giffuni OUSTR("NoSuchElementException occurred: ") +
479cdf0e10cSrcweir exc.Message, static_cast<OWeakObject *>(this),
480cdf0e10cSrcweir -1 /* unknown */ );
481cdf0e10cSrcweir }
482cdf0e10cSrcweir
483cdf0e10cSrcweir try
484cdf0e10cSrcweir {
485cdf0e10cSrcweir OUString newName( xNewTD->getName() );
486cdf0e10cSrcweir Reference<reflection::XTypeDescription> xExistingTD(
487cdf0e10cSrcweir getByHierarchicalName( newName ), UNO_QUERY );
488cdf0e10cSrcweir OSL_ASSERT( xExistingTD.is() );
489cdf0e10cSrcweir // existing, check whether compatible:
490cdf0e10cSrcweir if (xExistingTD.is())
491cdf0e10cSrcweir {
492cdf0e10cSrcweir try
493cdf0e10cSrcweir {
494cdf0e10cSrcweir check( xNewTD, xExistingTD );
495cdf0e10cSrcweir }
496cdf0e10cSrcweir catch (IncompatibleTypeException & exc)
497cdf0e10cSrcweir {
498cdf0e10cSrcweir throw lang::IllegalArgumentException(
499cdf0e10cSrcweir OUSTR("Rejecting types due to "
500cdf0e10cSrcweir "incompatibility! ") + exc.m_cause,
501cdf0e10cSrcweir static_cast<OWeakObject *>(this), 0 );
502cdf0e10cSrcweir }
503cdf0e10cSrcweir }
504cdf0e10cSrcweir }
505cdf0e10cSrcweir catch (container::NoSuchElementException &)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir // type not in: ok
508cdf0e10cSrcweir }
509cdf0e10cSrcweir }
510cdf0e10cSrcweir }
511cdf0e10cSrcweir catch (reflection::NoSuchTypeNameException & exc)
512cdf0e10cSrcweir {
513cdf0e10cSrcweir throw lang::IllegalArgumentException(
514*86e1cf34SPedro Giffuni OUSTR("NoSuchTypeNameException occurred: ") + exc.Message,
515cdf0e10cSrcweir static_cast<OWeakObject *>(this), -1 /* unknown */ );
516cdf0e10cSrcweir }
517cdf0e10cSrcweir catch (reflection::InvalidTypeNameException & exc)
518cdf0e10cSrcweir {
519cdf0e10cSrcweir throw lang::IllegalArgumentException(
520*86e1cf34SPedro Giffuni OUSTR("InvalidTypeNameException occurred: ") + exc.Message,
521cdf0e10cSrcweir static_cast<OWeakObject *>(this), -1 /* unknown */ );
522cdf0e10cSrcweir }
523cdf0e10cSrcweir }
524cdf0e10cSrcweir }
525cdf0e10cSrcweir
526cdf0e10cSrcweir _aProviders.push_back( xElem );
527cdf0e10cSrcweir Reference< XComponent > xComp( xElem, UNO_QUERY );
528cdf0e10cSrcweir if (xComp.is())
529cdf0e10cSrcweir xComp->addEventListener( &_aEventListener );
530cdf0e10cSrcweir }
531cdf0e10cSrcweir //__________________________________________________________________________________________________
remove(const Any & rElement)532cdf0e10cSrcweir void SAL_CALL ManagerImpl::remove( const Any & rElement )
533cdf0e10cSrcweir throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
534cdf0e10cSrcweir {
535cdf0e10cSrcweir if (!rBHelper.bDisposed && !rBHelper.bInDispose)
536cdf0e10cSrcweir {
537cdf0e10cSrcweir Reference< XHierarchicalNameAccess > xElem;
538cdf0e10cSrcweir if (! (rElement >>= xElem))
539cdf0e10cSrcweir {
540cdf0e10cSrcweir throw IllegalArgumentException(
541cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("no type description provider given!") ),
542cdf0e10cSrcweir (XWeak *)(OWeakObject *)this, 0 );
543cdf0e10cSrcweir }
544cdf0e10cSrcweir
545cdf0e10cSrcweir MutexGuard aGuard( _aComponentMutex );
546cdf0e10cSrcweir ProviderVector::iterator iFind( find( _aProviders.begin(), _aProviders.end(), xElem ) );
547cdf0e10cSrcweir if (iFind == _aProviders.end())
548cdf0e10cSrcweir {
549cdf0e10cSrcweir throw NoSuchElementException(
550cdf0e10cSrcweir OUString( RTL_CONSTASCII_USTRINGPARAM("provider not found!") ),
551cdf0e10cSrcweir (XWeak *)(OWeakObject *)this );
552cdf0e10cSrcweir }
553cdf0e10cSrcweir _aProviders.erase( iFind );
554cdf0e10cSrcweir }
555cdf0e10cSrcweir
556cdf0e10cSrcweir Reference< XComponent > xComp;
557cdf0e10cSrcweir if (rElement >>= xComp)
558cdf0e10cSrcweir xComp->removeEventListener( &_aEventListener );
559cdf0e10cSrcweir }
560cdf0e10cSrcweir
561cdf0e10cSrcweir // XTypeDescriptionEnumerationAccess
562cdf0e10cSrcweir //__________________________________________________________________________________________________
563cdf0e10cSrcweir // virtual
564cdf0e10cSrcweir Reference< XTypeDescriptionEnumeration > SAL_CALL
createTypeDescriptionEnumeration(const OUString & moduleName,const Sequence<TypeClass> & types,TypeDescriptionSearchDepth depth)565cdf0e10cSrcweir ManagerImpl::createTypeDescriptionEnumeration(
566cdf0e10cSrcweir const OUString & moduleName,
567cdf0e10cSrcweir const Sequence< TypeClass > & types,
568cdf0e10cSrcweir TypeDescriptionSearchDepth depth )
569cdf0e10cSrcweir throw ( NoSuchTypeNameException,
570cdf0e10cSrcweir InvalidTypeNameException,
571cdf0e10cSrcweir RuntimeException )
572cdf0e10cSrcweir {
573cdf0e10cSrcweir MutexGuard aGuard( _aComponentMutex );
574cdf0e10cSrcweir
575cdf0e10cSrcweir TDEnumerationAccessStack aStack;
576cdf0e10cSrcweir ProviderVector::const_iterator it = _aProviders.begin();
577cdf0e10cSrcweir const ProviderVector::const_iterator end = _aProviders.end();
578cdf0e10cSrcweir while ( it != end )
579cdf0e10cSrcweir {
580cdf0e10cSrcweir Reference< XTypeDescriptionEnumerationAccess >xEnumAccess(
581cdf0e10cSrcweir (*it), UNO_QUERY );
582cdf0e10cSrcweir OSL_ENSURE( xEnumAccess.is(),
583cdf0e10cSrcweir "### no XTypeDescriptionEnumerationAccess!" );
584cdf0e10cSrcweir if ( xEnumAccess.is() )
585cdf0e10cSrcweir aStack.push( xEnumAccess );
586cdf0e10cSrcweir
587cdf0e10cSrcweir it++;
588cdf0e10cSrcweir }
589cdf0e10cSrcweir
590cdf0e10cSrcweir return Reference< XTypeDescriptionEnumeration >(
591cdf0e10cSrcweir new TypeDescriptionEnumerationImpl( moduleName,
592cdf0e10cSrcweir types,
593cdf0e10cSrcweir depth,
594cdf0e10cSrcweir aStack ) );
595cdf0e10cSrcweir }
596cdf0e10cSrcweir
597cdf0e10cSrcweir
598cdf0e10cSrcweir //##################################################################################################
599cdf0e10cSrcweir //##################################################################################################
600cdf0e10cSrcweir //##################################################################################################
601cdf0e10cSrcweir
602cdf0e10cSrcweir
603cdf0e10cSrcweir //==================================================================================================
604cdf0e10cSrcweir class SimpleTypeDescriptionImpl
605cdf0e10cSrcweir : public WeakImplHelper1< XTypeDescription >
606cdf0e10cSrcweir {
607cdf0e10cSrcweir TypeClass _eTC;
608cdf0e10cSrcweir OUString _aName;
609cdf0e10cSrcweir
610cdf0e10cSrcweir public:
SimpleTypeDescriptionImpl(TypeClass eTC,const OUString & rName)611cdf0e10cSrcweir SimpleTypeDescriptionImpl( TypeClass eTC, const OUString & rName )
612cdf0e10cSrcweir : _eTC( eTC )
613cdf0e10cSrcweir , _aName( rName )
614cdf0e10cSrcweir {}
615cdf0e10cSrcweir
616cdf0e10cSrcweir // XTypeDescription
617cdf0e10cSrcweir virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
618cdf0e10cSrcweir virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
619cdf0e10cSrcweir };
620cdf0e10cSrcweir
621cdf0e10cSrcweir // XTypeDescription
622cdf0e10cSrcweir //__________________________________________________________________________________________________
getTypeClass()623cdf0e10cSrcweir TypeClass SimpleTypeDescriptionImpl::getTypeClass()
624cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
625cdf0e10cSrcweir {
626cdf0e10cSrcweir return _eTC;
627cdf0e10cSrcweir }
628cdf0e10cSrcweir //__________________________________________________________________________________________________
getName()629cdf0e10cSrcweir OUString SimpleTypeDescriptionImpl::getName()
630cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
631cdf0e10cSrcweir {
632cdf0e10cSrcweir return _aName;
633cdf0e10cSrcweir }
634cdf0e10cSrcweir
635cdf0e10cSrcweir //==================================================================================================
636cdf0e10cSrcweir class SequenceTypeDescriptionImpl
637cdf0e10cSrcweir : public WeakImplHelper1< XIndirectTypeDescription >
638cdf0e10cSrcweir {
639cdf0e10cSrcweir Reference< XTypeDescription > _xElementTD;
640cdf0e10cSrcweir
641cdf0e10cSrcweir public:
SequenceTypeDescriptionImpl(const Reference<XTypeDescription> & xElementTD)642cdf0e10cSrcweir SequenceTypeDescriptionImpl( const Reference< XTypeDescription > & xElementTD )
643cdf0e10cSrcweir : _xElementTD( xElementTD )
644cdf0e10cSrcweir {}
645cdf0e10cSrcweir
646cdf0e10cSrcweir // XTypeDescription
647cdf0e10cSrcweir virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
648cdf0e10cSrcweir virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
649cdf0e10cSrcweir
650cdf0e10cSrcweir // XIndirectTypeDescription
651cdf0e10cSrcweir virtual Reference< XTypeDescription > SAL_CALL getReferencedType() throw(::com::sun::star::uno::RuntimeException);
652cdf0e10cSrcweir };
653cdf0e10cSrcweir
654cdf0e10cSrcweir // XTypeDescription
655cdf0e10cSrcweir //__________________________________________________________________________________________________
getTypeClass()656cdf0e10cSrcweir TypeClass SequenceTypeDescriptionImpl::getTypeClass()
657cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
658cdf0e10cSrcweir {
659cdf0e10cSrcweir return TypeClass_SEQUENCE;
660cdf0e10cSrcweir }
661cdf0e10cSrcweir //__________________________________________________________________________________________________
getName()662cdf0e10cSrcweir OUString SequenceTypeDescriptionImpl::getName()
663cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
664cdf0e10cSrcweir {
665cdf0e10cSrcweir return (OUString( RTL_CONSTASCII_USTRINGPARAM("[]") ) + _xElementTD->getName());
666cdf0e10cSrcweir }
667cdf0e10cSrcweir
668cdf0e10cSrcweir // XIndirectTypeDescription
669cdf0e10cSrcweir //__________________________________________________________________________________________________
getReferencedType()670cdf0e10cSrcweir Reference< XTypeDescription > SequenceTypeDescriptionImpl::getReferencedType()
671cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
672cdf0e10cSrcweir {
673cdf0e10cSrcweir return _xElementTD;
674cdf0e10cSrcweir }
675cdf0e10cSrcweir
676cdf0e10cSrcweir //==================================================================================================
677cdf0e10cSrcweir class ArrayTypeDescriptionImpl
678cdf0e10cSrcweir : public WeakImplHelper1< XArrayTypeDescription >
679cdf0e10cSrcweir {
680cdf0e10cSrcweir Reference< XTypeDescription > _xElementTD;
681cdf0e10cSrcweir Mutex _aDimensionMutex;
682cdf0e10cSrcweir sal_Int32 _nDimensions;
683cdf0e10cSrcweir Sequence< sal_Int32 > _seqDimensions;
684cdf0e10cSrcweir OUString _sDimensions;
685cdf0e10cSrcweir
686cdf0e10cSrcweir void initDimensions(const OUString& rSDimensions);
687cdf0e10cSrcweir public:
ArrayTypeDescriptionImpl(const Reference<XTypeDescription> & xElementTD,sal_Int32 nDimensions,const OUString & rSDimensions)688cdf0e10cSrcweir ArrayTypeDescriptionImpl( const Reference< XTypeDescription > & xElementTD,
689cdf0e10cSrcweir sal_Int32 nDimensions, const OUString& rSDimensions )
690cdf0e10cSrcweir : _xElementTD( xElementTD )
691cdf0e10cSrcweir , _nDimensions( nDimensions )
692cdf0e10cSrcweir , _seqDimensions( Sequence< sal_Int32 >(nDimensions) )
693cdf0e10cSrcweir , _sDimensions( rSDimensions )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir initDimensions( rSDimensions );
696cdf0e10cSrcweir }
~ArrayTypeDescriptionImpl()697cdf0e10cSrcweir virtual ~ArrayTypeDescriptionImpl() {}
698cdf0e10cSrcweir
699cdf0e10cSrcweir // XTypeDescription
700cdf0e10cSrcweir virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException);
701cdf0e10cSrcweir virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
702cdf0e10cSrcweir
703cdf0e10cSrcweir // XArrayTypeDescription
704cdf0e10cSrcweir virtual Reference< XTypeDescription > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException);
705cdf0e10cSrcweir virtual sal_Int32 SAL_CALL getNumberOfDimensions() throw(::com::sun::star::uno::RuntimeException);
706cdf0e10cSrcweir virtual Sequence< sal_Int32 > SAL_CALL getDimensions() throw(::com::sun::star::uno::RuntimeException);
707cdf0e10cSrcweir };
708cdf0e10cSrcweir //__________________________________________________________________________________________________
unicodeToInteger(sal_Int8 base,const sal_Unicode * s)709cdf0e10cSrcweir static sal_Int32 unicodeToInteger( sal_Int8 base, const sal_Unicode *s )
710cdf0e10cSrcweir {
711cdf0e10cSrcweir sal_Int32 r = 0;
712cdf0e10cSrcweir sal_Int32 negative = 0;
713cdf0e10cSrcweir
714cdf0e10cSrcweir if (*s == '-')
715cdf0e10cSrcweir {
716cdf0e10cSrcweir negative = 1;
717cdf0e10cSrcweir s++;
718cdf0e10cSrcweir }
719cdf0e10cSrcweir if (base == 8 && *s == '0')
720cdf0e10cSrcweir s++;
721cdf0e10cSrcweir else if (base == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X'))
722cdf0e10cSrcweir s += 2;
723cdf0e10cSrcweir
724cdf0e10cSrcweir for (; *s; s++)
725cdf0e10cSrcweir {
726cdf0e10cSrcweir if (*s <= '9' && *s >= '0')
727cdf0e10cSrcweir r = (r * base) + (*s - '0');
728cdf0e10cSrcweir else if (base > 10 && *s <= 'f' && *s >= 'a')
729cdf0e10cSrcweir r = (r * base) + (*s - 'a' + 10);
730cdf0e10cSrcweir else if (base > 10 && *s <= 'F' && *s >= 'A')
731cdf0e10cSrcweir r = (r * base) + (*s - 'A' + 10);
732cdf0e10cSrcweir else
733cdf0e10cSrcweir break;
734cdf0e10cSrcweir }
735cdf0e10cSrcweir if (negative) r *= -1;
736cdf0e10cSrcweir return r;
737cdf0e10cSrcweir }
738cdf0e10cSrcweir //__________________________________________________________________________________________________
initDimensions(const OUString & rSDimensions)739cdf0e10cSrcweir void ArrayTypeDescriptionImpl::initDimensions(const OUString& rSDimensions)
740cdf0e10cSrcweir {
741cdf0e10cSrcweir MutexGuard aGuard( _aDimensionMutex );
742cdf0e10cSrcweir
743cdf0e10cSrcweir sal_Int32 * pDimensions = _seqDimensions.getArray();
744cdf0e10cSrcweir OUString tmp(rSDimensions);
745cdf0e10cSrcweir sal_Unicode* p = (sal_Unicode*)tmp.getStr()+1;
746cdf0e10cSrcweir sal_Unicode* pOffset = p;
747cdf0e10cSrcweir sal_Int32 len = tmp.getLength() - 1 ;
748cdf0e10cSrcweir sal_Int32 i = 0;
749cdf0e10cSrcweir
750cdf0e10cSrcweir while ( len > 0)
751cdf0e10cSrcweir {
752cdf0e10cSrcweir pOffset++;
753cdf0e10cSrcweir if (*pOffset == ']')
754cdf0e10cSrcweir {
755cdf0e10cSrcweir *pOffset = '\0';
756cdf0e10cSrcweir pOffset += 2;
757cdf0e10cSrcweir len -= 3;
758cdf0e10cSrcweir pDimensions[i++] = unicodeToInteger(10, p);
759cdf0e10cSrcweir p = pOffset;
760cdf0e10cSrcweir } else
761cdf0e10cSrcweir len--;
762cdf0e10cSrcweir }
763cdf0e10cSrcweir }
764cdf0e10cSrcweir
765cdf0e10cSrcweir // XTypeDescription
766cdf0e10cSrcweir //__________________________________________________________________________________________________
getTypeClass()767cdf0e10cSrcweir TypeClass ArrayTypeDescriptionImpl::getTypeClass()
768cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
769cdf0e10cSrcweir {
770cdf0e10cSrcweir return TypeClass_ARRAY;
771cdf0e10cSrcweir }
772cdf0e10cSrcweir //__________________________________________________________________________________________________
getName()773cdf0e10cSrcweir OUString ArrayTypeDescriptionImpl::getName()
774cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
775cdf0e10cSrcweir {
776cdf0e10cSrcweir return (_xElementTD->getName() + _sDimensions);
777cdf0e10cSrcweir }
778cdf0e10cSrcweir
779cdf0e10cSrcweir // XArrayTypeDescription
780cdf0e10cSrcweir //__________________________________________________________________________________________________
getType()781cdf0e10cSrcweir Reference< XTypeDescription > ArrayTypeDescriptionImpl::getType()
782cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
783cdf0e10cSrcweir {
784cdf0e10cSrcweir return _xElementTD;
785cdf0e10cSrcweir }
786cdf0e10cSrcweir
787cdf0e10cSrcweir //__________________________________________________________________________________________________
getNumberOfDimensions()788cdf0e10cSrcweir sal_Int32 ArrayTypeDescriptionImpl::getNumberOfDimensions()
789cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
790cdf0e10cSrcweir {
791cdf0e10cSrcweir return _nDimensions;
792cdf0e10cSrcweir }
793cdf0e10cSrcweir
794cdf0e10cSrcweir //__________________________________________________________________________________________________
getDimensions()795cdf0e10cSrcweir Sequence< sal_Int32 > ArrayTypeDescriptionImpl::getDimensions()
796cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
797cdf0e10cSrcweir {
798cdf0e10cSrcweir return _seqDimensions;
799cdf0e10cSrcweir }
800cdf0e10cSrcweir
801cdf0e10cSrcweir //##################################################################################################
802cdf0e10cSrcweir //##################################################################################################
803cdf0e10cSrcweir //##################################################################################################
804cdf0e10cSrcweir
805cdf0e10cSrcweir
806cdf0e10cSrcweir //__________________________________________________________________________________________________
getSimpleType(const OUString & rName)807cdf0e10cSrcweir inline Any ManagerImpl::getSimpleType( const OUString & rName )
808cdf0e10cSrcweir {
809cdf0e10cSrcweir Any aRet;
810cdf0e10cSrcweir
811cdf0e10cSrcweir if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("string") ))
812cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_STRING, rName ) );
813cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("long") ))
814cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_LONG, rName ) );
815cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("unsigned long") ))
816cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_LONG, rName ) );
817cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("boolean") ))
818cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_BOOLEAN, rName ) );
819cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("char") ))
820cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_CHAR, rName ) );
821cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("byte") ))
822cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_BYTE, rName ) );
823cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("short") ))
824cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_SHORT, rName ) );
825cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("unsigned short") ))
826cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_SHORT, rName ) );
827cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("hyper") ))
828cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_HYPER, rName ) );
829cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("unsigned hyper") ))
830cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_HYPER, rName ) );
831cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("float") ))
832cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_FLOAT, rName ) );
833cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("double") ))
834cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_DOUBLE, rName ) );
835cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("any") ))
836cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_ANY, rName ) );
837cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("void") ))
838cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_VOID, rName ) );
839cdf0e10cSrcweir else if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("type") ))
840cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_TYPE, rName ) );
841cdf0e10cSrcweir
842cdf0e10cSrcweir return aRet;
843cdf0e10cSrcweir }
844cdf0e10cSrcweir
845cdf0e10cSrcweir namespace {
846cdf0e10cSrcweir
resolveTypedefs(Reference<XTypeDescription> const & type)847cdf0e10cSrcweir Reference< XTypeDescription > resolveTypedefs(
848cdf0e10cSrcweir Reference< XTypeDescription > const & type)
849cdf0e10cSrcweir {
850cdf0e10cSrcweir Reference< XTypeDescription > resolved(type);
851cdf0e10cSrcweir while (resolved->getTypeClass() == TypeClass_TYPEDEF) {
852cdf0e10cSrcweir resolved = Reference< XIndirectTypeDescription >(
853cdf0e10cSrcweir type, UNO_QUERY_THROW)->getReferencedType();
854cdf0e10cSrcweir }
855cdf0e10cSrcweir return resolved;
856cdf0e10cSrcweir }
857cdf0e10cSrcweir
isNonVoidNonExceptionType(Reference<XTypeDescription> const & type)858cdf0e10cSrcweir bool isNonVoidNonExceptionType(Reference< XTypeDescription > const & type) {
859cdf0e10cSrcweir switch (type->getTypeClass()) {
860cdf0e10cSrcweir case TypeClass_BOOLEAN:
861cdf0e10cSrcweir case TypeClass_BYTE:
862cdf0e10cSrcweir case TypeClass_SHORT:
863cdf0e10cSrcweir case TypeClass_UNSIGNED_SHORT:
864cdf0e10cSrcweir case TypeClass_LONG:
865cdf0e10cSrcweir case TypeClass_UNSIGNED_LONG:
866cdf0e10cSrcweir case TypeClass_HYPER:
867cdf0e10cSrcweir case TypeClass_UNSIGNED_HYPER:
868cdf0e10cSrcweir case TypeClass_FLOAT:
869cdf0e10cSrcweir case TypeClass_DOUBLE:
870cdf0e10cSrcweir case TypeClass_CHAR:
871cdf0e10cSrcweir case TypeClass_STRING:
872cdf0e10cSrcweir case TypeClass_TYPE:
873cdf0e10cSrcweir case TypeClass_ANY:
874cdf0e10cSrcweir case TypeClass_SEQUENCE:
875cdf0e10cSrcweir case TypeClass_ENUM:
876cdf0e10cSrcweir case TypeClass_STRUCT:
877cdf0e10cSrcweir case TypeClass_INTERFACE:
878cdf0e10cSrcweir return true;
879cdf0e10cSrcweir
880cdf0e10cSrcweir default:
881cdf0e10cSrcweir return false;
882cdf0e10cSrcweir }
883cdf0e10cSrcweir }
884cdf0e10cSrcweir
885cdf0e10cSrcweir class InstantiatedStruct: public WeakImplHelper1< XStructTypeDescription > {
886cdf0e10cSrcweir public:
887cdf0e10cSrcweir InstantiatedStruct(
888cdf0e10cSrcweir Reference< XStructTypeDescription > const & structType,
889cdf0e10cSrcweir std::vector< Reference< XTypeDescription > > const & arguments);
890cdf0e10cSrcweir
getTypeClass()891cdf0e10cSrcweir virtual TypeClass SAL_CALL getTypeClass() throw (RuntimeException)
892cdf0e10cSrcweir { return TypeClass_STRUCT; }
893cdf0e10cSrcweir
894cdf0e10cSrcweir virtual OUString SAL_CALL getName() throw (RuntimeException);
895cdf0e10cSrcweir
getBaseType()896cdf0e10cSrcweir virtual Reference< XTypeDescription > SAL_CALL getBaseType()
897cdf0e10cSrcweir throw (RuntimeException)
898cdf0e10cSrcweir { return m_struct->getBaseType(); }
899cdf0e10cSrcweir
900cdf0e10cSrcweir virtual Sequence< Reference< XTypeDescription > > SAL_CALL getMemberTypes()
901cdf0e10cSrcweir throw (RuntimeException);
902cdf0e10cSrcweir
getMemberNames()903cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getMemberNames()
904cdf0e10cSrcweir throw (RuntimeException)
905cdf0e10cSrcweir { return m_struct->getMemberNames(); }
906cdf0e10cSrcweir
getTypeParameters()907cdf0e10cSrcweir virtual Sequence< OUString > SAL_CALL getTypeParameters()
908cdf0e10cSrcweir throw (RuntimeException)
909cdf0e10cSrcweir { return Sequence< OUString >(); }
910cdf0e10cSrcweir
911cdf0e10cSrcweir virtual Sequence< Reference< XTypeDescription > > SAL_CALL
getTypeArguments()912cdf0e10cSrcweir getTypeArguments() throw (RuntimeException)
913cdf0e10cSrcweir { return m_arguments; }
914cdf0e10cSrcweir
915cdf0e10cSrcweir private:
916cdf0e10cSrcweir Reference< XStructTypeDescription > m_struct;
917cdf0e10cSrcweir Sequence< Reference< XTypeDescription > > m_arguments;
918cdf0e10cSrcweir };
919cdf0e10cSrcweir
InstantiatedStruct(Reference<XStructTypeDescription> const & structType,std::vector<Reference<XTypeDescription>> const & arguments)920cdf0e10cSrcweir InstantiatedStruct::InstantiatedStruct(
921cdf0e10cSrcweir Reference< XStructTypeDescription > const & structType,
922cdf0e10cSrcweir std::vector< Reference< XTypeDescription > > const & arguments):
923cdf0e10cSrcweir m_struct(structType),
924cdf0e10cSrcweir m_arguments(static_cast< sal_Int32 >(arguments.size()))
925cdf0e10cSrcweir {
926cdf0e10cSrcweir for (std::vector< Reference< XTypeDescription > >::size_type i = 0;
927cdf0e10cSrcweir i < arguments.size(); ++i)
928cdf0e10cSrcweir {
929cdf0e10cSrcweir m_arguments[static_cast< sal_Int32 >(i)] = arguments[i];
930cdf0e10cSrcweir }
931cdf0e10cSrcweir }
932cdf0e10cSrcweir
getName()933cdf0e10cSrcweir OUString InstantiatedStruct::getName() throw (RuntimeException) {
934cdf0e10cSrcweir OUStringBuffer buf(m_struct->getName());
935cdf0e10cSrcweir buf.append(static_cast< sal_Unicode >('<'));
936cdf0e10cSrcweir for (sal_Int32 i = 0; i < m_arguments.getLength(); ++i) {
937cdf0e10cSrcweir if (i != 0) {
938cdf0e10cSrcweir buf.append(static_cast< sal_Unicode >(','));
939cdf0e10cSrcweir }
940cdf0e10cSrcweir buf.append(m_arguments[i]->getName());
941cdf0e10cSrcweir }
942cdf0e10cSrcweir buf.append(static_cast< sal_Unicode >('>'));
943cdf0e10cSrcweir return buf.makeStringAndClear();
944cdf0e10cSrcweir }
945cdf0e10cSrcweir
getMemberTypes()946cdf0e10cSrcweir Sequence< Reference< XTypeDescription > > InstantiatedStruct::getMemberTypes()
947cdf0e10cSrcweir throw (RuntimeException)
948cdf0e10cSrcweir {
949cdf0e10cSrcweir Sequence< Reference< XTypeDescription > > types(m_struct->getMemberTypes());
950cdf0e10cSrcweir for (sal_Int32 i = 0; i < types.getLength(); ++i) {
951cdf0e10cSrcweir if (types[i]->getTypeClass() == TypeClass_UNKNOWN) {
952cdf0e10cSrcweir Sequence< OUString > parameters(m_struct->getTypeParameters());
953cdf0e10cSrcweir OSL_ASSERT(parameters.getLength() == m_arguments.getLength());
954cdf0e10cSrcweir for (sal_Int32 j = 0; j < parameters.getLength(); ++j) {
955cdf0e10cSrcweir if (parameters[j] == types[i]->getName()) {
956cdf0e10cSrcweir types[i] = m_arguments[j];
957cdf0e10cSrcweir break;
958cdf0e10cSrcweir }
959cdf0e10cSrcweir }
960cdf0e10cSrcweir }
961cdf0e10cSrcweir }
962cdf0e10cSrcweir return types;
963cdf0e10cSrcweir }
964cdf0e10cSrcweir
965cdf0e10cSrcweir }
966cdf0e10cSrcweir
getInstantiatedStruct(OUString const & name)967cdf0e10cSrcweir Reference< XTypeDescription > ManagerImpl::getInstantiatedStruct(
968cdf0e10cSrcweir OUString const & name)
969cdf0e10cSrcweir {
970cdf0e10cSrcweir sal_Int32 i = name.indexOf('<');
971cdf0e10cSrcweir OSL_ASSERT(i >= 0);
972cdf0e10cSrcweir Reference< XStructTypeDescription > structType(
973cdf0e10cSrcweir getByHierarchicalName(name.copy(0, i)), UNO_QUERY);
974cdf0e10cSrcweir std::vector< Reference< XTypeDescription > > args;
975cdf0e10cSrcweir bool good = structType.is();
976cdf0e10cSrcweir if (good) {
977cdf0e10cSrcweir do {
978cdf0e10cSrcweir ++i; // skip '<' or ','
979cdf0e10cSrcweir sal_Int32 j = i;
980cdf0e10cSrcweir for (sal_Int32 level = 0; j != name.getLength(); ++j) {
981cdf0e10cSrcweir sal_Unicode c = name[j];
982cdf0e10cSrcweir if (c == ',') {
983cdf0e10cSrcweir if (level == 0) {
984cdf0e10cSrcweir break;
985cdf0e10cSrcweir }
986cdf0e10cSrcweir } else if (c == '<') {
987cdf0e10cSrcweir ++level;
988cdf0e10cSrcweir } else if (c == '>') {
989cdf0e10cSrcweir if (level == 0) {
990cdf0e10cSrcweir break;
991cdf0e10cSrcweir }
992cdf0e10cSrcweir --level;
993cdf0e10cSrcweir }
994cdf0e10cSrcweir }
995cdf0e10cSrcweir if (j != name.getLength()) {
996cdf0e10cSrcweir Reference< XTypeDescription > type(
997cdf0e10cSrcweir getByHierarchicalName(name.copy(i, j - i)), UNO_QUERY);
998cdf0e10cSrcweir if (isNonVoidNonExceptionType(resolveTypedefs(type))) {
999cdf0e10cSrcweir args.push_back(type);
1000cdf0e10cSrcweir } else {
1001cdf0e10cSrcweir good = false;
1002cdf0e10cSrcweir break;
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir i = j;
1006cdf0e10cSrcweir } while (i != name.getLength() && name[i] != '>');
1007cdf0e10cSrcweir good = good && i == name.getLength() - 1
1008cdf0e10cSrcweir && name[i] == '>' && !args.empty();
1009cdf0e10cSrcweir }
1010cdf0e10cSrcweir // args.size() cannot exceed SAL_MAX_INT32, as each argument consumes at
1011cdf0e10cSrcweir // least one position within an rtl::OUString (which is no longer than
1012cdf0e10cSrcweir // SAL_MAX_INT32):
1013cdf0e10cSrcweir if (!good
1014cdf0e10cSrcweir || (args.size()
1015cdf0e10cSrcweir != sal::static_int_cast< sal_uInt32 >(
1016cdf0e10cSrcweir structType->getTypeParameters().getLength())))
1017cdf0e10cSrcweir {
1018cdf0e10cSrcweir throw NoSuchElementException(name, static_cast< OWeakObject * >(this));
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir return new InstantiatedStruct(structType, args);
1021cdf0e10cSrcweir }
1022cdf0e10cSrcweir
1023cdf0e10cSrcweir // XHierarchicalNameAccess
1024cdf0e10cSrcweir //__________________________________________________________________________________________________
getByHierarchicalName(const OUString & rName)1025cdf0e10cSrcweir Any ManagerImpl::getByHierarchicalName( const OUString & rName )
1026cdf0e10cSrcweir throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException)
1027cdf0e10cSrcweir {
1028cdf0e10cSrcweir Any aRet;
1029cdf0e10cSrcweir if (_bCaching)
1030cdf0e10cSrcweir aRet = _aElements.getValue( rName );
1031cdf0e10cSrcweir if (rName.getLength() && !aRet.hasValue())
1032cdf0e10cSrcweir {
1033cdf0e10cSrcweir sal_Int32 nIndex;
1034cdf0e10cSrcweir if (rName[0] == '[') // test for sequence
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir Reference< XTypeDescription > xElemType(
1037cdf0e10cSrcweir getByHierarchicalName( rName.copy( 2 ) ),
1038cdf0e10cSrcweir UNO_QUERY_THROW );
1039cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >(
1040cdf0e10cSrcweir new SequenceTypeDescriptionImpl( xElemType ) );
1041cdf0e10cSrcweir }
1042cdf0e10cSrcweir else if (rName[rName.getLength()-1] == ']') // test for array
1043cdf0e10cSrcweir {
1044cdf0e10cSrcweir sal_Int32 nIndex2 = 0, nTokens = 0;
1045cdf0e10cSrcweir do { rName.getToken( 0, '[', nIndex2 ); nTokens++; } while( nIndex2 != -1 );
1046cdf0e10cSrcweir sal_Int32 nDims = nTokens - 1;
1047cdf0e10cSrcweir sal_Int32 dimOffset = rName.indexOf('[');
1048cdf0e10cSrcweir Reference< XTypeDescription > xElemType(
1049cdf0e10cSrcweir getByHierarchicalName( rName.copy( 0, dimOffset ) ),
1050cdf0e10cSrcweir UNO_QUERY_THROW );
1051cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >(
1052cdf0e10cSrcweir new ArrayTypeDescriptionImpl(
1053cdf0e10cSrcweir xElemType, nDims, rName.copy(dimOffset) ) );
1054cdf0e10cSrcweir }
1055cdf0e10cSrcweir // test for interface member names:
1056cdf0e10cSrcweir else if ((nIndex = rName.indexOf( ':' )) >= 0)
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir Reference< XInterfaceTypeDescription > xIfaceTD(
1059cdf0e10cSrcweir getByHierarchicalName( rName.copy( 0, nIndex ) ),
1060cdf0e10cSrcweir UNO_QUERY_THROW );
1061cdf0e10cSrcweir const Sequence< Reference< XInterfaceMemberTypeDescription > > &
1062cdf0e10cSrcweir rMembers = xIfaceTD->getMembers();
1063cdf0e10cSrcweir const Reference< XInterfaceMemberTypeDescription > * pMembers =
1064cdf0e10cSrcweir rMembers.getConstArray();
1065cdf0e10cSrcweir
1066cdf0e10cSrcweir for ( sal_Int32 nPos = rMembers.getLength(); nPos--; )
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir if (rName == pMembers[nPos]->getName())
1069cdf0e10cSrcweir {
1070cdf0e10cSrcweir aRet <<= Reference< XTypeDescription >(
1071cdf0e10cSrcweir pMembers[nPos], UNO_QUERY_THROW );
1072cdf0e10cSrcweir break;
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir if (! aRet.hasValue())
1076cdf0e10cSrcweir {
1077cdf0e10cSrcweir // member not found:
1078cdf0e10cSrcweir throw NoSuchElementException(
1079cdf0e10cSrcweir rName, static_cast< OWeakObject * >(this) );
1080cdf0e10cSrcweir }
1081cdf0e10cSrcweir }
1082cdf0e10cSrcweir // test for instantiated polymorphic struct types:
1083cdf0e10cSrcweir else if (rName.indexOf('<') >= 0)
1084cdf0e10cSrcweir {
1085cdf0e10cSrcweir aRet <<= getInstantiatedStruct(rName);
1086cdf0e10cSrcweir }
1087cdf0e10cSrcweir else if (rName.indexOf( '.' ) < 0) // test for simple/ build in types
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir aRet = getSimpleType( rName );
1090cdf0e10cSrcweir }
1091cdf0e10cSrcweir
1092cdf0e10cSrcweir if (! aRet.hasValue())
1093cdf0e10cSrcweir {
1094cdf0e10cSrcweir // last, try callback chain
1095cdf0e10cSrcweir for ( ProviderVector::const_iterator iPos( _aProviders.begin() );
1096cdf0e10cSrcweir iPos != _aProviders.end(); ++iPos )
1097cdf0e10cSrcweir {
1098cdf0e10cSrcweir try
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir if ((aRet = (*iPos)->getByHierarchicalName(
1101cdf0e10cSrcweir rName )).hasValue())
1102cdf0e10cSrcweir {
1103cdf0e10cSrcweir break;
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir catch (NoSuchElementException &)
1107cdf0e10cSrcweir {
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir }
1111cdf0e10cSrcweir
1112cdf0e10cSrcweir // update cache
1113cdf0e10cSrcweir if (_bCaching && aRet.hasValue())
1114cdf0e10cSrcweir _aElements.setValue( rName, aRet );
1115cdf0e10cSrcweir }
1116cdf0e10cSrcweir
1117cdf0e10cSrcweir if (! aRet.hasValue())
1118cdf0e10cSrcweir {
1119cdf0e10cSrcweir throw NoSuchElementException(
1120cdf0e10cSrcweir rName, static_cast< OWeakObject * >(this) );
1121cdf0e10cSrcweir }
1122cdf0e10cSrcweir return aRet;
1123cdf0e10cSrcweir }
1124cdf0e10cSrcweir //__________________________________________________________________________________________________
hasByHierarchicalName(const OUString & rName)1125cdf0e10cSrcweir sal_Bool ManagerImpl::hasByHierarchicalName( const OUString & rName )
1126cdf0e10cSrcweir throw(::com::sun::star::uno::RuntimeException)
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir try
1129cdf0e10cSrcweir {
1130cdf0e10cSrcweir return getByHierarchicalName( rName ).hasValue();
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir catch (NoSuchElementException &)
1133cdf0e10cSrcweir {
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir return sal_False;
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir }
1138cdf0e10cSrcweir
1139cdf0e10cSrcweir namespace stoc_bootstrap
1140cdf0e10cSrcweir {
1141cdf0e10cSrcweir //==================================================================================================
ManagerImpl_create(Reference<XComponentContext> const & xContext)1142cdf0e10cSrcweir Reference< XInterface > SAL_CALL ManagerImpl_create(
1143cdf0e10cSrcweir Reference< XComponentContext > const & xContext )
1144cdf0e10cSrcweir SAL_THROW( (::com::sun::star::uno::Exception) )
1145cdf0e10cSrcweir {
1146cdf0e10cSrcweir sal_Int32 nCacheSize = CACHE_SIZE;
1147cdf0e10cSrcweir if (xContext.is()) {
1148cdf0e10cSrcweir xContext->getValueByName(
1149cdf0e10cSrcweir OUString(
1150cdf0e10cSrcweir RTL_CONSTASCII_USTRINGPARAM(
1151cdf0e10cSrcweir "/implementations/" IMPLNAME "/CacheSize"))) >>=
1152cdf0e10cSrcweir nCacheSize;
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir
1155cdf0e10cSrcweir return Reference< XInterface >( *new stoc_tdmgr::ManagerImpl( xContext, nCacheSize ) );
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir
1158cdf0e10cSrcweir }
1159cdf0e10cSrcweir
1160