sw/inc/swabstdlg.hxx | 10 +++++++++- sw/source/ui/dbui/dbinsdlg.cxx | 15 ++++++++++++--- sw/source/ui/dialog/swdlgfact.cxx | 18 +++++++++++++++--- sw/source/ui/dialog/swdlgfact.hxx | 16 ++++++++++------ sw/source/ui/misc/srtdlg.cxx | 8 -------- sw/source/ui/table/convert.cxx | 12 +++++++++--- sw/source/ui/table/tautofmt.cxx | 6 ++---- sw/source/uibase/inc/srtdlg.hxx | 3 +-- sw/source/uibase/inc/tautofmt.hxx | 4 ++-- sw/source/uibase/shells/tabsh.cxx | 11 +++++++++-- sw/source/uibase/shells/textsh1.cxx | 15 ++++++++++++--- 11 files changed, 81 insertions(+), 37 deletions(-)
New commits: commit b70d96db53085bdd4e66c22857590d5b2cd391f9 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jan 30 15:36:56 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 30 20:12:38 2024 +0100 make sorting dialog async Change-Id: I9773ec07e13144662a06307452b17f9e96527e89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162759 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index 597781c04f13..4ea4085f387e 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -419,6 +419,13 @@ public: virtual std::optional<SwLanguageListItem> GetSelectedLanguage() = 0; }; +class AbstractSwSortDlg : public VclAbstractDialog +{ +protected: + virtual ~AbstractSwSortDlg() override = default; +public: + virtual void Apply() = 0; +}; class AbstractSwTableWidthDlg : public VclAbstractDialog { @@ -488,7 +495,7 @@ public: virtual VclPtr<AbstractSwSelGlossaryDlg> CreateSwSelGlossaryDlg(weld::Window *pParent, const OUString &rShortName) = 0; - virtual VclPtr<VclAbstractDialog> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) = 0; + virtual VclPtr<AbstractSwSortDlg> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) = 0; virtual VclPtr<VclAbstractDialog> 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 155a8d854571..5b26dcd38c59 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -185,7 +185,13 @@ bool AbstractGenericDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) short AbstractSwSortDlg_Impl::Execute() { - return m_xDlg->run(); + assert(false); + return -1; +} + +bool AbstractSwSortDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); } short AbstractMultiTOXMarkDlg_Impl::Execute() @@ -1121,7 +1127,7 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwTableHeightDialo return VclPtr<AbstractSwTableHeightDlg_Impl>::Create(std::make_unique<SwTableHeightDlg>(pParent, rSh)); } -VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) +VclPtr<AbstractSwSortDlg> SwAbstractDialogFactory_Impl::CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) { return VclPtr<AbstractSwSortDlg_Impl>::Create(std::make_unique<SwSortDlg>(pParent, rSh)); } diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 2a67b5547d64..92e565f5bfcf 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -185,15 +185,17 @@ public: virtual bool StartExecuteAsync(AsyncContext &rCtx) override; }; -class AbstractSwSortDlg_Impl : public VclAbstractDialog +class AbstractSwSortDlg_Impl : public AbstractSwSortDlg { - std::unique_ptr<SwSortDlg> m_xDlg; + std::shared_ptr<SwSortDlg> m_xDlg; public: - explicit AbstractSwSortDlg_Impl(std::unique_ptr<SwSortDlg> p) + explicit AbstractSwSortDlg_Impl(std::shared_ptr<SwSortDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void Apply() override { m_xDlg->Apply(); } }; class AbstractMultiTOXMarkDlg_Impl : public VclAbstractDialog @@ -790,7 +792,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<VclAbstractDialog> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) override; + virtual VclPtr<AbstractSwSortDlg> CreateSwSortingDialog(weld::Window *pParent, SwWrtShell &rSh) override; virtual VclPtr<VclAbstractDialog> 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/misc/srtdlg.cxx b/sw/source/ui/misc/srtdlg.cxx index 724390ff6edb..49ffa058636f 100644 --- a/sw/source/ui/misc/srtdlg.cxx +++ b/sw/source/ui/misc/srtdlg.cxx @@ -217,14 +217,6 @@ sal_Unicode SwSortDlg::GetDelimChar() const return cRet; } -short SwSortDlg::run() -{ - short nRet = GenericDialogController::run(); - if (nRet == RET_OK) - Apply(); - return nRet; -} - // pass on to the Core void SwSortDlg::Apply() { diff --git a/sw/source/uibase/inc/srtdlg.hxx b/sw/source/uibase/inc/srtdlg.hxx index 590988735405..e7516fb4c94a 100644 --- a/sw/source/uibase/inc/srtdlg.hxx +++ b/sw/source/uibase/inc/srtdlg.hxx @@ -70,7 +70,6 @@ class SwSortDlg final : public weld::GenericDialogController sal_uInt16 m_nX; sal_uInt16 m_nY; - void Apply(); sal_Unicode GetDelimChar() const; DECL_LINK(CheckHdl, weld::Toggleable&, void); @@ -81,7 +80,7 @@ class SwSortDlg final : public weld::GenericDialogController public: SwSortDlg(weld::Window* pParent, SwWrtShell& rSh); - virtual short run() override; + void Apply(); }; #endif diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 1716e6183180..23fd3e4804d4 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1289,9 +1289,18 @@ void SwTextShell::Execute(SfxRequest &rReq) case FN_SORTING_DLG: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSwSortingDialog(GetView().GetFrameWeld(), rWrtSh)); - pDlg->Execute(); - rReq.Done(); + VclPtr<AbstractSwSortDlg> pDlg(pFact->CreateSwSortingDialog(GetView().GetFrameWeld(), rWrtSh)); + auto xRequest = std::make_shared<SfxRequest>(rReq); + rReq.Ignore(); // the 'old' request is not relevant any more + pDlg->StartExecuteAsync( + [pDlg, xRequest] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + pDlg->Apply(); + pDlg->disposeOnce(); + xRequest->Done(); + } + ); } break; case FN_NUMBERING_OUTLINE_DLG: commit c91faacfb7dd26fe7b7c93c7af5d4c330779a59f Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jan 30 15:29:59 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 30 20:12:29 2024 +0100 make auto-format dialog async Change-Id: Ibef42bed3448e466877608c165131a806068f5b3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162758 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index f9398ad73fca..597781c04f13 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -326,6 +326,7 @@ protected: virtual ~AbstractSwAutoFormatDlg() override = default; public: virtual std::unique_ptr<SwTableAutoFormat> FillAutoFormatOfIndex() const = 0; + virtual void Apply() = 0; }; class AbstractSwFieldDlg : public SfxAbstractTabDialog diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx index 2a0b00018208..7e8613235f26 100644 --- a/sw/source/ui/dbui/dbinsdlg.cxx +++ b/sw/source/ui/dbui/dbinsdlg.cxx @@ -733,9 +733,18 @@ IMPL_LINK_NOARG(SwInsertDBColAutoPilot, AutoFormatHdl, weld::Button&, void) { SwAbstractDialogFactory& rFact = swui::GetFactory(); - ScopedVclPtr<AbstractSwAutoFormatDlg> pDlg(rFact.CreateSwAutoFormatDlg(m_xDialog.get(), m_pView->GetWrtShellPtr(), false, m_xTAutoFormat.get())); - if( RET_OK == pDlg->Execute()) - m_xTAutoFormat = pDlg->FillAutoFormatOfIndex(); + VclPtr<AbstractSwAutoFormatDlg> pDlg(rFact.CreateSwAutoFormatDlg(m_xDialog.get(), m_pView->GetWrtShellPtr(), false, m_xTAutoFormat.get())); + pDlg->StartExecuteAsync( + [this, pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + { + pDlg->Apply(); + m_xTAutoFormat = pDlg->FillAutoFormatOfIndex(); + } + pDlg->disposeOnce(); + } + ); } IMPL_LINK(SwInsertDBColAutoPilot, TVSelectHdl, weld::TreeView&, rBox, void) diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 8b79dc4446bf..155a8d854571 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -240,7 +240,13 @@ short AbstractSwSelGlossaryDlg_Impl::Execute() short AbstractSwAutoFormatDlg_Impl::Execute() { - return m_xDlg->run(); + assert(false); + return -1; +} + +bool AbstractSwAutoFormatDlg_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return weld::GenericDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); } short AbstractSwFieldDlg_Impl::Execute() diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index c8c6de47d489..2a67b5547d64 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -434,14 +434,16 @@ public: class AbstractSwAutoFormatDlg_Impl : public AbstractSwAutoFormatDlg { - std::unique_ptr<SwAutoFormatDlg, o3tl::default_delete<SwAutoFormatDlg>> m_xDlg; + std::shared_ptr<SwAutoFormatDlg> m_xDlg; public: - explicit AbstractSwAutoFormatDlg_Impl(std::unique_ptr<SwAutoFormatDlg, o3tl::default_delete<SwAutoFormatDlg>> p) + explicit AbstractSwAutoFormatDlg_Impl(std::shared_ptr<SwAutoFormatDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; virtual std::unique_ptr<SwTableAutoFormat> FillAutoFormatOfIndex() const override; + virtual void Apply() override { m_xDlg->Apply(); } }; class AbstractSwFieldDlg_Impl : public AbstractSwFieldDlg diff --git a/sw/source/ui/table/convert.cxx b/sw/source/ui/table/convert.cxx index fa5184cd69ff..3f7a55ad1936 100644 --- a/sw/source/ui/table/convert.cxx +++ b/sw/source/ui/table/convert.cxx @@ -166,10 +166,16 @@ IMPL_LINK_NOARG(SwConvertTableDlg, AutoFormatHdl, weld::Button&, void) { SwAbstractDialogFactory& rFact = swui::GetFactory(); - ScopedVclPtr<AbstractSwAutoFormatDlg> pDlg( + VclPtr<AbstractSwAutoFormatDlg> pDlg( rFact.CreateSwAutoFormatDlg(m_xDialog.get(), m_pShell, false, mxTAutoFormat.get())); - if (RET_OK == pDlg->Execute()) - mxTAutoFormat = pDlg->FillAutoFormatOfIndex(); + pDlg->StartExecuteAsync([this, pDlg](sal_Int32 nResult) -> void { + if (nResult == RET_OK) + { + pDlg->Apply(); + mxTAutoFormat = pDlg->FillAutoFormatOfIndex(); + } + pDlg->disposeOnce(); + }); } IMPL_LINK(SwConvertTableDlg, BtnHdl, weld::Toggleable&, rButton, void) diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index 8dbc965e80ba..bc7057d75d4f 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -397,12 +397,10 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFormatHdl, weld::TreeView&, void) m_xBtnRename->set_sensitive(bBtnEnable); } -short SwAutoFormatDlg::run() +void SwAutoFormatDlg::Apply() { - short nRet = SfxDialogController::run(); - if (nRet == RET_OK && m_bSetAutoFormat) + if (m_bSetAutoFormat) m_pShell->SetTableStyle((*m_xTableTable)[m_nIndex]); - return nRet; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/tautofmt.hxx b/sw/source/uibase/inc/tautofmt.hxx index 4c03bd981d92..8cddab7fcca0 100644 --- a/sw/source/uibase/inc/tautofmt.hxx +++ b/sw/source/uibase/inc/tautofmt.hxx @@ -77,10 +77,10 @@ public: SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pShell, bool bSetAutoFormat, const SwTableAutoFormat* pSelFormat); - virtual short run() override; - std::unique_ptr<SwTableAutoFormat> FillAutoFormatOfIndex() const; + void Apply(); + virtual ~SwAutoFormatDlg() override; }; diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx index 48ef761818dd..0adc875b5279 100644 --- a/sw/source/uibase/shells/tabsh.cxx +++ b/sw/source/uibase/shells/tabsh.cxx @@ -873,8 +873,15 @@ void SwTableShell::Execute(SfxRequest &rReq) case SID_AUTOFORMAT: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - ScopedVclPtr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(GetView().GetFrameWeld(), &rSh)); - pDlg->Execute(); + VclPtr<AbstractSwAutoFormatDlg> pDlg(pFact->CreateSwAutoFormatDlg(GetView().GetFrameWeld(), &rSh)); + pDlg->StartExecuteAsync( + [pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + pDlg->Apply(); + pDlg->disposeOnce(); + } + ); break; } case FN_TABLE_SET_ROW_HEIGHT: