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 46c2581503b7a98b85dff8994109dd67af45b5e6
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 16:47:11 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>
    (cherry picked from commit 4ff32749721a50f3ce8769306e8442652d6355d2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188037
    Tested-by: Jenkins

diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 1da1020a005a..742245975dd2 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -421,6 +421,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 5a4fd2fc700a..c75bd174ac19 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 4a21a7d05478..530a21e5ad5c 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -155,6 +155,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" },

Reply via email to