sc/source/ui/view/tabvwshf.cxx | 100 +++++++++++++++++++++++++---------------- vcl/jsdialog/enabled.cxx | 1 2 files changed, 64 insertions(+), 37 deletions(-)
New commits: commit 5044236b08e5390ba5a154966391e9a32441c6e7 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Wed Aug 14 09:50:28 2024 +0000 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Sep 11 14:56:30 2024 +0200 feat: Make move/copy sheet an async jsdialog Generally pretty standard ... I asynced this one specifically because I wanted to be able to put it into the mobile wizard as part of https://github.com/CollaboraOnline/online/issues/9787 I used 'mutable' for the callback here, as we modify some variables (e.g. bDoIt) inside the callback, and I preferred to do so rather than either shadow the variables or have separately-named things inside the callback. Change-Id: I23cef6330a5d5f64ac8b1746ef22516dc76f9d8e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172975 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx index b5355e2d1c28..c8fed32c9dd3 100644 --- a/sc/source/ui/view/tabvwshf.cxx +++ b/sc/source/ui/view/tabvwshf.cxx @@ -633,6 +633,16 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) if ( bDoIt && nTab >= nTableCount ) // if necessary append nTab = SC_TAB_APPEND; } + + if( bDoIt ) + { + rReq.Done(); // record, while doc is active + if (bFromContextMenu) + MoveTable(nDoc, nTab, bCpy, &aTabName, true, + nContextMenuTab); + else + MoveTable( nDoc, nTab, bCpy, &aTabName ); + } } else { @@ -641,7 +651,7 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractScMoveTableDlg> pDlg(pFact->CreateScMoveTableDlg(GetFrameWeld(), + VclPtr<AbstractScMoveTableDlg> pDlg(pFact->CreateScMoveTableDlg(GetFrameWeld(), aDefaultName)); SCTAB nTableCount = rDoc.GetTableCount(); @@ -657,51 +667,67 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq ) // is selected. pDlg->EnableRenameTable(nTabSelCount == 1); - if ( pDlg->Execute() == RET_OK ) - { - nDoc = pDlg->GetSelectedDocument(); - nTab = pDlg->GetSelectedTable(); - bCpy = pDlg->GetCopyTable(); - bool bRna = pDlg->GetRenameTable(); - // Leave aTabName string empty, when Rename is FALSE. - if( bRna ) - { - pDlg->GetTabNameString( aTabName ); - } - bDoIt = true; + std::shared_ptr<SfxRequest> pReq = std::make_shared<SfxRequest>(rReq); - OUString aFoundDocName; - if ( nDoc != SC_DOC_NEW ) + pDlg->StartExecuteAsync([ + this, + bFromContextMenu, + nContextMenuTab, + pDlg, + pReq + ](sal_Int32 nResult) { + if ( nResult == RET_OK ) { - ScDocShell* pSh = ScDocShell::GetShellByNum( nDoc ); - if (pSh) + sal_uInt16 nDoc = pDlg->GetSelectedDocument(); + SCTAB nSelectedTab = pDlg->GetSelectedTable(); + bool bCopy = pDlg->GetCopyTable(); + bool bRna = pDlg->GetRenameTable(); + OUString aNewTabName; + + // Leave aNewTabName string empty, when Rename is FALSE. + if( bRna ) + { + pDlg->GetTabNameString(aNewTabName); + } + bool bDoItAsync = true; + + OUString aFoundDocName; + if ( nDoc != SC_DOC_NEW ) { - aFoundDocName = pSh->GetTitle(); - if ( !pSh->GetDocument().IsDocEditable() ) + ScDocShell* pSh = ScDocShell::GetShellByNum( nDoc ); + if (pSh) { - ErrorMessage(STR_READONLYERR); - bDoIt = false; + aFoundDocName = pSh->GetTitle(); + if ( !pSh->GetDocument().IsDocEditable() ) + { + ErrorMessage(STR_READONLYERR); + bDoItAsync = false; + } } } - } - rReq.AppendItem( SfxStringItem( FID_TAB_MOVE, aFoundDocName ) ); - // 1-based table, if not APPEND - SCTAB nBasicTab = ( nTab <= MAXTAB ) ? (nTab+1) : nTab; - rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nBasicTab) ) ); - rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bCpy ) ); - } - } + pReq->AppendItem( SfxStringItem( FID_TAB_MOVE, aFoundDocName ) ); + // 1-based table, if not APPEND + SCTAB nBasicTab = ( nSelectedTab <= MAXTAB ) ? (nSelectedTab+1) : nSelectedTab; + pReq->AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nBasicTab) ) ); + pReq->AppendItem( SfxBoolItem( FN_PARAM_2, bCopy ) ); - if( bDoIt ) - { - rReq.Done(); // record, while doc is active + if( bDoItAsync ) + { + pReq->Done(); - if (bFromContextMenu) - MoveTable(nDoc, nTab, bCpy, &aTabName, true, - nContextMenuTab); - else - MoveTable( nDoc, nTab, bCpy, &aTabName ); + if (bFromContextMenu) + MoveTable(nDoc, nSelectedTab, bCopy, &aNewTabName, true, + nContextMenuTab); + else + MoveTable(nDoc, nSelectedTab, bCopy, &aNewTabName); + } + } + + pDlg->disposeOnce(); + }); + rReq.Ignore(); } + } break; diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index 8be77d39673d..e66033083e1a 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -124,6 +124,7 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile) || rUIFile == u"modules/scalc/ui/headerfooterdialog.ui" || rUIFile == u"modules/scalc/ui/insertcells.ui" || rUIFile == u"modules/scalc/ui/managenamesdialog.ui" + || rUIFile == u"modules/scalc/ui/movecopysheet.ui" || rUIFile == u"modules/scalc/ui/movingaveragedialog.ui" || rUIFile == u"modules/scalc/ui/optimalcolwidthdialog.ui" || rUIFile == u"modules/scalc/ui/optimalrowheightdialog.ui"