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 /extensions | |
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 'extensions')
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilebe.cxx | 17 | ||||
-rw-r--r-- | extensions/source/config/ldap/ldapuserprofilebe.hxx | 8 | ||||
-rw-r--r-- | extensions/source/logging/loggerconfig.cxx | 9 | ||||
-rw-r--r-- | extensions/source/oooimprovement/makefile.mk | 1 | ||||
-rw-r--r-- | extensions/source/oooimprovement/myconfigurationhelper.cxx | 43 | ||||
-rw-r--r-- | extensions/source/oooimprovement/myconfigurationhelper.hxx | 4 | ||||
-rw-r--r-- | extensions/source/update/check/download.cxx | 16 | ||||
-rw-r--r-- | extensions/source/update/check/updatecheckconfig.cxx | 16 | ||||
-rw-r--r-- | extensions/source/update/check/updatehdl.cxx | 13 | ||||
-rw-r--r-- | extensions/source/update/feed/updatefeed.cxx | 16 |
10 files changed, 36 insertions, 107 deletions
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); |