[Libreoffice-commits] core.git: Branch 'feature/mailmerge-toolbar' - 1303 commits - accessibility/inc accessibility/source android/Bootstrap android/source animations/Library_animcore.mk animations/source avmedia/source basctl/inc basctl/source basebmp/CppunitTest_basebmp.mk basebmp/inc basebmp/Library_basebmp.mk basebmp/Makefile basebmp/Module_basebmp.mk basebmp/README basebmp/source basebmp/StaticLibrary_basebmp.mk basebmp/test basegfx/source basegfx/test basic/inc basic/qa basic/source bean/com bean/Module_bean.mk bin/distro-install-desktop-integration bin/distro-install-file-lists bin/find-german-comments bin/fuzzfiles bin/gen-iwyu-dummy-lib bin/lo-all-static-libs bin/update_pch bin/update_pch_autotune.sh bin/update_pch_bisect bridges/source bridges/test canvas/source canvas/workben chart2/inc chart2/qa chart2/source clew/Library_clew.mk cli_ure/qa cli_ure/readme.txt cli_ure/source codemaker/source comphelper/CppunitTest_comphelper_ifcontainer.mk comphelper/CppunitTest_comphelper_test.mk comp helper/Library_comphelper.mk comphelper/Module_comphelper.mk comphelper/qa comphelper/source compilerplugins/clang config.guess config_host/config_clang.h.in config_host.mk.in configmgr/source configure.ac connectivity/inc connectivity/Library_tdeab1.mk connectivity/Module_connectivity.mk connectivity/qa connectivity/source cppcanvas/source cppuhelper/source cppu/qa cppu/source cui/inc cui/source cui/uiconfig dbaccess/qa dbaccess/source desktop/CppunitTest_desktop_lib.mk desktop/inc desktop/Library_sofficeapp.mk desktop/qa desktop/source desktop/unx dictionaries distro-configs/LibreOfficeAndroidAarch64.conf distro-configs/LibreOfficeAndroid.conf distro-configs/LibreOfficeAndroidX86.conf download.lst drawinglayer/source dtrans/source dtrans/test editeng/inc editeng/qa editeng/source embeddedobj/source embeddedobj/test embedserv/source extensions/source extensions/test extensions/workben external/boost external/cairo external/clucene external/firebird external/graphite external/icu ex ternal/libetonyek external/liblangtag external/libxml2 external/libxmlsec external/libxslt external/Module_external.mk external/openssl external/python3 external/python33 external/redland external/unixODBC external/vigra extras/source filter/Configuration_filter.mk filter/Library_gie.mk filter/qa filter/source forms/qa forms/source formula/source fpicker/source framework/inc framework/JunitTest_framework_complex.mk framework/Library_fwe.mk framework/qa framework/README framework/source g .gitignore helpcompiler/inc helpcompiler/source helpcontent2 hwpfilter/source i18nlangtag/qa i18nlangtag/source i18npool/inc i18npool/Library_localedata_euro.mk i18npool/source icon-themes/breeze icon-themes/crystal icon-themes/elementary icon-themes/galaxy icon-themes/hicontrast icon-themes/human icon-themes/industrial icon-themes/oxygen icon-themes/sifr icon-themes/tango icon-themes/tango_testing idlc/inc idlc/source idl/inc idl/source include/basebmp include/basegfx include/basic include/comphelp er include/connectivity include/cppuhelper include/dbaccess include/drawinglayer include/editeng include/filter include/formula include/framework include/helpcompiler include/i18nlangtag include/jvmfwk include/LibreOfficeKit include/linguistic include/o3tl include/oox include/osl include/postx.h include/registry include/rsc include/rtl include/sal include/sax include/sfx2 include/sot include/store include/svl include/svtools include/svx include/toolkit include/tools include/ucbhelper include/uno include/unotools include/vcl include/xmloff instsetoo_native/inc_openoffice ios/CustomTarget_Lo_Xcconfig.mk io/source ios/README io/test jurt/com jvmfwk/plugins jvmfwk/source l10ntools/inc l10ntools/source libreofficekit/Module_libreofficekit.mk libreofficekit/Package_selectionhandles.mk libreofficekit/qa libreofficekit/README libreofficekit/source lingucomponent/Library_hyphen.mk lingucomponent/Library_MacOSXSpell.mk lingucomponent/Library_spell.mk lingucomponent/source linguistic/source li nguistic/workben lotuswordpro/Library_lwpft.mk lotuswordpro/source lotuswordpro/util Makefile.fetch Makefile.in mysqlc/source nlpsolver/src nlpsolver/ThirdParty o3tl/qa odk/config odk/docs odk/examples odk/index.html odk/index_online.html offapi/com offapi/type_reference officecfg/registry officecfg/util onlineupdate/Executable_updater.mk onlineupdate/source oox/inc oox/source package/inc package/source postprocess/CppunitTest_services.mk postprocess/CustomTarget_images.mk postprocess/CustomTarget_registry.mk postprocess/packimages pyuno/CustomTarget_zipcore.mk pyuno/qa pyuno/source qadevOOo/runner qadevOOo/tests readlicense_oo/docs readlicense_oo/license readlicense_oo/Module_readlicense_oo.mk readlicense_oo/Package_readlicense_oo_readmes.mk README.md registry/source registry/tools reportbuilder/java reportdesign/inc reportdesign/source RepositoryExternal.mk Repository.mk RepositoryModule_build.mk RepositoryModule_host.mk rsc/inc rsc/source sal/cppunittester salhelper/source sal/in c sal/osl sal/qa sal/rtl sal/workben sax/qa sax/source sc/CppunitTest_sc_ucalc.mk sc/inc sc/Library_sc.mk sc/Library_scui.mk scp2/InstallModule_ooo.mk scp2/source sc/qa scripting/examples scripting/java scripting/Library_stringresource.mk scripting/source sc/sdi sc/source sc/uiconfig sc/UIConfig_scalc.mk sd/CppunitTest_sd_export_tests.mk sdext/source sd/inc sd/qa sd/source sd/uiconfig setup_native/scripts setup_native/source sfx2/AllLangResTarget_sfx2.mk sfx2/inc sfx2/README sfx2/sdi sfx2/source sfx2/uiconfig shell/source slideshow/inc slideshow/opengl slideshow/Package_opengl.mk slideshow/source slideshow/test solenv/bin solenv/doc solenv/gbuild solenv/inc soltools/cpp soltools/mkdepend sot/Library_sot.mk sot/source sot/util starmath/inc starmath/qa starmath/source stoc/source stoc/test store/source svgio/inc svgio/source svl/source svl/unx svtools/inc svtools/source svtools/uiconfig svx/inc svx/Library_svx.mk svx/sdi svx/source svx/uiconfig sw/CppunitTest_sw_globalfilter.mk sw/Cpp unitTest_sw_odfexport.mk sw/CppunitTest_sw_odfimport.mk sw/CppunitTest_sw_ooxmlfieldexport.mk sw/CppunitTest_sw_ooxmlimport.mk sw/CppunitTest_sw_ooxmlw14export.mk sw/CppunitTest_sw_rtfexport.mk sw/CppunitTest_sw_rtfimport.mk sw/CppunitTest_sw_uiwriter.mk sw/CppunitTest_sw_ww8import.mk swext/mediawiki sw/inc sw/Library_sw.mk sw/Library_swui.mk sw/ooxmlexport_setup.mk sw/qa sw/sdi sw/source sw/uiconfig sw/UIConfig_sglobal.mk sw/UIConfig_sweb.mk sw/UIConfig_swform.mk sw/UIConfig_swreport.mk sw/UIConfig_swriter.mk sw/UIConfig_swxform.mk sw/util sysui/desktop test/source testtools/qa testtools/source toolkit/Library_tk.mk toolkit/qa toolkit/source toolkit/test tools/source translations ucb/CppunitTest_ucb_webdav_local_neon.mk ucbhelper/source ucb/Library_srtrs1.mk ucb/Module_ucb.mk ucb/qa ucb/source udkapi/com UnoControls/inc unotest/source unotools/source unoxml/source unusedcode.easy unusedcode.exclude vbahelper/inc vbahelper/source vcl/android vcl/CppunitTest_vcl_bitmap_test.mk vcl/Cp punitTest_vcl_fontmetric.mk vcl/CppunitTest_vcl_font.mk vcl/CustomTarget_afm_hash.mk vcl/generic vcl/headless vcl/inc vcl/ios vcl/Library_vcl.mk vcl/Library_vclplug_gen.mk vcl/Library_vclplug_gtk3.mk vcl/Module_vcl.mk vcl/null vcl/opengl vcl/osx vcl/Package_opengl_blacklist.mk vcl/qa vcl/quartz vcl/README vcl/README.lifecycle vcl/source vcl/unx vcl/win vcl/workben winaccessibility/inc winaccessibility/source wizards/com wizards/source writerfilter/documentation writerfilter/inc writerfilter/source writerperfect/CppunitTest_writerperfect_impress.mk writerperfect/source xmerge/source xmlhelp/Library_ucpchelp1.mk xmlhelp/source xmloff/dtd xmloff/inc xmloff/source xmloff/util xmlscript/source xmlscript/test xmlsecurity/CppunitTest_xmlsecurity_signing.mk xmlsecurity/inc xmlsecurity/Library_xmlsecurity.mk xmlsecurity/Module_xmlsecurity.mk xmlsecurity/qa xmlsecurity/source xmlsecurity/uiconfig

Jan Holesovsky kendy at collabora.com
Wed Jan 27 08:37:54 PST 2016


Rebased ref, commits from common ancestor:
commit 77752c75d54d2fcc4f6f5f129d35e5abe5c6c7b9
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 6 12:07:55 2016 +0100

    mailmerge: Create the target view independantly of the mailmerge execution.
    
    Change-Id: Ib6a53b89b0fe2a30eac104afd1c8fe75d2348edd

diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 40403b6..4e9b025 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -245,7 +245,7 @@ friend class SwConnectionDisposedListener_Impl;
         return css::uno::Reference<css::beans::XPropertySet>( xRowSet, css::uno::UNO_QUERY );
     }
 
-    SAL_DLLPRIVATE void CreateDumpDocs(sal_Int32 &nMaxDumpDocs);
+    SAL_DLLPRIVATE static sal_Int32 GetMaxDumpDocs();
 
     SAL_DLLPRIVATE void SetSourceProp(SwDocShell* pSourceDocSh);
 
@@ -257,11 +257,6 @@ friend class SwConnectionDisposedListener_Impl;
                                       const SwMergeDescriptor& rMergeDescriptor,  const SfxFilter* pStoreToFilter);
 
 
-    SAL_DLLPRIVATE void CreateTargetDocShell(sal_Int32 nMaxDumpDocs, bool bMergeShell, vcl::Window *pSourceWindow,
-                                             SwWrtShell *pSourceShell, SwDocShell *pSourceDocSh,
-                                             SfxObjectShellRef &xTargetDocShell, SwDoc *&pTargetDoc,
-                                             SwWrtShell *&pTargetShell, SwView  *&pTargetView);
-
     SAL_DLLPRIVATE void LockUnlockDisp(bool bLock, SwDocShell *pSourceDocSh);
 
     SAL_DLLPRIVATE void CreateWorkDoc(SfxObjectShellLock &xWorkDocSh, SwView *&pWorkView, SwDoc *&pWorkDoc, SwDBManager *&pOldDBManager,
@@ -505,6 +500,10 @@ public:
     SwDoc* getDoc() const;
     /// Stop reacting to removed database registrations.
     void releaseRevokeListener();
+
+    /// Creates & sets up the target docshell.
+    static SwView* CreateTargetDocShell(bool bMergeShell, vcl::Window *pSourceWindow,
+            SwWrtShell *pSourceShell, SwDocShell *pSourceDocSh);
 };
 
 #endif
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index f219cdd..ca57274 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -55,6 +55,7 @@
 #include <sfx2/objface.hxx>
 #include <sfx2/app.hxx>
 
+#include <edtwin.hxx>
 #include <view.hxx>
 #include <pview.hxx>
 #include <srcview.hxx>
@@ -779,6 +780,8 @@ void SwModule::ExecOther(SfxRequest& rReq)
             aDescriptor[ svx::daSelection ]   <<= pConfigItem->GetSelection();
 
             SwWrtShell& rSh = pView->GetWrtShell();
+            pConfigItem->SetTargetView(nullptr);
+
             SwMergeDescriptor aMergeDesc(DBMGR_MERGE_SHELL, rSh, aDescriptor);
             aMergeDesc.pMailMergeConfigItem = pConfigItem;
             aMergeDesc.bCreateSingleFile = true;
@@ -789,21 +792,28 @@ void SwModule::ExecOther(SfxRequest& rReq)
                 pConfigItem->GetTargetView()->GetViewFrame()->GetFrame().Appear();
         }
         case FN_MAILMERGE_SAVE_DOCUMENTS:
-        {
-            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            pFact->ExecuteMMResultSaveDialog();
-        }
-        break;
         case FN_MAILMERGE_PRINT_DOCUMENTS:
-        {
-            SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            pFact->ExecuteMMResultPrintDialog();
-        }
-        break;
         case FN_MAILMERGE_EMAIL_DOCUMENTS:
         {
+            SwView* pView = ::GetActiveView();
+            SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
+            if (!pConfigItem)
+                return;
+
+            if (!pConfigItem->GetTargetView())
+            {
+                SwView* pSourceView = pConfigItem->GetSourceView();
+                assert(pSourceView);
+                pConfigItem->SetTargetView(SwDBManager::CreateTargetDocShell(true, &pSourceView->GetEditWin(), pSourceView->GetWrtShellPtr(), pSourceView->GetDocShell()));
+            }
+
             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            pFact->ExecuteMMResultEmailDialog();
+            switch (nWhich)
+            {
+                case FN_MAILMERGE_SAVE_DOCUMENTS: pFact->ExecuteMMResultSaveDialog(); break;
+                case FN_MAILMERGE_PRINT_DOCUMENTS: pFact->ExecuteMMResultPrintDialog(); break;
+                case FN_MAILMERGE_EMAIL_DOCUMENTS: pFact->ExecuteMMResultEmailDialog(); break;
+            }
         }
         break;
 #endif
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 5e04fe8..5d420c2 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -942,9 +942,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
     OUString sBodyMimeType;
     rtl_TextEncoding eEncoding = ::osl_getThreadTextEncoding();
 
-    static sal_Int32 nMaxDumpDocs = 0;
-
-    CreateDumpDocs(nMaxDumpDocs);
+    const sal_Int32 nMaxDumpDocs = GetMaxDumpDocs();
 
     if(bEMail)
     {
@@ -994,12 +992,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
             bCancel = false;
 
             // in case of creating a single resulting file this has to be created here
+            SwView* pTargetView = rMergeDescriptor.pMailMergeConfigItem->GetTargetView();
             SwWrtShell* pTargetShell = nullptr;
             SwDoc* pTargetDoc = nullptr;
+            SfxObjectShellRef xTargetDocShell = nullptr;
 
-            SfxObjectShellRef xTargetDocShell;
-
-            SwView* pTargetView = nullptr;
             std::unique_ptr< utl::TempFile > aTempFile;
             bool createTempFile = ( bEMail || rMergeDescriptor.nMergeType == DBMGR_MERGE_FILE );
             OUString sModifiedStartingPageDesc;
@@ -1016,12 +1013,20 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                     pSourceWindow, pProgressDlg, bMergeShell, pSourceShell, pParent);
             }
 
-            if (bCreateSingleFile)
+            if (bCreateSingleFile && !pTargetView)
             {
-                CreateTargetDocShell(nMaxDumpDocs, bMergeShell, pSourceWindow, pSourceShell,
-                        pSourceDocSh, xTargetDocShell, pTargetDoc,
-                        pTargetShell, pTargetView);
+                pTargetView = CreateTargetDocShell(bMergeShell, pSourceWindow, pSourceShell, pSourceDocSh);
+            }
+
+            if (pTargetView)
+            {
+                pTargetShell = pTargetView->GetWrtShellPtr();
+                pTargetDoc = pTargetShell->GetDoc();
+                xTargetDocShell = pTargetView->GetDocShell();
+            }
 
+            if (bCreateSingleFile)
+            {
                 // determine the page style and number used at the start of the source document
                 pSourceShell->SttEndDoc(true);
                 nStartingPageNo = pSourceShell->GetVirtPageNum();
@@ -1293,8 +1298,9 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
     return bNoError;
 }
 
-void SwDBManager::CreateDumpDocs(sal_Int32 &nMaxDumpDocs)
+sal_Int32 SwDBManager::GetMaxDumpDocs()
 {
+    static sal_Int32 nMaxDumpDocs = 0;
     static const char *sMaxDumpDocs = nullptr;
 
     if (!sMaxDumpDocs)
@@ -1305,6 +1311,8 @@ void SwDBManager::CreateDumpDocs(sal_Int32 &nMaxDumpDocs)
         else
             nMaxDumpDocs = rtl_ustr_toInt32(reinterpret_cast<const sal_Unicode*>( sMaxDumpDocs ), 10);
     }
+
+    return nMaxDumpDocs;
 }
 
 void SwDBManager::SetSourceProp(SwDocShell* pSourceDocSh)
@@ -1365,10 +1373,13 @@ SwView* SwDBManager::CreateTargetDocShell(bool bMergeShell, vcl::Window *pSource
         SwWrtShell *pSourceShell, SwDocShell *pSourceDocSh)
 {
     // create a target docshell to put the merged document into
-    xTargetDocShell = new SwDocShell( SfxObjectCreateMode::STANDARD );
+    SfxObjectShellRef xTargetDocShell = new SwDocShell( SfxObjectCreateMode::STANDARD );
     xTargetDocShell->DoInitNew( );
+
+    const sal_Int32 nMaxDumpDocs = GetMaxDumpDocs();
     if (nMaxDumpDocs)
-        lcl_SaveDoc( xTargetDocShell, "MergeDoc" );
+        lcl_SaveDoc(xTargetDocShell, "MergeDoc");
+
     SfxViewFrame* pTargetFrame = SfxViewFrame::LoadHiddenDocument( *xTargetDocShell, 0 );
     if (bMergeShell && pSourceWindow)
     {
@@ -1377,12 +1388,12 @@ SwView* SwDBManager::CreateTargetDocShell(bool bMergeShell, vcl::Window *pSource
         rTargetWindow.SetPosPixel(pSourceWindow->GetPosPixel());
     }
 
-    pTargetView = static_cast<SwView*>( pTargetFrame->GetViewShell() );
+    SwView *pTargetView = static_cast<SwView*>(pTargetFrame->GetViewShell());
 
     //initiate SelectShell() to create sub shells
     pTargetView->AttrChangedNotify( &pTargetView->GetWrtShell() );
-    pTargetShell = pTargetView->GetWrtShellPtr();
-    pTargetDoc = pTargetShell->GetDoc();
+    SwWrtShell *pTargetShell = pTargetView->GetWrtShellPtr();
+    SwDoc *pTargetDoc = pTargetShell->GetDoc();
     pTargetDoc->SetInMailMerge(true);
 
     //copy the styles from the source to the target document
@@ -1394,6 +1405,8 @@ SwView* SwDBManager::CreateTargetDocShell(bool bMergeShell, vcl::Window *pSource
     pTargetShell->GetDoc()->ReplaceDefaults( *pSourceShell->GetDoc());
 
     pTargetShell->GetDoc()->ReplaceDocumentProperties( *pSourceShell->GetDoc());
+
+    return pTargetView;
 }
 
 void SwDBManager::LockUnlockDisp(bool bLock, SwDocShell *pSourceDocSh)
commit 9b12406b2421d4b1dce12789871636c947eb5676
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 6 10:32:24 2016 +0100

    mailmerge: nStartingPageNo and sStartingPageDesc shouldn't be return values.
    
    Change-Id: I86a049411c2ec461e66009e6dc54d8ea086e7f12

diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index fb20216..40403b6 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -260,8 +260,7 @@ friend class SwConnectionDisposedListener_Impl;
     SAL_DLLPRIVATE void CreateTargetDocShell(sal_Int32 nMaxDumpDocs, bool bMergeShell, vcl::Window *pSourceWindow,
                                              SwWrtShell *pSourceShell, SwDocShell *pSourceDocSh,
                                              SfxObjectShellRef &xTargetDocShell, SwDoc *&pTargetDoc,
-                                             SwWrtShell *&pTargetShell, SwView  *&pTargetView,
-                                             sal_uInt16 &nStartingPageNo, OUString &sStartingPageDesc);
+                                             SwWrtShell *&pTargetShell, SwView  *&pTargetView);
 
     SAL_DLLPRIVATE void LockUnlockDisp(bool bLock, SwDocShell *pSourceDocSh);
 
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 569bb71..5e04fe8 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1019,8 +1019,13 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
             if (bCreateSingleFile)
             {
                 CreateTargetDocShell(nMaxDumpDocs, bMergeShell, pSourceWindow, pSourceShell,
-                        pSourceDocSh, xTargetDocShell, pTargetDoc, pTargetShell,
-                        pTargetView, nStartingPageNo, sStartingPageDesc);
+                        pSourceDocSh, xTargetDocShell, pTargetDoc,
+                        pTargetShell, pTargetView);
+
+                // determine the page style and number used at the start of the source document
+                pSourceShell->SttEndDoc(true);
+                nStartingPageNo = pSourceShell->GetVirtPageNum();
+                sStartingPageDesc = pSourceShell->GetPageDesc(pSourceShell->GetCurPageDesc()).GetName();
 
                 // #i72517#
                 const SwPageDesc* pSourcePageDesc = pSourceShell->FindPageDescByName(sStartingPageDesc);
@@ -1383,12 +1388,6 @@ SwView* SwDBManager::CreateTargetDocShell(bool bMergeShell, vcl::Window *pSource
     //copy the styles from the source to the target document
     pTargetView->GetDocShell()->_LoadStyles( *pSourceDocSh, true );
 
-    //determine the page style and number used at the start of the source document
-    pSourceShell->SttEndDoc(true);
-    nStartingPageNo = pSourceShell->GetVirtPageNum();
-    sStartingPageDesc = pSourceShell->GetPageDesc(
-        pSourceShell->GetCurPageDesc()).GetName();
-
     // copy compatibility options
     pTargetShell->GetDoc()->ReplaceCompatibilityOptions( *pSourceShell->GetDoc());
     // #72821# copy dynamic defaults
commit 735ff45bed30923ef1ae96526e23eae9c547ca96
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 6 10:12:35 2016 +0100

    mailmerge: bPageStylesWithHeaderFooter should not be a return value.
    
    Change-Id: I8d39b6b031b543e4cc6a31cf57d207b04a19ba38

diff --git a/sw/inc/dbmgr.hxx b/sw/inc/dbmgr.hxx
index 8b0af90..fb20216 100644
--- a/sw/inc/dbmgr.hxx
+++ b/sw/inc/dbmgr.hxx
@@ -257,7 +257,7 @@ friend class SwConnectionDisposedListener_Impl;
                                       const SwMergeDescriptor& rMergeDescriptor,  const SfxFilter* pStoreToFilter);
 
 
-    SAL_DLLPRIVATE bool CreateTargetDocShell(sal_Int32 nMaxDumpDocs, bool bMergeShell, vcl::Window *pSourceWindow,
+    SAL_DLLPRIVATE void CreateTargetDocShell(sal_Int32 nMaxDumpDocs, bool bMergeShell, vcl::Window *pSourceWindow,
                                              SwWrtShell *pSourceShell, SwDocShell *pSourceDocSh,
                                              SfxObjectShellRef &xTargetDocShell, SwDoc *&pTargetDoc,
                                              SwWrtShell *&pTargetShell, SwView  *&pTargetView,
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index 3365251..569bb71 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1016,11 +1016,16 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                     pSourceWindow, pProgressDlg, bMergeShell, pSourceShell, pParent);
             }
 
-            if(bCreateSingleFile)
+            if (bCreateSingleFile)
             {
-                bPageStylesWithHeaderFooter = CreateTargetDocShell(nMaxDumpDocs, bMergeShell, pSourceWindow, pSourceShell,
-                                                                   pSourceDocSh, xTargetDocShell, pTargetDoc, pTargetShell,
-                                                                   pTargetView, nStartingPageNo, sStartingPageDesc);
+                CreateTargetDocShell(nMaxDumpDocs, bMergeShell, pSourceWindow, pSourceShell,
+                        pSourceDocSh, xTargetDocShell, pTargetDoc, pTargetShell,
+                        pTargetView, nStartingPageNo, sStartingPageDesc);
+
+                // #i72517#
+                const SwPageDesc* pSourcePageDesc = pSourceShell->FindPageDescByName(sStartingPageDesc);
+                const SwFrameFormat& rMaster = pSourcePageDesc->GetMaster();
+                bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive() || rMaster.GetFooter().IsActive();
 
                 sModifiedStartingPageDesc = sStartingPageDesc;
             }
@@ -1351,11 +1356,8 @@ bool SwDBManager::CreateNewTemp(OUString &sPath, const OUString &sAddress,
     return bErr;
 }
 
-bool SwDBManager::CreateTargetDocShell(sal_Int32 nMaxDumpDocs, bool bMergeShell, vcl::Window *pSourceWindow,
-                                       SwWrtShell *pSourceShell, SwDocShell *pSourceDocSh,
-                                       SfxObjectShellRef &xTargetDocShell, SwDoc *&pTargetDoc,
-                                       SwWrtShell *&pTargetShell, SwView  *&pTargetView,
-                                       sal_uInt16 &nStartingPageNo, OUString &sStartingPageDesc)
+SwView* SwDBManager::CreateTargetDocShell(bool bMergeShell, vcl::Window *pSourceWindow,
+        SwWrtShell *pSourceShell, SwDocShell *pSourceDocSh)
 {
     // create a target docshell to put the merged document into
     xTargetDocShell = new SwDocShell( SfxObjectCreateMode::STANDARD );
@@ -1387,20 +1389,12 @@ bool SwDBManager::CreateTargetDocShell(sal_Int32 nMaxDumpDocs, bool bMergeShell,
     sStartingPageDesc = pSourceShell->GetPageDesc(
         pSourceShell->GetCurPageDesc()).GetName();
 
-    // #i72517#
-    const SwPageDesc* pSourcePageDesc = pSourceShell->FindPageDescByName( sStartingPageDesc );
-    const SwFrameFormat& rMaster = pSourcePageDesc->GetMaster();
-    bool bPageStylesWithHeaderFooter = rMaster.GetHeader().IsActive()  ||
-                                       rMaster.GetFooter().IsActive();
-
     // copy compatibility options
     pTargetShell->GetDoc()->ReplaceCompatibilityOptions( *pSourceShell->GetDoc());
     // #72821# copy dynamic defaults
     pTargetShell->GetDoc()->ReplaceDefaults( *pSourceShell->GetDoc());
 
     pTargetShell->GetDoc()->ReplaceDocumentProperties( *pSourceShell->GetDoc());
-
-    return bPageStylesWithHeaderFooter;
 }
 
 void SwDBManager::LockUnlockDisp(bool bLock, SwDocShell *pSourceDocSh)
commit d6691af388d884d5774d595404adde52c859dacc
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Jan 6 10:05:19 2016 +0100

    This assert is useless.
    
    Change-Id: I2a76f449d4fb3452583407dc3cbb73f10a3d1705

diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index f3f1b6c..3365251 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -1090,7 +1090,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
 
                         UpdateExpFields(rWorkShell, xWorkDocSh);
 
-                        if(bCreateSingleFile)
+                        if (bCreateSingleFile)
                         {
                             MergeSingleFiles(pWorkDoc, rWorkShell, pTargetShell, pTargetDoc, xWorkDocSh, xTargetDocShell,
                                              bPageStylesWithHeaderFooter, bSynchronizedDoc, sModifiedStartingPageDesc,
@@ -1100,7 +1100,6 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell,
                         }
                         else if( rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER )
                         {
-                            assert(!bCreateSingleFile);
                             if( 1 == nDocNo ) // set up printing only once at the beginning
                             {
                                 // printing should be done synchronously otherwise the document
commit eac9623f585328f193f20a897ad15874d814ab7d
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 5 11:16:51 2016 +0100

    mailmerge: Kill SwMailMergeChildWindow.
    
    It was used to return to the Mail Merge wizard after pressing the [Edit
    Document] button in the wizard.  The wizard pages that had such a button are
    gone now, so the childwindow for returning to the wizard can go too.
    
    Change-Id: I53284633979179fd67ed6fd21a2188aa859a8a22

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index f8c16b7..21bb231 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -766,7 +766,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/uibase/dbui/dbtree \
     sw/source/uibase/dbui/dbui \
     sw/source/uibase/dbui/maildispatcher \
-    sw/source/uibase/dbui/mailmergechildwindow \
     sw/source/uibase/dbui/mailmergehelper \
     sw/source/uibase/dbui/mailmergetoolbarcontrols \
     sw/source/uibase/dbui/mmconfigitem \
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index b9c655e..5440955 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -127,7 +127,6 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
 	sw/uiconfig/swriter/ui/fldfuncpage \
 	sw/uiconfig/swriter/ui/fldrefpage \
 	sw/uiconfig/swriter/ui/fldvarpage \
-	sw/uiconfig/swriter/ui/floatingmmchild \
 	sw/uiconfig/swriter/ui/floatingnavigation \
 	sw/uiconfig/swriter/ui/floatingsync \
 	sw/uiconfig/swriter/ui/formatsectiondialog \
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index bbb953e..09cd1f4 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -249,7 +249,6 @@
 #define FN_MAILMERGE_WIZARD     (FN_INSERT + 64)    /* mail merge wizard */
 #define FN_TOOL_ANCHOR_FRAME    (FN_INSERT + 66)    /* anchor Draw-Object to frame*/
 #define FN_QRY_MERGE            (FN_INSERT + 67)    /* insert record (serial letter) */
-#define FN_MAILMERGE_CHILDWINDOW (FN_INSERT + 68)   /* back-to-mail-merge-wizard child window*/
 #define FN_INSERT_SMA           (FN_INSERT + 69)    /* insert StarMath  */
 
 #define FN_MAILMERGE_FIRST_ENTRY (FN_INSERT + 70)   /* mail merge toolbar - go to the first entry */
diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index b51b280..b418d3e 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -300,8 +300,6 @@ public:
 };
 
 #define RET_LOAD_DOC            100
-#define RET_EDIT_DOC            101
-#define RET_EDIT_RESULT_DOC     102
 #define RET_TARGET_CREATED      103
 #define RET_REMOVE_TARGET       104
 
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index 58573f4..6daee62 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -574,11 +574,6 @@ interface BaseTextEditView
     [
         ExecMethod = Execute ;
     ]
-    FN_MAILMERGE_CHILDWINDOW
-    [
-        ExecMethod = Execute ;
-        StateMethod = GetState;
-    ]
 
     FN_MAILMERGE_SENDMAIL_CHILDWINDOW
     [
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 3a70fe9..67321ca 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -9599,30 +9599,6 @@ SfxBoolItem RowSplit FN_TABLE_ROW_SPLIT
         GroupId = GID_FORMAT;
 ]
 
-SfxBoolItem MailmergeChildWindow FN_MAILMERGE_CHILDWINDOW
-()
-[
-    /* flags: */
-    AutoUpdate = FALSE,
-    Cachable = Cachable,
-    FastCall = FALSE,
-    HasCoreId = FALSE,
-    HasDialog = FALSE,
-    ReadOnlyDoc = FALSE,
-    Toggle = FALSE,
-    Container = FALSE,
-    RecordAbsolute = FALSE,
-    RecordPerSet;
-    Asynchron;
-
-    /* config: */
-    AccelConfig = FALSE,
-    MenuConfig = FALSE,
-    StatusBarConfig = FALSE,
-    ToolBoxConfig = FALSE,
-    GroupId = GID_EDIT;
-]
-
 SfxVoidItem WordCountDialog FN_WORDCOUNT_DIALOG
 ()
 [
diff --git a/sw/source/ui/dbui/mmresultdialogs.cxx b/sw/source/ui/dbui/mmresultdialogs.cxx
index 104395a..2c5d2b1 100644
--- a/sw/source/ui/dbui/mmresultdialogs.cxx
+++ b/sw/source/ui/dbui/mmresultdialogs.cxx
@@ -20,7 +20,6 @@
 #include <mmresultdialogs.hxx>
 #include <mailmergewizard.hxx>
 #include <mmconfigitem.hxx>
-#include <mailmergechildwindow.hxx>
 #include <mailconfigpage.hxx>
 #include <swmessdialog.hxx>
 #include <cmdid.h>
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index 277b266..f219cdd 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -83,7 +83,6 @@
 #include <uinums.hxx>
 #include <dbconfig.hxx>
 #include <mmconfigitem.hxx>
-#include <mailmergechildwindow.hxx>
 #include <linguistic/lngprops.hxx>
 #include <editeng/unolingu.hxx>
 #include <com/sun/star/beans/XMultiPropertySet.hpp>
@@ -381,25 +380,8 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs
     // keep self alive until done.
     acquire();
 
-    // if called from the child window - get the config item and close the ChildWindow, then restore
-    // the wizard
-    SwMailMergeChildWindow* pChildWin =
-        static_cast<SwMailMergeChildWindow*>(m_pView->GetViewFrame()->GetChildWindow(FN_MAILMERGE_CHILDWINDOW));
-    bool bRestoreWizard = false;
-    sal_uInt16 nRestartPage = 0;
-
-    SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem();
-    if (pChildWin && pChildWin->IsVisible())
-    {
-        nRestartPage = m_pView->GetMailMergeRestartPage();
-        if (m_pView->IsMailMergeSourceView())
-            pMMConfig->SetSourceView(m_pView);
-        SfxViewFrame* pViewFrame = m_pView->GetViewFrame();
-        pViewFrame->ShowChildWindow(FN_MAILMERGE_CHILDWINDOW, false);
-        bRestoreWizard = true;
-    }
-
     // create if it does not exist yet
+    SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem();
     if (!pMMConfig)
     {
         pMMConfig = new SwMailMergeConfigItem;
@@ -459,11 +441,6 @@ void SwMailMergeWizardExecutor::ExecuteMailMergeWizard( const SfxItemSet * pArgs
     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     m_pWizard = pFact->CreateMailMergeWizard(*m_pView, *pMMConfig);
 
-    if (bRestoreWizard)
-    {
-        m_pWizard->ShowPage(nRestartPage);
-    }
-
     ExecuteWizard();
 }
 
@@ -543,21 +520,6 @@ IMPL_LINK_NOARG_TYPED( SwMailMergeWizardExecutor, EndDialogHdl, Dialog&, void )
             }
             break;
         }
-    case RET_EDIT_DOC:
-    case RET_EDIT_RESULT_DOC:
-        {
-            //create a non-modal dialog that allows to return to the wizard
-            //the ConfigItem ownership moves to this dialog
-            SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem();
-            bool bResult = nRet == RET_EDIT_RESULT_DOC && pMMConfig->GetTargetView();
-            SwView* pTempView = bResult ? pMMConfig->GetTargetView() : pMMConfig->GetSourceView();
-            pTempView->SetMailMergeConfigItem(pMMConfig, m_pWizard->GetRestartPage(), !bResult);
-            SfxViewFrame* pViewFrame = pTempView->GetViewFrame();
-            pViewFrame->GetDispatcher()->Execute(
-                FN_MAILMERGE_CHILDWINDOW, SfxCallMode::SYNCHRON);
-            ExecutionFinished();
-            break;
-        }
     case RET_REMOVE_TARGET:
         {
             SwMailMergeConfigItem* pMMConfig = m_pView->GetMailMergeConfigItem();
diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx
index 2c3559b..fa02efb 100644
--- a/sw/source/uibase/app/swmodule.cxx
+++ b/sw/source/uibase/app/swmodule.cxx
@@ -98,7 +98,6 @@
 #include <fldwrap.hxx>
 #include <redlndlg.hxx>
 #include <syncbtn.hxx>
-#include <mailmergechildwindow.hxx>
 #include <modcfg.hxx>
 #include <fontcfg.hxx>
 #include <sfx2/sidebar/SidebarChildWindow.hxx>
@@ -350,7 +349,6 @@ void SwDLL::RegisterControls()
     SwInputChild::RegisterChildWindow( false, pMod, SfxChildWindowFlags::FORCEDOCK );
     SwRedlineAcceptChild::RegisterChildWindow( false, pMod );
     SwSyncChildWin::RegisterChildWindow( true, pMod );
-    SwMailMergeChildWindow::RegisterChildWindow( false, pMod );
     SwInsertIdxMarkWrapper::RegisterChildWindow( false, pMod );
     SwInsertAuthMarkWrapper::RegisterChildWindow( false, pMod );
     SwWordCountWrapper::RegisterChildWindow( false, pMod );
diff --git a/sw/source/uibase/dbui/mailmergechildwindow.cxx b/sw/source/uibase/dbui/mailmergechildwindow.cxx
deleted file mode 100644
index ebd2343..0000000
--- a/sw/source/uibase/dbui/mailmergechildwindow.cxx
+++ /dev/null
@@ -1,99 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <sfx2/viewfrm.hxx>
-#include <sfx2/dispatch.hxx>
-
-#include <cmdid.h>
-#include <swmodule.hxx>
-#include <view.hxx>
-#include <edtwin.hxx>
-#include <vcl/layout.hxx>
-#include <mailmergechildwindow.hxx>
-#include <mmconfigitem.hxx>
-#include <svtools/svmedit.hxx>
-#include <vcl/msgbox.hxx>
-#include <vcl/image.hxx>
-#include <dbui.hrc>
-#include <helpid.h>
-
-using namespace ::com::sun::star;
-
-SFX_IMPL_FLOATINGWINDOW( SwMailMergeChildWindow, FN_MAILMERGE_CHILDWINDOW )
-
-SwMailMergeChildWindow::SwMailMergeChildWindow( vcl::Window* _pParent,
-                                sal_uInt16 nId,
-                                SfxBindings* pBindings,
-                                SfxChildWinInfo* pInfo ) :
-                                SfxChildWindow( _pParent, nId )
-{
-    SetWindow( VclPtr<SwMailMergeChildWin>::Create( pBindings, this, _pParent) );
-
-    if (!pInfo->aSize.Width() || !pInfo->aSize.Height())
-    {
-        SwView* pActiveView = ::GetActiveView();
-        if(pActiveView)
-        {
-            const SwEditWin &rEditWin = pActiveView->GetEditWin();
-            GetWindow()->SetPosPixel(rEditWin.OutputToScreenPixel(Point(0, 0)));
-        }
-        else
-            GetWindow()->SetPosPixel(_pParent->OutputToScreenPixel(Point(0, 0)));
-        pInfo->aPos = GetWindow()->GetPosPixel();
-        pInfo->aSize = GetWindow()->GetSizePixel();
-    }
-
-    static_cast<SwMailMergeChildWin *>(GetWindow())->Initialize(pInfo);
-    GetWindow()->Show();
-}
-
-SwMailMergeChildWin::SwMailMergeChildWin(SfxBindings* _pBindings,
-    SfxChildWindow* pChild, vcl::Window *pParent)
-    : SfxFloatingWindow(_pBindings, pChild, pParent, "FloatingMMChild",
-                        "modules/swriter/ui/floatingmmchild.ui")
-{
-    get(m_pBackTB, "back");
-    m_pBackTB->SetSelectHdl(LINK(this, SwMailMergeChildWin, BackHdl));
-    m_pBackTB->SetButtonType( ButtonType::SYMBOLTEXT );
-}
-
-SwMailMergeChildWin::~SwMailMergeChildWin()
-{
-    disposeOnce();
-}
-
-void SwMailMergeChildWin::dispose()
-{
-    m_pBackTB.clear();
-    SfxFloatingWindow::dispose();
-}
-
-IMPL_LINK_NOARG_TYPED(SwMailMergeChildWin, BackHdl, ToolBox *, void)
-{
-    GetBindings().GetDispatcher()->Execute(FN_MAILMERGE_WIZARD, SfxCallMode::ASYNCHRON);
-}
-
-void SwMailMergeChildWin::FillInfo(SfxChildWinInfo& rInfo) const
-{
-    SfxFloatingWindow::FillInfo(rInfo);
-    rInfo.aWinState.clear();
-    rInfo.bVisible = false;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/mailmergechildwindow.hxx b/sw/source/uibase/inc/mailmergechildwindow.hxx
deleted file mode 100644
index 8b5fd12..0000000
--- a/sw/source/uibase/inc/mailmergechildwindow.hxx
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_MAILMERGECHILDWINDOW_HXX
-#define INCLUDED_SW_SOURCE_UIBASE_INC_MAILMERGECHILDWINDOW_HXX
-#include <sfx2/childwin.hxx>
-#include <sfx2/basedlgs.hxx>
-#include <vcl/toolbox.hxx>
-#include "swdllapi.h"
-
-class SwMailMergeChildWin : public SfxFloatingWindow
-{
-    VclPtr<ToolBox> m_pBackTB;
-    DECL_LINK_TYPED( BackHdl, ToolBox*, void );
-
-public:
-    SwMailMergeChildWin(SfxBindings*, SfxChildWindow*, vcl::Window *pParent);
-    virtual ~SwMailMergeChildWin();
-    virtual void dispose() override;
-
-    virtual void FillInfo(SfxChildWinInfo&) const override;
-};
-
-class SwMailMergeChildWindow : public SfxChildWindow
-{
-public:
-    SwMailMergeChildWindow( vcl::Window* ,
-                    sal_uInt16 nId,
-                    SfxBindings*,
-                    SfxChildWinInfo*  );
-
-    SFX_DECL_CHILDWINDOW( SwMailMergeChildWindow );
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/uiview/view0.cxx b/sw/source/uibase/uiview/view0.cxx
index 77614df..281b009 100644
--- a/sw/source/uibase/uiview/view0.cxx
+++ b/sw/source/uibase/uiview/view0.cxx
@@ -110,7 +110,6 @@ void SwView::InitInterface_Impl()
     GetStaticInterface()->RegisterChildWindow(FN_INSERT_FIELD_DATA_ONLY);
 
     GetStaticInterface()->RegisterChildWindow(FN_SYNC_LABELS, false, CHILDWIN_LABEL);
-    GetStaticInterface()->RegisterChildWindow(FN_MAILMERGE_CHILDWINDOW, false, CHILDWIN_MAILMERGE);
 
     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER,
                                             RID_TOOLS_TOOLBOX);
diff --git a/sw/source/uibase/uiview/view2.cxx b/sw/source/uibase/uiview/view2.cxx
index a8c83ce..3ad577d 100644
--- a/sw/source/uibase/uiview/view2.cxx
+++ b/sw/source/uibase/uiview/view2.cxx
@@ -799,7 +799,6 @@ void SwView::Execute(SfxRequest &rReq)
             }
         break;
         case FN_SYNC_LABELS:
-        case FN_MAILMERGE_CHILDWINDOW:
             GetViewFrame()->ShowChildWindow(nSlot);
         break;
         case FN_ESCAPE:
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index c37b8d7..3dc3b7a 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -390,14 +390,6 @@ void SwView::GetState(SfxItemSet &rSet)
             break;
             case FN_MAILMERGE_SENDMAIL_CHILDWINDOW:
             break;
-#if HAVE_FEATURE_DBCONNECTIVITY
-            case FN_MAILMERGE_CHILDWINDOW:
-            {
-                if(!GetMailMergeConfigItem())
-                    rSet.DisableItem(nWhich);
-            }
-            break;
-#endif
             case SID_ALIGN_ANY_LEFT :
             case SID_ALIGN_ANY_HCENTER  :
             case SID_ALIGN_ANY_RIGHT    :
diff --git a/sw/uiconfig/swriter/ui/floatingmmchild.ui b/sw/uiconfig/swriter/ui/floatingmmchild.ui
deleted file mode 100644
index af65a14..0000000
--- a/sw/uiconfig/swriter/ui/floatingmmchild.ui
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
-<interface>
-  <requires lib="gtk+" version="3.0"/>
-  <object class="GtkWindow" id="FloatingMMChild">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="no_show_all">True</property>
-    <property name="border_width">6</property>
-    <property name="title" translatable="yes">Mail Merge Wizard</property>
-    <property name="resizable">False</property>
-    <property name="type_hint">utility</property>
-    <property name="deletable">False</property>
-    <child>
-      <object class="GtkBox" id="box1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
-        <property name="orientation">vertical</property>
-        <child>
-          <object class="GtkToolbar" id="back">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-            <property name="toolbar_style">both-horiz</property>
-            <property name="show_arrow">False</property>
-            <child>
-              <object class="GtkToolButton" id="return">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="label" translatable="yes">Return to Mail Merge Wizard</property>
-                <property name="use_underline">True</property>
-                <property name="icon_name">sw/imglst/sc20234.png</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="homogeneous">True</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
-</interface>
commit 72502321c1a85849cee3646c33cd4533be45e50b
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 5 10:41:53 2016 +0100

    mailmerge: Create the layout when pressing Finish.
    
    Change-Id: Ifde5fcf29329c58be1a71cfbcf08f95c4516ca0d

diff --git a/sw/source/ui/dbui/mmlayoutpage.cxx b/sw/source/ui/dbui/mmlayoutpage.cxx
index 06446f3..8f2bb05 100644
--- a/sw/source/ui/dbui/mmlayoutpage.cxx
+++ b/sw/source/ui/dbui/mmlayoutpage.cxx
@@ -230,11 +230,11 @@ void SwMailMergeLayoutPage::ActivatePage()
     }
 }
 
-bool SwMailMergeLayoutPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+bool SwMailMergeLayoutPage::commitPage(::svt::WizardTypes::CommitPageReason eReason)
 {
     //now insert the frame and the greeting
     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
-    if(::svt::WizardTypes::eTravelForward == _eReason)
+    if (eReason == ::svt::WizardTypes::eTravelForward || eReason == ::svt::WizardTypes::eFinish)
     {
         long nLeft = static_cast< long >(m_pLeftMF->Denormalize(m_pLeftMF->GetValue(FUNIT_TWIP)));
         long nTop  = static_cast< long >(m_pTopMF->Denormalize(m_pTopMF->GetValue(FUNIT_TWIP)));
commit ca4d801c86f059aeabdbc315ef5190c83b6086d1
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Tue Jan 5 10:18:56 2016 +0100

    mailmerge: Remove "Edit document" page, fuctionality available via toolbar.
    
    Change-Id: I0a5d1ed6703871dc5e90acf5e1119e0126755282

diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk
index 2d49d3c..5126598 100644
--- a/sw/Library_swui.mk
+++ b/sw/Library_swui.mk
@@ -169,7 +169,6 @@ $(eval $(call gb_Library_add_exception_objects,swui,\
     sw/source/ui/dbui/mmgreetingspage \
     sw/source/ui/dbui/mmlayoutpage \
     sw/source/ui/dbui/mmoutputtypepage \
-    sw/source/ui/dbui/mmpreparemergepage \
     sw/source/ui/dbui/mmresultdialogs \
     sw/source/ui/dbui/selectdbtabledialog \
 ))
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 61f9217..b9c655e 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -191,7 +191,6 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/swriter,\
 	sw/uiconfig/swriter/ui/mmlayoutpage \
 	sw/uiconfig/swriter/ui/mmmailbody \
 	sw/uiconfig/swriter/ui/mmoutputtypepage \
-	sw/uiconfig/swriter/ui/mmpreparepage \
 	sw/uiconfig/swriter/ui/mmresultemaildialog \
 	sw/uiconfig/swriter/ui/mmresultprintdialog \
 	sw/uiconfig/swriter/ui/mmresultsavedialog \
diff --git a/sw/inc/dbui.hrc b/sw/inc/dbui.hrc
index 9bb6168..e85523b 100644
--- a/sw/inc/dbui.hrc
+++ b/sw/inc/dbui.hrc
@@ -79,11 +79,9 @@
 #define ST_ADDRESSBLOCK         (RC_DBUI_BEGIN + 54)
 #define ST_GREETINGSLINE        (RC_DBUI_BEGIN + 55)
 #define ST_LAYOUT               (RC_DBUI_BEGIN + 56)
-#define ST_PREPAREMERGE         (RC_DBUI_BEGIN + 57)
-#define ST_MERGE                (RC_DBUI_BEGIN + 58)
+#define ST_FINISH               (RC_DBUI_BEGIN + 57)
+#define ST_ADDRESSLIST          (RC_DBUI_BEGIN + 58)
 #define ST_EXCLUDE              (RC_DBUI_BEGIN + 59)
-#define ST_FINISH               (RC_DBUI_BEGIN + 60)
-#define ST_ADDRESSLIST          (RC_DBUI_BEGIN + 61)
 
 // ImageList
 #define ILIST                   (RC_DBUI_BEGIN + 62)
diff --git a/sw/source/ui/dbui/mailmergewizard.cxx b/sw/source/ui/dbui/mailmergewizard.cxx
index 9b853e8..d361063 100644
--- a/sw/source/ui/dbui/mailmergewizard.cxx
+++ b/sw/source/ui/dbui/mailmergewizard.cxx
@@ -21,7 +21,6 @@
 #include <mmdocselectpage.hxx>
 #include <mmoutputtypepage.hxx>
 #include <mmaddressblockpage.hxx>
-#include <mmpreparemergepage.hxx>
 #include <mmgreetingspage.hxx>
 #include <mmlayoutpage.hxx>
 #include <mmconfigitem.hxx>
@@ -51,8 +50,6 @@ SwMailMergeWizard::SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rItem
         m_sAddressList(     SW_RES( ST_ADDRESSLIST )),
         m_sGreetingsLine(   SW_RES( ST_GREETINGSLINE   )),
         m_sLayout(          SW_RES( ST_LAYOUT        )),
-        m_sPrepareMerge(    SW_RES( ST_PREPAREMERGE )),
-        m_sMerge(           SW_RES( ST_MERGE        )),
         m_sFinish(          SW_RES( ST_FINISH       )),
         m_nRestartPage( MM_DOCUMENTSELECTPAGE )
 {
@@ -72,7 +69,6 @@ SwMailMergeWizard::SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rItem
             MM_ADDRESSBLOCKPAGE,
             MM_GREETINGSPAGE,
             MM_LAYOUTPAGE,
-            MM_PREPAREMERGEPAGE,
             WZS_INVALID_STATE
         );
     else
@@ -82,7 +78,6 @@ SwMailMergeWizard::SwMailMergeWizard(SwView& rView, SwMailMergeConfigItem& rItem
             MM_ADDRESSBLOCKPAGE,
             MM_GREETINGSPAGE,
             MM_LAYOUTPAGE,
-            MM_PREPAREMERGEPAGE,
             WZS_INVALID_STATE
         );
 
@@ -104,7 +99,6 @@ VclPtr<TabPage> SwMailMergeWizard::createPage(WizardState _nState)
         case MM_ADDRESSBLOCKPAGE  : pRet = VclPtr<SwMailMergeAddressBlockPage>::Create(this);     break;
         case MM_GREETINGSPAGE     : pRet = VclPtr<SwMailMergeGreetingsPage>::Create(this);      break;
         case MM_LAYOUTPAGE        : pRet = VclPtr<SwMailMergeLayoutPage>::Create(this);     break;
-        case MM_PREPAREMERGEPAGE  : pRet = VclPtr<SwMailMergePrepareMergePage>::Create(this);   break;
     }
     OSL_ENSURE(pRet, "no page created in ::createPage");
     return pRet;
@@ -140,14 +134,14 @@ void SwMailMergeWizard::enterState( WizardState _nState )
     bool bEnableNext = true;
     switch(_nState)
     {
-        case MM_DOCUMENTSELECTPAGE :
-            bEnablePrev = false;
+        case MM_DOCUMENTSELECTPAGE:
+            bEnablePrev = false; // the first page
         break;
         case MM_ADDRESSBLOCKPAGE  :
             bEnableNext = m_rConfigItem.GetResultSet().is();
         break;
-        case MM_PREPAREMERGEPAGE:
-            bEnableNext = false;
+        case MM_LAYOUTPAGE:
+            bEnableNext = false; // the last page
         break;
     }
     enableButtons( WizardButtonFlags::PREVIOUS, bEnablePrev);
@@ -171,8 +165,6 @@ OUString SwMailMergeWizard::getStateDisplayName( WizardState _nState ) const
             return m_sGreetingsLine;
         case MM_LAYOUTPAGE:
             return m_sLayout;
-        case MM_PREPAREMERGEPAGE:
-            return m_sPrepareMerge;
     }
     return OUString();
 }
@@ -188,8 +180,6 @@ void SwMailMergeWizard::UpdateRoadmap()
     MM_LAYOUTPAGE               >   inactive after the layoutpage
                                     inactive if address block and greeting are switched off
                                     or are already inserted into the source document
-    MM_PREPAREMERGEPAGE         > only active if address data has been selected
-                                    inactive after preparemerge page
 */
 
     // enableState( <page id>, false );
@@ -203,12 +193,20 @@ void SwMailMergeWizard::UpdateRoadmap()
     bool bGreetingFieldsConfigured = !m_rConfigItem.IsGreetingLine(false) ||
             !m_rConfigItem.IsIndividualGreeting(false)||
                     m_rConfigItem.IsGreetingFieldsAssigned();
+
     //#i97436# if a document has to be loaded then enable output type page only
     m_bDocumentLoad = false;
     bool bEnableOutputTypePage = (nCurPage != MM_DOCUMENTSELECTPAGE) ||
         static_cast<svt::OWizardPage*>(pCurPage)->commitPage( ::svt::WizardTypes::eValidate );
 
-    for(sal_uInt16 nPage = MM_DOCUMENTSELECTPAGE; nPage <= MM_PREPAREMERGEPAGE; ++nPage)
+    // handle the Finish button
+    bool bCanFinish = !m_bDocumentLoad && bEnableOutputTypePage &&
+        m_rConfigItem.GetResultSet().is() &&
+        bAddressFieldsConfigured &&
+        bGreetingFieldsConfigured;
+    enableButtons(WizardButtonFlags::FINISH, (nCurPage != MM_DOCUMENTSELECTPAGE) && bCanFinish);
+
+    for(sal_uInt16 nPage = MM_DOCUMENTSELECTPAGE; nPage <= MM_LAYOUTPAGE; ++nPage)
     {
         bool bEnable = true;
         switch(nPage)
@@ -228,15 +226,9 @@ void SwMailMergeWizard::UpdateRoadmap()
                             bAddressFieldsConfigured;
             break;
             case MM_LAYOUTPAGE:
-                bEnable =
+                bEnable = bCanFinish &&
                         ((m_rConfigItem.IsAddressBlock() && !m_rConfigItem.IsAddressInserted()) ||
                             (m_rConfigItem.IsGreetingLine(false) && !m_rConfigItem.IsGreetingInserted() ));
-                // fall-through
-            case MM_PREPAREMERGEPAGE:
-                bEnable = bEnable && !m_bDocumentLoad && bEnableOutputTypePage &&
-                            m_rConfigItem.GetResultSet().is() &&
-                            bAddressFieldsConfigured &&
-                            bGreetingFieldsConfigured;
             break;
         }
         enableState( nPage, bEnable );
diff --git a/sw/source/ui/dbui/mailmergewizard.src b/sw/source/ui/dbui/mailmergewizard.src
index 176af67..43ddf62 100644
--- a/sw/source/ui/dbui/mailmergewizard.src
+++ b/sw/source/ui/dbui/mailmergewizard.src
@@ -49,16 +49,6 @@ String ST_LAYOUT
     Text [ en-US ] = "Adjust layout";
 };
 
-String ST_PREPAREMERGE
-{
-    Text [ en-US ] = "Edit document";
-};
-
-String ST_MERGE
-{
-    Text [ en-US ] = "Personalize document";
-};
-
 String ST_EXCLUDE
 {
     Text [ en-US ] = "Exclude recipient";
diff --git a/sw/source/ui/dbui/mmgreetingspage.cxx b/sw/source/ui/dbui/mmgreetingspage.cxx
index 105bb6e..6a8a013 100644
--- a/sw/source/ui/dbui/mmgreetingspage.cxx
+++ b/sw/source/ui/dbui/mmgreetingspage.cxx
@@ -96,7 +96,7 @@ IMPL_LINK_NOARG_TYPED(SwGreetingsHandler, IndividualHdl_Impl, Button*, void)
     {
         m_pWizard->GetConfigItem().SetIndividualGreeting(bIndividual, false);
         m_pWizard->UpdateRoadmap();
-        m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
+        m_pWizard->enableButtons(WizardButtonFlags::NEXT, true);
     }
     UpdatePreview();
 }
@@ -115,7 +115,7 @@ IMPL_LINK_TYPED(SwGreetingsHandler, GreetingHdl_Impl, Button*, pButton, void)
         if(m_bIsTabPage)
         {
             m_pWizard->UpdateRoadmap();
-            m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
+            m_pWizard->enableButtons(WizardButtonFlags::NEXT, true);
         }
         UpdatePreview();
     }
@@ -135,7 +135,7 @@ IMPL_LINK_TYPED(SwMailMergeGreetingsPage, AssignHdl_Impl, Button*, pButton, void
     {
         UpdatePreview();
         m_pWizard->UpdateRoadmap();
-        m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
+        m_pWizard->enableButtons(WizardButtonFlags::NEXT, true);
     }
 }
 
@@ -331,7 +331,7 @@ void SwMailMergeGreetingsPage::ActivatePage()
     m_pFemaleFieldCB->SaveValue();
 
     UpdatePreview();
-    m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_PREPAREMERGEPAGE));
+    m_pWizard->enableButtons(WizardButtonFlags::NEXT, true);
 }
 
 bool SwMailMergeGreetingsPage::commitPage( ::svt::WizardTypes::CommitPageReason )
diff --git a/sw/source/ui/dbui/mmpreparemergepage.cxx b/sw/source/ui/dbui/mmpreparemergepage.cxx
deleted file mode 100644
index 0b24123..0000000
--- a/sw/source/ui/dbui/mmpreparemergepage.cxx
+++ /dev/null
@@ -1,168 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <mmpreparemergepage.hxx>
-
-#include <comphelper/propertysequence.hxx>
-#include <mailmergewizard.hxx>
-#include <mmconfigitem.hxx>
-#include <dbui.hrc>
-#include <swtypes.hxx>
-#include <view.hxx>
-#include <dbmgr.hxx>
-#include <wrtsh.hxx>
-#include <svx/dataaccessdescriptor.hxx>
-#include <com/sun/star/sdbc/XConnection.hpp>
-#include <swabstdlg.hxx>
-
-#include <unomid.h>
-
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::sdbc;
-
-SwMailMergePrepareMergePage::SwMailMergePrepareMergePage( SwMailMergeWizard* _pParent)
-    : svt::OWizardPage(_pParent, "MMPreparePage", "modules/swriter/ui/mmpreparepage.ui")
-    , m_pWizard(_pParent)
-{
-    get(m_pFirstPB, "first");
-    get(m_pPrevPB, "prev");
-    get(m_pRecordED, "record-nospin");
-    get(m_pNextPB, "next");
-    get(m_pLastPB, "last");
-    get(m_pExcludeCB, "exclude");
-    get(m_pEditPB, "edit");
-
-    m_pEditPB->SetClickHdl( LINK( this, SwMailMergePrepareMergePage, EditDocumentHdl_Impl));
-    Link<Button*,void> aMoveLink(LINK( this, SwMailMergePrepareMergePage, MoveClickHdl_Impl));
-    m_pFirstPB->SetClickHdl( aMoveLink );
-    m_pPrevPB->SetClickHdl( aMoveLink );
-    m_pNextPB->SetClickHdl( aMoveLink );
-    m_pLastPB->SetClickHdl( aMoveLink );
-    m_pRecordED->SetModifyHdl( LINK( this, SwMailMergePrepareMergePage, MoveEditHdl_Impl) );
-    m_pExcludeCB->SetClickHdl(LINK(this, SwMailMergePrepareMergePage, ExcludeHdl_Impl));
-    MoveHdl_Impl(m_pRecordED);
-}
-
-SwMailMergePrepareMergePage::~SwMailMergePrepareMergePage()
-{
-    disposeOnce();
-}
-
-void SwMailMergePrepareMergePage::dispose()
-{
-    m_pFirstPB.clear();
-    m_pPrevPB.clear();
-    m_pRecordED.clear();
-    m_pNextPB.clear();
-    m_pLastPB.clear();
-    m_pExcludeCB.clear();
-    m_pEditPB.clear();
-    m_pWizard.clear();
-    svt::OWizardPage::dispose();
-}
-
-IMPL_LINK_NOARG_TYPED(SwMailMergePrepareMergePage, EditDocumentHdl_Impl, Button*, void)
-{
-    m_pWizard->SetRestartPage(MM_PREPAREMERGEPAGE);
-    m_pWizard->EndDialog(RET_EDIT_DOC);
-}
-
-IMPL_LINK_TYPED( SwMailMergePrepareMergePage, MoveClickHdl_Impl, Button*, pCtrl, void)
-{
-    MoveHdl_Impl(pCtrl);
-}
-IMPL_LINK_TYPED( SwMailMergePrepareMergePage, MoveEditHdl_Impl, Edit&, rEdit, void)
-{
-    MoveHdl_Impl(&rEdit);
-}
-void SwMailMergePrepareMergePage:: MoveHdl_Impl(Control* pCtrl)
-{
-    SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
-    sal_Int32 nPos = rConfigItem.GetResultSetPosition();
-    if (pCtrl == m_pFirstPB)
-    {
-        rConfigItem.MoveResultSet(1);
-    }
-    else if (pCtrl == m_pPrevPB)
-    {
-        rConfigItem.MoveResultSet(nPos - 1);
-    }
-    else if (pCtrl == m_pRecordED)
-    {
-        rConfigItem.MoveResultSet( static_cast< sal_Int32 >(m_pRecordED->GetValue()) );
-    }
-    else if (pCtrl == m_pNextPB)
-        rConfigItem.MoveResultSet(nPos + 1);
-    else if (pCtrl == m_pLastPB)
-        rConfigItem.MoveResultSet(-1);
-
-    nPos = rConfigItem.GetResultSetPosition();
-    m_pRecordED->SetValue(nPos);
-    bool bIsFirst;
-    bool bIsLast;
-    bool bValid = rConfigItem.IsResultSetFirstLast(bIsFirst, bIsLast);
-    m_pFirstPB->Enable(bValid && !bIsFirst);
-    m_pPrevPB->Enable(bValid && !bIsFirst);
-    m_pNextPB->Enable(bValid && !bIsLast);
-    m_pLastPB->Enable(bValid && !bIsLast);
-    m_pExcludeCB->Check(rConfigItem.IsRecordExcluded( rConfigItem.GetResultSetPosition() ));
-
-    //now the record has to be merged into the source document
-    const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
-    Sequence<Any> vSelection({ makeAny(rConfigItem.GetResultSetPosition()) });
-    svx::ODataAccessDescriptor aDescriptor(::comphelper::InitPropertySequence({
-        {"Selection",        makeAny(vSelection)},
-        {"DataSourceName",   makeAny(rDBData.sDataSource)},
-        {"Command",          makeAny(rDBData.sCommand)},
-        {"CommandType",      makeAny(rDBData.nCommandType)},
-        {"ActiveConnection", makeAny(rConfigItem.GetConnection().getTyped())},
-        {"Filter",           makeAny(rConfigItem.GetFilter())},
-        {"Cursor",           makeAny(rConfigItem.GetResultSet())}
-    }));
-
-    SwWrtShell& rSh = m_pWizard->GetSwView()->GetWrtShell();
-    SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor );
-    rSh.GetDBManager()->MergeNew(aMergeDesc);
-}
-
-IMPL_LINK_TYPED( SwMailMergePrepareMergePage, ExcludeHdl_Impl, Button*, pBox, void)
-{
-    SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
-    rConfigItem.ExcludeRecord( rConfigItem.GetResultSetPosition(), static_cast<CheckBox*>(pBox)->IsChecked());
-};
-
-void  SwMailMergePrepareMergePage::ActivatePage()
-{
-    MoveHdl_Impl(m_pRecordED);
-}
-
-// merge the data into a new file
-bool SwMailMergePrepareMergePage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
-{
-    SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
-    if(::svt::WizardTypes::eTravelForward == _eReason && !rConfigItem.IsMergeDone())
-    {
-        m_pWizard->CreateTargetDocument();
-        m_pWizard->EndDialog(RET_TARGET_CREATED);
-    }
-    return true;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/dbui/mmpreparemergepage.hxx b/sw/source/ui/dbui/mmpreparemergepage.hxx
deleted file mode 100644
index 89c4475..0000000
--- a/sw/source/ui/dbui/mmpreparemergepage.hxx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-#ifndef INCLUDED_SW_SOURCE_UI_DBUI_MMPREPAREMERGEPAGE_HXX
-#define INCLUDED_SW_SOURCE_UI_DBUI_MMPREPAREMERGEPAGE_HXX
-
-#include <svtools/wizardmachine.hxx>
-#include <vcl/button.hxx>
-#include <vcl/field.hxx>
-#include <svtools/stdctrl.hxx>
-#include <mailmergehelper.hxx>
-
-class SwMailMergeWizard;
-
-class SwMailMergePrepareMergePage : public svt::OWizardPage
-{
-    VclPtr<PushButton>     m_pFirstPB;
-    VclPtr<PushButton>     m_pPrevPB;
-    VclPtr<NumericField>   m_pRecordED;
-    VclPtr<PushButton>     m_pNextPB;
-    VclPtr<PushButton>     m_pLastPB;
-    VclPtr<CheckBox>       m_pExcludeCB;
-
-    VclPtr<PushButton>     m_pEditPB;
-
-    VclPtr<SwMailMergeWizard>  m_pWizard;
-
-    DECL_LINK_TYPED(EditDocumentHdl_Impl, Button*, void);
-    DECL_LINK_TYPED(ExcludeHdl_Impl, Button*, void);
-    DECL_LINK_TYPED(MoveEditHdl_Impl, Edit&, void);
-    DECL_LINK_TYPED(MoveClickHdl_Impl, Button*, void);
-    void MoveHdl_Impl(Control*);
-
-    virtual void        ActivatePage() override;
-    virtual bool        commitPage( ::svt::WizardTypes::CommitPageReason _eReason ) override;
-
-public:
-    SwMailMergePrepareMergePage( SwMailMergeWizard* _pParent);
-    virtual ~SwMailMergePrepareMergePage();
-    virtual void dispose() override;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/mailmergewizard.hxx b/sw/source/uibase/inc/mailmergewizard.hxx
index dba59f4..e2866ae 100644
--- a/sw/source/uibase/inc/mailmergewizard.hxx
+++ b/sw/source/uibase/inc/mailmergewizard.hxx
@@ -30,7 +30,6 @@ class SwMailMergeConfigItem;
 #define MM_ADDRESSBLOCKPAGE     2
 #define MM_GREETINGSPAGE        3
 #define MM_LAYOUTPAGE           4
-#define MM_PREPAREMERGEPAGE     5
 
 class SwMailMergeWizard : public ::svt::RoadmapWizard
 {
diff --git a/sw/uiconfig/swriter/ui/mmpreparepage.ui b/sw/uiconfig/swriter/ui/mmpreparepage.ui
deleted file mode 100644
index 95bfd32..0000000
--- a/sw/uiconfig/swriter/ui/mmpreparepage.ui
+++ /dev/null
@@ -1,350 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
-<interface>
-  <requires lib="gtk+" version="3.0"/>
-  <object class="GtkAdjustment" id="adjustment1">
-    <property name="lower">1</property>
-    <property name="upper">65535</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkBox" id="MMPreparePage">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="hexpand">True</property>
-    <property name="vexpand">True</property>
-    <property name="border_width">6</property>
-    <property name="orientation">vertical</property>
-    <property name="spacing">12</property>
-    <child>
-      <object class="GtkFrame" id="frame1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
-        <property name="label_xalign">0</property>
-        <property name="shadow_type">none</property>
-        <child>
-          <object class="GtkAlignment" id="alignment1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-            <property name="top_padding">6</property>
-            <property name="left_padding">12</property>
-            <child>
-              <object class="GtkGrid" id="grid1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="row_spacing">12</property>
-                <child>
-                  <object class="GtkGrid" id="grid3">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="row_spacing">6</property>
-                    <child>
-                      <object class="GtkLabel" id="label3">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="xalign">0</property>
-                        <property name="yalign">0</property>
-                        <property name="label" translatable="yes">The preview of a merged document is visible now. To see the preview of another document click one of the arrows.</property>
-                        <property name="wrap">True</property>
-                        <property name="max_width_chars">56</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkGrid" id="grid4">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="row_spacing">6</property>
-                        <property name="column_spacing">12</property>
-                        <child>
-                          <object class="GtkLabel" id="label4">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="xalign">0</property>
-                            <property name="yalign">0</property>
-                            <property name="label" translatable="yes">_Recipient</property>
-                            <property name="use_underline">True</property>
-                          </object>
-                          <packing>
-                            <property name="left_attach">0</property>
-                            <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkGrid" id="grid5">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="halign">center</property>
-                            <property name="hexpand">True</property>
-                            <property name="row_spacing">6</property>
-                            <property name="column_spacing">12</property>
-                            <child>
-                              <object class="GtkButton" id="first">
-                                <property name="label" translatable="yes">|<</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip_text" translatable="yes">First</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">0</property>
-                                <property name="top_attach">0</property>
-                                <property name="width">1</property>
-                                <property name="height">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkButton" id="prev">
-                                <property name="label" translatable="yes"><</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip_text" translatable="yes">Previous</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">1</property>
-                                <property name="top_attach">0</property>
-                                <property name="width">1</property>
-                                <property name="height">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkButton" id="next">
-                                <property name="label" translatable="yes">></property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip_text" translatable="yes">Next</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">3</property>
-                                <property name="top_attach">0</property>
-                                <property name="width">1</property>
-                                <property name="height">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkButton" id="last">
-                                <property name="label" translatable="yes">>|</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="tooltip_text" translatable="yes">Last</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">4</property>
-                                <property name="top_attach">0</property>
-                                <property name="width">1</property>
-                                <property name="height">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkSpinButton" id="record-nospin">
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="adjustment">adjustment1</property>
-                                <property name="value">1</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">2</property>
-                                <property name="top_attach">0</property>
-                                <property name="width">1</property>
-                                <property name="height">1</property>
-                              </packing>
-                            </child>
-                            <child>
-                              <object class="GtkCheckButton" id="exclude">
-                                <property name="label" translatable="yes">E_xclude this recipient</property>
-                                <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">False</property>
-                                <property name="halign">center</property>
-                                <property name="use_underline">True</property>
-                                <property name="xalign">0</property>
-                                <property name="draw_indicator">True</property>
-                              </object>
-                              <packing>
-                                <property name="left_attach">0</property>
-                                <property name="top_attach">1</property>
-                                <property name="width">5</property>
-                                <property name="height">1</property>
-                              </packing>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="left_attach">1</property>
-                            <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkBox" id="box1">
-                            <property name="visible">True</property>
-                            <property name="can_focus">False</property>
-                            <property name="orientation">vertical</property>
-                            <child>
-                              <placeholder/>
-                            </child>
-                          </object>
-                          <packing>
-                            <property name="left_attach">2</property>
-                            <property name="top_attach">0</property>
-                            <property name="width">1</property>
-                            <property name="height">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child type="label">
-          <object class="GtkLabel" id="label1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Preview Document</property>
-            <attributes>
-              <attribute name="weight" value="bold"/>
-            </attributes>
-          </object>
-        </child>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">0</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkFrame" id="frame2">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="hexpand">True</property>
-        <property name="vexpand">True</property>
-        <property name="label_xalign">0</property>
-        <property name="shadow_type">none</property>
-        <child>
-          <object class="GtkAlignment" id="alignment2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-            <property name="top_padding">6</property>
-            <property name="left_padding">12</property>
-            <child>
-              <object class="GtkGrid" id="grid2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="hexpand">True</property>
-                <property name="vexpand">True</property>
-                <property name="row_spacing">12</property>
-                <child>
-                  <object class="GtkGrid" id="grid6">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="hexpand">True</property>
-                    <property name="row_spacing">6</property>
-                    <child>
-                      <object class="GtkLabel" id="label5">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="xalign">0</property>
-                        <property name="yalign">0</property>
-                        <property name="label" translatable="yes">Write or edit your document now if you have not already done so. The changes will affect all merged documents.
-
-Clicking 'Edit Document...' will temporarily reduce the wizard to a small window so you can edit the mail merge document. After editing the document, return to the wizard by clicking 'Return to Mail Merge Wizard' in the small window.</property>
-                        <property name="wrap">True</property>
-                        <property name="max_width_chars">56</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="edit">
-                        <property name="label" translatable="yes">_Edit Document...</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="halign">center</property>
-                        <property name="use_underline">True</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">1</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child type="label">
-          <object class="GtkLabel" id="label2">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="label" translatable="yes">Edit Document</property>
-            <attributes>
-              <attribute name="weight" value="bold"/>
-            </attributes>
-          </object>
-        </child>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">True</property>
-        <property name="position">1</property>
-      </packing>
-    </child>
-  </object>
-  <object class="GtkSizeGroup" id="sizegroup1">
-    <widgets>
-      <widget name="label4"/>
-      <widget name="box1"/>
-    </widgets>
-  </object>
-</interface>
commit 60cec5dde876b0f1415d4d48bf4e4aff6141ad9e
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Sat Jan 2 00:38:18 2016 +0100

    mailmerge: Toolbar edit box to show or change the current entry number.
    
    Change-Id: I935c059da44f2309c3cb1a8b2e93341c353bee01

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 08fdfc6..acf283f 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -869,6 +869,17 @@
           <value>starshapes;.uno:StarShapes.star5</value>
         </prop>
       </node>
+      <node oor:name="lo.writer.MMCurrentEntryController" oor:op="replace">
+        <prop oor:name="Command">
+          <value>.uno:MailMergeCurrentEntry</value>
+        </prop>
+        <prop oor:name="Module">
+          <value/>
+        </prop>
+        <prop oor:name="Controller">
+          <value>lo.writer.MMCurrentEntryController</value>
+        </prop>
+      </node>
       <node oor:name="lo.writer.MMExcludeEntryController" oor:op="replace">
         <prop oor:name="Command">
           <value>.uno:MailMergeExcludeEntry</value>
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 0bb0cd4..bbb953e 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -256,6 +256,7 @@
 #define FN_MAILMERGE_PREV_ENTRY (FN_INSERT + 71)    /* mail merge toolbar - go to the previous entry */
 #define FN_MAILMERGE_NEXT_ENTRY (FN_INSERT + 72)    /* mail merge toolbar - go to the next entry */
 #define FN_MAILMERGE_LAST_ENTRY (FN_INSERT + 73)    /* mail merge toolbar - go to the next entry */
+#define FN_MAILMERGE_CURRENT_ENTRY (FN_INSERT + 74) /* mail merge toolbar - show or change the current entry */
 #define FN_MAILMERGE_EXCLUDE_ENTRY (FN_INSERT + 75) /* mail merge toolbar - checkbox to exclude the current entry */
 
 #define FN_DRAWTEXT_ATTR_DLG    (FN_INSERT + 76)    /* position DrawText */
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 760bbba..3a70fe9 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -5347,6 +5347,30 @@ SfxVoidItem MailMergeLastEntry FN_MAILMERGE_LAST_ENTRY
     GroupId = GID_DOCUMENT;
 ]
 
+SfxVoidItem MailMergeCurrentEntry FN_MAILMERGE_CURRENT_ENTRY
+()
+[
+    /* flags: */
+    AutoUpdate = TRUE,
+    Cachable = Cachable,
+    FastCall = TRUE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = TRUE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_DOCUMENT;
+]
+
 SfxVoidItem MailMergeExcludeEntry FN_MAILMERGE_EXCLUDE_ENTRY
 ()
 [
diff --git a/sw/sdi/wrtapp.sdi b/sw/sdi/wrtapp.sdi
index 794f796..16e5094 100644
--- a/sw/sdi/wrtapp.sdi
+++ b/sw/sdi/wrtapp.sdi
@@ -89,6 +89,12 @@ interface StarWriter
         StateMethod = StateOther ;
     ]
 
+    FN_MAILMERGE_CURRENT_ENTRY
+    [
+        ExecMethod = ExecOther ;
+        StateMethod = StateOther ;
+    ]
+
     FN_MAILMERGE_EXCLUDE_ENTRY
     [
         StateMethod = StateOther ;
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index 725a3cf..277b266 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -225,9 +225,11 @@ void SwModule::StateOther(SfxItemSet &rSet)
                 }
             }
             break;
+            case FN_MAILMERGE_CURRENT_ENTRY:
             case FN_MAILMERGE_EXCLUDE_ENTRY:
             {
                 // just trigger calling statusChanged() of MMExcludeEntryController
+                // resp. MMCurrentEntryController
                 rSet.InvalidateItem(nWhich);
             }
             break;
@@ -751,6 +753,7 @@ void SwModule::ExecOther(SfxRequest& rReq)
         case FN_MAILMERGE_PREV_ENTRY:
         case FN_MAILMERGE_NEXT_ENTRY:
         case FN_MAILMERGE_LAST_ENTRY:
+        case FN_MAILMERGE_CURRENT_ENTRY:
         {
             SwView* pView = ::GetActiveView();
             SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
@@ -764,6 +767,7 @@ void SwModule::ExecOther(SfxRequest& rReq)
                 case FN_MAILMERGE_PREV_ENTRY:  pConfigItem->MoveResultSet(nPos - 1); break;
                 case FN_MAILMERGE_NEXT_ENTRY:  pConfigItem->MoveResultSet(nPos + 1); break;
                 case FN_MAILMERGE_LAST_ENTRY:  pConfigItem->MoveResultSet(-1); break;
+                case FN_MAILMERGE_CURRENT_ENTRY: /* don't move the result set, just update the document */ break;
                 default: break;
             }
 
@@ -790,6 +794,7 @@ void SwModule::ExecOther(SfxRequest& rReq)
             rBindings.Invalidate(FN_MAILMERGE_PREV_ENTRY);
             rBindings.Invalidate(FN_MAILMERGE_NEXT_ENTRY);
             rBindings.Invalidate(FN_MAILMERGE_LAST_ENTRY);
+            rBindings.Invalidate(FN_MAILMERGE_CURRENT_ENTRY);
             rBindings.Invalidate(FN_MAILMERGE_EXCLUDE_ENTRY);
             rBindings.Update();
         }
diff --git a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
index d4dacfb..749d65f 100644
--- a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
+++ b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
@@ -36,6 +36,74 @@ using namespace css;
 
 namespace {
 
+/// Controller for .uno:MailMergeCurrentEntry toolbar checkbox: creates the checkbox & handles the value.
+class MMCurrentEntryController : public svt::ToolboxController, public lang::XServiceInfo
+{
+    VclPtr<Edit> m_pCurrentEdit;
+
+    DECL_LINK_TYPED(CurrentEditUpdatedHdl, Edit&, void);
+
+public:
+    MMCurrentEntryController(const uno::Reference<uno::XComponentContext>& rContext)
+        : svt::ToolboxController(rContext, uno::Reference<frame::XFrame>(), OUString(".uno:MailMergeCurrentEntry"))
+        , m_pCurrentEdit(nullptr)
+    {
+    }
+
+    virtual ~MMCurrentEntryController()
+    {
+    }
+
+    // XInterface
+    virtual uno::Any SAL_CALL queryInterface(const uno::Type& aType) throw (uno::RuntimeException, std::exception) override
+    {
+        uno::Any a(ToolboxController::queryInterface(aType));
+        if (a.hasValue())
+            return a;
+
+        return ::cppu::queryInterface(aType, static_cast<lang::XServiceInfo*>(this));
+    }
+
+    void SAL_CALL acquire() throw ()
+    {
+        ToolboxController::acquire();
+    }
+
+    void SAL_CALL release() throw ()
+    {
+        ToolboxController::release();
+    }
+
+    // XServiceInfo
+    virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException, std::exception) override
+    {
+        return OUString("lo.writer.MMCurrentEntryController");
+    }
+
+    virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) override
+    {
+        return cppu::supportsService(this, rServiceName);
+    }
+
+    virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException, std::exception) override
+    {
+        uno::Sequence<OUString> aServices { "com.sun.star.frame.ToolbarController" };
+        return aServices;
+    }
+
+    // XComponent
+    virtual void SAL_CALL dispose() throw (uno::RuntimeException, std::exception) override;
+
+    // XInitialization
+    virtual void SAL_CALL initialize(const uno::Sequence< uno::Any >& aArguments) throw (uno::Exception, uno::RuntimeException, std::exception) override;
+
+    // XToolbarController
+    virtual uno::Reference<awt::XWindow> SAL_CALL createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception) override;
+
+    // XStatusListener
+    virtual void SAL_CALL statusChanged(const frame::FeatureStateEvent& rEvent) throw (uno::RuntimeException, std::exception) override;
+};
+
 /// Controller for .uno:MailMergeExcludeEntry toolbar checkbox: creates the checkbox & handles the value.
 class MMExcludeEntryController : public svt::ToolboxController, public lang::XServiceInfo
 {
@@ -104,6 +172,78 @@ public:
     virtual void SAL_CALL statusChanged(const frame::FeatureStateEvent& rEvent) throw (uno::RuntimeException, std::exception) override;
 };
 
+void MMCurrentEntryController::dispose() throw (uno::RuntimeException, std::exception)
+{
+    SolarMutexGuard aSolarMutexGuard;
+
+    svt::ToolboxController::dispose();
+    m_pCurrentEdit.disposeAndClear();
+}
+
+void MMCurrentEntryController::initialize(const uno::Sequence< uno::Any >& aArguments) throw (uno::Exception, uno::RuntimeException, std::exception)
+{
+    svt::ToolboxController::initialize(aArguments);
+}
+
+uno::Reference<awt::XWindow> MMCurrentEntryController::createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception)
+{
+    vcl::Window* pParent = VCLUnoHelper::GetWindow(rParent);
+    ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent);
+    if (pToolbar)
+    {
+        // make it visible
+        m_pCurrentEdit = VclPtr<Edit>::Create(pToolbar);
+        m_pCurrentEdit->SetWidthInChars(4);
+        m_pCurrentEdit->SetSizePixel(m_pCurrentEdit->GetOptimalSize());
+
+        m_pCurrentEdit->SetModifyHdl(LINK(this, MMCurrentEntryController, CurrentEditUpdatedHdl));
+    }
+
+    return uno::Reference<awt::XWindow>(VCLUnoHelper::GetInterface(m_pCurrentEdit));
+}
+
+IMPL_LINK_TYPED(MMCurrentEntryController, CurrentEditUpdatedHdl, Edit&, rEdit, void)
+{
+    SwView* pView = ::GetActiveView();
+    SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
+
+    if (!pConfigItem)
+        return;
+
+    OUString aText(rEdit.GetText());
+    sal_Int32 nEntry = aText.toInt32();
+    if (!aText.isEmpty() && nEntry != pConfigItem->GetResultSetPosition())
+    {
+        pConfigItem->MoveResultSet(nEntry);
+        // notify about the change
+        dispatchCommand(".uno:MailMergeCurrentEntry", uno::Sequence<beans::PropertyValue>());
+    }
+};
+
+void MMCurrentEntryController::statusChanged(const frame::FeatureStateEvent& rEvent) throw (uno::RuntimeException, std::exception)
+{
+    if (!m_pCurrentEdit)
+        return;
+
+    SwView* pView = ::GetActiveView();
+    SwMailMergeConfigItem* pConfigItem = pView->GetMailMergeConfigItem();
+
+    if (!pConfigItem || !rEvent.IsEnabled)
+    {
+        m_pCurrentEdit->Disable();
+        m_pCurrentEdit->SetText("");
+    }
+    else
+    {
+        sal_Int32 nEntry = m_pCurrentEdit->GetText().toInt32();
+        if (!m_pCurrentEdit->IsEnabled() || nEntry != pConfigItem->GetResultSetPosition())
+        {
+            m_pCurrentEdit->Enable();
+            m_pCurrentEdit->SetText(OUString::number(pConfigItem->GetResultSetPosition()));
+        }
+    }
+}
+
 void MMExcludeEntryController::dispose() throw (uno::RuntimeException, std::exception)
 {
     SolarMutexGuard aSolarMutexGuard;
@@ -166,6 +306,14 @@ void MMExcludeEntryController::statusChanged(const frame::FeatureStateEvent& rEv
 }
 
 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface * SAL_CALL
+lo_writer_MMCurrentEntryController_get_implementation(
+    uno::XComponentContext *context,
+    uno::Sequence<uno::Any> const &)
+{
+    return cppu::acquire(new MMCurrentEntryController(context));
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface * SAL_CALL
 lo_writer_MMExcludeEntryController_get_implementation(
     uno::XComponentContext *context,
     uno::Sequence<uno::Any> const &)
diff --git a/sw/uiconfig/swform/toolbar/mailmerge.xml b/sw/uiconfig/swform/toolbar/mailmerge.xml
index 61cca36..ff9773d 100644
--- a/sw/uiconfig/swform/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swform/toolbar/mailmerge.xml
@@ -13,6 +13,7 @@
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeFirstEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeCurrentEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
diff --git a/sw/uiconfig/swreport/toolbar/mailmerge.xml b/sw/uiconfig/swreport/toolbar/mailmerge.xml
index 61cca36..ff9773d 100644
--- a/sw/uiconfig/swreport/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swreport/toolbar/mailmerge.xml
@@ -13,6 +13,7 @@
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeFirstEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeCurrentEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
diff --git a/sw/uiconfig/swriter/toolbar/mailmerge.xml b/sw/uiconfig/swriter/toolbar/mailmerge.xml
index 61cca36..ff9773d 100644
--- a/sw/uiconfig/swriter/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swriter/toolbar/mailmerge.xml
@@ -13,6 +13,7 @@
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeFirstEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeCurrentEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
diff --git a/sw/uiconfig/swxform/toolbar/mailmerge.xml b/sw/uiconfig/swxform/toolbar/mailmerge.xml
index 61cca36..ff9773d 100644
--- a/sw/uiconfig/swxform/toolbar/mailmerge.xml
+++ b/sw/uiconfig/swxform/toolbar/mailmerge.xml
@@ -13,6 +13,7 @@
   <toolbar:toolbarseparator/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeFirstEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergePrevEntry"/>
+  <toolbar:toolbaritem xlink:href=".uno:MailMergeCurrentEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeNextEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeLastEntry"/>
   <toolbar:toolbaritem xlink:href=".uno:MailMergeExcludeEntry"/>
diff --git a/sw/util/sw.component b/sw/util/sw.component
index ff6b032..c069d63 100644
--- a/sw/util/sw.component
+++ b/sw/util/sw.component
@@ -27,6 +27,10 @@
     <service name="com.sun.star.sdb.DataAccessDescriptor"/>
     <service name="com.sun.star.text.MailMerge"/>
   </implementation>
+  <implementation name="lo.writer.MMCurrentEntryController"
+      constructor="lo_writer_MMCurrentEntryController_get_implementation">
+    <service name="com.sun.star.frame.ToolbarController"/>
+  </implementation>
   <implementation name="lo.writer.MMExcludeEntryController"
       constructor="lo_writer_MMExcludeEntryController_get_implementation">
     <service name="com.sun.star.frame.ToolbarController"/>
commit 1fec8e09e20b1fc6495d1c678e0e27e9d044c65f
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Wed Dec 30 00:00:37 2015 +0100

    mailmerge: Implement toolbar controller to exclude entries.
    
    This can be used as a "How to implement a custom widget / control in
    the toolbar" example:
    
    * the Controller.xcu change introduces a .uno:MailMergeExcludeEntry command so
      that it can be added in the toolbar .xml description (in this case
      mailmerge.xml)
    
    * the swriter.sdi introduces the .uno:MailMergeExcludeEntry command for the
      sfx2 handling - so that it can get notifications about enable/disable
      changes, invalidates, etc.
    
    * wrtapp.sdi + associated apphdl.cxx change make it possible to forward
      command invalidates (the rBindings.Invalidate(FN_MAILMERGE_EXCLUDE_ENTRY);)
      to the MMExcludeEntryController::statusChanged() for further handling
      (in this case setting the checked state according to the current data)
    
    * MMExcludeEntryController::createItemWindow() implements the custom widget
      itself (in this case a checkbox, but can be any VCL widget, even a custom
      one)
    
    * the rest (sw.component and the associated getImplementationName(),
      supportsService(), etc.) takes care of the instantiation of the controller.
    
    Change-Id: I68269538f779a6680b0ba98395b7985d3f1ab95a

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index 4df10e2..08fdfc6 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -869,6 +869,17 @@
           <value>starshapes;.uno:StarShapes.star5</value>
         </prop>
       </node>
+      <node oor:name="lo.writer.MMExcludeEntryController" oor:op="replace">
+        <prop oor:name="Command">
+          <value>.uno:MailMergeExcludeEntry</value>
+        </prop>
+        <prop oor:name="Module">
+          <value/>
+        </prop>
+        <prop oor:name="Controller">
+          <value>lo.writer.MMExcludeEntryController</value>
+        </prop>
+      </node>
       <node oor:name="com.sun.star.svx.FindTextToolboxController" oor:op="replace">
         <prop oor:name="Command">
           <value>.uno:FindText</value>
diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index f9725be..f8c16b7 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -768,6 +768,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/uibase/dbui/maildispatcher \
     sw/source/uibase/dbui/mailmergechildwindow \
     sw/source/uibase/dbui/mailmergehelper \
+    sw/source/uibase/dbui/mailmergetoolbarcontrols \
     sw/source/uibase/dbui/mmconfigitem \
     sw/source/uibase/uno/unomailmerge \
 ))
diff --git a/sw/inc/cmdid.h b/sw/inc/cmdid.h
index 908d5c8..0bb0cd4 100644
--- a/sw/inc/cmdid.h
+++ b/sw/inc/cmdid.h
@@ -256,6 +256,7 @@
 #define FN_MAILMERGE_PREV_ENTRY (FN_INSERT + 71)    /* mail merge toolbar - go to the previous entry */
 #define FN_MAILMERGE_NEXT_ENTRY (FN_INSERT + 72)    /* mail merge toolbar - go to the next entry */
 #define FN_MAILMERGE_LAST_ENTRY (FN_INSERT + 73)    /* mail merge toolbar - go to the next entry */
+#define FN_MAILMERGE_EXCLUDE_ENTRY (FN_INSERT + 75) /* mail merge toolbar - checkbox to exclude the current entry */
 
 #define FN_DRAWTEXT_ATTR_DLG    (FN_INSERT + 76)    /* position DrawText */
 
diff --git a/sw/inc/dbui.hrc b/sw/inc/dbui.hrc
index 8aeb2c7..9bb6168 100644
--- a/sw/inc/dbui.hrc
+++ b/sw/inc/dbui.hrc
@@ -81,7 +81,7 @@
 #define ST_LAYOUT               (RC_DBUI_BEGIN + 56)
 #define ST_PREPAREMERGE         (RC_DBUI_BEGIN + 57)
 #define ST_MERGE                (RC_DBUI_BEGIN + 58)
-#define ST_OUTPUT               (RC_DBUI_BEGIN + 59)
+#define ST_EXCLUDE              (RC_DBUI_BEGIN + 59)
 #define ST_FINISH               (RC_DBUI_BEGIN + 60)
 #define ST_ADDRESSLIST          (RC_DBUI_BEGIN + 61)
 
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 4dbbe30..760bbba 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -5347,6 +5347,30 @@ SfxVoidItem MailMergeLastEntry FN_MAILMERGE_LAST_ENTRY
     GroupId = GID_DOCUMENT;
 ]
 
+SfxVoidItem MailMergeExcludeEntry FN_MAILMERGE_EXCLUDE_ENTRY
+()
+[
+    /* flags: */
+    AutoUpdate = TRUE,
+    Cachable = Cachable,
+    FastCall = TRUE,
+    HasCoreId = FALSE,
+    HasDialog = FALSE,
+    ReadOnlyDoc = FALSE,
+    Toggle = FALSE,
+    Container = TRUE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+    Synchron;
+
+    /* config: */
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    StatusBarConfig = FALSE,
+    ToolBoxConfig = TRUE,
+    GroupId = GID_DOCUMENT;
+]
+
 SfxVoidItem MailMergeCreateDocuments FN_MAILMERGE_CREATE_DOCUMENTS
 ()
 [
diff --git a/sw/sdi/wrtapp.sdi b/sw/sdi/wrtapp.sdi
index 2a9883f..794f796 100644
--- a/sw/sdi/wrtapp.sdi
+++ b/sw/sdi/wrtapp.sdi
@@ -89,6 +89,11 @@ interface StarWriter
         StateMethod = StateOther ;
     ]
 
+    FN_MAILMERGE_EXCLUDE_ENTRY
+    [
+        StateMethod = StateOther ;
+    ]
+
     FN_MAILMERGE_CREATE_DOCUMENTS
     [
         ExecMethod = ExecOther ;
diff --git a/sw/source/ui/dbui/mailmergewizard.src b/sw/source/ui/dbui/mailmergewizard.src
index 7231ce2..176af67 100644
--- a/sw/source/ui/dbui/mailmergewizard.src
+++ b/sw/source/ui/dbui/mailmergewizard.src
@@ -59,9 +59,9 @@ String ST_MERGE
     Text [ en-US ] = "Personalize document";
 };
 
-String ST_OUTPUT
+String ST_EXCLUDE
 {
-    Text [ en-US ] = "Save, print or send";
+    Text [ en-US ] = "Exclude recipient";
 };
 
 String ST_FINISH
diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx
index ebd58de..725a3cf 100644
--- a/sw/source/uibase/app/apphdl.cxx
+++ b/sw/source/uibase/app/apphdl.cxx
@@ -225,6 +225,12 @@ void SwModule::StateOther(SfxItemSet &rSet)
                 }
             }
             break;
+            case FN_MAILMERGE_EXCLUDE_ENTRY:
+            {
+                // just trigger calling statusChanged() of MMExcludeEntryController
+                rSet.InvalidateItem(nWhich);
+            }
+            break;
             case FN_MAILMERGE_CREATE_DOCUMENTS:
             case FN_MAILMERGE_SAVE_DOCUMENTS:
             case FN_MAILMERGE_PRINT_DOCUMENTS:
@@ -784,6 +790,7 @@ void SwModule::ExecOther(SfxRequest& rReq)
             rBindings.Invalidate(FN_MAILMERGE_PREV_ENTRY);
             rBindings.Invalidate(FN_MAILMERGE_NEXT_ENTRY);
             rBindings.Invalidate(FN_MAILMERGE_LAST_ENTRY);
+            rBindings.Invalidate(FN_MAILMERGE_EXCLUDE_ENTRY);
             rBindings.Update();
         }
         break;
diff --git a/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
new file mode 100644
index 0000000..d4dacfb
--- /dev/null
+++ b/sw/source/uibase/dbui/mailmergetoolbarcontrols.cxx
@@ -0,0 +1,176 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <svtools/toolboxcontroller.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/button.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/toolbox.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <dbui.hrc>
+#include <mmconfigitem.hxx>
+#include <swmodule.hxx>
+#include <view.hxx>
+
+using namespace css;
+
+namespace {
+
+/// Controller for .uno:MailMergeExcludeEntry toolbar checkbox: creates the checkbox & handles the value.
+class MMExcludeEntryController : public svt::ToolboxController, public lang::XServiceInfo
+{
+    VclPtr<CheckBox> m_pExcludeCheckbox;
+
+    DECL_LINK_TYPED(ExcludeHdl, CheckBox&, void);
+
+public:
+    MMExcludeEntryController(const uno::Reference<uno::XComponentContext>& rContext)
+        : svt::ToolboxController(rContext, uno::Reference<frame::XFrame>(), OUString(".uno:MailMergeExcludeEntry"))
+        , m_pExcludeCheckbox(nullptr)
+    {
+    }
+
+    virtual ~MMExcludeEntryController()
+    {
+    }
+
+    // XInterface
+    virtual uno::Any SAL_CALL queryInterface(const uno::Type& aType) throw (uno::RuntimeException, std::exception) override
+    {
+        uno::Any a(ToolboxController::queryInterface(aType));

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list