[Libreoffice-commits] core.git: 3 commits - basctl/source include/svx reportdesign/inc reportdesign/source sc/inc sc/source sd/inc sd/source svx/source sw/inc sw/source

David Tardon dtardon at redhat.com
Thu Dec 4 14:11:19 PST 2014


 basctl/source/dlged/dlgedpage.cxx        |   21 +++++-
 basctl/source/inc/dlgedpage.hxx          |    9 ++
 include/svx/fmpage.hxx                   |   12 ++-
 include/svx/obj3d.hxx                    |    8 ++
 include/svx/svdpage.hxx                  |   32 ++++++---
 reportdesign/inc/RptPage.hxx             |    4 -
 reportdesign/source/core/sdr/RptPage.cxx |   15 ++++
 sc/inc/drawpage.hxx                      |   10 ++
 sc/source/core/data/drawpage.cxx         |   23 ++++++
 sd/inc/sdpage.hxx                        |    6 +
 sd/source/core/sdpage2.cxx               |   28 +++++---
 svx/source/engine3d/obj3d.cxx            |   11 ++-
 svx/source/form/fmpage.cxx               |   22 +++++-
 svx/source/inc/fmpgeimp.hxx              |    2 
 svx/source/svdraw/svdpage.cxx            |  105 +++++++++++--------------------
 sw/inc/dpage.hxx                         |   15 +++-
 sw/source/core/draw/dpage.cxx            |   54 +++++++++++++++
 17 files changed, 271 insertions(+), 106 deletions(-)

New commits:
commit d242b464b1b9299c14552e7cc369f2c4810644a7
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Dec 4 22:00:10 2014 +0100

    be more explicit
    
    Change-Id: I33b639b3505d5db2ea8b708d80e68e576ec53308

diff --git a/basctl/source/inc/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx
index e0bb633..7376f26 100644
--- a/basctl/source/inc/dlgedpage.hxx
+++ b/basctl/source/inc/dlgedpage.hxx
@@ -42,7 +42,7 @@ private:
 public:
     TYPEINFO_OVERRIDE();
 
-    DlgEdPage( DlgEdModel& rModel, bool bMasterPage = false );
+    explicit DlgEdPage( DlgEdModel& rModel, bool bMasterPage = false );
     virtual ~DlgEdPage();
 
     virtual SdrPage* Clone() const SAL_OVERRIDE;
diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx
index 8b90dbb..74d3ec1 100644
--- a/include/svx/fmpage.hxx
+++ b/include/svx/fmpage.hxx
@@ -49,7 +49,7 @@ class SVX_DLLPUBLIC FmFormPage : public SdrPage
 public:
     TYPEINFO_OVERRIDE();
 
-    FmFormPage(FmFormModel& rModel, bool bMasterPage=false);
+    explicit FmFormPage(FmFormModel& rModel, bool bMasterPage=false);
     virtual ~FmFormPage();
 
     virtual void    SetModel(SdrModel* pNewModel) SAL_OVERRIDE;
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index cbacc8c..55a2740 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -490,7 +490,7 @@ protected:
 
 public:
     TYPEINFO_OVERRIDE();
-    SdrPage(SdrModel& rNewModel, bool bMasterPage=false);
+    explicit SdrPage(SdrModel& rNewModel, bool bMasterPage=false);
     virtual ~SdrPage();
     virtual SdrPage* Clone() const SAL_OVERRIDE;
     virtual SdrPage* Clone(SdrModel* pNewModel) const;
diff --git a/sc/inc/drawpage.hxx b/sc/inc/drawpage.hxx
index 9f294e3..2573434 100644
--- a/sc/inc/drawpage.hxx
+++ b/sc/inc/drawpage.hxx
@@ -29,7 +29,7 @@ class ScDrawPage: public FmFormPage
     ScDrawPage& operator=(const ScDrawPage&) SAL_DELETED_FUNCTION;
 
 public:
-    ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage = false);
+    explicit ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage = false);
     virtual ~ScDrawPage();
 
     virtual ScDrawPage* Clone() const SAL_OVERRIDE;
diff --git a/svx/source/inc/fmpgeimp.hxx b/svx/source/inc/fmpgeimp.hxx
index dfd4083..fee4a83 100644
--- a/svx/source/inc/fmpgeimp.hxx
+++ b/svx/source/inc/fmpgeimp.hxx
@@ -64,7 +64,7 @@ protected:
     void Init();
 
 public:
-    FmFormPageImpl( FmFormPage& _rPage );
+    explicit FmFormPageImpl( FmFormPage& _rPage );
     ~FmFormPageImpl();
 
     void initFrom( FmFormPageImpl& i_foreignImpl );
diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx
index 82078ce..c748816 100644
--- a/sw/inc/dpage.hxx
+++ b/sw/inc/dpage.hxx
@@ -34,7 +34,7 @@ class SwDPage : public FmFormPage, public SdrObjUserCall
     SwDoc*                  pDoc;
 
 public:
-    SwDPage(SwDrawModel& rNewModel, bool bMasterPage=false);
+    explicit SwDPage(SwDrawModel& rNewModel, bool bMasterPage=false);
     virtual ~SwDPage();
 
     virtual SwDPage* Clone() const SAL_OVERRIDE;
commit 51bacc6a065f380a26b8cc2e5c18ff0ab4162ac3
Author: David Tardon <dtardon at redhat.com>
Date:   Thu Dec 4 21:39:43 2014 +0100

    impl. Clone for all subclasses of SdrPage
    
    Change-Id: Ie370161e51ff83cb605bc57d317ff945404e5611

diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx
index 15f7f12..b3ed46c 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 0275292..e0bb633 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 a48df9c..8b90dbb 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 87bf2f3..cbacc8c 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 9ea966a..e45a906 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 c55a360..c22864c 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 6f7b68e..9f294e3 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 0c2ecee..3594c1d 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 96c3baa..5c41a76 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 da27d4a..e4238d9 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 8284f6e..82078ce 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 048394c..df6f577 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();
commit 9638e6207c7fc48712b1b238177462c00f5011e8
Author: David Tardon <dtardon at redhat.com>
Date:   Wed Dec 3 22:01:57 2014 +0100

    ooo#93212 avoid slicing during construction of SdrPage
    
    Also hide copy ctor and assignment operator of all derived classes, to
    ensure that Clone() is the only method to make copies of them.
    
    Change-Id: Icb3b50c63b086abe8c9add32e3041fe19692d20b

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


More information about the Libreoffice-commits mailing list