3b44e74
From 9638e6207c7fc48712b1b238177462c00f5011e8 Mon Sep 17 00:00:00 2001
3b44e74
From: David Tardon <dtardon@redhat.com>
3b44e74
Date: Wed, 3 Dec 2014 22:01:57 +0100
3b44e74
Subject: [PATCH] ooo#93212 avoid slicing during construction of SdrPage
3b44e74
3b44e74
Also hide copy ctor and assignment operator of all derived classes, to
3b44e74
ensure that Clone() is the only method to make copies of them.
3b44e74
3b44e74
Change-Id: Icb3b50c63b086abe8c9add32e3041fe19692d20b
3b44e74
---
3b44e74
 basctl/source/dlged/dlgedpage.cxx        | 10 +++-
3b44e74
 basctl/source/inc/dlgedpage.hxx          |  5 ++
3b44e74
 include/svx/fmpage.hxx                   |  9 +++-
3b44e74
 include/svx/obj3d.hxx                    |  8 ++-
3b44e74
 include/svx/svdpage.hxx                  | 27 +++++++---
3b44e74
 reportdesign/inc/RptPage.hxx             |  2 +
3b44e74
 reportdesign/source/core/sdr/RptPage.cxx |  4 +-
3b44e74
 sc/inc/drawpage.hxx                      |  3 ++
3b44e74
 sd/inc/sdpage.hxx                        |  6 ++-
3b44e74
 sd/source/core/sdpage2.cxx               | 28 ++++++-----
3b44e74
 svx/source/engine3d/obj3d.cxx            | 11 ++++-
3b44e74
 svx/source/form/fmpage.cxx               | 11 ++++-
3b44e74
 svx/source/svdraw/svdpage.cxx            | 84 +++++++++-----------------------
3b44e74
 sw/inc/dpage.hxx                         |  3 ++
3b44e74
 14 files changed, 122 insertions(+), 89 deletions(-)
3b44e74
3b44e74
diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx
3b44e74
index 86a792f..15f7f12 100644
3b44e74
--- a/basctl/source/dlged/dlgedpage.cxx
3b44e74
+++ b/basctl/source/dlged/dlgedpage.cxx
3b44e74
@@ -33,6 +33,12 @@ DlgEdPage::DlgEdPage(DlgEdModel& rModel, bool bMasterPage)
3b44e74
 {
3b44e74
 }
3b44e74
 
3b44e74
+DlgEdPage::DlgEdPage(const DlgEdPage& rSrcPage)
3b44e74
+    : SdrPage(rSrcPage)
3b44e74
+    , pDlgEdForm(0)
3b44e74
+{
3b44e74
+}
3b44e74
+
3b44e74
 DlgEdPage::~DlgEdPage()
3b44e74
 {
3b44e74
     Clear();
3b44e74
@@ -41,7 +47,9 @@ DlgEdPage::~DlgEdPage()
3b44e74
 
3b44e74
 SdrPage* DlgEdPage::Clone() const
3b44e74
 {
3b44e74
-    return new DlgEdPage( *this );
3b44e74
+    DlgEdPage* const pNewPage = new DlgEdPage( *this );
3b44e74
+    pNewPage->lateInit( *this );
3b44e74
+    return pNewPage;
3b44e74
 }
3b44e74
 
3b44e74
 
3b44e74
diff --git a/basctl/source/inc/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx
3b44e74
index b92760f..0275292 100644
3b44e74
--- a/basctl/source/inc/dlgedpage.hxx
3b44e74
+++ b/basctl/source/inc/dlgedpage.hxx
3b44e74
@@ -34,6 +34,8 @@ class DlgEdForm;
3b44e74
 
3b44e74
 class DlgEdPage : public SdrPage
3b44e74
 {
3b44e74
+    DlgEdPage& operator=(const DlgEdPage&) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
 private:
3b44e74
     DlgEdForm*      pDlgEdForm;
3b44e74
 
3b44e74
@@ -50,6 +52,9 @@ public:
3b44e74
     DlgEdForm*      GetDlgEdForm() const { return pDlgEdForm; }
3b44e74
 
3b44e74
     virtual SdrObject* SetObjectOrdNum(sal_uLong nOldObjNum, sal_uLong nNewObjNum) SAL_OVERRIDE;
3b44e74
+
3b44e74
+protected:
3b44e74
+    DlgEdPage(const DlgEdPage& rSrcPage);
3b44e74
 };
3b44e74
 
3b44e74
 } // namespace basctl
3b44e74
diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx
3b44e74
index e381a64..a48df9c 100644
3b44e74
--- a/include/svx/fmpage.hxx
3b44e74
+++ b/include/svx/fmpage.hxx
3b44e74
@@ -40,6 +40,8 @@ class HelpEvent;
3b44e74
 
3b44e74
 class SVX_DLLPUBLIC FmFormPage : public SdrPage
3b44e74
 {
3b44e74
+    FmFormPage& operator=(const FmFormPage&) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
     friend class FmFormObj;
3b44e74
     FmFormPageImpl*     m_pImpl;
3b44e74
     OUString            m_sPageName;
3b44e74
@@ -48,12 +50,12 @@ public:
3b44e74
     TYPEINFO_OVERRIDE();
3b44e74
 
3b44e74
     FmFormPage(FmFormModel& rModel, bool bMasterPage=false);
3b44e74
-    FmFormPage(const FmFormPage& rPage);
3b44e74
     virtual ~FmFormPage();
3b44e74
 
3b44e74
     virtual void    SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
3b44e74
 
3b44e74
     virtual SdrPage* Clone() const SAL_OVERRIDE;
3b44e74
+    // TODO: Uh huh, how is this supposed to work? Creating a SdrPage from FmFormPage?
3b44e74
     using SdrPage::Clone;
3b44e74
 
3b44e74
     virtual void    InsertObject(SdrObject* pObj, sal_uLong nPos = CONTAINER_APPEND,
3b44e74
@@ -73,6 +75,11 @@ public:
3b44e74
                             Window* pWin,
3b44e74
                             SdrView* pView,
3b44e74
                             const HelpEvent& rEvt );
3b44e74
+
3b44e74
+protected:
3b44e74
+    FmFormPage(const FmFormPage& rPage);
3b44e74
+
3b44e74
+    void lateInit(const FmFormPage& rPage);
3b44e74
 };
3b44e74
 
3b44e74
 #endif // INCLUDED_SVX_FMPAGE_HXX
3b44e74
diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx
3b44e74
index bdba2c3..f370f20 100644
3b44e74
--- a/include/svx/obj3d.hxx
3b44e74
+++ b/include/svx/obj3d.hxx
3b44e74
@@ -78,16 +78,22 @@ public:
3b44e74
 
3b44e74
 class E3dObjList : public SdrObjList
3b44e74
 {
3b44e74
+    E3dObjList &operator=(const E3dObjList& rSrcList) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
 public:
3b44e74
     TYPEINFO_OVERRIDE();
3b44e74
     E3dObjList(SdrModel* pNewModel = 0, SdrPage* pNewPage = 0, E3dObjList* pNewUpList = 0);
3b44e74
-    SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList);
3b44e74
     SVX_DLLPUBLIC virtual ~E3dObjList();
3b44e74
 
3b44e74
+    virtual E3dObjList* Clone() const;
3b44e74
+
3b44e74
     virtual void NbcInsertObject(SdrObject* pObj, sal_uIntPtr nPos=CONTAINER_APPEND, const SdrInsertReason* pReason=NULL) SAL_OVERRIDE;
3b44e74
     virtual void InsertObject(SdrObject* pObj, sal_uIntPtr nPos=CONTAINER_APPEND, const SdrInsertReason* pReason=NULL) SAL_OVERRIDE;
3b44e74
     virtual SdrObject* NbcRemoveObject(sal_uIntPtr nObjNum) SAL_OVERRIDE;
3b44e74
     virtual SdrObject* RemoveObject(sal_uIntPtr nObjNum) SAL_OVERRIDE;
3b44e74
+
3b44e74
+protected:
3b44e74
+    SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList);
3b44e74
 };
3b44e74
 
3b44e74
 /*************************************************************************
3b44e74
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
3b44e74
index c737186..87bf2f3 100644
3b44e74
--- a/include/svx/svdpage.hxx
3b44e74
+++ b/include/svx/svdpage.hxx
3b44e74
@@ -78,6 +78,9 @@ public:
3b44e74
 
3b44e74
 class SVX_DLLPUBLIC SdrObjList
3b44e74
 {
3b44e74
+    SdrObjList(const SdrObjList& rSrcList) SAL_DELETED_FUNCTION;
3b44e74
+    SdrObjList &operator=(const SdrObjList& rSrcList) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
 private:
3b44e74
     typedef ::std::vector<SdrObject*> SdrObjectContainerType;
3b44e74
     SdrObjectContainerType maList;
3b44e74
@@ -97,20 +100,23 @@ friend class SdrEditView;
3b44e74
 protected:
3b44e74
     virtual void RecalcRects();
3b44e74
 
3b44e74
+    SdrObjList();
3b44e74
+    void lateInit(const SdrObjList& rSrcList);
3b44e74
+
3b44e74
 private:
3b44e74
     /// simple ActionChildInserted forwarder to have it on a central place
3b44e74
     void impChildInserted(SdrObject& rChild) const;
3b44e74
 public:
3b44e74
     TYPEINFO();
3b44e74
     SdrObjList(SdrModel* pNewModel, SdrPage* pNewPage, SdrObjList* pNewUpList=NULL);
3b44e74
-    SdrObjList(const SdrObjList& rSrcList);
3b44e74
     virtual ~SdrObjList();
3b44e74
+
3b44e74
+    virtual SdrObjList* Clone() const;
3b44e74
+
3b44e74
     // !!! Diese Methode nur fuer Leute, die ganz genau wissen was sie tun !!!
3b44e74
 
3b44e74
     // #110094# This should not be needed (!)
3b44e74
     void SetObjOrdNumsDirty()                           { bObjOrdNumsDirty=true; }
3b44e74
-    // pModel, pPage, pUpList und pOwnerObj werden Zuweisungeoperator nicht veraendert!
3b44e74
-    void operator=(const SdrObjList& rSrcList);
3b44e74
     void CopyObjects(const SdrObjList& rSrcList);
3b44e74
     // alles Aufraeumen (ohne Undo)
3b44e74
     void    Clear();
3b44e74
@@ -403,6 +409,7 @@ public:
3b44e74
 
3b44e74
 class SVX_DLLPUBLIC SdrPage : public SdrObjList, public tools::WeakBase< SdrPage >
3b44e74
 {
3b44e74
+    SdrPage& operator=(const SdrPage& rSrcPage) SAL_DELETED_FUNCTION;
3b44e74
 
3b44e74
     // start PageUser section
3b44e74
 private:
3b44e74
@@ -473,15 +480,19 @@ protected:
3b44e74
                         ::com::sun::star::drawing::XDrawPage> const&);
3b44e74
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createUnoPage();
3b44e74
 
3b44e74
+    // Copying of pages is split into two parts: construction and copying of page objects,
3b44e74
+    // because the copying might need access to fully initialized page. Clone() is responsible
3b44e74
+    // to call lateInit() after copy-construction of a new object. Any initialization in derived
3b44e74
+    // classes that needs access to the page objects must be deferred to lateInit. And it must
3b44e74
+    // call lateInit() of its parent class.
3b44e74
+    SdrPage(const SdrPage& rSrcPage);
3b44e74
+    void lateInit(const SdrPage& rSrcPage);
3b44e74
+
3b44e74
 public:
3b44e74
     TYPEINFO_OVERRIDE();
3b44e74
     SdrPage(SdrModel& rNewModel, bool bMasterPage=false);
3b44e74
-    // Copy-Ctor und Zuweisungeoperator sind nicht getestet!
3b44e74
-    SdrPage(const SdrPage& rSrcPage);
3b44e74
     virtual ~SdrPage();
3b44e74
-    // pModel, pPage, pUpList, pOwnerObj und mbInserted werden Zuweisungeoperator nicht veraendert!
3b44e74
-    SdrPage& operator=(const SdrPage& rSrcPage);
3b44e74
-    virtual SdrPage* Clone() const;
3b44e74
+    virtual SdrPage* Clone() const SAL_OVERRIDE;
3b44e74
     virtual SdrPage* Clone(SdrModel* pNewModel) const;
3b44e74
     bool IsMasterPage() const       { return mbMaster; }
3b44e74
     void SetInserted(bool bNew = true);
3b44e74
diff --git a/reportdesign/inc/RptPage.hxx b/reportdesign/inc/RptPage.hxx
3b44e74
index b320a3e..9ea966a 100644
3b44e74
--- a/reportdesign/inc/RptPage.hxx
3b44e74
+++ b/reportdesign/inc/RptPage.hxx
3b44e74
@@ -34,6 +34,8 @@ class OReportModel;
3b44e74
 
3b44e74
 class REPORTDESIGN_DLLPUBLIC OReportPage : public SdrPage
3b44e74
 {
3b44e74
+    OReportPage& operator=(const OReportPage&) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
     OReportModel&           rModel;
3b44e74
     ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection > m_xSection;
3b44e74
     bool                    m_bSpecialInsertMode;
3b44e74
diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx
3b44e74
index 5009a66..c55a360 100644
3b44e74
--- a/reportdesign/source/core/sdr/RptPage.cxx
3b44e74
+++ b/reportdesign/source/core/sdr/RptPage.cxx
3b44e74
@@ -61,7 +61,9 @@ OReportPage::~OReportPage()
3b44e74
 
3b44e74
 SdrPage* OReportPage::Clone() const
3b44e74
 {
3b44e74
-    return new OReportPage( *this );
3b44e74
+    OReportPage *const pNewPage = new OReportPage( *this );
3b44e74
+    pNewPage->lateInit( *this );
3b44e74
+    return pNewPage;
3b44e74
 }
3b44e74
 
3b44e74
 
3b44e74
diff --git a/sc/inc/drawpage.hxx b/sc/inc/drawpage.hxx
3b44e74
index c11d4cc..6f7b68e 100644
3b44e74
--- a/sc/inc/drawpage.hxx
3b44e74
+++ b/sc/inc/drawpage.hxx
3b44e74
@@ -26,6 +26,9 @@ class ScDrawLayer;
3b44e74
 
3b44e74
 class ScDrawPage: public FmFormPage
3b44e74
 {
3b44e74
+    ScDrawPage(const ScDrawPage&) SAL_DELETED_FUNCTION;
3b44e74
+    ScDrawPage& operator=(const ScDrawPage&) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
 public:
3b44e74
     ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage = false);
3b44e74
     virtual ~ScDrawPage();
3b44e74
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
3b44e74
index 767cf39..13ec1c2 100644
3b44e74
--- a/sd/inc/sdpage.hxx
3b44e74
+++ b/sd/inc/sdpage.hxx
3b44e74
@@ -98,6 +98,8 @@ namespace sd {
3b44e74
 
3b44e74
 class SD_DLLPUBLIC SdPage : public FmFormPage, public SdrObjUserCall
3b44e74
 {
3b44e74
+    SdPage& operator=(const SdPage&) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
 friend class SdGenericDrawPage;
3b44e74
 friend class SdDrawPage;
3b44e74
 friend class sd::UndoAnimation;
3b44e74
@@ -153,11 +155,13 @@ protected:
3b44e74
     sal_Int32 mnTransitionFadeColor;
3b44e74
     double mfTransitionDuration;
3b44e74
 
3b44e74
+    SdPage(const SdPage& rSrcPage);
3b44e74
+    void lateInit(const SdPage& rSrcPage);
3b44e74
+
3b44e74
 public:
3b44e74
     TYPEINFO_OVERRIDE();
3b44e74
 
3b44e74
     SdPage(SdDrawDocument& rNewDoc, bool bMasterPage=false);
3b44e74
-    SdPage(const SdPage& rSrcPage);
3b44e74
     virtual ~SdPage();
3b44e74
     virtual SdrPage* Clone() const SAL_OVERRIDE;
3b44e74
     virtual SdrPage* Clone(SdrModel* pNewModel) const SAL_OVERRIDE;
3b44e74
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
3b44e74
index 450c646..57f4699 100644
3b44e74
--- a/sd/source/core/sdpage2.cxx
3b44e74
+++ b/sd/source/core/sdpage2.cxx
3b44e74
@@ -377,15 +377,6 @@ SdPage::SdPage(const SdPage& rSrcPage)
3b44e74
     mePageKind           = rSrcPage.mePageKind;
3b44e74
     meAutoLayout         = rSrcPage.meAutoLayout;
3b44e74
 
3b44e74
-    // use shape list directly to preserve constness of rSrcPage
3b44e74
-    const std::list< SdrObject* >& rShapeList = rSrcPage.maPresentationShapeList.getList();
3b44e74
-    for( std::list< SdrObject* >::const_iterator aIter = rShapeList.begin();
3b44e74
-         aIter != rShapeList.end(); ++aIter )
3b44e74
-    {
3b44e74
-        SdrObject* pObj = *aIter;
3b44e74
-        InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj));
3b44e74
-    }
3b44e74
-
3b44e74
     mbSelected           = false;
3b44e74
     mnTransitionType    = rSrcPage.mnTransitionType;
3b44e74
     mnTransitionSubtype = rSrcPage.mnTransitionSubtype;
3b44e74
@@ -410,10 +401,24 @@ SdPage::SdPage(const SdPage& rSrcPage)
3b44e74
     mnPaperBin           = rSrcPage.mnPaperBin;
3b44e74
     meOrientation        = rSrcPage.meOrientation;
3b44e74
 
3b44e74
+    mpPageLink           = NULL;    // is set when inserting via ConnectLink()
3b44e74
+}
3b44e74
+
3b44e74
+void SdPage::lateInit(const SdPage& rSrcPage)
3b44e74
+{
3b44e74
+    FmFormPage::lateInit(rSrcPage);
3b44e74
+
3b44e74
+    // use shape list directly to preserve constness of rSrcPage
3b44e74
+    const std::list< SdrObject* >& rShapeList = rSrcPage.maPresentationShapeList.getList();
3b44e74
+    for( std::list< SdrObject* >::const_iterator aIter = rShapeList.begin();
3b44e74
+         aIter != rShapeList.end(); ++aIter )
3b44e74
+    {
3b44e74
+        SdrObject* pObj = *aIter;
3b44e74
+        InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj));
3b44e74
+    }
3b44e74
+
3b44e74
     // header footer
3b44e74
     setHeaderFooterSettings( rSrcPage.getHeaderFooterSettings() );
3b44e74
-
3b44e74
-    mpPageLink           = NULL;    // is set when inserting via ConnectLink()
3b44e74
 }
3b44e74
 
3b44e74
 
3b44e74
@@ -433,6 +438,7 @@ SdrPage* SdPage::Clone(SdrModel* pNewModel) const
3b44e74
     (void)pNewModel;
3b44e74
 
3b44e74
     SdPage* pNewPage = new SdPage(*this);
3b44e74
+    pNewPage->lateInit( *this );
3b44e74
 
3b44e74
     cloneAnimations( *pNewPage );
3b44e74
 
3b44e74
diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx
3b44e74
index eee59ad..ef50b3d 100644
3b44e74
--- a/svx/source/engine3d/obj3d.cxx
3b44e74
+++ b/svx/source/engine3d/obj3d.cxx
3b44e74
@@ -91,11 +91,18 @@ E3dObjList::E3dObjList(SdrModel* pNewModel, SdrPage* pNewPage, E3dObjList* pNewU
3b44e74
 {
3b44e74
 }
3b44e74
 
3b44e74
-E3dObjList::E3dObjList(const E3dObjList& rSrcList)
3b44e74
-:   SdrObjList(rSrcList)
3b44e74
+E3dObjList::E3dObjList(const E3dObjList&)
3b44e74
+:   SdrObjList()
3b44e74
 {
3b44e74
 }
3b44e74
 
3b44e74
+E3dObjList* E3dObjList::Clone() const
3b44e74
+{
3b44e74
+    E3dObjList* const pObjList = new E3dObjList(*this);
3b44e74
+    pObjList->lateInit(*this);
3b44e74
+    return pObjList;
3b44e74
+}
3b44e74
+
3b44e74
 E3dObjList::~E3dObjList()
3b44e74
 {
3b44e74
 }
3b44e74
diff --git a/svx/source/form/fmpage.cxx b/svx/source/form/fmpage.cxx
3b44e74
index 365dfd3..96c3baa 100644
3b44e74
--- a/svx/source/form/fmpage.cxx
3b44e74
+++ b/svx/source/form/fmpage.cxx
3b44e74
@@ -66,6 +66,12 @@ FmFormPage::FmFormPage(const FmFormPage& rPage)
3b44e74
            :SdrPage(rPage)
3b44e74
            ,m_pImpl(new FmFormPageImpl( *this ) )
3b44e74
 {
3b44e74
+}
3b44e74
+
3b44e74
+void FmFormPage::lateInit(const FmFormPage& rPage)
3b44e74
+{
3b44e74
+    SdrPage::lateInit( rPage );
3b44e74
+
3b44e74
     m_pImpl->initFrom( rPage.GetImpl() );
3b44e74
     m_sPageName = rPage.m_sPageName;
3b44e74
 }
3b44e74
@@ -113,8 +119,9 @@ void FmFormPage::SetModel(SdrModel* pNewModel)
3b44e74
 
3b44e74
 SdrPage* FmFormPage::Clone() const
3b44e74
 {
3b44e74
-    return new FmFormPage(*this);
3b44e74
-    // hier fehlt noch ein kopieren der Objekte
3b44e74
+    FmFormPage* const pNewPage = new FmFormPage(*this);
3b44e74
+    pNewPage->lateInit(*this);
3b44e74
+    return pNewPage;
3b44e74
 }
3b44e74
 
3b44e74
 
3b44e74
diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx
3b44e74
index 94139448..da27d4a 100644
3b44e74
--- a/svx/source/svdraw/svdpage.cxx
3b44e74
+++ b/svx/source/svdraw/svdpage.cxx
3b44e74
@@ -88,7 +88,7 @@ SdrObjList::SdrObjList(SdrModel* pNewModel, SdrPage* pNewPage, SdrObjList* pNewU
3b44e74
     eListKind=SDROBJLIST_UNKNOWN;
3b44e74
 }
3b44e74
 
3b44e74
-SdrObjList::SdrObjList(const SdrObjList& rSrcList):
3b44e74
+SdrObjList::SdrObjList():
3b44e74
     maList(),
3b44e74
     mpNavigationOrder(),
3b44e74
     mbIsNavigationOrderDirty(false)
3b44e74
@@ -101,7 +101,6 @@ SdrObjList::SdrObjList(const SdrObjList& rSrcList):
3b44e74
     bRectsDirty=false;
3b44e74
     pOwnerObj=NULL;
3b44e74
     eListKind=SDROBJLIST_UNKNOWN;
3b44e74
-    *this=rSrcList;
3b44e74
 }
3b44e74
 
3b44e74
 SdrObjList::~SdrObjList()
3b44e74
@@ -115,9 +114,18 @@ SdrObjList::~SdrObjList()
3b44e74
     Clear(); // delete contents of container
3b44e74
 }
3b44e74
 
3b44e74
-void SdrObjList::operator=(const SdrObjList& rSrcList)
3b44e74
+SdrObjList* SdrObjList::Clone() const
3b44e74
 {
3b44e74
-    Clear();
3b44e74
+    SdrObjList* const pObjList = new SdrObjList();
3b44e74
+    pObjList->lateInit(*this);
3b44e74
+    return pObjList;
3b44e74
+}
3b44e74
+
3b44e74
+void SdrObjList::lateInit(const SdrObjList& rSrcList)
3b44e74
+{
3b44e74
+    // this function is only supposed to be called once, right after construction
3b44e74
+    assert(maList.empty());
3b44e74
+
3b44e74
     eListKind=rSrcList.eListKind;
3b44e74
     CopyObjects(rSrcList);
3b44e74
 }
3b44e74
@@ -1246,31 +1254,6 @@ SdrPage::SdrPage(const SdrPage& rSrcPage)
3b44e74
     mbPageBorderOnlyLeftRight(rSrcPage.mbPageBorderOnlyLeftRight)
3b44e74
 {
3b44e74
     aPrefVisiLayers.SetAll();
3b44e74
-    eListKind = (mbMaster) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
3b44e74
-
3b44e74
-    // copy things from source
3b44e74
-    // Warning: this leads to slicing (see issue 93186) and has to be
3b44e74
-    // removed as soon as possible.
3b44e74
-    *this = rSrcPage;
3b44e74
-    OSL_ENSURE(mpSdrPageProperties,
3b44e74
-        "SdrPage::SdrPage: operator= did not create needed SdrPageProperties (!)");
3b44e74
-
3b44e74
-    // be careful and correct eListKind, a member of SdrObjList which
3b44e74
-    // will be changed by the SdrOIbjList::operator= before...
3b44e74
-    eListKind = (mbMaster) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
3b44e74
-
3b44e74
-    // The previous assignment to *this may have resulted in a call to
3b44e74
-    // createUnoPage at a partially initialized (sliced) SdrPage object.
3b44e74
-    // Due to the vtable being not yet fully set-up at this stage,
3b44e74
-    // createUnoPage() may have been called at the wrong class.
3b44e74
-    // To force a call to the right createUnoPage() at a later time when the
3b44e74
-    // new object is full constructed mxUnoPage is disposed now.
3b44e74
-    uno::Reference<lang::XComponent> xComponent (mxUnoPage, uno::UNO_QUERY);
3b44e74
-    if (xComponent.is())
3b44e74
-    {
3b44e74
-        mxUnoPage = NULL;
3b44e74
-        xComponent->dispose();
3b44e74
-    }
3b44e74
 }
3b44e74
 
3b44e74
 SdrPage::~SdrPage()
3b44e74
@@ -1319,20 +1302,10 @@ SdrPage::~SdrPage()
3b44e74
 
3b44e74
 }
3b44e74
 
3b44e74
-SdrPage& SdrPage::operator=(const SdrPage& rSrcPage)
3b44e74
+void SdrPage::lateInit(const SdrPage& rSrcPage)
3b44e74
 {
3b44e74
-    if( this == &rSrcPage )
3b44e74
-        return *this;
3b44e74
-    if(mpViewContact)
3b44e74
-    {
3b44e74
-        delete mpViewContact;
3b44e74
-        mpViewContact = 0L;
3b44e74
-    }
3b44e74
-
3b44e74
-    // Joe also sets some parameters for the class this one
3b44e74
-    // is derived from. SdrObjList does the same bad handling of
3b44e74
-    // copy constructor and operator=, so i better let it stand here.
3b44e74
-    pPage = this;
3b44e74
+    assert(!mpViewContact);
3b44e74
+    assert(!mpSdrPageProperties);
3b44e74
 
3b44e74
     // copy all the local parameters to make this instance
3b44e74
     // a valid copy of source page before copying and inserting
3b44e74
@@ -1361,21 +1334,7 @@ SdrPage& SdrPage::operator=(const SdrPage& rSrcPage)
3b44e74
     mbObjectsNotPersistent = rSrcPage.mbObjectsNotPersistent;
3b44e74
 
3b44e74
     {
3b44e74
-        // #i111122# delete SdrPageProperties when model is different
3b44e74
-        if(mpSdrPageProperties && GetModel() != rSrcPage.GetModel())
3b44e74
-        {
3b44e74
-            delete mpSdrPageProperties;
3b44e74
-            mpSdrPageProperties = 0;
3b44e74
-        }
3b44e74
-
3b44e74
-        if(!mpSdrPageProperties)
3b44e74
-        {
3b44e74
-            mpSdrPageProperties = new SdrPageProperties(*this);
3b44e74
-        }
3b44e74
-        else
3b44e74
-        {
3b44e74
-            mpSdrPageProperties->ClearItem(0);
3b44e74
-        }
3b44e74
+        mpSdrPageProperties = new SdrPageProperties(*this);
3b44e74
 
3b44e74
         if(!IsMasterPage())
3b44e74
         {
3b44e74
@@ -1385,9 +1344,12 @@ SdrPage& SdrPage::operator=(const SdrPage& rSrcPage)
3b44e74
         mpSdrPageProperties->SetStyleSheet(rSrcPage.getSdrPageProperties().GetStyleSheet());
3b44e74
     }
3b44e74
 
3b44e74
-    // Now copy the contained objects (by cloning them)
3b44e74
-    SdrObjList::operator=(rSrcPage);
3b44e74
-    return *this;
3b44e74
+    // Now copy the contained objects
3b44e74
+    SdrObjList::lateInit(rSrcPage);
3b44e74
+
3b44e74
+    // be careful and correct eListKind, a member of SdrObjList which
3b44e74
+    // will be changed by the SdrObjList::lateInit before...
3b44e74
+    eListKind = (mbMaster) ? SDROBJLIST_MASTERPAGE : SDROBJLIST_DRAWPAGE;
3b44e74
 }
3b44e74
 
3b44e74
 SdrPage* SdrPage::Clone() const
3b44e74
@@ -1399,7 +1361,7 @@ SdrPage* SdrPage::Clone(SdrModel* pNewModel) const
3b44e74
 {
3b44e74
     if (pNewModel==NULL) pNewModel=pModel;
3b44e74
     SdrPage* pPage2=new SdrPage(*pNewModel);
3b44e74
-    *pPage2=*this;
3b44e74
+    pPage2->lateInit(*this);
3b44e74
     return pPage2;
3b44e74
 }
3b44e74
 
3b44e74
diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx
3b44e74
index 54aa789..8284f6e 100644
3b44e74
--- a/sw/inc/dpage.hxx
3b44e74
+++ b/sw/inc/dpage.hxx
3b44e74
@@ -28,6 +28,9 @@ class SwDoc;
3b44e74
 
3b44e74
 class SwDPage : public FmFormPage, public SdrObjUserCall
3b44e74
 {
3b44e74
+    SwDPage(const SwDPage&) SAL_DELETED_FUNCTION;
3b44e74
+    SwDPage &operator=(const SwDPage&) SAL_DELETED_FUNCTION;
3b44e74
+
3b44e74
     SdrPageGridFrameList*   pGridLst;
3b44e74
     SwDoc&                  rDoc;
3b44e74
 
3b44e74
-- 
3b44e74
2.1.0
3b44e74