diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-04-17 16:43:13 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-04-22 18:25:42 +0200 |
commit | 5275ed805a6e42f56c59d1c5876a7994625905a9 (patch) | |
tree | 0a802c2ce8bbf54c047ada5c303a403b51ba8136 /stoc | |
parent | clean up PythonTests (diff) | |
download | core-5275ed805a6e42f56c59d1c5876a7994625905a9.tar.gz core-5275ed805a6e42f56c59d1c5876a7994625905a9.zip |
Revert "Revert "WIP: Experimental new binary type.rdb format""
This reverts commit 67e69a55820f50973ca0de75ccab2bb07d0bada8, applying a band-
aid fix to cli_ure/source/climaker for now.
Conflicts:
stoc/inc/bootstrapservices.hxx
stoc/source/tdmanager/lrucache.hxx
stoc/source/tdmanager/tdmgr.cxx
stoc/source/tdmanager/tdmgr_common.hxx
stoc/source/tdmanager/tdmgr_tdenumeration.cxx
stoc/source/tdmanager/tdmgr_tdenumeration.hxx
Change-Id: Iae669985d0194f06fa349a4a39f0ebd230bc5d28
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/Library_bootstrap.mk | 3 | ||||
-rw-r--r-- | stoc/inc/bootstrapservices.hxx | 7 | ||||
-rw-r--r-- | stoc/source/bootstrap/services.cxx | 6 | ||||
-rw-r--r-- | stoc/source/tdmanager/lrucache.hxx | 242 | ||||
-rw-r--r-- | stoc/source/tdmanager/tdmgr.cxx | 1132 | ||||
-rw-r--r-- | stoc/source/tdmanager/tdmgr_check.cxx | 546 | ||||
-rw-r--r-- | stoc/source/tdmanager/tdmgr_common.hxx | 48 | ||||
-rw-r--r-- | stoc/source/tdmanager/tdmgr_tdenumeration.cxx | 170 | ||||
-rw-r--r-- | stoc/source/tdmanager/tdmgr_tdenumeration.hxx | 82 | ||||
-rw-r--r-- | stoc/util/bootstrap.component | 4 |
10 files changed, 0 insertions, 2240 deletions
diff --git a/stoc/Library_bootstrap.mk b/stoc/Library_bootstrap.mk index 0a08b174b7d9..7615a5c2026e 100644 --- a/stoc/Library_bootstrap.mk +++ b/stoc/Library_bootstrap.mk @@ -67,9 +67,6 @@ $(eval $(call gb_Library_add_exception_objects,bootstrap,\ stoc/source/security/permissions \ stoc/source/servicemanager/servicemanager \ stoc/source/simpleregistry/simpleregistry \ - stoc/source/tdmanager/tdmgr \ - stoc/source/tdmanager/tdmgr_check \ - stoc/source/tdmanager/tdmgr_tdenumeration \ )) # vim:set noet sw=4 ts=4: diff --git a/stoc/inc/bootstrapservices.hxx b/stoc/inc/bootstrapservices.hxx index 57b9ca907cb0..a754d13a543c 100644 --- a/stoc/inc/bootstrapservices.hxx +++ b/stoc/inc/bootstrapservices.hxx @@ -91,13 +91,6 @@ namespace stoc_bootstrap throw(::com::sun::star::uno::Exception); ::com::sun::star::uno::Sequence< OUString > rdbtdp_getSupportedServiceNames(); OUString rdbtdp_getImplementationName(); - - //tdmanager - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ManagerImpl_create( - const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ) - SAL_THROW( (::com::sun::star::uno::Exception) ); - ::com::sun::star::uno::Sequence< OUString > SAL_CALL tdmgr_getSupportedServiceNames(); - OUString SAL_CALL tdmgr_getImplementationName(); } // namespace /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/bootstrap/services.cxx b/stoc/source/bootstrap/services.cxx index 3157d2556f00..b35295facc7a 100644 --- a/stoc/source/bootstrap/services.cxx +++ b/stoc/source/bootstrap/services.cxx @@ -94,12 +94,6 @@ static struct ImplementationEntry g_entries[] = rdbtdp_getSupportedServiceNames, createSingleComponentFactory, 0, 0 }, - //tdmanager - { - ManagerImpl_create, tdmgr_getImplementationName, - tdmgr_getSupportedServiceNames, createSingleComponentFactory, - 0, 0 - }, //end { 0, 0, 0, 0, 0, 0 } }; diff --git a/stoc/source/tdmanager/lrucache.hxx b/stoc/source/tdmanager/lrucache.hxx deleted file mode 100644 index 0ab1712fb793..000000000000 --- a/stoc/source/tdmanager/lrucache.hxx +++ /dev/null @@ -1,242 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef _LRU_CACHE_HXX_ -#define _LRU_CACHE_HXX_ - -// __CACHE_DIAGNOSE forces cache size to 4 and works only for OUString keys -// #define __CACHE_DIAGNOSE 1 - -#include <osl/mutex.hxx> -#include "rtl/ustring.hxx" -#include "sal/log.hxx" - -#include <boost/unordered_map.hpp> - - -/** Implementation of a least recently used (lru) cache. - <br> - @author Daniel Boelzle -*/ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -class LRU_Cache -{ - struct CacheEntry - { - t_Key aKey; - t_Val aVal; - CacheEntry * pPred; - CacheEntry * pSucc; - }; - typedef ::boost::unordered_map< t_Key, CacheEntry *, t_KeyHash, t_KeyEqual > t_Key2Element; - - mutable ::osl::Mutex _aCacheMutex; - sal_Int32 _nCachedElements; - t_Key2Element _aKey2Element; - - CacheEntry * _pBlock; - mutable CacheEntry * _pHead; - mutable CacheEntry * _pTail; - inline void toFront( CacheEntry * pEntry ) const; - -public: - /** Constructor: - <br> - @param nCachedElements number of elements to be cached; default param set to 128 - */ - inline LRU_Cache( sal_Int32 nCachedElements = 128 ); - /** Destructor: releases all cached elements and keys. - <br> - */ - inline ~LRU_Cache(); - - /** Retrieves a value from the cache. Returns default constructed value, - if none was found. - <br> - @param rKey a key - @return value - */ - inline t_Val getValue( t_Key const & rKey ) const; - /** Sets a value to be cached for given key. - <br> - @param rKey a key - @param rValue a value - */ - inline void setValue( t_Key const & rKey, t_Val const & rValue ); - /** Tests whether a value is cached for given key. - <br> - @param rKey a key - @return true, if value is cached - */ - inline sal_Bool hasValue( t_Key const & rKey ) const; - /** Clears the cache, thus releasing all cached elements and keys. - <br> - */ - inline void clear(); -}; -//__________________________________________________________________________________________________ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::LRU_Cache( sal_Int32 nCachedElements ) -#ifdef __CACHE_DIAGNOSE - : _nCachedElements( 4 ) -#else - : _nCachedElements( nCachedElements ) -#endif - , _pBlock( 0 ) -{ - if (_nCachedElements > 0) - { - _pBlock = new CacheEntry[_nCachedElements]; - _pHead = _pBlock; - _pTail = _pBlock + _nCachedElements -1; - for ( sal_Int32 nPos = _nCachedElements; nPos--; ) - { - _pBlock[nPos].pPred = _pBlock + nPos -1; - _pBlock[nPos].pSucc = _pBlock + nPos +1; - } - } -} -//__________________________________________________________________________________________________ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -inline LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::~LRU_Cache() -{ - delete [] _pBlock; -} -//__________________________________________________________________________________________________ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::toFront( - CacheEntry * pEntry ) const -{ - if (pEntry != _pHead) - { - // cut out element - if (pEntry == _pTail) - { - _pTail = pEntry->pPred; - } - else - { - pEntry->pSucc->pPred = pEntry->pPred; - pEntry->pPred->pSucc = pEntry->pSucc; - } - // push to front - _pHead->pPred = pEntry; - pEntry->pSucc = _pHead; - _pHead = pEntry; - } -} -//__________________________________________________________________________________________________ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -inline sal_Bool LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::hasValue( - t_Key const & rKey ) const -{ - ::osl::MutexGuard aGuard( _aCacheMutex ); - typename t_Key2Element::const_iterator const iFind( _aKey2Element.find( rKey ) ); - return (iFind != _aKey2Element.end()); -} -//__________________________________________________________________________________________________ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -inline t_Val LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::getValue( - t_Key const & rKey ) const -{ - ::osl::MutexGuard aGuard( _aCacheMutex ); - const typename t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) ); - if (iFind != _aKey2Element.end()) - { - CacheEntry * pEntry = (*iFind).second; - toFront( pEntry ); -#ifdef __CACHE_DIAGNOSE - SAL_INFO("stoc.tdmanager", "> retrieved element \"" ); - SAL_INFO("stoc.tdmanager", "" << pEntry->aKey); - SAL_INFO("stoc.tdmanager", "\" from cache <" ); -#endif - return pEntry->aVal; - } - return t_Val(); -} -//__________________________________________________________________________________________________ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::setValue( - t_Key const & rKey, t_Val const & rValue ) -{ - if (_nCachedElements > 0) - { - ::osl::MutexGuard aGuard( _aCacheMutex ); - typename t_Key2Element::const_iterator const iFind( _aKey2Element.find( rKey ) ); - - CacheEntry * pEntry; - if (iFind == _aKey2Element.end()) - { - pEntry = _pTail; // erase last element -#ifdef __CACHE_DIAGNOSE - if (pEntry->aKey.getLength()) - { - SAL_INFO("stoc.tdmanager", "> kicking element \"" ); - SAL_INFO("stoc.tdmanager", "" << pEntry->aKey); - SAL_INFO("stoc.tdmanager", "\" from cache <" ); - } -#endif - _aKey2Element.erase( pEntry->aKey ); - _aKey2Element[ pEntry->aKey = rKey ] = pEntry; - } - else - { - pEntry = (*iFind).second; -#ifdef __CACHE_DIAGNOSE - SAL_INFO("stoc.tdmanager", "> replacing element \"" ); - SAL_INFO("stoc.tdmanager", "" << pEntry->aKey); - SAL_INFO("stoc.tdmanager", "\" in cache <" ); -#endif - } - pEntry->aVal = rValue; - toFront( pEntry ); - } -} -//__________________________________________________________________________________________________ -template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > -inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::clear() -{ - ::osl::MutexGuard aGuard( _aCacheMutex ); - _aKey2Element.clear(); - for ( sal_Int32 nPos = _nCachedElements; nPos--; ) - { - _pBlock[nPos].aKey = t_Key(); - _pBlock[nPos].aVal = t_Val(); - } -#ifdef __CACHE_DIAGNOSE - SAL_INFO("stoc.tdmanager", "> cleared cache <" ); -#endif -} - -//================================================================================================== -struct FctHashOUString : public ::std::unary_function< OUString const &, size_t > -{ - size_t operator()( OUString const & rKey ) const - { return (size_t)rKey.hashCode(); } -}; - -/** Template instance for OUString keys, Any values.<br> -*/ -typedef LRU_Cache< OUString, ::com::sun::star::uno::Any, - FctHashOUString, ::std::equal_to< OUString > > - LRU_CacheAnyByOUString; - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/tdmanager/tdmgr.cxx b/stoc/source/tdmanager/tdmgr.cxx deleted file mode 100644 index d7242910ac0b..000000000000 --- a/stoc/source/tdmanager/tdmgr.cxx +++ /dev/null @@ -1,1132 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/diagnose.h> -#include <osl/mutex.hxx> -#include "rtl/ustrbuf.hxx" -#include <cppuhelper/factory.hxx> -#include <cppuhelper/compbase5.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implementationentry.hxx> -#include "tdmgr_common.hxx" -#include "tdmgr_tdenumeration.hxx" -#include "lrucache.hxx" - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/lang/XTypeProvider.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/container/XHierarchicalNameAccess.hpp> -#include <com/sun/star/container/XSet.hpp> -#include <com/sun/star/container/XContentEnumerationAccess.hpp> -#include <com/sun/star/reflection/XTypeDescription.hpp> -#include <com/sun/star/reflection/XArrayTypeDescription.hpp> -#include <com/sun/star/reflection/XIndirectTypeDescription.hpp> -#include <com/sun/star/reflection/XInterfaceTypeDescription.hpp> -#include "com/sun/star/reflection/XStructTypeDescription.hpp" -#include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> -#include "com/sun/star/uno/RuntimeException.hpp" - -#include <algorithm> -#include <vector> - -using namespace std; -using namespace cppu; -using namespace osl; -using namespace com::sun::star; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::reflection; -using namespace com::sun::star::container; -using namespace com::sun::star::registry; - - -static const sal_Int32 CACHE_SIZE = 512; - -#define SERVICENAME "com.sun.star.reflection.TypeDescriptionManager" -#define IMPLNAME "com.sun.star.comp.stoc.TypeDescriptionManager" - -namespace stoc_bootstrap -{ -Sequence< OUString > SAL_CALL tdmgr_getSupportedServiceNames() -{ - Sequence< OUString > seqNames(1); - seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME)); - return seqNames; -} - -OUString SAL_CALL tdmgr_getImplementationName() -{ - return OUString(RTL_CONSTASCII_USTRINGPARAM(IMPLNAME)); -} -} - -namespace stoc_tdmgr -{ -typedef vector< Reference< XHierarchicalNameAccess > > ProviderVector; - -class EnumerationImpl; -class ManagerImpl; - -//================================================================================================== -class EventListenerImpl : public ImplHelper1< XEventListener > -{ - ManagerImpl * _pMgr; - -public: - EventListenerImpl( ManagerImpl * pMgr ) - : _pMgr( pMgr ) - {} - virtual ~EventListenerImpl(); - - // lifetime delegated to manager - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XEventListener - virtual void SAL_CALL disposing( const EventObject & rEvt ) throw(::com::sun::star::uno::RuntimeException); -}; - -EventListenerImpl::~EventListenerImpl() {} - -//================================================================================================== -class ManagerImpl - : public WeakComponentImplHelper5< XServiceInfo, - XSet, - XHierarchicalNameAccess, - XTypeDescriptionEnumerationAccess, - XInitialization > -{ - friend class EnumerationImpl; - friend class EventListenerImpl; - - Mutex _aComponentMutex; - Reference< XComponentContext > _xContext; - EventListenerImpl _aEventListener; - - // elements - sal_Bool _bCaching; - LRU_CacheAnyByOUString _aElements; - // provider chain - ProviderVector _aProviders; - - inline Any getSimpleType( const OUString & rName ); - - Reference< XTypeDescription > getInstantiatedStruct(OUString const & name); - -protected: - virtual void SAL_CALL disposing(); - -public: - ManagerImpl( Reference< XComponentContext > const & xContext, sal_Int32 nCacheSize ); - virtual ~ManagerImpl(); - - // XInitialization - virtual void SAL_CALL initialize( const Sequence< Any > & args ) throw (Exception, RuntimeException); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw(::com::sun::star::uno::RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); - - // XElementAccess - virtual Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException); - - // XEnumerationAccess - virtual Reference< XEnumeration > SAL_CALL createEnumeration() throw(::com::sun::star::uno::RuntimeException); - - // XSet - virtual sal_Bool SAL_CALL has( const Any & rElement ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL insert( const Any & rElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL remove( const Any & rElement ) throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - - // XHierarchicalNameAccess - virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException); - - // XTypeDescriptionEnumerationAccess - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::reflection::XTypeDescriptionEnumeration > SAL_CALL - createTypeDescriptionEnumeration( - const OUString& moduleName, - const ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::TypeClass >& types, - ::com::sun::star::reflection::TypeDescriptionSearchDepth depth ) - throw ( ::com::sun::star::reflection::NoSuchTypeNameException, - ::com::sun::star::reflection::InvalidTypeNameException, - ::com::sun::star::uno::RuntimeException ); -}; - -//================================================================================================== -class EnumerationImpl - : public WeakImplHelper1< XEnumeration > -{ - ManagerImpl * _pMgr; - size_t _nPos; - -public: - EnumerationImpl( ManagerImpl * pManager ); - virtual ~EnumerationImpl(); - - // XEnumeration - virtual sal_Bool SAL_CALL hasMoreElements() throw(::com::sun::star::uno::RuntimeException); - virtual Any SAL_CALL nextElement() throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); -}; - -//################################################################################################## - -// lifetime delegated to manager -//__________________________________________________________________________________________________ -void EventListenerImpl::acquire() throw() -{ - _pMgr->acquire(); -} -//__________________________________________________________________________________________________ -void EventListenerImpl::release() throw() -{ - _pMgr->release(); -} - -// XEventListener -//__________________________________________________________________________________________________ -void EventListenerImpl::disposing( const EventObject & rEvt ) - throw(::com::sun::star::uno::RuntimeException) -{ - _pMgr->remove( makeAny( rEvt.Source ) ); -} - -//################################################################################################## - -//__________________________________________________________________________________________________ -EnumerationImpl::EnumerationImpl( ManagerImpl * pManager ) - : _pMgr( pManager ) - , _nPos( 0 ) -{ - _pMgr->acquire(); -} -//__________________________________________________________________________________________________ -EnumerationImpl::~EnumerationImpl() -{ - _pMgr->release(); -} - -// XEnumeration -//__________________________________________________________________________________________________ -sal_Bool EnumerationImpl::hasMoreElements() - throw(::com::sun::star::uno::RuntimeException) -{ - MutexGuard aGuard( _pMgr->_aComponentMutex ); - return (_nPos < _pMgr->_aProviders.size()); -} -//__________________________________________________________________________________________________ -Any EnumerationImpl::nextElement() - throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) -{ - MutexGuard aGuard( _pMgr->_aComponentMutex ); - if (_nPos >= _pMgr->_aProviders.size()) - { - throw NoSuchElementException( - OUString("there is no further element!"), - (XWeak *)(OWeakObject *)this ); - } - return makeAny( _pMgr->_aProviders[_nPos++] ); -} - -//################################################################################################## - -//__________________________________________________________________________________________________ -ManagerImpl::ManagerImpl( - Reference< XComponentContext > const & xContext, sal_Int32 nCacheSize ) - : WeakComponentImplHelper5< - XServiceInfo, XSet, XHierarchicalNameAccess, - XTypeDescriptionEnumerationAccess, XInitialization >( _aComponentMutex ) - , _xContext( xContext ) - , _aEventListener( this ) - , _bCaching( sal_True ) - , _aElements( nCacheSize ) -{} -//__________________________________________________________________________________________________ -ManagerImpl::~ManagerImpl() -{ - OSL_ENSURE( _aProviders.empty(), "### still providers left!" ); - OSL_TRACE( "> TypeDescriptionManager shut down. <" ); -} -//__________________________________________________________________________________________________ -void ManagerImpl::disposing() -{ - // called on disposing the tdmgr instance (supposedly from context) - _bCaching = sal_False; - _aElements.clear(); - _xContext.clear(); - _aProviders.clear(); -} - -// XInitialization -//__________________________________________________________________________________________________ -void ManagerImpl::initialize( - const Sequence< Any > & args ) - throw (Exception, RuntimeException) -{ - // additional providers - Any const * pProviders = args.getConstArray(); - for ( sal_Int32 nPos = 0; nPos < args.getLength(); ++nPos ) - { - Reference< XHierarchicalNameAccess > xHA( pProviders[ nPos ], UNO_QUERY ); - OSL_ENSURE( xHA.is(), "### no td provider!" ); - - if (xHA.is()) - { - try - { - insert( makeAny( xHA ) ); - } - catch (const IllegalArgumentException &) - { - } - catch (const ElementExistException &) - { - } - } - } -} - -// XServiceInfo -//__________________________________________________________________________________________________ -OUString ManagerImpl::getImplementationName() - throw(::com::sun::star::uno::RuntimeException) -{ - return stoc_bootstrap::tdmgr_getImplementationName(); -} -//__________________________________________________________________________________________________ -sal_Bool ManagerImpl::supportsService( const OUString & rServiceName ) - throw(::com::sun::star::uno::RuntimeException) -{ - const Sequence< OUString > & rSNL = getSupportedServiceNames(); - const OUString * pArray = rSNL.getConstArray(); - for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) - { - if (pArray[nPos] == rServiceName) - return sal_True; - } - return sal_False; -} -//__________________________________________________________________________________________________ -Sequence< OUString > ManagerImpl::getSupportedServiceNames() - throw(::com::sun::star::uno::RuntimeException) -{ - return stoc_bootstrap::tdmgr_getSupportedServiceNames(); -} - -// XElementAccess -//__________________________________________________________________________________________________ -Type ManagerImpl::getElementType() - throw(::com::sun::star::uno::RuntimeException) -{ - return ::getCppuType( (const Reference< XHierarchicalNameAccess > *)0 ); -} -//__________________________________________________________________________________________________ -sal_Bool ManagerImpl::hasElements() - throw(::com::sun::star::uno::RuntimeException) -{ - MutexGuard aGuard( _aComponentMutex ); - return (!_aProviders.empty()); -} - -// XEnumerationAccess -//__________________________________________________________________________________________________ -Reference< XEnumeration > ManagerImpl::createEnumeration() - throw(::com::sun::star::uno::RuntimeException) -{ - return new EnumerationImpl( this ); -} - -// XSet -//__________________________________________________________________________________________________ -sal_Bool SAL_CALL ManagerImpl::has( const Any & rElement ) - throw(::com::sun::star::uno::RuntimeException) -{ - Reference< XHierarchicalNameAccess > xElem; - if (rElement >>= xElem) - { - MutexGuard aGuard( _aComponentMutex ); - return (find( _aProviders.begin(), _aProviders.end(), xElem ) != _aProviders.end()); - } - return sal_False; -} - -//__________________________________________________________________________________________________ -void SAL_CALL ManagerImpl::insert( const Any & rElement ) - throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException) -{ - // Passing in a sequence of type providers instead of a single one bypasses - // the consistency checks; it is used during bootstrap: - bool doCheck = false; - css::uno::Sequence< - css::uno::Reference< css::container::XHierarchicalNameAccess > > provs; - if (!(rElement >>= provs)) { - css::uno::Reference< css::container::XHierarchicalNameAccess > prov; - if (!(rElement >>= prov)) { - throw css::lang::IllegalArgumentException( - "no type description provider (or sequence thereof)", - static_cast< cppu::OWeakObject * >(this), 0); - } - doCheck = true; - provs.realloc(1); - provs[0] = prov; - } - - MutexGuard aGuard( _aComponentMutex ); - ProviderVector newProvs(_aProviders); - for (sal_Int32 i = 0; i != provs.getLength(); ++i) { - Reference< XHierarchicalNameAccess > xElem(provs[i]); - if (!xElem.is()) { - throw css::lang::IllegalArgumentException( - "null type description provider", - static_cast< cppu::OWeakObject * >(this), 0); - } - - if (doCheck) { - if (find( newProvs.begin(), newProvs.end(), xElem ) != newProvs.end()) - { - throw ElementExistException( - OUString("provider already inserted!"), - (XWeak *)(OWeakObject *)this ); - } - - // check whether all types are compatible, if possible: - Reference<reflection::XTypeDescriptionEnumerationAccess> xTDEnumAccess( - xElem, UNO_QUERY ); - OSL_ENSURE( xTDEnumAccess.is(), - "### providers ought to implement " - "reflection::XTypeDescriptionEnumerationAccess!" ); - if (xTDEnumAccess.is()) - { - try - { - TypeClass ar [] = { - TypeClass_ENUM, TypeClass_TYPEDEF, TypeClass_SEQUENCE, - TypeClass_STRUCT, TypeClass_EXCEPTION, - /* TypeClass_UNION, TypeClass_ARRAY not supported */ - TypeClass_INTERFACE, - TypeClass_SERVICE, - TypeClass_INTERFACE_METHOD, TypeClass_INTERFACE_ATTRIBUTE, - TypeClass_PROPERTY, TypeClass_CONSTANT, TypeClass_CONSTANTS, - TypeClass_SINGLETON - }; - Reference<reflection::XTypeDescriptionEnumeration> xTDEnum( - xTDEnumAccess->createTypeDescriptionEnumeration( - OUString() /* all modules */, - Sequence<TypeClass>( ar, ARLEN(ar) ), - reflection::TypeDescriptionSearchDepth_INFINITE ) ); - - while (xTDEnum->hasMoreElements()) - { - Reference<reflection::XTypeDescription> xNewTD; - try - { - xNewTD = xTDEnum->nextTypeDescription(); - } - catch (const container::NoSuchElementException & exc) - { - throw lang::IllegalArgumentException( - "NoSuchElementException occurred: " + - exc.Message, static_cast<OWeakObject *>(this), - -1 /* unknown */ ); - } - - try - { - OUString newName( xNewTD->getName() ); - Reference<reflection::XTypeDescription> xExistingTD( - getByHierarchicalName( newName ), UNO_QUERY ); - OSL_ASSERT( xExistingTD.is() ); - // existing, check whether compatible: - if (xExistingTD.is()) - { - try - { - check( xNewTD, xExistingTD ); - } - catch (const IncompatibleTypeException & exc) - { - throw lang::IllegalArgumentException( - "Rejecting types due to " - "incompatibility! " + exc.m_cause, - static_cast<OWeakObject *>(this), 0 ); - } - } - } - catch (const container::NoSuchElementException &) - { - // type not in: ok - } - } - } - catch (const reflection::NoSuchTypeNameException & exc) - { - throw lang::IllegalArgumentException( - "NoSuchTypeNameException occurred: " + exc.Message, - static_cast<OWeakObject *>(this), -1 /* unknown */ ); - } - catch (const reflection::InvalidTypeNameException & exc) - { - throw lang::IllegalArgumentException( - "InvalidTypeNameException occurred: " + exc.Message, - static_cast<OWeakObject *>(this), -1 /* unknown */ ); - } - } - } - newProvs.push_back( xElem ); - } - - _aProviders = newProvs; - for (sal_Int32 i = 0; i != provs.getLength(); ++i) { - Reference< XComponent > xComp( provs[i], UNO_QUERY ); - if (xComp.is()) - xComp->addEventListener( &_aEventListener ); - } -} -//__________________________________________________________________________________________________ -void SAL_CALL ManagerImpl::remove( const Any & rElement ) - throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) -{ - if (!rBHelper.bDisposed && !rBHelper.bInDispose) - { - Reference< XHierarchicalNameAccess > xElem; - if (! (rElement >>= xElem)) - { - throw IllegalArgumentException( - OUString("no type description provider given!"), - (XWeak *)(OWeakObject *)this, 0 ); - } - - MutexGuard aGuard( _aComponentMutex ); - ProviderVector::iterator iFind( find( _aProviders.begin(), _aProviders.end(), xElem ) ); - if (iFind == _aProviders.end()) - { - throw NoSuchElementException( - OUString("provider not found!"), - (XWeak *)(OWeakObject *)this ); - } - _aProviders.erase( iFind ); - } - - Reference< XComponent > xComp; - if (rElement >>= xComp) - xComp->removeEventListener( &_aEventListener ); -} - -// XTypeDescriptionEnumerationAccess -//__________________________________________________________________________________________________ -// virtual -Reference< XTypeDescriptionEnumeration > SAL_CALL -ManagerImpl::createTypeDescriptionEnumeration( - const OUString & moduleName, - const Sequence< TypeClass > & types, - TypeDescriptionSearchDepth depth ) - throw ( NoSuchTypeNameException, - InvalidTypeNameException, - RuntimeException ) -{ - MutexGuard aGuard( _aComponentMutex ); - - TDEnumerationAccessStack aStack; - ProviderVector::const_iterator it = _aProviders.begin(); - const ProviderVector::const_iterator end = _aProviders.end(); - while ( it != end ) - { - Reference< XTypeDescriptionEnumerationAccess >xEnumAccess( - (*it), UNO_QUERY ); - OSL_ENSURE( xEnumAccess.is(), - "### no XTypeDescriptionEnumerationAccess!" ); - if ( xEnumAccess.is() ) - aStack.push( xEnumAccess ); - - ++it; - } - - return Reference< XTypeDescriptionEnumeration >( - new TypeDescriptionEnumerationImpl( moduleName, - types, - depth, - aStack ) ); -} - - -//################################################################################################## -//################################################################################################## -//################################################################################################## - - -//================================================================================================== -class SimpleTypeDescriptionImpl - : public WeakImplHelper1< XTypeDescription > -{ - TypeClass _eTC; - OUString _aName; - -public: - SimpleTypeDescriptionImpl( TypeClass eTC, const OUString & rName ) - : _eTC( eTC ) - , _aName( rName ) - {} - - // XTypeDescription - virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); -}; - -// XTypeDescription -//__________________________________________________________________________________________________ -TypeClass SimpleTypeDescriptionImpl::getTypeClass() - throw(::com::sun::star::uno::RuntimeException) -{ - return _eTC; -} -//__________________________________________________________________________________________________ -OUString SimpleTypeDescriptionImpl::getName() - throw(::com::sun::star::uno::RuntimeException) -{ - return _aName; -} - -//================================================================================================== -class SequenceTypeDescriptionImpl - : public WeakImplHelper1< XIndirectTypeDescription > -{ - Reference< XTypeDescription > _xElementTD; - -public: - SequenceTypeDescriptionImpl( const Reference< XTypeDescription > & xElementTD ) - : _xElementTD( xElementTD ) - {} - - // XTypeDescription - virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); - - // XIndirectTypeDescription - virtual Reference< XTypeDescription > SAL_CALL getReferencedType() throw(::com::sun::star::uno::RuntimeException); -}; - -// XTypeDescription -//__________________________________________________________________________________________________ -TypeClass SequenceTypeDescriptionImpl::getTypeClass() - throw(::com::sun::star::uno::RuntimeException) -{ - return TypeClass_SEQUENCE; -} -//__________________________________________________________________________________________________ -OUString SequenceTypeDescriptionImpl::getName() - throw(::com::sun::star::uno::RuntimeException) -{ - return (OUString("[]") + _xElementTD->getName()); -} - -// XIndirectTypeDescription -//__________________________________________________________________________________________________ -Reference< XTypeDescription > SequenceTypeDescriptionImpl::getReferencedType() - throw(::com::sun::star::uno::RuntimeException) -{ - return _xElementTD; -} - -//================================================================================================== -class ArrayTypeDescriptionImpl - : public WeakImplHelper1< XArrayTypeDescription > -{ - Reference< XTypeDescription > _xElementTD; - Mutex _aDimensionMutex; - sal_Int32 _nDimensions; - Sequence< sal_Int32 > _seqDimensions; - OUString _sDimensions; - - void initDimensions(const OUString& rSDimensions); -public: - ArrayTypeDescriptionImpl( const Reference< XTypeDescription > & xElementTD, - sal_Int32 nDimensions, const OUString& rSDimensions ) - : _xElementTD( xElementTD ) - , _nDimensions( nDimensions ) - , _seqDimensions( Sequence< sal_Int32 >(nDimensions) ) - , _sDimensions( rSDimensions ) - { - initDimensions( rSDimensions ); - } - virtual ~ArrayTypeDescriptionImpl() {} - - // XTypeDescription - virtual TypeClass SAL_CALL getTypeClass() throw(::com::sun::star::uno::RuntimeException); - virtual OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException); - - // XArrayTypeDescription - virtual Reference< XTypeDescription > SAL_CALL getType() throw(::com::sun::star::uno::RuntimeException); - virtual sal_Int32 SAL_CALL getNumberOfDimensions() throw(::com::sun::star::uno::RuntimeException); - virtual Sequence< sal_Int32 > SAL_CALL getDimensions() throw(::com::sun::star::uno::RuntimeException); -}; -//__________________________________________________________________________________________________ -static sal_Int32 unicodeToInteger( sal_Int8 base, const sal_Unicode *s ) -{ - sal_Int32 r = 0; - sal_Int32 negative = 0; - - if (*s == '-') - { - negative = 1; - s++; - } - if (base == 8 && *s == '0') - s++; - else if (base == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')) - s += 2; - - for (; *s; s++) - { - if (*s <= '9' && *s >= '0') - r = (r * base) + (*s - '0'); - else if (base > 10 && *s <= 'f' && *s >= 'a') - r = (r * base) + (*s - 'a' + 10); - else if (base > 10 && *s <= 'F' && *s >= 'A') - r = (r * base) + (*s - 'A' + 10); - else - break; - } - if (negative) r *= -1; - return r; -} -//__________________________________________________________________________________________________ -void ArrayTypeDescriptionImpl::initDimensions(const OUString& rSDimensions) -{ - MutexGuard aGuard( _aDimensionMutex ); - - sal_Int32 * pDimensions = _seqDimensions.getArray(); - OUString tmp(rSDimensions); - sal_Unicode* p = (sal_Unicode*)tmp.getStr()+1; - sal_Unicode* pOffset = p; - sal_Int32 len = tmp.getLength() - 1 ; - sal_Int32 i = 0; - - while ( len > 0) - { - pOffset++; - if (*pOffset == ']') - { - *pOffset = '\0'; - pOffset += 2; - len -= 3; - pDimensions[i++] = unicodeToInteger(10, p); - p = pOffset; - } else - len--; - } -} - -// XTypeDescription -//__________________________________________________________________________________________________ -TypeClass ArrayTypeDescriptionImpl::getTypeClass() - throw(::com::sun::star::uno::RuntimeException) -{ - return TypeClass_ARRAY; -} -//__________________________________________________________________________________________________ -OUString ArrayTypeDescriptionImpl::getName() - throw(::com::sun::star::uno::RuntimeException) -{ - return (_xElementTD->getName() + _sDimensions); -} - -// XArrayTypeDescription -//__________________________________________________________________________________________________ -Reference< XTypeDescription > ArrayTypeDescriptionImpl::getType() - throw(::com::sun::star::uno::RuntimeException) -{ - return _xElementTD; -} - -//__________________________________________________________________________________________________ -sal_Int32 ArrayTypeDescriptionImpl::getNumberOfDimensions() - throw(::com::sun::star::uno::RuntimeException) -{ - return _nDimensions; -} - -//__________________________________________________________________________________________________ -Sequence< sal_Int32 > ArrayTypeDescriptionImpl::getDimensions() - throw(::com::sun::star::uno::RuntimeException) -{ - return _seqDimensions; -} - -//################################################################################################## -//################################################################################################## -//################################################################################################## - - -//__________________________________________________________________________________________________ -inline Any ManagerImpl::getSimpleType( const OUString & rName ) -{ - Any aRet; - - if ( rName == "string" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_STRING, rName ) ); - else if ( rName == "long" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_LONG, rName ) ); - else if ( rName == "unsigned long" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_LONG, rName ) ); - else if ( rName == "boolean" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_BOOLEAN, rName ) ); - else if ( rName == "char" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_CHAR, rName ) ); - else if ( rName == "byte" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_BYTE, rName ) ); - else if ( rName == "short" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_SHORT, rName ) ); - else if ( rName == "unsigned short" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_SHORT, rName ) ); - else if ( rName == "hyper" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_HYPER, rName ) ); - else if ( rName == "unsigned hyper" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_UNSIGNED_HYPER, rName ) ); - else if ( rName == "float" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_FLOAT, rName ) ); - else if ( rName == "double" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_DOUBLE, rName ) ); - else if ( rName == "any" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_ANY, rName ) ); - else if ( rName == "void" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_VOID, rName ) ); - else if ( rName == "type" ) - aRet <<= Reference< XTypeDescription >( new SimpleTypeDescriptionImpl( TypeClass_TYPE, rName ) ); - - return aRet; -} - -namespace { - -Reference< XTypeDescription > resolveTypedefs( - Reference< XTypeDescription > const & type) -{ - Reference< XTypeDescription > resolved(type); - while (resolved->getTypeClass() == TypeClass_TYPEDEF) { - resolved = Reference< XIndirectTypeDescription >( - type, UNO_QUERY_THROW)->getReferencedType(); - } - return resolved; -} - -bool isNonVoidNonExceptionType(Reference< XTypeDescription > const & type) { - switch (type->getTypeClass()) { - case TypeClass_BOOLEAN: - case TypeClass_BYTE: - case TypeClass_SHORT: - case TypeClass_UNSIGNED_SHORT: - case TypeClass_LONG: - case TypeClass_UNSIGNED_LONG: - case TypeClass_HYPER: - case TypeClass_UNSIGNED_HYPER: - case TypeClass_FLOAT: - case TypeClass_DOUBLE: - case TypeClass_CHAR: - case TypeClass_STRING: - case TypeClass_TYPE: - case TypeClass_ANY: - case TypeClass_SEQUENCE: - case TypeClass_ENUM: - case TypeClass_STRUCT: - case TypeClass_INTERFACE: - return true; - - default: - return false; - } -} - -class InstantiatedStruct: public WeakImplHelper1< XStructTypeDescription > { -public: - InstantiatedStruct( - Reference< XStructTypeDescription > const & structType, - std::vector< Reference< XTypeDescription > > const & arguments); - - virtual TypeClass SAL_CALL getTypeClass() throw (RuntimeException) - { return TypeClass_STRUCT; } - - virtual OUString SAL_CALL getName() throw (RuntimeException); - - virtual Reference< XTypeDescription > SAL_CALL getBaseType() - throw (RuntimeException) - { return m_struct->getBaseType(); } - - virtual Sequence< Reference< XTypeDescription > > SAL_CALL getMemberTypes() - throw (RuntimeException); - - virtual Sequence< OUString > SAL_CALL getMemberNames() - throw (RuntimeException) - { return m_struct->getMemberNames(); } - - virtual Sequence< OUString > SAL_CALL getTypeParameters() - throw (RuntimeException) - { return Sequence< OUString >(); } - - virtual Sequence< Reference< XTypeDescription > > SAL_CALL - getTypeArguments() throw (RuntimeException) - { return m_arguments; } - -private: - Reference< XStructTypeDescription > m_struct; - Sequence< Reference< XTypeDescription > > m_arguments; -}; - -InstantiatedStruct::InstantiatedStruct( - Reference< XStructTypeDescription > const & structType, - std::vector< Reference< XTypeDescription > > const & arguments): - m_struct(structType), - m_arguments(static_cast< sal_Int32 >(arguments.size())) -{ - for (std::vector< Reference< XTypeDescription > >::size_type i = 0; - i < arguments.size(); ++i) - { - m_arguments[static_cast< sal_Int32 >(i)] = arguments[i]; - } -} - -OUString InstantiatedStruct::getName() throw (RuntimeException) { - OUStringBuffer buf(m_struct->getName()); - buf.append(static_cast< sal_Unicode >('<')); - for (sal_Int32 i = 0; i < m_arguments.getLength(); ++i) { - if (i != 0) { - buf.append(static_cast< sal_Unicode >(',')); - } - buf.append(m_arguments[i]->getName()); - } - buf.append(static_cast< sal_Unicode >('>')); - return buf.makeStringAndClear(); -} - -Sequence< Reference< XTypeDescription > > InstantiatedStruct::getMemberTypes() - throw (RuntimeException) -{ - Sequence< Reference< XTypeDescription > > types(m_struct->getMemberTypes()); - for (sal_Int32 i = 0; i < types.getLength(); ++i) { - if (types[i]->getTypeClass() == TypeClass_UNKNOWN) { - Sequence< OUString > parameters(m_struct->getTypeParameters()); - OSL_ASSERT(parameters.getLength() == m_arguments.getLength()); - for (sal_Int32 j = 0; j < parameters.getLength(); ++j) { - if (parameters[j] == types[i]->getName()) { - types[i] = m_arguments[j]; - break; - } - } - } - } - return types; -} - -} - -Reference< XTypeDescription > ManagerImpl::getInstantiatedStruct( - OUString const & name) -{ - sal_Int32 i = name.indexOf('<'); - OSL_ASSERT(i >= 0); - Reference< XStructTypeDescription > structType( - getByHierarchicalName(name.copy(0, i)), UNO_QUERY); - std::vector< Reference< XTypeDescription > > args; - bool good = structType.is(); - if (good) { - do { - ++i; // skip '<' or ',' - sal_Int32 j = i; - for (sal_Int32 level = 0; j != name.getLength(); ++j) { - sal_Unicode c = name[j]; - if (c == ',') { - if (level == 0) { - break; - } - } else if (c == '<') { - ++level; - } else if (c == '>') { - if (level == 0) { - break; - } - --level; - } - } - if (j != name.getLength()) { - Reference< XTypeDescription > type( - getByHierarchicalName(name.copy(i, j - i)), UNO_QUERY); - if (isNonVoidNonExceptionType(resolveTypedefs(type))) { - args.push_back(type); - } else { - good = false; - break; - } - } - i = j; - } while (i != name.getLength() && name[i] != '>'); - good = good && i == name.getLength() - 1 - && name[i] == '>' && !args.empty(); - } - // args.size() cannot exceed SAL_MAX_INT32, as each argument consumes at - // least one position within an OUString (which is no longer than - // SAL_MAX_INT32): - if (!good - || (args.size() - != sal::static_int_cast< sal_uInt32 >( - structType->getTypeParameters().getLength()))) - { - throw NoSuchElementException(name, static_cast< OWeakObject * >(this)); - } - return new InstantiatedStruct(structType, args); -} - -// XHierarchicalNameAccess -//__________________________________________________________________________________________________ -Any ManagerImpl::getByHierarchicalName( const OUString & rName ) - throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException) -{ - Any aRet; - if (_bCaching) - aRet = _aElements.getValue( rName ); - if (!rName.isEmpty() && !aRet.hasValue()) - { - sal_Int32 nIndex; - if (rName[0] == '[') // test for sequence - { - Reference< XTypeDescription > xElemType( - getByHierarchicalName( rName.copy( 2 ) ), - UNO_QUERY_THROW ); - aRet <<= Reference< XTypeDescription >( - new SequenceTypeDescriptionImpl( xElemType ) ); - } - else if (rName[rName.getLength()-1] == ']') // test for array - { - sal_Int32 nIndex2 = 0, nTokens = 0; - do { rName.getToken( 0, '[', nIndex2 ); nTokens++; } while( nIndex2 != -1 ); - sal_Int32 nDims = nTokens - 1; - sal_Int32 dimOffset = rName.indexOf('['); - Reference< XTypeDescription > xElemType( - getByHierarchicalName( rName.copy( 0, dimOffset ) ), - UNO_QUERY_THROW ); - aRet <<= Reference< XTypeDescription >( - new ArrayTypeDescriptionImpl( - xElemType, nDims, rName.copy(dimOffset) ) ); - } - // test for interface member names: - else if ((nIndex = rName.indexOf( ':' )) >= 0) - { - Reference< XInterfaceTypeDescription > xIfaceTD( - getByHierarchicalName( rName.copy( 0, nIndex ) ), - UNO_QUERY_THROW ); - const Sequence< Reference< XInterfaceMemberTypeDescription > > & - rMembers = xIfaceTD->getMembers(); - const Reference< XInterfaceMemberTypeDescription > * pMembers = - rMembers.getConstArray(); - - for ( sal_Int32 nPos = rMembers.getLength(); nPos--; ) - { - if (rName == pMembers[nPos]->getName()) - { - aRet <<= Reference< XTypeDescription >( - pMembers[nPos], UNO_QUERY_THROW ); - break; - } - } - if (! aRet.hasValue()) - { - // member not found: - throw NoSuchElementException( - rName, static_cast< OWeakObject * >(this) ); - } - } - // test for instantiated polymorphic struct types: - else if (rName.indexOf('<') >= 0) - { - aRet <<= getInstantiatedStruct(rName); - } - else if (rName.indexOf( '.' ) < 0) // test for simple/ build in types - { - aRet = getSimpleType( rName ); - } - - if (! aRet.hasValue()) - { - // last, try callback chain - for ( ProviderVector::const_iterator iPos( _aProviders.begin() ); - iPos != _aProviders.end(); ++iPos ) - { - if ( (*iPos)->hasByHierarchicalName( rName ) ) - { - aRet = (*iPos)->getByHierarchicalName( rName ); - break; - } - } - } - - // update cache - if (_bCaching && aRet.hasValue()) - _aElements.setValue( rName, aRet ); - } - - if (! aRet.hasValue()) - { - throw NoSuchElementException( - rName, static_cast< OWeakObject * >(this) ); - } - return aRet; -} -//__________________________________________________________________________________________________ -sal_Bool ManagerImpl::hasByHierarchicalName( const OUString & rName ) - throw(::com::sun::star::uno::RuntimeException) -{ - try - { - return getByHierarchicalName( rName ).hasValue(); - } - catch (const NoSuchElementException &) - { - } - return sal_False; -} -} - -namespace stoc_bootstrap -{ -//================================================================================================== -Reference< XInterface > SAL_CALL ManagerImpl_create( - Reference< XComponentContext > const & xContext ) - SAL_THROW( (::com::sun::star::uno::Exception) ) -{ - sal_Int32 nCacheSize = CACHE_SIZE; - if (xContext.is()) { - xContext->getValueByName( - OUString( - RTL_CONSTASCII_USTRINGPARAM( - "/implementations/" IMPLNAME "/CacheSize"))) >>= - nCacheSize; - } - - return Reference< XInterface >( *new stoc_tdmgr::ManagerImpl( xContext, nCacheSize ) ); -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/tdmanager/tdmgr_check.cxx b/stoc/source/tdmanager/tdmgr_check.cxx deleted file mode 100644 index 2ffb80a32c97..000000000000 --- a/stoc/source/tdmanager/tdmgr_check.cxx +++ /dev/null @@ -1,546 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - - -#include "tdmgr_common.hxx" -#include "rtl/ustrbuf.hxx" -#include "typelib/typedescription.h" -#include "com/sun/star/beans/PropertyAttribute.hpp" -#include "com/sun/star/reflection/XConstantsTypeDescription.hpp" -#include "com/sun/star/reflection/XIndirectTypeDescription.hpp" -#include "com/sun/star/reflection/XEnumTypeDescription.hpp" -#include "com/sun/star/reflection/XStructTypeDescription.hpp" -#include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp" -#include "com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp" -#include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp" -#include "com/sun/star/reflection/XServiceTypeDescription2.hpp" -#include "com/sun/star/reflection/XSingletonTypeDescription2.hpp" - - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::stoc_tdmgr; - -namespace { - -OUString getTypeClassName( TypeClass tc ) -{ - typelib_EnumTypeDescription * typeDescr = 0; - OUString name = "com.sun.star.uno.TypeClass"; - typelib_typedescription_getByName( - reinterpret_cast<typelib_TypeDescription **>(&typeDescr), name.pData ); - OSL_ASSERT( typeDescr != 0 ); - if (typeDescr == 0) - return "Cannot get type description of " + name; - typelib_typedescription_complete( - reinterpret_cast<typelib_TypeDescription **>(&typeDescr) ); - - sal_Int32 const * pValues = typeDescr->pEnumValues; - sal_Int32 nPos = typeDescr->nEnumValues; - while (nPos--) - { - if (pValues[ nPos ] == (sal_Int32) tc) - break; - } - if (nPos >= 0) - name = typeDescr->ppEnumNames[ nPos ]; - else - name = "unknown TypeClass value: " + - OUString::valueOf( (sal_Int32) tc ); - - typelib_typedescription_release( - reinterpret_cast<typelib_TypeDescription *>(typeDescr) ); - return name; -} - -OUString getPropertyFlagsAsString( sal_Int16 attributes ) -{ - OUStringBuffer buf; - if ((attributes & beans::PropertyAttribute::MAYBEVOID) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEVOID, ") ); - if ((attributes & beans::PropertyAttribute::BOUND) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("BOUND, ") ); - if ((attributes & beans::PropertyAttribute::CONSTRAINED) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("CONSTRAINED, ") ); - if ((attributes & beans::PropertyAttribute::TRANSIENT) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("TRANSIENT, ") ); - if ((attributes & beans::PropertyAttribute::READONLY) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("READONLY, ") ); - if ((attributes & beans::PropertyAttribute::MAYBEAMBIGUOUS) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEAMBIGUOUS, ") ); - if ((attributes & beans::PropertyAttribute::MAYBEDEFAULT) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("MAYBEDEFAULT, ") ); - if ((attributes & beans::PropertyAttribute::REMOVABLE) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("REMOVABLE, ") ); - if ((attributes & beans::PropertyAttribute::OPTIONAL) != 0) - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("OPTIONAL") ); - else if (buf.getLength() > 0) - buf.setLength( buf.getLength() - 2 ); // truncate ", " - return buf.makeStringAndClear(); -} - -void typeError( OUString const & msg, OUString const & context ) -{ - OUStringBuffer buf; - if (!context.isEmpty()) { - buf.append( static_cast<sal_Unicode>('[') ); - buf.append( context ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("] ") ); - } - buf.append( msg ); - throw IncompatibleTypeException( buf.makeStringAndClear() ); -} - -template<typename T> -void checkSeq( Sequence< Reference<T> > const & newTypes, - Sequence< Reference<T> > const & existingTypes, - OUString const & context, - bool optionalMode = false ) -{ - sal_Int32 len = newTypes.getLength(); - if (len != existingTypes.getLength()) - { - if (!optionalMode || len < newTypes.getLength()) - typeError( "Different number of types!", context ); - len = existingTypes.getLength(); - } - - Reference<T> const * pNewTypes = newTypes.getConstArray(); - Reference<T> const * pExistingTypes = existingTypes.getConstArray(); - for ( sal_Int32 pos = 0; pos < len; ++pos ) - { - OUStringBuffer buf; - buf.append( context ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", position ") ); - buf.append( pos ); - check( pNewTypes[pos].get(), pExistingTypes[pos].get(), - buf.makeStringAndClear() ); - } -} - -void checkEnum( - Reference<reflection::XEnumTypeDescription> const & xNewTD, - Reference<reflection::XEnumTypeDescription> const & xExistingTD ) -{ - if (xNewTD->getEnumNames() != xExistingTD->getEnumNames()) - typeError( "ENUM names don't match!", xNewTD->getName() ); - if (xNewTD->getEnumValues() != xExistingTD->getEnumValues()) - typeError( "ENUM values don't match!", xNewTD->getName() ); -} - -void checkStruct( - Reference<reflection::XCompoundTypeDescription> const & xNewTD, - Reference<reflection::XCompoundTypeDescription> const & xExistingTD ) -{ - check( xNewTD->getBaseType(), xExistingTD->getBaseType(), - xNewTD->getName() + ", base type" ); - checkSeq( xNewTD->getMemberTypes(), xExistingTD->getMemberTypes(), - xNewTD->getName() + ", member types" ); - - if (xNewTD->getMemberNames() != xExistingTD->getMemberNames()) - typeError( "Different member names!", xNewTD->getName() ); - - if (xNewTD->getTypeClass() == TypeClass_STRUCT) - { - Reference<reflection::XStructTypeDescription> xNewStructTD( - xNewTD, UNO_QUERY ); - Reference<reflection::XStructTypeDescription> xExistingStructTD( - xExistingTD, UNO_QUERY ); - if (xNewStructTD.is() && xExistingStructTD.is()) - { - if (xNewStructTD->getTypeParameters() != - xExistingStructTD->getTypeParameters()) - typeError( "Different type parameters of instantiated " - "polymorphic STRUCT!", xNewTD->getName() ); - checkSeq( xNewStructTD->getTypeArguments(), - xExistingStructTD->getTypeArguments(), - xNewTD->getName() + ", argument types" ); - } - else if (xNewStructTD.is() || xExistingStructTD.is()) - typeError( "Mixing polymorphic STRUCT types " - "with non-polymorphic!", xNewTD->getName() ); - } -} - -void checkInterface( - Reference<reflection::XInterfaceTypeDescription2> const & xNewTD, - Reference<reflection::XInterfaceTypeDescription2> const & xExistingTD ) -{ - checkSeq( xNewTD->getBaseTypes(), xExistingTD->getBaseTypes(), - xNewTD->getName() + ", base types" ); - checkSeq(xNewTD->getOptionalBaseTypes(),xExistingTD->getOptionalBaseTypes(), - xNewTD->getName() + ", optional base types" ); - checkSeq( xNewTD->getMembers(), xExistingTD->getMembers(), - xNewTD->getName() + ", members" ); -} - -void checkRestParam( Reference<reflection::XParameter> const & xNewParam, - Reference<reflection::XParameter> const & xExistingParam, - OUString const & context ) -{ - if (xNewParam->isRestParameter() != xExistingParam->isRestParameter()) - typeError( "Different ... parameters specified!", context ); -} - -void checkRestParam( - SAL_UNUSED_PARAMETER Reference<reflection::XMethodParameter> const &, - SAL_UNUSED_PARAMETER Reference<reflection::XMethodParameter> const &, - SAL_UNUSED_PARAMETER OUString const & ) -{} - -template<typename T> -void checkParameters( Sequence< Reference<T> > const & newParams, - Sequence< Reference<T> > const & existingParams, - OUString const & context_ ) -{ - sal_Int32 len = newParams.getLength(); - if (len != existingParams.getLength()) - typeError( "Different number of parameters!", context_ ); - Reference<T> const * pNewParams = newParams.getConstArray(); - Reference<T> const * pExistingParams = existingParams.getConstArray(); - for ( sal_Int32 pos = 0; pos < len; ++pos ) - { - Reference<T> const & xNewParam = pNewParams[pos]; - Reference<T> const & xExistingParam = pExistingParams[pos]; - - OUStringBuffer buf; - buf.append( context_ ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", parameter ") ); - buf.append( pos ); - OSL_ASSERT( pos == xNewParam->getPosition() && - pos == xExistingParam->getPosition() ); - OUString context( buf.makeStringAndClear() ); - - if (xNewParam->getName() != xExistingParam->getName()) - { - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Name differs: ") ); - buf.append( xNewParam->getName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); - buf.append( xExistingParam->getName() ); - typeError( buf.makeStringAndClear(), context ); - } - check( xNewParam->getType(), xExistingParam->getType(), context ); - - if (xNewParam->isIn() != xExistingParam->isIn()) - typeError( "IN attribute differs!", context ); - if (xNewParam->isOut() != xExistingParam->isOut()) - typeError( "OUT attribute differs!", context ); - checkRestParam( xNewParam, xExistingParam, context ); - } -} - -static void checkMethod( - Reference<reflection::XInterfaceMethodTypeDescription> const & xNewTD, - Reference<reflection::XInterfaceMethodTypeDescription> const & xExistingTD ) -{ - check( xNewTD->getReturnType(), xExistingTD->getReturnType(), - xNewTD->getName() ); - - if (xNewTD->isOneway() != xExistingTD->isOneway()) - typeError( "Methods have differing OneWay attribute!", - xNewTD->getName() ); - - checkParameters( xNewTD->getParameters(), xExistingTD->getParameters(), - xNewTD->getName() ); - - checkSeq( xNewTD->getExceptions(), xExistingTD->getExceptions(), - xNewTD->getName() + ", declared exceptions" ); -} - -void checkAttribute( - Reference<reflection::XInterfaceAttributeTypeDescription2> const & xNewTD, - Reference<reflection::XInterfaceAttributeTypeDescription2> - const & xExistingTD ) -{ - if (xNewTD->isReadOnly() != xExistingTD->isReadOnly()) - typeError( "ReadOnly attribute differs!", xNewTD->getName() ); - - check( xNewTD->getType(), xExistingTD->getType(), - xNewTD->getName() + ", attribute type" ); - - if (xNewTD->isBound() != xExistingTD->isBound()) - typeError( "Bound attribute differs!", xNewTD->getName() ); - - checkSeq( xNewTD->getGetExceptions(), xExistingTD->getGetExceptions(), - xNewTD->getName() + ", getter exceptions" ); - checkSeq( xNewTD->getSetExceptions(), xExistingTD->getSetExceptions(), - xNewTD->getName() + ", setter exceptions" ); -} - -void checkProperty( - Reference<reflection::XPropertyTypeDescription> const & xNewTD, - Reference<reflection::XPropertyTypeDescription> const & xExistingTD ) -{ - if (xNewTD->getPropertyFlags() != xExistingTD->getPropertyFlags()) - { - OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "Different set of property flags: { ") ); - buf.append( getPropertyFlagsAsString( - xNewTD->getPropertyFlags() ) ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" } (new), { ") ); - buf.append( getPropertyFlagsAsString( - xExistingTD->getPropertyFlags() ) ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" } (existing)!") ); - typeError( buf.makeStringAndClear(), xNewTD->getName() ); - } - - check( xNewTD->getPropertyTypeDescription(), - xExistingTD->getPropertyTypeDescription(), - xNewTD->getName() ); -} - -void checkSingleton( - Reference<reflection::XSingletonTypeDescription2> const & xNewTD, - Reference<reflection::XSingletonTypeDescription2> const & xExistingTD ) -{ - sal_Bool ifaceBased = xNewTD->isInterfaceBased(); - if (ifaceBased != xExistingTD->isInterfaceBased()) - typeError( - "Mixing interface and NON-interface based singletons!", - xNewTD->getName() ); - if (ifaceBased) - check( xNewTD->getInterface(), xExistingTD->getInterface(), - xNewTD->getName() ); - else - check( xNewTD->getService().get(), xExistingTD->getService().get(), - xNewTD->getName() ); -} - -void checkService( - Reference<reflection::XServiceTypeDescription2> const & xNewTD, - Reference<reflection::XServiceTypeDescription2> const & xExistingTD ) -{ - sal_Bool singleIfaceBased = xNewTD->isSingleInterfaceBased(); - if (singleIfaceBased != xExistingTD->isSingleInterfaceBased()) - typeError( "Mixing interface and NON-interface based services!", - xNewTD->getName() ); - if (singleIfaceBased) - { - check( xNewTD->getInterface(), xExistingTD->getInterface(), - xNewTD->getName() ); - Sequence< Reference<reflection::XServiceConstructorDescription> > - newCtors( xNewTD->getConstructors() ); - Sequence< Reference<reflection::XServiceConstructorDescription> > - existingCtors( xExistingTD->getConstructors() ); - sal_Int32 len = newCtors.getLength(); - if (len != existingCtors.getLength()) - typeError( "Different number of service constructors!", - xNewTD->getName() ); - Reference<reflection::XServiceConstructorDescription> const * - pNewCtors = newCtors.getConstArray(); - Reference<reflection::XServiceConstructorDescription> const * - pExistingCtors = existingCtors.getConstArray(); - for ( sal_Int32 pos = 0; pos < len; ++pos ) - { - Reference<reflection::XServiceConstructorDescription> const & - xNewCtor = pNewCtors[pos]; - Reference<reflection::XServiceConstructorDescription> const & - xExistingCtor = pExistingCtors[pos]; - - if (xNewCtor->getName() != xExistingCtor->getName()) - { - OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - "Different constructor names: ") ); - buf.append( xNewCtor->getName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") ); - buf.append( xExistingCtor->getName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") ); - typeError( buf.makeStringAndClear(), xNewTD->getName() ); - } - - OUStringBuffer buf; - buf.append( xNewTD->getName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", constructor ") ); - buf.append( xNewCtor->getName() ); - OUString context( buf.makeStringAndClear() ); - checkParameters( xNewCtor->getParameters(), - xExistingCtor->getParameters(), - context ); - checkSeq( xNewCtor->getExceptions(), xExistingCtor->getExceptions(), - context + ", exceptions" ); - } - } - else // old-style service descriptions: - { - checkSeq( xNewTD->getMandatoryServices(), - xExistingTD->getMandatoryServices(), - xNewTD->getName() + ", mandatory services" ); - checkSeq( xNewTD->getOptionalServices(), - xExistingTD->getOptionalServices(), - xNewTD->getName() + ", optional services", - true /* optionalMode */ ); - checkSeq( xNewTD->getMandatoryInterfaces(), - xExistingTD->getMandatoryInterfaces(), - xNewTD->getName() + ", mandatory interfaces" ); - checkSeq( xNewTD->getOptionalInterfaces(), - xExistingTD->getOptionalInterfaces(), - xNewTD->getName() + ", optional interfaces", - true /* optionalMode */ ); - - Sequence< Reference<reflection::XPropertyTypeDescription> > - newProperties( xNewTD->getProperties() ); - Sequence< Reference<reflection::XPropertyTypeDescription> > - existingProperties( xExistingTD->getProperties() ); - checkSeq( newProperties, existingProperties, - xNewTD->getName() + ", properties", - true /* optionalMode */ ); - if (newProperties.getLength() > existingProperties.getLength()) - { - // check whether all added properties are OPTIONAL: - Reference<reflection::XPropertyTypeDescription> const * - pNewProperties = newProperties.getConstArray(); - for ( sal_Int32 pos = existingProperties.getLength() + 1; - pos < newProperties.getLength(); ++pos ) - { - if ((pNewProperties[pos]->getPropertyFlags() & - beans::PropertyAttribute::OPTIONAL) == 0) - typeError( "New property is not OPTIONAL!", - pNewProperties[pos]->getName() ); - } - } - } -} - -} - -namespace stoc_tdmgr { - -void check( Reference<reflection::XTypeDescription> const & xNewTD, - Reference<reflection::XTypeDescription> const & xExistingTD, - OUString const & context ) -{ - if (xNewTD == xExistingTD) - return; - if (xNewTD->getName() != xExistingTD->getName()) - { - OUStringBuffer buf; - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Different type names: ") ); - buf.append( xNewTD->getName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") ); - buf.append( xExistingTD->getName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") ); - typeError( buf.makeStringAndClear(), context ); - } - - TypeClass tc = xNewTD->getTypeClass(); - if (tc != xExistingTD->getTypeClass()) - { - OUStringBuffer buf; - buf.append( xNewTD->getName() ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( - " has different type classes: ") ); - buf.append( getTypeClassName( tc ) ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (new), ") ); - buf.append( getTypeClassName( xExistingTD->getTypeClass() ) ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" (existing)!") ); - typeError( buf.makeStringAndClear(), context ); - } - - switch (tc) - { - case TypeClass_ENUM: - checkEnum( Reference<reflection::XEnumTypeDescription>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XEnumTypeDescription>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - - case TypeClass_TYPEDEF: - case TypeClass_SEQUENCE: - check( Reference<reflection::XIndirectTypeDescription>( - xNewTD, UNO_QUERY_THROW )->getReferencedType(), - Reference<reflection::XIndirectTypeDescription>( - xExistingTD, UNO_QUERY_THROW )->getReferencedType() ); - break; - - case TypeClass_STRUCT: - case TypeClass_EXCEPTION: - checkStruct( Reference<reflection::XCompoundTypeDescription>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XCompoundTypeDescription>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - - case TypeClass_INTERFACE: - checkInterface( Reference<reflection::XInterfaceTypeDescription2>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XInterfaceTypeDescription2>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - - case TypeClass_SERVICE: - checkService( Reference<reflection::XServiceTypeDescription2>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XServiceTypeDescription2>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - - case TypeClass_INTERFACE_METHOD: - checkMethod( Reference<reflection::XInterfaceMethodTypeDescription>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XInterfaceMethodTypeDescription>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - case TypeClass_INTERFACE_ATTRIBUTE: - checkAttribute( - Reference<reflection::XInterfaceAttributeTypeDescription2>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XInterfaceAttributeTypeDescription2>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - - case TypeClass_PROPERTY: - checkProperty( Reference<reflection::XPropertyTypeDescription>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XPropertyTypeDescription>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - - case TypeClass_CONSTANT: - if (Reference<reflection::XConstantTypeDescription>( - xNewTD, UNO_QUERY_THROW )->getConstantValue() != - Reference<reflection::XConstantTypeDescription>( - xExistingTD, UNO_QUERY_THROW )->getConstantValue()) - typeError( "Different constant value!", xNewTD->getName() ); - break; - case TypeClass_CONSTANTS: - checkSeq( Reference<reflection::XConstantsTypeDescription>( - xNewTD, UNO_QUERY_THROW )->getConstants(), - Reference<reflection::XConstantsTypeDescription>( - xExistingTD, UNO_QUERY_THROW )->getConstants(), - xNewTD->getName() ); - break; - - case TypeClass_SINGLETON: - checkSingleton( Reference<reflection::XSingletonTypeDescription2>( - xNewTD, UNO_QUERY_THROW ), - Reference<reflection::XSingletonTypeDescription2>( - xExistingTD, UNO_QUERY_THROW ) ); - break; - - default: - break; - } -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/tdmanager/tdmgr_common.hxx b/stoc/source/tdmanager/tdmgr_common.hxx deleted file mode 100644 index eb3bcdec850f..000000000000 --- a/stoc/source/tdmanager/tdmgr_common.hxx +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _STOC_TDMGR_COMMON_HXX -#define _STOC_TDMGR_COMMON_HXX - -#include "com/sun/star/reflection/XTypeDescription.hpp" - -#define ARLEN(x) (sizeof (x) / sizeof *(x)) - - -namespace stoc_tdmgr -{ - -struct IncompatibleTypeException -{ - OUString m_cause; - IncompatibleTypeException( OUString const & cause ) - : m_cause( cause ) {} -}; - -void check( - css::uno::Reference<css::reflection::XTypeDescription> const & xNewTD, - css::uno::Reference<css::reflection::XTypeDescription> const & xExistingTD, - OUString const & context = OUString() ); -/* throw (css::uno::RuntimeException, IncompatibleTypeException) */ - -} // namespace stoc_tdmgr - -#endif /* _STOC_TDMGR_COMMON_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/tdmanager/tdmgr_tdenumeration.cxx b/stoc/source/tdmanager/tdmgr_tdenumeration.cxx deleted file mode 100644 index ac71a1a0aa47..000000000000 --- a/stoc/source/tdmanager/tdmgr_tdenumeration.cxx +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <osl/diagnose.h> -#include "tdmgr_common.hxx" -#include "tdmgr_tdenumeration.hxx" - -using namespace com::sun::star; - -namespace stoc_tdmgr -{ - -//========================================================================= -//========================================================================= -// -// TypeDescriptionEnumerationImpl Implementation. -// -//========================================================================= -//========================================================================= - -TypeDescriptionEnumerationImpl::TypeDescriptionEnumerationImpl( - const OUString & rModuleName, - const com::sun::star::uno::Sequence< - com::sun::star::uno::TypeClass > & rTypes, - com::sun::star::reflection::TypeDescriptionSearchDepth eDepth, - const TDEnumerationAccessStack & rTDEAS ) -: m_aModuleName( rModuleName ), - m_aTypes( rTypes ), - m_eDepth( eDepth ), - m_aChildren( rTDEAS ) -{ -} - -//========================================================================= -// virtual -TypeDescriptionEnumerationImpl::~TypeDescriptionEnumerationImpl() -{ -} - -//========================================================================= -// -// XEnumeration (base of XTypeDescriptionEnumeration) methods -// -//========================================================================= - -// virtual -sal_Bool SAL_CALL TypeDescriptionEnumerationImpl::hasMoreElements() - throw ( uno::RuntimeException ) -{ - uno::Reference< reflection::XTypeDescriptionEnumeration > xEnum - = queryCurrentChildEnumeration(); - if ( xEnum.is() ) - return xEnum->hasMoreElements(); - - return sal_False; -} - -//========================================================================= -// virtual -uno::Any SAL_CALL TypeDescriptionEnumerationImpl::nextElement() - throw ( container::NoSuchElementException, - lang::WrappedTargetException, - uno::RuntimeException ) -{ - uno::Reference< reflection::XTypeDescriptionEnumeration > xEnum - = queryCurrentChildEnumeration(); - if ( xEnum.is() ) - return xEnum->nextElement(); - - throw container::NoSuchElementException( - OUString("No further elements in enumeration!"), - static_cast< cppu::OWeakObject * >( this ) ); -} - -//========================================================================= -// -// XTypeDescriptionEnumeration methods -// -//========================================================================= - -// virtual -uno::Reference< reflection::XTypeDescription > SAL_CALL -TypeDescriptionEnumerationImpl::nextTypeDescription() - throw ( container::NoSuchElementException, - uno::RuntimeException ) -{ - uno::Reference< reflection::XTypeDescriptionEnumeration > xEnum - = queryCurrentChildEnumeration(); - if ( xEnum.is() ) - return xEnum->nextTypeDescription(); - - throw container::NoSuchElementException( - OUString("No further elements in enumeration!"), - static_cast< cppu::OWeakObject * >( this ) ); -} - -//========================================================================= -uno::Reference< reflection::XTypeDescriptionEnumeration > -TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration() -{ - osl::MutexGuard aGuard( m_aMutex ); - - for (;;) - { - if ( m_xEnum.is() ) - { - if ( m_xEnum->hasMoreElements() ) - { - return m_xEnum; - } - else - { - // Forget about enumeration without further elements. Try next. - m_xEnum.clear(); - } - } - - // Note: m_xEnum is always null here. - - if ( m_aChildren.empty() ) - { - // No child enumerations left. - return m_xEnum; - } - - try - { - m_xEnum = - m_aChildren.top()->createTypeDescriptionEnumeration( - m_aModuleName, m_aTypes, m_eDepth ); - } - catch ( reflection::NoSuchTypeNameException const & ) - { - OSL_FAIL( "TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration " - "- Caught NoSuchTypeNameException!" ); - } - catch ( reflection::InvalidTypeNameException const & ) - { - OSL_FAIL( "TypeDescriptionEnumerationImpl::queryCurrentChildEnumeration " - "- Caught InvalidTypeNameException!" ); - } - - // We're done with this enumeration access in any case (Either - // enumeration was successfully created or creation failed for some - // reason). - m_aChildren.pop(); - } - - // unreachable -} - -} // namespace stoc_tdmgr - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/tdmanager/tdmgr_tdenumeration.hxx b/stoc/source/tdmanager/tdmgr_tdenumeration.hxx deleted file mode 100644 index 81672ce5c0f8..000000000000 --- a/stoc/source/tdmanager/tdmgr_tdenumeration.hxx +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef _STOC_TDMGR_TDENUMERATION_HXX -#define _STOC_TDMGR_TDENUMERATION_HXX - -#include <stack> -#include <osl/mutex.hxx> -#include <com/sun/star/reflection/XTypeDescriptionEnumeration.hpp> -#include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp> -#include <cppuhelper/implbase1.hxx> - -namespace stoc_tdmgr -{ - -typedef std::stack< com::sun::star::uno::Reference< - com::sun::star::reflection::XTypeDescriptionEnumerationAccess > > - TDEnumerationAccessStack; - -class TypeDescriptionEnumerationImpl - : public cppu::WeakImplHelper1< - com::sun::star::reflection::XTypeDescriptionEnumeration > -{ -public: - TypeDescriptionEnumerationImpl( - const OUString & rModuleName, - const com::sun::star::uno::Sequence< - com::sun::star::uno::TypeClass > & rTypes, - com::sun::star::reflection::TypeDescriptionSearchDepth eDepth, - const TDEnumerationAccessStack & rTDEAS ); - virtual ~TypeDescriptionEnumerationImpl(); - - // XEnumeration (base of XTypeDescriptionEnumeration) - virtual sal_Bool SAL_CALL hasMoreElements() - throw ( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Any SAL_CALL nextElement() - throw ( ::com::sun::star::container::NoSuchElementException, - ::com::sun::star::lang::WrappedTargetException, - ::com::sun::star::uno::RuntimeException ); - - // XTypeDescriptionEnumeration - virtual ::com::sun::star::uno::Reference< - ::com::sun::star::reflection::XTypeDescription > SAL_CALL - nextTypeDescription() - throw ( ::com::sun::star::container::NoSuchElementException, - ::com::sun::star::uno::RuntimeException ); - -private: - com::sun::star::uno::Reference< - com::sun::star::reflection::XTypeDescriptionEnumeration > - queryCurrentChildEnumeration(); - - osl::Mutex m_aMutex; - OUString m_aModuleName; - com::sun::star::uno::Sequence< com::sun::star::uno::TypeClass > m_aTypes; - com::sun::star::reflection::TypeDescriptionSearchDepth m_eDepth; - TDEnumerationAccessStack m_aChildren; - com::sun::star::uno::Reference< - com::sun::star::reflection::XTypeDescriptionEnumeration > m_xEnum; -}; - -} // namespace stoc_tdmgr - -#endif /* _STOC_TDMGR_TDENUMERATION_HXX */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/util/bootstrap.component b/stoc/util/bootstrap.component index ec1aa548e2d1..59761e04edcd 100644 --- a/stoc/util/bootstrap.component +++ b/stoc/util/bootstrap.component @@ -41,10 +41,6 @@ <implementation name="com.sun.star.comp.stoc.SimpleRegistry"> <service name="com.sun.star.registry.SimpleRegistry"/> </implementation> - <implementation name="com.sun.star.comp.stoc.TypeDescriptionManager"> - <service name="com.sun.star.reflection.TypeDescriptionManager"/> - <singleton name="com.sun.star.reflection.theTypeDescriptionManager"/> - </implementation> <implementation name="com.sun.star.security.comp.stoc.AccessController"> <service name="com.sun.star.security.AccessController"/> </implementation> |