cui/source/dialogs/SignatureLineDialogBase.cxx |    6 ++----
 cui/source/factory/dlgfact.cxx                 |    2 +-
 cui/source/factory/dlgfact.hxx                 |    4 +++-
 cui/source/inc/SignSignatureLineDialog.hxx     |    3 ++-
 cui/source/inc/SignatureLineDialog.hxx         |    4 ++--
 cui/source/inc/SignatureLineDialogBase.hxx     |    1 -
 include/vcl/abstdlg.hxx                        |    4 ++++
 sc/source/ui/view/tabvwshb.cxx                 |   18 +++++++++++++++---
 sw/inc/view.hxx                                |    2 +-
 sw/source/uibase/uiview/viewdlg2.cxx           |   20 ++++++++++++++++----
 10 files changed, 46 insertions(+), 18 deletions(-)

New commits:
commit ea88508c9f23e1594a77c287d5a6c86e6b92d870
Author:     Noel Grandin <[email protected]>
AuthorDate: Mon Jan 22 14:58:54 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Tue Jan 23 14:53:46 2024 +0100

    make signature line dialog async
    
    Change-Id: I64cb2ae5b3748e8034fb0624b56c3d3dfdc31654
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162420
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/cui/source/dialogs/SignatureLineDialogBase.cxx 
b/cui/source/dialogs/SignatureLineDialogBase.cxx
index e0ae28fe5040..fb154c34319d 100644
--- a/cui/source/dialogs/SignatureLineDialogBase.cxx
+++ b/cui/source/dialogs/SignatureLineDialogBase.cxx
@@ -26,10 +26,8 @@ 
SignatureLineDialogBase::SignatureLineDialogBase(weld::Widget* pParent, Referenc
 
 short SignatureLineDialogBase::run()
 {
-    short nRet = GenericDialogController::run();
-    if (nRet == RET_OK)
-        Apply();
-    return nRet;
+    assert(false && "these dialogs are async now");
+    return -1;
 }
 
 OUString SignatureLineDialogBase::getCDataString(std::u16string_view rString)
diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx
index 3e680e54ba91..a856d84c6901 100644
--- a/cui/source/factory/dlgfact.cxx
+++ b/cui/source/factory/dlgfact.cxx
@@ -113,7 +113,7 @@ IMPL_ABSTDLG_CLASS(AbstractHangulHanjaConversionDialog)
 IMPL_ABSTDLG_CLASS(AbstractInsertObjectDialog)
 IMPL_ABSTDLG_CLASS_ASYNC(AbstractLinksDialog, SvBaseLinksDlg)
 IMPL_ABSTDLG_CLASS(AbstractScreenshotAnnotationDlg)
-IMPL_ABSTDLG_CLASS(AbstractSignatureLineDialog)
+IMPL_ABSTDLG_CLASS_ASYNC(AbstractSignatureLineDialog, SignatureLineDialog)
 IMPL_ABSTDLG_CLASS_ASYNC(AbstractSignSignatureLineDialog, 
SignSignatureLineDialog)
 IMPL_ABSTDLG_CLASS_ASYNC(AbstractSvxCharacterMapDialog, SvxCharacterMap)
 IMPL_ABSTDLG_CLASS(AbstractSvxHpLinkDlg)
diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx
index eccd43980bf0..0125c975ae79 100644
--- a/cui/source/factory/dlgfact.hxx
+++ b/cui/source/factory/dlgfact.hxx
@@ -403,7 +403,8 @@ 
DECL_ABSTDLG_CLASS(AbstractScreenshotAnnotationDlg,ScreenshotAnnotationDlg)
 };
 
 // AbstractSignatureLineDialog_Impl
-DECL_ABSTDLG_CLASS(AbstractSignatureLineDialog,SignatureLineDialog)
+DECL_ABSTDLG_CLASS_ASYNC(AbstractSignatureLineDialog,SignatureLineDialog)
+    virtual void Apply() override { m_xDlg->Apply(); }
 };
 
 // AbstractQrCodeGenDialog_Impl
@@ -412,6 +413,7 @@ 
DECL_ABSTDLG_CLASS_ASYNC(AbstractQrCodeGenDialog,QrCodeGenDialog)
 
 // AbstractSignSignatureLineDialog_Impl
 
DECL_ABSTDLG_CLASS_ASYNC(AbstractSignSignatureLineDialog,SignSignatureLineDialog)
+    virtual void Apply() override { m_xDlg->Apply(); }
 };
 
 // AbstractAdditionsDialog_Impl
diff --git a/cui/source/inc/SignSignatureLineDialog.hxx 
b/cui/source/inc/SignSignatureLineDialog.hxx
index 5abe1969e32c..7c894a16a0b3 100644
--- a/cui/source/inc/SignSignatureLineDialog.hxx
+++ b/cui/source/inc/SignSignatureLineDialog.hxx
@@ -20,6 +20,8 @@ class SignSignatureLineDialog : public SignatureLineDialogBase
 public:
     SignSignatureLineDialog(weld::Widget* pParent, 
css::uno::Reference<css::frame::XModel> xModel);
 
+    void Apply();
+
 private:
     std::unique_ptr<weld::Entry> m_xEditName;
     std::unique_ptr<weld::TextView> m_xEditComment;
@@ -42,7 +44,6 @@ private:
 
     void ValidateFields();
     css::uno::Reference<css::graphic::XGraphic> getSignedGraphic(bool bValid);
-    virtual void Apply() override;
 
     DECL_LINK(clearImage, weld::Button&, void);
     DECL_LINK(loadImage, weld::Button&, void);
diff --git a/cui/source/inc/SignatureLineDialog.hxx 
b/cui/source/inc/SignatureLineDialog.hxx
index 73b093f601a5..e686cb4a4123 100644
--- a/cui/source/inc/SignatureLineDialog.hxx
+++ b/cui/source/inc/SignatureLineDialog.hxx
@@ -19,6 +19,8 @@ public:
     SignatureLineDialog(weld::Widget* pParent, 
css::uno::Reference<css::frame::XModel> xModel,
                         bool bEditExisting);
 
+    void Apply();
+
 private:
     std::unique_ptr<weld::Entry> m_xEditName;
     std::unique_ptr<weld::Entry> m_xEditTitle;
@@ -29,8 +31,6 @@ private:
 
     css::uno::Reference<css::beans::XPropertySet> m_xExistingShapeProperties;
     OUString m_aSignatureLineId;
-
-    virtual void Apply() override;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/cui/source/inc/SignatureLineDialogBase.hxx 
b/cui/source/inc/SignatureLineDialogBase.hxx
index dd114d81ab7d..4e0a3f298e5b 100644
--- a/cui/source/inc/SignatureLineDialogBase.hxx
+++ b/cui/source/inc/SignatureLineDialogBase.hxx
@@ -27,7 +27,6 @@ public:
 
 protected:
     css::uno::Reference<css::frame::XModel> m_xModel;
-    virtual void Apply() = 0;
     static OUString getCDataString(std::u16string_view rString);
 };
 
diff --git a/include/vcl/abstdlg.hxx b/include/vcl/abstdlg.hxx
index 9fbe53529cff..5eaf46061e69 100644
--- a/include/vcl/abstdlg.hxx
+++ b/include/vcl/abstdlg.hxx
@@ -119,12 +119,16 @@ class VCL_DLLPUBLIC AbstractSignatureLineDialog : public 
VclAbstractDialog
 {
 protected:
     virtual ~AbstractSignatureLineDialog() override = default;
+public:
+    virtual void Apply() = 0;
 };
 
 class VCL_DLLPUBLIC AbstractSignSignatureLineDialog : public VclAbstractDialog
 {
 protected:
     virtual ~AbstractSignSignatureLineDialog() override = default;
+public:
+    virtual void Apply() = 0;
 };
 
 class VCL_DLLPUBLIC AbstractQrCodeGenDialog : public VclAbstractDialog
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index 1db954039a36..098ea68d33d5 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -402,9 +402,19 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
                 const uno::Reference<frame::XModel> xModel( 
GetViewData().GetDocShell()->GetBaseModel() );
 
                 VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
-                ScopedVclPtr<AbstractSignatureLineDialog> 
pDialog(pFact->CreateSignatureLineDialog(
+                VclPtr<AbstractSignatureLineDialog> 
pDialog(pFact->CreateSignatureLineDialog(
                     pWin->GetFrameWeld(), xModel, rReq.GetSlot() == 
SID_EDIT_SIGNATURELINE));
-                pDialog->Execute();
+                auto xRequest = std::make_shared<SfxRequest>(rReq);
+                rReq.Ignore(); // the 'old' request is not relevant any more
+                pDialog->StartExecuteAsync(
+                    [pDialog, xRequest] (sal_Int32 nResult)->void
+                    {
+                        if (nResult == RET_OK)
+                            pDialog->Apply();
+                        pDialog->disposeOnce();
+                        xRequest->Done();
+                    }
+                );
                 break;
             }
 
@@ -417,8 +427,10 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
                 VclPtr<AbstractSignSignatureLineDialog> pDialog(
                     pFact->CreateSignSignatureLineDialog(GetFrameWeld(), 
xModel));
                 pDialog->StartExecuteAsync(
-                    [pDialog] (sal_Int32 /*nResult*/)->void
+                    [pDialog] (sal_Int32 nResult)->void
                     {
+                        if (nResult == RET_OK)
+                            pDialog->Apply();
                         pDialog->disposeOnce();
                     }
                 );
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 3aa6524ac74b..d735e5e6e94a 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -518,7 +518,7 @@ public:
     void            Execute(SfxRequest&);
     void            ExecLingu(SfxRequest&);
     void            ExecDlg(SfxRequest const &);
-    void            ExecDlgExt(SfxRequest const &);
+    void            ExecDlgExt(SfxRequest&);
     void            ExecColl(SfxRequest const &);
     void            ExecutePrint(SfxRequest&);
     void            ExecDraw(const SfxRequest&);
diff --git a/sw/source/uibase/uiview/viewdlg2.cxx 
b/sw/source/uibase/uiview/viewdlg2.cxx
index 38cdb7ecac54..696ce623a0a6 100644
--- a/sw/source/uibase/uiview/viewdlg2.cxx
+++ b/sw/source/uibase/uiview/viewdlg2.cxx
@@ -46,7 +46,7 @@
 
 using namespace css;
 
-void SwView::ExecDlgExt(SfxRequest const& rReq)
+void SwView::ExecDlgExt(SfxRequest& rReq)
 {
     switch (rReq.GetSlot())
     {
@@ -65,9 +65,19 @@ void SwView::ExecDlgExt(SfxRequest const& rReq)
         {
             VclAbstractDialogFactory* pFact = 
VclAbstractDialogFactory::Create();
             const uno::Reference<frame::XModel> xModel(GetCurrentDocument());
-            ScopedVclPtr<AbstractSignatureLineDialog> 
pDialog(pFact->CreateSignatureLineDialog(
+            VclPtr<AbstractSignatureLineDialog> 
pDialog(pFact->CreateSignatureLineDialog(
                 GetFrameWeld(), xModel, rReq.GetSlot() == 
SID_EDIT_SIGNATURELINE));
-            pDialog->Execute();
+            auto xRequest = std::make_shared<SfxRequest>(rReq);
+            rReq.Ignore(); // the 'old' request is not relevant any more
+            pDialog->StartExecuteAsync(
+                [pDialog, xRequest] (sal_Int32 nResult)->void
+                {
+                    if (nResult == RET_OK)
+                        pDialog->Apply();
+                    pDialog->disposeOnce();
+                    xRequest->Done();
+                }
+            );
             break;
         }
         case SID_INSERT_QRCODE:
@@ -108,8 +118,10 @@ void SwView::ExecDlgExt(SfxRequest const& rReq)
             VclPtr<AbstractSignSignatureLineDialog> pDialog(
                 pFact->CreateSignSignatureLineDialog(GetFrameWeld(), xModel));
             pDialog->StartExecuteAsync(
-                [pDialog] (sal_Int32 /*nResult*/)->void
+                [pDialog] (sal_Int32 nResult)->void
                 {
+                    if (nResult == RET_OK)
+                        pDialog->Apply();
                     pDialog->disposeOnce();
                 }
             );

Reply via email to