[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - sw/inc sw/source

Vasily Melenchuk vasily.melenchuk at cib.de
Thu Aug 20 08:39:01 PDT 2015


 sw/inc/editsh.hxx               |    1 +
 sw/source/core/edit/edfld.cxx   |    5 +++++
 sw/source/uibase/dbui/dbmgr.cxx |   13 ++++++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

New commits:
commit d0bafebbcd4a301bcca6fb74627820b251f6dce5
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
Date:   Tue Aug 18 14:09:19 2015 +0300

    tdf#92324 Fixed MailMerge printing with values from database
    
    Locking of ExpFields is required to lock current state of fields and database cursor:
    generation of print preview and some other operations can cause changing
    of current database record, especially if document contains nextrecord fields.
    
    Reviewed-on: https://gerrit.libreoffice.org/17857
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    (cherry picked from commit 959a5043ccb4bb027e0149a56d31ebb78d5eb862)
    
    Conflicts:
    	sw/source/uibase/dbui/dbmgr.cxx
    
    Change-Id: If0466ef2489d96264380b5978ef7d7cf3f545c23
    Reviewed-on: https://gerrit.libreoffice.org/17877
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index c80d81d..6a7d718 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -388,6 +388,7 @@ public:
     void UpdateExpFields(bool bCloseDB = false);///< only every expression fields update
     void LockExpFields();
     void UnlockExpFields();
+    bool IsExpFieldsLocked() const;
 
     SwFieldUpdateFlags GetFieldUpdateFlags(bool bDocSettings = false) const;
     void SetFieldUpdateFlags( SwFieldUpdateFlags eFlags );
diff --git a/sw/source/core/edit/edfld.cxx b/sw/source/core/edit/edfld.cxx
index 3bc69b3..affe278 100644
--- a/sw/source/core/edit/edfld.cxx
+++ b/sw/source/core/edit/edfld.cxx
@@ -403,6 +403,11 @@ void SwEditShell::UnlockExpFields()
     GetDoc()->getIDocumentFieldsAccess().UnlockExpFields();
 }
 
+bool SwEditShell::IsExpFieldsLocked() const
+{
+    return GetDoc()->getIDocumentFieldsAccess().IsExpFieldsLocked();
+}
+
 void SwEditShell::SetFieldUpdateFlags( SwFieldUpdateFlags eFlags )
 {
     getIDocumentSettingAccess()->setFieldUpdateFlags( eFlags );
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 922006d..f116153 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1136,12 +1136,17 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                         // #i69458# lock fields to prevent access to the result set while calculating layout
                         rWorkShell.LockExpFields();
                         rWorkShell.CalcLayout();
-                        rWorkShell.UnlockExpFields();
                     }
 
                         SwWrtShell& rWorkShell = pWorkView->GetWrtShell();
                         SfxGetpApp()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE), xWorkDocSh));
+                        // tdf#92324: Allow ExpFields update only by explicit instruction to avoid
+                        // database cursor movement on any other fields update, for example during
+                        // print preview and other operations
+                        if ( rWorkShell.IsExpFieldsLocked() )
+                            rWorkShell.UnlockExpFields();
                         rWorkShell.SwViewShell::UpdateFields();
+                        rWorkShell.LockExpFields();
                         SfxGetpApp()->NotifyEvent(SfxEventHint(SW_EVENT_FIELD_MERGE_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_FIELD_MERGE_FINISHED), xWorkDocSh));
 
                         // launch MailMergeEvent if required
@@ -1377,6 +1382,12 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
             } while( !bCancel &&
                 (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
 
+            if ( xWorkDocSh.Is() && pWorkView->GetWrtShell().IsExpFieldsLocked() )
+            {
+                // Unlock ducment fields after merge complete
+                pWorkView->GetWrtShell().UnlockExpFields();
+            }
+
             if( !bCreateSingleFile )
             {
                 if( rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER )


More information about the Libreoffice-commits mailing list