summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2015-08-18 14:09:19 +0300
committerMichael Stahl <mstahl@redhat.com>2015-08-20 12:17:35 +0000
commit959a5043ccb4bb027e0149a56d31ebb78d5eb862 (patch)
tree67f7e4d6c828b392176913ac05da3ca21fa88a24
parentcc8f854707d751a610dac5a993f7d21a88f63cd8 (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. Change-Id: If0466ef2489d96264380b5978ef7d7cf3f545c23 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>
-rw-r--r--sw/inc/editsh.hxx1
-rw-r--r--sw/source/core/edit/edfld.cxx5
-rw-r--r--sw/source/uibase/dbui/dbmgr.cxx15
3 files changed, 20 insertions, 1 deletions
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 20efecf886ab..44d04c93a437 100644
--- a/sw/inc/editsh.hxx
+++ b/sw/inc/editsh.hxx
@@ -386,6 +386,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 4a5e60c2dae3..e4d259de962d 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 c5a3c60c8be6..a5c97013a7ba 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1199,14 +1199,21 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
pWorkDoc->getIDocumentLinksAdministration().EmbedAllLinks();
// #i69458# lock fields to prevent access to the result set while calculating layout
+ // tdf#92324: and do not unlock: keep document locked during printing to avoid
+ // ExpFields update during printing, generation of preview, etc.
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
@@ -1442,6 +1449,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 )