summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-09-05 17:24:05 +0200
committerAndras Timar <andras.timar@collabora.com>2017-09-12 14:58:10 +0200
commitcba9bce6936c31aa836763a4dd147ac3db2013bc (patch)
tree8287905d8e805ee62e4bdf259b25bd77008da40e
parente3312f41fb70f91e31878e2bb9ccbfbf7e917eea (diff)
tdf#108572 revoke connection if mail-merge is cancelled
Change-Id: Idca4969af8043f7dbc54f4a63b99e92155ef1585 Reviewed-on: https://gerrit.libreoffice.org/41949 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> (cherry picked from commit ba368643e6a0c5ac7a7b7ea8d72899d60b2a8331) Reviewed-on: https://gerrit.libreoffice.org/42044 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sw/inc/dbmgr.hxx9
-rw-r--r--sw/source/uibase/app/apphdl.cxx8
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx28
3 files changed, 45 insertions, 0 deletions
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 09a077200454..d4797b303e23 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -258,6 +258,9 @@ friend class SwConnectionDisposedListener_Impl;
/// 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;
@@ -478,6 +481,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 5abd1de7c9fa..0b029e6e5a04 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -489,6 +489,8 @@ void SwMailMergeWizardExecutor::ExecutionFinished()
if (xMMConfig)
xMMConfig->Commit();
+ SwDBManager::CommitLastRegistrations();
+
// release/destroy asynchronously
Application::PostUserEvent( LINK( this, SwMailMergeWizardExecutor, DestroyDialogHdl ) );
}
@@ -661,6 +663,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 876f4c22166a..410fb02e6ade 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -165,6 +165,8 @@ void lcl_emitEvent(sal_uInt16 nEventId, sal_Int32 nStrId, SfxObjectShell* pDocSh
}
+std::vector<OUString> SwDBManager::m_aUncommitedRegistrations;
+
enum class SwDBNextRecord { NEXT, FIRST };
static bool lcl_ToNextRecord( SwDSParam* pParam, const SwDBNextRecord action = SwDBNextRecord::NEXT );
@@ -2624,6 +2626,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;
}
@@ -3200,4 +3204,28 @@ std::shared_ptr<SwMailMergeConfigItem> SwDBManager::PerformMailMerge(SwView* pVi
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: */