summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2015-08-18 14:09:19 +0300
committerKatarina Behrens <Katarina.Behrens@cib.de>2015-08-20 15:38:25 +0000
commitd0bafebbcd4a301bcca6fb74627820b251f6dce5 (patch)
tree0a9b5867b4aa9d44e6a975f3d3628afc2702ec55 /sw
parentd25971910099ca9d0c57b76a8edee3402a718704 (diff)
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@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Reviewed-by: Michael Stahl <mstahl@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@redhat.com> Tested-by: Katarina Behrens <Katarina.Behrens@cib.de>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/editsh.hxx1
-rw-r--r--sw/source/core/edit/edfld.cxx5
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx13
3 files changed, 18 insertions, 1 deletions
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index c80d81d32642..6a7d718b5ce4 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 3bc69b30c123..affe278258e7 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 922006df4cb8..f1161537206e 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 )