sw/inc/swabstdlg.hxx | 11 ++++++++++- sw/source/ui/dbui/mmdocselectpage.cxx | 28 ++++++++++++++++++---------- sw/source/ui/dialog/swdlgfact.cxx | 21 ++++++++++++++++++--- sw/source/ui/dialog/swdlgfact.hxx | 17 ++++++++++++++++- sw/source/ui/fldui/changedb.cxx | 8 -------- sw/source/ui/fldui/fldedt.cxx | 6 ------ sw/source/uibase/inc/changedb.hxx | 4 ++-- sw/source/uibase/inc/fldedt.hxx | 2 -- sw/source/uibase/shells/basesh.cxx | 11 +++++++++-- sw/source/uibase/shells/textfld.cxx | 11 +++++++++-- 10 files changed, 82 insertions(+), 37 deletions(-)
New commits: commit d1ac38a3d269ce862c17da00885c8b0b0bee5e6c Author: Noel Grandin <[email protected]> AuthorDate: Wed Jan 31 10:35:55 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Jan 31 17:22:08 2024 +0100 make change-db dialog async Change-Id: I3310592cb2e7922f86ead8a6e19792e5852a4ca1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162806 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 4877095d761c..2af7aea2ef29 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -451,6 +451,15 @@ protected: public: virtual void Apply() = 0; }; + +class AbstractChangeDbDialog : public VclAbstractDialog +{ +protected: + virtual ~AbstractChangeDbDialog() override = default; +public: + virtual void UpdateFields() = 0; +}; + class SwAbstractDialogFactory { public: @@ -475,7 +484,7 @@ public: virtual std::shared_ptr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) = 0; virtual std::shared_ptr<AbstractSwTranslateLangSelectDlg> CreateSwTranslateLangSelectDlg(weld::Window *pParent, SwWrtShell &rSh) = 0; - virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) = 0; + virtual VclPtr<AbstractChangeDbDialog> CreateSwChangeDBDlg(SwView& rVw) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSwCharDlg(weld::Window* pParent, SwView& pVw, const SfxItemSet& rCoreSet, SwCharDlgMode nDialogMode, const OUString* pFormatStr = nullptr) = 0; virtual VclPtr<AbstractSwConvertTableDlg> CreateSwConvertTableDlg(SwView& rView, bool bToTable) = 0; diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx b/sw/source/ui/dbui/mmdocselectpage.cxx index 180a6d044168..fa613ee9bb48 100644 --- a/sw/source/ui/dbui/mmdocselectpage.cxx +++ b/sw/source/ui/dbui/mmdocselectpage.cxx @@ -167,18 +167,26 @@ IMPL_LINK_NOARG(SwMailMergeDocSelectPage, ExchangeDatabaseHdl, weld::Button&, vo { SwAbstractDialogFactory& rFact = ::swui::GetFactory(); - ScopedVclPtr<VclAbstractDialog> pDlg(rFact.CreateSwChangeDBDlg(*m_pWizard->GetSwView())); - pDlg->Execute(); + VclPtr<AbstractChangeDbDialog> pDlg(rFact.CreateSwChangeDBDlg(*m_pWizard->GetSwView())); + pDlg->StartExecuteAsync( + [this, pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + pDlg->UpdateFields(); + pDlg->disposeOnce(); - OUString sDataSourceName = m_pWizard->GetSwView()->GetDataSourceName(); + OUString sDataSourceName = m_pWizard->GetSwView()->GetDataSourceName(); + + if(m_xCurrentDocRB->get_active() && + !sDataSourceName.isEmpty() && + SwView::IsDataSourceAvailable(sDataSourceName)) + { + m_xDataSourceWarningFT->hide(); + m_pWizard->enableButtons(WizardButtonFlags::NEXT, true); + } + } + ); - if(m_xCurrentDocRB->get_active() && - !sDataSourceName.isEmpty() && - SwView::IsDataSourceAvailable(sDataSourceName)) - { - m_xDataSourceWarningFT->hide(); - m_pWizard->enableButtons(WizardButtonFlags::NEXT, true); - } } bool SwMailMergeDocSelectPage::commitPage( ::vcl::WizardTypes::CommitPageReason _eReason ) diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 219beb1c4bb8..6ae455d3600c 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -977,6 +977,17 @@ std::optional<SwLanguageListItem> AbstractSwTranslateLangSelectDlg_Impl::GetSele #endif } +short AbstractChangeDbDialog_Impl::Execute() +{ + assert(false); + return -1; +} + +bool AbstractChangeDbDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + VclPtr<AbstractSwInsertAbstractDlg> SwAbstractDialogFactory_Impl::CreateSwInsertAbstractDlg(weld::Window* pParent) { return VclPtr<AbstractSwInsertAbstractDlg_Impl>::Create(std::make_unique<SwInsertAbstractDlg>(pParent)); @@ -1047,10 +1058,10 @@ std::shared_ptr<AbstractSwTranslateLangSelectDlg> SwAbstractDialogFactory_Impl:: #endif } -VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwChangeDBDlg(SwView& rVw) +VclPtr<AbstractChangeDbDialog> SwAbstractDialogFactory_Impl::CreateSwChangeDBDlg(SwView& rVw) { #if HAVE_FEATURE_DBCONNECTIVITY && !ENABLE_FUZZERS - return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwChangeDBDlg>(rVw)); + return VclPtr<AbstractChangeDbDialog_Impl>::Create(std::make_shared<SwChangeDBDlg>(rVw)); #else (void) rVw; return nullptr; diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 1fb65a001436..bb795127cf5e 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -57,6 +57,7 @@ #include <optional> #include <o3tl/deleter.hxx> #include <pagenumberdlg.hxx> +#include <changedb.hxx> class SwInsertAbstractDlg; @@ -744,6 +745,20 @@ public: virtual sal_uInt16 GetRestartPage() const override; }; +class AbstractChangeDbDialog_Impl : public AbstractChangeDbDialog +{ + std::shared_ptr<SwChangeDBDlg> m_xDlg; +public: + explicit AbstractChangeDbDialog_Impl(std::shared_ptr<SwChangeDBDlg> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void UpdateFields() override { m_xDlg->UpdateFields(); } +}; + + //AbstractDialogFactory_Impl implementations class SwAbstractDialogFactory_Impl : public SwAbstractDialogFactory { @@ -770,7 +785,7 @@ public: virtual std::shared_ptr<AbstractSwBreakDlg> CreateSwBreakDlg(weld::Window *pParent, SwWrtShell &rSh) override; virtual std::shared_ptr<AbstractSwTranslateLangSelectDlg> CreateSwTranslateLangSelectDlg(weld::Window *pParent, SwWrtShell &rSh) override; - virtual VclPtr<VclAbstractDialog> CreateSwChangeDBDlg(SwView& rVw) override; + virtual VclPtr<AbstractChangeDbDialog> CreateSwChangeDBDlg(SwView& rVw) override; virtual VclPtr<SfxAbstractTabDialog> CreateSwCharDlg(weld::Window* pParent, SwView& pVw, const SfxItemSet& rCoreSet, SwCharDlgMode nDialogMode, const OUString* pFormatStr = nullptr) override; virtual VclPtr<AbstractSwConvertTableDlg> CreateSwConvertTableDlg(SwView& rView, bool bToTable) override; diff --git a/sw/source/ui/fldui/changedb.cxx b/sw/source/ui/fldui/changedb.cxx index a1e1803d9037..1d4d763dfbae 100644 --- a/sw/source/ui/fldui/changedb.cxx +++ b/sw/source/ui/fldui/changedb.cxx @@ -158,14 +158,6 @@ SwChangeDBDlg::~SwChangeDBDlg() { } -short SwChangeDBDlg::run() -{ - short nRet = SfxDialogController::run(); - if (nRet == RET_OK) - UpdateFields(); - return nRet; -} - void SwChangeDBDlg::UpdateFields() { std::vector<OUString> aDBNames; diff --git a/sw/source/uibase/inc/changedb.hxx b/sw/source/uibase/inc/changedb.hxx index f14f163dd73a..d9c42c1984d9 100644 --- a/sw/source/uibase/inc/changedb.hxx +++ b/sw/source/uibase/inc/changedb.hxx @@ -44,15 +44,15 @@ class SwChangeDBDlg final : public SfxDialogController DECL_LINK(ButtonHdl, weld::Button&, void); DECL_LINK(AddDBHdl, weld::Button&, void); - void UpdateFields(); void FillDBPopup(); std::unique_ptr<weld::TreeIter> Insert(std::u16string_view rDBName); void ShowDBName(const SwDBData& rDBData); public: SwChangeDBDlg(SwView const & rVw); - virtual short run() override; virtual ~SwChangeDBDlg() override; + + void UpdateFields(); }; #endif diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 5c5af8c3581a..fa2f03ab63a3 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -3337,8 +3337,15 @@ void SwBaseShell::ExecField( SfxRequest const & rReq ) case FN_CHANGE_DBFIELD: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwChangeDBDlg(GetView())); - pDlg->Execute(); + VclPtr<AbstractChangeDbDialog> pDlg(pFact->CreateSwChangeDBDlg(GetView())); + pDlg->StartExecuteAsync( + [pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + pDlg->UpdateFields(); + pDlg->disposeOnce(); + } + ); } break; #endif commit 09c29b56fe8af1f3428a96017fec4d921e023906 Author: Noel Grandin <[email protected]> AuthorDate: Wed Jan 31 10:22:38 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Jan 31 17:21:59 2024 +0100 make field-edit dialog async Change-Id: Ib24166fe0370a27357adf1611deafda2686a14aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162805 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 742608f3e871..219beb1c4bb8 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -1202,7 +1202,11 @@ VclPtr<AbstractSwFieldDlg> SwAbstractDialogFactory_Impl::CreateSwFieldDlg(SfxBin VclPtr<SfxAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwFieldEditDlg(SwView& rVw) { - return VclPtr<SwAbstractSfxController_Impl>::Create(std::make_unique<SwFieldEditDlg>(rVw)); + auto xDlg = std::make_shared<SwFieldEditDlg>(rVw); + // without TabPage no dialog + if (!xDlg->GetTabPage()) + return nullptr; + return VclPtr<SwAbstractSfxController_Impl>::Create(std::move(xDlg)); } VclPtr<AbstractSwRenameXNamedDlg> SwAbstractDialogFactory_Impl::CreateSwRenameXNamedDlg(weld::Widget* pParent, diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx index c947c064e5d4..cfa614b712ab 100644 --- a/sw/source/ui/fldui/fldedt.cxx +++ b/sw/source/ui/fldui/fldedt.cxx @@ -252,12 +252,6 @@ IMPL_LINK_NOARG(SwFieldEditDlg, OKHdl, weld::Button&, void) } } -short SwFieldEditDlg::run() -{ - // without TabPage no dialog - return GetTabPage() ? SfxSingleTabDialogController::run() : static_cast<short>(RET_CANCEL); -} - // Traveling between fields of the same type IMPL_LINK(SwFieldEditDlg, NextPrevHdl, weld::Button&, rButton, void) { diff --git a/sw/source/uibase/inc/fldedt.hxx b/sw/source/uibase/inc/fldedt.hxx index 7692e1256137..635065580985 100644 --- a/sw/source/uibase/inc/fldedt.hxx +++ b/sw/source/uibase/inc/fldedt.hxx @@ -48,8 +48,6 @@ public: DECL_LINK(OKHdl, weld::Button&, void); - virtual short run() override; - void EnableInsert(bool bEnable); void InsertHdl(); }; diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx index ac28d14bd079..efb60c197a3c 100644 --- a/sw/source/uibase/shells/textfld.cxx +++ b/sw/source/uibase/shells/textfld.cxx @@ -164,8 +164,15 @@ void SwTextShell::ExecField(SfxRequest &rReq) default: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateSwFieldEditDlg( GetView() )); - pDlg->Execute(); + VclPtr<SfxAbstractDialog> pDlg(pFact->CreateSwFieldEditDlg( GetView() )); + // without TabPage no dialog + if (pDlg) + pDlg->StartExecuteAsync( + [pDlg] (sal_Int32 /*nResult*/)->void + { + pDlg->disposeOnce(); + } + ); } } }
