From 51bacc6a065f380a26b8cc2e5c18ff0ab4162ac3 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Thu, 4 Dec 2014 21:39:43 +0100 Subject: impl. Clone for all subclasses of SdrPage Change-Id: Ie370161e51ff83cb605bc57d317ff945404e5611 --- svx/source/form/fmpage.cxx | 17 ++++++++++++++--- svx/source/svdraw/svdpage.cxx | 27 ++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) (limited to 'svx') diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx index 96c3baaf7105..5c41a768728f 100644 --- a/svx/source/form/fmpage.cxx +++ b/svx/source/form/fmpage.cxx @@ -68,9 +68,9 @@ FmFormPage::FmFormPage(const FmFormPage& rPage) { } -void FmFormPage::lateInit(const FmFormPage& rPage) +void FmFormPage::lateInit(const FmFormPage& rPage, FmFormModel* const pNewModel) { - SdrPage::lateInit( rPage ); + SdrPage::lateInit( rPage, pNewModel ); m_pImpl->initFrom( rPage.GetImpl() ); m_sPageName = rPage.m_sPageName; @@ -118,9 +118,20 @@ void FmFormPage::SetModel(SdrModel* pNewModel) SdrPage* FmFormPage::Clone() const +{ + return Clone(0); +} + +SdrPage* FmFormPage::Clone(SdrModel* const pNewModel) const { FmFormPage* const pNewPage = new FmFormPage(*this); - pNewPage->lateInit(*this); + FmFormModel* pFormModel = 0; + if (pNewModel) + { + pFormModel = dynamic_cast(pNewModel); + assert(pFormModel); + } + pNewPage->lateInit(*this, pFormModel); return pNewPage; } diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index da27d4a27f09..e4238d96766b 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -1302,10 +1302,17 @@ SdrPage::~SdrPage() } -void SdrPage::lateInit(const SdrPage& rSrcPage) +void SdrPage::lateInit(const SdrPage& rSrcPage, SdrModel* const pNewModel) { assert(!mpViewContact); assert(!mpSdrPageProperties); + assert(!mxUnoPage.is()); + + if (pNewModel && (pNewModel != pModel)) + { + pModel = pNewModel; + impl_setModelForLayerAdmin(pNewModel); + } // copy all the local parameters to make this instance // a valid copy of source page before copying and inserting @@ -1512,18 +1519,24 @@ sal_Int32 SdrPage::GetLwrBorder() const return nBordLwr; } +void SdrPage::impl_setModelForLayerAdmin(SdrModel* const pNewModel) +{ + if (pNewModel!=NULL) { + pLayerAdmin->SetParent(&pNewModel->GetLayerAdmin()); + } else { + pLayerAdmin->SetParent(NULL); + } + pLayerAdmin->SetModel(pNewModel); +} + void SdrPage::SetModel(SdrModel* pNewModel) { SdrModel* pOldModel=pModel; SdrObjList::SetModel(pNewModel); + if (pNewModel!=pOldModel) { - if (pNewModel!=NULL) { - pLayerAdmin->SetParent(&pNewModel->GetLayerAdmin()); - } else { - pLayerAdmin->SetParent(NULL); - } - pLayerAdmin->SetModel(pNewModel); + impl_setModelForLayerAdmin( pNewModel ); // create new SdrPageProperties with new model (due to SfxItemSet there) // and copy ItemSet and StyleSheet -- cgit