summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2011-11-14 22:07:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2011-11-14 22:07:23 +0100
commit8b75883b87c9f7989f98fb413f5e51200c52891c (patch)
tree5eaf6d052d25c61654b4e06ffb67784eab9d263b /connectivity
parentavoid trying to run stuff at configure time due to cross-compile need (diff)
downloadcore-8b75883b87c9f7989f98fb413f5e51200c52891c.tar.gz
core-8b75883b87c9f7989f98fb413f5e51200c52891c.zip
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 'connectivity')
-rw-r--r--connectivity/source/cpool/ZPoolCollection.cxx82
-rwxr-xr-xconnectivity/source/cpool/makefile.mk1
-rw-r--r--connectivity/source/drivers/hsqldb/HDriver.cxx11
-rw-r--r--connectivity/source/drivers/kab/KDriver.cxx6
-rwxr-xr-xconnectivity/source/drivers/kab/makefile.mk1
-rw-r--r--connectivity/source/drivers/mozab/MConfigAccess.cxx66
-rw-r--r--connectivity/source/manager/mdrivermanager.cxx9
7 files changed, 68 insertions, 108 deletions
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);