tdf#80390 Use local copy in anonymous function.

The nCount object might go out of scope, as it's used by
an async function.

https://gerrit.libreoffice.org/c/core/+/164316/comments/507b830b_001a71eb

Change-Id: I4218f6e35b61704115047481cb97a193c593a072
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154750
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 69fbd1e..ae55a33 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -352,7 +352,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
        case FID_INS_CELL:
            {
                InsCellCmd eCmd=INS_NONE;
                size_t nCount = 0;

                if ( pReqArgs )
                {
@@ -386,20 +385,21 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                        ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();

                        VclPtr<AbstractScInsertCellDlg> pDlg(pFact->CreateScInsertCellDlg(pTabViewShell->GetFrameWeld(), bTheFlag));
                        pDlg->StartExecuteAsync([pDlg, pTabViewShell, &nCount](sal_Int32 nResult){
                        pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
                            if (nResult == RET_OK)
                            {
                                SfxRequest aRequest(pTabViewShell->GetViewFrame(), FID_INS_CELL);
                                InsCellCmd eTmpCmd = pDlg->GetInsCellCmd();
                                nCount = pDlg->GetCount();
                                InsertCells(pTabViewShell, aRequest, eTmpCmd, nCount);
                                size_t nInsCount = pDlg->GetCount();
                                InsertCells(pTabViewShell, aRequest, eTmpCmd, nInsCount);
                            }
                            pDlg->disposeOnce();
                        });
                        break;
                    }
                }

                InsertCells(pTabViewShell, rReq, eCmd, nCount);
                InsertCells(pTabViewShell, rReq, eCmd);
            }
            break;