diff options
Diffstat (limited to 'cppuhelper')
19 files changed, 357 insertions, 127 deletions
diff --git a/cppuhelper/inc/cppuhelper/factory.hxx b/cppuhelper/inc/cppuhelper/factory.hxx index 538d85c51..f0d1a8407 100644 --- a/cppuhelper/inc/cppuhelper/factory.hxx +++ b/cppuhelper/inc/cppuhelper/factory.hxx @@ -53,7 +53,7 @@ typedef struct _uno_Environment uno_Environment; compiled it. If the environment is NOT session specific (needs no additional context), then this function should return the environment type name and leave ppEnv (to 0). - @paramppEnvTypeName environment type name; string must be constant + @param ppEnvTypeName environment type name; string must be constant @param ppEnv function returns its environment if the environment is session specific, i.e. has special context */ @@ -86,6 +86,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 eb49075d1..7e03bb939 100644 --- a/cppuhelper/inc/cppuhelper/implementationentry.hxx +++ b/cppuhelper/inc/cppuhelper/implementationentry.hxx @@ -73,6 +73,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. @@ -91,9 +93,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/propshlp.hxx b/cppuhelper/inc/cppuhelper/propshlp.hxx index 0beca5ab0..4e8889ccf 100644 --- a/cppuhelper/inc/cppuhelper/propshlp.hxx +++ b/cppuhelper/inc/cppuhelper/propshlp.hxx @@ -596,6 +596,29 @@ protected: ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const = 0; + /** sets an dependent property's value + + <p>Sometimes setting a given property needs to implicitly modify another property's value. Calling |setPropertyValue| + from within |setFastPropertyValue_NoBroadcast| is not an option here, as it would notify the property listeners + while our mutex is still locked. Setting the dependent property's value directly (e.g. by calling |setFastPropertyValue_NoBroadcast| + recursively) is not an option, too, since it would miss firing the property change event.</p> + + <p>So, in such cases, you use |setDependentFastPropertyValue| from within |setFastPropertyValue_NoBroadcast|. + It will convert and actually set the property value (invoking |convertFastPropertyValue| and |setFastPropertyValue_NoBroadcast| + for the given handle and value), and add the property change event to the list of events to be notified + when the bottom-most |setFastPropertyValue_NoBroadcast| on the stack returns.</p> + + <p><strong>Note</strong>: The method will <em>not</em> invoke veto listeners for the property.</p> + + <p><strong>Note</strong>: It's the caller's responsibility to ensure that our mutex is locked. This is + canonically given when the method is invoked from within |setFastPropertyValue_NoBroadcast|, in other + contexts, you might need to take own measures.</p> + */ + void setDependentFastPropertyValue( + sal_Int32 i_handle, + const ::com::sun::star::uno::Any& i_value + ); + /** The common data of a broadcaster. Use the mutex, disposing state and the listener container. */ OBroadcastHelper &rBHelper; /** @@ -611,12 +634,22 @@ protected: /** reserved for future use. finally, the future has arrived... */ - const std::auto_ptr<const Impl> m_pReserved; + const std::auto_ptr<Impl> m_pReserved; private: OPropertySetHelper( const OPropertySetHelper & ) SAL_THROW( () ); OPropertySetHelper & operator = ( const OPropertySetHelper & ) SAL_THROW( () ); + /** notifies the given changes in property's values, <em>plus</em> all property changes collected during recent + |setDependentFastPropertyValue| calls. + */ + void impl_fireAll( + sal_Int32* i_handles, + const ::com::sun::star::uno::Any * i_newValues, + const ::com::sun::star::uno::Any * i_oldValues, + sal_Int32 i_count + ); + public: // Suppress warning about virtual functions but non-virtual destructor: #if defined __GNUC__ diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx index a4f52ca94..a092ce34a 100644 --- a/cppuhelper/inc/cppuhelper/shlib.hxx +++ b/cppuhelper/inc/cppuhelper/shlib.hxx @@ -65,7 +65,9 @@ SAL_CALL loadSharedLibComponentFactory( (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific 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/prj/build.lst b/cppuhelper/prj/build.lst index de66b2d61..ff837f90d 100644 --- a/cppuhelper/prj/build.lst +++ b/cppuhelper/prj/build.lst @@ -1,4 +1,4 @@ -ch cppuhelper : BOOST:boost codemaker cppu offuh NULL +ch cppuhelper : BOOST:boost LIBXSLT:libxslt codemaker cppu offuh NULL ch cppuhelper usr1 - all ch_mkout NULL ch cppuhelper\inc nmake - all ch_include NULL ch cppuhelper\source nmake - all ch_source ch_unotypes ch_include NULL diff --git a/cppuhelper/qa/propertysetmixin/JavaSupplier.java b/cppuhelper/qa/propertysetmixin/JavaSupplier.java index 513f207ab..834e448c6 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 adf161083..d013941a4 100644 --- a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx @@ -429,11 +429,5 @@ 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); -} -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/cppuhelper/qa/propertysetmixin/makefile.mk b/cppuhelper/qa/propertysetmixin/makefile.mk index edd4795fc..04aa2479c 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 000000000..a654e0758 --- /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 000000000..9711563b7 --- /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 3b05dc3f3..403b3f1f4 100644 --- a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx @@ -53,21 +53,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" @@ -99,14 +97,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 > { @@ -179,7 +169,7 @@ class Test: public CppUnit::TestFixture { public: virtual void setUp(); - void finish(); + virtual void tearDown(); void testCppEmpty1() { testEmpty1(getCppSupplier()); } @@ -200,7 +190,6 @@ public: CPPUNIT_TEST(testJavaEmpty1); CPPUNIT_TEST(testJavaEmpty2); CPPUNIT_TEST(testJavaFull); - CPPUNIT_TEST(finish); CPPUNIT_TEST_SUITE_END(); private: @@ -222,30 +211,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(); } @@ -672,8 +646,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 17db064b7..51b8afe5d 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -381,9 +381,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/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map index 090f8a1cc..6d4c9e6ce 100755 --- a/cppuhelper/source/cc5_solaris_sparc.map +++ b/cppuhelper/source/cc5_solaris_sparc.map @@ -387,3 +387,9 @@ UDK_3.7 { # OOo 3.3 __1cDcomDsunEstarDunoTWeakReferenceHelperFclear6M_v_; __1cEcppubHcreateOneInstanceComponentFactory6FpFrknDcomDsunEstarDunoJReference4n0ERXComponentContext____n0EJReference4n0EKXInterface___rknDrtlIOUString_rkn0EISequence4n0K___pnQ_rtl_ModuleCount__n0EJReference4n0DElangXXSingleComponentFactory____; } UDK_3.6; + +UDK_3.8 { # OOo 3.4 + global: + __1cEcppuSOPropertySetHelperbDsetDependentFastPropertyValue6MlrknDcomDsunEstarDunoDAny__v_; +} UDK_3.7; + diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index d37f069ac..c2951b597 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -229,9 +229,17 @@ Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndCont else { if ( rArguments.getLength() ) + { + // dispose the here created UNO object before throwing out exception + // to avoid risk of memory leaks #i113722# + Reference<XComponent> xComp( xRet, UNO_QUERY ); + if (xComp.is()) + xComp->dispose(); + throw lang::IllegalArgumentException( OUString( RTL_CONSTASCII_USTRINGPARAM("cannot pass arguments to component => no XInitialization implemented!") ), Reference< XInterface >(), 0 ); + } } return xRet; diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 88e58df65..0aee99691 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -382,3 +382,9 @@ UDK_3.6 { # OOo 3.3 _ZN4cppu33createOneInstanceComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInterfaceEEERKNS4_INS3_17XComponentContextEEEERKN3rtl8OUStringERKNS3_8SequenceISE_EEP16_rtl_ModuleCount; } UDK_3.5; + +UDK_3.7 { # OOo 3.4 + global: + _ZN4cppu18OPropertySetHelper29setDependentFastPropertyValueE?RKN3com3sun4star3uno3AnyE; +} UDK_3.6; + diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map index 6d5a491ab..7069276e2 100644 --- a/cppuhelper/source/msvc_win32_intel.map +++ b/cppuhelper/source/msvc_win32_intel.map @@ -278,3 +278,9 @@ UDK_3.6 { # OOo 3.3 ?clear@WeakReferenceHelper@uno@star@sun@com@@QAAXXZ; ?createOneInstanceComponentFactory@cppu@@YA?AV?$Reference@VXSingleComponentFactory@lang@star@sun@com@@@uno@star@sun@com@@P6A?AV?$Reference@VXInterface@uno@star@sun@com@@@3456@ABV?$Reference@VXComponentContext@uno@star@sun@com@@@3456@@ZABVOUString@rtl@@ABV?$Sequence@VOUString@rtl@@@3456@PAU_rtl_ModuleCount@@@Z; } UDK_3.5; + +UDK_3.7 { # OOo 3.4 + global: + ?setDependentFastPropertyValue@OPropertySetHelper@cppu@@IAEXJABVAny@uno@star@sun@com@@@Z; +} UDK_3.6; + diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx index bbf167121..82b90c63e 100644 --- a/cppuhelper/source/propshlp.cxx +++ b/cppuhelper/source/propshlp.cxx @@ -33,6 +33,7 @@ #include "cppuhelper/implbase1.hxx" #include "cppuhelper/weak.hxx" #include "cppuhelper/propshlp.hxx" +#include "cppuhelper/exc_hlp.hxx" #include "com/sun/star/beans/PropertyAttribute.hpp" #include "com/sun/star/lang/DisposedException.hpp" @@ -147,15 +148,20 @@ sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const OUString & Proper class OPropertySetHelper::Impl { public: - Impl ( bool i_bIgnoreRuntimeExceptionsWhileFiring, - IEventNotificationHook *i_pFireEvents) - : m_bIgnoreRuntimeExceptionsWhileFiring( - i_bIgnoreRuntimeExceptionsWhileFiring ), - m_pFireEvents( i_pFireEvents ) - { } + Impl( bool i_bIgnoreRuntimeExceptionsWhileFiring, + IEventNotificationHook *i_pFireEvents + ) + :m_bIgnoreRuntimeExceptionsWhileFiring( i_bIgnoreRuntimeExceptionsWhileFiring ) + ,m_pFireEvents( i_pFireEvents ) + { + } bool m_bIgnoreRuntimeExceptionsWhileFiring; class IEventNotificationHook * const m_pFireEvents; + + ::std::vector< sal_Int32 > m_handles; + ::std::vector< Any > m_newValues; + ::std::vector< Any > m_oldValues; }; @@ -435,6 +441,57 @@ void OPropertySetHelper::removeVetoableChangeListener( } } +void OPropertySetHelper::setDependentFastPropertyValue( sal_Int32 i_handle, const ::com::sun::star::uno::Any& i_value ) +{ + //OSL_PRECOND( rBHelper.rMutex.isAcquired(), "OPropertySetHelper::setDependentFastPropertyValue: to be called with a locked mutex only!" ); + // there is no such thing as Mutex.isAcquired, sadly ... + + sal_Int16 nAttributes(0); + IPropertyArrayHelper& rInfo = getInfoHelper(); + if ( !rInfo.fillPropertyMembersByHandle( NULL, &nAttributes, i_handle ) ) + // unknown property + throw UnknownPropertyException(); + + // no need to check for READONLY-ness of the property. The method is intended to be called internally, which + // implies it might be invoked for properties which are read-only to the instance's clients, but well allowed + // to change their value. + + Any aConverted, aOld; + sal_Bool bChanged = convertFastPropertyValue( aConverted, aOld, i_handle, i_value ); + if ( !bChanged ) + return; + + // don't fire vetoable events. This method is called with our mutex locked, so calling into listeners would not be + // a good idea. The caler is responsible for not invoking this for constrained properties. + OSL_ENSURE( ( nAttributes & PropertyAttribute::CONSTRAINED ) == 0, + "OPropertySetHelper::setDependentFastPropertyValue: not to be used for constrained properties!" ); + (void)nAttributes; + + // actually set the new value + try + { + setFastPropertyValue_NoBroadcast( i_handle, aConverted ); + } + catch (const UnknownPropertyException& ) { throw; /* allowed to leave */ } + catch (const PropertyVetoException& ) { throw; /* allowed to leave */ } + catch (const IllegalArgumentException& ) { throw; /* allowed to leave */ } + catch (const WrappedTargetException& ) { throw; /* allowed to leave */ } + catch (const RuntimeException& ) { throw; /* allowed to leave */ } + catch (const Exception& ) + { + // not allowed to leave this meathod + WrappedTargetException aWrapped; + aWrapped.TargetException <<= ::cppu::getCaughtException(); + aWrapped.Context = static_cast< XPropertySet* >( this ); + throw aWrapped; + } + + // remember the handle/values, for the events to be fired later + m_pReserved->m_handles.push_back( i_handle ); + m_pReserved->m_newValues.push_back( aConverted ); // TODO: setFastPropertyValue notifies the unconverted value here ...? + m_pReserved->m_oldValues.push_back( aOld ); +} + // XFastPropertySet void OPropertySetHelper::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, @@ -501,7 +558,7 @@ void OPropertySetHelper::setFastPropertyValue( sal_Int32 nHandle, const Any& rVa // release guard to fire events } // file a change event, if the value changed - fire( &nHandle, &rValue, &aOldVal, 1, sal_False ); + impl_fireAll( &nHandle, &rValue, &aOldVal, 1 ); } } @@ -524,6 +581,42 @@ Any OPropertySetHelper::getFastPropertyValue( sal_Int32 nHandle ) } //-------------------------------------------------------------------------- +void OPropertySetHelper::impl_fireAll( sal_Int32* i_handles, const Any* i_newValues, const Any* i_oldValues, sal_Int32 i_count ) +{ + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if ( m_pReserved->m_handles.empty() ) + { + aGuard.clear(); + fire( i_handles, i_newValues, i_oldValues, i_count, sal_False ); + return; + } + + const size_t additionalEvents = m_pReserved->m_handles.size(); + OSL_ENSURE( additionalEvents == m_pReserved->m_newValues.size() + && additionalEvents == m_pReserved->m_oldValues.size(), + "OPropertySetHelper::impl_fireAll: inconsistency!" ); + + ::std::vector< sal_Int32 > allHandles( additionalEvents + i_count ); + ::std::copy( m_pReserved->m_handles.begin(), m_pReserved->m_handles.end(), allHandles.begin() ); + ::std::copy( i_handles, i_handles + i_count, allHandles.begin() + additionalEvents ); + + ::std::vector< Any > allNewValues( additionalEvents + i_count ); + ::std::copy( m_pReserved->m_newValues.begin(), m_pReserved->m_newValues.end(), allNewValues.begin() ); + ::std::copy( i_newValues, i_newValues + i_count, allNewValues.begin() + additionalEvents ); + + ::std::vector< Any > allOldValues( additionalEvents + i_count ); + ::std::copy( m_pReserved->m_oldValues.begin(), m_pReserved->m_oldValues.end(), allOldValues.begin() ); + ::std::copy( i_oldValues, i_oldValues + i_count, allOldValues.begin() + additionalEvents ); + + m_pReserved->m_handles.clear(); + m_pReserved->m_newValues.clear(); + m_pReserved->m_oldValues.clear(); + + aGuard.clear(); + fire( &allHandles[0], &allNewValues[0], &allOldValues[0], additionalEvents + i_count, sal_False ); +} + +//-------------------------------------------------------------------------- void OPropertySetHelper::fire ( sal_Int32 * pnHandles, @@ -806,7 +899,7 @@ void OPropertySetHelper::setFastPropertyValues( } // fire change events - fire( pHandles, pConvertedValues, pOldValues, n, sal_False ); + impl_fireAll( pHandles, pConvertedValues, pOldValues, n ); } catch( ... ) { diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx index 1a9b85a75..584e9b5aa 100644 --- a/cppuhelper/source/servicefactory.cxx +++ b/cppuhelper/source/servicefactory.cxx @@ -29,13 +29,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" @@ -47,6 +43,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" @@ -65,6 +62,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 { @@ -418,39 +416,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)); } } } diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx index 90547ed9b..b2a68c5d0 100644 --- a/cppuhelper/source/tdmgr.cxx +++ b/cppuhelper/source/tdmgr.cxx @@ -28,6 +28,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cppuhelper.hxx" + +#include "sal/config.h" + +#include <vector> + #include <sal/alloca.h> #include <osl/diagnose.h> @@ -46,7 +51,7 @@ #include <com/sun/star/reflection/XEnumTypeDescription.hpp> #include <com/sun/star/reflection/XIndirectTypeDescription.hpp> #include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp> -#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp> +#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp> #include <com/sun/star/reflection/XMethodParameter.hpp> #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp> #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp> @@ -303,7 +308,7 @@ inline static typelib_TypeDescription * createCTD( } //================================================================================================== inline static typelib_TypeDescription * createCTD( - const Reference< XInterfaceAttributeTypeDescription > & xAttribute ) + const Reference< XInterfaceAttributeTypeDescription2 > & xAttribute ) { typelib_TypeDescription * pRet = 0; if (xAttribute.is()) @@ -311,14 +316,31 @@ inline static typelib_TypeDescription * createCTD( OUString aMemberName( xAttribute->getName() ); Reference< XTypeDescription > xType( xAttribute->getType() ); OUString aMemberTypeName( xType->getName() ); - - typelib_typedescription_newInterfaceAttribute( + std::vector< rtl_uString * > getExc; + Sequence< Reference< XCompoundTypeDescription > > getExcs( + xAttribute->getGetExceptions() ); + for (sal_Int32 i = 0; i != getExcs.getLength(); ++i) + { + OSL_ASSERT( getExcs[i].is() ); + getExc.push_back( getExcs[i]->getName().pData ); + } + std::vector< rtl_uString * > setExc; + Sequence< Reference< XCompoundTypeDescription > > setExcs( + xAttribute->getSetExceptions() ); + for (sal_Int32 i = 0; i != setExcs.getLength(); ++i) + { + OSL_ASSERT( setExcs[i].is() ); + setExc.push_back( setExcs[i]->getName().pData ); + } + typelib_typedescription_newExtendedInterfaceAttribute( (typelib_InterfaceAttributeTypeDescription **)&pRet, xAttribute->getPosition(), aMemberName.pData, // name (typelib_TypeClass)xType->getTypeClass(), aMemberTypeName.pData, // type name - xAttribute->isReadOnly() ); + xAttribute->isReadOnly(), + getExc.size(), getExc.empty() ? 0 : &getExc[0], + setExc.size(), setExc.empty() ? 0 : &setExc[0] ); } return pRet; } @@ -643,7 +665,7 @@ static typelib_TypeDescription * createCTD( pRet = createCTD( Reference< XInterfaceMethodTypeDescription >::query( xType ) ); break; case TypeClass_INTERFACE_ATTRIBUTE: - pRet = createCTD( Reference< XInterfaceAttributeTypeDescription >::query( xType ) ); + pRet = createCTD( Reference< XInterfaceAttributeTypeDescription2 >::query( xType ) ); break; default: break; |