diff options
author | rash419 <rashesh.padia@collabora.com> | 2022-04-12 20:00:13 +0530 |
---|---|---|
committer | Aron Budea <aron.budea@collabora.com> | 2022-11-15 06:34:37 +0100 |
commit | 057eca05f23d9d15465e591bd0da671735d62d50 (patch) | |
tree | 28aed68078b52ffb35544cb5ad965bba4935dd26 /sc | |
parent | e340b81d9d75d3aacfa941df4b531c6a9f5aaffa (diff) |
sc: convert optimal width/height and normal width/height dialog to async
Signed-off-by: rash419 <rashesh.padia@collabora.com>
Change-Id: I96f6d90692d7767bdc276f753897bdc392c90411
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132919
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133127
Reviewed-by: Gökay ŞATIR <gokaysatir@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142633
Tested-by: Jenkins
Reviewed-by: Aron Budea <aron.budea@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/attrdlg/scdlgfact.hxx | 5 | ||||
-rw-r--r-- | sc/source/ui/view/cellsh3.cxx | 96 |
3 files changed, 65 insertions, 43 deletions
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx index 722c3b8c29e4..0eca6bafb8a7 100644 --- a/sc/source/ui/attrdlg/scdlgfact.cxx +++ b/sc/source/ui/attrdlg/scdlgfact.cxx @@ -204,6 +204,11 @@ short AbstractScMetricInputDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractScMetricInputDlg_Impl::StartExecuteAsync(AsyncContext& rCtx) +{ + return ScMetricInputDlg::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractScMoveTableDlg_Impl::Execute() { return m_xDlg->run(); @@ -1149,7 +1154,7 @@ VclPtr<AbstractScMetricInputDlg> ScAbstractDialogFactory_Impl::CreateScMetricInp tools::Long nMaximum , tools::Long nMinimum ) { - return VclPtr<AbstractScMetricInputDlg_Impl>::Create(std::make_unique<ScMetricInputDlg>(pParent, sDialogName, nCurrent ,nDefault, eFUnit, + return VclPtr<AbstractScMetricInputDlg_Impl>::Create(std::make_shared<ScMetricInputDlg>(pParent, sDialogName, nCurrent ,nDefault, eFUnit, nDecimals, nMaximum , nMinimum)); } diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx index 35782000b979..e39428018287 100644 --- a/sc/source/ui/attrdlg/scdlgfact.hxx +++ b/sc/source/ui/attrdlg/scdlgfact.hxx @@ -348,13 +348,14 @@ public: class AbstractScMetricInputDlg_Impl : public AbstractScMetricInputDlg { - std::unique_ptr<ScMetricInputDlg> m_xDlg; + std::shared_ptr<ScMetricInputDlg> m_xDlg; public: - explicit AbstractScMetricInputDlg_Impl(std::unique_ptr<ScMetricInputDlg> p) + explicit AbstractScMetricInputDlg_Impl(std::shared_ptr<ScMetricInputDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext& rCtx) override; virtual int GetInputValue() const override; }; diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx index a0d08a605058..9ab0e09ac00e 100644 --- a/sc/source/ui/view/cellsh3.cxx +++ b/sc/source/ui/view/cellsh3.cxx @@ -687,21 +687,24 @@ void ScCellShell::Execute( SfxRequest& rReq ) GetRowHeight( rData.GetCurY(), rData.GetTabNo() ); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( + VclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( pTabViewShell->GetFrameWeld(), "RowHeightDialog", nCurHeight, ScGlobal::nStdRowHeight, eMetric, 2, MAX_ROW_HEIGHT)); - if ( pDlg->Execute() == RET_OK ) - { - tools::Long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nVal) ); - - // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); - rReq.Done(); + pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){ + if (nResult == RET_OK) + { + SfxRequest pRequest(pTabViewShell->GetViewFrame(), FID_ROW_HEIGHT); + tools::Long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nVal) ); - } + // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert + pRequest.AppendItem( SfxUInt16Item( FID_ROW_HEIGHT, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); + pRequest.Done(); + } + pDlg->disposeOnce(); + }); } } break; @@ -725,20 +728,24 @@ void ScCellShell::Execute( SfxRequest& rReq ) FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( + VclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( pTabViewShell->GetFrameWeld(), "OptimalRowHeightDialog", ScGlobal::nLastRowHeightExtra, 0, eMetric, 2, MAX_EXTRA_HEIGHT)); - if ( pDlg->Execute() == RET_OK ) - { - tools::Long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL, static_cast<sal_uInt16>(nVal) ); - ScGlobal::nLastRowHeightExtra = nVal; - - // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); - rReq.Done(); - } + pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){ + if ( nResult == RET_OK ) + { + SfxRequest pRequest(pTabViewShell->GetViewFrame(), FID_ROW_OPT_HEIGHT); + tools::Long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( false, SC_SIZE_OPTIMAL, static_cast<sal_uInt16>(nVal) ); + ScGlobal::nLastRowHeightExtra = nVal; + + // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert + pRequest.AppendItem( SfxUInt16Item( FID_ROW_OPT_HEIGHT, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); + pRequest.Done(); + } + pDlg->disposeOnce(); + }); } } break; @@ -786,19 +793,23 @@ void ScCellShell::Execute( SfxRequest& rReq ) GetColWidth( rData.GetCurX(), rData.GetTabNo() ); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( + VclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( pTabViewShell->GetFrameWeld(), "ColWidthDialog", nCurHeight, STD_COL_WIDTH, eMetric, 2, MAX_COL_WIDTH)); - if ( pDlg->Execute() == RET_OK ) - { - tools::Long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nVal) ); - // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_COL_WIDTH, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal))) ); - rReq.Done(); + pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){ + if ( nResult == RET_OK ) + { + SfxRequest pRequest(pTabViewShell->GetViewFrame(), FID_COL_WIDTH); + tools::Long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_DIRECT, static_cast<sal_uInt16>(nVal) ); - } + // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert + pRequest.AppendItem( SfxUInt16Item( FID_COL_WIDTH, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal))) ); + pRequest.Done(); + } + pDlg->disposeOnce(); + }); } } break; @@ -822,19 +833,24 @@ void ScCellShell::Execute( SfxRequest& rReq ) FieldUnit eMetric = SC_MOD()->GetAppOptions().GetAppMetric(); ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( + VclPtr<AbstractScMetricInputDlg> pDlg(pFact->CreateScMetricInputDlg( pTabViewShell->GetFrameWeld(), "OptimalColWidthDialog", ScGlobal::nLastColWidthExtra, STD_EXTRA_WIDTH, eMetric, 2, MAX_EXTRA_WIDTH)); - if ( pDlg->Execute() == RET_OK ) - { - tools::Long nVal = pDlg->GetInputValue(); - pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL, static_cast<sal_uInt16>(nVal) ); - ScGlobal::nLastColWidthExtra = nVal; - // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert - rReq.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); - rReq.Done(); - } + pDlg->StartExecuteAsync([pDlg, pTabViewShell](sal_Int32 nResult){ + SfxRequest pRequest(pTabViewShell->GetViewFrame(), FID_COL_OPT_WIDTH); + if ( nResult == RET_OK ) + { + tools::Long nVal = pDlg->GetInputValue(); + pTabViewShell->SetMarkedWidthOrHeight( true, SC_SIZE_OPTIMAL, static_cast<sal_uInt16>(nVal) ); + ScGlobal::nLastColWidthExtra = nVal; + + // #101390#; the value of the macro should be in HMM so use TwipsToEvenHMM to convert + pRequest.AppendItem( SfxUInt16Item( FID_COL_OPT_WIDTH, static_cast<sal_uInt16>(TwipsToEvenHMM(nVal)) ) ); + pRequest.Done(); + } + pDlg->disposeOnce(); + }); } } break; |