User: kz Date: 2008-03-06 18:28:57+0000 Modified: dba/dbaccess/source/ui/misc/datasourceconnector.cxx
Log: INTEGRATION: CWS odbmacros2 (1.13.82); FILE MERGED 2008/01/24 14:12:01 fs 1.13.82.2: #i49133# connect: use the document's interaction handler, if there is one 2007/12/19 13:26:25 fs 1.13.82.1: m_xDatabaseContext is not needed File Changes: Directory: /dba/dbaccess/source/ui/misc/ ======================================== File [changed]: datasourceconnector.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/misc/datasourceconnector.cxx?r1=1.13&r2=1.14 Delta lines: +22 -31 --------------------- --- datasourceconnector.cxx 2007-07-24 12:10:26+0000 1.13 +++ datasourceconnector.cxx 2008-03-06 18:28:54+0000 1.14 @@ -57,6 +57,9 @@ #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_ #include <com/sun/star/task/XInteractionHandler.hpp> #endif +#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ +#include <com/sun/star/frame/XModel.hpp> +#endif #ifndef _COM_SUN_STAR_SDB_SQLCONTEXT_HPP_ #include <com/sun/star/sdb/SQLContext.hpp> #endif @@ -69,6 +72,9 @@ #ifndef _COMPHELPER_EXTRACT_HXX_ #include <comphelper/extract.hxx> #endif +#ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX +#include <comphelper/namedvaluecollection.hxx> +#endif #ifndef _DBHELPER_DBEXCEPTION_HXX_ #include <connectivity/dbexception.hxx> #endif @@ -107,6 +113,7 @@ using namespace ::com::sun::star::task; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::container; + using namespace ::com::sun::star::frame; using namespace ::dbtools; using ::svt::OFileNotation; @@ -118,7 +125,6 @@ :m_pErrorMessageParent(_pMessageParent) ,m_xORB(_rxORB) { - implConstruct(); } //--------------------------------------------------------------------- @@ -128,27 +134,6 @@ ,m_xORB(_rxORB) ,m_sContextInformation( _rContextInformation ) { - implConstruct(); - } - - //--------------------------------------------------------------------- - void ODatasourceConnector::implConstruct() - { - OSL_ENSURE(m_xORB.is(), "ODatasourceConnector::implConstruct: invalid ORB!"); - if (m_xORB.is()) - { - try - { - Reference< XInterface > xContext = m_xORB->createInstance(SERVICE_SDB_DATABASECONTEXT); - OSL_ENSURE(xContext.is(), "ODatasourceConnector::implConstruct: got no data source context!"); - m_xDatabaseContext.set(xContext,UNO_QUERY); - OSL_ENSURE(m_xDatabaseContext.is() || !xContext.is(), "ODatasourceConnector::ODatasourceConnector: missing the XNameAccess interface on the data source context!"); - } - catch(const Exception&) - { - OSL_ENSURE(sal_False, "ODatasourceConnector::implConstruct: caught an exception while creating the data source context!"); - } - } } //--------------------------------------------------------------------- @@ -162,7 +147,7 @@ // get the data source Reference< XDataSource > xDatasource( - getDataSourceByName_displayError( m_xDatabaseContext, _rDataSourceName, m_pErrorMessageParent, m_xORB, _bShowError ), + getDataSourceByName_displayError( _rDataSourceName, m_pErrorMessageParent, m_xORB, _bShowError ), UNO_QUERY ); if ( xDatasource.is() ) @@ -208,13 +193,19 @@ { // password required, but empty -> connect using an interaction handler Reference< XCompletedConnection > xConnectionCompletion( _xDataSource, UNO_QUERY_THROW ); - // instantiate the default SDB interaction handler - Reference< XInteractionHandler > xHandler(m_xORB->createInstance(SERVICE_SDB_INTERACTION_HANDLER), UNO_QUERY); - if (!xHandler.is()) + Reference< XModel > xModel( getDataSourceOrModel( _xDataSource ), UNO_QUERY_THROW ); + ::comphelper::NamedValueCollection aArgs( xModel->getArgs() ); + Reference< XInteractionHandler > xHandler( aArgs.getOrDefault( "InteractionHandler", Reference< XInteractionHandler >() ) ); + + if ( !xHandler.is() ) { + // instantiate the default SDB interaction handler + xHandler = Reference< XInteractionHandler >( m_xORB->createInstance( SERVICE_SDB_INTERACTION_HANDLER ), UNO_QUERY ); + if ( !xHandler.is() ) ShowServiceNotAvailableError(m_pErrorMessageParent, String(SERVICE_SDB_INTERACTION_HANDLER), sal_True); } - else + + if ( xHandler.is() ) { xConnection = xConnectionCompletion->connectWithCompletion(xHandler); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
