sw/inc/swabstdlg.hxx                             |    9 +++++++-
 sw/source/ui/dialog/swdlgfact.cxx                |   10 +++++++--
 sw/source/ui/dialog/swdlgfact.hxx                |   10 +++++----
 sw/source/uibase/inc/DropDownFormFieldDialog.hxx |    9 --------
 sw/source/uibase/shells/textsh1.cxx              |   25 ++++++++++++++++-------
 sw/source/uibase/uiview/view0.cxx                |    9 ++++++--
 6 files changed, 48 insertions(+), 24 deletions(-)

New commits:
commit 9884fa5bf4ce5413179d6a054a2d533fa829c13e
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jan 31 10:11:40 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Wed Jan 31 12:06:36 2024 +0100

    make drop-down-form-field dialog async
    
    Change-Id: Ic3c6111878271f31a07fab835501cd92cbca7950
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162791
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx
index c8974620060e..4877095d761c 100644
--- a/sw/inc/swabstdlg.hxx
+++ b/sw/inc/swabstdlg.hxx
@@ -444,6 +444,13 @@ public:
     virtual void Apply() = 0;
 };
 
+class AbstractDropDownFormFieldDialog : public VclAbstractDialog
+{
+protected:
+    virtual ~AbstractDropDownFormFieldDialog() override = default;
+public:
+    virtual void Apply() = 0;
+};
 class SwAbstractDialogFactory
 {
 public:
@@ -482,7 +489,7 @@ public:
 
     virtual VclPtr<AbstractDropDownFieldDialog> 
CreateDropDownFieldDialog(weld::Widget* pParent, SwWrtShell &rSh,
         SwField* pField, bool bPrevButton, bool bNextButton) = 0;
-    virtual VclPtr<VclAbstractDialog> 
CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* 
pDropDownField) = 0;
+    virtual VclPtr<AbstractDropDownFormFieldDialog> 
CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* 
pDropDownField) = 0;
 
     virtual VclPtr<VclAbstractDialog> CreateDateFormFieldDialog(weld::Widget* 
pParent, sw::mark::IDateFieldmark* pDateField, SwDoc& rDoc) = 0;
 
diff --git a/sw/source/ui/dialog/swdlgfact.cxx 
b/sw/source/ui/dialog/swdlgfact.cxx
index a0f7ec33225f..742608f3e871 100644
--- a/sw/source/ui/dialog/swdlgfact.cxx
+++ b/sw/source/ui/dialog/swdlgfact.cxx
@@ -232,7 +232,13 @@ short AbstractDropDownFieldDialog_Impl::Execute()
 
 short AbstractDropDownFormFieldDialog_Impl::Execute()
 {
-    return m_xDlg->run();
+    assert(false);
+    return -1;
+}
+
+bool AbstractDropDownFormFieldDialog_Impl::StartExecuteAsync(AsyncContext 
&rCtx)
+{
+    return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn);
 }
 
 short AbstractDateFormFieldDialog_Impl::Execute()
@@ -1094,7 +1100,7 @@ VclPtr<AbstractDropDownFieldDialog> 
SwAbstractDialogFactory_Impl::CreateDropDown
     return 
VclPtr<AbstractDropDownFieldDialog_Impl>::Create(std::make_unique<sw::DropDownFieldDialog>(pParent,
 rSh, pField, bPrevButton, bNextButton));
 }
 
-VclPtr<VclAbstractDialog> 
SwAbstractDialogFactory_Impl::CreateDropDownFormFieldDialog(weld::Widget 
*pParent, sw::mark::IFieldmark* pDropDownField)
+VclPtr<AbstractDropDownFormFieldDialog> 
SwAbstractDialogFactory_Impl::CreateDropDownFormFieldDialog(weld::Widget 
*pParent, sw::mark::IFieldmark* pDropDownField)
 {
     return 
VclPtr<AbstractDropDownFormFieldDialog_Impl>::Create(std::make_unique<sw::DropDownFormFieldDialog>(pParent,
 pDropDownField));
 }
diff --git a/sw/source/ui/dialog/swdlgfact.hxx 
b/sw/source/ui/dialog/swdlgfact.hxx
index 9e04a8b70db3..1fb65a001436 100644
--- a/sw/source/ui/dialog/swdlgfact.hxx
+++ b/sw/source/ui/dialog/swdlgfact.hxx
@@ -381,15 +381,17 @@ public:
     virtual bool          NextButtonPressed() const override;
 };
 
-class AbstractDropDownFormFieldDialog_Impl : public VclAbstractDialog
+class AbstractDropDownFormFieldDialog_Impl : public 
AbstractDropDownFormFieldDialog
 {
-    std::unique_ptr<sw::DropDownFormFieldDialog> m_xDlg;
+    std::shared_ptr<sw::DropDownFormFieldDialog> m_xDlg;
 public:
-    explicit 
AbstractDropDownFormFieldDialog_Impl(std::unique_ptr<sw::DropDownFormFieldDialog>
 p)
+    explicit 
AbstractDropDownFormFieldDialog_Impl(std::shared_ptr<sw::DropDownFormFieldDialog>
 p)
         : m_xDlg(std::move(p))
     {
     }
     virtual short Execute() override;
+    virtual bool StartExecuteAsync(AsyncContext &rCtx) override;
+    virtual void Apply() override { m_xDlg->Apply(); }
 };
 
 class AbstractDateFormFieldDialog_Impl : public VclAbstractDialog
@@ -781,7 +783,7 @@ public:
 
     virtual VclPtr<AbstractDropDownFieldDialog> 
CreateDropDownFieldDialog(weld::Widget* pParent, SwWrtShell &rSh,
         SwField* pField, bool bPrevButton, bool bNextButton) override;
-    virtual VclPtr<VclAbstractDialog> 
CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* 
pDropDownField) override;
+    virtual VclPtr<AbstractDropDownFormFieldDialog> 
CreateDropDownFormFieldDialog(weld::Widget* pParent, sw::mark::IFieldmark* 
pDropDownField) override;
     virtual VclPtr<VclAbstractDialog> CreateDateFormFieldDialog(weld::Widget* 
pParent, sw::mark::IDateFieldmark* pDateField, SwDoc& rDoc) override;
 
     virtual VclPtr<SfxAbstractTabDialog> CreateSwEnvDlg(weld::Window* pParent, 
const SfxItemSet& rSet, SwWrtShell* pWrtSh, Printer* pPrt, bool bInsert) 
override;
diff --git a/sw/source/uibase/inc/DropDownFormFieldDialog.hxx 
b/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
index c6bcc9837304..ae71ad45cba0 100644
--- a/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
+++ b/sw/source/uibase/inc/DropDownFormFieldDialog.hxx
@@ -43,19 +43,12 @@ private:
     void InitControls();
     void AppendItemToList();
     void UpdateButtons();
-    void Apply();
 
 public:
     DropDownFormFieldDialog(weld::Widget* pParent, mark::IFieldmark* 
pDropDownField);
     virtual ~DropDownFormFieldDialog() override;
 
-    virtual short run() override
-    {
-        short nRet = GenericDialogController::run();
-        if (nRet == RET_OK)
-            Apply();
-        return nRet;
-    }
+    void Apply();
 };
 
 } // namespace sw
diff --git a/sw/source/uibase/shells/textsh1.cxx 
b/sw/source/uibase/shells/textsh1.cxx
index a1680e5be43a..362a01899e39 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -2009,13 +2009,24 @@ void SwTextShell::Execute(SfxRequest &rReq)
              && !(rWrtSh.GetCurrSection() && 
rWrtSh.GetCurrSection()->IsProtect()) )
         {
             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-            ScopedVclPtr<VclAbstractDialog> 
pDlg(pFact->CreateDropDownFormFieldDialog(rWrtSh.GetView().GetFrameWeld(), 
pFieldBM));
-            if (pDlg->Execute() == RET_OK)
-            {
-                pFieldBM->Invalidate();
-                rWrtSh.InvalidateWindows( 
SwRect(rWrtSh.GetView().GetVisArea()) );
-                rWrtSh.UpdateCursor(); // cursor position might be invalid
-            }
+            VclPtr<AbstractDropDownFormFieldDialog> 
pDlg(pFact->CreateDropDownFormFieldDialog(rWrtSh.GetView().GetFrameWeld(), 
pFieldBM));
+            auto xRequest = std::make_shared<SfxRequest>(rReq);
+            rReq.Ignore(); // the 'old' request is not relevant any more
+            auto pWrtSh = &rWrtSh;
+            pDlg->StartExecuteAsync(
+                [pDlg, pFieldBM, pWrtSh, xRequest] (sal_Int32 nResult)->void
+                {
+                    if (nResult == RET_OK)
+                    {
+                        pDlg->Apply();
+                        pFieldBM->Invalidate();
+                        pWrtSh->InvalidateWindows( 
SwRect(pWrtSh->GetView().GetVisArea()) );
+                        pWrtSh->UpdateCursor(); // cursor position might be 
invalid
+                    }
+                    pDlg->disposeOnce();
+                    xRequest->Done();
+                }
+            );
         }
         else if ( pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDATE )
         {
commit 8291b91f84930a8034093c94bf68b94babf9c391
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jan 31 10:07:06 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Wed Jan 31 12:06:28 2024 +0100

    make footnote-option dialog async
    
    Change-Id: I1f04b98ac8a804aa74b4b6be335c088649ef8547
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162790
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/sw/source/uibase/uiview/view0.cxx 
b/sw/source/uibase/uiview/view0.cxx
index 2a27bd95b5a9..70c9882e0d2e 100644
--- a/sw/source/uibase/uiview/view0.cxx
+++ b/sw/source/uibase/uiview/view0.cxx
@@ -744,8 +744,13 @@ void SwView::ExecViewOptions(SfxRequest &rReq)
 void SwView::ExecFormatFootnote()
 {
     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
-    ScopedVclPtr<VclAbstractDialog> 
pDlg(pFact->CreateSwFootNoteOptionDlg(GetFrameWeld(), GetWrtShell()));
-    pDlg->Execute();
+    VclPtr<VclAbstractDialog> 
pDlg(pFact->CreateSwFootNoteOptionDlg(GetFrameWeld(), GetWrtShell()));
+    pDlg->StartExecuteAsync(
+        [pDlg] (sal_Int32 /*nResult*/)->void
+        {
+            pDlg->disposeOnce();
+        }
+    );
 }
 
 void SwView::ExecNumberingOutline(SfxItemPool & rPool)

Reply via email to