diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/swabstdlg.hxx | 9 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 10 | ||||
-rw-r--r-- | sw/source/uibase/inc/DropDownFormFieldDialog.hxx | 9 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 25 |
5 files changed, 41 insertions, 22 deletions
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 ) { |