include/sfx2/tabdlg.hxx | 1 sw/inc/swabstdlg.hxx | 12 +++++++-- sw/source/ui/dialog/swdlgfact.cxx | 47 ++++++++++++++++++++++++++++++++++--- sw/source/ui/dialog/swdlgfact.hxx | 24 +++++++++++++++++- sw/source/ui/misc/num.cxx | 4 +-- sw/source/uibase/inc/num.hxx | 2 - sw/source/uibase/shells/txtnum.cxx | 6 ++-- 7 files changed, 83 insertions(+), 13 deletions(-)
New commits: commit c2164850f20d9342db94faa84c78fbb5b976552e Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Aug 16 12:43:47 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Aug 16 16:30:02 2023 +0200 cid#1539911 Big parameter passed by value Change-Id: I761fb02d80a224a4b170bb287169da923a003d99 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155736 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx index bde7dee39660..f43df12970cc 100644 --- a/include/sfx2/tabdlg.hxx +++ b/include/sfx2/tabdlg.hxx @@ -141,6 +141,7 @@ public: const WhichRangesContainer& GetInputRanges( const SfxItemPool& ); void SetInputSet( const SfxItemSet* pInSet ); const SfxItemSet* GetOutputItemSet() const { return m_pOutSet.get(); } + const SfxItemSet* GetInputItemSet() const { return m_pSet.get(); } virtual weld::Button& GetOKButton() const override { return *m_xOKBtn; } weld::Button& GetCancelButton() const { return *m_xCancelBtn; } diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index c6f38756a265..a9ceb855b337 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -339,6 +339,14 @@ public: virtual std::shared_ptr<SfxDialogController> GetController() = 0; }; +class AbstractNumBulletDialog : public SfxAbstractTabDialog +{ +protected: + virtual ~AbstractNumBulletDialog() override = default; +public: + virtual const SfxItemSet* GetInputItemSet() const = 0; +}; + /** * Interface for e.g. the insert -> bookmark -> rename dialog. It's implemented by * AbstractSwRenameXNamedDlg_Impl, but SwInsertBookmarkDlg only knows about this interface and the @@ -531,7 +539,7 @@ public: virtual VclPtr<SfxAbstractTabDialog> CreateOutlineTabDialog(weld::Window* pParent, const SfxItemSet* pSwItemSet, SwWrtShell &) = 0; - virtual VclPtr<SfxAbstractTabDialog> CreateSvxNumBulletTabDialog(weld::Window* pParent, + virtual VclPtr<AbstractNumBulletDialog> CreateSvxNumBulletTabDialog(weld::Window* pParent, const SfxItemSet& rSwItemSet, SwWrtShell &) = 0; virtual VclPtr<AbstractMultiTOXTabDialog> CreateMultiTOXTabDialog( diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index b75d4a39bd0a..960852fe3a44 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -187,6 +187,11 @@ short AbstractTabController_Impl::Execute() return m_xDlg->run(); } +short AbstractNumBulletDialog_Impl::Execute() +{ + return m_xDlg->run(); +} + short AbstractSwConvertTableDlg_Impl::Execute() { return m_xDlg->run(); @@ -353,6 +358,42 @@ void AbstractTabController_Impl::SetText( const OUString& rStr ) m_xDlg->set_title(rStr); } +void AbstractNumBulletDialog_Impl::SetCurPageId( const OUString &rName ) +{ + m_xDlg->SetCurPageId( rName ); +} + +const SfxItemSet* AbstractNumBulletDialog_Impl::GetOutputItemSet() const +{ + return m_xDlg->GetOutputItemSet(); +} + +const SfxItemSet* AbstractNumBulletDialog_Impl::GetInputItemSet() const +{ + return m_xDlg->GetInputItemSet(); +} + +WhichRangesContainer AbstractNumBulletDialog_Impl::GetInputRanges(const SfxItemPool& pItem ) +{ + return m_xDlg->GetInputRanges( pItem ); +} + +void AbstractNumBulletDialog_Impl::SetInputSet( const SfxItemSet* pInSet ) +{ + m_xDlg->SetInputSet( pInSet ); +} + +bool AbstractNumBulletDialog_Impl::StartExecuteAsync(AsyncContext &rCtx) +{ + return SfxTabDialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + +//From class Window. +void AbstractNumBulletDialog_Impl::SetText( const OUString& rStr ) +{ + m_xDlg->set_title(rStr); +} + IMPL_LINK_NOARG(AbstractApplyTabController_Impl, ApplyHdl, weld::Button&, void) { if (m_xDlg->Apply()) @@ -1213,11 +1254,11 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateMultiTOXMarkDlg(we return VclPtr<AbstractMultiTOXMarkDlg_Impl>::Create(std::make_unique<SwMultiTOXMarkDlg>(pParent, rTOXMgr)); } -VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSvxNumBulletTabDialog(weld::Window* pParent, +VclPtr<AbstractNumBulletDialog> SwAbstractDialogFactory_Impl::CreateSvxNumBulletTabDialog(weld::Window* pParent, const SfxItemSet& rSwItemSet, SwWrtShell & rWrtSh) { - return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwSvxNumBulletTabDialog>(pParent, rSwItemSet, rWrtSh)); + return VclPtr<AbstractNumBulletDialog_Impl>::Create(std::make_shared<SwSvxNumBulletTabDialog>(pParent, rSwItemSet, rWrtSh)); } VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateOutlineTabDialog(weld::Window* pParent, diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 2d7508ab51b5..d5c1c43806d8 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -206,6 +206,26 @@ public: virtual short Execute() override; }; +class AbstractNumBulletDialog_Impl : public AbstractNumBulletDialog +{ +protected: + std::shared_ptr<SfxTabDialogController> m_xDlg; +public: + explicit AbstractNumBulletDialog_Impl(std::shared_ptr<SfxTabDialogController> p) + : m_xDlg(std::move(p)) + { + } + virtual short Execute() override; + virtual bool StartExecuteAsync(AsyncContext &rCtx) override; + virtual void SetCurPageId( const OUString &rName ) override; + virtual const SfxItemSet* GetOutputItemSet() const override; + virtual const SfxItemSet* GetInputItemSet() const override; + virtual WhichRangesContainer GetInputRanges( const SfxItemPool& pItem ) override; + virtual void SetInputSet( const SfxItemSet* pInSet ) override; + //From class Window. + virtual void SetText( const OUString& rStr ) override; +}; + class AbstractSwBreakDlg_Impl : public AbstractSwBreakDlg { std::shared_ptr<weld::DialogController> m_xDlg; @@ -819,7 +839,7 @@ public: virtual VclPtr<VclAbstractDialog> CreateMultiTOXMarkDlg(weld::Window* pParent, SwTOXMgr &rTOXMgr) override; virtual VclPtr<SfxAbstractTabDialog> CreateOutlineTabDialog(weld::Window* pParent, const SfxItemSet* pSwItemSet, SwWrtShell &) override; - virtual VclPtr<SfxAbstractTabDialog> CreateSvxNumBulletTabDialog(weld::Window* pParent, + virtual VclPtr<AbstractNumBulletDialog> CreateSvxNumBulletTabDialog(weld::Window* pParent, const SfxItemSet& rSwItemSet, SwWrtShell &) override; virtual VclPtr<AbstractMultiTOXTabDialog> CreateMultiTOXTabDialog( diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx index d4150c806379..c577cdafdfcc 100644 --- a/sw/source/uibase/shells/txtnum.cxx +++ b/sw/source/uibase/shells/txtnum.cxx @@ -192,7 +192,7 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); weld::Window *pParent = rReq.GetFrameWeld(); - VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, aSet, GetShell())); + VclPtr<AbstractNumBulletDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, aSet, GetShell())); const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1); if ( pPageItem ) pDlg->SetCurPageId( pPageItem->GetValue() ); @@ -200,7 +200,7 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) auto pRequest = std::make_shared<SfxRequest>(rReq); rReq.Ignore(); // the 'old' request is not relevant any more - pDlg->StartExecuteAsync([aSet=std::move(aSet), pDlg, pNumRuleAtCurrentSelection, pRequest, this](sal_Int32 nResult){ + pDlg->StartExecuteAsync([pDlg, pNumRuleAtCurrentSelection, pRequest, this](sal_Int32 nResult){ if (RET_OK == nResult) { const SvxNumBulletItem* pBulletItem = pDlg->GetOutputItemSet()->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false); @@ -224,7 +224,7 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) // If the Dialog was leaved with OK but nothing was chosen then the // numbering must be at least activated, if it is not already. else if (pNumRuleAtCurrentSelection == nullptr - && (pBulletItem = aSet.GetItemIfSet(SID_ATTR_NUMBERING_RULE, false))) + && (pBulletItem = pDlg->GetInputItemSet()->GetItemIfSet(SID_ATTR_NUMBERING_RULE, false))) { pRequest->AppendItem(*pBulletItem); pRequest->Done(); commit 89d020bc5887077a2e5175bcaec7cd7e4c453305 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Wed Aug 16 11:46:04 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Aug 16 16:29:55 2023 +0200 itemset is always passed, so can use a reference Change-Id: Id238066861ee21a9a69f40d1c136bd5b5bd0f804 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155735 Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/inc/swabstdlg.hxx b/sw/inc/swabstdlg.hxx index fe6bab309ef9..c6f38756a265 100644 --- a/sw/inc/swabstdlg.hxx +++ b/sw/inc/swabstdlg.hxx @@ -532,7 +532,7 @@ public: const SfxItemSet* pSwItemSet, SwWrtShell &) = 0; virtual VclPtr<SfxAbstractTabDialog> CreateSvxNumBulletTabDialog(weld::Window* pParent, - const SfxItemSet* pSwItemSet, + const SfxItemSet& rSwItemSet, SwWrtShell &) = 0; virtual VclPtr<AbstractMultiTOXTabDialog> CreateMultiTOXTabDialog( weld::Widget* pParent, const SfxItemSet& rSet, diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 90f7c6e34d84..b75d4a39bd0a 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -1214,10 +1214,10 @@ VclPtr<VclAbstractDialog> SwAbstractDialogFactory_Impl::CreateMultiTOXMarkDlg(we } VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateSvxNumBulletTabDialog(weld::Window* pParent, - const SfxItemSet* pSwItemSet, + const SfxItemSet& rSwItemSet, SwWrtShell & rWrtSh) { - return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwSvxNumBulletTabDialog>(pParent, pSwItemSet, rWrtSh)); + return VclPtr<AbstractTabController_Impl>::Create(std::make_shared<SwSvxNumBulletTabDialog>(pParent, rSwItemSet, rWrtSh)); } VclPtr<SfxAbstractTabDialog> SwAbstractDialogFactory_Impl::CreateOutlineTabDialog(weld::Window* pParent, diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 8105a6fd4e33..2d7508ab51b5 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -820,7 +820,7 @@ public: virtual VclPtr<SfxAbstractTabDialog> CreateOutlineTabDialog(weld::Window* pParent, const SfxItemSet* pSwItemSet, SwWrtShell &) override; virtual VclPtr<SfxAbstractTabDialog> CreateSvxNumBulletTabDialog(weld::Window* pParent, - const SfxItemSet* pSwItemSet, + const SfxItemSet& rSwItemSet, SwWrtShell &) override; virtual VclPtr<AbstractMultiTOXTabDialog> CreateMultiTOXTabDialog( weld::Widget* pParent, const SfxItemSet& rSet, diff --git a/sw/source/ui/misc/num.cxx b/sw/source/ui/misc/num.cxx index 15848bf98c4b..0764a61be710 100644 --- a/sw/source/ui/misc/num.cxx +++ b/sw/source/ui/misc/num.cxx @@ -860,9 +860,9 @@ void SwNumPositionTabPage::SetModified() #endif SwSvxNumBulletTabDialog::SwSvxNumBulletTabDialog(weld::Window* pParent, - const SfxItemSet* pSwItemSet, SwWrtShell & rSh) + const SfxItemSet& rSwItemSet, SwWrtShell & rSh) : SfxTabDialogController(pParent, "modules/swriter/ui/bulletsandnumbering.ui", "BulletsAndNumberingDialog", - pSwItemSet) + &rSwItemSet) , m_rWrtSh(rSh) , m_xDummyCombo(m_xBuilder->weld_combo_box("dummycombo")) { diff --git a/sw/source/uibase/inc/num.hxx b/sw/source/uibase/inc/num.hxx index c849198b86ec..9dfa2bf9ea4f 100644 --- a/sw/source/uibase/inc/num.hxx +++ b/sw/source/uibase/inc/num.hxx @@ -129,7 +129,7 @@ class SwSvxNumBulletTabDialog final : public SfxTabDialogController public: SwSvxNumBulletTabDialog(weld::Window* pParent, - const SfxItemSet* pSwItemSet, + const SfxItemSet& rSwItemSet, SwWrtShell &); virtual ~SwSvxNumBulletTabDialog() override; }; diff --git a/sw/source/uibase/shells/txtnum.cxx b/sw/source/uibase/shells/txtnum.cxx index 3a2df2cdc0cf..d4150c806379 100644 --- a/sw/source/uibase/shells/txtnum.cxx +++ b/sw/source/uibase/shells/txtnum.cxx @@ -192,7 +192,7 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); weld::Window *pParent = rReq.GetFrameWeld(); - VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, &aSet, GetShell())); + VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxNumBulletTabDialog(pParent, aSet, GetShell())); const SfxStringItem* pPageItem = rReq.GetArg<SfxStringItem>(FN_PARAM_1); if ( pPageItem ) pDlg->SetCurPageId( pPageItem->GetValue() );