[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - sw/source

Mike Kaganski mike.kaganski at collabora.com
Wed Jul 11 08:58:37 UTC 2018


 sw/source/ui/fldui/flddb.cxx |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 39ba5e3bde93358af1b363da8f850bdc96806cfa
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date:   Wed Jul 4 01:33:38 2018 +1000

    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 at collabora.com>
    (cherry picked from commit 54d76f5203aa5f3ef0e5afdca9d131dadeb3794e)
    Reviewed-on: https://gerrit.libreoffice.org/57005
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/ui/fldui/flddb.cxx b/sw/source/ui/fldui/flddb.cxx
index 6da535c89b69..7447a7708c87 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,12 @@ IMPL_LINK( SwFieldDBPage, TreeSelectHdl, SvTreeListBox *, pBox, void )
 
 IMPL_LINK_NOARG(SwFieldDBPage, AddDBHdl, Button*, void)
 {
-    OUString sNewDB = SwDBManager::LoadAndRegisterDataSource(GetFrameWeld());
+    SwWrtShell* pSh = GetWrtShell();
+    if (!pSh)
+        pSh = ::GetActiveWrtShell();
+
+    OUString sNewDB
+        = SwDBManager::LoadAndRegisterDataSource(GetFrameWeld(), pSh->GetDoc()->GetDocShell());
     if(!sNewDB.isEmpty())
     {
         m_pDatabaseTLB->AddDataSource(sNewDB);


More information about the Libreoffice-commits mailing list