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 7f7e81f70304d672b85fe457c126285a5abac103
Author:     rash419 <rashesh.pa...@collabora.com>
AuthorDate: Tue Apr 12 20:00:13 2022 +0530
Commit:     Gökay ŞATIR <gokaysa...@collabora.com>
CommitDate: Thu Apr 21 18:28:28 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>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133127
    Reviewed-by: Gökay ŞATIR <gokaysa...@collabora.com>

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx 
b/sc/source/ui/attrdlg/scdlgfact.cxx
index 9fbfccaa4d38..ab8741a9e8d8 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -194,6 +194,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();
@@ -1112,7 +1117,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 fef206002dea..b3756bb075af 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -390,13 +390,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 f24c06e9a0d2..f5c1155ec218 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;

Reply via email to