Kaydet (Commit) d7e0d013 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

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
üst cdd14dbd
...@@ -287,13 +287,13 @@ friend class SwConnectionDisposedListener_Impl; ...@@ -287,13 +287,13 @@ friend class SwConnectionDisposedListener_Impl;
long nStartRow, sal_uInt16 nStartingPageNo, int &targetDocPageCount, const bool bMergeShell, long nStartRow, sal_uInt16 nStartingPageNo, int &targetDocPageCount, const bool bMergeShell,
const SwMergeDescriptor& rMergeDescriptor, sal_Int32 nMaxDumpDocs); 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 FreezeLayouts(SwWrtShell *pTargetShell, bool freeze);
SAL_DLLPRIVATE void FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pWorkView, SwDoc *pTargetDoc, SAL_DLLPRIVATE void FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pWorkView, SwDoc *pTargetDoc,
SwWrtShell *pTargetShell, bool bCreateSingleFile, bool bPrinter, 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, SAL_DLLPRIVATE bool SavePrintDoc(SfxObjectShellRef xTargetDocShell, SwView *pTargetView,
const SwMergeDescriptor &rMergeDescriptor, const SwMergeDescriptor &rMergeDescriptor,
......
...@@ -974,6 +974,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, ...@@ -974,6 +974,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
const OUString* pStoreToFilterOptions = nullptr; const OUString* pStoreToFilterOptions = nullptr;
CreateStoreToFilter(pStoreToFilter, pStoreToFilterOptions, pSourceDocSh, bEMail, rMergeDescriptor); CreateStoreToFilter(pStoreToFilter, pStoreToFilterOptions, pSourceDocSh, bEMail, rMergeDescriptor);
const bool bIsPDFeport = pStoreToFilter && pStoreToFilter->GetFilterName() == "writer_pdf_Export";
bCancel = false; bCancel = false;
...@@ -1060,7 +1061,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, ...@@ -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. // 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), // 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. // 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); CreateWorkDoc(xWorkDocSh, pWorkView, pWorkDoc, pOldDBManager, pSourceDocSh, nMaxDumpDocs, nDocNo);
SwWrtShell &rWorkShell = pWorkView->GetWrtShell(); SwWrtShell &rWorkShell = pWorkView->GetWrtShell();
...@@ -1121,7 +1122,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, ...@@ -1121,7 +1122,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
//convert fields to text if we are exporting to PDF //convert fields to text if we are exporting to PDF
//this prevents a second merge while updating the fields in SwXTextDocument::getRendererCount() //this prevents a second merge while updating the fields in SwXTextDocument::getRendererCount()
if( pStoreToFilter && pStoreToFilter->GetFilterName() == "writer_pdf_Export") if( bIsPDFeport )
rWorkShell.ConvertFieldsToText(); rWorkShell.ConvertFieldsToText();
xWorkDocSh->DoSaveAs(*pDstMed); xWorkDocSh->DoSaveAs(*pDstMed);
xWorkDocSh->DoSaveCompleted(pDstMed); xWorkDocSh->DoSaveCompleted(pDstMed);
...@@ -1210,9 +1211,9 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, ...@@ -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, ...@@ -1230,7 +1231,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
(bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord())); (bSynchronizedDoc && (nStartRow != nEndRow)? ExistsNextRecord() : ToNextMergeRecord()));
FinishMailMergeFile(xWorkDocSh, pWorkView, pTargetDoc, pTargetShell, bCreateSingleFile, rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER, FinishMailMergeFile(xWorkDocSh, pWorkView, pTargetDoc, pTargetShell, bCreateSingleFile, rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER,
pWorkDoc, pOldDBManager); pWorkDoc, pOldDBManager, bIsPDFeport);
pProgressDlg.disposeAndClear(); pProgressDlg.disposeAndClear();
...@@ -1577,7 +1578,7 @@ void SwDBManager::MergeSingleFiles(SwDoc *pWorkDoc, SwWrtShell &rWorkShell, SwWr ...@@ -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 ); pWorkDoc->SetDBManager( pOldDBManager );
xWorkDocSh->DoClose(); xWorkDocSh->DoClose();
...@@ -1596,7 +1597,7 @@ void SwDBManager::FreezeLayouts(SwWrtShell *pTargetShell, bool freeze) ...@@ -1596,7 +1597,7 @@ void SwDBManager::FreezeLayouts(SwWrtShell *pTargetShell, bool freeze)
void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pWorkView, SwDoc *pTargetDoc, void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pWorkView, SwDoc *pTargetDoc,
SwWrtShell *pTargetShell, bool bCreateSingleFile, bool bPrinter, SwWrtShell *pTargetShell, bool bCreateSingleFile, bool bPrinter,
SwDoc *pWorkDoc, SwDBManager *pOldDBManager) SwDoc *pWorkDoc, SwDBManager *pOldDBManager, const bool bIsPDFeport)
{ {
if ( xWorkDocSh.Is() && pWorkView->GetWrtShell().IsExpFieldsLocked() ) if ( xWorkDocSh.Is() && pWorkView->GetWrtShell().IsExpFieldsLocked() )
{ {
...@@ -1604,9 +1605,9 @@ void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pW ...@@ -1604,9 +1605,9 @@ void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pW
pWorkView->GetWrtShell().UnlockExpFields(); pWorkView->GetWrtShell().UnlockExpFields();
} }
if(!bCreateSingleFile) if( !bCreateSingleFile )
{ {
if(bPrinter) if( bPrinter )
{ {
Printer::FinishPrintJob( pWorkView->GetPrinterController() ); Printer::FinishPrintJob( pWorkView->GetPrinterController() );
#if ENABLE_CUPS && !defined(MACOSX) #if ENABLE_CUPS && !defined(MACOSX)
...@@ -1614,7 +1615,8 @@ void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pW ...@@ -1614,7 +1615,8 @@ void SwDBManager::FinishMailMergeFile(SfxObjectShellLock &xWorkDocSh, SwView *pW
#endif #endif
} }
ResetWorkDoc(pWorkDoc, xWorkDocSh, pOldDBManager); if( !bIsPDFeport )
CloseWorkDoc(pWorkDoc, xWorkDocSh, pOldDBManager);
} }
if( bCreateSingleFile ) if( bCreateSingleFile )
......
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