tdf#135636 the selection at dialog-launch time is lost by dialog-apply time

since...

commit c3a085d22742f88e91ff92f319a26d6e8d1d9a98
Date:   Tue Jan 23 18:13:01 2018 +0100

    lokdialog: Convert the Table -> Properties... to async exec.

so save it at launch and temp apply it during ok handler. This is somewhat
similar to tdf#134439

Change-Id: Ia0869307b1a37e5efa1703e68b946793b0ddc91b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101679
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 0348f46..04dfbda 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -596,9 +596,13 @@ void SwTableShell::Execute(SfxRequest &rReq)
                auto pRequest = std::make_shared<SfxRequest>(rReq);
                rReq.Ignore(); // the 'old' request is not relevant any more

                pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh](sal_Int32 nResult){
                auto xPaM(std::make_shared<SwPaM>(*rSh.GetCursor(), nullptr)); // tdf#135636 make a copy to use at later apply
                pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh, xPaM](sal_Int32 nResult){
                    if (RET_OK == nResult)
                    {
                        rSh.Push();              // save current cursor on stack
                        rSh.SetSelection(*xPaM); // tdf#135636 set the table selected at dialog launch as current selection

                        const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();

                        //to record FN_INSERT_TABLE correctly
@@ -606,6 +610,8 @@ void SwTableShell::Execute(SfxRequest &rReq)
                        pRequest->Done(*pOutSet);

                        ItemSetToTableParam(*pOutSet, rSh);

                        rSh.Pop(SwCursorShell::PopMode::DeleteCurrent); // restore cursor from stack
                    }

                    rBindings.Update(SID_RULER_BORDERS);