diff options
-rw-r--r-- | sw/inc/swabstdlg.hxx | 11 | ||||
-rw-r--r-- | sw/source/ui/dbui/mmdocselectpage.cxx | 28 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 15 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 17 | ||||
-rw-r--r-- | sw/source/ui/fldui/changedb.cxx | 8 | ||||
-rw-r--r-- | sw/source/uibase/inc/changedb.hxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/shells/basesh.cxx | 11 |
7 files changed, 68 insertions, 26 deletions
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 |