[Libreoffice-commits] core.git: sw/inc sw/source
Jan-Marek Glogowski
glogow at fbihome.de
Tue Jan 5 13:48:32 PST 2016
sw/inc/dbmgr.hxx | 4 ++--
sw/source/uibase/dbui/dbmgr.cxx | 22 ++++++++++++----------
2 files changed, 14 insertions(+), 12 deletions(-)
New commits:
commit d7e0d0135ba65243fab5ee038c21290b8e74e548
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Tue Jan 5 20:53:06 2016 +0100
tdf#93565 Use multiple docs for individual PDF MM
There is actually a comment in the mail merge code:
// convert fields to text if we are exporting to PDF
// this prevents a second merge while updating the fields
// in SwXTextDocument::getRendererCount()
This was included to fix i#93714.
But the reference to 2005-05-23 #122919# in the actual code
doesn't help to understand, why the original code is needed.
I would like to get rid of it, but currently don't have time
for tests.
So the optimization to skip ConvertFieldsToText() and use a
single working document for individual document mail merge
breaks for PDF, as the working document won't contain any
fields after the first document is written.
This uses multiple working documents for PDF export again.
Change-Id: I0cf1c64da27863fc5fb4bb6c7812fed90b737d13
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 580b0f1..fb4ec0d 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -287,13 +287,13 @@ friend class SwConnectionDisposedListener_Impl;
long nStartRow, sal_uInt16 nStartingPageNo, int &targetDocPageCount, const bool bMergeShell,
const SwMergeDescriptor& rMergeDescriptor, sal_Int32 nMaxDumpDocs);
- SAL_DLLPRIVATE void ResetWorkDoc(SwDoc *pWorkDoc, SfxObjectShellLock &xWorkDocSh, SwDBManager *pOldDBManager);
+ SAL_DLLPRIVATE void CloseWorkDoc(SwDoc *pWorkDoc, SfxObjectShellLock &xWorkDocSh, SwDBManager *pOldDBManager);
SAL_DLLPRIVATE void FreezeLayouts(SwWrtShell *pTargetShell, bool freeze);
SAL_DLLPRIVATE void FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pWorkView, SwDoc *pTargetDoc,
SwWrtShell *pTargetShell, bool bCreateSingleFile, bool bPrinter,
- SwDoc *pWorkDoc, SwDBManager *pOldDBManager);
+ SwDoc *pWorkDoc, SwDBManager *pOldDBManager, const bool bIsPDFeport);
SAL_DLLPRIVATE bool SavePrintDoc(SfxObjectShellRef xTargetDocShell, SwView *pTargetView,
const SwMergeDescriptor &rMergeDescriptor,
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 6fcd7b5..ab1544c 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -974,6 +974,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
const OUString* pStoreToFilterOptions = nullptr;
CreateStoreToFilter(pStoreToFilter, pStoreToFilterOptions, pSourceDocSh, bEMail, rMergeDescriptor);
+ const bool bIsPDFeport = pStoreToFilter && pStoreToFilter->GetFilterName() == "writer_pdf_Export";
bCancel = false;
@@ -1060,7 +1061,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
// Create a copy of the source document and work with that one instead of the source.
// If we're not in the single file mode (which requires modifying the document for the merging),
// it is enough to do this just once.
- if( 1 == nDocNo || bCreateSingleFile )
+ if( 1 == nDocNo || bCreateSingleFile || bIsPDFeport )
CreateWorkDoc(xWorkDocSh, pWorkView, pWorkDoc, pOldDBManager, pSourceDocSh, nMaxDumpDocs, nDocNo);
SwWrtShell &rWorkShell = pWorkView->GetWrtShell();
@@ -1121,7 +1122,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
//convert fields to text if we are exporting to PDF
//this prevents a second merge while updating the fields in SwXTextDocument::getRendererCount()
- if( pStoreToFilter && pStoreToFilter->GetFilterName() == "writer_pdf_Export")
+ if( bIsPDFeport )
rWorkShell.ConvertFieldsToText();
xWorkDocSh->DoSaveAs(*pDstMed);
xWorkDocSh->DoSaveCompleted(pDstMed);
@@ -1210,9 +1211,9 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
}
}
}
- if( bCreateSingleFile )
+ if( bCreateSingleFile || bIsPDFeport )
{
- ResetWorkDoc(pWorkDoc, xWorkDocSh, pOldDBManager);
+ CloseWorkDoc(pWorkDoc, xWorkDocSh, pOldDBManager);
}
}
}
@@ -1230,7 +1231,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
FinishMailMergeFile(xWorkDocSh, pWorkView, pTargetDoc, pTargetShell, bCreateSingleFile, rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER,
- pWorkDoc, pOldDBManager);
+ pWorkDoc, pOldDBManager, bIsPDFeport);
pProgressDlg.disposeAndClear();
@@ -1577,7 +1578,7 @@ void SwDBManager::MergeSingleFiles(SwDoc *pWorkDoc, SwWrtShell &rWorkShell, SwWr
}
}
-void SwDBManager::ResetWorkDoc(SwDoc *pWorkDoc, SfxObjectShellLock &xWorkDocSh, SwDBManager *pOldDBManager)
+void SwDBManager::CloseWorkDoc(SwDoc *pWorkDoc, SfxObjectShellLock &xWorkDocSh, SwDBManager *pOldDBManager)
{
pWorkDoc->SetDBManager( pOldDBManager );
xWorkDocSh->DoClose();
@@ -1596,7 +1597,7 @@ void SwDBManager::FreezeLayouts(SwWrtShell *pTargetShell, bool freeze)
void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pWorkView, SwDoc *pTargetDoc,
SwWrtShell *pTargetShell, bool bCreateSingleFile, bool bPrinter,
- SwDoc *pWorkDoc, SwDBManager *pOldDBManager)
+ SwDoc *pWorkDoc, SwDBManager *pOldDBManager, const bool bIsPDFeport)
{
if ( xWorkDocSh.Is() && pWorkView->GetWrtShell().IsExpFieldsLocked() )
{
@@ -1604,9 +1605,9 @@ void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pW
pWorkView->GetWrtShell().UnlockExpFields();
}
- if(!bCreateSingleFile)
+ if( !bCreateSingleFile )
{
- if(bPrinter)
+ if( bPrinter )
{
Printer::FinishPrintJob( pWorkView->GetPrinterController() );
#if ENABLE_CUPS && !defined(MACOSX)
@@ -1614,7 +1615,8 @@ void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pW
#endif
}
- ResetWorkDoc(pWorkDoc, xWorkDocSh, pOldDBManager);
+ if( !bIsPDFeport )
+ CloseWorkDoc(pWorkDoc, xWorkDocSh, pOldDBManager);
}
if( bCreateSingleFile )
More information about the Libreoffice-commits
mailing list