summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2018-07-04 01:33:38 +1000
committerAron Budea <aron.budea@collabora.com>2018-07-09 16:27:08 +0200
commitc9ac66ddcf8bfa135bbd17b0fbb4e6afdcfc3335 (patch)
treeacd4cb09cf3ef36f5a9635cc947833a57fb6ab65
parent046f62db2e6a8092e84fa7c3e82e12cce1d52eb4 (diff)
tdf#116543: don't forget to commit registrations in DB field editor
This avoids revoking the uncommitted registration when any mailmerge doc is destroyed. Also don't forget to pass relevant SwDocShell when registering data source. This allows to register the data source for current document. Change-Id: Id89be82b0120661700e9fee6a075e5877d76e3b0 Reviewed-on: https://gerrit.libreoffice.org/56891 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/57104 Tested-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Aron Budea <aron.budea@collabora.com>
-rw-r--r--sw/source/ui/fldui/flddb.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index cb2763b475a6..4c823118ae3a 100644
--- a/sw/source/ui/fldui/flddb.cxx
+++ b/sw/source/ui/fldui/flddb.cxx
@@ -24,6 +24,7 @@
#include <dbfld.hxx>
#include <fldtdlg.hxx>
#include <numrule.hxx>
+#include <doc.hxx>
#include "flddb.hxx"
#include <dbconfig.hxx>
@@ -78,6 +79,14 @@ SwFieldDBPage::~SwFieldDBPage()
void SwFieldDBPage::dispose()
{
+ SwWrtShell* pSh = GetWrtShell();
+ if (!pSh)
+ pSh = ::GetActiveWrtShell();
+ // This would cleanup in the case of cancelled dialog
+ SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager();
+ if (pDbManager)
+ pDbManager->RevokeLastRegistrations();
+
m_pTypeLB.clear();
m_pDatabaseTLB.clear();
m_pAddDBPB.clear();
@@ -208,6 +217,10 @@ bool SwFieldDBPage::FillItemSet(SfxItemSet* )
if(!pSh)
pSh = ::GetActiveWrtShell();
+ SwDBManager* pDbManager = pSh->GetDoc()->GetDBManager();
+ if (pDbManager)
+ pDbManager->CommitLastRegistrations();
+
if (aData.sDataSource.isEmpty())
aData = pSh->GetDBData();
@@ -477,7 +490,11 @@ IMPL_LINK( SwFieldDBPage, TreeSelectHdl, SvTreeListBox *, pBox, void )
IMPL_LINK_NOARG(SwFieldDBPage, AddDBHdl, Button*, void)
{
- OUString sNewDB = SwDBManager::LoadAndRegisterDataSource(this);
+ SwWrtShell* pSh = GetWrtShell();
+ if (!pSh)
+ pSh = ::GetActiveWrtShell();
+
+ OUString sNewDB = SwDBManager::LoadAndRegisterDataSource(this, pSh->GetDoc()->GetDocShell());
if(!sNewDB.isEmpty())
{
m_pDatabaseTLB->AddDataSource(sNewDB);