diff options
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/inc/cppuhelper/factory.hxx | 3 | ||||
-rw-r--r-- | cppuhelper/inc/cppuhelper/implementationentry.hxx | 6 | ||||
-rw-r--r-- | cppuhelper/inc/cppuhelper/interfacecontainer.h | 23 | ||||
-rw-r--r-- | cppuhelper/inc/cppuhelper/shlib.hxx | 2 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/JavaSupplier.java | 5 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx | 7 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/makefile.mk | 59 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component | 34 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/qa_propertysetmixin.java.component | 34 | ||||
-rw-r--r-- | cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx | 40 | ||||
-rw-r--r-- | cppuhelper/source/bootstrap.cxx | 10 | ||||
-rw-r--r-- | cppuhelper/source/interfacecontainer.cxx | 108 | ||||
-rw-r--r-- | cppuhelper/source/servicefactory.cxx | 73 |
13 files changed, 235 insertions, 169 deletions
diff --git a/cppuhelper/inc/cppuhelper/factory.hxx b/cppuhelper/inc/cppuhelper/factory.hxx index 1b733d7a9170..579ee876cb39 100644 --- a/cppuhelper/inc/cppuhelper/factory.hxx +++ b/cppuhelper/inc/cppuhelper/factory.hxx @@ -87,6 +87,9 @@ typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)( typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void); /** Function pointer declaration. + + @obsolete component_writeInfo should no longer be used in new components + Function writes component registry info, at least writing the supported service names. @param pServiceManager diff --git a/cppuhelper/inc/cppuhelper/implementationentry.hxx b/cppuhelper/inc/cppuhelper/implementationentry.hxx index f1f20cf01391..e432a6186482 100644 --- a/cppuhelper/inc/cppuhelper/implementationentry.hxx +++ b/cppuhelper/inc/cppuhelper/implementationentry.hxx @@ -72,6 +72,8 @@ struct ImplementationEntry /** Helper function for implementation of the component_writeInfo()-function. + @obsolete component_writeInfo should no longer be used in new components + @param pServiceManager The first parameter passed to component_writeInfo()-function (This is an instance of the service manager, that creates the factory). @param pRegistryKey The second parameter passed to the component_writeInfo()-function. @@ -90,9 +92,9 @@ sal_Bool component_writeInfoHelper( @param pImplName The implementation-name to be instantiated ( This is the first parameter passed to the component_getFactory - @param pServiceManager The first parameter passed to component_writeInfo()-function + @param pServiceManager The second parameter passed to component_getFactory()-function (This is a of the service manager, that creates the factory). - @param pRegistryKey The second parameter passed to the component_writeInfo()-function. + @param pRegistryKey The third parameter passed to the component_getFactory()-function. This is a reference to the registry key, where the implementation data has been written to. @param entries Each element of the entries-array must contains a function pointer diff --git a/cppuhelper/inc/cppuhelper/interfacecontainer.h b/cppuhelper/inc/cppuhelper/interfacecontainer.h index 3f5da6bd10dc..ee57127a4fca 100644 --- a/cppuhelper/inc/cppuhelper/interfacecontainer.h +++ b/cppuhelper/inc/cppuhelper/interfacecontainer.h @@ -44,6 +44,17 @@ namespace cppu { +namespace detail { + + union element_alias + { + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > *pAsSequence; + ::com::sun::star::uno::XInterface * pAsInterface; + element_alias() : pAsInterface(0) {} + }; + +} + //=================================================================== class OInterfaceContainerHelper; /** @@ -95,7 +106,9 @@ public: private: OInterfaceContainerHelper & rCont; sal_Bool bIsList; - void * pData; + + detail::element_alias aData; + sal_Int32 nRemain; OInterfaceIteratorHelper( const OInterfaceIteratorHelper & ) SAL_THROW( () ); @@ -222,14 +235,14 @@ public: private: friend class OInterfaceIteratorHelper; /** - bIsList == TRUE -> pData of type Sequence< XInterfaceSequence >, - otherwise pData == of type (XEventListener *) + bIsList == TRUE -> aData.pAsSequence of type Sequence< XInterfaceSequence >, + otherwise aData.pAsInterface == of type (XEventListener *) */ - void * pData; + detail::element_alias aData; ::osl::Mutex & rMutex; /** TRUE -> used by an iterator. */ sal_Bool bInUse; - /** TRUE -> pData is of type Sequence< XInterfaceSequence >. */ + /** TRUE -> aData.pAsSequence is of type Sequence< XInterfaceSequence >. */ sal_Bool bIsList; OInterfaceContainerHelper( const OInterfaceContainerHelper & ) SAL_THROW( () ); diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx index 47bf2fc06b97..ee7ae8ff4fda 100644 --- a/cppuhelper/inc/cppuhelper/shlib.hxx +++ b/cppuhelper/inc/cppuhelper/shlib.hxx @@ -65,6 +65,8 @@ SAL_CALL loadSharedLibComponentFactory( directory. The resulting path of the library will be checked against environment variable CPLD_ACCESSPATH if set. + @obsolete component_writeInfo should no longer be used in new components + @param rLibName name of the library @param rPath optional path @param xMgr service manager to be provided to the component diff --git a/cppuhelper/qa/propertysetmixin/JavaSupplier.java b/cppuhelper/qa/propertysetmixin/JavaSupplier.java index 2d37c8901077..0aa267610801 100644 --- a/cppuhelper/qa/propertysetmixin/JavaSupplier.java +++ b/cppuhelper/qa/propertysetmixin/JavaSupplier.java @@ -75,11 +75,6 @@ public final class JavaSupplier extends WeakBase implements XSupplier { : null; } - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo( - implementationName, serviceName, regKey); - } - private static final String implementationName = JavaSupplier.class.getName(); private static final String serviceName diff --git a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx index 1159d1aed7a0..1ed996617ce5 100644 --- a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx @@ -427,10 +427,3 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( { *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } - -extern "C" sal_Bool SAL_CALL component_writeInfo( - void * serviceManager, void * registryKey) -{ - return cppu::component_writeInfoHelper( - serviceManager, registryKey, entries); -} diff --git a/cppuhelper/qa/propertysetmixin/makefile.mk b/cppuhelper/qa/propertysetmixin/makefile.mk index edd4795fc115..04aa2479c3b8 100644 --- a/cppuhelper/qa/propertysetmixin/makefile.mk +++ b/cppuhelper/qa/propertysetmixin/makefile.mk @@ -37,6 +37,8 @@ PACKAGE = test/cppuhelper/propertysetmixin/comp ENABLE_EXCEPTIONS := TRUE +my_components = $(TARGET).cpp $(TARGET).java + .INCLUDE: settings.mk .IF "$(OS)" == "WNT" @@ -75,51 +77,62 @@ JARFILES = java_uno.jar juh.jar jurt.jar ridl.jar ALLTAR: test $(MISC)/$(TARGET)/types.urd: types.idl - - $(MKDIR) $(@:d) + $(MKDIRHIER) $(@:d) $(IDLC) -O$(@:d) -I$(SOLARIDLDIR) -cid -we $< $(MISC)/$(TARGET)/types.rdb: $(MISC)/$(TARGET)/types.urd - $(RM) $@ $(REGMERGE) $@ /UCR $< -$(MISC)/$(TARGET)/uno.rdb: $(MISC)/$(TARGET)/types.rdb $(SHL2TARGETN) \ - $(MISC)/$(TARGET)/$(TARGET).uno.jar $(MISC)/$(TARGET)/bootstrap.rdb - - $(MKDIR) $(@:d) - $(COPY) $(SOLARBINDIR)/types.rdb $@ - $(REGMERGE) $@ / $(MISC)/$(TARGET)/types.rdb - $(REGCOMP) -register -r $@ -wop -c javaloader.uno -c javavm.uno \ - -c reflection.uno -c stocservices.uno -c $(SHL2TARGETN) - $(REGCOMP) -register -br $(MISC)/$(TARGET)/bootstrap.rdb -r $@ \ - -c $(my_file)$(PWD)/$(MISC)/$(TARGET)/$(TARGET).uno.jar \ - -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) - -$(MISC)/$(TARGET)/bootstrap.rdb: - - $(MKDIR) $(@:d) - $(COPY) $(SOLARBINDIR)/types.rdb $@ - $(REGCOMP) -register -r $@ -wop -c javaloader.uno -c javavm.uno \ - -c stocservices.uno - $(MISC)/$(TARGET)/cppumaker.flag: $(MISC)/$(TARGET)/types.rdb $(CPPUMAKER) -O$(MISC)/$(TARGET)/inc -BUCR -Gc \ - -X$(SOLARBINDIR)/types.rdb $< + -X$(SOLARBINDIR)/udkapi.rdb $< $(TOUCH) $@ $(SLOFILES): $(MISC)/$(TARGET)/cppumaker.flag $(MISC)/$(TARGET)/javamaker.flag: $(MISC)/$(TARGET)/types.rdb - $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD -Gc -X$(SOLARBINDIR)/types.rdb $< + $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD -Gc -X$(SOLARBINDIR)/udkapi.rdb $< $(TOUCH) $@ $(JAVATARGET): $(MISC)/$(TARGET)/javamaker.flag +$(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \ + $(MISC)/$(TARGET)/services.input \ + $(my_components:^"$(MISC)/$(TARGET)/":+".component") + $(XSLTPROC) --nonet --stringparam prefix $(PWD)/$(MISC)/$(TARGET)/ -o $@ \ + $(SOLARENV)/bin/packcomponents.xslt $(MISC)/$(TARGET)/services.input + +$(MISC)/$(TARGET)/services.input: + $(MKDIRHIER) $(@:d) + echo \ + '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \ + > $@ + +$(MISC)/$(TARGET)/$(TARGET).cpp.component .ERRREMOVE: \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).cpp.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_INBUILD_NATIVE)$(SHL2TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).cpp.component + +$(MISC)/$(TARGET)/$(TARGET).java.component .ERRREMOVE: \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).java.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_INBUILD_JAVA)$(TARGET).uno.jar' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).java.component + $(MISC)/$(TARGET)/$(TARGET).uno.jar: $(JAVATARGET) \ $(MISC)/$(TARGET)/javamaker.flag manifest jar cfm $@ manifest -C $(CLASSDIR) test/cppuhelper/propertysetmixin -test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/uno.rdb +test .PHONY: $(SHL1TARGETN) $(SHL2TARGETN) $(MISC)/$(TARGET)/$(TARGET).uno.jar \ + $(MISC)/$(TARGET)/types.rdb $(MISC)/$(TARGET)/services.rdb $(CPPUNITTESTER) $(SHL1TARGETN) \ - -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) \ + '-env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/types.rdb' \ + '-env:UNO_SERVICES=$(my_file)$(SOLARXMLDIR)/ure/services.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb'\ -env:URE_INTERNAL_LIB_DIR=$(my_file)$(SOLARSHAREDBIN) \ - -env:arg-reg=$(MISC)/$(TARGET)/uno.rdb -env:arg-path=$(SOLARSHAREDBIN) + -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) \ + -env:OOO_INBUILD_SHAREDLIB_DIR=$(my_file)$(PWD)/$(DLLDEST) \ + -env:OOO_INBUILD_JAR_DIR=$(my_file)$(PWD)/$(MISC)/$(TARGET) .END diff --git a/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component new file mode 100644 index 000000000000..a654e07581a3 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="test.cppuhelper.propertysetmixin.comp.CppSupplier"> + <service name="test.cppuhelper.propertysetmixin.CppSupplier"/> + </implementation> +</component> diff --git a/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.java.component b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.java.component new file mode 100644 index 000000000000..9711563b758b --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.java.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="test.cppuhelper.propertysetmixin.comp.JavaSupplier"> + <service name="test.cppuhelper.propertysetmixin.JavaSupplier"/> + </implementation> +</component> diff --git a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx index 06db4cfdad52..e4f1a4a78c3b 100644 --- a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx @@ -52,21 +52,19 @@ #include "com/sun/star/beans/XPropertySetInfo.hpp" #include "com/sun/star/beans/XVetoableChangeListener.hpp" #include "com/sun/star/lang/XComponent.hpp" -#include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/Type.hxx" #include "com/sun/star/uno/XComponentContext.hpp" +#include "cppuhelper/bootstrap.hxx" #include "cppuhelper/implbase1.hxx" -#include "cppuhelper/servicefactory.hxx" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" #include "cppunit/plugin/TestPlugIn.h" #include "osl/mutex.hxx" -#include "rtl/bootstrap.hxx" #include "rtl/ref.hxx" #include "rtl/string.h" #include "rtl/textenc.h" @@ -98,14 +96,6 @@ std::ostream & operator <<(std::ostream & out, css::uno::Any const & value) { out << "com::sun::star::uno::Any[" << value.getValueType() << ", ...]"; } -rtl::OUString getArgument(rtl::OUString const & name) { - rtl::OUString val; - CPPUNIT_ASSERT( - rtl::Bootstrap::get( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arg-")) + name, val)); - return val; -} - class BoundListener: public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener > { @@ -178,7 +168,7 @@ class Test: public CppUnit::TestFixture { public: virtual void setUp(); - void finish(); + virtual void tearDown(); void testCppEmpty1() { testEmpty1(getCppSupplier()); } @@ -199,7 +189,6 @@ public: CPPUNIT_TEST(testJavaEmpty1); CPPUNIT_TEST(testJavaEmpty2); CPPUNIT_TEST(testJavaFull); - CPPUNIT_TEST(finish); CPPUNIT_TEST_SUITE_END(); private: @@ -221,30 +210,15 @@ private: css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > const & supplier) const; - static css::uno::Reference< css::uno::XComponentContext > m_context; + css::uno::Reference< css::uno::XComponentContext > m_context; }; void Test::setUp() { - // For whatever reason, on W32 it does not work to create/destroy a fresh - // component context for each test in Test::setUp/tearDown; therefore, a - // single component context is used for all tests and destroyed in the last - // pseudo-test "finish": - if (!m_context.is()) { - css::uno::Reference< css::lang::XMultiComponentFactory > factory( - cppu::createRegistryServiceFactory( - getArgument(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reg"))), - sal_False, - getArgument( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("path")))), - css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::beans::XPropertySet >( - factory, css::uno::UNO_QUERY_THROW)->getPropertyValue( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))) - >>= m_context; - } + m_context = cppu::defaultBootstrap_InitialComponentContext(); + CPPUNIT_ASSERT(m_context.is()); } -void Test::finish() { +void Test::tearDown() { css::uno::Reference< css::lang::XComponent >( m_context, css::uno::UNO_QUERY_THROW)->dispose(); } @@ -671,8 +645,6 @@ void Test::testFull( } catch (css::beans::UnknownPropertyException &) {} } -css::uno::Reference< css::uno::XComponentContext > Test::m_context; - CPPUNIT_TEST_SUITE_REGISTRATION(Test); } 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)); } } } |