sw/source/ui/dialog/swdlgfact.cxx |    7 ++++++-
 sw/source/ui/dialog/swdlgfact.hxx |    5 +++--
 sw/source/ui/table/splittbl.cxx   |   11 +----------
 sw/source/uibase/inc/splittbl.hxx |   12 ++++++++++--
 sw/source/uibase/shells/tabsh.cxx |   18 ++++++++++++++----
 vcl/jsdialog/enabled.cxx          |    3 ++-
 6 files changed, 36 insertions(+), 20 deletions(-)

New commits:
commit bcabb3d1891fc67fb4e4b35642c2d55340994ecc
Author:     Skyler Grey <skyler3...@gmail.com>
AuthorDate: Wed Aug 3 09:54:45 2022 +0100
Commit:     Pedro Silva <pedro.si...@collabora.com>
CommitDate: Thu Aug 4 10:24:55 2022 +0200

    Turn the split table dialog into an async JSDialog
    
    - Previously the split table dialog was not an async dialog, and it
      wasn't a JSDialog either
    - A non-async dialog has issues when multiple people try to change
      something using the dialog at the same time. Generally the changes
      from one person will not be applied until all people who opened the
      dialog later than them have submitted
    - This PR makes the dialog async, fixing multi-user issues with it
    - This PR makes the dialog into a JSDialog, rendering it on the client
      with native HTML elements
    
    Signed-off-by: Skyler Grey <skyler3...@gmail.com>
    Change-Id: I9254bc1b635531c8b38d1ade76f99ffdda145b35
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137741
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index 17f0ed1d3a03..ba883398486a 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -120,6 +120,11 @@ short AbstractSplitTableDialog_Impl::Execute()
     return m_xDlg->run();
 }
 
+bool AbstractSplitTableDialog_Impl::StartExecuteAsync(AsyncContext &rCtx)
+{
+    return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
+}
+
 short AbstractSwTableWidthDlg_Impl::Execute()
 {
     return m_xDlg->run();
@@ -972,7 +977,7 @@ VclPtr<VclAbstractDialog> 
SwAbstractDialogFactory_Impl::CreateSwSortingDialog(we
 
 VclPtr<AbstractSplitTableDialog> 
SwAbstractDialogFactory_Impl::CreateSplitTableDialog(weld::Window *pParent, 
SwWrtShell &rSh)
 {
-    return 
VclPtr<AbstractSplitTableDialog_Impl>::Create(std::make_unique<SwSplitTableDlg>(pParent,
 rSh));
+    return 
VclPtr<AbstractSplitTableDialog_Impl>::Create(std::make_shared<SwSplitTableDlg>(pParent,
 rSh));
 }
 
 VclPtr<AbstractSwSelGlossaryDlg> 
SwAbstractDialogFactory_Impl::CreateSwSelGlossaryDlg(weld::Window *pParent, 
const OUString &rShortName)
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 8690d9db8129..b756a4de614e 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -222,13 +222,14 @@ public:
 
 class AbstractSplitTableDialog_Impl : public AbstractSplitTableDialog // add 
for
 {
-    std::unique_ptr<SwSplitTableDlg> m_xDlg;
+    std::shared_ptr<SwSplitTableDlg> m_xDlg;
 public:
-    explicit AbstractSplitTableDialog_Impl(std::unique_ptr<SwSplitTableDlg> p)
+    explicit AbstractSplitTableDialog_Impl(std::shared_ptr<SwSplitTableDlg> p)
         : m_xDlg(std::move(p))
     {
     }
     virtual short Execute() override;
+    virtual bool  StartExecuteAsync(AsyncContext &rCtx) override;
     virtual SplitTable_HeadlineOption GetSplitMode() override;
 };
 
diff --git a/sw/source/ui/table/splittbl.cxx b/sw/source/ui/table/splittbl.cxx
index 0deb5d03093c..0af89a160121 100644
--- a/sw/source/ui/table/splittbl.cxx
+++ b/sw/source/ui/table/splittbl.cxx
@@ -28,21 +28,12 @@ SwSplitTableDlg::SwSplitTableDlg(weld::Window* pParent, 
SwWrtShell& rSh)
     , m_xBoxAttrCopyNoParaRB(m_xBuilder->weld_radio_button("customheading"))
     , m_xBorderCopyRB(m_xBuilder->weld_radio_button("noheading"))
     , rShell(rSh)
-    , m_nSplit(SplitTable_HeadlineOption::ContentCopy)
 {
 }
 
 void SwSplitTableDlg::Apply()
 {
-    m_nSplit = SplitTable_HeadlineOption::ContentCopy;
-    if (m_xBoxAttrCopyWithParaRB->get_active())
-        m_nSplit = SplitTable_HeadlineOption::BoxAttrAllCopy;
-    else if (m_xBoxAttrCopyNoParaRB->get_active())
-        m_nSplit = SplitTable_HeadlineOption::BoxAttrCopy;
-    else if (m_xBorderCopyRB->get_active())
-        m_nSplit = SplitTable_HeadlineOption::BorderCopy;
-
-    rShell.SplitTable(m_nSplit);
+    rShell.SplitTable(GetSplitMode());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/splittbl.hxx 
b/sw/source/uibase/inc/splittbl.hxx
index 99e61f7d4075..b826914e4720 100644
--- a/sw/source/uibase/inc/splittbl.hxx
+++ b/sw/source/uibase/inc/splittbl.hxx
@@ -34,7 +34,6 @@ private:
     std::unique_ptr<weld::RadioButton> m_xBorderCopyRB;
 
     SwWrtShell& rShell;
-    SplitTable_HeadlineOption m_nSplit;
 
     void Apply();
 
@@ -49,7 +48,16 @@ public:
         return nRet;
     }
 
-    SplitTable_HeadlineOption GetSplitMode() const { return m_nSplit; }
+    SplitTable_HeadlineOption GetSplitMode() const {
+        auto nSplit = SplitTable_HeadlineOption::ContentCopy;
+        if (m_xBoxAttrCopyWithParaRB->get_active())
+            nSplit = SplitTable_HeadlineOption::BoxAttrAllCopy;
+        else if (m_xBoxAttrCopyNoParaRB->get_active())
+            nSplit = SplitTable_HeadlineOption::BoxAttrCopy;
+        else if (m_xBorderCopyRB->get_active())
+            nSplit = SplitTable_HeadlineOption::BorderCopy;
+        return nSplit;
+    }
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/tabsh.cxx 
b/sw/source/uibase/shells/tabsh.cxx
index 84a090b111fd..4d83dd1ec756 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -1081,10 +1081,20 @@ void SwTableShell::Execute(SfxRequest &rReq)
             else
             {
                 SwAbstractDialogFactory* pFact = 
SwAbstractDialogFactory::Create();
-                ScopedVclPtr<AbstractSplitTableDialog> 
pDlg(pFact->CreateSplitTableDialog(GetView().GetFrameWeld(), rSh));
-                pDlg->Execute();
-                rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, 
static_cast<sal_uInt16>(pDlg->GetSplitMode()) ) );
-                bCallDone = true;
+                VclPtr<AbstractSplitTableDialog> 
pDlg(pFact->CreateSplitTableDialog(GetView().GetFrameWeld(), rSh));
+
+                SwWrtShell* pSh = &rSh;
+
+                pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
+                    if (nResult == RET_OK)
+                    {
+                        const auto aSplitMode = pDlg->GetSplitMode();
+                        pSh->SplitTable( aSplitMode );
+                    }
+
+                    pDlg->disposeOnce();
+                });
+                rReq.Ignore(); // We're already handling the request in our 
async bit
             }
             break;
         }
diff --git a/vcl/jsdialog/enabled.cxx b/vcl/jsdialog/enabled.cxx
index ce8acb91d48a..f0d8ed530dcf 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -60,7 +60,8 @@ bool isBuilderEnabled(std::u16string_view rUIFile, bool 
bMobile)
         || rUIFile == u"svx/ui/accessibilitycheckentry.ui"
         || rUIFile == u"cui/ui/widgettestdialog.ui"
         || rUIFile == u"modules/swriter/ui/contentcontroldlg.ui"
-        || rUIFile == u"modules/swriter/ui/contentcontrollistitemdlg.ui")
+        || rUIFile == u"modules/swriter/ui/contentcontrollistitemdlg.ui"
+        || rUIFile == u"modules/swriter/ui/splittable.ui")
     {
         return true;
     }

Reply via email to