sc/source/ui/attrdlg/scdlgfact.cxx |    7 ++
 sc/source/ui/attrdlg/scdlgfact.hxx |    5 +
 sc/source/ui/view/cellsh3.cxx      |   96 +++++++++++++++++++++----------------
 3 files changed, 65 insertions(+), 43 deletions(-)

New commits:
commit f7e1018f88f400aeee91a0b85a26964492e216fc
Author:     rash419 <rashesh.pa...@collabora.com>
AuthorDate: Tue Apr 12 20:00:13 2022 +0530
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Fri Apr 15 10:47:56 2022 +0200

    sc: convert optimal width/height and normal width/height dialog to async
    
    Signed-off-by: rash419 <rashesh.pa...@collabora.com>
    Change-Id: I96f6d90692d7767bdc276f753897bdc392c90411
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132919
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index 928f235882ad..57648f857fef 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -192,6 +192,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();
@@ -1105,7 +1110,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 46583103919f..b7e8d9efbe65 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -392,13 +392,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 924ce27ab5f8..e2e31108c944 100644
--- a/sc/source/ui/view/cellsh3.cxx
+++ b/sc/source/ui/view/cellsh3.cxx
@@ -697,21 +697,24 @@ void ScCellShell::Execute( SfxRequest& rReq )
                                                 GetRowHeight( pData->GetCurY(),
                                                               
pData->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;
@@ -735,20 +738,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, 1, 
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;
@@ -796,19 +803,23 @@ void ScCellShell::Execute( SfxRequest& rReq )
                                                 GetColWidth( pData->GetCurX(),
                                                              pData->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;
@@ -832,19 +843,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, 1, 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;

Reply via email to