Kaydet (Commit) 959a5043 authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Michael Stahl

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/17857Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst cc8f8547
......@@ -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 );
......
......@@ -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 );
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment