Kaydet (Commit) 78b2bf15 authored tarafından Ariel Constenla-Haile's avatar Ariel Constenla-Haile

Ensure UNO context propagation on drivers instantiation

üst 54b984f7
......@@ -125,7 +125,8 @@ Any SAL_CALL ODriverEnumeration::nextElement( ) throw(NoSuchElementException, W
// we did not load this driver, yet
if ( _rDescriptor.xComponentFactory.is() )
// we have a factory for it
const_cast< DriverAccess& >( _rDescriptor ).xDriver = _rDescriptor.xDriver.query( _rDescriptor.xComponentFactory->createInstance() );
const_cast< DriverAccess& >( _rDescriptor ).xDriver = _rDescriptor.xDriver.query(
_rDescriptor.xComponentFactory->createInstanceWithContext( _rDescriptor.xUNOContext ) );
return _rDescriptor;
}
};
......@@ -318,7 +319,7 @@ void OSDBCDriverManager::bootstrapDrivers()
OSL_ENSURE( xEnumDrivers.is(), "OSDBCDriverManager::bootstrapDrivers: no enumeration for the drivers available!" );
if (xEnumDrivers.is())
{
Reference< XSingleServiceFactory > xFactory;
Reference< XSingleComponentFactory > xFactory;
Reference< XServiceInfo > xSI;
while (xEnumDrivers->hasMoreElements())
{
......@@ -337,6 +338,7 @@ void OSDBCDriverManager::bootstrapDrivers()
{ // yes -> no need to load the driver immediately (load it later when needed)
aDriverDescriptor.sImplementationName = xSI->getImplementationName();
aDriverDescriptor.xComponentFactory = xFactory;
aDriverDescriptor.xUNOContext = m_aContext.getUNOContext();
bValidDescriptor = sal_True;
m_aEventLogger.log( LogLevel::CONFIG,
......@@ -347,7 +349,7 @@ void OSDBCDriverManager::bootstrapDrivers()
else
{
// no -> create the driver
Reference< XDriver > xDriver( xFactory->createInstance(), UNO_QUERY );
Reference< XDriver > xDriver( xFactory->createInstanceWithContext( m_aContext.getUNOContext() ), UNO_QUERY );
OSL_ENSURE( xDriver.is(), "OSDBCDriverManager::bootstrapDrivers: a driver which is no driver?!" );
if ( xDriver.is() )
......
......@@ -30,7 +30,8 @@
#include <com/sun/star/uno/XNamingService.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/sdbc/XDriverAccess.hpp>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
//#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
#include <cppuhelper/implbase5.hxx>
#include <comphelper/stl_types.hxx>
......@@ -48,11 +49,13 @@ namespace drivermanager
typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDriver > SdbcDriver;
DECLARE_STL_USTRINGACCESS_MAP( SdbcDriver, DriverCollection );
typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > DriverFactory;
typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > DriverFactory;
typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > UNOContext;
struct DriverAccess
{
::rtl::OUString sImplementationName; /// the implementation name of the driver
DriverFactory xComponentFactory; /// the factory to create the driver component (if not already done so)
UNOContext xUNOContext; /// ensure UNO context propagation
SdbcDriver xDriver; /// the driver itself
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment