[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - cui/source svx/source sw/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 6 11:34:22 UTC 2020


 cui/source/dialogs/splitcelldlg.cxx  |   35 ++++++++++++++++++++++++++++++-----
 cui/source/factory/dlgfact.cxx       |    2 +-
 cui/source/inc/splitcelldlg.hxx      |   20 ++++++++++++++++++--
 svx/source/table/tablecontroller.cxx |    9 +++++----
 sw/source/uibase/shells/tabsh.cxx    |   33 +++++++++++++++++++--------------
 5 files changed, 73 insertions(+), 26 deletions(-)

New commits:
commit ca189b78bc9bfb0e6fad72e3374bf8e8408093f0
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Sep 30 10:49:12 2020 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Oct 6 13:33:45 2020 +0200

    Make Split Table Cell dialog async
    
    Change-Id: I4efbb24f721aa50cc4dbbe78ae1e7e6087f8c876
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103670
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/cui/source/dialogs/splitcelldlg.cxx b/cui/source/dialogs/splitcelldlg.cxx
index 40b798b7c2c9..3de8082c939a 100644
--- a/cui/source/dialogs/splitcelldlg.cxx
+++ b/cui/source/dialogs/splitcelldlg.cxx
@@ -74,15 +74,40 @@ long SvxSplitTableDlg::GetCount() const
     return m_xCountEdit->get_value();
 }
 
-short SvxSplitTableDlg::Execute()
-{
-    return run();
-}
-
 void SvxSplitTableDlg::SetSplitVerticalByDefault()
 {
     if( mnMaxVertical >= 2 )
         m_xVertBox->set_active(true); // tdf#60242
 }
 
+bool SvxAbstractSplitTableDialog_Impl::IsHorizontal() const
+{
+    return m_xDlg->IsHorizontal();
+}
+
+bool SvxAbstractSplitTableDialog_Impl::IsProportional() const
+{
+    return m_xDlg->IsProportional();
+}
+
+long SvxAbstractSplitTableDialog_Impl::GetCount() const
+{
+    return m_xDlg->GetCount();
+}
+
+void SvxAbstractSplitTableDialog_Impl::SetSplitVerticalByDefault()
+{
+    m_xDlg->SetSplitVerticalByDefault();
+}
+
+short SvxAbstractSplitTableDialog_Impl::Execute()
+{
+    return m_xDlg->run();
+}
+
+bool SvxAbstractSplitTableDialog_Impl::StartExecuteAsync(AsyncContext& rContext)
+{
+    return weld::DialogController::runAsync(m_xDlg, rContext.maEndDialogFn);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 46180fc4435c..be6351d04b8b 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -1619,7 +1619,7 @@ std::shared_ptr<AbstractTabController> AbstractDialogFactory_Impl::CreateSvxForm
 
 VclPtr<SvxAbstractSplitTableDialog> AbstractDialogFactory_Impl::CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical)
 {
-    return VclPtr<SvxSplitTableDlg>::Create( pParent, bIsTableVertical, nMaxVertical, 99 );
+    return VclPtr<SvxAbstractSplitTableDialog_Impl>::Create( std::make_shared<SvxSplitTableDlg>(pParent, bIsTableVertical, nMaxVertical, 99 ));
 }
 
 std::shared_ptr<SvxAbstractNewTableDialog> AbstractDialogFactory_Impl::CreateSvxNewTableDialog(weld::Window* pParent)
diff --git a/cui/source/inc/splitcelldlg.hxx b/cui/source/inc/splitcelldlg.hxx
index b0c2fddae3c7..44df027d3a93 100644
--- a/cui/source/inc/splitcelldlg.hxx
+++ b/cui/source/inc/splitcelldlg.hxx
@@ -22,7 +22,7 @@
 #include <svx/svxdlg.hxx>
 #include <vcl/weld.hxx>
 
-class SvxSplitTableDlg : public SvxAbstractSplitTableDialog, public weld::GenericDialogController
+class SvxSplitTableDlg : public weld::GenericDialogController
 {
 private:
     std::unique_ptr<weld::SpinButton> m_xCountEdit;
@@ -38,12 +38,28 @@ public:
 
     DECL_LINK(ClickHdl, weld::Button&, void);
 
+    virtual bool IsHorizontal() const;
+    virtual bool IsProportional() const;
+    virtual long GetCount() const;
+
+    virtual void SetSplitVerticalByDefault();
+};
+
+class SvxAbstractSplitTableDialog_Impl : public SvxAbstractSplitTableDialog
+{
+    std::shared_ptr<SvxSplitTableDlg> m_xDlg;
+
+public:
+    SvxAbstractSplitTableDialog_Impl(std::shared_ptr<SvxSplitTableDlg> pDlg) : m_xDlg(std::move(pDlg)) {}
+
     virtual bool IsHorizontal() const override;
     virtual bool IsProportional() const override;
     virtual long GetCount() const override;
 
-    virtual short Execute() override;
     virtual void SetSplitVerticalByDefault() override;
+
+    virtual short Execute() override;
+    virtual bool StartExecuteAsync(AsyncContext& rContext) override;
 };
 
 #endif
diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx
index 48a73e528143..d6541073be6e 100644
--- a/svx/source/table/tablecontroller.cxx
+++ b/svx/source/table/tablecontroller.cxx
@@ -1279,10 +1279,9 @@ void SvxTableController::SplitMarkedCells(const SfxRequest& rReq)
         return;
 
     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-    ScopedVclPtr<SvxAbstractSplitTableDialog> xDlg(pFact->CreateSvxSplitTableDialog(rReq.GetFrameWeld(), false, 99));
+    VclPtr<SvxAbstractSplitTableDialog> xDlg(pFact->CreateSvxSplitTableDialog(rReq.GetFrameWeld(), false, 99));
 
-    if( xDlg->Execute() )
-    {
+    xDlg->StartExecuteAsync([xDlg, this](int) {
         const sal_Int32 nCount = xDlg->GetCount() - 1;
 
         if( nCount < 1 )
@@ -1324,7 +1323,9 @@ void SvxTableController::SplitMarkedCells(const SfxRequest& rReq)
         aEnd.mnCol += mxTable->getColumnCount() - nColCount;
 
         setSelectedCells( aStart, aEnd );
-    }
+
+        xDlg->disposeOnce();
+    });
 }
 
 void SvxTableController::DistributeColumns(const bool bOptimize, const bool bMinimize)
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index 073fe280c924..10ad72aff6a0 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -987,23 +987,28 @@ void SwTableShell::Execute(SfxRequest &rReq)
             else
             {
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+                SwWrtShell* pSh = &rSh;
                 const long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
-                ScopedVclPtr<SvxAbstractSplitTableDialog> pDlg(pFact->CreateSvxSplitTableDialog(GetView().GetFrameWeld(), rSh.IsTableVertical(), nMaxVert));
+                VclPtr<SvxAbstractSplitTableDialog> pDlg(pFact->CreateSvxSplitTableDialog(GetView().GetFrameWeld(), rSh.IsTableVertical(), nMaxVert));
                 if(rSh.IsSplitVerticalByDefault())
                     pDlg->SetSplitVerticalByDefault();
-                if( pDlg->Execute() == RET_OK )
-                {
-                    nCount = pDlg->GetCount();
-                    bHorizontal = pDlg->IsHorizontal();
-                    bProportional = pDlg->IsProportional();
-                    rReq.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS, nCount ) );
-                    rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bHorizontal ) );
-                    rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bProportional ) );
-
-                    // tdf#60242: remember choice for next time
-                    bool bVerticalWasChecked = !pDlg->IsHorizontal();
-                    rSh.SetSplitVerticalByDefault(bVerticalWasChecked);
-                }
+                pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
+                    if (nResult == RET_OK)
+                    {
+                        long nCount2 = pDlg->GetCount();
+                        bool bHorizontal2 = pDlg->IsHorizontal();
+                        bool bProportional2 = pDlg->IsProportional();
+
+                        // tdf#60242: remember choice for next time
+                        bool bVerticalWasChecked = !pDlg->IsHorizontal();
+                        pSh->SetSplitVerticalByDefault(bVerticalWasChecked);
+
+                        if ( nCount2 > 1 )
+                            pSh->SplitTab(!bHorizontal2, static_cast< sal_uInt16 >( nCount2-1 ), bProportional2 );
+                    }
+
+                    pDlg->disposeOnce();
+                });
             }
 
             if ( nCount>1 )


More information about the Libreoffice-commits mailing list