summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2022-11-01 21:43:08 +0000
committerMichael Meeks <michael.meeks@collabora.com>2022-11-02 16:48:14 +0100
commit66a95dec001c5db891f20ddd5005fcc496bef4f8 (patch)
tree40c5539822b30a3521061824b0297416400fe4eb
parent1f231147e021dae0cb94a88e762eb79ca29bf0d4 (diff)
sc: make InsertCell and DeleteCell async.
Also enable for use with jsdialogs. Change-Id: I378f228e86959edb98ad691089af919330dcdcec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142163 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.cxx10
-rw-r--r--sc/source/ui/attrdlg/scdlgfact.hxx10
-rw-r--r--sc/source/ui/view/cellsh1.cxx122
-rw-r--r--vcl/jsdialog/enabled.cxx2
4 files changed, 89 insertions, 55 deletions
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index ab8741a9e8d8..7cea4669e784 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -137,6 +137,11 @@ short AbstractScDeleteCellDlg_Impl::Execute()
return m_xDlg->run();
}
+bool AbstractScDeleteCellDlg_Impl::StartExecuteAsync(AsyncContext& rCtx)
+{
+ return ScDeleteCellDlg::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
//for dataform
short AbstractScDataFormDlg_Impl::Execute()
{
@@ -174,6 +179,11 @@ short AbstractScInsertCellDlg_Impl::Execute()
return m_xDlg->run();
}
+bool AbstractScInsertCellDlg_Impl::StartExecuteAsync(AsyncContext& rCtx)
+{
+ return ScInsertCellDlg::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
short AbstractScInsertContentsDlg_Impl::Execute()
{
return m_xDlg->run();
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index b3756bb075af..e13efe7b5c93 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -218,13 +218,14 @@ public:
class AbstractScDeleteCellDlg_Impl : public AbstractScDeleteCellDlg
{
- std::unique_ptr<ScDeleteCellDlg> m_xDlg;
+ std::shared_ptr<ScDeleteCellDlg> m_xDlg;
public:
explicit AbstractScDeleteCellDlg_Impl(std::unique_ptr<ScDeleteCellDlg> p)
: m_xDlg(std::move(p))
{
}
- virtual short Execute() override;
+ virtual short Execute() override;
+ virtual bool StartExecuteAsync(AsyncContext& rCtx) override;
virtual DelCellCmd GetDelCellCmd() const override;
// screenshotting
@@ -299,13 +300,14 @@ public:
class AbstractScInsertCellDlg_Impl : public AbstractScInsertCellDlg
{
- std::unique_ptr<ScInsertCellDlg> m_xDlg;
+ std::shared_ptr<ScInsertCellDlg> m_xDlg;
public:
explicit AbstractScInsertCellDlg_Impl(std::unique_ptr<ScInsertCellDlg> p)
: m_xDlg(std::move(p))
{
}
- virtual short Execute() override;
+ virtual short Execute() override;
+ virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override;
virtual InsCellCmd GetInsCellCmd() const override ;
};
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index edd2dac01280..dd9726bc1ee0 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -168,6 +168,60 @@ void SetTabNoAndCursor( const ScViewData& rViewData, const OUString& rCellId )
pTabViewShell->SetCursor(aFoundPos.Col(), aFoundPos.Row());
}
}
+
+void InsertCells(ScTabViewShell* pTabViewShell, SfxRequest &rReq, InsCellCmd eCmd)
+{
+ if (eCmd!=INS_NONE)
+ {
+ pTabViewShell->InsertCells( eCmd );
+
+ if( ! rReq.IsAPI() )
+ {
+ OUString aParam;
+
+ switch( eCmd )
+ {
+ case INS_CELLSDOWN: aParam = "V"; break;
+ case INS_CELLSRIGHT: aParam = ">"; break;
+ case INS_INSROWS_BEFORE: aParam = "R"; break;
+ case INS_INSCOLS_BEFORE: aParam = "C"; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
+ rReq.Done();
+ }
+ }
+}
+
+void DeleteCells(ScTabViewShell* pTabViewShell, SfxRequest &rReq, DelCellCmd eCmd)
+{
+ if (eCmd != DelCellCmd::NONE )
+ {
+ pTabViewShell->DeleteCells( eCmd );
+
+ if( ! rReq.IsAPI() )
+ {
+ OUString aParam;
+
+ switch( eCmd )
+ {
+ case DelCellCmd::CellsUp: aParam = "U"; break;
+ case DelCellCmd::CellsLeft: aParam = "L"; break;
+ case DelCellCmd::Rows: aParam = "R"; break;
+ case DelCellCmd::Cols: aParam = "C"; break;
+ default:
+ {
+ // added to avoid warnings
+ }
+ }
+ rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
+ rReq.Done();
+ }
+ }
+}
}
void ScCellShell::ExecuteEdit( SfxRequest& rReq )
@@ -286,35 +340,19 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
- ScopedVclPtr<AbstractScInsertCellDlg> pDlg(pFact->CreateScInsertCellDlg(pTabViewShell->GetFrameWeld(), bTheFlag));
- if (pDlg->Execute() == RET_OK)
- eCmd = pDlg->GetInsCellCmd();
- }
- }
-
- if (eCmd!=INS_NONE)
- {
- pTabViewShell->InsertCells( eCmd );
-
- if( ! rReq.IsAPI() )
- {
- OUString aParam;
-
- switch( eCmd )
- {
- case INS_CELLSDOWN: aParam = "V"; break;
- case INS_CELLSRIGHT: aParam = ">"; break;
- case INS_INSROWS_BEFORE: aParam = "R"; break;
- case INS_INSCOLS_BEFORE: aParam = "C"; break;
- default:
+ VclPtr<AbstractScInsertCellDlg> pDlg(pFact->CreateScInsertCellDlg(pTabViewShell->GetFrameWeld(), bTheFlag));
+ pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
+ if (nResult == RET_OK)
{
- // added to avoid warnings
+ SfxRequest aRequest(pTabViewShell->GetViewFrame(), FID_INS_CELL);
+ InsertCells(pTabViewShell, aRequest, pDlg->GetInsCellCmd());
}
- }
- rReq.AppendItem( SfxStringItem( FID_INS_CELL, aParam ) );
- rReq.Done();
+ pDlg->disposeOnce();
+ });
}
}
+
+ InsertCells(pTabViewShell, rReq, eCmd);
}
break;
@@ -355,37 +393,19 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
(rDoc.GetChangeTrack() != nullptr);
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
+ VclPtr<AbstractScDeleteCellDlg> pDlg(pFact->CreateScDeleteCellDlg( pTabViewShell->GetFrameWeld(), bTheFlag ));
- ScopedVclPtr<AbstractScDeleteCellDlg> pDlg(pFact->CreateScDeleteCellDlg( pTabViewShell->GetFrameWeld(), bTheFlag ));
-
- if (pDlg->Execute() == RET_OK)
- eCmd = pDlg->GetDelCellCmd();
- }
- }
-
- if (eCmd != DelCellCmd::NONE )
- {
- pTabViewShell->DeleteCells( eCmd );
-
- if( ! rReq.IsAPI() )
- {
- OUString aParam;
-
- switch( eCmd )
- {
- case DelCellCmd::CellsUp: aParam = "U"; break;
- case DelCellCmd::CellsLeft: aParam = "L"; break;
- case DelCellCmd::Rows: aParam = "R"; break;
- case DelCellCmd::Cols: aParam = "C"; break;
- default:
+ pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){
+ if (nResult == RET_OK)
{
- // added to avoid warnings
+ SfxRequest aRequest(pTabViewShell->GetViewFrame(), FID_INS_CELL);
+ DeleteCells(pTabViewShell, aRequest, pDlg->GetDelCellCmd());
}
- }
- rReq.AppendItem( SfxStringItem( FID_DELETE_CELL, aParam ) );
- rReq.Done();
+ pDlg->disposeOnce();
+ });
}
}
+ DeleteCells(pTabViewShell, rReq, eCmd);
}
break;
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index fff272b25ad7..fd2afd7bbf68 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -50,6 +50,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool bMobile)
|| rUIFile == u"modules/scalc/ui/datafielddialog.ui"
|| rUIFile == u"modules/scalc/ui/pivotfielddialog.ui"
|| rUIFile == u"modules/scalc/ui/datafieldoptionsdialog.ui"
+ || rUIFile == u"modules/scalc/ui/insertcells.ui"
+ || rUIFile == u"modules/scalc/ui/deletecells.ui"
|| rUIFile == u"svx/ui/fontworkgallerydialog.ui"
|| rUIFile == u"svx/ui/findreplacedialog.ui" || rUIFile == u"cui/ui/macroselectordialog.ui"
|| rUIFile == u"uui/ui/macrowarnmedium.ui"