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

New commits:
commit b5d3a3ac031d055e433eb2b79b48f6d00fb0e0d6
Author:     Skyler Grey <[email protected]>
AuthorDate: Wed Aug 3 09:54:45 2022 +0100
Commit:     Szymon Kłos <[email protected]>
CommitDate: Sun Nov 20 10:40:49 2022 +0100

    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 <[email protected]>
    Change-Id: I9254bc1b635531c8b38d1ade76f99ffdda145b35
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137741
    Reviewed-by: Szymon Kłos <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142972
    Tested-by: Jenkins

diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index 6e9ebc873ab7..68135716fcb9 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();
@@ -978,7 +983,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 f97ff430c294..c0326249a15b 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -236,13 +236,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/uibase/inc/splittbl.hxx 
b/sw/source/uibase/inc/splittbl.hxx
index 8c8891c1df1b..0311f08d4043 100644
--- a/sw/source/uibase/inc/splittbl.hxx
+++ b/sw/source/uibase/inc/splittbl.hxx
@@ -49,7 +49,17 @@ 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 01bd9389c152..ab93b027e69f 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -1082,10 +1082,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 efb87ac0b9fe..3d830d07cf56 100644
--- a/vcl/jsdialog/enabled.cxx
+++ b/vcl/jsdialog/enabled.cxx
@@ -63,7 +63,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