summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2024-01-24 11:34:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-01-24 19:53:59 +0100
commit5d993a39c60d9184ddc3dbdaa9854ec1ecc99464 (patch)
treecac8b7a9fce7f2a8ba908d93f18c5dff6deb1d93 /sc
parent38f98c60e797753fa54bf3649520995df9861b45 (diff)
make insert table dialog async
Change-Id: I4fd880ed2b1f07439229750e77246cf9cb2df5f3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162498 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx5
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx5
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx3
-rw-r--r--sc/source/ui/view/tabvwshf.cxx167
4 files changed, 102 insertions, 78 deletions
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 24fecf8e9966..8cbd923ce63a 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -199,6 +199,11 @@ short AbstractScInsertTableDlg_Impl::Execute()
return m_xDlg->run();
}
+bool AbstractScInsertTableDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx)
+{
+ return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
short AbstractScSelEntryDlg_Impl::Execute()
{
return m_xDlg->run();
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 954e58f0f2a8..7591b7338801 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -295,13 +295,14 @@ public:
class AbstractScInsertTableDlg_Impl : public AbstractScInsertTableDlg
{
- std::unique_ptr<ScInsertTableDlg> m_xDlg;
+ std::shared_ptr<ScInsertTableDlg> m_xDlg;
public:
- explicit AbstractScInsertTableDlg_Impl(std::unique_ptr<ScInsertTableDlg> p)
+ explicit AbstractScInsertTableDlg_Impl(std::shared_ptr<ScInsertTableDlg> p)
: m_xDlg(std::move(p))
{
}
virtual short Execute() override;
+ virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override;
virtual bool GetTablesFromFile() override;
virtual bool GetTablesAsLink() override;
virtual const OUString* GetFirstTable( sal_uInt16* pN = nullptr ) override;
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 219fb3534d60..b85400e02692 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -41,7 +41,7 @@ class SfxBindings;
class SfxChildWindow;
class SvxNumberInfoItem;
struct SfxChildWinInfo;
-
+class AbstractScInsertTableDlg;
class ScArea;
class ScAuditingShell;
class ScDrawShell;
@@ -455,6 +455,7 @@ public:
private:
void ExecuteMoveTable( SfxRequest& rReq );
void ExecuteInsertTable( SfxRequest& rReq );
+ void DoInsertTableFromDialog( SfxRequest& rReq, const VclPtr<AbstractScInsertTableDlg>& pDlg );
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshf.cxx b/sc/source/ui/view/tabvwshf.cxx
index 41781f2cee19..c7a53f87427d 100644
--- a/sc/source/ui/view/tabvwshf.cxx
+++ b/sc/source/ui/view/tabvwshf.cxx
@@ -1126,97 +1126,114 @@ void ScTabViewShell::ExecuteInsertTable(SfxRequest& rReq)
}
else // dialog
{
+ auto xRequest = std::make_shared<SfxRequest>(rReq);
+ rReq.Ignore(); // the 'old' request is not relevant any more
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
-
- ScopedVclPtr<AbstractScInsertTableDlg> pDlg(pFact->CreateScInsertTableDlg(GetFrameWeld(), rViewData,
+ VclPtr<AbstractScInsertTableDlg> pDlg(pFact->CreateScInsertTableDlg(GetFrameWeld(), rViewData,
nTabSelCount, nSlot == FID_INS_TABLE_EXT));
- if ( RET_OK == pDlg->Execute() )
- {
- if (pDlg->GetTablesFromFile())
+ pDlg->StartExecuteAsync(
+ [this, pDlg, xRequest] (sal_Int32 nResult)->void
{
- std::vector<SCTAB> nTabs;
- sal_uInt16 n = 0;
- const OUString* pStr = pDlg->GetFirstTable( &n );
- while ( pStr )
- {
- nTabs.push_back( static_cast<SCTAB>(n) );
- pStr = pDlg->GetNextTable( &n );
- }
- bool bLink = pDlg->GetTablesAsLink();
- if (!nTabs.empty())
- {
- if(pDlg->IsTableBefore())
- {
- ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
- bLink,nTabNr );
- }
- else
- {
- SCTAB nTabAfter = nTabNr+1;
+ if (nResult == RET_OK)
+ DoInsertTableFromDialog(*xRequest, pDlg);
+ pDlg->disposeOnce();
+ }
+ );
+ }
+}
- for(SCTAB j=nCurrentTab+1;j<nTabCount;j++)
- {
- if(!rDoc.IsScenario(j))
- {
- nTabAfter=j;
- break;
- }
- }
+void ScTabViewShell::DoInsertTableFromDialog(SfxRequest& rReq, const VclPtr<AbstractScInsertTableDlg>& pDlg)
+{
+ ScViewData& rViewData = GetViewData();
+ ScDocument& rDoc = rViewData.GetDocument();
+ SCTAB nCurrentTab = rViewData.GetTabNo();
+ SCTAB nTabNr = nCurrentTab;
+ SCTAB nTabCount = rDoc.GetTableCount();
+ ScMarkData& rMark = rViewData.GetMarkData();
- ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
- bLink,nTabAfter );
- }
- }
+ if (pDlg->GetTablesFromFile())
+ {
+ std::vector<SCTAB> nTabs;
+ sal_uInt16 n = 0;
+ const OUString* pStr = pDlg->GetFirstTable( &n );
+ while ( pStr )
+ {
+ nTabs.push_back( static_cast<SCTAB>(n) );
+ pStr = pDlg->GetNextTable( &n );
+ }
+ bool bLink = pDlg->GetTablesAsLink();
+ if (!nTabs.empty())
+ {
+ if(pDlg->IsTableBefore())
+ {
+ ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
+ bLink,nTabNr );
}
else
{
- SCTAB nCount=pDlg->GetTableCount();
- if(pDlg->IsTableBefore())
- {
- if(nCount==1 && !pDlg->GetFirstTable()->isEmpty())
- {
- rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
- rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabNr) + 1 ) ); // 1-based
- rReq.Done();
+ SCTAB nTabAfter = nTabNr+1;
- InsertTable( *pDlg->GetFirstTable(), nTabNr );
- }
- else
+ for(SCTAB j=nCurrentTab+1;j<nTabCount;j++)
+ {
+ if(!rDoc.IsScenario(j))
{
- std::vector<OUString> aNames(0);
- InsertTables( aNames, nTabNr,nCount );
+ nTabAfter=j;
+ break;
}
}
- else
- {
- SCTAB nTabAfter = nTabNr+1;
- SCTAB nSelHigh = rMark.GetLastSelected();
- for(SCTAB j=nSelHigh+1;j<nTabCount;j++)
- {
- if(!rDoc.IsScenario(j))
- {
- nTabAfter=j;
- break;
- }
- else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
- nTabAfter = j + 1;
- }
+ ImportTables( pDlg->GetDocShellTables(), nTabs.size(), nTabs.data(),
+ bLink,nTabAfter );
+ }
+ }
+ }
+ else
+ {
+ SCTAB nCount=pDlg->GetTableCount();
+ if(pDlg->IsTableBefore())
+ {
+ if(nCount==1 && !pDlg->GetFirstTable()->isEmpty())
+ {
+ rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabNr) + 1 ) ); // 1-based
+ rReq.Done();
- if(nCount==1 && !pDlg->GetFirstTable()->isEmpty())
- {
- rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
- rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabAfter) + 1 ) ); // 1-based
- rReq.Done();
+ InsertTable( *pDlg->GetFirstTable(), nTabNr );
+ }
+ else
+ {
+ std::vector<OUString> aNames(0);
+ InsertTables( aNames, nTabNr,nCount );
+ }
+ }
+ else
+ {
+ SCTAB nTabAfter = nTabNr+1;
+ SCTAB nSelHigh = rMark.GetLastSelected();
- InsertTable( *pDlg->GetFirstTable(), nTabAfter);
- }
- else
- {
- std::vector<OUString> aNames(0);
- InsertTables( aNames, nTabAfter,nCount);
- }
+ for(SCTAB j=nSelHigh+1;j<nTabCount;j++)
+ {
+ if(!rDoc.IsScenario(j))
+ {
+ nTabAfter=j;
+ break;
}
+ else // #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
+ nTabAfter = j + 1;
+ }
+
+ if(nCount==1 && !pDlg->GetFirstTable()->isEmpty())
+ {
+ rReq.AppendItem( SfxStringItem( FID_INS_TABLE, *pDlg->GetFirstTable() ) );
+ rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(nTabAfter) + 1 ) ); // 1-based
+ rReq.Done();
+
+ InsertTable( *pDlg->GetFirstTable(), nTabAfter);
+ }
+ else
+ {
+ std::vector<OUString> aNames(0);
+ InsertTables( aNames, nTabAfter,nCount);
}
}
}