[Libreoffice-commits] core.git: Branch 'libreoffice-5-1' - sw/source

Jan-Marek Glogowski glogow at fbihome.de
Thu Jan 7 06:13:37 PST 2016


 sw/source/uibase/dbui/dbmgr.cxx |   15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

New commits:
commit dcae0a5dba5aadc1e89828518102947f749db10e
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.
    
    (cherry picked from commit d7e0d0135ba65243fab5ee038c21290b8e74e548)
    
    Conflicts:
    	sw/inc/dbmgr.hxx
    	sw/source/uibase/dbui/dbmgr.cxx
    
    Change-Id: I0cf1c64da27863fc5fb4bb6c7812fed90b737d13
    Reviewed-on: https://gerrit.libreoffice.org/21136
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 0c0a7c7..3932b11 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -991,6 +991,8 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                         pStoreToFilterOptions = &rMergeDescriptor.sSaveToFilterOptions;
                 }
             }
+            const bool bIsPDFeport = pStoreToFilter && pStoreToFilter->GetFilterName() == "writer_pdf_Export";
+
             bCancel = false;
 
             // in case of creating a single resulting file this has to be created here
@@ -1176,7 +1178,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 )
                         {
                             assert( !xWorkDocSh.Is());
                             // copy the source document
@@ -1336,7 +1338,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);
@@ -1425,7 +1427,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                                 }
                             }
                         }
-                        if( bCreateSingleFile )
+                        if( bCreateSingleFile || bIsPDFeport )
                         {
                             pWorkDoc->SetDBManager( pOldDBManager );
                             xWorkDocSh->DoClose();
@@ -1462,8 +1464,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                     psp::PrinterInfoManager::get().flushBatchPrint();
 #endif
                 }
-                pWorkDoc->SetDBManager( pOldDBManager );
-                xWorkDocSh->DoClose();
+                if( !bIsPDFeport )
+                {
+                    pWorkDoc->SetDBManager( pOldDBManager );
+                    xWorkDocSh->DoClose();
+                }
             }
 
             if (bCreateSingleFile)


More information about the Libreoffice-commits mailing list