[Libreoffice-commits] core.git: sw/inc sw/source
Vasily Melenchuk
vasily.melenchuk at cib.de
Thu Aug 20 05:17:59 PDT 2015
sw/inc/editsh.hxx | 1 +
sw/source/core/edit/edfld.cxx | 5 +++++
sw/source/uibase/dbui/dbmgr.cxx | 15 ++++++++++++++-
3 files changed, 20 insertions(+), 1 deletion(-)
New commits:
commit 959a5043ccb4bb027e0149a56d31ebb78d5eb862
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.
Change-Id: If0466ef2489d96264380b5978ef7d7cf3f545c23
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>
diff --git a/sw/inc/editsh.hxx b/sw/inc/editsh.hxx
index 20efecf..44d04c9 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 4a5e60c..e4d259d 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 c5a3c60..a5c9701 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 )
More information about the Libreoffice-commits
mailing list