[Libreoffice-commits] core.git: sc/inc sc/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 28 13:26:46 UTC 2020


 sc/inc/scabstdlg.hxx               |   11 +++++-
 sc/source/ui/attrdlg/scdlgfact.cxx |   19 +++++++++-
 sc/source/ui/attrdlg/scdlgfact.hxx |   15 +++++++-
 sc/source/ui/view/cellsh2.cxx      |   65 ++++++++-----------------------------
 4 files changed, 56 insertions(+), 54 deletions(-)

New commits:
commit 70b81e74d2a14308e1897d840c681404225d328a
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jul 21 11:40:22 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Jul 28 15:26:02 2020 +0200

    Make Sort dialog async
    
    Change-Id: I914e09e59561e261dc2807ad00615d3b58afa541
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99127
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99351
    Tested-by: Jenkins

diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index c05b96f1c2e8..d3bdb6e4e0f1 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -50,6 +50,15 @@ enum class CellShiftDisabledFlags;
 
 namespace com::sun::star::sheet { struct DataPilotFieldReference; }
 
+class ScAsyncTabController
+{
+public:
+    virtual ~ScAsyncTabController() = default;
+    virtual bool  StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) = 0;
+    virtual const SfxItemSet*   GetOutputItemSet() const = 0;
+    virtual void                SetCurPageId( const OString &rName ) = 0;
+};
+
 class AbstractScImportAsciiDlg : public VclAbstractDialog
 {
 protected:
@@ -537,7 +546,7 @@ public:
     virtual VclPtr<SfxAbstractTabDialog> CreateScParagraphDlg(weld::Window* pParent,
         const SfxItemSet* pAttr) = 0;
 
-    virtual VclPtr<SfxAbstractTabDialog> CreateScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet) = 0;
+    virtual std::shared_ptr<ScAsyncTabController> CreateScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet) = 0;
 
     // for tabpage
     virtual CreateTabPage                GetTabPageCreatorFunc( sal_uInt16 nId ) = 0;
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 55340b185d8b..071e19038590 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -921,6 +921,21 @@ OString ScAbstractTabController_Impl::GetScreenshotId() const
     return m_xDlg->GetScreenshotId();
 }
 
+bool ScAsyncTabController_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx)
+{
+    return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
+void ScAsyncTabController_Impl::SetCurPageId( const OString &rName )
+{
+    m_xDlg->SetCurPageId( rName );
+}
+
+const SfxItemSet* ScAsyncTabController_Impl::GetOutputItemSet() const
+{
+    return m_xDlg->GetOutputItemSet();
+}
+
 // =========================Factories  for createdialog ===================
 VclPtr<AbstractScImportAsciiDlg> ScAbstractDialogFactory_Impl::CreateScImportAsciiDlg(weld::Window* pParent,
                                                     const OUString& aDatName,
@@ -1224,9 +1239,9 @@ VclPtr<SfxAbstractTabDialog> ScAbstractDialogFactory_Impl::CreateScParagraphDlg(
     return VclPtr<ScAbstractTabController_Impl>::Create(std::make_shared<ScParagraphDlg>(pParent, pAttr));
 }
 
-VclPtr<SfxAbstractTabDialog> ScAbstractDialogFactory_Impl::CreateScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet)
+std::shared_ptr<ScAsyncTabController> ScAbstractDialogFactory_Impl::CreateScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet)
 {
-    return VclPtr<ScAbstractTabController_Impl>::Create(std::make_shared<ScSortDlg>(pParent, pArgSet));
+    return std::make_shared<ScAsyncTabController_Impl>(std::make_shared<ScSortDlg>(pParent, pArgSet));
 }
 
 //------------------ Factories for TabPages--------------------
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index ddcdef3cadf7..f1d26bf8e65c 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -652,6 +652,19 @@ public:
     virtual OString GetScreenshotId() const override;
 };
 
+class ScAsyncTabController_Impl : public ScAsyncTabController
+{
+    std::shared_ptr<SfxTabDialogController> m_xDlg;
+public:
+    explicit ScAsyncTabController_Impl(std::shared_ptr<SfxTabDialogController> p)
+        : m_xDlg(std::move(p))
+    {
+    }
+    virtual bool  StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override;
+    virtual const SfxItemSet*   GetOutputItemSet() const override;
+    virtual void                SetCurPageId( const OString &rName ) override;
+};
+
 //AbstractDialogFactory_Impl implementations
 class ScAbstractDialogFactory_Impl : public ScAbstractDialogFactory
 {
@@ -803,7 +816,7 @@ public:
     virtual VclPtr<SfxAbstractTabDialog> CreateScParagraphDlg(weld::Window* pParent,
         const SfxItemSet* pAttr) override;
 
-    virtual VclPtr<SfxAbstractTabDialog> CreateScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet) override;
+    virtual std::shared_ptr<ScAsyncTabController> CreateScSortDlg(weld::Window* pParent, const SfxItemSet* pArgSet) override;
 
     // For TabPage
     virtual CreateTabPage                GetTabPageCreatorFunc( sal_uInt16 nId ) override;
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
index 75f5b463a58c..7f527796c899 100644
--- a/sc/source/ui/view/cellsh2.cxx
+++ b/sc/source/ui/view/cellsh2.cxx
@@ -515,64 +515,29 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
                         aArgSet.Put( ScSortItem( SCITEM_SORTDATA, GetViewData(), &aSortParam ) );
 
                         ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
-                        ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateScSortDlg(pTabViewShell->GetFrameWeld(),  &aArgSet));
+                        std::shared_ptr<ScAsyncTabController> pDlg(pFact->CreateScSortDlg(pTabViewShell->GetFrameWeld(),  &aArgSet));
                         pDlg->SetCurPageId("criteria");  // 1=sort field tab  2=sort options tab
 
-                        if ( pDlg->Execute() == RET_OK )
-                        {
-                            const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
-                            const ScSortParam& rOutParam = static_cast<const ScSortItem&>(
-                                pOutSet->Get( SCITEM_SORTDATA )).GetSortData();
-
-                            // subtotal when needed new
-
-                            pTabViewShell->UISort( rOutParam );
-
-                            if ( rOutParam.bInplace )
+                        VclAbstractDialog::AsyncContext aContext;
+                        aContext.maEndDialogFn = [pDlg, pData, pTabViewShell](sal_Int32 nResult)
                             {
-                                rReq.AppendItem( SfxBoolItem( SID_SORT_BYROW,
-                                    rOutParam.bByRow ) );
-                                rReq.AppendItem( SfxBoolItem( SID_SORT_HASHEADER,
-                                    rOutParam.bHasHeader ) );
-                                rReq.AppendItem( SfxBoolItem( SID_SORT_CASESENS,
-                                    rOutParam.bCaseSens ) );
-                                rReq.AppendItem( SfxBoolItem( SID_SORT_NATURALSORT,
-                                            rOutParam.bNaturalSort ) );
-                                rReq.AppendItem( SfxBoolItem( SID_SORT_INCCOMMENTS,
-                                            rOutParam.bIncludeComments ) );
-                                rReq.AppendItem( SfxBoolItem( SID_SORT_INCIMAGES,
-                                            rOutParam.bIncludeGraphicObjects ) );
-                                rReq.AppendItem( SfxBoolItem( SID_SORT_ATTRIBS,
-                                    rOutParam.bIncludePattern ) );
-                                sal_uInt16 nUser = rOutParam.bUserDef ? ( rOutParam.nUserIndex + 1 ) : 0;
-                                rReq.AppendItem( SfxUInt16Item( SID_SORT_USERDEF, nUser ) );
-                                if ( rOutParam.maKeyState[0].bDoSort )
-                                {
-                                    rReq.AppendItem( SfxInt32Item( FN_PARAM_1,
-                                        rOutParam.maKeyState[0].nField + 1 ) );
-                                    rReq.AppendItem( SfxBoolItem( FN_PARAM_2,
-                                        rOutParam.maKeyState[0].bAscending ) );
-                                }
-                                if ( rOutParam.maKeyState[1].bDoSort )
+                                if ( nResult == RET_OK )
                                 {
-                                    rReq.AppendItem( SfxInt32Item( FN_PARAM_3,
-                                        rOutParam.maKeyState[1].nField + 1 ) );
-                                    rReq.AppendItem( SfxBoolItem( FN_PARAM_4,
-                                        rOutParam.maKeyState[1].bAscending ) );
+                                    const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
+                                    const ScSortParam& rOutParam = static_cast<const ScSortItem&>(
+                                        pOutSet->Get( SCITEM_SORTDATA )).GetSortData();
+
+                                    // subtotal when needed new
+
+                                    pTabViewShell->UISort( rOutParam );
                                 }
-                                if ( rOutParam.maKeyState[2].bDoSort )
+                                else
                                 {
-                                    rReq.AppendItem( SfxInt32Item( FN_PARAM_5,
-                                        rOutParam.maKeyState[2].nField + 1 ) );
-                                    rReq.AppendItem( SfxBoolItem( FN_PARAM_6,
-                                        rOutParam.maKeyState[2].bAscending ) );
+                                    pData->GetDocShell()->CancelAutoDBRange();
                                 }
-                            }
+                            };
 
-                            rReq.Done();
-                        }
-                        else
-                            GetViewData()->GetDocShell()->CancelAutoDBRange();
+                        pDlg->StartExecuteAsync(aContext);
                     }
                 }
             }


More information about the Libreoffice-commits mailing list