summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-01-31 13:10:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-01 07:00:04 +0100
commit137df7cd67e5bb34cb75f716700d3c765a3efad2 (patch)
tree503ed29dbe1f1caef4af145c99693c416c5f60ba /sw/source/uibase/shells
parent1276daee3d0d4f30ee8844b6df55d72e0b54093f (diff)
make insert-db-col-auto-pilot dialog async
Change-Id: I954c9a4c55c9c641955484626aa744dd9fa74995 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162808 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase/shells')
-rw-r--r--sw/source/uibase/shells/textsh2.cxx75
1 files changed, 40 insertions, 35 deletions
diff --git a/sw/source/uibase/shells/textsh2.cxx b/sw/source/uibase/shells/textsh2.cxx
index 8a62f401fe46..566c8d357a4a 100644
--- a/sw/source/uibase/shells/textsh2.cxx
+++ b/sw/source/uibase/shells/textsh2.cxx
@@ -205,48 +205,53 @@ void SwTextShell::ExecDB(SfxRequest const &rReq)
IMPL_LINK( SwBaseShell, InsertDBTextHdl, void*, p, void )
{
- DBTextStruct_Impl* pDBStruct = static_cast<DBTextStruct_Impl*>(p);
- if( pDBStruct )
- {
- bool bDispose = false;
- Reference< sdbc::XConnection> xConnection = pDBStruct->xConnection;
- Reference<XDataSource> xSource = SwDBManager::getDataSourceAsParent(xConnection,pDBStruct->aDBData.sDataSource);
- // #111987# the connection is disposed and so no parent has been found
- if(xConnection.is() && !xSource.is())
- return;
+ std::shared_ptr<DBTextStruct_Impl> pDBStruct(static_cast<DBTextStruct_Impl*>(p));
+ if( !pDBStruct )
+ return;
- if ( !xConnection.is() )
- {
- SwView &rSwView = GetView();
- xConnection = SwDBManager::GetConnection(pDBStruct->aDBData.sDataSource, xSource, &rSwView);
- bDispose = true;
- }
+ bool bDispose = false;
+ Reference< sdbc::XConnection> xConnection = pDBStruct->xConnection;
+ Reference<XDataSource> xSource = SwDBManager::getDataSourceAsParent(xConnection,pDBStruct->aDBData.sDataSource);
+ // #111987# the connection is disposed and so no parent has been found
+ if(xConnection.is() && !xSource.is())
+ return;
- Reference< XColumnsSupplier> xColSupp;
- if(xConnection.is())
- xColSupp = SwDBManager::GetColumnSupplier(xConnection,
- pDBStruct->aDBData.sCommand,
- pDBStruct->aDBData.nCommandType == CommandType::QUERY ?
- SwDBSelect::QUERY : SwDBSelect::TABLE);
+ if ( !xConnection.is() )
+ {
+ SwView &rSwView = GetView();
+ xConnection = SwDBManager::GetConnection(pDBStruct->aDBData.sDataSource, xSource, &rSwView);
+ bDispose = true;
+ }
- if( xColSupp.is() )
- {
- SwDBData aDBData = pDBStruct->aDBData;
- SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
- ScopedVclPtr<AbstractSwInsertDBColAutoPilot>pDlg (pFact->CreateSwInsertDBColAutoPilot(GetView(),
- xSource,
- xColSupp,
- aDBData));
- if( RET_OK == pDlg->Execute() )
- {
- pDlg->DataToDoc(pDBStruct->aSelection, xSource, xConnection, pDBStruct->xCursor);
- }
- }
+ Reference< XColumnsSupplier> xColSupp;
+ if(xConnection.is())
+ xColSupp = SwDBManager::GetColumnSupplier(xConnection,
+ pDBStruct->aDBData.sCommand,
+ pDBStruct->aDBData.nCommandType == CommandType::QUERY ?
+ SwDBSelect::QUERY : SwDBSelect::TABLE);
+
+ if( !xColSupp )
+ {
if ( bDispose )
::comphelper::disposeComponent(xConnection);
+ return;
}
- delete pDBStruct;
+ SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
+ VclPtr<AbstractSwInsertDBColAutoPilot>pDlg (pFact->CreateSwInsertDBColAutoPilot(GetView(),
+ xSource,
+ xColSupp,
+ pDBStruct->aDBData));
+ pDlg->StartExecuteAsync(
+ [pDlg, pDBStruct2=std::move(pDBStruct), xSource, xConnection, bDispose] (sal_Int32 nResult) mutable
+ {
+ if (nResult == RET_OK)
+ pDlg->DataToDoc(pDBStruct2->aSelection, xSource, xConnection, pDBStruct2->xCursor);
+ pDlg->disposeOnce();
+ if ( bDispose )
+ ::comphelper::disposeComponent(xConnection);
+ }
+ );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */