[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - connectivity/source dbaccess/source extensions/source forms/source include/connectivity reportdesign/source svx/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Aug 29 07:40:51 UTC 2019


 connectivity/source/commontools/dbtools.cxx           |   56 +++++++++++++-----
 connectivity/source/commontools/parameters.cxx        |    4 -
 dbaccess/source/core/api/RowSet.cxx                   |    2 
 dbaccess/source/core/dataaccess/datasource.cxx        |   42 +++++++------
 dbaccess/source/core/dataaccess/datasource.hxx        |    6 +
 dbaccess/source/core/inc/ModelImpl.hxx                |    4 +
 dbaccess/source/ui/browser/sbagrid.cxx                |    2 
 dbaccess/source/ui/uno/composerdialogs.cxx            |    2 
 extensions/source/dbpilots/controlwizard.cxx          |    2 
 extensions/source/propctrlr/formcomponenthandler.cxx  |    4 -
 extensions/source/propctrlr/formlinkdialog.cxx        |    4 -
 forms/source/component/DatabaseForm.cxx               |   23 +++++++
 include/connectivity/dbtools.hxx                      |   12 ++-
 reportdesign/source/ui/inspection/GeometryHandler.cxx |    2 
 svx/source/fmcomp/fmgridcl.cxx                        |    2 
 svx/source/form/fmvwimp.cxx                           |    3 
 svx/source/form/tabwin.cxx                            |    2 
 17 files changed, 119 insertions(+), 53 deletions(-)

New commits:
commit a7035eb87aef491b52fae83675dd4d1a9877de4a
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Aug 16 20:23:50 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Aug 29 09:40:09 2019 +0200

    tdf#125340 transport preferred dialog parent down the migration dialog
    
    Change-Id: Icb7bab35eac3ae08fb82d73f559ef161dd1820c3
    Reviewed-on: https://gerrit.libreoffice.org/77638
    Tested-by: Jenkins
    Tested-by: Xisco Faulí <xiscofauli at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx
index 1e3f51ec00e2..52ec49cdb010 100644
--- a/connectivity/source/commontools/dbtools.cxx
+++ b/connectivity/source/commontools/dbtools.cxx
@@ -22,12 +22,14 @@
 #include <connectivity/ParameterCont.hxx>
 
 #include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/container/XChild.hpp>
 #include <com/sun/star/form/FormComponentType.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/sdb/DatabaseContext.hpp>
 #include <com/sun/star/sdb/BooleanComparisonMode.hpp>
@@ -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> xConnection;
     if (xDataSource.is())
     {
+
+        //set ParentWindow for dialog, but just for the duration of this
+        //call, undo at end of scope
+        Reference<XInitialization> 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())
         {
@@ -292,8 +307,8 @@ static Reference< XConnection > getConnection_allowException(
                 Reference<XCompletedConnection> xConnectionCompletion(xProp, UNO_QUERY);
                 if (xConnectionCompletion.is())
                 {   // instantiate the default SDB interaction handler
-                    Reference< XInteractionHandler > xHandler(
-                        InteractionHandler::createWithParent(_rxContext, nullptr), UNO_QUERY );
+                    Reference< XInteractionHandler > xHandler =
+                        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<XWindow>()) );
+            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 3458ed7cc34e..d99bbb900a7a 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 );
@@ -838,7 +838,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);
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index b2b9430f562e..228542cd7c4b 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -1454,7 +1454,7 @@ void SAL_CALL ORowSet::executeWithCompletion( const Reference< XInteractionHandl
         calcConnection( _rxHandler );
         m_bRebuildConnOnExecute = false;
 
-        Reference< XSingleSelectQueryComposer > xComposer = getCurrentSettingsComposer( this, m_aContext );
+        Reference< XSingleSelectQueryComposer > xComposer = getCurrentSettingsComposer( this, m_aContext, nullptr );
         Reference<XParametersSupplier>  xParameters(xComposer, UNO_QUERY);
 
         Reference<XIndexAccess>  xParamsAsIndicies = xParameters.is() ? xParameters->getParameters() : Reference<XIndexAccess>();
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx
index d2afd8cc78aa..f25a11bfdf91 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -576,23 +576,22 @@ void ODatabaseSource::disposing()
     m_pImpl.clear();
 }
 
-namespace
+weld::Window* ODatabaseModelImpl::GetFrameWeld()
 {
-#if ENABLE_FIREBIRD_SDBC
-    weld::Window* GetFrameWeld(const Reference<XModel>& rModel)
-    {
-        if (!rModel.is())
-            return nullptr;
-        Reference<XController> xController(rModel->getCurrentController());
-        if (!xController.is())
-            return nullptr;
-        Reference<XFrame> xFrame(xController->getFrame());
-        if (!xFrame.is())
-            return nullptr;
-        Reference<css::awt::XWindow> xWindow(xFrame->getContainerWindow());
-        return Application::GetFrameWeld(xWindow);
-    }
-#endif
+    if (m_xDialogParent.is())
+        return Application::GetFrameWeld(m_xDialogParent);
+
+    Reference<XModel> xModel = getModel_noCreate();
+    if (!xModel.is())
+        return nullptr;
+    Reference<XController> xController(xModel->getCurrentController());
+    if (!xController.is())
+        return nullptr;
+    Reference<XFrame> xFrame(xController->getFrame());
+    if (!xFrame.is())
+        return nullptr;
+    Reference<css::awt::XWindow> xWindow(xFrame->getContainerWindow());
+    return Application::GetFrameWeld(xWindow);
 }
 
 Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString& _rUid, const OUString& _rPwd)
@@ -633,7 +632,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString
                 && (nOpenMode & css::embed::ElementModes::WRITE)
                 && (!Application::IsHeadlessModeEnabled()))
             {
-                MigrationWarnDialog aWarnDlg(GetFrameWeld(m_pImpl->getModel_noCreate()));
+                MigrationWarnDialog aWarnDlg(m_pImpl->GetFrameWeld());
                 bNeedMigration = aWarnDlg.run() == RET_OK;
             }
         }
@@ -777,7 +776,7 @@ Reference< XConnection > ODatabaseSource::buildLowLevelConnection(const OUString
                 m_pImpl->getDocumentSubStorageSupplier() );
         dbahsql::HsqlImporter importer(xReturn,
                 xDocSup->getDocumentSubStorage("database",ElementModes::READWRITE) );
-        importer.importHsqlDatabase(GetFrameWeld(m_pImpl->getModel_noCreate()));
+        importer.importHsqlDatabase(m_pImpl->GetFrameWeld());
     }
 #endif
 
@@ -1399,6 +1398,13 @@ Reference< XOfficeDatabaseDocument > SAL_CALL ODatabaseSource::getDatabaseDocume
     return Reference< XOfficeDatabaseDocument >( xModel, UNO_QUERY_THROW );
 }
 
+void SAL_CALL ODatabaseSource::initialize( css::uno::Sequence< css::uno::Any > const & rArguments)
+{
+    ::comphelper::NamedValueCollection aProperties( rArguments );
+    if (aProperties.has("ParentWindow"))
+        aProperties.get("ParentWindow") >>= m_pImpl->m_xDialogParent;
+}
+
 Reference< XInterface > ODatabaseSource::getThis() const
 {
     return *const_cast< ODatabaseSource* >( this );
diff --git a/dbaccess/source/core/dataaccess/datasource.hxx b/dbaccess/source/core/dataaccess/datasource.hxx
index 815b662506fe..b9d8e8bbf407 100644
--- a/dbaccess/source/core/dataaccess/datasource.hxx
+++ b/dbaccess/source/core/dataaccess/datasource.hxx
@@ -68,6 +68,7 @@ typedef ::cppu::WeakComponentImplHelper<   css::lang::XServiceInfo
                                        ,   css::util::XFlushable
                                        ,   css::util::XFlushListener
                                        ,   css::sdb::XDocumentDataSource
+                                       ,   css::lang::XInitialization
                                        >   ODatabaseSource_Base;
 
 class ODatabaseSource   :public ModelDependentComponent // must be first
@@ -83,7 +84,7 @@ private:
     using ODatabaseSource_Base::rBHelper;
     // note: this thing uses the ref-count of "this", see OBookmarkContainer::acquire!
     OBookmarkContainer m_Bookmarks;
-    ::comphelper::OInterfaceContainerHelper2       m_aFlushListeners;
+    ::comphelper::OInterfaceContainerHelper2 m_aFlushListeners;
 
 private:
     virtual ~ODatabaseSource() override;
@@ -183,6 +184,9 @@ public:
     // XDocumentDataSource
     virtual css::uno::Reference< css::sdb::XOfficeDatabaseDocument > SAL_CALL getDatabaseDocument() override;
 
+    // XInitialization
+    virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
+
 protected:
     // ModelDependentComponent overridables
     virtual css::uno::Reference< css::uno::XInterface > getThis() const override;
diff --git a/dbaccess/source/core/inc/ModelImpl.hxx b/dbaccess/source/core/inc/ModelImpl.hxx
index 0ed9c8dfeece..e938cf830dca 100644
--- a/dbaccess/source/core/inc/ModelImpl.hxx
+++ b/dbaccess/source/core/inc/ModelImpl.hxx
@@ -215,6 +215,8 @@ public:
     OSharedConnectionManager*                           m_pSharedConnectionManager;
     css::uno::Reference< css::lang::XEventListener >
                                                         m_xSharedConnectionManager;
+    css::uno::Reference<css::awt::XWindow>
+                                                        m_xDialogParent;
     sal_uInt16                                          m_nControllerLockCount;
 
     void reset();
@@ -449,6 +451,8 @@ public:
     void    unlockModify()            { m_bModificationLock = false; }
     bool    isModifyLocked() const    { return m_bModificationLock; }
 
+    weld::Window* GetFrameWeld();
+
 private:
     void    impl_construct_nothrow();
     css::uno::Reference< css::embed::XStorage > const &
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx
index c41a4e395c67..5e3a99ca8028 100644
--- a/dbaccess/source/ui/browser/sbagrid.cxx
+++ b/dbaccess/source/ui/browser/sbagrid.cxx
@@ -983,7 +983,7 @@ bool SbaGridControl::IsReadOnlyDB() const
         if (xColumns.is())
         {
             Reference< XRowSet >  xDataSource(xColumns->getParent(), UNO_QUERY);
-            ::dbtools::ensureRowSetConnection( xDataSource, getContext() );
+            ::dbtools::ensureRowSetConnection( xDataSource, getContext(), nullptr );
             Reference< XChild >  xConn(::dbtools::getConnection(xDataSource),UNO_QUERY);
             if (xConn.is())
             {
diff --git a/dbaccess/source/ui/uno/composerdialogs.cxx b/dbaccess/source/ui/uno/composerdialogs.cxx
index 3c983f5a0669..85dee7a7f86b 100644
--- a/dbaccess/source/ui/uno/composerdialogs.cxx
+++ b/dbaccess/source/ui/uno/composerdialogs.cxx
@@ -97,7 +97,7 @@ namespace dbaui
 
             // fallback: if there is a connection and thus a row set, but no composer, create one
             if ( xConnection.is() && !m_xComposer.is() )
-                m_xComposer = ::dbtools::getCurrentSettingsComposer( Reference< XPropertySet >( m_xRowSet, UNO_QUERY ), m_aContext );
+                m_xComposer = ::dbtools::getCurrentSettingsComposer( Reference< XPropertySet >( m_xRowSet, UNO_QUERY ), m_aContext, rParent );
 
             // the columns of the row set
             Reference< XColumnsSupplier > xSuppColumns( m_xRowSet, UNO_QUERY );
diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx
index 4453b72f95f0..338272afe6ee 100644
--- a/extensions/source/dbpilots/controlwizard.cxx
+++ b/extensions/source/dbpilots/controlwizard.cxx
@@ -521,7 +521,7 @@ namespace dbp
                 Reference< XConnection > xConnection;
                 m_aContext.bEmbedded = ::dbtools::isEmbeddedInDatabase( m_aContext.xForm, xConnection );
                 if ( !m_aContext.bEmbedded )
-                    xConnection = ::dbtools::connectRowset( m_aContext.xRowSet, m_xContext );
+                    xConnection = ::dbtools::connectRowset( m_aContext.xRowSet, m_xContext, nullptr );
 
                 // get the fields
                 if (xConnection.is())
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
index ed7348bfaa5d..f1f94fb98d49 100644
--- a/extensions/source/propctrlr/formcomponenthandler.cxx
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -2405,7 +2405,7 @@ namespace pcr
             if ( xRowSetProps.is() )
             {
                 weld::WaitObject aWaitCursor(impl_getDefaultDialogFrame_nothrow());
-                m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_xContext );
+                m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_xContext, nullptr );
             }
         }
         catch ( const SQLException& ) { aError = SQLExceptionInfo( ::cppu::getCaughtException() ); }
@@ -2617,7 +2617,7 @@ namespace pcr
                 return false;
 
             // get a composer for the statement which the form is currently based on
-            Reference< XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( m_xComponent, m_xContext ) );
+            Reference< XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( m_xComponent, m_xContext, nullptr ) );
             OSL_ENSURE( xComposer.is(), "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: could not obtain a composer!" );
             if ( !xComposer.is() )
                 return false;
diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx
index 72d7de9fd4c4..d867c1e97048 100644
--- a/extensions/source/propctrlr/formlinkdialog.cxx
+++ b/extensions/source/propctrlr/formlinkdialog.cxx
@@ -431,7 +431,7 @@ namespace pcr
             _rxConnection.set(_rxFormProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
 
         if ( !_rxConnection.is() )
-            _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xContext );
+            _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xContext, nullptr );
     }
 
 
@@ -453,7 +453,7 @@ namespace pcr
         Reference< XPropertySet > xTable;
         try
         {
-            Reference< XTablesSupplier > xTablesInForm( ::dbtools::getCurrentSettingsComposer( _rxFormProps, m_xContext ), UNO_QUERY );
+            Reference< XTablesSupplier > xTablesInForm( ::dbtools::getCurrentSettingsComposer( _rxFormProps, m_xContext, nullptr ), UNO_QUERY );
             Reference< XNameAccess > xTables;
             if ( xTablesInForm.is() )
                 xTables = xTablesInForm->getTables();
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 2367a06b5441..3f7c04ea8121 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -2718,6 +2718,21 @@ void ODatabaseForm::stopSharingConnection( )
     }
 }
 
+namespace
+{
+    Reference<css::awt::XWindow> GetDialogParentWindow(const Reference<XModel>& rModel)
+    {
+        if (!rModel.is())
+            return nullptr;
+        Reference<XController> xController(rModel->getCurrentController());
+        if (!xController.is())
+            return nullptr;
+        Reference<XFrame> xFrame(xController->getFrame());
+        if (!xFrame.is())
+            return nullptr;
+        return xFrame->getContainerWindow();
+    }
+}
 
 bool ODatabaseForm::implEnsureConnection()
 {
@@ -2759,9 +2774,15 @@ bool ODatabaseForm::implEnsureConnection()
 
         if (m_xAggregateSet.is())
         {
+            //Dig out a suitable parent for any warning dialogs
+            Reference<css::awt::XWindow> m_xDialogParent;
+            Reference<XChild> xParent(m_xParent, UNO_QUERY);
+            if (xParent.is())
+                m_xDialogParent = GetDialogParentWindow(getXModel(xParent->getParent()));
+
             Reference< XConnection >  xConnection = connectRowset(
                 Reference<XRowSet> (m_xAggregate, UNO_QUERY),
-                m_xContext
+                m_xContext, m_xDialogParent
             );
             return xConnection.is();
         }
diff --git a/include/connectivity/dbtools.hxx b/include/connectivity/dbtools.hxx
index 7be98eeeef25..223486b95978 100644
--- a/include/connectivity/dbtools.hxx
+++ b/include/connectivity/dbtools.hxx
@@ -141,7 +141,8 @@ namespace dbtools
     OOO_DLLPUBLIC_DBTOOLS
     css::uno::Reference< css::sdbc::XConnection> connectRowset(
         const css::uno::Reference< css::sdbc::XRowSet>& _rxRowSet,
-        const css::uno::Reference< css::uno::XComponentContext>& _rxContext
+        const css::uno::Reference< css::uno::XComponentContext>& _rxContext,
+        const css::uno::Reference< css::awt::XWindow>& _rxParent
     );
 
     /** ensures that a row set has a valid ActiveConnection, if possible
@@ -164,7 +165,8 @@ namespace dbtools
     */
     OOO_DLLPUBLIC_DBTOOLS SharedConnection    ensureRowSetConnection(
         const css::uno::Reference< css::sdbc::XRowSet>& _rxRowSet,
-        const css::uno::Reference< css::uno::XComponentContext>& _rxContext
+        const css::uno::Reference< css::uno::XComponentContext>& _rxContext,
+        const css::uno::Reference< css::awt::XWindow>& _rxParent
     );
 
     /** returns the connection the RowSet is currently working with (which is the ActiveConnection property)
@@ -176,7 +178,8 @@ namespace dbtools
             const OUString& _rDataSourceName,
             const OUString& _rUser,
             const OUString& _rPwd,
-            const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
+            const css::uno::Reference< css::uno::XComponentContext>& _rxContext,
+            const css::uno::Reference< css::awt::XWindow>& _rxParent);
 
 
     /** determines whether the given component is part of a document which is an embedded database
@@ -400,7 +403,8 @@ namespace dbtools
     */
     OOO_DLLPUBLIC_DBTOOLS css::uno::Reference< css::sdb::XSingleSelectQueryComposer > getCurrentSettingsComposer(
         const css::uno::Reference< css::beans::XPropertySet>& _rxRowSetProps,
-        const css::uno::Reference< css::uno::XComponentContext>& _rxContext
+        const css::uno::Reference< css::uno::XComponentContext>& _rxContext,
+        const css::uno::Reference< css::awt::XWindow>& _rxParent
     );
 
     /** transfer and translate properties between two FormComponents
diff --git a/reportdesign/source/ui/inspection/GeometryHandler.cxx b/reportdesign/source/ui/inspection/GeometryHandler.cxx
index 746c9de1a3f8..0799add7eca3 100644
--- a/reportdesign/source/ui/inspection/GeometryHandler.cxx
+++ b/reportdesign/source/ui/inspection/GeometryHandler.cxx
@@ -1598,7 +1598,7 @@ bool GeometryHandler::impl_dialogFilter_nothrow( OUString& _out_rSelectedClause,
         }
 
         // get a composer for the statement which the form is currently based on
-        uno::Reference< sdb::XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( xRowSetProp, m_xContext ) );
+        uno::Reference< sdb::XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( xRowSetProp, m_xContext, nullptr ) );
         OSL_ENSURE( xComposer.is(), "GeometryHandler::impl_dialogFilter_nothrow: could not obtain a composer!" );
         if ( !xComposer.is() )
             return false;
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx
index e4d4bf6e010b..90b25997821c 100644
--- a/svx/source/fmcomp/fmgridcl.cxx
+++ b/svx/source/fmcomp/fmgridcl.cxx
@@ -267,7 +267,7 @@ sal_Int8 FmGridHeader::ExecuteDrop( const ExecuteDropEvent& _rEvt )
             {
                 OUString sSignificantSource( sDatasource.isEmpty() ? sDatabaseLocation : sDatasource );
                 xConnection = getConnection_withFeedback(sSignificantSource, OUString(), OUString(),
-                                  static_cast<FmGridControl*>(GetParent())->getContext() );
+                                  static_cast<FmGridControl*>(GetParent())->getContext(), nullptr );
             }
             catch(NoSuchElementException&)
             {   // allowed, means sDatasource isn't a valid data source name ....
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index 588c6757f55a..cc6bcef46f65 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1167,7 +1167,8 @@ SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDe
                 sDataSource,
                 OUString(),
                 OUString(),
-                comphelper::getProcessComponentContext()
+                comphelper::getProcessComponentContext(),
+                nullptr
             ) );
     }
     catch (const SQLException&)
diff --git a/svx/source/form/tabwin.cxx b/svx/source/form/tabwin.cxx
index 5620c9ffdea5..5da553b356e2 100644
--- a/svx/source/form/tabwin.cxx
+++ b/svx/source/form/tabwin.cxx
@@ -316,7 +316,7 @@ void FmFieldWin::UpdateContent(const css::uno::Reference< css::form::XForm > & x
 
         // get the connection of the form
         m_aConnection.reset(
-            connectRowset( Reference< XRowSet >( xForm, UNO_QUERY ), ::comphelper::getProcessComponentContext() ),
+            connectRowset( Reference< XRowSet >( xForm, UNO_QUERY ), ::comphelper::getProcessComponentContext(), nullptr ),
             SharedConnection::NoTakeOwnership
         );
         // TODO: When incompatible changes (such as extending the "virtualdbtools" interface by ensureRowSetConnection)


More information about the Libreoffice-commits mailing list