sw/inc/dbmgr.hxx | 9 +++++++++ sw/source/uibase/app/apphdl.cxx | 8 ++++++++ sw/source/uibase/dbui/dbmgr.cxx | 28 ++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+)
New commits: commit ba368643e6a0c5ac7a7b7ea8d72899d60b2a8331 Author: Szymon KÅos <szymon.k...@collabora.com> Date: Tue Sep 5 17:24:05 2017 +0200 tdf#108572 revoke connection if mail-merge is cancelled Change-Id: Idca4969af8043f7dbc54f4a63b99e92155ef1585 Reviewed-on: https://gerrit.libreoffice.org/41949 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Szymon KÅos <szymon.k...@collabora.com> diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx index 2b9cb62c814d..373ca1175215 100644 --- a/sw/inc/dbmgr.hxx +++ b/sw/inc/dbmgr.hxx @@ -256,6 +256,9 @@ class SW_DLLPUBLIC SwDBManager /// Name of the embedded database that's included in the current document. OUString m_sEmbeddedName; + /// Store last registrations to revoke or commit + static std::vector<OUString> m_aUncommitedRegistrations; + /// The document that owns this manager. SwDoc* m_pDoc; @@ -476,6 +479,12 @@ public: SwDoc* getDoc() const; /// Stop reacting to removed database registrations. void releaseRevokeListener(); + + /// Revoke not commited registrations in case of mail merge cancel + void RevokeLastRegistrations(); + + /// Accept not commited registrations + static void CommitLastRegistrations(); }; #endif diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index 114cd5467c79..a9c72fe84ac2 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -479,6 +479,8 @@ void SwMailMergeWizardExecutor::ExecutionFinished() if (xMMConfig) xMMConfig->Commit(); + SwDBManager::CommitLastRegistrations(); + // release/destroy asynchronously Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, DestroyDialogHdl ) ); } @@ -651,6 +653,12 @@ IMPL_LINK_NOARG(SwMailMergeWizardExecutor, CancelHdl, void*, void) xMMConfig->Commit(); } + // Revoke created connections + SwDoc* pDoc = m_pView->GetDocShell()->GetDoc(); + SwDBManager* pDbManager = pDoc->GetDBManager(); + if (pDbManager) + pDbManager->RevokeLastRegistrations(); + m_pWizard.disposeAndClear(); release(); } diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index a08a6a923cdc..6cac7eb100a6 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -161,6 +161,8 @@ void lcl_emitEvent(SfxEventHintId nEventId, sal_Int32 nStrId, SfxObjectShell* pD } +std::vector<OUString> SwDBManager::m_aUncommitedRegistrations; + enum class SwDBNextRecord { NEXT, FIRST }; static bool lcl_ToNextRecord( SwDSParam* pParam, const SwDBNextRecord action = SwDBNextRecord::NEXT ); @@ -2612,6 +2614,8 @@ OUString SwDBManager::LoadAndRegisterDataSource(SwDocShell* pDocShell) aSettings.set( uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY_THROW ) ); } sFind = LoadAndRegisterDataSource( type, aURLAny, DBCONN_FLAT == type ? &aSettings : nullptr, aURI, nullptr, nullptr, pDocShell ); + + m_aUncommitedRegistrations.push_back(sFind); } return sFind; } @@ -3181,4 +3185,28 @@ std::shared_ptr<SwMailMergeConfigItem> SwDBManager::PerformMailMerge(SwView cons return xConfigItem; } +void SwDBManager::RevokeLastRegistrations() +{ + if (m_aUncommitedRegistrations.size()) + { + SwView* pView = m_pDoc->GetDocShell()->GetView(); + std::shared_ptr<SwMailMergeConfigItem> xConfigItem = pView->GetMailMergeConfigItem(); + if (xConfigItem) + { + xConfigItem->DisposeResultSet(); + xConfigItem->DocumentReloaded(); + } + + for (const OUString& rName : m_aUncommitedRegistrations) + RevokeDataSource(rName); + + m_aUncommitedRegistrations.clear(); + } +} + +void SwDBManager::CommitLastRegistrations() +{ + m_aUncommitedRegistrations.clear(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits