sc/source/ui/inc/tabvwsh.hxx | 2 sc/source/ui/view/tabvwsh3.cxx | 122 ++++++++++++++++++++++++----------------- vcl/jsdialog/enabled.cxx | 1 3 files changed, 75 insertions(+), 50 deletions(-)
New commits: commit 4ff32749721a50f3ce8769306e8442652d6355d2 Author: Hubert Figuière <h...@collabora.com> AuthorDate: Thu Jul 17 12:07:10 2025 -0400 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Jul 18 09:21:42 2025 +0200 calc: Make the GotoSheet dialog async Also enable the JSDialog Signed-off-by: Hubert Figuière <h...@collabora.com> Change-Id: Ibc6a54ad685052cf904032e6606f506332db6806 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188017 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx index 06f88b4f6e74..ea40ff8fef20 100644 --- a/sc/source/ui/inc/tabvwsh.hxx +++ b/sc/source/ui/inc/tabvwsh.hxx @@ -430,6 +430,8 @@ public: void FinishProtectTable(); void ExecProtectTable( SfxRequest& rReq ); + void ExecGoToTab( SfxRequest& rReq, SfxBindings& rBindings ); + using ScTabView::ShowCursor; bool IsActive() const { return bIsActive; } diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index 8d5888a5b5f3..8c0c18aeb250 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -171,6 +171,77 @@ namespace } } +void ScTabViewShell::ExecGoToTab( SfxRequest& rReq, SfxBindings& rBindings ) +{ + SCTAB nTab; + ScViewData& rViewData = GetViewData(); + ScDocument& rDoc = rViewData.GetDocument(); + SCTAB nTabCount = rDoc.GetTableCount(); + const SfxItemSet* pReqArgs = rReq.GetArgs(); + sal_uInt16 nSlot = rReq.GetSlot(); + + if ( pReqArgs ) // command from Navigator with nTab + { + // sheet for basic is one-based + nTab = static_cast<const SfxUInt16Item&>(pReqArgs->Get(nSlot)).GetValue() - 1; + if ( nTab < nTabCount ) + { + SetTabNo( nTab ); + rBindings.Update( nSlot ); + + if( ! rReq.IsAPI() ) + rReq.Done(); + } + } + else // command from Menu: ask for nTab + { + auto xRequest = std::make_shared<SfxRequest>(rReq); + rReq.Ignore(); + + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + + VclPtr<AbstractScGoToTabDlg> pDlg(pFact->CreateScGoToTabDlg(GetFrameWeld())); + pDlg->SetDescription( + ScResId( STR_DLG_SELECTTABLE_TITLE ), + ScResId( STR_DLG_SELECTTABLE_MASK ), + ScResId( STR_DLG_SELECTTABLE_LBNAME ), + GetStaticInterface()->GetSlot(SID_CURRENTTAB)->GetCommand(), HID_GOTOTABLEMASK, HID_GOTOTABLE ); + + // fill all table names and select current tab + OUString aTabName; + for( nTab = 0; nTab < nTabCount; ++nTab ) + { + if( rDoc.IsVisible( nTab ) ) + { + rDoc.GetName( nTab, aTabName ); + pDlg->Insert( aTabName, rViewData.GetTabNo() == nTab ); + } + } + + pDlg->StartExecuteAsync([this, nTab, nTabCount, pDlg, + xRequest=std::move(xRequest)](sal_Int32 response) { + if( response == RET_OK ) + { + auto nTab2 = nTab; + if( !GetViewData().GetDocument().GetTable( pDlg->GetSelectedEntry(), nTab2 ) ) + nTab2 = nTabCount; + if ( nTab2 < nTabCount ) + { + SetTabNo( nTab2 ); + + if ( !xRequest->IsAPI() ) + xRequest->Done(); + } + } + else + { + xRequest->Ignore(); + } + pDlg->disposeOnce(); + }); + } +} + void ScTabViewShell::FinishProtectTable() { TabChanged(); @@ -638,56 +709,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) case SID_CURRENTTAB: { - SCTAB nTab; - ScViewData& rViewData = GetViewData(); - ScDocument& rDoc = rViewData.GetDocument(); - SCTAB nTabCount = rDoc.GetTableCount(); - if ( pReqArgs ) // command from Navigator with nTab - { - // sheet for basic is one-based - nTab = static_cast<const SfxUInt16Item&>(pReqArgs->Get(nSlot)).GetValue() - 1; - } - else // command from Menu: ask for nTab - { - ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - - ScopedVclPtr<AbstractScGoToTabDlg> pDlg(pFact->CreateScGoToTabDlg(GetFrameWeld())); - pDlg->SetDescription( - ScResId( STR_DLG_SELECTTABLE_TITLE ), - ScResId( STR_DLG_SELECTTABLE_MASK ), - ScResId( STR_DLG_SELECTTABLE_LBNAME ), - GetStaticInterface()->GetSlot(SID_CURRENTTAB)->GetCommand(), HID_GOTOTABLEMASK, HID_GOTOTABLE ); - - // fill all table names and select current tab - OUString aTabName; - for( nTab = 0; nTab < nTabCount; ++nTab ) - { - if( rDoc.IsVisible( nTab ) ) - { - rDoc.GetName( nTab, aTabName ); - pDlg->Insert( aTabName, rViewData.GetTabNo() == nTab ); - } - } - - if( pDlg->Execute() == RET_OK ) - { - if( !rDoc.GetTable( pDlg->GetSelectedEntry(), nTab ) ) - nTab = nTabCount; - pDlg.disposeAndClear(); - } - else - { - rReq.Ignore(); - } - } - if ( nTab < nTabCount ) - { - SetTabNo( nTab ); - rBindings.Update( nSlot ); - - if( ! rReq.IsAPI() ) - rReq.Done(); - } + ExecGoToTab( rReq, rBindings ); //! otherwise an error ? } break; diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx index a5b1fa38f334..ac55cc4eb248 100644 --- a/vcl/jsdialog/enabled.cxx +++ b/vcl/jsdialog/enabled.cxx @@ -157,6 +157,7 @@ constexpr auto ScalcDialogList { u"modules/scalc/ui/formatcellsdialog.ui" }, { u"modules/scalc/ui/fourieranalysisdialog.ui" }, { u"modules/scalc/ui/goalseekdlg.ui" }, + { u"modules/scalc/ui/gotosheetdialog.ui" }, { u"modules/scalc/ui/groupdialog.ui" }, { u"modules/scalc/ui/headerfootercontent.ui" }, { u"modules/scalc/ui/headerfooterdialog.ui" },