sw/inc/swabstdlg.hxx | 10 +++++++++- sw/source/ui/dialog/swdlgfact.cxx | 18 +++++++++++++++--- sw/source/ui/dialog/swdlgfact.hxx | 16 ++++++++++------ sw/source/ui/table/rowht.cxx | 8 -------- sw/source/uibase/inc/insfnote.hxx | 10 +--------- sw/source/uibase/inc/rowht.hxx | 5 +---- sw/source/uibase/shells/tabsh.cxx | 11 +++++++++-- sw/source/uibase/shells/textsh1.cxx | 30 ++++++++++++++++++------------ sw/source/uibase/uiview/viewdlg2.cxx | 11 +++++++++-- 9 files changed, 72 insertions(+), 47 deletions(-)
New commits: commit 95dc399434ea08b7c762f918d0c6360ef3e0e179 Author: Noel Grandin <[email protected]> AuthorDate: Tue Jan 30 15:57:46 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Jan 30 20:12:58 2024 +0100 make set-row-height dialog async Change-Id: I03e27c09da4f8b58468d4e551413946f03b25f1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162761 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 621ac8cd666f..c8974620060e 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -436,6 +436,13 @@ public: virtual void Apply() = 0; }; +class AbstractSwTableHeightDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractSwTableHeightDlg() override = default; +public: + virtual void Apply() = 0; +}; class SwAbstractDialogFactory { @@ -497,7 +504,7 @@ public: virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) = 0; virtual VclPtr<AbstractSwSortDlg> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) = 0; - virtual VclPtr<VclAbstractDialog> CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) = 0; + virtual VclPtr<AbstractSwTableHeightDlg> CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) = 0; virtual VclPtr<VclAbstractDialog> CreateSwColumnDialog(weld::Window *pParent, SwWrtShell &rSh) = 0; virtual VclPtr<AbstractSplitTableDialog> CreateSplitTableDialog(weld::Window* pParent, SwWrtShell &rSh) = 0; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 66a77db67b4b..46825f29a320 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -155,7 +155,13 @@ bool AbstractSwTableWidthDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) short AbstractSwTableHeightDlg_Impl::Execute() { - return m_xDlg->run(); + assert(false); + return -1; +} + +bool AbstractSwTableHeightDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); } short AbstractSwMergeTableDlg_Impl::Execute() @@ -1128,7 +1134,7 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwColumnDialog(wel return VclPtr<AbstractGenericDialog_Impl>::Create(std::make_shared<SwColumnDlg>(pParent, rSh)); } -VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) +VclPtr<AbstractSwTableHeightDlg> SwAbstractDialogFactory_Impl::CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) { return VclPtr<AbstractSwTableHeightDlg_Impl>::Create(std::make_unique<SwTableHeightDlg>(pParent, rSh)); } diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 5ebcbdd7509e..88e9d2b632c7 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -271,15 +271,17 @@ public: virtual void Apply() override { m_xDlg->Apply(); } }; -class AbstractSwTableHeightDlg_Impl : public VclAbstractDialog +class AbstractSwTableHeightDlg_Impl : public AbstractSwTableHeightDlg { - std::unique_ptr<SwTableHeightDlg> m_xDlg; + std::shared_ptr<SwTableHeightDlg> m_xDlg; public: - explicit AbstractSwTableHeightDlg_Impl(std::unique_ptr<SwTableHeightDlg> p) + explicit AbstractSwTableHeightDlg_Impl(std::shared_ptr<SwTableHeightDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void Apply() override { m_xDlg->Apply(); } }; class AbstractSwMergeTableDlg_Impl : public VclAbstractDialog @@ -795,7 +797,7 @@ public: virtual VclPtr<VclAbstractDialog> CreateSwAutoMarkDialog(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) override; virtual VclPtr<AbstractSwSortDlg> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) override; - virtual VclPtr<VclAbstractDialog> CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<AbstractSwTableHeightDlg> CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<VclAbstractDialog> CreateSwColumnDialog(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<AbstractSplitTableDialog> CreateSplitTableDialog(weld::Window* pParent, SwWrtShell &rSh) override; diff --git a/sw/source/ui/table/rowht.cxx b/sw/source/ui/table/rowht.cxx index f46297bf7de5..7a7c26906f5e 100644 --- a/sw/source/ui/table/rowht.cxx +++ b/sw/source/ui/table/rowht.cxx @@ -61,12 +61,4 @@ SwTableHeightDlg::SwTableHeightDlg(weld::Window *pParent, SwWrtShell &rS) } } -short SwTableHeightDlg::run() -{ - short nRet = GenericDialogController::run(); - if (nRet == RET_OK) - Apply(); - return nRet; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/rowht.hxx b/sw/source/uibase/inc/rowht.hxx index 659b9ac6331a..59a51fc97abe 100644 --- a/sw/source/uibase/inc/rowht.hxx +++ b/sw/source/uibase/inc/rowht.hxx @@ -30,12 +30,9 @@ class SwTableHeightDlg final : public weld::GenericDialogController std::unique_ptr<weld::MetricSpinButton> m_xHeightEdit; std::unique_ptr<weld::CheckButton> m_xAutoHeightCB; -private: - void Apply(); - public: SwTableHeightDlg(weld::Window* pParent, SwWrtShell& rS); - virtual short run() override; + void Apply(); }; #endif diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 0adc875b5279..8b1280dcbab7 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -887,8 +887,15 @@ void SwTableShell::Execute(SfxRequest &rReq) case FN_TABLE_SET_ROW_HEIGHT: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwTableHeightDialog(GetView().GetFrameWeld(), rSh)); - pDlg->Execute(); + VclPtr<AbstractSwTableHeightDlg> pDlg(pFact->CreateSwTableHeightDialog(GetView().GetFrameWeld(), rSh)); + pDlg->StartExecuteAsync( + [pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + pDlg->Apply(); + pDlg->disposeOnce(); + } + ); break; } case FN_NUMBER_BULLETS: commit 7bd438c42c8c7f80bfdb99d53aac9674b5ae0a3e Author: Noel Grandin <[email protected]> AuthorDate: Tue Jan 30 15:50:01 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Jan 30 20:12:48 2024 +0100 convert insert-footnote dialog to async Change-Id: Iea3cb8fe1486c229b5441574b1de9b81758bc251 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162760 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 4ea4085f387e..621ac8cd666f 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -113,6 +113,7 @@ class AbstractInsFootNoteDlg : public VclAbstractDialog protected: virtual ~AbstractInsFootNoteDlg() override = default; public: + virtual void Apply() = 0; virtual OUString GetFontName() = 0; virtual bool IsEndNote() = 0; virtual OUString GetStr() = 0; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 5b26dcd38c59..66a77db67b4b 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -298,7 +298,13 @@ short AbstractFieldInputDlg_Impl::Execute() short AbstractInsFootNoteDlg_Impl::Execute() { - return m_xDlg->run(); + assert(false); + return -1; +} + +bool AbstractInsFootNoteDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); } short AbstractJavaEditDialog_Impl::Execute() diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 92e565f5bfcf..5ebcbdd7509e 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -550,13 +550,15 @@ public: class SwInsFootNoteDlg; class AbstractInsFootNoteDlg_Impl : public AbstractInsFootNoteDlg { - std::unique_ptr<SwInsFootNoteDlg> m_xDlg; + std::shared_ptr<SwInsFootNoteDlg> m_xDlg; public: - explicit AbstractInsFootNoteDlg_Impl(std::unique_ptr<SwInsFootNoteDlg> p) + explicit AbstractInsFootNoteDlg_Impl(std::shared_ptr<SwInsFootNoteDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void Apply() override { m_xDlg->Apply(); } virtual OUString GetFontName() override; virtual bool IsEndNote() override; virtual OUString GetStr() override; diff --git a/sw/source/uibase/inc/insfnote.hxx b/sw/source/uibase/inc/insfnote.hxx index 396e87404644..7e9bb2649029 100644 --- a/sw/source/uibase/inc/insfnote.hxx +++ b/sw/source/uibase/inc/insfnote.hxx @@ -54,8 +54,6 @@ class SwInsFootNoteDlg final : public weld::GenericDialogController DECL_LINK(NumberExtCharHdl, weld::Button&, void); DECL_LINK(NextPrevHdl, weld::Button&, void); - void Apply(); - void Init(); public: @@ -70,13 +68,7 @@ public: return m_xNumberCharEdit->get_text(); return OUString(); } - virtual short run() override - { - short nRet = GenericDialogController::run(); - if (nRet == RET_OK) - Apply(); - return nRet; - } + void Apply(); }; #endif diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 23fd3e4804d4..1a70f027fdef 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -990,20 +990,26 @@ void SwTextShell::Execute(SfxRequest &rReq) case FN_INSERT_FOOTNOTE_DLG: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg( + VclPtr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg( GetView().GetFrameWeld(), rWrtSh)); pDlg->SetHelpId(GetStaticInterface()->GetSlot(nSlot)->GetCommand()); - if ( pDlg->Execute() == RET_OK ) - { - const sal_uInt16 nId = pDlg->IsEndNote() ? FN_INSERT_ENDNOTE : FN_INSERT_FOOTNOTE; - SfxRequest aReq(GetView().GetViewFrame(), nId); - if ( !pDlg->GetStr().isEmpty() ) - aReq.AppendItem( SfxStringItem( nId, pDlg->GetStr() ) ); - if ( !pDlg->GetFontName().isEmpty() ) - aReq.AppendItem( SfxStringItem( FN_PARAM_1, pDlg->GetFontName() ) ); - ExecuteSlot( aReq ); - } - + pDlg->StartExecuteAsync( + [this, pDlg] (sal_Int32 nResult)->void + { + if ( nResult == RET_OK ) + { + pDlg->Apply(); + const sal_uInt16 nId = pDlg->IsEndNote() ? FN_INSERT_ENDNOTE : FN_INSERT_FOOTNOTE; + SfxRequest aReq(GetView().GetViewFrame(), nId); + if ( !pDlg->GetStr().isEmpty() ) + aReq.AppendItem( SfxStringItem( nId, pDlg->GetStr() ) ); + if ( !pDlg->GetFontName().isEmpty() ) + aReq.AppendItem( SfxStringItem( FN_PARAM_1, pDlg->GetFontName() ) ); + ExecuteSlot( aReq ); + } + pDlg->disposeOnce(); + } + ); rReq.Ignore(); } break; diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx index bd2b9509e6d9..7d78b693dfaa 100644 --- a/sw/source/uibase/uiview/viewdlg2.cxx +++ b/sw/source/uibase/uiview/viewdlg2.cxx @@ -130,12 +130,19 @@ void SwView::ExecDlgExt(SfxRequest& rReq) case FN_EDIT_FOOTNOTE: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg( + VclPtr<AbstractInsFootNoteDlg> pDlg(pFact->CreateInsFootNoteDlg( GetFrameWeld(), *m_pWrtShell, true)); pDlg->SetHelpId(GetStaticInterface()->GetSlot(FN_EDIT_FOOTNOTE)->GetCommand()); pDlg->SetText( SwResId(STR_EDIT_FOOTNOTE) ); - pDlg->Execute(); + pDlg->StartExecuteAsync( + [pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + pDlg->Apply(); + pDlg->disposeOnce(); + } + ); break; } }
