[Libreoffice-commits] core.git: Branch 'private/jmux/libreoffice-4-1-6+backports' - 15 commits - bridges/source config_host/config_gcc.h.in configure.ac filter/source offapi/com sw/CppunitTest_sw_mailmerge.mk sw/CppunitTest_sw_ooxmlexport.mk sw/CppunitTest_sw_ooxmlimport.mk sw/CppunitTest_sw_ww8import.mk sw/inc sw/Module_sw.mk sw/qa sw/source vcl/headless

Luboš Luňák l.lunak at collabora.com
Thu Oct 30 05:21:23 PDT 2014


 bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx          |    9 
 bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx           |   51 +
 bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx         |    7 
 config_host/config_gcc.h.in                                  |   19 
 configure.ac                                                 |   34 +
 filter/source/graphicfilter/ipbm/ipbm.cxx                    |    6 
 filter/source/graphicfilter/ipcd/ipcd.cxx                    |    2 
 filter/source/graphicfilter/ipcx/ipcx.cxx                    |    2 
 filter/source/graphicfilter/iras/iras.cxx                    |    2 
 filter/source/graphicfilter/itga/itga.cxx                    |    2 
 offapi/com/sun/star/text/MailMergeType.idl                   |    9 
 sw/CppunitTest_sw_mailmerge.mk                               |   94 +++
 sw/CppunitTest_sw_ooxmlexport.mk                             |    6 
 sw/CppunitTest_sw_ooxmlimport.mk                             |    5 
 sw/CppunitTest_sw_ww8import.mk                               |    5 
 sw/Module_sw.mk                                              |    1 
 sw/inc/dbmgr.hxx                                             |   49 +
 sw/inc/doc.hxx                                               |    2 
 sw/inc/swabstdlg.hxx                                         |    2 
 sw/inc/unotbl.hxx                                            |    2 
 sw/inc/viewsh.hxx                                            |    2 
 sw/qa/extras/inc/swmodeltestbase.hxx                         |  184 ++++++
 sw/qa/extras/mailmerge/data/4_v01.ods                        |binary
 sw/qa/extras/mailmerge/data/missing-default-line-color.ott   |binary
 sw/qa/extras/mailmerge/data/multiple-page-anchored-draws.odt |binary
 sw/qa/extras/mailmerge/data/one-empty-address.ods            |binary
 sw/qa/extras/mailmerge/mailmerge.cxx                         |  100 +++
 sw/source/core/doc/docnew.cxx                                |   25 
 sw/source/core/inc/frame.hxx                                 |    2 
 sw/source/core/inc/frmtool.hxx                               |    2 
 sw/source/core/unocore/unotbl.cxx                            |    2 
 sw/source/core/view/vprint.cxx                               |    2 
 sw/source/ui/dbui/dbmgr.cxx                                  |  322 +++++------
 sw/source/ui/dbui/mailmergewizard.cxx                        |    2 
 sw/source/ui/dialog/swdlgfact.cxx                            |    4 
 sw/source/ui/dialog/swdlgfact.hxx                            |    4 
 sw/source/ui/envelp/mailmrge.cxx                             |    8 
 sw/source/ui/inc/mailmrge.hxx                                |    2 
 sw/source/ui/uno/unomailmerge.cxx                            |  176 +++---
 vcl/headless/svptext.cxx                                     |    2 
 40 files changed, 828 insertions(+), 320 deletions(-)

New commits:
commit 00434310dd3b3bd1b9b365a1a51c3bb5f69f2c91
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Fri Oct 3 18:21:08 2014 +0200

    copy default drawinglayer attributes when doing mailmerge
    
    (cherry picked from commit f4825097a98c681cc187d88cfc1f8fd82362e1e0)
    
    Conflicts:
    	sw/qa/extras/mailmerge/mailmerge.cxx
    
    Change-Id: I4c6fc31ae72d179975c65aec0b560741474d433e

diff --git a/sw/qa/extras/mailmerge/data/missing-default-line-color.ott b/sw/qa/extras/mailmerge/data/missing-default-line-color.ott
new file mode 100644
index 0000000..dad5a7b
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/missing-default-line-color.ott differ
diff --git a/sw/qa/extras/mailmerge/data/one-empty-address.ods b/sw/qa/extras/mailmerge/data/one-empty-address.ods
new file mode 100644
index 0000000..abffed9
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/one-empty-address.ods differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index 7284058..ca59513 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -71,6 +71,29 @@ DECLARE_DFLT_MAILMERGE_TEST(testMultiPageAnchoredDraws, "multiple-page-anchored-
     }
 }
 
+DECLARE_DFLT_MAILMERGE_TEST(testMissingDefaultLineColor, "missing-default-line-color.ott", "one-empty-address.ods", "one-empty-address")
+{
+    executeMailMerge();
+    // The document was created by LO version which didn't write out the default value for line color
+    // (see XMLGraphicsDefaultStyle::SetDefaults()).
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxMMComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    uno::Reference<beans::XPropertySet> xPropertySet(xDraws->getByIndex(0), uno::UNO_QUERY);
+    // Lines do not have a line color.
+    CPPUNIT_ASSERT( !xPropertySet->getPropertySetInfo()->hasPropertyByName( "LineColor" ));
+    SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxMMComponent.get());
+    CPPUNIT_ASSERT(pTxtDoc);
+    uno::Reference< lang::XMultiServiceFactory > xFact( mxMMComponent, uno::UNO_QUERY );
+    uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance( "com.sun.star.drawing.Defaults" ), uno::UNO_QUERY );
+    CPPUNIT_ASSERT( xDefaults.is());
+    uno::Reference< beans::XPropertySetInfo > xInfo( xDefaults->getPropertySetInfo());
+    CPPUNIT_ASSERT( xInfo->hasPropertyByName( "LineColor" ));
+    sal_uInt32 lineColor;
+    xDefaults->getPropertyValue( "LineColor" ) >>= lineColor;
+    // And the default value is black (wasn't copied properly by mailmerge).
+    CPPUNIT_ASSERT_EQUAL( COL_BLACK, lineColor );
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index f68fb27..7a83586 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -90,6 +90,7 @@
 #include <unochart.hxx>
 #include <fldbas.hxx>
 #include <wrtsh.hxx>
+#include <svx/xdef.hxx>
 
 #include <cmdid.h>              // for the default printer in SetJob
 
@@ -1066,6 +1067,7 @@ void SwDoc::ReplaceDefaults(const SwDoc& rSource)
         RES_PARATR_BEGIN, RES_PARATR_END-1,
         RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
         RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
+        XATTR_START, XATTR_END-1,
         0
     };
 
@@ -1074,6 +1076,11 @@ void SwDoc::ReplaceDefaults(const SwDoc& rSource)
     sal_uInt16 nRange = 0;
     while (aRangeOfDefaults[nRange] != 0)
     {
+        if( aRangeOfDefaults[nRange] == XATTR_START && ( !mpDrawModel || !mbSetDrawDefaults))
+        {
+            nRange += 2;
+            continue;
+        }
         for (sal_uInt16 nWhich = aRangeOfDefaults[nRange];
              nWhich <= aRangeOfDefaults[nRange + 1]; ++nWhich)
         {
commit cf8a3238917c7b396a066099237b05b8af69308d
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Tue Sep 30 12:49:00 2014 +0200

    SfxItemSet ranges are inclusive
    
    This used to skip the last item in the range.
    
    (cherry picked from commit 540243834390256f0a1dd968ff02860fda07edcf)
    
    Change-Id: Icf27a041f1388c8bd01568356d1009a08e5b7a7a

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 7d11718..f68fb27 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1075,7 +1075,7 @@ void SwDoc::ReplaceDefaults(const SwDoc& rSource)
     while (aRangeOfDefaults[nRange] != 0)
     {
         for (sal_uInt16 nWhich = aRangeOfDefaults[nRange];
-             nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich)
+             nWhich <= aRangeOfDefaults[nRange + 1]; ++nWhich)
         {
             const SfxPoolItem& rSourceAttr =
                 rSource.mpAttrPool->GetDefaultItem(nWhich);
commit 59189390366e997d9ab144bedadc6f2ddc99f898
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Fri Oct 3 16:40:18 2014 +0200

    long live code duplication
    
    (cherry picked from commit 105ddd124ad4cff3109d2e25c8035402446ac0db)
    
    Conflicts:
    
    	sw/source/uibase/dbui/dbmgr.cxx
    
    Change-Id: I7386c26e5ff05cec23a6cccb86ed3aa6ab715096

diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 40846c5..37cdff2 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -190,22 +190,6 @@ bool lcl_getCountFromResultSet( sal_Int32& rCount, const uno::Reference<XResultS
     }
     return false;
 }
-// copy compatibility options
-void lcl_CopyCompatibilityOptions( SwWrtShell& rSourceShell, SwWrtShell& rTargetShell)
-{
-    IDocumentSettingAccess* pIDsa = rSourceShell.getIDocumentSettingAccess();
-
-    rTargetShell.SetParaSpaceMax( pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX));
-    rTargetShell.SetParaSpaceMaxAtPages(pIDsa->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES));
-    rTargetShell.SetTabCompat( pIDsa->get(IDocumentSettingAccess::TAB_COMPAT));
-    rTargetShell.SetAddExtLeading( pIDsa->get(IDocumentSettingAccess::ADD_EXT_LEADING));
-    rTargetShell.SetUseVirDev( pIDsa->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE));
-    rTargetShell.SetAddParaSpacingToTableCells( pIDsa->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS));
-    rTargetShell.SetUseFormerLineSpacing( pIDsa->get(IDocumentSettingAccess::OLD_LINE_SPACING));
-    rTargetShell.SetUseFormerObjectPositioning( pIDsa->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS));
-    rTargetShell.SetConsiderWrapOnObjPos( pIDsa->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION));
-    rTargetShell.SetUseFormerTextWrapping( pIDsa->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING));
-}
 }
 
 class SwConnectionDisposedListener_Impl : public cppu::WeakImplHelper1
@@ -764,35 +748,6 @@ static String lcl_FindUniqueName(SwWrtShell* pTargetShell, const String& rStarti
     }while(true);
 }
 
-static void lcl_CopyDynamicDefaults( const SwDoc& rSource, SwDoc& rTarget )
-{
-    sal_uInt16 aRangeOfDefaults[] = {
-        RES_FRMATR_BEGIN, RES_FRMATR_END-1,
-        RES_CHRATR_BEGIN, RES_CHRATR_END-1,
-        RES_PARATR_BEGIN, RES_PARATR_END-1,
-        RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
-        RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
-        0
-    };
-
-    SfxItemSet aNewDefaults( rTarget.GetAttrPool(), aRangeOfDefaults );
-
-    sal_uInt16 nWhich;
-    sal_uInt16 nRange = 0;
-    while( aRangeOfDefaults[nRange] != 0)
-    {
-        for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
-        {
-            const SfxPoolItem& rSourceAttr = rSource.GetDefault( nWhich );
-            if( rSourceAttr != rTarget.GetDefault( nWhich ) )
-                aNewDefaults.Put( rSourceAttr );
-        }
-        nRange += 2;
-    }
-    if( aNewDefaults.Count() )
-        rTarget.SetDefault( aNewDefaults );
-}
-
 static void lcl_CopyFollowPageDesc(
                             SwWrtShell& rTargetShell,
                             const SwPageDesc& rSourcePageDesc,
@@ -1041,9 +996,9 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                                                 rMaster.GetFooter().IsActive();
 
                 // copy compatibility options
-                lcl_CopyCompatibilityOptions( *pSourceShell, *pTargetShell);
+                pTargetShell->GetDoc()->ReplaceCompatabilityOptions( *pSourceShell->GetDoc());
                 // #72821# copy dynamic defaults
-                lcl_CopyDynamicDefaults( *pSourceShell->GetDoc(), *pTargetShell->GetDoc() );
+                pTargetShell->GetDoc()->ReplaceDefaults( *pSourceShell->GetDoc());
 
                 lcl_CopyDocumentPorperties( xSourceDocProps, xTargetDocShell, pTargetDoc );
             }
commit 7ee0043d5bfdd54e83e3dedba77b8bc2c0002d39
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Tue Oct 7 12:18:02 2014 +0200

    use -> with pointers
    
    Change-Id: I0df4775931e8e0b289a63afd501efaaf079302fe

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 5990385..7d11718 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1247,11 +1247,11 @@ void SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNumber,
     SwPaM aInsertPam( aTargetIdx );
 
 #ifdef DBG_UTIL
-    SAL_INFO( "sw.docappend", "Pam-Nd: " << aCpyPam.GetNode( true ).GetIndex() - aCpyPam.GetNode( false ).GetIndex() + 1
-                              << " (0x" << std::hex << (int) aCpyPam.GetNode( false ).GetNodeType() << std::dec
-                              << " " << aCpyPam.GetNode( false ).GetIndex()
-                              << " - 0x" << std::hex << (int) aCpyPam.GetNode( true ).GetNodeType() << std::dec
-                              << " " << aCpyPam.GetNode( true ).GetIndex() << ")" );
+    SAL_INFO( "sw.docappend", "Pam-Nd: " << aCpyPam.GetNode( true )->GetIndex() - aCpyPam.GetNode( false )->GetIndex() + 1
+                              << " (0x" << std::hex << (int) aCpyPam.GetNode( false )->GetNodeType() << std::dec
+                              << " " << aCpyPam.GetNode( false )->GetIndex()
+                              << " - 0x" << std::hex << (int) aCpyPam.GetNode( true )->GetNodeType() << std::dec
+                              << " " << aCpyPam.GetNode( true )->GetIndex() << ")" );
 #endif
 
     this->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL );
commit 1a7455d8b5bcdde7aed1e502ff2413c573a7a271
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jul 8 13:40:12 2013 +0200

    error: comparison between pointer and integer (Clang trunk towards 3.4)
    
    ...the check in itga.cxx was useless anyway, as new[] does not return null.
    
    (cherry picked from commit b63524d269a792e20777a91e4ed7e8ceae7ff55f)
    
    Change-Id: I4de5a46e14a83ab134d0a098a62748e909dc9c00

diff --git a/filter/source/graphicfilter/ipbm/ipbm.cxx b/filter/source/graphicfilter/ipbm/ipbm.cxx
index 4de5cef..ee9feb0 100644
--- a/filter/source/graphicfilter/ipbm/ipbm.cxx
+++ b/filter/source/graphicfilter/ipbm/ipbm.cxx
@@ -102,7 +102,7 @@ sal_Bool PBMReader::ReadPBM(Graphic & rGraphic )
     {
         case 0 :
             maBmp = Bitmap( Size( mnWidth, mnHeight ), 1 );
-            if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == sal_False )
+            if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == 0 )
                 return sal_False;
             mpAcc->SetPaletteEntryCount( 2 );
             mpAcc->SetPaletteColor( 0, BitmapColor( 0xff, 0xff, 0xff ) );
@@ -117,7 +117,7 @@ sal_Bool PBMReader::ReadPBM(Graphic & rGraphic )
             else
                 maBmp = Bitmap( Size( mnWidth, mnHeight ), 8);
 
-            if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == sal_False )
+            if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == 0 )
                 return sal_False;
             mnCol = (sal_uInt16)mnMaxVal + 1;
             if ( mnCol > 256 )
@@ -132,7 +132,7 @@ sal_Bool PBMReader::ReadPBM(Graphic & rGraphic )
             break;
         case 2 :
             maBmp = Bitmap( Size( mnWidth, mnHeight ), 24 );
-            if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == sal_False )
+            if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == 0 )
                 return sal_False;
             break;
     }
diff --git a/filter/source/graphicfilter/ipcd/ipcd.cxx b/filter/source/graphicfilter/ipcd/ipcd.cxx
index 57178d8..b5be77d 100644
--- a/filter/source/graphicfilter/ipcd/ipcd.cxx
+++ b/filter/source/graphicfilter/ipcd/ipcd.cxx
@@ -151,7 +151,7 @@ sal_Bool PCDReader::ReadPCD( Graphic & rGraphic, FilterConfigItem* pConfigItem )
             nBMPHeight = nWidth;
         }
         aBmp = Bitmap( Size( nBMPWidth, nBMPHeight ), 24 );
-        if ( ( mpAcc = aBmp.AcquireWriteAccess() ) == sal_False )
+        if ( ( mpAcc = aBmp.AcquireWriteAccess() ) == 0 )
             return sal_False;
 
         ReadImage( 5 ,65 );
diff --git a/filter/source/graphicfilter/ipcx/ipcx.cxx b/filter/source/graphicfilter/ipcx/ipcx.cxx
index 3738180..54579ff 100644
--- a/filter/source/graphicfilter/ipcx/ipcx.cxx
+++ b/filter/source/graphicfilter/ipcx/ipcx.cxx
@@ -100,7 +100,7 @@ sal_Bool PCXReader::ReadPCX(Graphic & rGraphic)
     if ( nStatus )
     {
         aBmp = Bitmap( Size( nWidth, nHeight ), nDestBitsPerPixel );
-        if ( ( pAcc = aBmp.AcquireWriteAccess() ) == sal_False )
+        if ( ( pAcc = aBmp.AcquireWriteAccess() ) == 0 )
             return sal_False;
 
         if ( nDestBitsPerPixel <= 8 )
diff --git a/filter/source/graphicfilter/iras/iras.cxx b/filter/source/graphicfilter/iras/iras.cxx
index 8add8e8..a1771e1 100644
--- a/filter/source/graphicfilter/iras/iras.cxx
+++ b/filter/source/graphicfilter/iras/iras.cxx
@@ -98,7 +98,7 @@ sal_Bool RASReader::ReadRAS(Graphic & rGraphic)
         return sal_False;
 
     maBmp = Bitmap( Size( mnWidth, mnHeight ), mnDstBitsPerPix );
-    if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == sal_False )
+    if ( ( mpAcc = maBmp.AcquireWriteAccess() ) == 0 )
         return sal_False;
 
     if ( mnDstBitsPerPix <= 8 )     // paletten bildchen
diff --git a/filter/source/graphicfilter/itga/itga.cxx b/filter/source/graphicfilter/itga/itga.cxx
index 06220e3..8672029 100644
--- a/filter/source/graphicfilter/itga/itga.cxx
+++ b/filter/source/graphicfilter/itga/itga.cxx
@@ -732,8 +732,6 @@ sal_Bool TGAReader::ImplReadPalette()
             mpFileHeader->nColorMapEntrySize = 0x3f;    // patch for the following switch routine
         }
         mpColorMap = new sal_uInt32[ nColors ];     // we will always index dwords
-        if ( mpColorMap == sal_False )
-            return sal_False;                       // out of memory %&!$&/!"�$
 
         switch( mpFileHeader->nColorMapEntrySize )
         {
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index 2b65746..fb6b70b 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -172,7 +172,7 @@ void SvpGlyphPeer::RemovingFont( ServerFont& )
 
 void SvpGlyphPeer::RemovingGlyph( ServerFont&, GlyphData& rGlyphData, int /*nGlyphIndex*/ )
 {
-    if( rGlyphData.ExtDataRef().mpData != Format::NONE )
+    if( rGlyphData.ExtDataRef().mpData != NULL )
     {
         // release the glyph related resources
         DBG_ASSERT( (rGlyphData.ExtDataRef().meInfo <= Format::MAX), "SVP::RG() invalid alpha format" );
commit 34495ac084dff2d30dff2d6edc280972982a9476
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Mon Jul 8 16:54:27 2013 +0200

    error: friend declaration specifying a default argument must be a definition
    
    ...(Clang trunk towards 3.4); this appears to be specific to C++11, which added at
    the end of 8.3.6/4 [dcl.fct.default]:  "If a friend declaration specifies a default
    argument expression, that declaration shall be a definition and shall be the only
    declaration of the function or function template in the translation unit."
    
    (cherry picked from commit 39f42b0b03489459540404dd218c38709853c021)
    
    Change-Id: I750c60a2206d7af41322ebb31aa6deca2491067f

diff --git a/sw/inc/unotbl.hxx b/sw/inc/unotbl.hxx
index a8cc7b9..38aa412 100644
--- a/sw/inc/unotbl.hxx
+++ b/sw/inc/unotbl.hxx
@@ -71,7 +71,7 @@ class SwXCell : public SwXCellBaseClass,
     public SwClient
 {
     friend void   sw_setString( SwXCell &rCell, const OUString &rTxt,
-                                 sal_Bool bKeepNumberFmt = sal_False );
+                                 sal_Bool bKeepNumberFmt );
     friend double sw_getValue( SwXCell &rCell );
     friend void   sw_setValue( SwXCell &rCell, double nVal );
 
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 72d7c48..92c5f0e 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -109,7 +109,7 @@ class SW_DLLPUBLIC ViewShell : public Ring
 
 
     // Set SwVisArea in order to enable clean formatting before printing.
-    friend void SetSwVisArea( ViewShell *pSh, const SwRect &, sal_Bool bPDFExport = sal_False );
+    friend void SetSwVisArea( ViewShell *pSh, const SwRect & );
 
     static BitmapEx*    mpReplaceBmp;    ///< replaced display of still loaded images
     static BitmapEx*    mpErrorBmp;      ///< error display of missed images
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index f93ae67..eeb84d8 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -234,7 +234,7 @@ class SwFrm: public SwClient, public SfxBroadcaster
     friend class SwLooping;
 
     // voids lower during creation of a column
-    friend SwFrm *SaveCntnt( SwLayoutFrm *, SwFrm* pStart = NULL );
+    friend SwFrm *SaveCntnt( SwLayoutFrm *, SwFrm* pStart );
     friend void   RestoreCntnt( SwFrm *, SwLayoutFrm *, SwFrm *pSibling, bool bGrow );
 
 #ifdef DBG_UTIL
diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx
index fc2e763..45b63bf 100644
--- a/sw/source/core/inc/frmtool.hxx
+++ b/sw/source/core/inc/frmtool.hxx
@@ -70,7 +70,7 @@ SwFlyFrm *GetFlyFromMarked( const SdrMarkList *pLst, ViewShell *pSh );
 
 sal_uLong SqRt( BigInt nX );
 
-SwFrm *SaveCntnt( SwLayoutFrm *pLay, SwFrm *pStart );
+SwFrm *SaveCntnt( SwLayoutFrm *pLay, SwFrm *pStart = NULL );
 void RestoreCntnt( SwFrm *pSav, SwLayoutFrm *pParent, SwFrm *pSibling, bool bGrow );
 
 // Get CntntNodes, create CntntFrms, and add them to LayFrm.
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 3fd2350..73c748b 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -692,7 +692,7 @@ static inline OUString lcl_getString( SwXCell &rCell )
 
 /*  non UNO function call to set string in SwXCell */
 void sw_setString( SwXCell &rCell, const OUString &rTxt,
-        sal_Bool bKeepNumberFmt )
+        sal_Bool bKeepNumberFmt = sal_False )
 {
     if(rCell.IsValid())
     {
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index d582d10..b7e4ee0 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -172,7 +172,7 @@ void SwPaintQueue::Remove( ViewShell *pSh )
     }
 }
 
-void SetSwVisArea( ViewShell *pSh, const SwRect &rRect, sal_Bool /*bPDFExport*/ )
+void SetSwVisArea( ViewShell *pSh, const SwRect &rRect )
 {
     OSL_ENSURE( !pSh->GetWin(), "Drucken mit Window?" );
     pSh->maVisArea = rRect;
commit f897fddfcb59d42a4075386ce0a340a5377c0163
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jun 20 15:58:58 2013 +0200

    ...and similarly for __cxa_allocate_exception and __cxa_throw
    
    Conflicts:
    	configure.ac
    
    (cherry picked from commit c17f01753ce94e9f57d6e4a2763152240fbcd50a)
    
    Change-Id: I87ae299aac97180f0587c553d85b051decca155c

diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
index 8229ce8..18a6eff 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
@@ -250,7 +250,7 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
             Reference< XInterface >() );
     }
 
-    pCppExc = __cxa_allocate_exception( pTypeDescr->nSize );
+    pCppExc = __cxxabiv1::__cxa_allocate_exception( pTypeDescr->nSize );
     ::uno_copyAndConvertData( pCppExc, pUnoExc->pData, pTypeDescr, pUno2Cpp );
 
     // destruct uno exception
@@ -269,7 +269,7 @@ void raiseException( uno_Any * pUnoExc, uno_Mapping * pUno2Cpp )
     }
     }
 
-    __cxa_throw( pCppExc, rtti, deleteException );
+    __cxxabiv1::__cxa_throw( pCppExc, rtti, deleteException );
 }
 
 //==================================================================================================
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
index f3f43e5..61702b7 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
@@ -80,27 +80,30 @@ struct __cxa_eh_globals
 // Therefore, provide a declaration here for old GCC (libstdc++, really) version
 // that returns a void pointer, and in the code calling it always cast to the
 // above fake definition of CPPU_CURRENT_NAMESPACE::__cxa_eh_globals (which
-// hopefully keeps matching the real definition in libstdc++):
+// hopefully keeps matching the real definition in libstdc++); similarly for
+// __cxa_allocate_exception and __cxa_throw, though they do not have the
+// additional problem of an incompletely declared return type:
+
 #if !HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS
-namespace __cxxabiv1 { extern "C" void * __cxa_get_globals () throw(); }
+namespace __cxxabiv1 { extern "C" void * __cxa_get_globals() throw(); }
 #endif
 
-namespace CPPU_CURRENT_NAMESPACE
-{
+#if !HAVE_GCC_CXXABI_H_CXA_ALLOCATE_EXCEPTION
+namespace __cxxabiv1 {
+extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw();
+}
+#endif
 
-// The following are in cxxabi.h since GCC 4.7 (they are wrapped in
-// CPPU_CURRENT_NAMESPACE here as different GCC versions have slightly different
-// declarations for them, e.g., with or without throw() specification, so would
-// complain about redeclarations of these somewhat implicitly declared
-// functions):
-#if __GNUC__ == 4 && __GNUC_MINOR__ <= 6
-extern "C" void *__cxa_allocate_exception(
-    std::size_t thrown_size ) throw();
-extern "C" void __cxa_throw (
-    void *thrown_exception, void *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
+#if !HAVE_GCC_CXXABI_H_CXA_THROW
+namespace __cxxabiv1 {
+extern "C" void __cxa_throw(
+    void * thrown_exception, void * tinfo, void (* dest)(void *))
+    __attribute__((noreturn));
+}
 #endif
 
-// -----
+namespace CPPU_CURRENT_NAMESPACE
+{
 
 //==================================================================================================
 void raiseException(
diff --git a/config_host/config_gcc.h.in b/config_host/config_gcc.h.in
index 4376877..c957179 100644
--- a/config_host/config_gcc.h.in
+++ b/config_host/config_gcc.h.in
@@ -10,7 +10,9 @@
 #ifndef CONFIG_GCC_H
 #define CONFIG_GCC_H
 
+#define HAVE_GCC_CXXABI_H_CXA_ALLOCATE_EXCEPTION 0
 #define HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS 0
+#define HAVE_GCC_CXXABI_H_CXA_THROW 0
 
 #endif
 
diff --git a/configure.ac b/configure.ac
index 13fe709..4e66ef6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5569,6 +5569,17 @@ if test "$GCC" = "yes"; then
         ], [AC_MSG_RESULT([no])])
     CFLAGS=$save_CFLAGS
 
+    AC_MSG_CHECKING([whether $CXX declares __cxa_allocate_exception in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cxxabi.h>
+            void * f() { return __cxxabiv1::__cxa_allocate_exception(0); }
+        ])], [
+            AC_DEFINE([HAVE_GCC_CXXABI_H_CXA_ALLOCATE_EXCEPTION],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
     AC_MSG_CHECKING([whether $CXX declares __cxa_get_globals in cxxabi.h])
     AC_LANG_PUSH([C++])
     AC_COMPILE_IFELSE([AC_LANG_SOURCE([
@@ -5580,6 +5591,17 @@ if test "$GCC" = "yes"; then
         ], [AC_MSG_RESULT([no])])
     AC_LANG_POP([C++])
 
+    AC_MSG_CHECKING([whether $CXX declares __cxa_throw in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cxxabi.h>
+            void f() { __cxxabiv1::__cxa_throw(0, 0, 0); }
+        ])], [
+            AC_DEFINE([HAVE_GCC_CXXABI_H_CXA_THROW],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #if __GNUC__ == 4 && __GNUC_MINOR__ == 7 && (__GNUC_PATCHLEVEL__ == 0 || __GNUC_PATCHLEVEL__ == 1)
 #else
commit 6733feaba76ced9a533cd38e930dbbb1623ef81c
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Thu Jun 20 13:57:45 2013 +0200

    Clean up declaration of __cxa_get_globals
    
    At least Clang trunk towards 3.4 now rejects incompatible declarations of the
    same extern "C" function in different namespaces, so that trick of getting at
    the function that is exported by libstdc++ but only rudimentarily if at all
    exposed in cxxabi.h no longer worked.
    
    TODO: This change should be reflected in any other bridges where it is relevant,
    too.
    
    Conflicts:
    	configure.ac
    
    (cherry picked from commit 5ba3d1740b03efa394b2d2bf34fb8a8d3db2331d)
    
    Change-Id: Ie3ccbdb7d75cc98636d02c0435958532620724f2

diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
index ea38f29..8229ce8 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/except.cxx
@@ -22,11 +22,6 @@
 #include <string.h>
 #include <dlfcn.h>
 
-#include <cxxabi.h>
-#ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h
-#define _GLIBCXX_CDTOR_CALLABI
-#endif
-
 #include <boost/unordered_map.hpp>
 
 #include <rtl/strbuf.hxx>
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
index c305197..f3f43e5 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/share.hxx
@@ -17,12 +17,20 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "uno/mapping.h"
+#include "sal/config.h"
 
 #include <typeinfo>
 #include <exception>
 #include <cstddef>
 
+#include <cxxabi.h>
+#ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h
+#define _GLIBCXX_CDTOR_CALLABI
+#endif
+
+#include "config_gcc.h"
+#include "uno/mapping.h"
+
 namespace CPPU_CURRENT_NAMESPACE
 {
 
@@ -65,7 +73,17 @@ struct __cxa_eh_globals
 
 }
 
-extern "C" CPPU_CURRENT_NAMESPACE::__cxa_eh_globals *__cxa_get_globals () throw();
+// __cxa_get_globals is exported from libstdc++ since GCC 3.4.0 (CXXABI_1.3),
+// but it is only declared in cxxabi.h (in namespace __cxxabiv1) since
+// GCC 4.7.0.  It returns a pointer to a struct __cxa_eh_globals, but that
+// struct is only incompletely declared even in the GCC 4.7.0 cxxabi.h.
+// Therefore, provide a declaration here for old GCC (libstdc++, really) version
+// that returns a void pointer, and in the code calling it always cast to the
+// above fake definition of CPPU_CURRENT_NAMESPACE::__cxa_eh_globals (which
+// hopefully keeps matching the real definition in libstdc++):
+#if !HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS
+namespace __cxxabiv1 { extern "C" void * __cxa_get_globals () throw(); }
+#endif
 
 namespace CPPU_CURRENT_NAMESPACE
 {
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
index cbf45bb..08c797c 100644
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx
@@ -289,8 +289,11 @@ static void cpp_call(
     }
      catch (...)
      {
-          // fill uno exception
-        fillUnoException( __cxa_get_globals()->caughtExceptions, *ppUnoExc, pThis->getBridge()->getCpp2Uno() );
+         // fill uno exception
+         fillUnoException(
+             reinterpret_cast< CPPU_CURRENT_NAMESPACE::__cxa_eh_globals * >(
+                 __cxxabiv1::__cxa_get_globals())->caughtExceptions,
+             *ppUnoExc, pThis->getBridge()->getCpp2Uno());
 
         // temporary params
         for ( ; nTempIndizes--; )
diff --git a/config_host/config_gcc.h.in b/config_host/config_gcc.h.in
new file mode 100644
index 0000000..4376877
--- /dev/null
+++ b/config_host/config_gcc.h.in
@@ -0,0 +1,17 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#ifndef CONFIG_GCC_H
+#define CONFIG_GCC_H
+
+#define HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS 0
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/configure.ac b/configure.ac
index a9a009d..13fe709 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5569,6 +5569,17 @@ if test "$GCC" = "yes"; then
         ], [AC_MSG_RESULT([no])])
     CFLAGS=$save_CFLAGS
 
+    AC_MSG_CHECKING([whether $CXX declares __cxa_get_globals in cxxabi.h])
+    AC_LANG_PUSH([C++])
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([
+            #include <cxxabi.h>
+            void * f() { return __cxxabiv1::__cxa_get_globals(); }
+        ])], [
+            AC_DEFINE([HAVE_GCC_CXXABI_H_CXA_GET_GLOBALS],[1])
+            AC_MSG_RESULT([yes])
+        ], [AC_MSG_RESULT([no])])
+    AC_LANG_POP([C++])
+
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #if __GNUC__ == 4 && __GNUC_MINOR__ == 7 && (__GNUC_PATCHLEVEL__ == 0 || __GNUC_PATCHLEVEL__ == 1)
 #else
@@ -12034,6 +12045,7 @@ AC_CONFIG_FILES([config_host.mk Makefile lo.xcent instsetoo_native/util/openoffi
 AC_CONFIG_HEADERS([config_host/config_buildid.h])
 AC_CONFIG_HEADERS([config_host/config_clang.h])
 AC_CONFIG_HEADERS([config_host/config_features.h])
+AC_CONFIG_HEADERS([config_host/config_gcc.h])
 AC_CONFIG_HEADERS([config_host/config_global.h])
 AC_CONFIG_HEADERS([config_host/config_graphite.h])
 AC_CONFIG_HEADERS([config_host/config_lgpl.h])
commit 2759932eb0bfb00aa40ca92d4b7d786b905b632f
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Oct 1 13:02:57 2014 +0200

    blind fix for windows build
    
    Change-Id: I8c3d8ccccb039bc82b23d74b41ca4254f50d5c84
    (cherry picked from commit 99bb7d664ef6c809ff6478fe2335c8a4a00e141b)

diff --git a/sw/CppunitTest_sw_mailmerge.mk b/sw/CppunitTest_sw_mailmerge.mk
index 274f4f2..c7a38fb 100644
--- a/sw/CppunitTest_sw_mailmerge.mk
+++ b/sw/CppunitTest_sw_mailmerge.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sw_mailmerge, \
 $(eval $(call gb_CppunitTest_use_libraries,sw_mailmerge, \
     comphelper \
     cppu \
+    cppuhelper \
     sal \
     sw \
     test \
commit a400f2c81131ea2ca6350efe55d2007c5f34c56d
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 1 11:31:35 2014 +0200

    loplugin:implicitboolconversion
    
    Change-Id: Ia63460949a3ba58f0394f5b94e0d906ca7849710
    (cherry picked from commit a5824fa97c7300faca3b09fe0922c9f319b3c49b)

diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index bf550a3..7284058 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -6,6 +6,10 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include <sal/config.h>
+
+#include <set>
+
 #include <swmodeltestbase.hxx>
 
 #if !defined(MACOSX) && !defined(WNT)
@@ -49,8 +53,7 @@ DECLARE_DFLT_MAILMERGE_TEST(testMultiPageAnchoredDraws, "multiple-page-anchored-
     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
     CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
 
-    // bitset of all page numbers
-    char nPageSum = 0xFF;
+    std::set<sal_uInt16> pages;
     uno::Reference<beans::XPropertySet> xPropertySet;
 
     for (sal_Int32 i = 0; i < xDraws->getCount(); i++)
@@ -63,11 +66,9 @@ DECLARE_DFLT_MAILMERGE_TEST(testMultiPageAnchoredDraws, "multiple-page-anchored-
         CPPUNIT_ASSERT_EQUAL( text::TextContentAnchorType_AT_PAGE, nAnchorType );
 
         xPropertySet->getPropertyValue( OUSTRING_FROM_PROP( UNO_NAME_ANCHOR_PAGE_NO ) ) >>= nAnchorPageNo;
-        nPageSum &= !nAnchorPageNo;
+        // are all shapes are on different page numbers?
+        CPPUNIT_ASSERT(pages.insert(nAnchorPageNo).second);
     }
-
-    // are all shapes are on different page numbers?
-    CPPUNIT_ASSERT_EQUAL(char(0), nPageSum);
 }
 
 #endif
commit 087b72493c775f0b27fa11cff3ee952e14db5241
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Tue Sep 23 10:00:13 2014 +0200

    MM: first unit test and infrastructure
    
    Extendes SwModelTestBase with mail merge functions and a declaration
    of the DECLARE_MAILMERGE_TEST macro and uses it in a first test.
    As most tests it's registered as a slow test run by 'make check'.
    
    The broken MM used to drop the leading empty pages, which resulted
    in a document with 4 pages and the two page bound draws merged
    per single page.
    
    Tests the MM result for page count (eight) and each draw anchor to
    be on a different page.
    
    (cherry picked from commit d10f6d49b77dcf955629901937d8d5e3a2976a6c)
    
    Conflicts:
    
    	sw/Module_sw.mk
    	sw/qa/extras/inc/swmodeltestbase.hxx
    	sw/qa/extras/mailmerge/mailmerge.cxx
    	sw/CppunitTest_sw_mailmerge.mk
    
    Change-Id: Iab17f5844e68221d48cb89863323bcfe4c8ae0d2

diff --git a/sw/CppunitTest_sw_mailmerge.mk b/sw/CppunitTest_sw_mailmerge.mk
new file mode 100644
index 0000000..274f4f2
--- /dev/null
+++ b/sw/CppunitTest_sw_mailmerge.mk
@@ -0,0 +1,93 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_mailmerge))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_mailmerge, \
+    sw/qa/extras/mailmerge/mailmerge \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_mailmerge, \
+    comphelper \
+    cppu \
+    sal \
+    sw \
+    test \
+    tl \
+    unotest \
+    utl \
+    $(gb_UWINAPI) \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_mailmerge, \
+    boost_headers \
+    libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_mailmerge,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_use_components,sw_mailmerge, \
+    basic/util/sb \
+    comphelper/util/comphelp \
+    configmgr/source/configmgr \
+    connectivity/source/cpool/dbpool2 \
+    connectivity/source/drivers/calc/calc \
+    connectivity/source/manager/sdbc2 \
+    dbaccess/source/filter/xml/dbaxml \
+    dbaccess/util/dba \
+    embeddedobj/util/embobj \
+    fileaccess/source/fileacc \
+    filter/source/config/cache/filterconfig1 \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    lingucomponent/source/languageguessing/guesslang \
+    linguistic/source/lng \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    sc/util/sc \
+    sfx2/util/sfx \
+    sot/util/sot \
+    svl/source/fsstor/fsstorage \
+    svl/util/svl \
+    svtools/util/svt \
+    sw/util/sw \
+    sw/util/swd \
+    toolkit/util/tk \
+    ucb/source/core/ucb1 \
+    ucb/source/ucp/file/ucpfile1 \
+    ucb/source/ucp/tdoc/ucptdoc1 \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+    uui/util/uui \
+    xmloff/util/xo \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_mailmerge))
+$(eval $(call gb_CppunitTest_use_filter_configuration,sw_mailmerge))
+$(eval $(call gb_CppunitTest_use_unittest_configuration,sw_mailmerge))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_mailmerge))
+#$(eval $(call gb_CppunitTest_use_vcl,sw_mailmerge))
+
+$(eval $(call gb_CppunitTest_set_include,sw_mailmerge,\
+    -I$(SRCDIR)/sw/inc \
+    -I$(SRCDIR)/sw/source/core/inc \
+    -I$(SRCDIR)/sw/qa/extras/inc \
+    -I$(SRCDIR)/sw/source/ui/inc \
+    $$(INCLUDE) \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/CppunitTest_sw_ooxmlexport.mk b/sw/CppunitTest_sw_ooxmlexport.mk
index 2e90bec..1de3357 100644
--- a/sw/CppunitTest_sw_ooxmlexport.mk
+++ b/sw/CppunitTest_sw_ooxmlexport.mk
@@ -18,15 +18,15 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sw_ooxmlexport, \
 $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlexport, \
     comphelper \
     cppu \
-	cppuhelper \
+    cppuhelper \
     sal \
     sw \
     test \
-	tl \
+    tl \
     unotest \
     utl \
     vcl \
-	$(gb_UWINAPI) \
+    $(gb_UWINAPI) \
 ))
 
 $(eval $(call gb_CppunitTest_use_externals,sw_ooxmlexport,\
diff --git a/sw/CppunitTest_sw_ooxmlimport.mk b/sw/CppunitTest_sw_ooxmlimport.mk
index b558073..6495c67 100644
--- a/sw/CppunitTest_sw_ooxmlimport.mk
+++ b/sw/CppunitTest_sw_ooxmlimport.mk
@@ -20,11 +20,12 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ooxmlimport, \
     cppu \
     cppuhelper \
     sal \
+    sw \
     test \
+    tl \
     unotest \
-    sw \
     vcl \
-	$(gb_UWINAPI) \
+    $(gb_UWINAPI) \
 ))
 
 $(eval $(call gb_CppunitTest_use_externals,sw_ooxmlimport,\
diff --git a/sw/CppunitTest_sw_ww8import.mk b/sw/CppunitTest_sw_ww8import.mk
index 1cb3425..0c8cdb0 100644
--- a/sw/CppunitTest_sw_ww8import.mk
+++ b/sw/CppunitTest_sw_ww8import.mk
@@ -20,10 +20,11 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_ww8import, \
     cppu \
     cppuhelper \
     sal \
+    sw \
     test \
+    tl \
     unotest \
-    sw \
-	$(gb_UWINAPI) \
+    $(gb_UWINAPI) \
 ))
 
 $(eval $(call gb_CppunitTest_use_externals,sw_ww8import,\
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 202c67c..828ed35 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -56,6 +56,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
     CppunitTest_sw_rtfimport \
     CppunitTest_sw_odfexport \
     CppunitTest_sw_odfimport \
+    CppunitTest_sw_mailmerge \
 ))
 
 ifneq ($(DISABLE_CVE_TESTS),TRUE)
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 727580d..4645bbf 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -16,12 +16,19 @@
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
 #include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/DatabaseContext.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/text/MailMergeType.hpp>
 
 #include <test/bootstrapfixture.hxx>
 #include <unotest/macros_test.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <comphelper/processfactory.hxx>
 #include <unotools/tempfile.hxx>
+#include <dbmgr.hxx>
+#include <unoprnms.hxx>
 
 #include <unotxdoc.hxx>
 #include <docsh.hxx>
@@ -35,12 +42,40 @@ using namespace com::sun::star;
 
 #define DEFAULT_STYLE "Default Style"
 
+#define DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, BaseClass) \
+    class TestName : public BaseClass { \
+    protected: \
+        virtual OUString getTestName() SAL_OVERRIDE { return OUString::createFromAscii(#TestName); } \
+    public: \
+        CPPUNIT_TEST_SUITE(TestName); \
+        CPPUNIT_TEST(MailMerge); \
+        CPPUNIT_TEST_SUITE_END(); \
+    \
+        void MailMerge() { \
+            executeMailMergeTest(filename, datasource, tablename); \
+        } \
+        void verify() SAL_OVERRIDE; \
+    }; \
+    CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
+    void TestName::verify()
+
+/**
+ * Maps database URIs to the registered database names for quick lookups
+ */
+typedef std::map<OUString, OUString> DBuriMap;
+DBuriMap aDBuriMap;
+
 /// Base class for filter tests loading or roundtriping a document, then asserting the document model.
 class SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
 {
+protected:
+    virtual OUString getTestName() { return OUString(); }
+
 public:
-    SwModelTestBase()
+    SwModelTestBase(const char* pTestDocumentPath = "")
         : mpXmlBuffer(0)
+        , mpTestDocumentPath(pTestDocumentPath)
+        , nCurOutputType(0)
     {
     }
 
@@ -59,10 +94,61 @@ public:
     {
         if (mxComponent.is())
             mxComponent->dispose();
+        // There is a reference cleanup error (fixed in master), so this
+        // explicitly releases the XJob reference to prevent the otherwise
+        // resulting "pure virtual" segfault.
+        if (mxJob.is())
+            mxJob.set( NULL );
+        if (mxMMComponent.is())
+        {
+            if (nCurOutputType == text::MailMergeType::SHELL)
+            {
+                SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxMMComponent.get());
+                pTxtDoc->GetDocShell()->DoClose();
+            }
+            else
+                mxMMComponent->dispose();
+        }
 
         test::BootstrapFixture::tearDown();
     }
 
+protected:
+
+    /**
+     * Helper func used by each unit test to test the 'mail merge' code.
+     *
+     * Registers the data source, loads the original file as reference,
+     * initializes the mail merge job and its default argument sequence.
+     *
+     * The 'verify' method actually has to execute the mail merge by
+     * calling executeMailMerge() after modifying the job arguments.
+     */
+    void executeMailMergeTest(const char* filename, const char* datasource, const char* tablename = 0)
+    {
+        header();
+        load(mpTestDocumentPath, filename);
+
+        const OUString aPrefix( "LOMM_" );
+        utl::TempFile maTempDir(NULL, true);
+        maTempDir.EnableKillingFile();
+        const String aWorkDir = maTempDir.GetURL();
+        const OUString aURI( getURLFromSrc(mpTestDocumentPath) + OUString::createFromAscii(datasource) );
+        OUString aDBName = registerDBsource( aURI, aPrefix, aWorkDir );
+        initMailMergeJobAndArgs( filename, tablename, aDBName, aPrefix, aWorkDir );
+
+        verify();
+        finish();
+    }
+
+    /**
+     * Function overloaded by unit test. See DECLARE_SW_*_TEST macros
+     */
+    virtual void verify()
+    {
+        CPPUNIT_FAIL( "verify method must be overridden" );
+    }
+
 private:
     void dumpLayout()
     {
@@ -282,7 +368,7 @@ protected:
         if (mxComponent.is())
             mxComponent->dispose();
         // Output name early, so in the case of a hang, the name of the hanging input file is visible.
-        fprintf(stderr, "%s,", pName);
+        fprintf(stderr, "%s %s,", pDir, pName);
         m_nStartTime = osl_getGlobalTimer();
         mxComponent = loadFromDesktop(getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.text.TextDocument");
         if (bCalcLayout)
@@ -351,6 +437,100 @@ protected:
         void (T::*pMethod)();
     };
     sal_uInt32 m_nStartTime;
+
+    uno::Reference< lang::XComponent > mxMMComponent;
+    uno::Reference< com::sun::star::task::XJob > mxJob;
+    uno::Sequence< beans::NamedValue > mSeqMailMergeArgs;
+
+    const char* mpTestDocumentPath;
+
+    sal_Int16 nCurOutputType;
+
+    virtual OUString registerDBsource( const OUString &aURI, const OUString &aPrefix, const String &aWorkDir )
+    {
+        OUString aDBName;
+        DBuriMap::const_iterator pos = aDBuriMap.find( aURI );
+        if (pos == aDBuriMap.end())
+        {
+            aDBName = SwNewDBMgr::LoadAndRegisterDataSource( aURI, &aPrefix, &aWorkDir );
+            aDBuriMap.insert( std::pair< OUString, OUString >( aURI, aDBName ) );
+            std::cout << "New datasource name: '" << aDBName << "'" << std::endl;
+        }
+        else
+        {
+            aDBName = pos->second;
+            std::cout << "Old datasource name: '" << aDBName << "'" << std::endl;
+        }
+        CPPUNIT_ASSERT(!aDBName.isEmpty());
+        return aDBName;
+    }
+
+    virtual void initMailMergeJobAndArgs( const char* filename, const char* tablename, const OUString &aDBName,
+                                          const OUString &aPrefix, const String &aWorkDir )
+    {
+        uno::Reference< task::XJob > xJob( getMultiServiceFactory()->createInstance( "com.sun.star.text.MailMerge" ), uno::UNO_QUERY_THROW );
+        mxJob.set( xJob );
+
+        int seq_id = 5;
+        if (tablename) seq_id += 2;
+        mSeqMailMergeArgs.realloc( seq_id );
+
+#define OUSTRING_FROM_PROP( prop ) \
+    OUString::createFromAscii(SW_PROP_NAME_STR( prop ) )
+
+        seq_id = 0;
+        mSeqMailMergeArgs[ seq_id++ ] = beans::NamedValue( OUSTRING_FROM_PROP( UNO_NAME_OUTPUT_TYPE ), uno::Any( text::MailMergeType::SHELL ) );
+        mSeqMailMergeArgs[ seq_id++ ] = beans::NamedValue( OUSTRING_FROM_PROP( UNO_NAME_DOCUMENT_URL ), uno::Any(
+                                        ( OUString(getURLFromSrc(mpTestDocumentPath) + OUString::createFromAscii(filename)) ) ) );
+        mSeqMailMergeArgs[ seq_id++ ] = beans::NamedValue( OUSTRING_FROM_PROP( UNO_NAME_DATA_SOURCE_NAME ), uno::Any( aDBName ) );
+        mSeqMailMergeArgs[ seq_id++ ] = beans::NamedValue( OUSTRING_FROM_PROP( UNO_NAME_OUTPUT_URL ), uno::Any( OUString( aWorkDir ) ) );
+        mSeqMailMergeArgs[ seq_id++ ] = beans::NamedValue( OUSTRING_FROM_PROP( UNO_NAME_FILE_NAME_PREFIX ), uno::Any( aPrefix ));
+        if (tablename)
+        {
+            mSeqMailMergeArgs[ seq_id++ ] = beans::NamedValue( OUSTRING_FROM_PROP( UNO_NAME_DAD_COMMAND_TYPE ), uno::Any( sdb::CommandType::TABLE ) );
+            mSeqMailMergeArgs[ seq_id++ ] = beans::NamedValue( OUSTRING_FROM_PROP( UNO_NAME_DAD_COMMAND ), uno::Any( OUString::createFromAscii(tablename) ) );
+        }
+    }
+
+    virtual void executeMailMerge()
+    {
+        uno::Any res = mxJob->execute( mSeqMailMergeArgs );
+
+        OUString aCurOutputURL;
+        OUString aCurFileNamePrefix;
+        const beans::NamedValue *pArguments = mSeqMailMergeArgs.getConstArray();
+        bool bOk = true;
+        sal_Int32 nArgs = mSeqMailMergeArgs.getLength();
+
+        for (sal_Int32 i = 0; i < nArgs; ++i) {
+            const OUString &rName  = pArguments[i].Name;
+            const uno::Any &rValue = pArguments[i].Value;
+
+            // all error checking was already done by the MM job execution
+            if (rName.equalsAscii( GetPropName( UNO_NAME_OUTPUT_URL ) ))
+                bOk &= rValue >>= aCurOutputURL;
+            else if (rName.equalsAscii( GetPropName( UNO_NAME_FILE_NAME_PREFIX ) ))
+                bOk &= rValue >>= aCurFileNamePrefix;
+            else if (rName.equalsAscii( GetPropName( UNO_NAME_OUTPUT_TYPE ) ))
+                bOk &= rValue >>= nCurOutputType;
+        }
+
+        CPPUNIT_ASSERT(bOk);
+
+        if (nCurOutputType == text::MailMergeType::SHELL)
+        {
+            CPPUNIT_ASSERT(res >>= mxMMComponent);
+            CPPUNIT_ASSERT(mxMMComponent.is());
+        }
+        else
+        {
+            CPPUNIT_ASSERT(res == true);
+            mxMMComponent = loadFromDesktop( aCurOutputURL + "/" + aCurFileNamePrefix + "0.odt",
+                                             "com.sun.star.text.TextDocument");
+            CPPUNIT_ASSERT(mxMMComponent.is());
+            calcLayout();
+        }
+    }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/mailmerge/data/4_v01.ods b/sw/qa/extras/mailmerge/data/4_v01.ods
new file mode 100644
index 0000000..ffbf33b
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/4_v01.ods differ
diff --git a/sw/qa/extras/mailmerge/data/multiple-page-anchored-draws.odt b/sw/qa/extras/mailmerge/data/multiple-page-anchored-draws.odt
new file mode 100644
index 0000000..55a0436
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/multiple-page-anchored-draws.odt differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
new file mode 100644
index 0000000..bf550a3
--- /dev/null
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -0,0 +1,76 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#if !defined(MACOSX) && !defined(WNT)
+
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/style/PageStyleLayout.hpp>
+#include <com/sun/star/table/XCell.hpp>
+#include <com/sun/star/table/BorderLine.hpp>
+#include <com/sun/star/text/XTextTable.hpp>
+#include <com/sun/star/text/MailMergeType.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+
+#include <wrtsh.hxx>
+#include <ndtxt.hxx>
+#include <swdtflvr.hxx>
+#include <view.hxx>
+#include <edtwin.hxx>
+#include <olmenu.hxx>
+#include <cmdid.h>
+
+class MMTest : public SwModelTestBase
+{
+    public:
+        MMTest() : SwModelTestBase("/sw/qa/extras/mailmerge/data/") {}
+};
+
+#define DECLARE_DFLT_MAILMERGE_TEST(TestName, filename, datasource, tablename) \
+    DECLARE_MAILMERGE_TEST(TestName, filename, datasource, tablename, MMTest)
+
+DECLARE_DFLT_MAILMERGE_TEST(testMultiPageAnchoredDraws, "multiple-page-anchored-draws.odt", "4_v01.ods", "Tabelle1")
+{
+    executeMailMerge();
+
+    SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxMMComponent.get());
+    CPPUNIT_ASSERT(pTxtDoc);
+    sal_uInt16 nPhysPages = pTxtDoc->GetDocShell()->GetWrtShell()->GetPhyPageNum();
+    CPPUNIT_ASSERT_EQUAL(sal_uInt16(8), nPhysPages);
+
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxMMComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xDraws->getCount());
+
+    // bitset of all page numbers
+    char nPageSum = 0xFF;
+    uno::Reference<beans::XPropertySet> xPropertySet;
+
+    for (sal_Int32 i = 0; i < xDraws->getCount(); i++)
+    {
+        text::TextContentAnchorType nAnchorType;
+        sal_uInt16 nAnchorPageNo;
+        xPropertySet.set(xDraws->getByIndex(i), uno::UNO_QUERY);
+
+        xPropertySet->getPropertyValue( OUSTRING_FROM_PROP( UNO_NAME_ANCHOR_TYPE ) ) >>= nAnchorType;
+        CPPUNIT_ASSERT_EQUAL( text::TextContentAnchorType_AT_PAGE, nAnchorType );
+
+        xPropertySet->getPropertyValue( OUSTRING_FROM_PROP( UNO_NAME_ANCHOR_PAGE_NO ) ) >>= nAnchorPageNo;
+        nPageSum &= !nAnchorPageNo;
+    }
+
+    // are all shapes are on different page numbers?
+    CPPUNIT_ASSERT_EQUAL(char(0), nPageSum);
+}
+
+#endif
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 2f3db8081c56cd91e5837978ddeae62788f34e0b
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Mon Sep 15 00:48:59 2014 +0200

    MM: add non-UI LoadAndRegisterDataSource function
    
    For the mail merge unit test we need a function to register new
    database sources without any UI interaction. This refactors and
    introduces new versions of LoadAndRegisterDataSource, which gets
    all previously interactive values as arguments.
    
    (cherry picked from commit 5187ce45b93e5e841e541eac98da3fa2110fe632)
    
    Conflicts:
    
    	sw/source/uibase/dbui/dbmgr.cxx
    
    Change-Id: I1601b4112ddc800a0935950133d386ce349b9087

diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index a009c077..0f5493c 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -74,6 +74,7 @@ class SwDbtoolsClient;
 class SwXMailMerge;
 class SwMailMergeConfigItem;
 class SwCalc;
+class INetURLObject;
 
 // -----------------------------------------------------------------------
 
@@ -225,6 +226,16 @@ public:
     SwNewDBMgr();
     ~SwNewDBMgr();
 
+    enum DBConnURITypes {
+        DBCONN_UNKNOWN = 0,
+        DBCONN_ODB,
+        DBCONN_CALC,
+        DBCONN_DBASE,
+        DBCONN_FLAT,
+        DBCONN_MSJET,
+        DBCONN_MSACE
+    };
+
     /// MailMergeEvent source
     const SwXMailMerge *    GetMailMergeEvtSrc() const  { return pMergeEvtSrc; }
     void SetMailMergeEvtSrc( const SwXMailMerge *pSrc ) { pMergeEvtSrc = pSrc; }
@@ -338,11 +349,35 @@ public:
 
     static ::com::sun::star::uno::Sequence<OUString> GetExistingDatabaseNames();
 
+    static DBConnURITypes GetDBunoURI(const OUString &rURI, ::com::sun::star::uno::Any &aURLAny);
+
     /**
-     Loads a data source from file and registers it. Returns the registered name.
+     Loads a data source from file and registers it.
+
+     This function requires GUI interaction, as it loads the data source from
+     the filename returned by a file picker and additional settings dialog.
+     In case of success it returns the registered name, otherwise an empty string.
      */
     static String               LoadAndRegisterDataSource();
 
+    /**
+     Loads a data source from file and registers it.
+
+     In case of success it returns the registered name, otherwise an empty string.
+     Optionally add a prefix to the registered DB name.
+     */
+    static OUString            LoadAndRegisterDataSource(const DBConnURITypes type, const ::com::sun::star::uno::Any &rUnoURI,
+                                                         const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > *pSettings,
+                                                         const OUString &rURI, const OUString *pPrefix = 0, const String *pDestDir = 0);
+    /**
+     Loads a data source from file and registers it.
+
+     Convenience function, which calls GetDBunoURI and has just one mandatory parameter.
+     In case of success it returns the registered name, otherwise an empty string.
+     */
+    static OUString            LoadAndRegisterDataSource(const OUString& rURI, const OUString *pPrefix = 0, const String *pDestDir = 0,
+                                                         const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > *pSettings = 0);
+
     static SwDbtoolsClient&    GetDbtoolsClient();
     /// has to be called from _FinitUI()
     static void                RemoveDbtoolsClient();
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 755a4b2..40846c5 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -2407,74 +2407,113 @@ String SwNewDBMgr::LoadAndRegisterDataSource()
 
     xFltMgr->setCurrentFilter( sFilterAll ) ;
     String sFind;
-    bool bTextConnection = false;
     if( ERRCODE_NONE == aDlgHelper.Execute() )
     {
-        String sURL = xFP->getFiles().getConstArray()[0];
-        //data sources have to be registered depending on their extensions
-        INetURLObject aURL( sURL );
-        String sExt( aURL.GetExtension() );
         Any aURLAny;
+        uno::Reference< beans::XPropertySet > aSettings;
+        const OUString aURI( xFP->getFiles().getConstArray()[0] );
+        const DBConnURITypes type = GetDBunoURI( aURI, aURLAny );
+
+        if( DBCONN_FLAT == type )
+        {
+            Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
+            uno::Reference < sdb::XTextConnectionSettings > xSettingsDlg = sdb::TextConnectionSettings::create(xContext);
+            if( xSettingsDlg->execute() )
+                aSettings.set( uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY_THROW ) );
+        }
+        sFind = LoadAndRegisterDataSource( type, aURLAny, DBCONN_FLAT == type ? &aSettings : 0, aURI );
+    }
+    return sFind;
+}
+
+SwNewDBMgr::DBConnURITypes SwNewDBMgr::GetDBunoURI(const OUString &rURI, Any &aURLAny)
+{
+    INetURLObject aURL( rURI );
+    String sExt( aURL.GetExtension() );
+    DBConnURITypes type = DBCONN_UNKNOWN;
+
+    if(sExt == "odb")
+    {
+        type = DBCONN_ODB;
+    }
+    else if(sExt.EqualsIgnoreCaseAscii("sxc")
+        || sExt.EqualsIgnoreCaseAscii("ods")
+            || sExt.EqualsIgnoreCaseAscii("xls"))
+    {
+        OUString sDBURL("sdbc:calc:");
+        sDBURL += aURL.GetMainURL(INetURLObject::NO_DECODE);
+        aURLAny <<= sDBURL;
+        type = DBCONN_CALC;
+    }
+    else if(sExt.EqualsIgnoreCaseAscii("dbf"))
+    {
+        aURL.removeSegment();
+        aURL.removeFinalSlash();
+        OUString sDBURL("sdbc:dbase:");
+        sDBURL += aURL.GetMainURL(INetURLObject::NO_DECODE);
+        aURLAny <<= sDBURL;
+        type = DBCONN_DBASE;
+    }
+    else if(sExt.EqualsIgnoreCaseAscii("csv") || sExt.EqualsIgnoreCaseAscii("txt"))
+    {
+        aURL.removeSegment();
+        aURL.removeFinalSlash();
+        OUString sDBURL("sdbc:flat:");
+        //only the 'path' has to be added
+        sDBURL += aURL.GetMainURL(INetURLObject::NO_DECODE);
+        aURLAny <<= sDBURL;
+        type = DBCONN_FLAT;
+    }
+#ifdef WNT
+    else if(sExt.EqualsIgnoreCaseAscii("mdb"))
+    {
+        OUString sDBURL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=");
+        sDBURL += aURL.PathToFileName();
+        aURLAny <<= sDBURL;
+        type = DBCONN_MSJET;
+    }
+    else if(sExt.EqualsIgnoreCaseAscii("accdb"))
+    {
+        OUString sDBURL("sdbc:ado:PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=");
+        sDBURL += aURL.PathToFileName();
+        aURLAny <<= sDBURL;
+        type = DBCONN_MSACE;
+    }
+#endif
+    return type;
+}
+
+OUString SwNewDBMgr::LoadAndRegisterDataSource(const DBConnURITypes type, const Any &aURLAny, const uno::Reference< beans::XPropertySet > *pSettings,
+                                               const OUString &rURI, const OUString *pPrefix, const String *pDestDir)
+{
+        INetURLObject aURL( rURI );
+        OUString sExt( aURL.GetExtension() );
         Any aTableFilterAny;
         Any aSuppressVersionsAny;
         Any aInfoAny;
-        INetURLObject aTempURL(aURL);
         bool bStore = true;
-        if(sExt.EqualsAscii("odb"))
-        {
+        OUString sFind;
+        Sequence<OUString> aFilters(1);
+
+        switch (type) {
+        case DBCONN_UNKNOWN:
+        case DBCONN_CALC:
+            break;
+        case DBCONN_ODB:
             bStore = false;
-        }
-        else if(sExt.EqualsIgnoreCaseAscii("sxc")
-            || sExt.EqualsIgnoreCaseAscii("ods")
-                || sExt.EqualsIgnoreCaseAscii("xls"))
-        {
-            OUString sDBURL("sdbc:calc:");
-            sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
-            aURLAny <<= sDBURL;
-        }
-        else if(sExt.EqualsIgnoreCaseAscii("dbf"))
-        {
-            aTempURL.removeSegment();
-            aTempURL.removeFinalSlash();
-            OUString sDBURL("sdbc:dbase:");
-            sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
-            aURLAny <<= sDBURL;
-            //set the filter to the file name without extension
-            Sequence<OUString> aFilters(1);
-            aFilters[0] = aURL.getBase();
-            aTableFilterAny <<= aFilters;
-        }
-        else if(sExt.EqualsIgnoreCaseAscii("csv") || sExt.EqualsIgnoreCaseAscii("txt"))
-        {
-            aTempURL.removeSegment();
-            aTempURL.removeFinalSlash();
-            OUString sDBURL("sdbc:flat:");
-            //only the 'path' has to be added
-            sDBURL += aTempURL.GetMainURL(INetURLObject::NO_DECODE);
-            aURLAny <<= sDBURL;
-
-            bTextConnection = true;
+            break;
+        case DBCONN_FLAT:
+        case DBCONN_DBASE:
             //set the filter to the file name without extension
-            Sequence<OUString> aFilters(1);
             aFilters[0] = aURL.getBase();
             aTableFilterAny <<= aFilters;
-        }
-#ifdef WNT
-        else if(sExt.EqualsIgnoreCaseAscii("mdb"))
-        {
-            OUString sDBURL("sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=");
-            sDBURL += aTempURL.PathToFileName();
-            aURLAny <<= sDBURL;
-            aSuppressVersionsAny <<= makeAny(true);
-        }
-        else if(sExt.EqualsIgnoreCaseAscii("accdb"))
-        {
-            OUString sDBURL("sdbc:ado:PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=");
-            sDBURL += aTempURL.PathToFileName();
-            aURLAny <<= sDBURL;
+            break;
+        case DBCONN_MSJET:
+        case DBCONN_MSACE:
             aSuppressVersionsAny <<= makeAny(true);
+            break;
         }
-#endif
+
         try
         {
             Reference<XComponentContext> xContext( ::comphelper::getProcessComponentContext() );
@@ -2487,6 +2526,8 @@ String SwNewDBMgr::LoadAndRegisterDataSource()
                                                      RTL_TEXTENCODING_UTF8 );
             xub_StrLen nExtLen = static_cast< xub_StrLen >(aURL.GetExtension().getLength());
             sNewName.Erase( sNewName.Len() - nExtLen - 1, nExtLen + 1 );
+            if (pPrefix)
+                sNewName = *pPrefix + sNewName;
 
             //find a unique name if sNewName already exists
             sFind = sNewName;
@@ -2501,7 +2542,7 @@ String SwNewDBMgr::LoadAndRegisterDataSource()
             if(!bStore)
             {
                 //odb-file
-                Any aDataSource = xDBContext->getByName(aTempURL.GetMainURL(INetURLObject::NO_DECODE));
+                Any aDataSource = xDBContext->getByName(aURL.GetMainURL(INetURLObject::NO_DECODE));
                 aDataSource >>= xNewInstance;
             }
             else
@@ -2518,19 +2559,13 @@ String SwNewDBMgr::LoadAndRegisterDataSource()
                 if(aInfoAny.hasValue())
                     xDataProperties->setPropertyValue("Info", aInfoAny);
 
-                if( bTextConnection )
+                if( DBCONN_FLAT == type && pSettings )
                 {
-                    uno::Reference < sdb::XTextConnectionSettings > xSettingsDlg = sdb::TextConnectionSettings::create(xContext);
-                    if( xSettingsDlg->execute() )
-                    {
                         uno::Any aSettings = xDataProperties->getPropertyValue( "Settings" );
                         uno::Reference < beans::XPropertySet > xDSSettings;
                         aSettings >>= xDSSettings;
-                        ::comphelper::copyProperties(
-                            uno::Reference < beans::XPropertySet >( xSettingsDlg, uno::UNO_QUERY_THROW ),
-                            xDSSettings );
+                        ::comphelper::copyProperties( *pSettings, xDSSettings );
                         xDSSettings->setPropertyValue( "Extension", uno::makeAny( OUString( sExt )));
-                    }
                 }
 
                 Reference<XDocumentDataSource> xDS(xNewInstance, UNO_QUERY_THROW);
@@ -2538,7 +2573,8 @@ String SwNewDBMgr::LoadAndRegisterDataSource()
                 String sOutputExt = OUString(".odb");
                 String sTmpName;
                 {
-                    utl::TempFile aTempFile(sNewName , &sOutputExt, &sHomePath);
+                    String sHomePath(SvtPathOptions().GetWorkPath());
+                    utl::TempFile aTempFile(sNewName, &sOutputExt, pDestDir ? pDestDir : &sHomePath);
                     aTempFile.EnableKillingFile(sal_True);
                     sTmpName = aTempFile.GetURL();
                 }
@@ -2546,14 +2582,20 @@ String SwNewDBMgr::LoadAndRegisterDataSource()
             }
             Reference<XNamingService> xNaming(xDBContext, UNO_QUERY);
             xNaming->registerObject( sFind, xNewInstance );
-
         }
         catch(const Exception&)
         {
+            sFind = "";
         }
-    }
     return sFind;
+}
 
+OUString SwNewDBMgr::LoadAndRegisterDataSource(const OUString &rURI, const OUString *pPrefix, const String *pDestDir,
+                                               const uno::Reference< beans::XPropertySet > *pSettings)
+{
+    Any aURLAny;
+    DBConnURITypes type = GetDBunoURI( rURI, aURLAny );
+    return LoadAndRegisterDataSource( type, aURLAny, pSettings, rURI, pPrefix, pDestDir );
 }
 
 void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
commit bf07857ff32d887bd215745430cfb6552577ff28
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Mon Sep 15 00:13:06 2014 +0200

    MM: export the SwDocShell mail merge via UNO
    
    This saves the loading time for large document. Use it if you
    want to present the generated document to the user or write a
    mail merge unit tests.
    
    This includes:
      * renaming "only" to "shell" at multiple occurences
      * dropping the DBMGR_MERGE_SINGLE_FILE special type for the mail
        merge wizard in favour of an additional SwMergeDescriptor
        boolean
      * cleanup and renaming of the internal merge type enums, so these
        actually  match the diffferent merge targets: printer, email,
        file and shell
    
    (cherry picked from commit 9835bb562cfe3a5d386c24d86176ba7bb5ab26d2)
    
    Conflicts:
    
    	offapi/type_reference/offapi.idl
    	sw/inc/dbmgr.hxx
    	sw/source/ui/dialog/swdlgfact.cxx
    	sw/source/ui/dialog/swdlgfact.hxx
    	sw/source/ui/envelp/mailmrge.cxx
    	sw/source/uibase/dbui/dbmgr.cxx
    	sw/source/uibase/inc/mailmrge.hxx
    	sw/source/uibase/uno/unomailmerge.cxx
    
    Change-Id: I33c6773972195193687ba9c3e12b562310d330c1

diff --git a/offapi/com/sun/star/text/MailMergeType.idl b/offapi/com/sun/star/text/MailMergeType.idl
index 8e5a5af..3a108cf 100644
--- a/offapi/com/sun/star/text/MailMergeType.idl
+++ b/offapi/com/sun/star/text/MailMergeType.idl
@@ -45,6 +45,15 @@ published constants MailMergeType
      */
     const short MAIL = 3;
 
+
+    /** The output is a document shell.
+
+        The successful mail marge returns a XTextDocument based component.
+
+        @since LibreOffice 4.4
+     */
+    const short SHELL = 4;
+
 };
 
 
diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 79bcddf..a009c077 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -80,12 +80,10 @@ class SwCalc;
 enum DBMgrOptions
 {
     DBMGR_MERGE,             ///< Data records in fields.
-    DBMGR_INSERT,            ///< Data records in text.
-    DBMGR_MERGE_MAILMERGE,   ///< Print mail merge.
-    DBMGR_MERGE_MAILING,     ///< Send mail merge as email.
-    DBMGR_MERGE_MAILFILES,   ///< Save mail merge as files.
-    DBMGR_MERGE_SINGLE_FILE, ///< Save merge as single file.
-    DBMGR_MERGE_ONLY         ///< Create merge doc w/o save/print.
+    DBMGR_MERGE_PRINTER,     ///< Print mail merge.
+    DBMGR_MERGE_EMAIL,       ///< Send mail merge as email.
+    DBMGR_MERGE_FILE,        ///< Save mail merge as files.
+    DBMGR_MERGE_SHELL        ///< Create merge doc and keep the doc shell.
 };
 
 // -----------------------------------------------------------------------
@@ -162,6 +160,7 @@ struct SwMergeDescriptor
 
     sal_Bool                                            bPrintAsync;
     sal_Bool                                            bCreateSingleFile;
+    sal_Bool                                            bSubjectIsFilename;
 
     SwMailMergeConfigItem*                              pMailMergeConfigItem;
 
@@ -175,6 +174,7 @@ struct SwMergeDescriptor
         bSendAsAttachment( sal_False ),
         bPrintAsync( sal_False ),
         bCreateSingleFile( sal_False ),
+        bSubjectIsFilename( sal_False ),
         pMailMergeConfigItem(0)
         {}
 
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index cb25b72..e00fd6a 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -145,7 +145,7 @@ public:
     virtual const OUString& GetSaveFilter() const = 0;
     virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > GetSelection() const = 0;
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> GetResultSet() const = 0;
-    virtual bool IsSaveIndividualDocs() const = 0;
+    virtual bool IsSaveSingleDoc() const = 0;
     virtual bool IsGenerateFromDataBase() const = 0;
     virtual String GetColumnName() const = 0;
     virtual String GetPath() const = 0;
diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index 30e2def..755a4b2 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -429,11 +429,10 @@ sal_Bool SwNewDBMgr::MergeNew( const SwMergeDescriptor& rMergeDesc )
             bRet = Merge(&rMergeDesc.rSh);
             break;
 
-        case DBMGR_MERGE_MAILMERGE: // printing merge from 'old' merge dialog or from UNO-component
-        case DBMGR_MERGE_MAILING:
-        case DBMGR_MERGE_MAILFILES:
-        case DBMGR_MERGE_SINGLE_FILE:
-        case DBMGR_MERGE_ONLY:
+        case DBMGR_MERGE_PRINTER:
+        case DBMGR_MERGE_EMAIL:
+        case DBMGR_MERGE_FILE:
+        case DBMGR_MERGE_SHELL:
             // save files and send them as e-Mail if required
             bRet = MergeMailFiles(&rMergeDesc.rSh,
                     rMergeDesc);
@@ -886,9 +885,8 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
     //check if the doc is synchronized and contains at least one linked section
     bool bSynchronizedDoc = pSourceShell->IsLabelDoc() && pSourceShell->GetSectionFmtCount() > 1;
     sal_Bool bNoError = sal_True;
-    const bool bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_MAILING;
-    const bool bAsSingleFile = rMergeDescriptor.nMergeType == DBMGR_MERGE_SINGLE_FILE;
-    const bool bMergeOnly = rMergeDescriptor.nMergeType == DBMGR_MERGE_ONLY;
+    const bool bEMail = rMergeDescriptor.nMergeType == DBMGR_MERGE_EMAIL;
+    const bool bMergeShell = rMergeDescriptor.nMergeType == DBMGR_MERGE_SHELL;
 
     ::rtl::Reference< MailDispatcher >          xMailDispatcher;
     OUString sBodyMimeType;
@@ -947,9 +945,9 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
             OSL_ENSURE(xSourceDocProps.is(), "DocumentProperties is null");
         }
 
-        if( !bMergeOnly && pSourceDocSh->IsModified() )
+        if( !bMergeShell && pSourceDocSh->IsModified() )
             pSfxDispatcher->Execute( pSourceDocSh->HasName() ? SID_SAVEDOC : SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD);
-        if( bMergeOnly || !pSourceDocSh->IsModified() )
+        if( bMergeShell || !pSourceDocSh->IsModified() )
         {
             const SfxFilter* pStoreToFilter = SwIoSystem::GetFileFilter(
                 pSourceDocSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ), ::aEmptyStr );
@@ -993,7 +991,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
 
             if (!IsMergeSilent()) {
                 pSourceWindow = &pSourceShell->GetView().GetEditWin();
-                if( bMergeOnly )
+                if( bMergeShell )
                     pProgressDlg = new CreateMonitor( pSourceWindow );
                 else {
                     pProgressDlg = new PrintMonitor( pSourceWindow, PrintMonitor::MONITOR_TYPE_PRINT );
@@ -1006,7 +1004,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                     Application::Reschedule();
             }
 
-            if(bAsSingleFile || rMergeDescriptor.bCreateSingleFile)
+            if(rMergeDescriptor.bCreateSingleFile)
             {
                 // create a target docshell to put the merged document into
                 xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
@@ -1014,7 +1012,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                 if (nMaxDumpDocs)
                     lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
                 SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
-                if (bMergeOnly) {
+                if (bMergeShell && pSourceWindow) {
                     //the created window has to be located at the same position as the source window
                     Window& rTargetWindow = pTargetFrame->GetFrame().GetWindow();
                     rTargetWindow.SetPosPixel(pSourceWindow->GetPosPixel());
@@ -1063,7 +1061,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
 
             sal_Int32 nDocNo = 1;
             sal_Int32 nDocCount = 0;
-            if( !IsMergeSilent() && bMergeOnly &&
+            if( !IsMergeSilent() && bMergeShell &&
                     lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
                 ((CreateMonitor*) pProgressDlg)->SetTotalCount( nDocCount );
 
@@ -1090,7 +1088,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                     }
 
                     // create a new temporary file name - only done once in case of bCreateSingleFile
-                    if( 1 == nDocNo || (!rMergeDescriptor.bCreateSingleFile && !bAsSingleFile) )
+                    if( 1 == nDocNo || !rMergeDescriptor.bCreateSingleFile )
                     {
                         INetURLObject aEntry(sPath);
                         String sLeading;
@@ -1104,7 +1102,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                         String sExt(comphelper::string::stripStart(pStoreToFilter->GetDefaultExtension(), '*'));
                         aTempFile = std::auto_ptr< utl::TempFile >(
                                 new utl::TempFile(sLeading,&sExt,&sPath ));
-                        if( bAsSingleFile )
+                        if( rMergeDescriptor.bSubjectIsFilename )
                             aTempFile->EnableKillingFile();
                     }
 
@@ -1118,7 +1116,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                     {
                         INetURLObject aTempFileURL(aTempFile->GetURL());
                         if (!IsMergeSilent()) {
-                            if( bMergeOnly )
+                            if( bMergeShell )
                                 ((CreateMonitor*) pProgressDlg)->SetCurrentPosition( nDocNo );
                             else {
                                 PrintMonitor *pPrintMonDlg = (PrintMonitor*) pProgressDlg;
@@ -1173,7 +1171,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                                 pEvtSrc->LaunchMailMergeEvent( aEvt );
                             }
 
-                            if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile )
+                            if(rMergeDescriptor.bCreateSingleFile)
                             {
                                 OSL_ENSURE( pTargetShell, "no target shell available!" );
                                 // copy created file into the target document
@@ -1217,7 +1215,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                                 pTargetShell->CalcLayout();
                                 if ( (nMaxDumpDocs < 0) || (nDocNo <= nMaxDumpDocs) )
                                     lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
-                                if (bMergeOnly)
+                                if (bMergeShell)
                                 {
                                     SwDocMergeInfo aMergeInfo;
                                     aMergeInfo.nStartPageInTarget = nStartPage;
@@ -1343,7 +1341,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
 
                 // Freeze the layouts of the target document after the first inserted
                 // sub-document, to get the correct PageDesc.
-                if(!bFreezedLayouts && (rMergeDescriptor.bCreateSingleFile || bAsSingleFile))
+                if(!bFreezedLayouts && (rMergeDescriptor.bCreateSingleFile))
                 {
                     std::set<SwRootFrm*> aAllLayouts = pTargetShell->GetDoc()->GetAllLayouts();
                     std::for_each( aAllLayouts.begin(), aAllLayouts.end(),
@@ -1357,7 +1355,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                 Application::Reschedule();
 
             // Unfreeze target document layouts and correct all PageDescs.
-            if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
+            if(rMergeDescriptor.bCreateSingleFile)
             {
                 std::set<SwRootFrm*> aAllLayouts = pTargetShell->GetDoc()->GetAllLayouts();
                 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),
@@ -1368,16 +1366,16 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
             DELETEZ( pProgressDlg );
 
             // save the single output document
-            if (bMergeOnly)
+            if (bMergeShell)
             {
                 rMergeDescriptor.pMailMergeConfigItem->SetTargetView( pTargetView );
             }
-            else if(rMergeDescriptor.bCreateSingleFile || bAsSingleFile)
+            else if(rMergeDescriptor.bCreateSingleFile)
             {
-                if( rMergeDescriptor.nMergeType != DBMGR_MERGE_MAILMERGE )
+                if( rMergeDescriptor.nMergeType != DBMGR_MERGE_PRINTER )
                 {
                     OSL_ENSURE( aTempFile.get(), "Temporary file not available" );
-                    INetURLObject aTempFileURL(bAsSingleFile ? sSubject : aTempFile->GetURL());
+                    INetURLObject aTempFileURL( rMergeDescriptor.bSubjectIsFilename ? sSubject : aTempFile->GetURL());
                     SfxMedium* pDstMed = new SfxMedium(
                         aTempFileURL.GetMainURL( INetURLObject::NO_DECODE ),
                         STREAM_STD_READWRITE );
@@ -1442,7 +1440,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                 }
 
                 // Leave docshell available for caller (e.g. MM wizard)
-                if (!bMergeOnly)
+                if (!bMergeShell)
                     xTargetDocShell->DoClose();
             }
 
@@ -1840,7 +1838,7 @@ String SwNewDBMgr::GetDBField(uno::Reference<XPropertySet> xColumnProps,
 
 // checks if a desired data source table or query is open
 sal_Bool    SwNewDBMgr::IsDataSourceOpen(const String& rDataSource,
-            const String& rTableOrQuery, sal_Bool bMergeOnly)
+            const String& rTableOrQuery, sal_Bool bMergeShell)
 {
     if(pImpl->pMergeData)
     {
@@ -1851,7 +1849,7 @@ sal_Bool    SwNewDBMgr::IsDataSourceOpen(const String& rDataSource,
                     &&
                     pImpl->pMergeData->xResultSet.is();
     }
-    else if(!bMergeOnly)
+    else if(!bMergeShell)
     {
         SwDBData aData;
         aData.sDataSource = rDataSource;
@@ -2659,7 +2657,8 @@ void SwNewDBMgr::ExecuteFormLetter( SwWrtShell& rSh,
 
                     SwMergeDescriptor aMergeDesc( pImpl->pMergeDialog->GetMergeType(), pView->GetWrtShell(), aDescriptor );
                     aMergeDesc.sSaveToFilter = pImpl->pMergeDialog->GetSaveFilter();
-                    aMergeDesc.bCreateSingleFile = !pImpl->pMergeDialog->IsSaveIndividualDocs();
+                    aMergeDesc.bCreateSingleFile = pImpl->pMergeDialog->IsSaveSingleDoc();
+                    aMergeDesc.bSubjectIsFilename = aMergeDesc.bCreateSingleFile;
                     if( !aMergeDesc.bCreateSingleFile && pImpl->pMergeDialog->IsGenerateFromDataBase() )
                     {
                         aMergeDesc.sAddressFromColumn = pImpl->pMergeDialog->GetColumnName();
diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx
index 40e0ea0..5dcf2e9 100644
--- a/sw/source/ui/dbui/mailmergewizard.cxx
+++ b/sw/source/ui/dbui/mailmergewizard.cxx
@@ -281,7 +281,7 @@ void SwMailMergeWizard::CreateTargetDocument()
     aDescriptor[ svx::daCommand ]     <<= m_rConfigItem.GetCurrentDBData().sCommand;
     aDescriptor[ svx::daCommandType ] <<= m_rConfigItem.GetCurrentDBData().nCommandType;
 
-    SwMergeDescriptor aMergeDesc( DBMGR_MERGE_ONLY, GetSwView()->GetWrtShell(),
+    SwMergeDescriptor aMergeDesc( DBMGR_MERGE_SHELL, GetSwView()->GetWrtShell(),
         aDescriptor);
     aMergeDesc.pMailMergeConfigItem = &m_rConfigItem;
     aMergeDesc.bCreateSingleFile = true;
diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx
index e455c68..0158996 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -491,9 +491,9 @@ uno::Reference< sdbc::XResultSet> AbstractMailMergeDlg_Impl::GetResultSet() cons
 {
     return pDlg->GetResultSet();
 }
-bool AbstractMailMergeDlg_Impl::IsSaveIndividualDocs() const
+bool AbstractMailMergeDlg_Impl::IsSaveSingleDoc() const
 {
-    return pDlg->IsSaveIndividualDocs();
+    return pDlg->IsSaveSingleDoc();
 }
 bool AbstractMailMergeDlg_Impl::IsGenerateFromDataBase() const
 {
diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx
index 2b6cb59..a4f4c65 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -329,13 +329,11 @@ class AbstractMailMergeDlg_Impl : public AbstractMailMergeDlg
     virtual const OUString& GetSaveFilter() const;
     virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > GetSelection() const ;
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> GetResultSet() const;
-    virtual bool IsSaveIndividualDocs() const;
+    virtual bool IsSaveSingleDoc() const SAL_OVERRIDE;
     virtual bool IsGenerateFromDataBase() const;
     virtual String GetColumnName() const;
     virtual String GetPath() const;
 };
-//for SwMailMergeDlg end
-//for SwMailMergeCreateFromDlg begin
 class SwMailMergeCreateFromDlg;
 class AbstractMailMergeCreateFromDlg_Impl : public AbstractMailMergeCreateFromDlg
 {
diff --git a/sw/source/ui/envelp/mailmrge.cxx b/sw/source/ui/envelp/mailmrge.cxx
index 4937fe1..05f3af5 100644
--- a/sw/source/ui/envelp/mailmrge.cxx
+++ b/sw/source/ui/envelp/mailmrge.cxx
@@ -193,7 +193,6 @@ SwMailMergeDlg::SwMailMergeDlg(Window* pParent, SwWrtShell& rShell,
     rSh             (rShell),
     rDBName         (rSourceName),
     rTableName      (rTblName),
-    nMergeType      (DBMGR_MERGE_MAILING),
     m_aDialogSize( GetSizePixel() )
 {
     FreeResource();
@@ -653,18 +652,17 @@ bool SwMailMergeDlg::ExecQryShell()
     SwNewDBMgr* pMgr = rSh.GetNewDBMgr();
 
     if (aPrinterRB.IsChecked())
-        nMergeType = DBMGR_MERGE_MAILMERGE;
+        nMergeType = DBMGR_MERGE_PRINTER;
     else if (aMailingRB.IsChecked())
     {
-        nMergeType = DBMGR_MERGE_MAILING;
+        nMergeType = DBMGR_MERGE_EMAIL;
         pMgr->SetEMailColumn(aAddressFldLB.GetSelectEntry());
         pMgr->SetSubject(aSubjectED.GetText());
         pMgr->SetAttachment(aAttachED.GetText());
     }
     else
     {
-        nMergeType = static_cast< sal_uInt16 >( aSaveSingleDocRB.IsChecked() ?
-                    DBMGR_MERGE_SINGLE_FILE : DBMGR_MERGE_MAILFILES );
+        nMergeType = DBMGR_MERGE_FILE;
         SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
         INetURLObject aAbs;
         if( pMedium )
diff --git a/sw/source/ui/inc/mailmrge.hxx b/sw/source/ui/inc/mailmrge.hxx
index e3ebd53..9527540 100644
--- a/sw/source/ui/inc/mailmrge.hxx
+++ b/sw/source/ui/inc/mailmrge.hxx
@@ -139,7 +139,7 @@ public:
 
     inline sal_uInt16   GetMergeType() { return nMergeType; }
 
-    bool IsSaveIndividualDocs() const { return aSaveIndividualRB.IsChecked(); }
+    bool IsSaveSingleDoc() const { return aSaveSingleDocRB.IsChecked(); }
     bool IsGenerateFromDataBase() const { return aGenerateFromDataBaseCB.IsChecked(); }
     String GetColumnName() const { return aColumnLB.GetSelectEntry();}
     String GetPath() const { return aPathED.GetText();}
diff --git a/sw/source/ui/uno/unomailmerge.cxx b/sw/source/ui/uno/unomailmerge.cxx
index 9bfab27..c58e1dd 100644
--- a/sw/source/ui/uno/unomailmerge.cxx
+++ b/sw/source/ui/uno/unomailmerge.cxx
@@ -688,9 +688,10 @@ uno::Any SAL_CALL SwXMailMerge::execute(
     sal_uInt16 nMergeType;
     switch (nCurOutputType)
     {
-        case MailMergeType::PRINTER : nMergeType = DBMGR_MERGE_MAILMERGE; break;
-        case MailMergeType::FILE    : nMergeType = DBMGR_MERGE_MAILFILES; break;
-        case MailMergeType::MAIL    : nMergeType = DBMGR_MERGE_MAILING; break;
+        case MailMergeType::PRINTER : nMergeType = DBMGR_MERGE_PRINTER; break;
+        case MailMergeType::FILE    : nMergeType = DBMGR_MERGE_FILE; break;
+        case MailMergeType::MAIL    : nMergeType = DBMGR_MERGE_EMAIL; break;
+        case MailMergeType::SHELL   : nMergeType = DBMGR_MERGE_SHELL; break;
         default:
             throw IllegalArgumentException( OUString( "Invalid value of property:" ) + "OutputType", static_cast < cppu::OWeakObject * > ( this ), 0 );
     }
@@ -705,88 +706,99 @@ uno::Any SAL_CALL SwXMailMerge::execute(
 
     std::auto_ptr< SwMailMergeConfigItem > pMMConfigItem;
     uno::Reference< mail::XMailService > xInService;
-    if (MailMergeType::PRINTER == nCurOutputType)
-    {
-        IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess();
-        SwPrintData aPrtData( pIDDA->getPrintData() );
-        aPrtData.SetPrintSingleJobs( bCurSinglePrintJobs );
-        pIDDA->setPrintData( aPrtData );
-        // #i25686# printing should not be done asynchronously to prevent dangling offices
-        // when mail merge is called as command line macro
-        aMergeDesc.bPrintAsync = sal_False;
-        aMergeDesc.aPrintOptions = aPrintSettings;
-        aMergeDesc.bCreateSingleFile = true;
-    }
-    else /* FILE and MAIL*/
+    switch (nCurOutputType)
     {
-        INetURLObject aURLObj;
-        aURLObj.SetSmartProtocol( INET_PROT_FILE );
-
-        if (!aCurDocumentURL.isEmpty())
+    case MailMergeType::PRINTER:
         {
-            // if OutputURL or FileNamePrefix are missing get
-            // them from DocumentURL
-            aURLObj.SetSmartURL( aCurDocumentURL );
-            if (aCurFileNamePrefix.isEmpty())
-                aCurFileNamePrefix = aURLObj.GetBase(); // filename without extension
-            if (aCurOutputURL.isEmpty())
-            {
-                aURLObj.removeSegment();
-                aCurOutputURL = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
-            }
+            IDocumentDeviceAccess* pIDDA = rSh.getIDocumentDeviceAccess();
+            SwPrintData aPrtData( pIDDA->getPrintData() );
+            aPrtData.SetPrintSingleJobs( bCurSinglePrintJobs );
+            pIDDA->setPrintData( aPrtData );
+            // #i25686# printing should not be done asynchronously to prevent dangling offices
+            // when mail merge is called as command line macro
+            aMergeDesc.bPrintAsync = sal_False;
+            aMergeDesc.aPrintOptions = aPrintSettings;
+            aMergeDesc.bCreateSingleFile = sal_True;
         }
-        else    // default empty document without URL
+        break;
+    case MailMergeType::SHELL:
+        aMergeDesc.bCreateSingleFile = sal_True;
+        pMMConfigItem.reset(new SwMailMergeConfigItem);
+        aMergeDesc.pMailMergeConfigItem = pMMConfigItem.get();
+        break;
+    case MailMergeType::FILE:
+    case MailMergeType::MAIL:
         {
-            if (aCurOutputURL.isEmpty())
-                throw RuntimeException( OUString( "OutputURL is not set and can not be obtained." ), static_cast < cppu::OWeakObject * > ( this ) );
-        }
+            INetURLObject aURLObj;
+            aURLObj.SetSmartProtocol( INET_PROT_FILE );
 
-        aURLObj.SetSmartURL( aCurOutputURL );
-        String aPath = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
+            if (!aCurDocumentURL.isEmpty())
+            {
+                // if OutputURL or FileNamePrefix are missing get
+                // them from DocumentURL
+                aURLObj.SetSmartURL( aCurDocumentURL );
+                if (aCurFileNamePrefix.isEmpty())
+                    aCurFileNamePrefix = aURLObj.GetBase(); // filename without extension
+                if (aCurOutputURL.isEmpty())
+                {
+                    aURLObj.removeSegment();
+                    aCurOutputURL = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
+                }
+            }
+            else    // default empty document without URL
+            {
+                if (aCurOutputURL.isEmpty())
+                    throw RuntimeException( OUString( "OutputURL is not set and can not be obtained." ), static_cast < cppu::OWeakObject * > ( this ) );
+            }
 
-        String aDelim = OUString(INET_PATH_TOKEN);
-        if (aPath.Len() >= aDelim.Len() &&
-            aPath.Copy( aPath.Len()-aDelim.Len() ).CompareTo( aDelim ) != COMPARE_EQUAL)
-            aPath += aDelim;
-        if (bCurFileNameFromColumn)
-            pMgr->SetEMailColumn( aCurFileNamePrefix );
-        else
-        {
-            aPath += String( aCurFileNamePrefix );
-            pMgr->SetEMailColumn( String() );
-        }
-        pMgr->SetSubject( aPath );
-        if(MailMergeType::FILE == nCurOutputType)
-        {
-            aMergeDesc.sSaveToFilter = sSaveFilter;
-            aMergeDesc.sSaveToFilterOptions = sSaveFilterOptions;
-            aMergeDesc.aSaveToFilterData = aSaveFilterData;
-            aMergeDesc.bCreateSingleFile = bSaveAsSingleFile;
-        }
-        else
-        {
-            pMgr->SetEMailColumn( sAddressFromColumn );
-            if(sAddressFromColumn.isEmpty())
-                throw RuntimeException( OUString( "Mail address column not set." ), static_cast < cppu::OWeakObject * > ( this ) );
-            aMergeDesc.sSaveToFilter     = sAttachmentFilter;
-            aMergeDesc.sSubject          = sSubject;
-            aMergeDesc.sMailBody         = sMailBody;
-            aMergeDesc.sAttachmentName   = sAttachmentName;
-            aMergeDesc.aCopiesTo         = aCopiesTo;
-            aMergeDesc.aBlindCopiesTo    = aBlindCopiesTo;
-            aMergeDesc.bSendAsHTML       = bSendAsHTML;
-            aMergeDesc.bSendAsAttachment = bSendAsAttachment;
-
-            aMergeDesc.bCreateSingleFile = sal_False;
-            pMMConfigItem = std::auto_ptr< SwMailMergeConfigItem >(new SwMailMergeConfigItem);
-            aMergeDesc.pMailMergeConfigItem = pMMConfigItem.get();
-            aMergeDesc.xSmtpServer = SwMailMergeHelper::ConnectToSmtpServer(
-                    *pMMConfigItem,
-                    xInService,
-                    sInServerPassword, sOutServerPassword );
-            if( !aMergeDesc.xSmtpServer.is() || !aMergeDesc.xSmtpServer->isConnected())
-                throw RuntimeException( OUString( "Failed to connect to mail server." ), static_cast < cppu::OWeakObject * > ( this ) );
+            aURLObj.SetSmartURL( aCurOutputURL );
+            String aPath = aURLObj.GetMainURL( INetURLObject::DECODE_TO_IURI );
+
+            String aDelim = OUString(INET_PATH_TOKEN);
+            if (aPath.Len() >= aDelim.Len() &&
+                aPath.Copy( aPath.Len()-aDelim.Len() ).CompareTo( aDelim ) != COMPARE_EQUAL)
+                aPath += aDelim;
+            if (bCurFileNameFromColumn)
+                pMgr->SetEMailColumn( aCurFileNamePrefix );
+            else
+            {
+                aPath += String( aCurFileNamePrefix );
+                pMgr->SetEMailColumn( String() );
+            }
+            pMgr->SetSubject( aPath );
+            if(MailMergeType::FILE == nCurOutputType)
+            {
+                aMergeDesc.sSaveToFilter = sSaveFilter;
+                aMergeDesc.sSaveToFilterOptions = sSaveFilterOptions;
+                aMergeDesc.aSaveToFilterData = aSaveFilterData;
+                aMergeDesc.bCreateSingleFile = bSaveAsSingleFile;
+            }
+            else
+            {
+                pMgr->SetEMailColumn( sAddressFromColumn );
+                if(sAddressFromColumn.isEmpty())
+                    throw RuntimeException( OUString( "Mail address column not set." ), static_cast < cppu::OWeakObject * > ( this ) );
+                aMergeDesc.sSaveToFilter     = sAttachmentFilter;
+                aMergeDesc.sSubject          = sSubject;
+                aMergeDesc.sMailBody         = sMailBody;
+                aMergeDesc.sAttachmentName   = sAttachmentName;
+                aMergeDesc.aCopiesTo         = aCopiesTo;
+                aMergeDesc.aBlindCopiesTo    = aBlindCopiesTo;
+                aMergeDesc.bSendAsHTML       = bSendAsHTML;
+                aMergeDesc.bSendAsAttachment = bSendAsAttachment;
+
+                aMergeDesc.bCreateSingleFile = sal_False;
+                pMMConfigItem = std::auto_ptr< SwMailMergeConfigItem >(new SwMailMergeConfigItem);
+                aMergeDesc.pMailMergeConfigItem = pMMConfigItem.get();
+                aMergeDesc.xSmtpServer = SwMailMergeHelper::ConnectToSmtpServer(
+                        *pMMConfigItem,
+                        xInService,
+                        sInServerPassword, sOutServerPassword );
+                if( !aMergeDesc.xSmtpServer.is() || !aMergeDesc.xSmtpServer->isConnected())
+                    throw RuntimeException( OUString( "Failed to connect to mail server." ), static_cast < cppu::OWeakObject * > ( this ) );
+            }
         }
+        break;
     }
 
 
@@ -841,7 +853,13 @@ uno::Any SAL_CALL SwXMailMerge::execute(
     if(aMergeDesc.xSmtpServer.is() && aMergeDesc.xSmtpServer->isConnected())
         aMergeDesc.xSmtpServer->disconnect();
 
-    return makeAny( sal_True );
+    if (DBMGR_MERGE_SHELL == nMergeType)
+    {
+        SwXTextDocument *xTextDoc = new SwXTextDocument( aMergeDesc.pMailMergeConfigItem->GetTargetView()->GetDocShell() );
+        return makeAny( Reference< XComponent >( xTextDoc->queryInterface( XComponent::static_type() ), css::uno::UNO_QUERY) );
+    }
+    else
+        return makeAny( sal_True );
 }
 
 void SAL_CALL SwXMailMerge::cancel() throw (com::sun::star::uno::RuntimeException)
commit 12052969b6edf9119f60d685a170f2fd442f2e67
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date:   Mon Sep 15 00:00:03 2014 +0200

    MM: dump debug documents based on environment var
    
    Introduce SW_DEBUG_MAILMERGE_DOCS=<n> to dump n mail merge debug
    documents (partly merged and working copies).
    
    This will speed up mail merge unit tests and allows dumping of
    an arbitrary amount of intermediate mail merge documents.
    
    (cherry picked from commit 0a5cd87e591d7f87bfab92716079af719259f143)
    
    Conflicts:
    
    	sw/source/uibase/dbui/dbmgr.cxx
    
    Change-Id: Idb9fc19f99ccafe5574897bd1e687d439c52ebe5

diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx
index d02871e..30e2def 100644
--- a/sw/source/ui/dbui/dbmgr.cxx
+++ b/sw/source/ui/dbui/dbmgr.cxx
@@ -859,17 +859,13 @@ static void lcl_CopyDocumentPorperties(
     pTargetDoc->ReplaceUserDefinedDocumentProperties( xSourceDocProps );
 }
 
-#ifdef DBG_UTIL
-
-#define MAX_DOC_DUMP 3
-
 static void lcl_SaveDoc( SfxObjectShell *xTargetDocShell,
                          const char *name, int no = 0 )
 {
     boost::scoped_ptr< utl::TempFile > aTempFile;
     String sExt( ".odt" );
     String basename = OUString::createFromAscii( name );
-    if (no > 0 )
+    if (no > 0)
         basename += OUString::number(no) + "-";
     aTempFile.reset( new utl::TempFile( basename, true, &sExt ) );
     OSL_ENSURE( aTempFile.get(), "Temporary file not available" );
@@ -883,7 +879,6 @@ static void lcl_SaveDoc( SfxObjectShell *xTargetDocShell,
         SAL_INFO( "sw.mailmerge", "Saved doc as: " << aTempFile->GetURL() );
     delete pDstMed;
 }
-#endif
 
 sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                                     const SwMergeDescriptor& rMergeDescriptor)
@@ -899,6 +894,17 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
     OUString sBodyMimeType;
     rtl_TextEncoding eEncoding = ::osl_getThreadTextEncoding();
 
+    static const char *sMaxDumpDocs = 0;
+    static sal_Int32 nMaxDumpDocs = 0;
+    if (!sMaxDumpDocs)
+    {
+        sMaxDumpDocs = getenv("SW_DEBUG_MAILMERGE_DOCS");
+        if (!sMaxDumpDocs)
+            sMaxDumpDocs = "";
+        else
+            nMaxDumpDocs = rtl_ustr_toInt32(reinterpret_cast<const sal_Unicode*>( sMaxDumpDocs ), 10);
+    }
+
     if(bEMail)
     {
         xMailDispatcher.set( new MailDispatcher(rMergeDescriptor.xSmtpServer));
@@ -1005,9 +1011,8 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                 // create a target docshell to put the merged document into
                 xTargetDocShell = new SwDocShell( SFX_CREATE_MODE_STANDARD );
                 xTargetDocShell->DoInitNew( 0 );
-#ifdef DBG_UTIL
-                lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
-#endif
+                if (nMaxDumpDocs)
+                    lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
                 SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
                 if (bMergeOnly) {
                     //the created window has to be located at the same position as the source window
@@ -1056,7 +1061,7 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                 pViewFrm = SfxViewFrame::GetNext(*pViewFrm, pSourceDocSh);
             }
 
-            sal_uLong nDocNo = 1;
+            sal_Int32 nDocNo = 1;
             sal_Int32 nDocCount = 0;
             if( !IsMergeSilent() && bMergeOnly &&
                     lcl_getCountFromResultSet( nDocCount, pImpl->pMergeData->xResultSet ) )
@@ -1142,10 +1147,8 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
 
                             SwDoc* pWorkDoc = rWorkShell.GetDoc();
                             lcl_CopyDocumentPorperties( xSourceDocProps, xWorkDocSh, pWorkDoc );
-#ifdef DBG_UTIL
-                            if ( nDocNo <= MAX_DOC_DUMP )
+                            if ( (nMaxDumpDocs < 0) || (nDocNo <= nMaxDumpDocs) )
                                 lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo );
-#endif
                             SwNewDBMgr* pOldDBMgr = pWorkDoc->GetNewDBMgr();
                             pWorkDoc->SetNewDBMgr( this );
                             pWorkDoc->EmbedAllLinks();
@@ -1205,19 +1208,15 @@ sal_Bool SwNewDBMgr::MergeMailFiles(SwWrtShell* pSourceShell,
                                     pTargetPageDesc = pTargetShell->FindPageDescByName( sModifiedStartingPageDesc );
 
                                 sal_uInt16 nStartPage = pTargetShell->GetPageCnt();
-#ifdef DBG_UTIL
-                                if ( nDocNo <= MAX_DOC_DUMP )
+                                if ( (nMaxDumpDocs < 0) || (nDocNo <= nMaxDumpDocs) )
                                     lcl_SaveDoc( xWorkDocSh, "WorkDoc", nDocNo );
-#endif
                                 pTargetDoc->AppendDoc(*rWorkShell.GetDoc(),
                                     nStartingPageNo, pTargetPageDesc, nDocNo == 1);
 
                                 // #i72820# calculate layout to be able to find the correct page index
                                 pTargetShell->CalcLayout();
-#ifdef DBG_UTIL
-                                if ( nDocNo <= MAX_DOC_DUMP )
+                                if ( (nMaxDumpDocs < 0) || (nDocNo <= nMaxDumpDocs) )
                                     lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
-#endif
                                 if (bMergeOnly)
                                 {
                                     SwDocMergeInfo aMergeInfo;
commit 4896a4984473857d5b12df69a287c44c485105b7
Author: Michael Stahl <mstahl at redhat.com>
Date:   Fri Sep 12 21:50:36 2014 +0200

    :sw: rename SwDoc::Append to something unique
    
    (cherry picked from commit 3b11057b75434526f67e678ddc1deb9ebd61c752)
    
    Conflicts:
    	sw/source/uibase/dbui/dbmgr.cxx
    

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list