filter/source/pdf/impdialog.cxx                |   48 ++++++++++++++-----------
 filter/source/pdf/impdialog.hxx                |    5 ++
 include/svx/AccessibilityCheckDialog.hxx       |    1 
 svx/source/dialog/AccessibilityCheckDialog.cxx |   10 +----
 sw/source/uibase/shells/basesh.cxx             |    4 +-
 5 files changed, 37 insertions(+), 31 deletions(-)

New commits:
commit 61fed0c4fe53738254d116543417f1c7028a0f39
Author:     NickWingate <nick.wing...@collabora.com>
AuthorDate: Wed Feb 23 14:11:49 2022 +0000
Commit:     Mert Tumer <mert.tu...@collabora.com>
CommitDate: Thu Feb 24 08:43:31 2022 +0100

    Make accessibility check dialog async
    
    Signed-off-by: NickWingate <nick.wing...@collabora.com>
    Change-Id: I88913b3d7e580a1d8c69a39454f2598e11ba43ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130438
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-by: Mert Tumer <mert.tu...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 31f712c47edf..8eda392710bd 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -271,6 +271,7 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, 
Sequence< PropertyValue
         GetOKButton().set_label(sOkButtonText);
 
     GetCancelButton().connect_clicked(LINK(this, ImpPDFTabDialog, CancelHdl));
+    GetOKButton().connect_clicked(LINK(this, ImpPDFTabDialog, OkHdl));
 
     // remove the reset button, not needed in this tabbed dialog
     RemoveResetButton();
@@ -313,10 +314,37 @@ IMPL_LINK_NOARG(ImpPDFTabDialog, CancelHdl, 
weld::Button&, void)
     m_xDialog->response(RET_CANCEL);
 }
 
+IMPL_LINK_NOARG(ImpPDFTabDialog, OkHdl, weld::Button&, void)
+{
+    if (getGeneralPage()->IsPdfUaSelected())
+    {
+        SfxObjectShell* pShell = SfxObjectShell::GetShellFromComponent(mrDoc);
+        if (pShell)
+        {
+            sfx::AccessibilityIssueCollection aCollection = 
pShell->runAccessibilityCheck();
+            if (!aCollection.getIssues().empty())
+            {
+                mpAccessibilityCheckDialog = 
std::make_shared<svx::AccessibilityCheckDialog>(mpParent, aCollection);
+                weld::DialogController::runAsync(mpAccessibilityCheckDialog, 
[this](sal_Int32 retValue){
+                    m_xDialog->response(retValue);
+                });
+            }
+        }
+    }
+    else
+    {
+        m_xDialog->response(RET_OK);
+    }
+}
+
 ImpPDFTabDialog::~ImpPDFTabDialog()
 {
     maConfigItem.WriteModifiedConfig();
     maConfigI18N.WriteModifiedConfig();
+    if (mpAccessibilityCheckDialog)
+    {
+        mpAccessibilityCheckDialog->response(RET_CANCEL);
+    }
 }
 
 void ImpPDFTabDialog::PageCreated(const OString& rId, SfxTabPage& rPage)
@@ -345,26 +373,6 @@ void ImpPDFTabDialog::PageCreated(const OString& rId, 
SfxTabPage& rPage)
     }
 }
 
-short ImpPDFTabDialog::Ok( )
-{
-    // here the whole mechanism of the base class is not used
-    // when Ok is hit, the user means 'convert to PDF', so simply close with ok
-
-    if (getGeneralPage()->IsPdfUaSelected())
-    {
-        SfxObjectShell* pShell = SfxObjectShell::GetShellFromComponent(mrDoc);
-        if (pShell)
-        {
-            sfx::AccessibilityIssueCollection aCollection = 
pShell->runAccessibilityCheck();
-            if (!aCollection.getIssues().empty())
-            {
-                svx::AccessibilityCheckDialog aDialog(mpParent, aCollection);
-                return aDialog.run();
-            }
-        }
-    }
-    return RET_OK;
-}
 
 Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
 {
diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx
index 17fb57890655..c9d116ed2803 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_FILTER_SOURCE_PDF_IMPDIALOG_HXX
 
 #include <sfx2/tabdlg.hxx>
+#include <svx/AccessibilityCheckDialog.hxx>
 
 #include <vcl/pdfwriter.hxx>
 #include <vcl/FilterConfigItem.hxx>
@@ -67,6 +68,7 @@ class ImpPDFTabDialog final : public SfxTabDialogController
     Any                         maSelection;
 
     DECL_LINK(CancelHdl, weld::Button&, void);
+    DECL_LINK(OkHdl, weld::Button&, void);
 
     // the following data are the configuration used throughout the dialog and 
pages
     bool                        mbIsPresentation;
@@ -124,6 +126,8 @@ class ImpPDFTabDialog final : public SfxTabDialogController
     bool                        mbCanExtractForAccessibility;
     css::uno::Reference< css::beans::XMaterialHolder > mxPreparedPasswords;
 
+    std::shared_ptr< svx::AccessibilityCheckDialog > 
mpAccessibilityCheckDialog;
+
     bool                        mbIsRangeChecked;
     OUString                    msPageRange;
     bool                        mbSelectionIsChecked;
@@ -164,7 +168,6 @@ public:
 
 private:
     virtual void                PageCreated(const OString& rId, SfxTabPage& 
rPage) override;
-    virtual short               Ok() override;
 };
 
 
diff --git a/include/svx/AccessibilityCheckDialog.hxx 
b/include/svx/AccessibilityCheckDialog.hxx
index 5227cbee2699..e3e1e201f227 100644
--- a/include/svx/AccessibilityCheckDialog.hxx
+++ b/include/svx/AccessibilityCheckDialog.hxx
@@ -50,7 +50,6 @@ public:
     AccessibilityCheckDialog(weld::Window* pParent,
                              sfx::AccessibilityIssueCollection const& 
rIssueCollection);
     virtual ~AccessibilityCheckDialog() override;
-    virtual short run() override;
 };
 
 } // end svx namespace
diff --git a/svx/source/dialog/AccessibilityCheckDialog.cxx 
b/svx/source/dialog/AccessibilityCheckDialog.cxx
index 4032e62f89f0..8f35e337176a 100644
--- a/svx/source/dialog/AccessibilityCheckDialog.cxx
+++ b/svx/source/dialog/AccessibilityCheckDialog.cxx
@@ -40,12 +40,6 @@ AccessibilityCheckDialog::AccessibilityCheckDialog(
                               "AccessibilityCheckDialog")
     , m_aIssueCollection(rIssueCollection)
     , m_xAccessibilityCheckBox(m_xBuilder->weld_box("accessibilityCheckBox"))
-{
-}
-
-AccessibilityCheckDialog::~AccessibilityCheckDialog() {}
-
-short AccessibilityCheckDialog::run()
 {
     sal_Int32 i = 0;
 
@@ -56,9 +50,11 @@ short AccessibilityCheckDialog::run()
         m_xAccessibilityCheckBox->reorder_child(xEntry->get_widget(), i++);
         m_aAccessibilityCheckEntries.push_back(std::move(xEntry));
     }
-    return GenericDialogController::run();
 }
 
+AccessibilityCheckDialog::~AccessibilityCheckDialog() {}
+
+
 } // end svx namespace
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/shells/basesh.cxx 
b/sw/source/uibase/shells/basesh.cxx
index ff9220badc23..99dbc6f05d6b 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -2701,8 +2701,8 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq)
         {
             sw::AccessibilityCheck aCheck(rSh.GetDoc());
             aCheck.check();
-            svx::AccessibilityCheckDialog aDialog(pMDI, 
aCheck.getIssueCollection());
-            aDialog.run();
+            std::shared_ptr<svx::AccessibilityCheckDialog> aDialog = 
std::make_shared<svx::AccessibilityCheckDialog>(pMDI, 
aCheck.getIssueCollection());
+            weld::DialogController::runAsync(aDialog, [](int){});
         }
         break;
         case SID_GRAPHIC_SIZE_CHECK:

Reply via email to