From d30ab819b80e67119e17d3e4243cab88c508ebae Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 16 Aug 2019 20:23:50 +0100 Subject: tdf#125340 transport preferred dialog parent down the migration dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Icb7bab35eac3ae08fb82d73f559ef161dd1820c3 Reviewed-on: https://gerrit.libreoffice.org/77606 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- connectivity/source/commontools/dbtools.cxx | 54 +++++++++++++++++++------- connectivity/source/commontools/parameters.cxx | 4 +- 2 files changed, 42 insertions(+), 16 deletions(-) (limited to 'connectivity') diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index d760a16a7fc6..75df94ec8ea1 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -22,12 +22,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -265,12 +267,25 @@ static Reference< XConnection > getConnection_allowException( const OUString& _rsTitleOrPath, const OUString& _rsUser, const OUString& _rsPwd, - const Reference< XComponentContext>& _rxContext) + const Reference< XComponentContext>& _rxContext, + const Reference< XWindow >& _rxParent) { Reference< XDataSource> xDataSource( getDataSource_allowException(_rsTitleOrPath, _rxContext) ); Reference xConnection; if (xDataSource.is()) { + + //set ParentWindow for dialog, but just for the duration of this + //call, undo at end of scope + Reference xIni(xDataSource, UNO_QUERY); + if (xIni.is()) + { + Sequence< Any > aArgs(1); + NamedValue aParam( "ParentWindow", makeAny(_rxParent) ); + aArgs[0] <<= aParam; + xIni->initialize(aArgs); + } + // do it with interaction handler if(_rsUser.isEmpty() || _rsPwd.isEmpty()) { @@ -293,7 +308,7 @@ static Reference< XConnection > getConnection_allowException( if (xConnectionCompletion.is()) { // instantiate the default SDB interaction handler Reference< XInteractionHandler > xHandler = - InteractionHandler::createWithParent(_rxContext, nullptr); + InteractionHandler::createWithParent(_rxContext, _rxParent); xConnection = xConnectionCompletion->connectWithCompletion(xHandler); } } @@ -302,17 +317,27 @@ static Reference< XConnection > getConnection_allowException( } if(!xConnection.is()) // try to get one if not already have one, just to make sure xConnection = xDataSource->getConnection(_rsUser, _rsPwd); + + if (xIni.is()) + { + Sequence< Any > aArgs(1); + NamedValue aParam( "ParentWindow", makeAny(Reference()) ); + aArgs[0] <<= aParam; + xIni->initialize(aArgs); + } + } return xConnection; } Reference< XConnection> getConnection_withFeedback(const OUString& _rDataSourceName, - const OUString& _rUser, const OUString& _rPwd, const Reference< XComponentContext>& _rxContext) + const OUString& _rUser, const OUString& _rPwd, const Reference< XComponentContext>& _rxContext, + const Reference< XWindow >& _rxParent) { Reference< XConnection > xReturn; try { - xReturn = getConnection_allowException(_rDataSourceName, _rUser, _rPwd, _rxContext); + xReturn = getConnection_allowException(_rDataSourceName, _rUser, _rPwd, _rxContext, _rxParent); } catch(SQLException&) { @@ -339,7 +364,7 @@ Reference< XConnection> getConnection(const Reference< XRowSet>& _rxRowSet) // if connectRowset (which is deprecated) is removed, this function and one of its parameters are // not needed anymore, the whole implementation can be moved into ensureRowSetConnection then) static SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, - bool _bAttachAutoDisposer ) + bool _bAttachAutoDisposer, const Reference< XWindow >& _rxParent) { SharedConnection xConnection; @@ -387,7 +412,7 @@ static SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, if (hasProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), xRowSetProps)) xRowSetProps->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPwd; - xPureConnection = getConnection_allowException( sDataSourceName, sUser, sPwd, _rxContext ); + xPureConnection = getConnection_allowException( sDataSourceName, sUser, sPwd, _rxContext, _rxParent ); } else if (!sURL.isEmpty()) { // the row set has no data source, but a connection url set @@ -448,15 +473,15 @@ static SharedConnection lcl_connectRowSet(const Reference< XRowSet>& _rxRowSet, return xConnection; } -Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext ) +Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext >& _rxContext, const Reference< XWindow >& _rxParent) { - SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxContext, true ); + SharedConnection xConnection = lcl_connectRowSet( _rxRowSet, _rxContext, true, _rxParent ); return xConnection.getTyped(); } -SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext>& _rxContext ) +SharedConnection ensureRowSetConnection(const Reference< XRowSet>& _rxRowSet, const Reference< XComponentContext>& _rxContext, const Reference< XWindow >& _rxParent) { - return lcl_connectRowSet( _rxRowSet, _rxContext, false/*bUseAutoConnectionDisposer*/ ); + return lcl_connectRowSet( _rxRowSet, _rxContext, false/*bUseAutoConnectionDisposer*/, _rxParent ); } Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const OUString& _rName) @@ -1195,12 +1220,12 @@ Reference< XDataSource> findDataSource(const Reference< XInterface >& _xParent) return xDataSource; } -static Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XComponentContext >& _rxContext ) +static Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XPropertySet >& _rxRowSet, const Reference< XComponentContext >& _rxContext, const Reference< XWindow >& _rxParent ) { Reference< XSingleSelectQueryComposer > xComposer; try { - Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxContext ); + Reference< XConnection> xConn = connectRowset( Reference< XRowSet >( _rxRowSet, UNO_QUERY ), _rxContext, _rxParent ); if ( xConn.is() ) // implies _rxRowSet.is() { // build the statement the row set is based on (can't use the ActiveCommand property of the set @@ -1244,12 +1269,13 @@ static Reference< XSingleSelectQueryComposer > getComposedRowSetStatement( const Reference< XSingleSelectQueryComposer > getCurrentSettingsComposer( const Reference< XPropertySet>& _rxRowSetProps, - const Reference< XComponentContext>& _rxContext) + const Reference< XComponentContext>& _rxContext, + const Reference< XWindow >& _rxParent) { Reference< XSingleSelectQueryComposer > xReturn; try { - xReturn = getComposedRowSetStatement( _rxRowSetProps, _rxContext ); + xReturn = getComposedRowSetStatement( _rxRowSetProps, _rxContext, _rxParent ); } catch( const SQLException& ) { diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx index 3485ce29b81f..4502dbc0687e 100644 --- a/connectivity/source/commontools/parameters.cxx +++ b/connectivity/source/commontools/parameters.cxx @@ -136,7 +136,7 @@ namespace dbtools try { // get a query composer for the 's settings - m_xComposer.reset( getCurrentSettingsComposer( _rxComponent, m_xContext ), SharedQueryComposer::TakeOwnership ); + m_xComposer.reset( getCurrentSettingsComposer( _rxComponent, m_xContext, nullptr ), SharedQueryComposer::TakeOwnership ); // see if the composer found parameters Reference< XParametersSupplier > xParamSupp( m_xComposer, UNO_QUERY ); @@ -833,7 +833,7 @@ namespace dbtools // re-create the parent composer all the time. Else, we'd have to bother with // being a listener at its properties, its loaded state, and event the parent-relationship. m_xParentComposer.reset( - getCurrentSettingsComposer( xParent, m_xContext ), + getCurrentSettingsComposer( xParent, m_xContext, nullptr ), SharedQueryComposer::TakeOwnership ); xParentColSupp.set(m_xParentComposer, css::uno::UNO_QUERY); -- cgit