summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-12-06 16:37:57 +0200
committerNoel Grandin <noel@peralex.com>2012-12-10 08:05:36 +0200
commit9fc4553b6433fbb6565a5b946c4256c0bfe345f1 (patch)
tree347cd116da96a13f9087685017f6ee4a5fc7aca7
parentd01fba6afc39092ae3ae85c38ac21bb7d26d63e2 (diff)
fdo#46808, Adapt sdbc::DriverManager UNO service to new style
Change-Id: Ic2be6bd08aaabc81d0fbe0269ca577868defe934
-rw-r--r--connectivity/inc/connectivity/dbtools.hxx4
-rw-r--r--connectivity/source/commontools/dbmetadata.cxx6
-rw-r--r--connectivity/source/commontools/dbtools2.cxx7
-rw-r--r--connectivity/source/cpool/ZPoolCollection.cxx26
-rw-r--r--connectivity/source/cpool/ZPoolCollection.hxx4
-rw-r--r--connectivity/source/drivers/hsqldb/HDriver.cxx7
-rw-r--r--connectivity/source/drivers/mysql/YDriver.cxx25
-rw-r--r--connectivity/source/drivers/mysql/Yservices.cxx31
-rw-r--r--connectivity/source/inc/mysql/YDriver.hxx7
-rw-r--r--connectivity/source/manager/mdrivermanager.hxx5
-rw-r--r--cui/source/options/sdbcdriverenum.cxx31
-rw-r--r--dbaccess/source/core/dataaccess/connection.cxx2
-rw-r--r--dbaccess/source/core/dataaccess/datasource.cxx7
-rw-r--r--dbaccess/source/inc/stringconstants.inc1
-rw-r--r--dbaccess/source/ui/uno/copytablewizard.cxx9
-rw-r--r--extensions/source/abpilot/admininvokationimpl.cxx14
-rw-r--r--extensions/source/abpilot/admininvokationimpl.hxx8
-rw-r--r--extensions/source/abpilot/admininvokationpage.cxx3
-rw-r--r--extensions/source/abpilot/typeselectionpage.cxx6
-rw-r--r--offapi/UnoApi_offapi.mk1
-rw-r--r--offapi/com/sun/star/sdbc/XDriverManager2.idl4
-rw-r--r--offapi/type_reference/types.rdbbin7440384 -> 7440384 bytes
-rw-r--r--sc/source/ui/docshell/docsh8.cxx18
23 files changed, 112 insertions, 114 deletions
diff --git a/connectivity/inc/connectivity/dbtools.hxx b/connectivity/inc/connectivity/dbtools.hxx
index fb1ff42d34d8..1fd66e910bf3 100644
--- a/connectivity/inc/connectivity/dbtools.hxx
+++ b/connectivity/inc/connectivity/dbtools.hxx
@@ -716,7 +716,7 @@ namespace dbtools
The URL used to connect to the database.
@param _xConnection
The connection used to find the correct driver.
- @param _rxFactory
+ @param _rxContext
Used to create the drivermanager.
@return
The datadefintion object.
@@ -724,7 +724,7 @@ namespace dbtools
OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> getDataDefinitionByURLAndConnection(
const ::rtl::OUString& _rsUrl,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& _rxFactory);
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
/** returns the table privileges to the given parameters
@param _xMetaData
diff --git a/connectivity/source/commontools/dbmetadata.cxx b/connectivity/source/commontools/dbmetadata.cxx
index d9cc23c21b13..06aed4ea1a76 100644
--- a/connectivity/source/commontools/dbmetadata.cxx
+++ b/connectivity/source/commontools/dbmetadata.cxx
@@ -34,6 +34,7 @@
#include <com/sun/star/sdbcx/XUsersSupplier.hpp>
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <tools/diagnose_ex.h>
#include <comphelper/namedvaluecollection.hxx>
@@ -67,6 +68,8 @@ namespace dbtools
using ::com::sun::star::sdbcx::XUsersSupplier;
using ::com::sun::star::sdbcx::XDataDefinitionSupplier;
using ::com::sun::star::sdbc::XDriverAccess;
+ using ::com::sun::star::sdbc::DriverManager;
+ using ::com::sun::star::sdbc::XDriverManager2;
using ::com::sun::star::uno::UNO_SET_THROW;
/** === end UNO using === **/
namespace BooleanComparisonMode = ::com::sun::star::sdb::BooleanComparisonMode;
@@ -376,8 +379,7 @@ namespace dbtools
if ( !xUsersSupp.is() )
{
// - or at the driver manager
- Reference< XDriverAccess > xDriverManager(
- _rContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW );
+ Reference< XDriverManager2 > xDriverManager = DriverManager::create( _rContext.getUNOContext() );
Reference< XDataDefinitionSupplier > xDriver( xDriverManager->getDriverByURL( m_pImpl->xConnectionMetaData->getURL() ), UNO_QUERY );
if ( xDriver.is() )
xUsersSupp.set( xDriver->getDataDefinitionByConnection( m_pImpl->xConnection ), UNO_QUERY );
diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx
index 4092e9e185de..acfb227703ab 100644
--- a/connectivity/source/commontools/dbtools2.cxx
+++ b/connectivity/source/commontools/dbtools2.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
@@ -636,14 +637,12 @@ sal_Bool isDataSourcePropertyEnabled(const Reference<XInterface>& _xProp,const :
Reference< XTablesSupplier> getDataDefinitionByURLAndConnection(
const ::rtl::OUString& _rsUrl,
const Reference< XConnection>& _xConnection,
- const Reference< XMultiServiceFactory>& _rxFactory)
+ const Reference< XComponentContext >& _rxContext)
{
Reference< XTablesSupplier> xTablesSup;
try
{
- Reference< XDriverAccess> xManager(
- _rxFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager")) ),
- UNO_QUERY_THROW );
+ Reference< XDriverManager2 > xManager = DriverManager::create( _rxContext );
Reference< XDataDefinitionSupplier > xSupp( xManager->getDriverByURL( _rsUrl ), UNO_QUERY );
if ( xSupp.is() )
diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx
index 68b5448b9506..b7d0abd075d5 100644
--- a/connectivity/source/cpool/ZPoolCollection.cxx
+++ b/connectivity/source/cpool/ZPoolCollection.cxx
@@ -25,6 +25,7 @@
#include <com/sun/star/beans/NamedValue.hpp>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/reflection/ProxyFactory.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <comphelper/extract.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -75,9 +76,7 @@ OPoolCollection::OPoolCollection(const Reference< XMultiServiceFactory >& _rxF
:m_xServiceFactory(_rxFactory)
{
// bootstrap all objects supporting the .sdb.Driver service
- m_xManager = Reference< XDriverManager >(m_xServiceFactory->createInstance(::rtl::OUString("com.sun.star.sdbc.DriverManager") ), UNO_QUERY);
- m_xDriverAccess = Reference< XDriverAccess >(m_xManager, UNO_QUERY);
- OSL_ENSURE(m_xDriverAccess.is(), "have no (or an invalid) driver manager!");
+ m_xManager = DriverManager::create( comphelper::getComponentContext(m_xServiceFactory) );
m_xProxyFactory = ProxyFactory::create( comphelper::getComponentContext(m_xServiceFactory) );
@@ -277,20 +276,17 @@ sal_Bool OPoolCollection::isPoolingEnabledByUrl(const ::rtl::OUString& _sUrl,
Reference< XInterface >& _rxDriverNode)
{
sal_Bool bEnabled = sal_False;
- if (m_xDriverAccess.is())
+ _rxDriver = m_xManager->getDriverByURL(_sUrl);
+ if (_rxDriver.is() && isPoolingEnabled())
{
- _rxDriver = m_xDriverAccess->getDriverByURL(_sUrl);
- if (_rxDriver.is() && isPoolingEnabled())
- {
- Reference< XServiceInfo > xSerivceInfo(_rxDriver,UNO_QUERY);
- OSL_ENSURE(xSerivceInfo.is(),"Each driver should have a XServiceInfo interface!");
+ Reference< XServiceInfo > xSerivceInfo(_rxDriver,UNO_QUERY);
+ OSL_ENSURE(xSerivceInfo.is(),"Each driver should have a XServiceInfo interface!");
- if(xSerivceInfo.is())
- {
- // look for the implementation name of the driver
- _rsImplName = xSerivceInfo->getImplementationName();
- bEnabled = isDriverPoolingEnabled(_rsImplName,_rxDriverNode);
- }
+ if(xSerivceInfo.is())
+ {
+ // look for the implementation name of the driver
+ _rsImplName = xSerivceInfo->getImplementationName();
+ bEnabled = isDriverPoolingEnabled(_rsImplName,_rxDriverNode);
}
}
return bEnabled;
diff --git a/connectivity/source/cpool/ZPoolCollection.hxx b/connectivity/source/cpool/ZPoolCollection.hxx
index 20108fd87b08..6fb05bb31339 100644
--- a/connectivity/source/cpool/ZPoolCollection.hxx
+++ b/connectivity/source/cpool/ZPoolCollection.hxx
@@ -22,6 +22,7 @@
#include <cppuhelper/implbase4.hxx>
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/XDriverManager2.hpp>
#include <com/sun/star/sdbc/XConnectionPool.hpp>
#include <com/sun/star/sdbc/XPooledConnection.hpp>
#include <com/sun/star/sdbc/XConnection.hpp>
@@ -65,8 +66,7 @@ namespace connectivity
::osl::Mutex m_aMutex;
OConnectionPools m_aPools; // the driver pools
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverManager > m_xManager;
- ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverAccess > m_xDriverAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriverManager2 > m_xManager;
::com::sun::star::uno::Reference< ::com::sun::star::reflection::XProxyFactory > m_xProxyFactory;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xConfigNode; // config node for generel connection pooling
::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> m_xDesktop;
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
index 471d67bd5fbf..a805bfcf7756 100644
--- a/connectivity/source/drivers/hsqldb/HDriver.cxx
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -22,6 +22,7 @@
#include <osl/diagnose.h>
#include "connectivity/dbexception.hxx"
#include <com/sun/star/configuration/theDefaultProvider.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/sdbc/XResultSet.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
@@ -130,10 +131,8 @@ namespace connectivity
if ( !m_xDriver.is() )
{
::rtl::OUString sURL("jdbc:hsqldb:db");
- Reference<XDriverAccess> xDriverAccess(m_xFactory->createInstance(::rtl::OUString("com.sun.star.sdbc.DriverManager") ),UNO_QUERY);
- OSL_ENSURE(xDriverAccess.is(),"Could not load driver manager!");
- if ( xDriverAccess.is() )
- m_xDriver = xDriverAccess->getDriverByURL(sURL);
+ Reference<XDriverManager2> xDriverAccess = DriverManager::create( comphelper::getComponentContext(m_xFactory) );
+ m_xDriver = xDriverAccess->getDriverByURL(sURL);
}
return m_xDriver;
diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx
index 941f47c1ec58..600a9855affc 100644
--- a/connectivity/source/drivers/mysql/YDriver.cxx
+++ b/connectivity/source/drivers/mysql/YDriver.cxx
@@ -21,9 +21,11 @@
#include "mysql/YCatalog.hxx"
#include <osl/diagnose.h>
#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/processfactory.hxx>
#include "connectivity/dbexception.hxx"
#include <connectivity/dbcharset.hxx>
-#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include "TConnection.hxx"
#include "resource/common_res.hrc"
#include "resource/sharedresources.hxx"
@@ -43,7 +45,7 @@ namespace connectivity
{
Reference< XInterface > SAL_CALL ODriverDelegator_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFac) throw( Exception )
{
- return *(new ODriverDelegator(_rxFac));
+ return *(new ODriverDelegator( comphelper::getComponentContext(_rxFac) ));
}
}
@@ -52,9 +54,9 @@ namespace connectivity
//= ODriverDelegator
//====================================================================
//--------------------------------------------------------------------
- ODriverDelegator::ODriverDelegator(const Reference< XMultiServiceFactory >& _rxFactory)
+ ODriverDelegator::ODriverDelegator(const Reference< XComponentContext >& _rxContext)
: ODriverDelegator_BASE(m_aMutex)
- ,m_xFactory(_rxFactory)
+ ,m_xContext(_rxContext)
{
}
@@ -140,13 +142,10 @@ namespace connectivity
return sNewUrl;
}
//--------------------------------------------------------------------
- Reference< XDriver > lcl_loadDriver(const Reference< XMultiServiceFactory >& _rxFactory,const ::rtl::OUString& _sUrl)
+ Reference< XDriver > lcl_loadDriver(const Reference< XComponentContext >& _rxContext,const ::rtl::OUString& _sUrl)
{
- Reference<XDriverAccess> xDriverAccess(_rxFactory->createInstance(::rtl::OUString("com.sun.star.sdbc.DriverManager") ),UNO_QUERY);
- OSL_ENSURE(xDriverAccess.is(),"Could not load driver manager!");
- Reference< XDriver > xDriver;
- if ( xDriverAccess.is() )
- xDriver = xDriverAccess->getDriverByURL(_sUrl);
+ Reference<XDriverManager2> xDriverAccess = DriverManager::create(_rxContext);
+ Reference< XDriver > xDriver = xDriverAccess->getDriverByURL(_sUrl);
return xDriver;
}
//--------------------------------------------------------------------
@@ -219,13 +218,13 @@ namespace connectivity
if ( eType == D_ODBC )
{
if ( !m_xODBCDriver.is() )
- m_xODBCDriver = lcl_loadDriver(m_xFactory,sCuttedUrl);
+ m_xODBCDriver = lcl_loadDriver(m_xContext,sCuttedUrl);
xDriver = m_xODBCDriver;
} // if ( bIsODBC )
else if ( eType == D_NATIVE )
{
if ( !m_xNativeDriver.is() )
- m_xNativeDriver = lcl_loadDriver(m_xFactory,sCuttedUrl);
+ m_xNativeDriver = lcl_loadDriver(m_xContext,sCuttedUrl);
xDriver = m_xNativeDriver;
}
else
@@ -236,7 +235,7 @@ namespace connectivity
TJDBCDrivers::iterator aFind = m_aJdbcDrivers.find(sDriverClass);
if ( aFind == m_aJdbcDrivers.end() )
- aFind = m_aJdbcDrivers.insert(TJDBCDrivers::value_type(sDriverClass,lcl_loadDriver(m_xFactory,sCuttedUrl))).first;
+ aFind = m_aJdbcDrivers.insert(TJDBCDrivers::value_type(sDriverClass,lcl_loadDriver(m_xContext,sCuttedUrl))).first;
xDriver = aFind->second;
}
diff --git a/connectivity/source/drivers/mysql/Yservices.cxx b/connectivity/source/drivers/mysql/Yservices.cxx
index ee2be92e9e06..ff6fe08804b1 100644
--- a/connectivity/source/drivers/mysql/Yservices.cxx
+++ b/connectivity/source/drivers/mysql/Yservices.cxx
@@ -80,24 +80,29 @@ extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL mysql_component_getFactory(
void* pServiceManager,
void* /*pRegistryKey*/)
{
- void* pRet = 0;
- if (pServiceManager)
+ if (!pServiceManager)
{
- ProviderRequest aReq(pServiceManager,pImplementationName);
+ return 0;
+ }
- aReq.CREATE_PROVIDER(
- ODriverDelegator::getImplementationName_Static(),
- ODriverDelegator::getSupportedServiceNames_Static(),
- ODriverDelegator_CreateInstance, ::cppu::createSingleFactory)
- ;
+ Reference< XSingleServiceFactory > xRet;
+ const Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast<XMultiServiceFactory*>(pServiceManager) );
+ const OUString sImplementationName( OUString::createFromAscii(pImplementationName) );
- if(aReq.xRet.is())
- aReq.xRet->acquire();
+ if( ODriverDelegator::getImplementationName_Static() == sImplementationName )
+ try
+ {
+ xRet = ::cppu::createSingleFactory( xServiceManager, sImplementationName, ODriverDelegator_CreateInstance,
+ ODriverDelegator::getSupportedServiceNames_Static(), 0);
+ }
+ catch(...)
+ {
+ }
- pRet = aReq.getProvider();
- }
+ if(xRet.is())
+ xRet->acquire();
- return pRet;
+ return xRet.get();
};
diff --git a/connectivity/source/inc/mysql/YDriver.hxx b/connectivity/source/inc/mysql/YDriver.hxx
index 32b6b21bd52b..a94a1711b381 100644
--- a/connectivity/source/inc/mysql/YDriver.hxx
+++ b/connectivity/source/inc/mysql/YDriver.hxx
@@ -22,6 +22,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/compbase3.hxx>
#include <comphelper/uno3.hxx>
#include <comphelper/stl_types.hxx>
@@ -37,7 +38,7 @@ namespace connectivity
namespace mysql
{
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriverDelegator_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxMSF) throw( ::com::sun::star::uno::Exception );
typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver
, ::com::sun::star::sdbcx::XDataDefinitionSupplier
@@ -61,7 +62,7 @@ namespace connectivity
// for this Driver
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xODBCDriver;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > m_xNativeDriver;
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::rtl::OUString m_sOldDriverClass;
/** load the driver we want to delegate.
@@ -78,7 +79,7 @@ namespace connectivity
public:
/** creates a new delegator for a mysql driver
*/
- ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+ ODriverDelegator(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
// XServiceInfo
DECLARE_SERVICE_INFO();
diff --git a/connectivity/source/manager/mdrivermanager.hxx b/connectivity/source/manager/mdrivermanager.hxx
index 87b145dec0ed..be87e4283da7 100644
--- a/connectivity/source/manager/mdrivermanager.hxx
+++ b/connectivity/source/manager/mdrivermanager.hxx
@@ -27,7 +27,7 @@
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase3.hxx>
#include <comphelper/stl_types.hxx>
#include <comphelper/logging.hxx>
#include <comphelper/componentcontext.hxx>
@@ -54,8 +54,7 @@ namespace drivermanager
//==========================================================================
//= OSDBCDriverManager - the one-instance service for managing SDBC drivers
//==========================================================================
- typedef ::cppu::WeakImplHelper4 < ::com::sun::star::sdbc::XDriverManager2
- , ::com::sun::star::sdbc::XDriverAccess
+ typedef ::cppu::WeakImplHelper3 < ::com::sun::star::sdbc::XDriverManager2
, ::com::sun::star::lang::XServiceInfo
, ::com::sun::star::uno::XNamingService
> OSDBCDriverManager_Base;
diff --git a/cui/source/options/sdbcdriverenum.cxx b/cui/source/options/sdbcdriverenum.cxx
index 9033ebcb3ca4..e210df625df0 100644
--- a/cui/source/options/sdbcdriverenum.cxx
+++ b/cui/source/options/sdbcdriverenum.cxx
@@ -20,9 +20,9 @@
#include "sdbcdriverenum.hxx"
#include <comphelper/stl_types.hxx>
#include <comphelper/processfactory.hxx>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
//........................................................................
namespace offapp
@@ -32,6 +32,7 @@ namespace offapp
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdbc;
//====================================================================
//= ODriverEnumerationImpl
@@ -52,25 +53,19 @@ namespace offapp
{
try
{
- Reference< XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
- Reference< XInterface > xDM = xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager") ) );
- OSL_ENSURE(xDM.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: no access to the SDBC driver manager!");
+ Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ Reference< XDriverManager2 > xEnumAccess = DriverManager::create( xContext );
- Reference< XEnumerationAccess > xEnumAccess(xDM, UNO_QUERY);
- OSL_ENSURE(xEnumAccess.is() || !xDM.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: can't enumerate SDBC drivers (missing the interface)!");
- if (xEnumAccess.is())
- {
- Reference< XEnumeration > xEnumDrivers = xEnumAccess->createEnumeration();
- OSL_ENSURE(xEnumDrivers.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: invalid enumeration object!");
+ Reference< XEnumeration > xEnumDrivers = xEnumAccess->createEnumeration();
+ OSL_ENSURE(xEnumDrivers.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: invalid enumeration object!");
- Reference< XServiceInfo > xDriverSI;
- while (xEnumDrivers->hasMoreElements())
- {
- xEnumDrivers->nextElement() >>= xDriverSI;
- OSL_ENSURE(xDriverSI.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: driver without service info!");
- if (xDriverSI.is())
- m_aImplNames.push_back(xDriverSI->getImplementationName());
- }
+ Reference< XServiceInfo > xDriverSI;
+ while (xEnumDrivers->hasMoreElements())
+ {
+ xEnumDrivers->nextElement() >>= xDriverSI;
+ OSL_ENSURE(xDriverSI.is(), "ODriverEnumerationImpl::ODriverEnumerationImpl: driver without service info!");
+ if (xDriverSI.is())
+ m_aImplNames.push_back(xDriverSI->getImplementationName());
}
}
catch(const Exception&)
diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx
index cab3e3a7f3fa..fcfe2196e778 100644
--- a/dbaccess/source/core/dataaccess/connection.cxx
+++ b/dbaccess/source/core/dataaccess/connection.cxx
@@ -717,7 +717,7 @@ Reference< XTablesSupplier > OConnection::getMasterTables()
{
Reference<XDatabaseMetaData> xMeta = getMetaData();
if ( xMeta.is() )
- m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection( xMeta->getURL(), m_xMasterConnection, m_aContext.getLegacyServiceFactory() );
+ m_xMasterTables = ::dbtools::getDataDefinitionByURLAndConnection( xMeta->getURL(), m_xMasterConnection, m_aContext.getUNOContext() );
}
catch(const SQLException&)
{
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index 926c118482a3..611042b636db 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/sdbc/ConnectionPool.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#include <com/sun/star/ucb/AuthenticationRequest.hpp>
#include <com/sun/star/ucb/XInteractionSupplyAuthentication.hpp>
@@ -641,13 +642,13 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const ::rtl::O
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dataaccess", "Ocke.Janssen@sun.com", "ODatabaseSource::buildLowLevelConnection" );
Reference< XConnection > xReturn;
- Reference< XConnectionPool > xManager;
+ Reference< XDriverManager > xManager;
try {
- xManager.set( ConnectionPool::create( m_pImpl->m_aContext.getUNOContext() ) );
+ xManager.set( ConnectionPool::create( m_pImpl->m_aContext.getUNOContext() ), UNO_QUERY_THROW );
} catch( const Exception& ) { }
if ( !xManager.is() )
// no connection pool installed, fall back to driver manager
- xManager.set( m_pImpl->m_aContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW );
+ xManager.set( DriverManager::create(m_pImpl->m_aContext.getUNOContext() ), UNO_QUERY_THROW );
::rtl::OUString sUser(_rUid);
::rtl::OUString sPwd(_rPwd);
diff --git a/dbaccess/source/inc/stringconstants.inc b/dbaccess/source/inc/stringconstants.inc
index 4b1434de4309..390d92dd7541 100644
--- a/dbaccess/source/inc/stringconstants.inc
+++ b/dbaccess/source/inc/stringconstants.inc
@@ -206,7 +206,6 @@ IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERYDEFINITION, "com.sun.star.sdb.Quer
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_COLUMNS, "com.sun.star.sdbcx.Columns");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_TABLES, "com.sun.star.sdbcx.Tables");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDB_QUERIES, "com.sun.star.sdb.Queries");
-IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBC_DRIVERMANAGER, "com.sun.star.sdbc.DriverManager");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_INDEXCOLUMN, "com.sun.star.sdbcx.IndexColumn");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_SDBCX_KEYCOLUMN, "com.sun.star.sdbcx.KeyColumn");
IMPLEMENT_CONSTASCII_USTRING(SERVICE_FRAME_DESKTOP, "com.sun.star.frame.Desktop");
diff --git a/dbaccess/source/ui/uno/copytablewizard.cxx b/dbaccess/source/ui/uno/copytablewizard.cxx
index 15e9cde96d0b..6774f2b81e91 100644
--- a/dbaccess/source/ui/uno/copytablewizard.cxx
+++ b/dbaccess/source/ui/uno/copytablewizard.cxx
@@ -52,7 +52,7 @@
#include <com/sun/star/sdbcx/XRowLocate.hpp>
#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
#include <com/sun/star/sdb/SQLContext.hpp>
-#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdbc/ConnectionPool.hpp>
#include <comphelper/componentcontext.hxx>
@@ -131,6 +131,7 @@ namespace dbaui
using ::com::sun::star::sdbc::ConnectionPool;
using ::com::sun::star::sdbc::XConnectionPool;
using ::com::sun::star::sdbc::XDriverManager;
+ using ::com::sun::star::sdbc::DriverManager;
using ::com::sun::star::beans::PropertyValue;
/** === end UNO using === **/
namespace CopyTableOperation = ::com::sun::star::sdb::application::CopyTableOperation;
@@ -954,13 +955,13 @@ SharedConnection CopyTableWizard::impl_extractConnection_throw( const Reference<
if ( xPSI->hasPropertyByName( PROPERTY_CONNECTION_INFO ) )
OSL_VERIFY( _rxDataSourceDescriptor->getPropertyValue( PROPERTY_CONNECTION_INFO ) >>= aConnectionInfo );
- Reference< XConnectionPool > xDriverManager;
+ Reference< XDriverManager > xDriverManager;
try {
- xDriverManager.set( ConnectionPool::create( m_aContext.getUNOContext() ) );
+ xDriverManager.set( ConnectionPool::create( m_aContext.getUNOContext() ), UNO_QUERY_THROW );
} catch( const Exception& ) { }
if ( !xDriverManager.is() )
// no connection pool installed
- xDriverManager.set( m_aContext.createComponent( "com.sun.star.sdbc.DriverManager" ), UNO_QUERY_THROW );
+ xDriverManager.set( DriverManager::create(m_aContext.getUNOContext() ), UNO_QUERY_THROW );
if ( aConnectionInfo.getLength() )
xConnection.set( xDriverManager->getConnectionWithInfo( sConnectionResource, aConnectionInfo ), UNO_SET_THROW );
diff --git a/extensions/source/abpilot/admininvokationimpl.cxx b/extensions/source/abpilot/admininvokationimpl.cxx
index a6720abeaf5b..003f70bb4736 100644
--- a/extensions/source/abpilot/admininvokationimpl.cxx
+++ b/extensions/source/abpilot/admininvokationimpl.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <vcl/stdtext.hxx>
#include <toolkit/unohlp.hxx>
#include "abpresid.hrc"
@@ -39,19 +40,20 @@ namespace abp
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::awt;
using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::sdbc;
//=====================================================================
//= OAdminDialogInvokation
//=====================================================================
//---------------------------------------------------------------------
- OAdminDialogInvokation::OAdminDialogInvokation(const Reference< XMultiServiceFactory >& _rxORB
+ OAdminDialogInvokation::OAdminDialogInvokation(const Reference< XComponentContext >& _rxContext
, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xDataSource
, Window* _pMessageParent)
- :m_xORB(_rxORB)
+ :m_xContext(_rxContext)
,m_xDataSource(_xDataSource)
,m_pMessageParent(_pMessageParent)
{
- DBG_ASSERT(m_xORB.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid service factory!");
+ DBG_ASSERT(m_xContext.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid service factory!");
DBG_ASSERT(m_xDataSource.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid preferred name!");
DBG_ASSERT(m_pMessageParent, "OAdminDialogInvokation::OAdminDialogInvokation: invalid message parent!");
}
@@ -59,7 +61,7 @@ namespace abp
//---------------------------------------------------------------------
sal_Bool OAdminDialogInvokation::invokeAdministration( sal_Bool _bFixedType )
{
- if (!m_xORB.is())
+ if (!m_xContext.is())
return sal_False;
try
@@ -89,7 +91,7 @@ namespace abp
// creating the dialog service is potentially expensive (if all the libraries invoked need to be loaded)
// so we display a wait cursor
WaitObject aWaitCursor(m_pMessageParent);
- xDialog = Reference< XExecutableDialog >( m_xORB->createInstanceWithArguments( _bFixedType ? s_sAdministrationServiceName : s_sDataSourceTypeChangeDialog, aArguments ), UNO_QUERY );
+ xDialog = Reference< XExecutableDialog >( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(_bFixedType ? s_sAdministrationServiceName : s_sDataSourceTypeChangeDialog, aArguments, m_xContext), UNO_QUERY );
// just for a smoother UI: What the dialog does upon execution, is (amongst other things) creating
// the DriverManager service
@@ -99,7 +101,7 @@ namespace abp
// context needs to be freshly created
// Thus, we access the context here (within the WaitCursor), which means the user sees a waitcursor
// while his/her office blocks a few seconds ....
- m_xORB->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbc.DriverManager" )) );
+ DriverManager::create( m_xContext );
}
if (xDialog.is())
diff --git a/extensions/source/abpilot/admininvokationimpl.hxx b/extensions/source/abpilot/admininvokationimpl.hxx
index 8196944047bc..de19a6bb08d5 100644
--- a/extensions/source/abpilot/admininvokationimpl.hxx
+++ b/extensions/source/abpilot/admininvokationimpl.hxx
@@ -20,7 +20,7 @@
#ifndef EXTENSIONS_ABP_ADMININVOKATIONIMPL_HXX
#define EXTENSIONS_ABP_ADMININVOKATIONIMPL_HXX
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
@@ -39,14 +39,14 @@ namespace abp
class OAdminDialogInvokation
{
private:
- ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
- m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDataSource;
Window* m_pMessageParent;
public:
OAdminDialogInvokation(
- const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xDataSource,
Window* _pMessageParent
);
diff --git a/extensions/source/abpilot/admininvokationpage.cxx b/extensions/source/abpilot/admininvokationpage.cxx
index c64f5a9b1dbb..0528191f9d91 100644
--- a/extensions/source/abpilot/admininvokationpage.cxx
+++ b/extensions/source/abpilot/admininvokationpage.cxx
@@ -20,6 +20,7 @@
#include "admininvokationpage.hxx"
#include "abspilot.hxx"
#include "admininvokationimpl.hxx"
+#include "comphelper/processfactory.hxx"
//.........................................................................
namespace abp
@@ -88,7 +89,7 @@ namespace abp
//---------------------------------------------------------------------
IMPL_LINK( AdminDialogInvokationPage, OnInvokeAdminDialog, void*, /*NOTINTERESTEDIN*/ )
{
- OAdminDialogInvokation aInvokation( getORB(), getDialog()->getDataSource().getDataSource(), getDialog() );
+ OAdminDialogInvokation aInvokation( comphelper::getComponentContext(getORB()), getDialog()->getDataSource().getDataSource(), getDialog() );
if ( aInvokation.invokeAdministration( AST_LDAP == getSettings().eType ) )
{
// try to connect to this data source
diff --git a/extensions/source/abpilot/typeselectionpage.cxx b/extensions/source/abpilot/typeselectionpage.cxx
index 6ce6280753f7..199125179c2d 100644
--- a/extensions/source/abpilot/typeselectionpage.cxx
+++ b/extensions/source/abpilot/typeselectionpage.cxx
@@ -21,7 +21,9 @@
#include "addresssettings.hxx"
#include "abspilot.hxx"
#include <vcl/msgbox.hxx>
-#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
+#include <comphelper/processfactory.hxx>
//.........................................................................
namespace abp
@@ -98,7 +100,7 @@ namespace abp
bWithMozilla = true;
#endif
- Reference< XDriverAccess> xManager(_pParent->getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager"))), UNO_QUERY);
+ Reference< XDriverManager2 > xManager = DriverManager::create( comphelper::getComponentContext( _pParent->getORB() ) );
try
{
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index eab0bf35086a..5bf747e28558 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -1013,7 +1013,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/sdbc,\
ConnectionProperties \
DBASEConnectionProperties \
Driver \
- DriverManager \
FILEConnectionProperties \
FLATConnectionProperties \
JDBCConnectionProperties \
diff --git a/offapi/com/sun/star/sdbc/XDriverManager2.idl b/offapi/com/sun/star/sdbc/XDriverManager2.idl
index 6512eb3131cc..8477e1b5d31d 100644
--- a/offapi/com/sun/star/sdbc/XDriverManager2.idl
+++ b/offapi/com/sun/star/sdbc/XDriverManager2.idl
@@ -21,6 +21,7 @@
#include <com/sun/star/container/XEnumerationAccess.idl>
#include <com/sun/star/sdbc/XDriverManager.idl>
+#include <com/sun/star/sdbc/XDriverAccess.idl>
module com { module sun { module star { module sdbc {
@@ -39,6 +40,7 @@ module com { module sun { module star { module sdbc {
</p>
@see com::sun::star::sdbc::XDriver
@see com::sun::star::sdbc::XConnection
+ @since LibreOffice 4.0
*/
published interface XDriverManager2
{
@@ -47,6 +49,8 @@ published interface XDriverManager2
*/
interface XDriverManager;
+ interface XDriverAccess;
+
/** creates an enumeration on all installed / registered drivers.
*/
interface com::sun::star::container::XEnumerationAccess;
diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb
index 1797e21ef754..b62918fa685b 100644
--- a/offapi/type_reference/types.rdb
+++ b/offapi/type_reference/types.rdb
Binary files differ
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 3759a5b5873f..267d6cf1239f 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -35,7 +35,7 @@
#include <com/sun/star/sdbc/XConnection.hpp>
#include <com/sun/star/sdbc/XDriver.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
-#include <com/sun/star/sdbc/XDriverManager.hpp>
+#include <com/sun/star/sdbc/DriverManager.hpp>
#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/sdbc/XRowSet.hpp>
@@ -82,7 +82,6 @@ using ::std::vector;
// -----------------------------------------------------------------------
#define SC_SERVICE_ROWSET "com.sun.star.sdb.RowSet"
-#define SC_SERVICE_DRVMAN "com.sun.star.sdbc.DriverManager"
//! move to a header file?
#define SC_DBPROP_ACTIVECONNECTION "ActiveConnection"
@@ -102,7 +101,7 @@ using ::std::vector;
namespace
{
- sal_uLong lcl_getDBaseConnection(uno::Reference<sdbc::XDriverManager>& _rDrvMgr,uno::Reference<sdbc::XConnection>& _rConnection,String& _rTabName,const String& rFullFileName,rtl_TextEncoding eCharSet)
+ sal_uLong lcl_getDBaseConnection(uno::Reference<sdbc::XDriverManager2>& _rDrvMgr,uno::Reference<sdbc::XConnection>& _rConnection,String& _rTabName,const String& rFullFileName,rtl_TextEncoding eCharSet)
{
INetURLObject aURL;
aURL.SetSmartProtocol( INET_PROT_FILE );
@@ -113,14 +112,9 @@ namespace
aURL.removeSegment();
aURL.removeFinalSlash();
String aPath = aURL.GetMainURL(INetURLObject::NO_DECODE);
- uno::Reference<lang::XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory();
- if (!xFactory.is()) return SCERR_EXPORT_CONNECT;
+ uno::Reference<uno::XComponentContext> xContext = comphelper::getProcessComponentContext();
- _rDrvMgr.set( xFactory->createInstance(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SC_SERVICE_DRVMAN )) ),
- uno::UNO_QUERY);
- OSL_ENSURE( _rDrvMgr.is(), "can't get DriverManager" );
- if (!_rDrvMgr.is()) return SCERR_EXPORT_CONNECT;
+ _rDrvMgr.set( sdbc::DriverManager::create( xContext ) );
// get connection
@@ -320,7 +314,7 @@ sal_uLong ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet
try
{
String aTabName;
- uno::Reference<sdbc::XDriverManager> xDrvMan;
+ uno::Reference<sdbc::XDriverManager2> xDrvMan;
uno::Reference<sdbc::XConnection> xConnection;
sal_uLong nRet = lcl_getDBaseConnection(xDrvMan,xConnection,aTabName,rFullFileName,eCharSet);
if ( !xConnection.is() || !xDrvMan.is() )
@@ -847,7 +841,7 @@ sal_uLong ScDocShell::DBaseExport( const rtl::OUString& rFullFileName, CharSet e
try
{
- uno::Reference<sdbc::XDriverManager> xDrvMan;
+ uno::Reference<sdbc::XDriverManager2> xDrvMan;
uno::Reference<sdbc::XConnection> xConnection;
sal_uLong nRet = lcl_getDBaseConnection(xDrvMan,xConnection,aTabName,rFullFileName,eCharSet);
if ( !xConnection.is() || !xDrvMan.is() )