sw/inc/swabstdlg.hxx | 1 + sw/source/ui/dialog/swdlgfact.cxx | 5 +++++ sw/source/ui/dialog/swdlgfact.hxx | 4 +++- sw/source/uibase/inc/DropDownFieldDialog.hxx | 2 +- sw/source/uibase/inc/wrtsh.hxx | 2 ++ sw/source/uibase/wrtsh/wrtsh2.cxx | 22 +++++++++++++++++++++- 6 files changed, 33 insertions(+), 3 deletions(-)
New commits: commit d2e881f8efe6cc7a0d788a79ec222ab4de3d9f07 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Dec 15 16:59:53 2025 +0000 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Dec 17 13:47:24 2025 +0100 make simple activate case of DropDownFieldDialog async Change-Id: If3a36540976014774b4cbf84f52e2d3de28b96b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195678 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 229b2fdc042d..6129e48157b3 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -300,6 +300,7 @@ protected: public: virtual bool PrevButtonPressed() const = 0; virtual bool NextButtonPressed() const = 0; + virtual void Apply() = 0; }; class AbstractSwLabDlg : public SfxAbstractTabDialog diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 5107f9a8406b..5b04ec24f59a 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -242,6 +242,11 @@ short AbstractDropDownFieldDialog_Impl::Execute() return m_xDlg->run(); } +bool AbstractDropDownFieldDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + short AbstractDropDownFormFieldDialog_Impl::Execute() { assert(false); diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 5c7fde5585c7..263ac544a253 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -377,13 +377,15 @@ public: class AbstractDropDownFieldDialog_Impl : public AbstractDropDownFieldDialog { - std::unique_ptr<sw::DropDownFieldDialog> m_xDlg; + std::shared_ptr<sw::DropDownFieldDialog> m_xDlg; public: explicit AbstractDropDownFieldDialog_Impl(std::unique_ptr<sw::DropDownFieldDialog> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void Apply() override { m_xDlg->Apply(); } virtual bool PrevButtonPressed() const override; virtual bool NextButtonPressed() const override; }; diff --git a/sw/source/uibase/inc/DropDownFieldDialog.hxx b/sw/source/uibase/inc/DropDownFieldDialog.hxx index b8b60f20c293..07b9e494d0a6 100644 --- a/sw/source/uibase/inc/DropDownFieldDialog.hxx +++ b/sw/source/uibase/inc/DropDownFieldDialog.hxx @@ -43,7 +43,6 @@ class DropDownFieldDialog final : public weld::GenericDialogController DECL_LINK(EditHdl, weld::Button&, void); DECL_LINK(PrevHdl, weld::Button&, void); DECL_LINK(NextHdl, weld::Button&, void); - void Apply(); DECL_LINK(DoubleClickHdl, weld::TreeView&, bool); public: DropDownFieldDialog(weld::Widget *pParent, SwWrtShell &rSh, @@ -51,6 +50,7 @@ public: virtual ~DropDownFieldDialog() override; bool PrevButtonPressed() const; bool NextButtonPressed() const; + void Apply(); virtual short run() override { short nRet = GenericDialogController::run(); diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx index f49c50f57e5f..6488d06646b4 100644 --- a/sw/source/uibase/inc/wrtsh.hxx +++ b/sw/source/uibase/inc/wrtsh.hxx @@ -418,6 +418,8 @@ typedef bool (SwWrtShell::*FNSimpleMove)(); bool StartInputFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Widget* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr); // update DropDown fields bool StartDropDownFieldDlg(SwField*, bool bPrevButton, bool bNextButton, weld::Widget* pParentWin, FieldDialogPressedButton* pPressedButton = nullptr); + // update single DropDown field + void EditDropDownFieldDlg(SwField*, weld::Widget* pParentWin); //"Handler" for changes at DrawView - for controls. virtual void DrawSelChanged( ) override; diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx index 12f04b8d3f8b..c035c617cdb9 100644 --- a/sw/source/uibase/wrtsh/wrtsh2.cxx +++ b/sw/source/uibase/wrtsh/wrtsh2.cxx @@ -293,6 +293,26 @@ bool SwWrtShell::StartInputFieldDlg(SwField* pField, bool bPrevButton, bool bNex return bRet; } +void SwWrtShell::EditDropDownFieldDlg(SwField* pField, weld::Widget* pParentWin) +{ + SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); + VclPtr<AbstractDropDownFieldDialog> pDlg(pFact->CreateDropDownFieldDialog(pParentWin, *this, pField, false, false)); + + pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nRet) { + if (nRet == RET_OK) + pDlg->Apply(); + + pDlg->disposeOnce(); + + GetWin()->PaintImmediately(); + + if (nRet == RET_YES) + { + GetView().GetViewFrame().GetDispatcher()->Execute(FN_EDIT_FIELD, SfxCallMode::SYNCHRON); + } + }); +} + bool SwWrtShell::StartDropDownFieldDlg(SwField* pField, bool bPrevButton, bool bNextButton, weld::Widget* pParentWin, SwWrtShell::FieldDialogPressedButton* pPressedButton) { @@ -500,7 +520,7 @@ void SwWrtShell::ClickToField(const SwField& rField, bool bExecHyperlinks) StartInputFieldDlg(const_cast<SwField*>(&rField), false, false, GetView().GetFrameWeld()); break; case SwFieldIds::Dropdown : - StartDropDownFieldDlg(const_cast<SwField*>(&rField), false, false, GetView().GetFrameWeld()); + EditDropDownFieldDlg(const_cast<SwField*>(&rField), GetView().GetFrameWeld()); break; default: SAL_WARN_IF(rField.IsClickable(), "sw", "unhandled clickable field!");
