diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2010-10-06 12:55:53 +0200 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2010-10-06 12:55:53 +0200 |
commit | 0d225db9972f2cd4426d129efc783d41caee4655 (patch) | |
tree | 1bac27ee52551a6f35856fcc282460dbf47f5312 /cppuhelper/source | |
parent | 1ab5c7561b9fdf579c74a8cb98e5749589c5cafb (diff) | |
parent | e7e67bc6543a18a65cf32f4b33caca54404f27e8 (diff) |
rebased to m89
Diffstat (limited to 'cppuhelper/source')
-rw-r--r-- | cppuhelper/source/bootstrap.cxx | 10 | ||||
-rw-r--r-- | cppuhelper/source/interfacecontainer.cxx | 108 | ||||
-rw-r--r-- | cppuhelper/source/servicefactory.cxx | 73 |
3 files changed, 98 insertions, 93 deletions
diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx index 5575c118420e..f892cdcab0f3 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -380,9 +380,15 @@ SAL_CALL defaultBootstrap_InitialComponentContext( Bootstrap const & bootstrap ) SAL_THROW( (Exception) ) { - OUString bootstrapPath( get_this_libpath() ); - OUString iniDir; + OUString bootstrapPath; + if (!bootstrap.getFrom( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URE_INTERNAL_LIB_DIR")), + bootstrapPath)) + { + bootstrapPath = get_this_libpath(); + } + OUString iniDir; osl_getProcessWorkingDir(&iniDir.pData); Reference<lang::XMultiComponentFactory> smgr_XMultiComponentFactory( diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx index 3053193d5ee6..b0c8d687a0a8 100644 --- a/cppuhelper/source/interfacecontainer.cxx +++ b/cppuhelper/source/interfacecontainer.cxx @@ -99,15 +99,15 @@ OInterfaceIteratorHelper::OInterfaceIteratorHelper( OInterfaceContainerHelper & // worst case, two iterators at the same time rCont.copyAndResetInUse(); bIsList = rCont_.bIsList; - pData = rCont_.pData; + aData = rCont_.aData; if( bIsList ) { rCont.bInUse = sal_True; - nRemain = ((Sequence< Reference< XInterface > >*)pData)->getLength(); + nRemain = aData.pAsSequence->getLength(); } - else if( pData ) + else if( aData.pAsInterface ) { - ((XInterface *)pData)->acquire(); + aData.pAsInterface->acquire(); nRemain = 1; } else @@ -120,7 +120,7 @@ OInterfaceIteratorHelper::~OInterfaceIteratorHelper() SAL_THROW( () ) { MutexGuard aGuard( rCont.rMutex ); // bResetInUse protect the iterator against recursion - bShared = pData == rCont.pData && rCont.bIsList; + bShared = aData.pAsSequence == rCont.aData.pAsSequence && rCont.bIsList; if( bShared ) { OSL_ENSURE( rCont.bInUse, "OInterfaceContainerHelper must be in use" ); @@ -132,10 +132,10 @@ OInterfaceIteratorHelper::~OInterfaceIteratorHelper() SAL_THROW( () ) { if( bIsList ) // Sequence owned by the iterator - delete (Sequence< Reference< XInterface > >*)pData; - else if( pData ) + delete aData.pAsSequence; + else if( aData.pAsInterface ) // Interface is acquired by the iterator - ((XInterface*)pData)->release(); + aData.pAsInterface->release(); } } @@ -146,9 +146,9 @@ XInterface * OInterfaceIteratorHelper::next() SAL_THROW( () ) nRemain--; if( bIsList ) // typecase to const,so the getArray method is faster - return ((const Sequence< Reference< XInterface > >*)pData)->getConstArray()[nRemain].get(); - else if( pData ) - return (XInterface*)pData; + return aData.pAsSequence->getConstArray()[nRemain].get(); + else if( aData.pAsInterface ) + return aData.pAsInterface; } // exception return 0; @@ -159,15 +159,14 @@ void OInterfaceIteratorHelper::remove() SAL_THROW( () ) if( bIsList ) { OSL_ASSERT( nRemain >= 0 && - nRemain < ((const Sequence< Reference< XInterface > >*)pData)->getLength() ); - XInterface * p = - ((const Sequence< Reference< XInterface > >*)pData)->getConstArray()[nRemain].get(); + nRemain < aData.pAsSequence->getLength() ); + XInterface * p = aData.pAsSequence->getConstArray()[nRemain].get(); rCont.removeInterface( * reinterpret_cast< const Reference< XInterface > * >( &p ) ); } else { OSL_ASSERT( 0 == nRemain ); - rCont.removeInterface( * reinterpret_cast< const Reference< XInterface > * >(&pData)); + rCont.removeInterface( * reinterpret_cast< const Reference< XInterface > * >(&aData.pAsInterface)); } } @@ -177,8 +176,7 @@ void OInterfaceIteratorHelper::remove() SAL_THROW( () ) OInterfaceContainerHelper::OInterfaceContainerHelper( Mutex & rMutex_ ) SAL_THROW( () ) - : pData( 0 ) - , rMutex( rMutex_ ) + : rMutex( rMutex_ ) , bInUse( sal_False ) , bIsList( sal_False ) { @@ -188,17 +186,17 @@ OInterfaceContainerHelper::~OInterfaceContainerHelper() SAL_THROW( () ) { OSL_ENSURE( !bInUse, "~OInterfaceContainerHelper but is in use" ); if( bIsList ) - delete (Sequence< Reference< XInterface > >*)pData; - else if( pData ) - ((XInterface*)pData)->release(); + delete aData.pAsSequence; + else if( aData.pAsInterface ) + aData.pAsInterface->release(); } sal_Int32 OInterfaceContainerHelper::getLength() const SAL_THROW( () ) { MutexGuard aGuard( rMutex ); if( bIsList ) - return ((Sequence< Reference< XInterface > >*)pData)->getLength(); - else if( pData ) + return aData.pAsSequence->getLength(); + else if( aData.pAsInterface ) return 1; return 0; } @@ -207,10 +205,10 @@ Sequence< Reference<XInterface> > OInterfaceContainerHelper::getElements() const { MutexGuard aGuard( rMutex ); if( bIsList ) - return *(Sequence< Reference< XInterface > >*)pData; - else if( pData ) + return *aData.pAsSequence; + else if( aData.pAsInterface ) { - Reference<XInterface> x( (XInterface *)pData ); + Reference<XInterface> x( aData.pAsInterface ); return Sequence< Reference< XInterface > >( &x, 1 ); } return Sequence< Reference< XInterface > >(); @@ -224,9 +222,9 @@ void OInterfaceContainerHelper::copyAndResetInUse() SAL_THROW( () ) // this should be the worst case. If a iterator is active // and a new Listener is added. if( bIsList ) - pData = new Sequence< Reference< XInterface > >( *(Sequence< Reference< XInterface > >*)pData ); - else if( pData ) - ((XInterface*)pData)->acquire(); + aData.pAsSequence = new Sequence< Reference< XInterface > >( *aData.pAsSequence ); + else if( aData.pAsInterface ) + aData.pAsInterface->acquire(); bInUse = sal_False; } @@ -241,25 +239,25 @@ sal_Int32 OInterfaceContainerHelper::addInterface( const Reference<XInterface> & if( bIsList ) { - sal_Int32 nLen = ((Sequence< Reference< XInterface > >*)pData)->getLength(); - realloc( *(Sequence< Reference< XInterface > >*)pData, nLen +1 ); - ((Sequence< Reference< XInterface > >*)pData)->getArray()[ nLen ] = rListener; + sal_Int32 nLen = aData.pAsSequence->getLength(); + realloc( *aData.pAsSequence, nLen +1 ); + aData.pAsSequence->getArray()[ nLen ] = rListener; return nLen +1; } - else if( pData ) + else if( aData.pAsInterface ) { Sequence< Reference< XInterface > > * pSeq = new Sequence< Reference< XInterface > >( 2 ); Reference<XInterface> * pArray = pSeq->getArray(); - pArray[0] = (XInterface *)pData; + pArray[0] = aData.pAsInterface; pArray[1] = rListener; - ((XInterface *)pData)->release(); - pData = pSeq; + aData.pAsInterface->release(); + aData.pAsSequence = pSeq; bIsList = sal_True; return 2; } else { - pData = rListener.get(); + aData.pAsInterface = rListener.get(); if( rListener.is() ) rListener->acquire(); return 1; @@ -275,8 +273,8 @@ sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface if( bIsList ) { - const Reference<XInterface> * pL = ((const Sequence< Reference< XInterface > >*)pData)->getConstArray(); - sal_Int32 nLen = ((Sequence< Reference< XInterface > >*)pData)->getLength(); + const Reference<XInterface> * pL = aData.pAsSequence->getConstArray(); + sal_Int32 nLen = aData.pAsSequence->getLength(); sal_Int32 i; for( i = 0; i < nLen; i++ ) { @@ -284,7 +282,7 @@ sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface // more faster. if( pL[i].get() == rListener.get() ) { - sequenceRemoveElementAt( *(Sequence< Reference< XInterface > >*)pData, i ); + sequenceRemoveElementAt( *aData.pAsSequence, i ); break; } } @@ -296,30 +294,30 @@ sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface { if( pL[i] == rListener ) { - sequenceRemoveElementAt(*(Sequence< Reference< XInterface > >*)pData, i ); + sequenceRemoveElementAt(*aData.pAsSequence, i ); break; } } } - if( ((Sequence< Reference< XInterface > >*)pData)->getLength() == 1 ) + if( aData.pAsSequence->getLength() == 1 ) { - XInterface * p = ((const Sequence< Reference< XInterface > >*)pData)->getConstArray()[0].get(); + XInterface * p = aData.pAsSequence->getConstArray()[0].get(); p->acquire(); - delete (Sequence< Reference< XInterface > >*)pData; - pData = p; + delete aData.pAsSequence; + aData.pAsInterface = p; bIsList = sal_False; return 1; } else - return ((Sequence< Reference< XInterface > >*)pData)->getLength(); + return aData.pAsSequence->getLength(); } - else if( pData && Reference<XInterface>( (XInterface*)pData ) == rListener ) + else if( aData.pAsInterface && Reference<XInterface>( aData.pAsInterface ) == rListener ) { - ((XInterface *)pData)->release(); - pData = 0; + aData.pAsInterface->release(); + aData.pAsInterface = 0; } - return pData ? 1 : 0; + return aData.pAsInterface ? 1 : 0; } void OInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt ) SAL_THROW( () ) @@ -328,10 +326,10 @@ void OInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt ) SAL_ OInterfaceIteratorHelper aIt( *this ); // Container freigeben, falls im disposing neue Eintrge kommen OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" ); - if( !bIsList && pData ) - ((XInterface *)pData)->release(); + if( !bIsList && aData.pAsInterface ) + aData.pAsInterface->release(); // set the member to null, the iterator delete the values - pData = NULL; + aData.pAsInterface = NULL; bIsList = sal_False; bInUse = sal_False; aGuard.clear(); @@ -358,10 +356,10 @@ void OInterfaceContainerHelper::clear() SAL_THROW( () ) OInterfaceIteratorHelper aIt( *this ); // Container freigeben, falls im disposing neue Eintrge kommen OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" ); - if( !bIsList && pData ) - ((XInterface *)pData)->release(); + if( !bIsList && aData.pAsInterface ) + aData.pAsInterface->release(); // set the member to null, the iterator delete the values - pData = 0; + aData.pAsInterface = 0; bIsList = sal_False; bInUse = sal_False; // release mutex before aIt destructor call diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx index 57eae9a51087..bcc58b74af59 100644 --- a/cppuhelper/source/servicefactory.cxx +++ b/cppuhelper/source/servicefactory.cxx @@ -28,13 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cppuhelper.hxx" -#if OSL_DEBUG_LEVEL > 0 -#include <stdio.h> -#endif #include <vector> #include "rtl/string.hxx" -#include "rtl/ustrbuf.hxx" #include "rtl/bootstrap.hxx" #include "osl/diagnose.h" #include "osl/file.h" @@ -46,6 +42,7 @@ #include "cppuhelper/servicefactory.hxx" #include "cppuhelper/bootstrap.hxx" +#include "com/sun/star/uno/DeploymentException.hpp" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/lang/XSingleServiceFactory.hpp" @@ -64,6 +61,7 @@ using namespace ::rtl; using namespace ::osl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +namespace css = com::sun::star; namespace cppu { @@ -417,39 +415,42 @@ Reference< XComponentContext > bootstrapInitialContext( keys.getConstArray(); for ( sal_Int32 nPos = keys.getLength(); nPos--; ) { - Reference< registry::XRegistryKey > const & xKey2 = - pKeys[ nPos ]; - try - { - OUStringBuffer buf( 32 ); - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM("/singletons/") ); - buf.append( - xKey2->getKeyName().copy( - sizeof("/SINGLETONS") /* -\0 +'/' */ ) ); - entry.name = buf.makeStringAndClear(); - entry.value <<= xKey2->getStringValue(); - context_values.push_back( entry ); - } - catch (Exception & rExc) - { -#if OSL_DEBUG_LEVEL > 0 - OString aStr( - OUStringToOString( - xKey2->getKeyName().copy( 11 ), - RTL_TEXTENCODING_ASCII_US ) ); - OString aStr2( - OUStringToOString( - rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); - fprintf( - stderr, - "### failed reading singleton [%s]" - " service name from registry: %s\n", - aStr.getStr(), aStr2.getStr() ); -#else - (void) rExc; // avoid warning about unused variable -#endif + css::uno::Sequence< rtl::OUString > impls( + css::uno::Reference< css::registry::XRegistryKey >( + pKeys[nPos]->openKey( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "REGISTERED_BY"))), + css::uno::UNO_SET_THROW)->getAsciiListValue()); + switch (impls.getLength()) { + case 0: + throw css::uno::DeploymentException( + (pKeys[nPos]->getKeyName() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "/REGISTERED_BY is empty"))), + css::uno::Reference< css::uno::XInterface >()); + case 1: + break; + default: + OSL_TRACE( + ("arbitrarily chosing \"%s\" among multiple" + " implementations for \"%s\""), + rtl::OUStringToOString( + impls[0], RTL_TEXTENCODING_UTF8).getStr(), + rtl::OUStringToOString( + pKeys[nPos]->getKeyName(), + RTL_TEXTENCODING_UTF8).getStr()); + break; } + context_values.push_back( + ContextEntry_Init( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("/singletons/")) + + pKeys[nPos]->getKeyName().copy( + RTL_CONSTASCII_LENGTH("/SINGLETONS/"))), + css::uno::makeAny(impls[0]), + true)); } } } |