diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2011-11-14 22:07:23 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2011-11-14 22:07:23 +0100 |
commit | 8b75883b87c9f7989f98fb413f5e51200c52891c (patch) | |
tree | 5eaf6d052d25c61654b4e06ffb67784eab9d263b /desktop | |
parent | f72516ed25d25963f497396985d56344eb3ff465 (diff) |
Simplified some uses of css.configuration.theDefaultProvider.
* Retro-added new-style UNOIDL singleton specification for it, for easy
instantiation.
* Plus new comphelper::getComponentContext to map from XMultiServiceFactory
to XComponentContext.
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/inc/app.hxx | 2 | ||||
-rw-r--r-- | desktop/source/app/app.cxx | 139 | ||||
-rw-r--r-- | desktop/source/app/appfirststart.cxx | 13 | ||||
-rw-r--r-- | desktop/source/app/check_ext_deps.cxx | 20 | ||||
-rw-r--r-- | desktop/source/app/configinit.cxx | 116 | ||||
-rw-r--r-- | desktop/source/app/configinit.hxx | 27 | ||||
-rw-r--r-- | desktop/source/app/langselect.cxx | 48 | ||||
-rw-r--r-- | desktop/source/app/userinstall.cxx | 25 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 4 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_updatedialog.cxx | 15 | ||||
-rw-r--r-- | desktop/source/migration/migration.cxx | 20 | ||||
-rw-r--r-- | desktop/test/deployment/options/handler/com/sun/star/comp/extensionoptions/OptionsEventHandler.java | 21 |
12 files changed, 73 insertions, 377 deletions
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. |