diff options
50 files changed, 385 insertions, 765 deletions
diff --git a/canvas/source/factory/cf_service.cxx b/canvas/source/factory/cf_service.cxx index 7b8e876e7c00..349e9bdc3301 100644 --- a/canvas/source/factory/cf_service.cxx +++ b/canvas/source/factory/cf_service.cxx @@ -39,6 +39,7 @@ #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> @@ -154,9 +155,7 @@ CanvasFactory::CanvasFactory( Reference<XComponentContext> const & xContext ) : { // read out configuration for preferred services: Reference<lang::XMultiServiceFactory> xConfigProvider( - m_xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.configuration.ConfigurationProvider"), - m_xContext ), UNO_QUERY_THROW ); + configuration::theDefaultProvider::get( m_xContext ) ); Any propValue( makeAny( beans::PropertyValue( diff --git a/comphelper/inc/comphelper/processfactory.hxx b/comphelper/inc/comphelper/processfactory.hxx index 6f608ccd6839..e3651530cfc3 100644 --- a/comphelper/inc/comphelper/processfactory.hxx +++ b/comphelper/inc/comphelper/processfactory.hxx @@ -75,6 +75,17 @@ COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XI const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArgs ) SAL_THROW( ( ::com::sun::star::uno::RuntimeException ) ); +/** Tries to obtain a component context from a service factory. + + @param factory may be null + @return may be null + */ +COMPHELPER_DLLPUBLIC +com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > +getComponentContext( + com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > + const & factory); + /** * This function gets the process service factory's default component context. * If no service factory is set the function returns a null interface. diff --git a/comphelper/source/misc/configurationhelper.cxx b/comphelper/source/misc/configurationhelper.cxx index 1016c88b341c..9911fd23d5f4 100644 --- a/comphelper/source/misc/configurationhelper.cxx +++ b/comphelper/source/misc/configurationhelper.cxx @@ -32,7 +32,9 @@ //_______________________________________________ // includes #include <comphelper/configurationhelper.hxx> +#include <comphelper/processfactory.hxx> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> @@ -53,7 +55,8 @@ css::uno::Reference< css::uno::XInterface > ConfigurationHelper::openConfig(cons sal_Int32 eMode ) { css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( - xSMGR->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))), css::uno::UNO_QUERY_THROW); + css::configuration::theDefaultProvider::get( + getComponentContext( xSMGR ) ) ); ::comphelper::SequenceAsVector< css::uno::Any > lParams; css::beans::PropertyValue aParam ; diff --git a/comphelper/source/misc/mimeconfighelper.cxx b/comphelper/source/misc/mimeconfighelper.cxx index dfa66e839bd9..92f4a2578930 100644 --- a/comphelper/source/misc/mimeconfighelper.cxx +++ b/comphelper/source/misc/mimeconfighelper.cxx @@ -29,11 +29,13 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_comphelper.hxx" #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XContainerQuery.hpp> #include <com/sun/star/document/XTypeDetection.hpp> #include <comphelper/fileformat.h> #include <comphelper/mimeconfighelper.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/classids.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/documentconstants.hxx> @@ -131,10 +133,8 @@ uno::Reference< container::XNameAccess > MimeConfigurationHelper::GetConfigurati try { if ( !m_xConfigProvider.is() ) - m_xConfigProvider = uno::Reference< lang::XMultiServiceFactory >( - m_xFactory->createInstance( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" )) ), - uno::UNO_QUERY_THROW ); + m_xConfigProvider = configuration::theDefaultProvider::get( + getComponentContext( m_xFactory ) ); uno::Sequence< uno::Any > aArgs( 1 ); beans::PropertyValue aPathProp; diff --git a/comphelper/source/processfactory/processfactory.cxx b/comphelper/source/processfactory/processfactory.cxx index f9b2218f7018..c07d195190a2 100644 --- a/comphelper/source/processfactory/processfactory.cxx +++ b/comphelper/source/processfactory/processfactory.cxx @@ -96,11 +96,11 @@ Reference< XInterface > createProcessComponentWithArguments( const ::rtl::OUStri return xComponent; } -Reference< XComponentContext > getProcessComponentContext() +Reference< XComponentContext > getComponentContext( + Reference< XMultiServiceFactory > const & factory) { Reference< XComponentContext > xRet; - uno::Reference<beans::XPropertySet> const xProps( - comphelper::getProcessServiceFactory(), uno::UNO_QUERY ); + uno::Reference<beans::XPropertySet> const xProps( factory, uno::UNO_QUERY ); if (xProps.is()) { try { xRet.set( xProps->getPropertyValue( rtl::OUString( @@ -113,6 +113,11 @@ Reference< XComponentContext > getProcessComponentContext() return xRet; } +Reference< XComponentContext > getProcessComponentContext() +{ + return getComponentContext( getProcessServiceFactory() ); +} + } // namespace comphelper extern "C" { diff --git a/configmgr/qa/unit/test.cxx b/configmgr/qa/unit/test.cxx index fe8d29e9ef88..f645517a3426 100644 --- a/configmgr/qa/unit/test.cxx +++ b/configmgr/qa/unit/test.cxx @@ -36,6 +36,7 @@ #include "com/sun/star/beans/XPropertyChangeListener.hpp" #include "com/sun/star/beans/XPropertySet.hpp" #include "com/sun/star/beans/XPropertyState.hpp" +#include "com/sun/star/configuration/theDefaultProvider.hpp" #include "com/sun/star/container/XHierarchicalNameAccess.hpp" #include "com/sun/star/container/XNameReplace.hpp" #include "com/sun/star/container/XNamed.hpp" @@ -371,13 +372,7 @@ void Test::setUp() { css::uno::UNO_QUERY_THROW)->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))), css::uno::UNO_QUERY_THROW); - CPPUNIT_ASSERT( - context_->getValueByName( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "/singletons/" - "com.sun.star.configuration.theDefaultProvider"))) >>= - provider_); + provider_ = css::configuration::theDefaultProvider::get(context_); } void Test::tearDown() { diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx index 2db64d365b12..ff2220a6d407 100644 --- a/connectivity/source/cpool/ZPoolCollection.cxx +++ b/connectivity/source/cpool/ZPoolCollection.cxx @@ -31,9 +31,12 @@ #include "ZPoolCollection.hxx" #include "ZDriverWrapper.hxx" #include "ZConnectionPool.hxx" +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <comphelper/extract.hxx> +#include <comphelper/processfactory.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include "diagnose_ex.h" @@ -351,71 +354,30 @@ OConnectionPool* OPoolCollection::getConnectionPool(const ::rtl::OUString& _sImp // ----------------------------------------------------------------------------- Reference< XInterface > OPoolCollection::createWithServiceFactory(const ::rtl::OUString& _rPath) const { - Reference< XInterface > xInterface; - try - { - Reference< XInterface > xProvider = m_xServiceFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))); - OSL_ENSURE(xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: could not instantiate the config provider service!"); - Reference< XMultiServiceFactory > xProviderAsFac(xProvider, UNO_QUERY); - OSL_ENSURE(xProviderAsFac.is() || !xProvider.is(), "OConfigurationTreeRoot::createWithServiceFactory: the provider is missing an interface!"); - if (xProviderAsFac.is()) - xInterface = createWithProvider(xProviderAsFac, _rPath); - } - catch(const Exception&) - { - OSL_FAIL("createWithServiceFactory: error while instantiating the provider service!"); - } - return xInterface; + return createWithProvider( + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getComponentContext(m_xServiceFactory)), + _rPath); } //------------------------------------------------------------------------ Reference< XInterface > OPoolCollection::createWithProvider(const Reference< XMultiServiceFactory >& _rxConfProvider, const ::rtl::OUString& _rPath) const { - OSL_ENSURE(_rxConfProvider.is(), "createWithProvider: invalid provider!"); - - Reference< XInterface > xInterface; -#ifdef DBG_UTIL - if (_rxConfProvider.is()) - { - try - { - Reference< XServiceInfo > xSI(_rxConfProvider, UNO_QUERY); - if (!xSI.is()) - { - OSL_FAIL("::createWithProvider: no XServiceInfo interface on the provider!"); - } - else - { - OSL_ENSURE(xSI->supportsService(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))), - "::createWithProvider: sure this is a provider? Missing the ConfigurationProvider service!"); - } - } - catch(const Exception&) - { - OSL_FAIL("::createWithProvider: unable to check the service conformance of the provider given!"); - } - } -#endif - - if (_rxConfProvider.is()) - { - try - { - Sequence< Any > aCreationArgs(3); - aCreationArgs[0] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), 0, makeAny(_rPath), PropertyState_DIRECT_VALUE)); - aCreationArgs[1] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("depth")), 0, makeAny((sal_Int32)-1), PropertyState_DIRECT_VALUE)); - aCreationArgs[2] = makeAny(PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")), 0, makeAny(sal_True), PropertyState_DIRECT_VALUE)); - - static ::rtl::OUString sAccessService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" )); - - xInterface = _rxConfProvider->createInstanceWithArguments(sAccessService, aCreationArgs); - OSL_ENSURE(xInterface.is(), "::createWithProvider: could not create the node access!"); - } - catch(Exception&) - { - OSL_FAIL("OConfigurationTreeRoot::createWithProvider: caught an exception while creating the access object!"); - } - } + OSL_ASSERT(_rxConfProvider.is()); + Sequence< Any > args(1); + args[0] = makeAny( + NamedValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), + makeAny(_rPath))); + Reference< XInterface > xInterface( + _rxConfProvider->createInstanceWithArguments( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.configuration.ConfigurationAccess")), + args)); + OSL_ENSURE( + xInterface.is(), + "::createWithProvider: could not create the node access!"); return xInterface; } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/cpool/makefile.mk b/connectivity/source/cpool/makefile.mk index 45ec3727ea3b..a1424dd4d1a8 100755 --- a/connectivity/source/cpool/makefile.mk +++ b/connectivity/source/cpool/makefile.mk @@ -59,6 +59,7 @@ SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1OBJS=$(SLOFILES) SHL1STDLIBS=\ + $(COMPHELPERLIB) \ $(CPPULIB) \ $(CPPUHELPERLIB) \ $(DBTOOLSLIB) \ diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx index 7d2623a31452..d59d4cc6fd61 100644 --- a/connectivity/source/drivers/hsqldb/HDriver.cxx +++ b/connectivity/source/drivers/hsqldb/HDriver.cxx @@ -32,6 +32,7 @@ #include "hsqldb/HConnection.hxx" #include <osl/diagnose.h> #include "connectivity/dbexception.hxx" +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/sdbc/XDriverAccess.hpp> #include <com/sun/star/sdbc/XResultSet.hpp> #include <com/sun/star/sdbc/XRow.hpp> @@ -53,6 +54,7 @@ #include <osl/process.h> #include <connectivity/dbexception.hxx> #include <comphelper/namedvaluecollection.hxx> +#include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> #include <unotools/confignode.hxx> #include <unotools/ucbstreamhelper.hxx> @@ -837,13 +839,8 @@ namespace connectivity { //......................................................... Reference< XMultiServiceFactory > xConfigProvider( - _rxORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")) ), - UNO_QUERY - ); - OSL_ENSURE( xConfigProvider.is(), "lcl_getSystemLocale: could not create the config provider!" ); - - if ( !xConfigProvider.is() ) - return sLocaleString; + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getComponentContext( _rxORB ) ) ); //......................................................... // arguments for creating the config access diff --git a/connectivity/source/drivers/kab/KDriver.cxx b/connectivity/source/drivers/kab/KDriver.cxx index 7240e53e6a2d..a67c6ca2965b 100644 --- a/connectivity/source/drivers/kab/KDriver.cxx +++ b/connectivity/source/drivers/kab/KDriver.cxx @@ -35,10 +35,12 @@ #include "rtl/strbuf.hxx" /** === begin UNO includes === **/ +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/sdb/SQLContext.hpp> #include <com/sun/star/lang/NullPointerException.hpp> #include <com/sun/star/frame/XDesktop.hpp> /** === end UNO includes === **/ +#include <comphelper/processfactory.hxx> #include <rtl/ustrbuf.hxx> #include <tools/diagnose_ex.h> #include "resource/kab_res.hrc" @@ -192,8 +194,8 @@ bool KabImplModule::impl_doAllowNewKDEVersion() try { Reference< XMultiServiceFactory > xConfigProvider( - m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ), - UNO_QUERY_THROW ); + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getComponentContext( m_xORB ) ) ); Sequence< Any > aCreationArgs(1); aCreationArgs[0] <<= PropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), diff --git a/connectivity/source/drivers/kab/makefile.mk b/connectivity/source/drivers/kab/makefile.mk index 13d4857c9182..b3690cc7c75c 100755 --- a/connectivity/source/drivers/kab/makefile.mk +++ b/connectivity/source/drivers/kab/makefile.mk @@ -69,6 +69,7 @@ SHL1VERSIONMAP=$(SOLARENV)/src/component.map SHL1TARGET= $(TARGET)$(KAB_MAJOR) SHL1OBJS=$(SLOFILES) SHL1STDLIBS=\ + $(COMPHELPERLIB) \ $(CPPULIB) \ $(CPPUHELPERLIB) \ $(DBTOOLSLIB) \ diff --git a/connectivity/source/drivers/mozab/MConfigAccess.cxx b/connectivity/source/drivers/mozab/MConfigAccess.cxx index 482f1f8bdd20..e5c1f0d7fa4f 100644 --- a/connectivity/source/drivers/mozab/MConfigAccess.cxx +++ b/connectivity/source/drivers/mozab/MConfigAccess.cxx @@ -29,6 +29,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_connectivity.hxx" +#include "com/sun/star/configuration/theDefaultProvider.hpp" +#include "comphelper/processfactory.hxx" + #include "MConfigAccess.hxx" #include "MExtConfigAccess.hxx" #include "MConnection.hxx" @@ -51,44 +54,39 @@ namespace connectivity //============================================================= // create the config provider Reference< XMultiServiceFactory > xConfigProvider( - _rxORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider" )) ), - UNO_QUERY - ); - OSL_ENSURE( xConfigProvider.is(), "createDriverConfigNode: could not create the config provider!" ); + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getComponentContext( _rxORB ) ) ); - if ( xConfigProvider.is() ) - { - ::rtl::OUString sCompleteNodePath(RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/DriverSettings/" )); - sCompleteNodePath += OConnection::getDriverImplementationName(); + ::rtl::OUString sCompleteNodePath(RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.DataAccess/DriverSettings/" )); + sCompleteNodePath += OConnection::getDriverImplementationName(); - //========================================================= - // arguments for creating the config access - Sequence< Any > aArguments(2); - // the path to the node to open - aArguments[0] <<= PropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath")), - 0, - makeAny( sCompleteNodePath ), - PropertyState_DIRECT_VALUE - ); - // the depth: -1 means unlimited - aArguments[1] <<= PropertyValue( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("depth")), - 0, - makeAny( (sal_Int32)-1 ), - PropertyState_DIRECT_VALUE - ); + //========================================================= + // arguments for creating the config access + Sequence< Any > aArguments(2); + // the path to the node to open + aArguments[0] <<= PropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath")), + 0, + makeAny( sCompleteNodePath ), + PropertyState_DIRECT_VALUE + ); + // the depth: -1 means unlimited + aArguments[1] <<= PropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("depth")), + 0, + makeAny( (sal_Int32)-1 ), + PropertyState_DIRECT_VALUE + ); - //========================================================= - // create the access - Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess" )), - aArguments - ); - OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" ); + //========================================================= + // create the access + Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess" )), + aArguments + ); + OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" ); - xNode = xNode.query( xAccess ); - } + xNode = xNode.query( xAccess ); } catch( const Exception& ) { diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index 261d02057bf8..8deab81404ec 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -32,11 +32,11 @@ #include <stdio.h> #include "mdrivermanager.hxx" +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/sdbc/XDriver.hpp> #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/container/ElementExistException.hpp> #include <com/sun/star/beans/NamedValue.hpp> -#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> #include <tools/diagnose_ex.h> #include <comphelper/extract.hxx> @@ -186,16 +186,15 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, W try { // some strings we need - const ::rtl::OUString sConfigurationProviderServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" )); const ::rtl::OUString sDriverManagerConfigLocation( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Office.DataAccess/DriverManager" )); const ::rtl::OUString sDriverPreferenceLocation( RTL_CONSTASCII_USTRINGPARAM( "DriverPrecedence" )); const ::rtl::OUString sNodePathArgumentName( RTL_CONSTASCII_USTRINGPARAM( "nodepath" )); const ::rtl::OUString sNodeAccessServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" )); // create a configuration provider - Reference< XMultiServiceFactory > xConfigurationProvider; - if ( !_rContext.createComponent( sConfigurationProviderServiceName, xConfigurationProvider ) ) - throw ServiceNotRegisteredException( sConfigurationProviderServiceName, NULL ); + Reference< XMultiServiceFactory > xConfigurationProvider( + com::sun::star::configuration::theDefaultProvider::get( + _rContext.getUNOContext() ) ); // one argument for creating the node access: the path to the configuration node Sequence< Any > aCreationArgs(1); diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx index 72355b768ea0..3d2fdb460a66 100644 --- a/cui/source/options/optgdlg.cxx +++ b/cui/source/options/optgdlg.cxx @@ -77,6 +77,7 @@ #include <unotools/saveopt.hxx> #include <sal/macros.h> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> @@ -587,17 +588,14 @@ CanvasSettings::CanvasSettings() : { try { - Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); Reference<XMultiServiceFactory> xConfigProvider( - xFactory->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))), - UNO_QUERY_THROW ); + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext())); Any propValue( - makeAny( PropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), -1, - makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Canvas")) ), - PropertyState_DIRECT_VALUE ) ) ); + makeAny( NamedValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), + makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Canvas")) ) ) ) ); mxForceFlagNameAccess.set( xConfigProvider->createInstanceWithArguments( @@ -606,10 +604,9 @@ CanvasSettings::CanvasSettings() : UNO_QUERY_THROW ); propValue = makeAny( - PropertyValue( - OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), -1, - makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Canvas/CanvasServiceList")) ), - PropertyState_DIRECT_VALUE ) ); + NamedValue( + OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), + makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.Canvas/CanvasServiceList")) ) ) ); Reference<XNameAccess> xNameAccess( xConfigProvider->createInstanceWithArguments( @@ -1230,7 +1227,6 @@ struct LanguageConfig_Impl static sal_Bool bLanguageCurrentDoc_Impl = sal_False; // some things we'll need... -static const OUString sConfigSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")); static const OUString sAccessSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")); static const OUString sAccessUpdSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")); static const OUString sInstalledLocalesPath(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup/Office/InstalledLocales")); @@ -1293,15 +1289,14 @@ OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSe OUString sOfficeLocaleValue; OUString sSystemLocaleValue; - Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); - Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > ( - theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW); - Sequence< Any > theArgs(2); + Reference< XMultiServiceFactory > theConfigProvider( + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext())); + Sequence< Any > theArgs(1); Reference< XNameAccess > theNameAccess; // find out which locales are currently installed and add them to the listbox - theArgs[0] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")), makeAny(sInstalledLocalesPath))); - theArgs[1] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("reload")), makeAny(sal_True))); + theArgs[0] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), makeAny(sInstalledLocalesPath))); theNameAccess = Reference< XNameAccess > ( theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW ); seqInstalledLanguages = theNameAccess->getElementNames(); @@ -1320,7 +1315,7 @@ OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSe // find out whether the user has a specific locale specified Sequence< Any > theArgs2(1); - theArgs2[0] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")), makeAny(sUserLocalePath))); + theArgs2[0] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), makeAny(sUserLocalePath))); theNameAccess = Reference< XNameAccess > ( theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW ); if (theNameAccess->hasByName(sUserLocaleKey)) @@ -1490,11 +1485,11 @@ sal_Bool OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) if( aUserInterfaceLB.GetSelectEntryPos() > 0) aLangString = ConvertLanguageToIsoString(aUserInterfaceLB.GetSelectLanguage()); */ - Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); - Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > ( - theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW); + Reference< XMultiServiceFactory > theConfigProvider( + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext())); Sequence< Any > theArgs(1); - theArgs[0] = makeAny(sUserLocalePath); + theArgs[0] = makeAny(NamedValue(OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), makeAny(sUserLocalePath))); Reference< XPropertySet >xProp( theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW ); if ( !m_sUserLocaleValue.equals(aLangString)) @@ -1509,6 +1504,8 @@ sal_Bool OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet ) // tell quickstarter to stop being a veto listener + Reference< XMultiServiceFactory > theMSF( + comphelper::getProcessServiceFactory()); Reference< XInitialization > xInit(theMSF->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.office.Quickstart"))), UNO_QUERY); if (xInit.is()) diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index 17a55efdd03a..65679e2de94c 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -86,9 +86,10 @@ #include <rtl/ustring.hxx> #include <osl/file.hxx> #include <osl/process.h> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameReplace.hpp> #include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/util/XChangesBatch.hpp> @@ -224,35 +225,23 @@ SvxProxyTabPage::SvxProxyTabPage(Window* pParent, const SfxItemSet& rSet ) : aProxyModeLB.SetSelectHdl(LINK( this, SvxProxyTabPage, ProxyHdl_Impl )); - Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager( - ::comphelper::getProcessServiceFactory()); + Reference< com::sun::star::lang::XMultiServiceFactory > + xConfigurationProvider( + configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); - if( xServiceManager.is() ) - { - try - { - Reference< com::sun::star::lang::XMultiServiceFactory > xConfigurationProvider = - Reference< com::sun::star::lang::XMultiServiceFactory > ( xServiceManager->createInstance( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ), - UNO_QUERY_THROW); + OUString aConfigRoot(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings" ) ); - OUString aConfigRoot(RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.Inet/Settings" ) ); + beans::NamedValue aProperty; + aProperty.Name = OUString(RTL_CONSTASCII_USTRINGPARAM( "nodepath" )); + aProperty.Value = makeAny( aConfigRoot ); - beans::PropertyValue aProperty; - aProperty.Name = OUString(RTL_CONSTASCII_USTRINGPARAM( "nodepath" )); - aProperty.Value = makeAny( aConfigRoot ); + Sequence< Any > aArgumentList( 1 ); + aArgumentList[0] = makeAny( aProperty ); - Sequence< Any > aArgumentList( 1 ); - aArgumentList[0] = makeAny( aProperty ); - - m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments( rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ), - aArgumentList ); - } - catch ( RuntimeException& ) - { - } - } + m_xConfigurationUpdateAccess = xConfigurationProvider->createInstanceWithArguments( rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ), + aArgumentList ); ArrangeControls_Impl(); } diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx index adcca4524532..ee87645b3bcd 100644 --- a/cui/source/options/optupdt.cxx +++ b/cui/source/options/optupdt.cxx @@ -35,6 +35,7 @@ #include <dialmgr.hxx> #include <cuires.hrc> #include <comphelper/processfactory.hxx> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/ui/dialogs/XFolderPicker.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> @@ -342,10 +343,10 @@ IMPL_LINK( SvxOnlineUpdateTabPage, CheckNowHdl_Impl, PushButton *, EMPTYARG ) try { uno::Reference< lang::XMultiServiceFactory > xConfigProvider( - xFactory->createInstance( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" )), - uno::UNO_QUERY_THROW); + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); - beans::PropertyValue aProperty; + beans::NamedValue aProperty; aProperty.Name = UNISTRING( "nodepath" ); aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Office.Addons/AddonUI/OfficeHelp/UpdateCheckJob") ); diff --git a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java index b22671fa2f18..7e131cd6a02e 100644 --- a/dbaccess/qa/complex/dbaccess/DatabaseDocument.java +++ b/dbaccess/qa/complex/dbaccess/DatabaseDocument.java @@ -26,6 +26,7 @@ ************************************************************************/ package complex.dbaccess; +import com.sun.star.configuration.theDefaultProvider; import com.sun.star.lang.NotInitializedException; import com.sun.star.frame.DoubleInitializationException; import com.sun.star.awt.XTopWindow; @@ -39,6 +40,7 @@ import com.sun.star.task.XInteractionRequest; import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; import com.sun.star.frame.XStorable; +import com.sun.star.beans.NamedValue; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameContainer; @@ -489,11 +491,12 @@ public class DatabaseDocument extends TestCase implements com.sun.star.document. // -------------------------------------------------------------------------------------------------------- private int impl_setMacroSecurityLevel(int _level) throws Exception { - final XMultiServiceFactory configProvider = UnoRuntime.queryInterface(XMultiServiceFactory.class, getMSF().createInstance("com.sun.star.configuration.ConfigurationProvider")); + final XMultiServiceFactory configProvider = theDefaultProvider.get( + getComponentContext()); - final PropertyValue[] args = new PropertyValue[] + final NamedValue[] args = new NamedValue[] { - new PropertyValue("nodepath", 0, "/org.openoffice.Office.Common/Security/Scripting", PropertyState.DIRECT_VALUE) + new NamedValue("nodepath", "/org.openoffice.Office.Common/Security/Scripting") }; final XPropertySet securitySettings = UnoRuntime.queryInterface(XPropertySet.class, configProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", args)); diff --git a/dbaccess/qa/complex/dbaccess/TestCase.java b/dbaccess/qa/complex/dbaccess/TestCase.java index f2cbdf988b38..91378b7dffee 100644 --- a/dbaccess/qa/complex/dbaccess/TestCase.java +++ b/dbaccess/qa/complex/dbaccess/TestCase.java @@ -29,7 +29,6 @@ package complex.dbaccess; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XModel; import com.sun.star.lang.XMultiServiceFactory; @@ -55,18 +54,7 @@ public abstract class TestCase // -------------------------------------------------------------------------------------------------------- protected final XComponentContext getComponentContext() { - XComponentContext context = null; - try - { - final XPropertySet orbProps = UnoRuntime.queryInterface( XPropertySet.class, getMSF() ); - context = UnoRuntime.queryInterface( XComponentContext.class, - orbProps.getPropertyValue( "DefaultContext" ) ); - } - catch ( Exception ex ) - { - fail( "could not retrieve the ComponentContext" ); - } - return context; + return connection.getComponentContext(); } // -------------------------------------------------------------------------------------------------------- diff --git a/desktop/inc/app.hxx b/desktop/inc/app.hxx index f30ac4645e89..fa4553afdc87 100644 --- a/desktop/inc/app.hxx +++ b/desktop/inc/app.hxx @@ -155,7 +155,7 @@ class Desktop : public Application void RemoveTemporaryDirectory(); sal_Bool InitializeInstallation( const rtl::OUString& rAppFilename ); - sal_Bool InitializeConfiguration(); + bool InitializeConfiguration(); void FlushConfiguration(); static sal_Bool shouldLaunchQuickstart(); sal_Bool InitializeQuickstartMode( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rSMgr ); diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 38ba4db1caa5..f851f63e1e9d 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -54,6 +54,7 @@ #include <com/sun/star/frame/XSynchronousDispatch.hpp> #include <com/sun/star/document/CorruptedFilterConfigurationException.hpp> #include <com/sun/star/configuration/CorruptedConfigurationException.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/util/XModifiable.hpp> #include <com/sun/star/util/XFlushable.hpp> @@ -323,14 +324,6 @@ CommandLineArgs& Desktop::GetCommandLineArgs() return theCommandLineArgs::get(); } -sal_Bool InitConfiguration() -{ - RTL_LOGFILE_CONTEXT( aLog, "desktop (jb99855) ::InitConfiguration" ); - - Reference< XMultiServiceFactory > xProvider( CreateApplicationConfigurationProvider( ) ); - return xProvider.is(); -} - namespace { struct BrandName @@ -1971,13 +1964,14 @@ IMPL_LINK( Desktop, ImplInitFilterHdl, ConvertData*, pData ) return GraphicFilter::GetGraphicFilter().GetFilterCallback().Call( pData ); } -sal_Bool Desktop::InitializeConfiguration() +bool Desktop::InitializeConfiguration() { - sal_Bool bOk = sal_False; - + RTL_LOGFILE_CONTEXT( aLog, "desktop (jb99855) ::InitConfiguration" ); try { - bOk = InitConfiguration(); + css::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ); + return true; } catch( ::com::sun::star::lang::ServiceNotRegisteredException& ) { @@ -2033,19 +2027,14 @@ sal_Bool Desktop::InitializeConfiguration() OUString() )); HandleBootstrapPathErrors( ::utl::Bootstrap::INVALID_BASE_INSTALL, aMsg ); } - - return bOk; + return false; } void Desktop::FlushConfiguration() { css::uno::Reference< css::util::XFlushable >( - (css::uno::Reference< css::lang::XMultiServiceFactory >( - comphelper::getProcessServiceFactory(), css::uno::UNO_SET_THROW)-> - createInstance( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationProvider")))), + css::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext()), css::uno::UNO_QUERY_THROW)->flush(); } @@ -2438,116 +2427,6 @@ void Desktop::PreloadConfigurationData() { } } - - static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); - static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ); - - // get configuration provider - Reference< XMultiServiceFactory > xConfigProvider; - xConfigProvider = Reference< XMultiServiceFactory > ( - rFactory->createInstance( sConfigSrvc ),UNO_QUERY ); - - if ( xConfigProvider.is() ) - { - // preload writer configuration - Sequence< Any > theArgs(1); - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Writer/MailMergeWizard")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - // WriterWeb - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.WriterWeb/Content")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - // preload compatibility - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Compatibility/WriterCompatibilityVersion")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - // preload calc configuration - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Calc/Content")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - // preload impress configuration - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.UI.Effects/UserInterface")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Impress/Layout")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - // preload draw configuration - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Draw/Layout")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - // preload ui configuration - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.UI/FilterClassification")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - - // preload addons configuration - theArgs[ 0 ] <<= OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Addons/AddonUI")); - try - { - xNameAccess = Reference< XNameAccess >( - xConfigProvider->createInstanceWithArguments( sAccessSrvc, theArgs ), UNO_QUERY ); - } - catch (::com::sun::star::uno::Exception& ) - { - } - } } void Desktop::OpenClients() diff --git a/desktop/source/app/appfirststart.cxx b/desktop/source/app/appfirststart.cxx index a5a161181efa..7334eeb67551 100644 --- a/desktop/source/app/appfirststart.cxx +++ b/desktop/source/app/appfirststart.cxx @@ -37,6 +37,7 @@ #include <comphelper/processfactory.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/util/XChangesBatch.hpp> #include "app.hxx" @@ -46,20 +47,16 @@ using namespace ::desktop; using namespace ::com::sun::star; using namespace ::com::sun::star::beans; -static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); /* Local function - get access to the configuration */ static Reference< XPropertySet > impl_getConfigurationAccess( const OUString& rPath ) { - Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - - // get configuration provider - Reference< XMultiServiceFactory > xConfigProvider = Reference< XMultiServiceFactory >( - xFactory->createInstance( sConfigSrvc ), UNO_QUERY_THROW ); - + Reference< XMultiServiceFactory > xConfigProvider( + configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); Sequence< Any > aArgs( 1 ); - NamedValue aValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "NodePath" ) ), makeAny( rPath ) ); + NamedValue aValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ), makeAny( rPath ) ); aArgs[0] <<= aValue; return Reference< XPropertySet >( xConfigProvider->createInstanceWithArguments( sAccessSrvc, aArgs ), UNO_QUERY_THROW ); diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 37b1bfe41b22..a279dbfff839 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -48,6 +48,7 @@ #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include "com/sun/star/deployment/XPackage.hpp" #include "com/sun/star/deployment/ExtensionManager.hpp" #include "com/sun/star/deployment/LicenseException.hpp" @@ -220,7 +221,6 @@ void SilentCommandEnv::pop() throw (uno::RuntimeException) } // end namespace //----------------------------------------------------------------------------- -static const OUString sConfigSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); static const OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ); //------------------------------------------------------------------------------ static sal_Int16 impl_showExtensionDialog( uno::Reference< uno::XComponentContext > &xContext ) @@ -326,13 +326,12 @@ static bool impl_checkDependencies( const uno::Reference< uno::XComponentContext static void impl_setNeedsCompatCheck() { try { - Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - // get configuration provider - Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( - xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); + Reference< XMultiServiceFactory > theConfigProvider( + configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); Sequence< Any > theArgs(1); - beans::NamedValue v( OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")), + beans::NamedValue v( OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup/Office")) ) ); theArgs[0] <<= v; Reference< beans::XPropertySet > pset = Reference< beans::XPropertySet >( @@ -379,13 +378,12 @@ static bool impl_needsCompatCheck() rtl::Bootstrap::expandMacros( aCurrentBuildID ); try { - Reference < XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - // get configuration provider - Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( - xFactory->createInstance(sConfigSrvc), UNO_QUERY_THROW); + Reference< XMultiServiceFactory > theConfigProvider( + configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); Sequence< Any > theArgs(1); - beans::NamedValue v( OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")), + beans::NamedValue v( OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), makeAny( OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup/Office")) ) ); theArgs[0] <<= v; Reference< beans::XPropertySet > pset = Reference< beans::XPropertySet >( diff --git a/desktop/source/app/configinit.cxx b/desktop/source/app/configinit.cxx index 16ef67f3b3d7..95affdb039a8 100644 --- a/desktop/source/app/configinit.cxx +++ b/desktop/source/app/configinit.cxx @@ -40,140 +40,24 @@ #include <rtl/ustrbuf.hxx> #include <osl/diagnose.h> #include <stdio.h> -#include <map> -#include <com/sun/star/lang/ServiceNotRegisteredException.hpp> -#include <com/sun/star/configuration/CannotLoadConfigurationException.hpp> -#include <com/sun/star/configuration/InvalidBootstrapFileException.hpp> -#include <com/sun/star/configuration/backend/BackendSetupException.hpp> -#include <com/sun/star/configuration/backend/CannotConnectException.hpp> // ---------------------------------------------------------------------------- namespace uno = ::com::sun::star::uno; namespace lang = ::com::sun::star::lang; -namespace configuration = ::com::sun::star::configuration; -namespace backend = ::com::sun::star::configuration::backend; using rtl::OUString; using uno::UNO_QUERY; -using desktop::Desktop; // ---------------------------------------------------------------------------- -static char const CONFIGURATION_PROVIDER[] = "com.sun.star.configuration.ConfigurationProvider"; - static char const CONFIGURATION_ERROR_HANDLER[] = "com.sun.star.configuration.backend.InteractionHandler"; // must be aligned with configmgr/source/misc/configinteractionhandler static char const CONFIG_ERROR_HANDLER[] = "configuration.interaction-handler"; // ---------------------------------------------------------------------------- -// ---------------------------------------------------------------------------- -#define arraysize( arr ) ( sizeof (arr)/sizeof *(arr) ) - -typedef uno::Reference< lang::XMultiServiceFactory > ConfigurationProvider; - #define OUSTRING( constascii ) OUString( RTL_CONSTASCII_USTRINGPARAM( constascii ) ) -#define OU2O( ustr, enc ) rtl::OUStringToOString( (ustr), RTL_TEXTENCODING_ ## enc ) - -#define k_PROVIDER OUSTRING( CONFIGURATION_PROVIDER ) #define k_ERRORHANDLER OUSTRING( CONFIGURATION_ERROR_HANDLER ) -// ---------------------------------------------------------------------------- -// Get a message string securely. There is a fallback string if the resource -// is not available. Adapted from Desktop::GetMsgString() - -OUString getMsgString( sal_uInt16 nId, char const * aFallBackMsg ) -{ - ResMgr* pResMgr = Desktop::GetDesktopResManager(); - if ( !pResMgr || !nId ) - return OUString::createFromAscii(aFallBackMsg); - else - return OUString( String(ResId( nId, *pResMgr ))); -} -// ---------------------------------------------------------------------------- -/** Creates the normal configuration provider. - -*/ -static -ConfigurationProvider createDefaultConfigurationProvider( ) -{ - uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory(); - - OSL_ENSURE( xServiceManager.is(),"No ServiceManager set for CreateApplicationConfigurationProvider"); - - ConfigurationProvider xProvider; - - if (xServiceManager.is()) - { - - xProvider.set( xServiceManager->createInstance(k_PROVIDER), UNO_QUERY); - } - - if (!xProvider.is()) - { - OUString const sMsg = OUSTRING("Service \"") + k_PROVIDER + - OUSTRING("\" is not available at the service manager."); - - throw lang::ServiceNotRegisteredException(sMsg, xServiceManager); - } - - return xProvider; -} -// ---------------------------------------------------------------------------- -/// @attention this method must be called from a catch statement! -static void handleGeneralException(uno::Exception& aException, - const rtl::OUString& aMessage) -{ - aException.Message = aMessage ; - throw ; -} -// ---------------------------------------------------------------------------- - -uno::Reference< lang::XMultiServiceFactory > CreateApplicationConfigurationProvider( ) -{ - uno::Reference< lang::XMultiServiceFactory > xProvider; - - try - { - xProvider = createDefaultConfigurationProvider( ); - } - catch (configuration::InvalidBootstrapFileException & exception) - { - handleGeneralException(exception, - getMsgString( STR_CONFIG_ERR_SETTINGS_INCOMPLETE, - "The startup settings for your configuration settings are incomplete. ")); - } - catch (backend::CannotConnectException & exception) - { - handleGeneralException(exception, - getMsgString( STR_CONFIG_ERR_CANNOT_CONNECT, - "A connection to your configuration settings could not be established. ")); - } - catch (backend::BackendSetupException & exception) - { - handleGeneralException(exception, - getMsgString( STR_CONFIG_ERR_CANNOT_CONNECT, - "A connection to your configuration settings could not be established. ")); - } - catch (configuration::CannotLoadConfigurationException & exception) - { - handleGeneralException(exception, - getMsgString( STR_CONFIG_ERR_CANNOT_CONNECT, - "A connection to your configuration settings could not be established. ")); - } - catch (uno::Exception & exception) - { - handleGeneralException(exception, - getMsgString( STR_CONFIG_ERR_ACCESS_GENERAL, - "A general error occurred while accessing your configuration settings.")); - } - - - return xProvider ; -} -// ---------------------------------------------------------------------------- - - - // ---------------------------------------------------------------------------- // ConfigurationErrorHandler diff --git a/desktop/source/app/configinit.hxx b/desktop/source/app/configinit.hxx index 24fb01881396..2b5bf67d7fb4 100644 --- a/desktop/source/app/configinit.hxx +++ b/desktop/source/app/configinit.hxx @@ -2,33 +2,8 @@ #ifndef _DESKTOP_CONFIGINIT_HXX_ #define _DESKTOP_CONFIGINIT_HXX_ -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <rtl/ustring.hxx> +#include "sal/config.h" -/** creates a ConfigurationProvider instance -Important: exceptions thrown from that method will contain a readily -displayable message. - - @return - The default configuration provider for the application or<br/> - <NULL/>, if startup was canceled - - @throw com::sun::star::configuration::CannotLoadConfigurationException - if the configuration provider can't be created - - @throw com::sun::star::lang::ServiceNotRegisteredException - if the ConfigurationProvider service is unknwon - - @throw com::sun::star::lang::WrappedTargetException - if the configuration backend could be created, - but incurred a failure later - -*/ -extern -com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > - CreateApplicationConfigurationProvider( ); - -//----------------------------------------------------------------------------- #include <com/sun/star/task/XInteractionHandler.hpp> /** diff --git a/desktop/source/app/langselect.cxx b/desktop/source/app/langselect.cxx index 063fc69b2d35..1a69fcd06627 100644 --- a/desktop/source/app/langselect.cxx +++ b/desktop/source/app/langselect.cxx @@ -41,6 +41,7 @@ #include <tools/config.hxx> #include <i18npool/mslangid.hxx> #include <comphelper/processfactory.hxx> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/beans/NamedValue.hpp> @@ -129,20 +130,10 @@ Locale LanguageSelection::IsoStringToLocale(const OUString& str) bool LanguageSelection::prepareLanguage() { m_eStatus = LS_STATUS_OK; - OUString sConfigSrvc = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")); - Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); - Reference< XLocalizable > theConfigProvider; - try - { - theConfigProvider = Reference< XLocalizable >(theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW ); - } - catch(const Exception&) - { - m_eStatus = LS_STATUS_CONFIGURATIONACCESS_BROKEN; - } - - if(!theConfigProvider.is()) - return false; + Reference< XLocalizable > theConfigProvider( + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ), + UNO_QUERY_THROW ); sal_Bool bSuccess = sal_False; @@ -225,11 +216,6 @@ bool LanguageSelection::prepareLanguage() // this will ensure localized configuration settings to be selected accoring to the // UI language. Locale loc = LanguageSelection::IsoStringToLocale(aLocaleString); - // flush any data already written to the configuration (which - // currently uses independent caches for different locales and thus - // would ignore data written to another cache): - Reference< XFlushable >(theConfigProvider, UNO_QUERY_THROW)-> - flush(); theConfigProvider->setLocale(loc); Reference< XPropertySet > xProp(getConfigAccess("org.openoffice.Setup/L10N/", sal_True), UNO_QUERY_THROW); @@ -371,7 +357,6 @@ Reference< XNameAccess > LanguageSelection::getConfigAccess(const sal_Char* pPat { Reference< XNameAccess > xNameAccess; try{ - OUString sConfigSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")); OUString sAccessSrvc; if (bUpdate) sAccessSrvc = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")); @@ -380,19 +365,16 @@ Reference< XNameAccess > LanguageSelection::getConfigAccess(const sal_Char* pPat OUString sConfigURL = OUString::createFromAscii(pPath); - // get configuration provider - Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); - if (theMSF.is()) { - Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > ( - theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW ); - - // access the provider - Sequence< Any > theArgs(1); - theArgs[ 0 ] <<= sConfigURL; - xNameAccess = Reference< XNameAccess > ( - theConfigProvider->createInstanceWithArguments( - sAccessSrvc, theArgs ), UNO_QUERY_THROW ); - } + Reference< XMultiServiceFactory > theConfigProvider( + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); + + // access the provider + Sequence< Any > theArgs(1); + theArgs[ 0 ] <<= sConfigURL; + xNameAccess = Reference< XNameAccess > ( + theConfigProvider->createInstanceWithArguments( + sAccessSrvc, theArgs ), UNO_QUERY_THROW ); } catch (com::sun::star::uno::Exception& e) { OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US); diff --git a/desktop/source/app/userinstall.cxx b/desktop/source/app/userinstall.cxx index 592821208a34..e6e1c834a892 100644 --- a/desktop/source/app/userinstall.cxx +++ b/desktop/source/app/userinstall.cxx @@ -48,6 +48,7 @@ #include <svl/languageoptions.hxx> #include <unotools/syslocaleoptions.hxx> #include <comphelper/processfactory.hxx> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -82,19 +83,13 @@ namespace desktop { { try { - OUString sConfigSrvc( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.configuration.ConfigurationProvider" ) ); OUString sAccessSrvc( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ); - // get configuration provider - Reference< XMultiServiceFactory > theMSF - = comphelper::getProcessServiceFactory(); - Reference< XMultiServiceFactory > theConfigProvider - = Reference< XMultiServiceFactory >( - theMSF->createInstance(sConfigSrvc), UNO_QUERY_THROW); + Reference< XMultiServiceFactory > theConfigProvider( + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); // localize the provider to user selection Reference< XLocalizable > localizable(theConfigProvider, UNO_QUERY_THROW); @@ -104,7 +99,7 @@ namespace desktop { Sequence< Any > theArgs(1); NamedValue v; - v.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")); + v.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")); v.Value = makeAny(OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup"))); theArgs[0] <<= v; Reference< XHierarchicalNameAccess> hnacc( @@ -261,15 +256,13 @@ namespace desktop { } try { - OUString sConfigSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")); OUString sAccessSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")); - // get configuration provider - Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); - Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory >( - theMSF->createInstance(sConfigSrvc), UNO_QUERY_THROW); + Reference< XMultiServiceFactory > theConfigProvider( + com::sun::star::configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext() ) ); Sequence< Any > theArgs(1); - NamedValue v(OUString(RTL_CONSTASCII_USTRINGPARAM("NodePath")), makeAny(OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")))); + NamedValue v(OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), makeAny(OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Setup")))); theArgs[0] <<= v; Reference< XHierarchicalPropertySet> hpset( theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs), UNO_QUERY_THROW); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 1d90229e7700..f3dd4cc9bea0 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -37,6 +37,7 @@ #include "toolkit/helper/vclunohelper.hxx" #include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/configuration/theDefaultProvider.hpp" #include "dp_gui_dialog2.hxx" #include "dp_gui_extensioncmdqueue.hxx" @@ -75,8 +76,7 @@ TheExtensionManager::TheExtensionManager( Window *pParent, m_xExtensionManager->addModifyListener( this ); uno::Reference< lang::XMultiServiceFactory > xConfig( - xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.configuration.ConfigurationProvider"), xContext ), uno::UNO_QUERY_THROW); + configuration::theDefaultProvider::get(xContext)); uno::Any args[1]; beans::PropertyValue aValue( OUSTR("nodepath"), 0, uno::Any( OUSTR("/org.openoffice.Office.OptionsDialog/Nodes") ), beans::PropertyState_DIRECT_VALUE ); diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index bf31cf195ed1..138c599d3b26 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -51,6 +51,7 @@ #include "com/sun/star/beans/Optional.hpp" #include "com/sun/star/beans/PropertyValue.hpp" #include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/configuration/theDefaultProvider.hpp" #include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/container/XNameContainer.hpp" #include "com/sun/star/deployment/DeploymentException.hpp" @@ -845,10 +846,9 @@ void UpdateDialog::createNotifyJob( bool bPrepareOnly, // notify update check job try { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); uno::Reference< lang::XMultiServiceFactory > xConfigProvider( - xFactory->createInstance( OUSTR( "com.sun.star.configuration.ConfigurationProvider" )), - uno::UNO_QUERY_THROW); + configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext())); beans::PropertyValue aProperty; aProperty.Name = OUSTR( "nodepath" ); @@ -865,6 +865,7 @@ void UpdateDialog::createNotifyJob( bool bPrepareOnly, util::URL aURL; xNameAccess->getByName(OUSTR("URL")) >>= aURL.Complete; + uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); uno::Reference < util::XURLTransformer > xTransformer( xFactory->createInstance( OUSTR( "com.sun.star.util.URLTransformer" ) ), uno::UNO_QUERY_THROW ); @@ -1082,8 +1083,8 @@ bool UpdateDialog::showDescription( const String& rDescription, bool bWithPublis //------------------------------------------------------------------------------ void UpdateDialog::getIgnoredUpdates() { - uno::Reference< lang::XMultiServiceFactory > xConfig( m_context->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.configuration.ConfigurationProvider"), m_context ), uno::UNO_QUERY_THROW); + uno::Reference< lang::XMultiServiceFactory > xConfig( + configuration::theDefaultProvider::get(m_context)); beans::NamedValue aValue( OUSTR("nodepath"), uno::Any( IGNORED_UPDATES ) ); uno::Sequence< uno::Any > args(1); args[0] <<= aValue; @@ -1108,8 +1109,8 @@ void UpdateDialog::storeIgnoredUpdates() { if ( m_bModified && ( !m_ignoredUpdates.empty() ) ) { - uno::Reference< lang::XMultiServiceFactory > xConfig( m_context->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.configuration.ConfigurationProvider"), m_context ), uno::UNO_QUERY_THROW ); + uno::Reference< lang::XMultiServiceFactory > xConfig( + configuration::theDefaultProvider::get(m_context)); beans::NamedValue aValue( OUSTR("nodepath"), uno::Any( IGNORED_UPDATES ) ); uno::Sequence< uno::Any > args(1); args[0] <<= aValue; diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index f242c3449282..a3303d667cbe 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -52,6 +52,7 @@ #include <unotools/configmgr.hxx> #include <com/sun/star/configuration/Update.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/task/XJob.hpp> #include <com/sun/star/beans/NamedValue.hpp> @@ -349,13 +350,10 @@ sal_Bool MigrationImpl::doMigration() void MigrationImpl::refresh() { - uno::Reference< XRefreshable > xRefresh(m_xFactory->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))), uno::UNO_QUERY); - if (xRefresh.is()) - xRefresh->refresh(); - else - OSL_FAIL("could not get XRefresh interface from default config provider. No refresh done."); - + uno::Reference< XRefreshable >( + configuration::theDefaultProvider::get( + comphelper::getComponentContext(m_xFactory)), + uno::UNO_QUERY_THROW)->refresh(); } void MigrationImpl::setMigrationCompleted() @@ -854,7 +852,6 @@ uno::Reference< XNameAccess > MigrationImpl::getConfigAccess(const sal_Char* pPa { uno::Reference< XNameAccess > xNameAccess; try{ - OUString sConfigSrvc(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")); OUString sAccessSrvc; if (bUpdate) sAccessSrvc = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")); @@ -863,10 +860,9 @@ uno::Reference< XNameAccess > MigrationImpl::getConfigAccess(const sal_Char* pPa OUString sConfigURL = OUString::createFromAscii(pPath); - // get configuration provider - uno::Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory(); - uno::Reference< XMultiServiceFactory > theConfigProvider = uno::Reference< XMultiServiceFactory > ( - theMSF->createInstance( sConfigSrvc ),uno::UNO_QUERY_THROW ); + uno::Reference< XMultiServiceFactory > theConfigProvider( + configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext())); // access the provider uno::Sequence< uno::Any > theArgs(1); diff --git a/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java b/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java index bb38108e5eea..6bd50a7a9ff5 100644 --- a/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java +++ b/desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java @@ -26,6 +26,7 @@ *************************************************************************/ package com.sun.star.comp.extensionoptions; +import com.sun.star.configuration.theDefaultProvider; import com.sun.star.lib.uno.helper.Factory; import com.sun.star.lib.uno.helper.WeakBase; import com.sun.star.lang.XMultiComponentFactory; @@ -49,8 +50,7 @@ import com.sun.star.awt.XControlModel; import com.sun.star.awt.XControlContainer; import com.sun.star.container.XNameAccess; import com.sun.star.container.NoSuchElementException; -import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.PropertyState; +import com.sun.star.beans.NamedValue; import com.sun.star.beans.XPropertySet; import com.sun.star.beans.UnknownPropertyException; import com.sun.star.beans.PropertyVetoException; @@ -93,24 +93,15 @@ public class OptionsEventHandler { //Create the com.sun.star.configuration.ConfigurationUpdateAccess //for the registry node which contains the data for our option //pages. - XMultiServiceFactory xConfig; - try { - xConfig = (XMultiServiceFactory) UnoRuntime.queryInterface( - XMultiServiceFactory.class, - m_cmpCtx.getServiceManager().createInstanceWithContext( - "com.sun.star.configuration.ConfigurationProvider", m_cmpCtx)); - } catch (com.sun.star.uno.Exception e) { - e.printStackTrace(); - return; - } + XMultiServiceFactory xConfig = theDefaultProvider.get(m_cmpCtx); //One argument for creating the ConfigurationUpdateAccess is the "nodepath". //Our nodepath point to the node of which the direct subnodes represent the //different options pages. Object[] args = new Object[1]; - args[0] = new PropertyValue( - "nodepath", 0, "/org.openoffice.desktop.deployment.options.ExtensionData/Leaves", - PropertyState.DIRECT_VALUE); + args[0] = new NamedValue( + "nodepath", + "/org.openoffice.desktop.deployment.options.ExtensionData/Leaves"); //We get the com.sun.star.container.XNameAccess from the instance of //ConfigurationUpdateAccess and save it for later use. diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx index 0a1c3a4bec6d..8b4bf198a3f6 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.cxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx @@ -40,6 +40,7 @@ #include <rtl/instance.hxx> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/Optional.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <osl/security.hxx> //============================================================================== @@ -68,10 +69,7 @@ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContex { bReentrantCall = true ; if (!readLdapConfiguration( - css::uno::Reference< css::lang::XMultiServiceFactory >( - xContext->getServiceManager(), - css::uno::UNO_QUERY_THROW), - &aDefinition, &loggedOnUser)) + xContext, &aDefinition, &loggedOnUser)) { throw css::uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LdapUserProfileBe- LDAP not configured")), @@ -100,11 +98,10 @@ LdapUserProfileBe::~LdapUserProfileBe() //------------------------------------------------------------------------------ bool LdapUserProfileBe::readLdapConfiguration( - css::uno::Reference< css::lang::XMultiServiceFactory > const & factory, + css::uno::Reference< css::uno::XComponentContext > const & context, LdapDefinition * definition, rtl::OUString * loggedOnUser) { - OSL_ASSERT(factory.is() && definition != 0 && loggedOnUser != 0); - const rtl::OUString kConfigurationProviderService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")) ; + OSL_ASSERT(context.is() && definition != 0 && loggedOnUser != 0); const rtl::OUString kReadOnlyViewService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")) ; const rtl::OUString kComponent( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.LDAP/UserDirectory")); const rtl::OUString kServerDefiniton(RTL_CONSTASCII_USTRINGPARAM ("ServerDefinition")); @@ -120,11 +117,7 @@ bool LdapUserProfileBe::readLdapConfiguration( try { uno::Reference< lang::XMultiServiceFactory > xCfgProvider( - factory->createInstance(kConfigurationProviderService), - uno::UNO_QUERY); - OSL_ENSURE(xCfgProvider.is(),"LdapUserProfileBe: could not create the configuration provider"); - if (!xCfgProvider.is()) - return false; + css::configuration::theDefaultProvider::get(context)); css::beans::NamedValue aPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")), uno::makeAny(kComponent) ); diff --git a/extensions/source/config/ldap/ldapuserprofilebe.hxx b/extensions/source/config/ldap/ldapuserprofilebe.hxx index 2a6cc93385cc..ccd9af8f42bd 100644 --- a/extensions/source/config/ldap/ldapuserprofilebe.hxx +++ b/extensions/source/config/ldap/ldapuserprofilebe.hxx @@ -31,15 +31,17 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <cppuhelper/compbase2.hxx> #include "ldapaccess.hxx" +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + namespace extensions { namespace config { namespace ldap { namespace css = com::sun::star ; @@ -144,7 +146,7 @@ class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase private: /** Check if LDAP is configured */ bool readLdapConfiguration( - uno::Reference<lang::XMultiServiceFactory> const & factory, + uno::Reference<uno::XComponentContext> const & context, LdapDefinition * definition, rtl::OUString * loggedOnUser); bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess, diff --git a/extensions/source/logging/loggerconfig.cxx b/extensions/source/logging/loggerconfig.cxx index a8d216162677..eb97216536f6 100644 --- a/extensions/source/logging/loggerconfig.cxx +++ b/extensions/source/logging/loggerconfig.cxx @@ -32,6 +32,7 @@ #include "loggerconfig.hxx" /** === begin UNO includes === **/ +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> @@ -214,11 +215,9 @@ namespace logging if ( !_rxLogger.is() ) throw NullPointerException(); - // the configuration provider - Reference< XMultiServiceFactory > xConfigProvider; - ::rtl::OUString sConfigProvServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ); - if ( !_rContext.createComponent( sConfigProvServiceName, xConfigProvider ) ) - throw ServiceNotRegisteredException( sConfigProvServiceName, _rxLogger ); + Reference< XMultiServiceFactory > xConfigProvider( + com::sun::star::configuration::theDefaultProvider::get( + _rContext.getUNOContext())); // write access to the "Settings" node (which includes settings for all loggers) Sequence< Any > aArguments(1); diff --git a/extensions/source/oooimprovement/makefile.mk b/extensions/source/oooimprovement/makefile.mk index a24707ecd13e..1a7e4ba17711 100644 --- a/extensions/source/oooimprovement/makefile.mk +++ b/extensions/source/oooimprovement/makefile.mk @@ -60,6 +60,7 @@ SLOFILES= \ $(SLO)$/soapsender.obj \ SHL1STDLIBS= \ + $(COMPHELPERLIB) \ $(CPPUHELPERLIB) \ $(CPPULIB) \ $(SALLIB) \ diff --git a/extensions/source/oooimprovement/myconfigurationhelper.cxx b/extensions/source/oooimprovement/myconfigurationhelper.cxx index b211fdb6756c..1aaeddc826db 100644 --- a/extensions/source/oooimprovement/myconfigurationhelper.cxx +++ b/extensions/source/oooimprovement/myconfigurationhelper.cxx @@ -30,32 +30,23 @@ #include "precompiled_extensions.hxx" #include "myconfigurationhelper.hxx" +#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <comphelper/processfactory.hxx> #include <rtl/ustrbuf.hxx> -#include <vector> - namespace css = ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using ::rtl::OUString; using ::rtl::OUStringBuffer; -using ::std::vector; - namespace { - static const Sequence<Any> sequenceFromVector(const vector<Any>& vec) - { - Sequence<Any> result(vec.size()); - for(size_t idx = 0; idx < vec.size(); ++idx) - result[idx] = vec[idx]; - return result; - }; - static const OUString noSuchElement(const OUString& path) { OUStringBuffer buf(256); @@ -74,30 +65,16 @@ namespace oooimprovement sal_Int32 eMode) { Reference<XMultiServiceFactory> xConfigProvider( - xSMGR->createInstance(OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))), - UNO_QUERY_THROW); + css::configuration::theDefaultProvider::get( + comphelper::getComponentContext(xSMGR))); - vector<Any> lParams; - css::beans::PropertyValue aParam; + css::uno::Sequence<Any> lParams(1); + css::beans::NamedValue aParam; // set root path aParam.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath")); aParam.Value <<= sPackage; - lParams.push_back(makeAny(aParam)); - - // enable all locales mode - if ((eMode & MyConfigurationHelper::E_ALL_LOCALES)==MyConfigurationHelper::E_ALL_LOCALES) - { - aParam.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("locale")); - aParam.Value <<= OUString(RTL_CONSTASCII_USTRINGPARAM("*")); - lParams.push_back(makeAny(aParam)); - } - - // enable lazy writing - sal_Bool bLazy = ((eMode & MyConfigurationHelper::E_LAZY_WRITE)==MyConfigurationHelper::E_LAZY_WRITE); - aParam.Name = OUString(RTL_CONSTASCII_USTRINGPARAM("lazywrite")); - aParam.Value = makeAny(bLazy); - lParams.push_back(makeAny(aParam)); + lParams[0] = makeAny(aParam); // open it Reference<XInterface> xCFG; @@ -106,11 +83,11 @@ namespace oooimprovement if (bReadOnly) xCFG = xConfigProvider->createInstanceWithArguments( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")), - sequenceFromVector(lParams)); + lParams); else xCFG = xConfigProvider->createInstanceWithArguments( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")), - sequenceFromVector(lParams)); + lParams); return xCFG; } diff --git a/extensions/source/oooimprovement/myconfigurationhelper.hxx b/extensions/source/oooimprovement/myconfigurationhelper.hxx index 619d8cf93e06..56b3d1353c8f 100644 --- a/extensions/source/oooimprovement/myconfigurationhelper.hxx +++ b/extensions/source/oooimprovement/myconfigurationhelper.hxx @@ -61,10 +61,6 @@ namespace oooimprovement E_STANDARD = 0, /// configuration will be opened readonly E_READONLY = 1, - /// all localized nodes will be interpreted as css::uno::XInterface instead of interpreting it as atomic value nodes - E_ALL_LOCALES = 2, - /// enable lazy writing - E_LAZY_WRITE = 4 }; //----------------------------------------------- diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx index 68123924c567..1a594dec7ef2 100644 --- a/extensions/source/update/check/download.cxx +++ b/extensions/source/update/check/download.cxx @@ -41,6 +41,7 @@ #include <curl/curl.h> #endif #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -194,21 +195,8 @@ progress_callback( void *clientp, double dltotal, double dlnow, double ultotal, void Download::getProxyForURL(const rtl::OUString& rURL, rtl::OString& rHost, sal_Int32& rPort) const { - if( !m_xContext.is() ) - throw uno::RuntimeException( - UNISTRING( "Download: empty component context" ), - uno::Reference< uno::XInterface >() ); - - uno::Reference< lang::XMultiComponentFactory > xServiceManager(m_xContext->getServiceManager()); - - if( !xServiceManager.is() ) - throw uno::RuntimeException( - UNISTRING( "Download: unable to obtain service manager from component context" ), - uno::Reference< uno::XInterface >() ); - uno::Reference< lang::XMultiServiceFactory > xConfigProvider( - xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), m_xContext ), - uno::UNO_QUERY_THROW); + com::sun::star::configuration::theDefaultProvider::get( m_xContext ) ); beans::PropertyValue aProperty; aProperty.Name = UNISTRING( "nodepath" ); diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx index 7f4e16139936..31f3e884ed80 100644 --- a/extensions/source/update/check/updatecheckconfig.cxx +++ b/extensions/source/update/check/updatecheckconfig.cxx @@ -34,6 +34,7 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <osl/security.hxx> #include <osl/time.h> @@ -269,21 +270,8 @@ UpdateCheckConfig::get( const uno::Reference<uno::XComponentContext>& xContext, const ::rtl::Reference< UpdateCheckConfigListener >& rListener) { - if( !xContext.is() ) - throw uno::RuntimeException( - UNISTRING( "UpdateCheckConfig: empty component context" ), - uno::Reference< uno::XInterface >() ); - - uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager()); - - if( !xServiceManager.is() ) - throw uno::RuntimeException( - UNISTRING( "UpdateCheckConfig: unable to obtain service manager from component context" ), - uno::Reference< uno::XInterface >() ); - uno::Reference< lang::XMultiServiceFactory > xConfigProvider( - xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), xContext ), - uno::UNO_QUERY_THROW); + com::sun::star::configuration::theDefaultProvider::get( xContext ) ); beans::PropertyValue aProperty; aProperty.Name = UNISTRING( "nodepath" ); diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx index 7ee3aa4e8d71..9f1656f15ca8 100644 --- a/extensions/source/update/check/updatehdl.cxx +++ b/extensions/source/update/check/updatehdl.cxx @@ -60,6 +60,8 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include "com/sun/star/beans/XPropertySet.hpp" +#include <com/sun/star/configuration/theDefaultProvider.hpp> + #include "com/sun/star/container/XNameContainer.hpp" #include "com/sun/star/frame/XDesktop.hpp" @@ -861,17 +863,8 @@ void UpdateHandler::insertControlModel( uno::Reference< awt::XControlModel > & r //-------------------------------------------------------------------- void UpdateHandler::setFullVersion( rtl::OUString& rString ) { - if( !mxContext.is() ) - throw uno::RuntimeException( UNISTRING( "getProductName: empty component context" ), *this ); - - uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() ); - - if( !xServiceManager.is() ) - throw uno::RuntimeException( UNISTRING( "getProductName: unable to obtain service manager from component context" ), *this ); - uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider( - xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), mxContext ), - uno::UNO_QUERY_THROW); + com::sun::star::configuration::theDefaultProvider::get( mxContext ) ); beans::PropertyValue aProperty; aProperty.Name = UNISTRING( "nodepath" ); diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx index bb250baeea91..42542c17c4b0 100644 --- a/extensions/source/update/feed/updatefeed.cxx +++ b/extensions/source/update/feed/updatefeed.cxx @@ -34,7 +34,8 @@ #include <cppuhelper/implementationentry.hxx> #include <com/sun/star/beans/Property.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/beans/NamedValue.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/deployment/UpdateInformationEntry.hpp> #include <com/sun/star/deployment/UpdateInformationProvider.hpp> @@ -338,17 +339,8 @@ UpdateInformationProvider::UpdateInformationProvider( m_xContentProvider(xContentProvider), m_xDocumentBuilder(xDocumentBuilder), m_xXPathAPI(xXPathAPI), m_aRequestHeaderList(1) { - uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager()); - if( !xServiceManager.is() ) - throw uno::RuntimeException( - UNISTRING("unable to obtain service manager from component context"), - uno::Reference< uno::XInterface >()); - uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider( - xServiceManager->createInstanceWithContext( - UNISTRING("com.sun.star.configuration.ConfigurationProvider"), - xContext ), - uno::UNO_QUERY_THROW); + com::sun::star::configuration::theDefaultProvider::get(xContext)); rtl::OUStringBuffer buf; rtl::OUString name; @@ -448,7 +440,7 @@ UpdateInformationProvider::~UpdateInformationProvider() uno::Any UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, rtl::OUString const & node, rtl::OUString const & item) { - beans::PropertyValue aProperty; + beans::NamedValue aProperty; aProperty.Name = UNISTRING("nodepath"); aProperty.Value = uno::makeAny(node); diff --git a/filter/source/config/cache/constant.hxx b/filter/source/config/cache/constant.hxx index 097f8aa1117e..32b91139fd39 100644 --- a/filter/source/config/cache/constant.hxx +++ b/filter/source/config/cache/constant.hxx @@ -182,7 +182,6 @@ extern rtl::OUString pFilterStrings[]; /** @short some uno service names. */ -#define SERVICE_CONFIGURATIONPROVIDER _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationProvider" ) #define SERVICE_CONFIGURATIONUPDATEACCESS _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationUpdateAccess" ) #define SERVICE_CONFIGURATIONACCESS _FILTER_CONFIG_FROM_ASCII_("com.sun.star.configuration.ConfigurationAccess" ) #define SERVICE_URLTRANSFORMER _FILTER_CONFIG_FROM_ASCII_("com.sun.star.util.URLTransformer" ) diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index 282ca5aa481c..eedd168a5771 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -41,9 +41,11 @@ //_______________________________________________ // includes +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/util/XChangesBatch.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XProperty.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -962,13 +964,11 @@ css::uno::Reference< css::uno::XInterface > FilterCache::impl_createConfigAccess try { css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( - m_xSMGR->createInstance(SERVICE_CONFIGURATIONPROVIDER), css::uno::UNO_QUERY); - - if (!xConfigProvider.is()) - return css::uno::Reference< css::uno::XInterface >(); + css::configuration::theDefaultProvider::get( + comphelper::getComponentContext(m_xSMGR))); ::comphelper::SequenceAsVector< css::uno::Any > lParams; - css::beans::PropertyValue aParam ; + css::beans::NamedValue aParam; // set root path aParam.Name = _FILTER_CONFIG_FROM_ASCII_("nodepath"); diff --git a/filter/source/msfilter/msoleexp.cxx b/filter/source/msfilter/msoleexp.cxx index c9c13ed4881a..0a682c83ddb4 100644 --- a/filter/source/msfilter/msoleexp.cxx +++ b/filter/source/msfilter/msoleexp.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/embed/XEmbedPersist.hpp> #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> @@ -97,38 +98,30 @@ String GetStorageType( const SvGlobalName& aEmbName ) sal_Bool UseOldMSExport() { - uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); - - if ( xFactory.is() ) - { - uno::Reference< lang::XMultiServiceFactory > xProvider( xFactory->createInstance( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider"))), - uno::UNO_QUERY); - if ( xProvider.is() ) + uno::Reference< lang::XMultiServiceFactory > xProvider( + configuration::theDefaultProvider::get( + comphelper::getProcessComponentContext())); + try { + uno::Sequence< uno::Any > aArg( 1 ); + aArg[0] <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/InternalMSExport") ); + uno::Reference< container::XNameAccess > xNameAccess( + xProvider->createInstanceWithArguments( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ), + aArg ), + uno::UNO_QUERY ); + if ( xNameAccess.is() ) { - try { - uno::Sequence< uno::Any > aArg( 1 ); - aArg[0] <<= rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/InternalMSExport") ); - uno::Reference< container::XNameAccess > xNameAccess( - xProvider->createInstanceWithArguments( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ), - aArg ), - uno::UNO_QUERY ); - if ( xNameAccess.is() ) - { - uno::Any aResult = xNameAccess->getByName( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseOldExport" ) ) ); + uno::Any aResult = xNameAccess->getByName( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UseOldExport" ) ) ); - sal_Bool bResult = sal_Bool(); - if ( aResult >>= bResult ) - return bResult; - } - } - catch( uno::Exception& ) - { - } + sal_Bool bResult = sal_Bool(); + if ( aResult >>= bResult ) + return bResult; } } + catch( uno::Exception& ) + { + } OSL_FAIL( "Could not get access to configuration entry!\n" ); return sal_False; diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index d5fd5864f74b..466132e2c612 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -62,6 +62,7 @@ #include "vcl/graphictools.hxx" #include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/configuration/theDefaultProvider.hpp" #include "com/sun/star/awt/Rectangle.hpp" #include "com/sun/star/awt/XDevice.hpp" #include "com/sun/star/util/MeasureUnit.hpp" @@ -325,55 +326,51 @@ static OUString getMimetypeForDocument( const Reference< XMultiServiceFactory >& // get the actual filter name OUString aFilterName; Reference< lang::XMultiServiceFactory > xConfigProvider( - xFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ), - uno::UNO_QUERY ); - if( xConfigProvider.is() ) + configuration::theDefaultProvider::get( + comphelper::getComponentContext( xFactory ) ) ); + uno::Sequence< uno::Any > aArgs( 1 ); + beans::NamedValue aPathProp; + aPathProp.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); + aPathProp.Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Setup/Office/Factories/" ) ); + aArgs[0] <<= aPathProp; + + Reference< container::XNameAccess > xSOFConfig( + xConfigProvider->createInstanceWithArguments( + OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ), + aArgs ), + uno::UNO_QUERY ); + + Reference< container::XNameAccess > xApplConfig; + xSOFConfig->getByName( aDocServiceName ) >>= xApplConfig; + if ( xApplConfig.is() ) { - uno::Sequence< uno::Any > aArgs( 1 ); - beans::PropertyValue aPathProp; - aPathProp.Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ); - aPathProp.Value <<= OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Setup/Office/Factories/" ) ); - aArgs[0] <<= aPathProp; - - Reference< container::XNameAccess > xSOFConfig( - xConfigProvider->createInstanceWithArguments( - OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ), - aArgs ), + xApplConfig->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "ooSetupFactoryActualFilter" ) ) ) >>= aFilterName; + if( aFilterName.getLength() ) + { + // find the related type name + OUString aTypeName; + Reference< container::XNameAccess > xFilterFactory( + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" )) ), uno::UNO_QUERY ); - Reference< container::XNameAccess > xApplConfig; - xSOFConfig->getByName( aDocServiceName ) >>= xApplConfig; - if ( xApplConfig.is() ) - { - xApplConfig->getByName( OUString( RTL_CONSTASCII_USTRINGPARAM( "ooSetupFactoryActualFilter" ) ) ) >>= aFilterName; - if( aFilterName.getLength() ) + Sequence< beans::PropertyValue > aFilterData; + xFilterFactory->getByName( aFilterName ) >>= aFilterData; + for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ ) + if ( aFilterData[nInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Type" ) ) ) + aFilterData[nInd].Value >>= aTypeName; + + if ( aTypeName.getLength() ) { - // find the related type name - OUString aTypeName; - Reference< container::XNameAccess > xFilterFactory( - xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.FilterFactory" )) ), - uno::UNO_QUERY ); - - Sequence< beans::PropertyValue > aFilterData; - xFilterFactory->getByName( aFilterName ) >>= aFilterData; - for ( sal_Int32 nInd = 0; nInd < aFilterData.getLength(); nInd++ ) - if ( aFilterData[nInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Type" ) ) ) - aFilterData[nInd].Value >>= aTypeName; - - if ( aTypeName.getLength() ) - { - // find the mediatype - Reference< container::XNameAccess > xTypeDetection( - xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.TypeDetection" )) ), - UNO_QUERY ); - - Sequence< beans::PropertyValue > aTypeData; - xTypeDetection->getByName( aTypeName ) >>= aTypeData; - for ( sal_Int32 nInd = 0; nInd < aTypeData.getLength(); nInd++ ) - if ( aTypeData[nInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) - aTypeData[nInd].Value >>= aDocMimetype; - } + // find the mediatype + Reference< container::XNameAccess > xTypeDetection( + xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.TypeDetection" )) ), + UNO_QUERY ); + + Sequence< beans::PropertyValue > aTypeData; + xTypeDetection->getByName( aTypeName ) >>= aTypeData; + for ( sal_Int32 nInd = 0; nInd < aTypeData.getLength(); nInd++ ) + if ( aTypeData[nInd].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MediaType" ) ) ) + aTypeData[nInd].Value >>= aDocMimetype; } } } diff --git a/odk/examples/java/Inspector/Inspector.java b/odk/examples/java/Inspector/Inspector.java index c8887d4c0344..39daa05e8826 100644 --- a/odk/examples/java/Inspector/Inspector.java +++ b/odk/examples/java/Inspector/Inspector.java @@ -38,6 +38,7 @@ import com.sun.star.awt.XMessageBoxFactory; import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.NamedValue; import com.sun.star.beans.XPropertySet; +import com.sun.star.configuration.theDefaultProvider; import com.sun.star.container.XNameAccess; import com.sun.star.frame.XModel; import com.sun.star.lang.XComponent; @@ -410,8 +411,7 @@ public class Inspector{ sAccess = "com.sun.star.configuration.ConfigurationAccess"; } XMultiComponentFactory xMCF = m_xComponentContext.getServiceManager(); - Object oDefaultProvider = xMCF.createInstanceWithContext("com.sun.star.configuration.DefaultProvider", this.getXComponentContext()); - XMultiServiceFactory xMSFCfg = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDefaultProvider); + XMultiServiceFactory xMSFCfg = theDefaultProvider.get(this.getXComponentContext()); Object oAccess = xMSFCfg.createInstanceWithArguments(sAccess, new Object[]{new NamedValue("nodepath", _sNodePath)}); xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oAccess); } catch (com.sun.star.uno.Exception e) { diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 8ae72cb5579b..c56b83bff6c5 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -66,6 +66,7 @@ $(eval $(call gb_UnoApiTarget_add_idlfiles_nohdl,offapi,offapi/com/sun/star/char )) $(eval $(call gb_UnoApiTarget_add_idlfiles_nohdl,offapi,offapi/com/sun/star/configuration,\ Update \ + theDefaultProvider \ )) $(eval $(call gb_UnoApiTarget_add_idlfiles_nohdl,offapi,offapi/com/sun/star/deployment,\ ExtensionManager \ diff --git a/offapi/com/sun/star/configuration/DefaultProvider.idl b/offapi/com/sun/star/configuration/DefaultProvider.idl index a2875c68f4e6..444c13ab1efd 100644 --- a/offapi/com/sun/star/configuration/DefaultProvider.idl +++ b/offapi/com/sun/star/configuration/DefaultProvider.idl @@ -44,7 +44,8 @@ module com { module sun { module star { module configuration { the default <type>ConfigurationProvider</type> for its <type scope="com::sun::star::uno">XComponentContext</type>. - <p>This object is accessible as singleton within the context</p>. + <p>This object is accessible as singleton + <type>theDefaultProvider</type></p>. @since OOo 1.1.2 */ diff --git a/offapi/com/sun/star/configuration/theDefaultProvider.idl b/offapi/com/sun/star/configuration/theDefaultProvider.idl new file mode 100644 index 000000000000..2fe61bc274a5 --- /dev/null +++ b/offapi/com/sun/star/configuration/theDefaultProvider.idl @@ -0,0 +1,54 @@ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2011 Stephan Bergmann, Red Hat <sbergman@redhat.com> (initial + * developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#ifndef INCLUDED_COM_SUN_STAR_CONFIGURATION_THEDEFAULTPROVIDER_IDL +#define INCLUDED_COM_SUN_STAR_CONFIGURATION_THEDEFAULTPROVIDER_IDL + +module com { module sun { module star { module lang { + published interface XMultiServiceFactory; +}; }; }; }; + +module com { module sun { module star { module configuration { + +/** + The default <type>ConfigurationProvider</type>. + + <p>This singleton somewhat arbitrarily makes available the + <type scope="com::sun::star::lang">XMultiServiceFactory</type> interface of + the (old-style) <type>DefaultProvider</type> service, as it is the most + frequently used one. See the <type>DefaultProvider</type> service for + details.</p> + + @since OOo 1.1.2 +*/ +published singleton theDefaultProvider: + com::sun::star::lang::XMultiServiceFactory; + +}; }; }; }; + +#endif diff --git a/qadevOOo/tests/java/mod/_configmgr/DefaultProvider.java b/qadevOOo/tests/java/mod/_configmgr/DefaultProvider.java index f8a023ea2f12..b7eefdb445b9 100644 --- a/qadevOOo/tests/java/mod/_configmgr/DefaultProvider.java +++ b/qadevOOo/tests/java/mod/_configmgr/DefaultProvider.java @@ -27,6 +27,7 @@ package mod._configmgr; +import com.sun.star.configuration.theDefaultProvider; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.XInterface; import lib.TestCase; @@ -44,9 +45,7 @@ public final class DefaultProvider extends TestCase { return ProviderTestEnvironment.create( AnyConverter.toObject( XInterface.class, - tParam.getComponentContext().getValueByName( - "/singletons/" + - "com.sun.star.configuration.theDefaultProvider"))); + theDefaultProvider.get(tParam.getComponentContext()))); } catch (com.sun.star.lang.IllegalArgumentException e) { throw new RuntimeException(e); } diff --git a/testautomation/global/system/includes/iniinfo.inc b/testautomation/global/system/includes/iniinfo.inc index 727763968076..a4ab87db3dcb 100644 --- a/testautomation/global/system/includes/iniinfo.inc +++ b/testautomation/global/system/includes/iniinfo.inc @@ -650,7 +650,7 @@ function fgetL10Nvalue() as string dim args(0) as new com.sun.star.beans.NamedValue args(0).Name = "nodepath" args(0).Value = "/org.openoffice.Setup/L10N" - fgetL10Nvalue = hGetUNOService().createInstance("com.sun.star.configuration.DefaultProvider").createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args()).getByName("ooLocale") + fgetL10Nvalue = com.sun.star.configuration.theDefaultProvider.get.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args()).getByName("ooLocale") end function '------------------------------------------------------------------------- |