sc: make InsertCell and DeleteCell async.
Also enable them for use with jsdialogs. Change-Id: I378f228e86959edb98ad691089af919330dcdcec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142144 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -174,13 +174,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
|
||||
@@ -255,13 +256,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 ;
|
||||
};
|
||||
|
||||
|
||||
@@ -169,6 +169,60 @@ void SetTabNoAndCursor( const ScViewData& rViewData, std::u16string_view 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 )
|
||||
@@ -287,35 +341,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;
|
||||
|
||||
@@ -356,37 +394,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;
|
||||
|
||||
|
||||
@@ -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"svx/ui/findreplacedialog.ui"
|
||||
|| rUIFile == u"cui/ui/macroselectordialog.ui" || rUIFile == u"uui/ui/macrowarnmedium.ui"
|
||||
|
||||
Reference in New Issue
Block a user