diff options
author | David Tardon <dtardon@redhat.com> | 2014-12-04 21:39:43 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-12-04 23:10:25 +0100 |
commit | 51bacc6a065f380a26b8cc2e5c18ff0ab4162ac3 (patch) | |
tree | b42a463a134ff18ddac578dc88066d282268c4eb | |
parent | 9638e6207c7fc48712b1b238177462c00f5011e8 (diff) |
impl. Clone for all subclasses of SdrPage
Change-Id: Ie370161e51ff83cb605bc57d317ff945404e5611
-rw-r--r-- | basctl/source/dlged/dlgedpage.cxx | 13 | ||||
-rw-r--r-- | basctl/source/inc/dlgedpage.hxx | 2 | ||||
-rw-r--r-- | include/svx/fmpage.hxx | 5 | ||||
-rw-r--r-- | include/svx/svdpage.hxx | 5 | ||||
-rw-r--r-- | reportdesign/inc/RptPage.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/core/sdr/RptPage.cxx | 13 | ||||
-rw-r--r-- | sc/inc/drawpage.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/drawpage.cxx | 23 | ||||
-rw-r--r-- | svx/source/form/fmpage.cxx | 17 | ||||
-rw-r--r-- | svx/source/svdraw/svdpage.cxx | 27 | ||||
-rw-r--r-- | sw/inc/dpage.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/draw/dpage.cxx | 54 |
12 files changed, 156 insertions, 24 deletions
diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx index 15f7f1253869..b3ed46ceffce 100644 --- a/basctl/source/dlged/dlgedpage.cxx +++ b/basctl/source/dlged/dlgedpage.cxx @@ -47,8 +47,19 @@ DlgEdPage::~DlgEdPage() SdrPage* DlgEdPage::Clone() const { + return Clone(0); +} + +SdrPage* DlgEdPage::Clone(SdrModel* const pNewModel) const +{ DlgEdPage* const pNewPage = new DlgEdPage( *this ); - pNewPage->lateInit( *this ); + DlgEdModel* pDlgEdModel = 0; + if ( pNewModel ) + { + pDlgEdModel = dynamic_cast<DlgEdModel*>( pNewModel ); + assert(pDlgEdModel); + } + pNewPage->lateInit( *this, pDlgEdModel ); return pNewPage; } diff --git a/basctl/source/inc/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx index 02752920769a..e0bb63396e31 100644 --- a/basctl/source/inc/dlgedpage.hxx +++ b/basctl/source/inc/dlgedpage.hxx @@ -45,8 +45,8 @@ public: DlgEdPage( DlgEdModel& rModel, bool bMasterPage = false ); virtual ~DlgEdPage(); - using SdrPage::Clone; virtual SdrPage* Clone() const SAL_OVERRIDE; + virtual SdrPage* Clone( SdrModel* pNewModel ) const SAL_OVERRIDE; void SetDlgEdForm( DlgEdForm* pForm ) { pDlgEdForm = pForm; } DlgEdForm* GetDlgEdForm() const { return pDlgEdForm; } diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx index a48df9ce5fda..8b90dbb06fb4 100644 --- a/include/svx/fmpage.hxx +++ b/include/svx/fmpage.hxx @@ -55,8 +55,7 @@ public: virtual void SetModel(SdrModel* pNewModel) SAL_OVERRIDE; virtual SdrPage* Clone() const SAL_OVERRIDE; - // TODO: Uh huh, how is this supposed to work? Creating a SdrPage from FmFormPage? - using SdrPage::Clone; + virtual SdrPage* Clone(SdrModel* pNewModel) const SAL_OVERRIDE; virtual void InsertObject(SdrObject* pObj, size_t nPos = SAL_MAX_SIZE, const SdrInsertReason* pReason=NULL) SAL_OVERRIDE; @@ -79,7 +78,7 @@ public: protected: FmFormPage(const FmFormPage& rPage); - void lateInit(const FmFormPage& rPage); + void lateInit(const FmFormPage& rPage, FmFormModel* pNewModel = 0); }; #endif // INCLUDED_SVX_FMPAGE_HXX diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index 87bf2f32e8bc..cbacc8c13cbf 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -486,7 +486,7 @@ protected: // classes that needs access to the page objects must be deferred to lateInit. And it must // call lateInit() of its parent class. SdrPage(const SdrPage& rSrcPage); - void lateInit(const SdrPage& rSrcPage); + void lateInit(const SdrPage& rSrcPage, SdrModel* pNewModel = 0); public: TYPEINFO_OVERRIDE(); @@ -575,6 +575,9 @@ public: bool bEdit ); void dumpAsXml(struct _xmlTextWriter* pWriter) const; + +private: + void impl_setModelForLayerAdmin(SdrModel* pNewModel); }; typedef tools::WeakReference< SdrPage > SdrPageWeakRef; diff --git a/reportdesign/inc/RptPage.hxx b/reportdesign/inc/RptPage.hxx index 9ea966aea156..e45a9064da48 100644 --- a/reportdesign/inc/RptPage.hxx +++ b/reportdesign/inc/RptPage.hxx @@ -60,7 +60,7 @@ public: virtual SdrPage* Clone() const SAL_OVERRIDE; - using SdrPage::Clone; + virtual SdrPage* Clone( SdrModel* pNewModel ) const SAL_OVERRIDE; virtual void NbcInsertObject(SdrObject* pObj, size_t nPos, const SdrInsertReason* pReason) SAL_OVERRIDE; virtual SdrObject* RemoveObject(size_t nObjNum) SAL_OVERRIDE; diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx index c55a36082264..c22864c6a1aa 100644 --- a/reportdesign/source/core/sdr/RptPage.cxx +++ b/reportdesign/source/core/sdr/RptPage.cxx @@ -61,8 +61,19 @@ OReportPage::~OReportPage() SdrPage* OReportPage::Clone() const { + return Clone(0); +} + +SdrPage* OReportPage::Clone( SdrModel* const pNewModel ) const +{ OReportPage *const pNewPage = new OReportPage( *this ); - pNewPage->lateInit( *this ); + OReportModel* pReportModel = 0; + if ( pNewModel ) + { + pReportModel = dynamic_cast<OReportModel*>( pNewModel ); + assert( pReportModel ); + } + pNewPage->lateInit( *this, pReportModel ); return pNewPage; } diff --git a/sc/inc/drawpage.hxx b/sc/inc/drawpage.hxx index 6f7b68ec7c66..9f294e36ea15 100644 --- a/sc/inc/drawpage.hxx +++ b/sc/inc/drawpage.hxx @@ -26,14 +26,19 @@ class ScDrawLayer; class ScDrawPage: public FmFormPage { - ScDrawPage(const ScDrawPage&) SAL_DELETED_FUNCTION; ScDrawPage& operator=(const ScDrawPage&) SAL_DELETED_FUNCTION; public: ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage = false); virtual ~ScDrawPage(); + virtual ScDrawPage* Clone() const SAL_OVERRIDE; + virtual ScDrawPage* Clone(SdrModel* pNewModel) const SAL_OVERRIDE; + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoPage() SAL_OVERRIDE; + +private: + ScDrawPage(const ScDrawPage& rSrcPage); }; #endif diff --git a/sc/source/core/data/drawpage.cxx b/sc/source/core/data/drawpage.cxx index 0c2eceed069e..3594c1d0c9aa 100644 --- a/sc/source/core/data/drawpage.cxx +++ b/sc/source/core/data/drawpage.cxx @@ -32,10 +32,33 @@ ScDrawPage::ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage) : SetSize( Size( LONG_MAX, LONG_MAX ) ); } +ScDrawPage::ScDrawPage(const ScDrawPage& rSrcPage) + : FmFormPage(rSrcPage) +{ +} + ScDrawPage::~ScDrawPage() { } +ScDrawPage* ScDrawPage::Clone() const +{ + return Clone(0); +} + +ScDrawPage* ScDrawPage::Clone(SdrModel* const pNewModel) const +{ + ScDrawPage* const pNewPage = new ScDrawPage(*this); + FmFormModel* pScDrawModel = 0; + if (pNewModel) + { + pScDrawModel = dynamic_cast<FmFormModel*>(pNewModel); + assert(pScDrawModel); + } + pNewPage->lateInit(*this, pScDrawModel); + return pNewPage; +} + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > ScDrawPage::createUnoPage() { return static_cast<cppu::OWeakObject*>( new ScPageObj( this ) ); 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; @@ -119,8 +119,19 @@ 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<FmFormModel*>(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 diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx index 8284f6e458e7..82078ce9c9a2 100644 --- a/sw/inc/dpage.hxx +++ b/sw/inc/dpage.hxx @@ -28,16 +28,18 @@ class SwDoc; class SwDPage : public FmFormPage, public SdrObjUserCall { - SwDPage(const SwDPage&) SAL_DELETED_FUNCTION; SwDPage &operator=(const SwDPage&) SAL_DELETED_FUNCTION; SdrPageGridFrameList* pGridLst; - SwDoc& rDoc; + SwDoc* pDoc; public: SwDPage(SwDrawModel& rNewModel, bool bMasterPage=false); virtual ~SwDPage(); + virtual SwDPage* Clone() const SAL_OVERRIDE; + virtual SwDPage* Clone(SdrModel* pNewModel) const SAL_OVERRIDE; + // #i3694# // This GetOffset() method is not needed anymore, it even leads to errors. // virtual Point GetOffset() const; @@ -49,6 +51,12 @@ public: bool RequestHelp( vcl::Window* pWindow, SdrView* pView, const HelpEvent& rEvt ); virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoPage() SAL_OVERRIDE; + +protected: + void lateInit(const SwDPage& rPage, SwDrawModel* pNewModel = 0); + +private: + SwDPage(const SwDPage& rSrcPage); }; #endif // INCLUDED_SW_INC_DPAGE_HXX diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx index 048394c4f2d3..df6f577e1a3e 100644 --- a/sw/source/core/draw/dpage.cxx +++ b/sw/source/core/draw/dpage.cxx @@ -52,15 +52,59 @@ using namespace ::com::sun::star::frame; SwDPage::SwDPage(SwDrawModel& rNewModel, bool bMasterPage) : FmFormPage(rNewModel, bMasterPage), pGridLst( 0 ), - rDoc(rNewModel.GetDoc()) + pDoc(&rNewModel.GetDoc()) { } +SwDPage::SwDPage(const SwDPage& rSrcPage) : + FmFormPage( rSrcPage ), + pGridLst( 0 ), + pDoc( 0 ) +{ + if ( rSrcPage.pGridLst ) + { + pGridLst = new SdrPageGridFrameList; + for ( sal_uInt16 i = 0; i != rSrcPage.pGridLst->GetCount(); ++i ) + pGridLst->Insert( ( *rSrcPage.pGridLst )[ i ] ); + } +} + SwDPage::~SwDPage() { delete pGridLst; } +void SwDPage::lateInit(const SwDPage& rPage, SwDrawModel* const pNewModel) +{ + FmFormPage::lateInit( rPage, pNewModel ); + + SwDrawModel* pSwDrawModel = pNewModel; + if ( !pModel ) + { + pSwDrawModel = dynamic_cast< SwDrawModel* >( GetModel() ); + assert( pSwDrawModel ); + } + pDoc = &pSwDrawModel->GetDoc(); +} + +SwDPage* SwDPage::Clone() const +{ + return Clone( 0 ); +} + +SwDPage* SwDPage::Clone(SdrModel* const pNewModel) const +{ + SwDPage* const pNewPage = new SwDPage( *this ); + SwDrawModel* pSwDrawModel = 0; + if ( pNewModel ) + { + pSwDrawModel = dynamic_cast< SwDrawModel* >( pNewModel ); + assert( pSwDrawModel ); + } + pNewPage->lateInit( *this, pSwDrawModel ); + return pNewPage; +} + SdrObject* SwDPage::ReplaceObject( SdrObject* pNewObj, size_t nObjNum ) { SdrObject *pOld = GetObj( nObjNum ); @@ -122,6 +166,8 @@ const SdrPageGridFrameList* SwDPage::GetGridFrameList( bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView, const HelpEvent& rEvt ) { + assert( pDoc ); + bool bContinue = true; if( rEvt.GetMode() & ( HelpEventMode::QUICK | HelpEventMode::BALLOON )) @@ -173,7 +219,7 @@ bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView, if ( !sTxt.isEmpty() ) { // #i80029# - bool bExecHyperlinks = rDoc.GetDocShell()->IsReadOnly(); + bool bExecHyperlinks = pDoc->GetDocShell()->IsReadOnly(); if ( !bExecHyperlinks ) { SvtSecurityOptions aSecOpts; @@ -208,8 +254,10 @@ bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView, Reference< XInterface > SwDPage::createUnoPage() { + assert( pDoc ); + Reference < XInterface > xRet; - SwDocShell* pDocShell = rDoc.GetDocShell(); + SwDocShell* pDocShell = pDoc->GetDocShell(); if ( pDocShell ) { Reference<XModel> xModel = pDocShell->GetBaseModel(); |