From 1d2773807f6d2deb1181ef4b14fbdd49ca1d5c14 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 5 Mar 2021 10:47:16 +0200 Subject: ref-count SdrPage which simplifies ownership handling, particularly with regard to undo/redo Change-Id: Ie8f300ebfdae6db3c06f78a87e35a07497d6b825 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111991 Tested-by: Jenkins Reviewed-by: Noel Grandin --- reportdesign/source/core/sdr/RptModel.cxx | 12 ++++++------ reportdesign/source/core/sdr/RptPage.cxx | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'reportdesign/source') diff --git a/reportdesign/source/core/sdr/RptModel.cxx b/reportdesign/source/core/sdr/RptModel.cxx index 0a636fa2f93a..3ac79aa42beb 100644 --- a/reportdesign/source/core/sdr/RptModel.cxx +++ b/reportdesign/source/core/sdr/RptModel.cxx @@ -66,7 +66,7 @@ void OReportModel::detachController() m_xUndoEnv->Clear(OXUndoEnvironment::Accessor()); } -SdrPage* OReportModel::AllocPage(bool /*bMasterPage*/) +rtl::Reference OReportModel::AllocPage(bool /*bMasterPage*/) { OSL_FAIL("Who called me!"); return nullptr; @@ -86,19 +86,19 @@ void OReportModel::SetModified(bool _bModified) m_pController->setModified(_bModified); } -SdrPage* OReportModel::RemovePage(sal_uInt16 nPgNum) +rtl::Reference OReportModel::RemovePage(sal_uInt16 nPgNum) { - OReportPage* pPage = dynamic_cast(SdrModel::RemovePage(nPgNum)); + rtl::Reference pPage = dynamic_cast(SdrModel::RemovePage(nPgNum).get()); return pPage; } OReportPage* OReportModel::createNewPage(const uno::Reference< report::XSection >& _xSection) { SolarMutexGuard aSolarGuard; - OReportPage* pPage = new OReportPage( *this ,_xSection); - InsertPage(pPage); + rtl::Reference pPage = new OReportPage( *this ,_xSection); + InsertPage(pPage.get()); m_xUndoEnv->AddSection(_xSection); - return pPage; + return pPage.get(); } OReportPage* OReportModel::getPage(const uno::Reference< report::XSection >& _xSection) diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx index 4c1fcba02f43..0b856322796c 100644 --- a/reportdesign/source/core/sdr/RptPage.cxx +++ b/reportdesign/source/core/sdr/RptPage.cxx @@ -41,10 +41,10 @@ OReportPage::~OReportPage() { } -SdrPage* OReportPage::CloneSdrPage(SdrModel& rTargetModel) const +rtl::Reference OReportPage::CloneSdrPage(SdrModel& rTargetModel) const { OReportModel& rOReportModel(static_cast< OReportModel& >(rTargetModel)); - OReportPage* pClonedOReportPage( + rtl::Reference pClonedOReportPage( new OReportPage( rOReportModel, m_xSection)); -- cgit