[Libreoffice-commits] core.git: Branch 'feature/SOSAW080' - basctl/source filter/source include/svx reportdesign/inc reportdesign/source sc/inc sc/qa sc/source sd/inc sd/source svx/inc svx/source sw/inc sw/source

Armin Le Grand (CIB) Armin.Le.Grand at cib.de
Sat Mar 10 14:40:28 UTC 2018


 basctl/source/dlged/dlgedpage.cxx                 |   27 +-
 basctl/source/inc/dlgedpage.hxx                   |    3 
 filter/source/svg/svgexport.cxx                   |   12 -
 include/svx/connctrl.hxx                          |    4 
 include/svx/fmpage.hxx                            |    5 
 include/svx/obj3d.hxx                             |    8 
 include/svx/sdr/properties/properties.hxx         |    2 
 include/svx/svdobj.hxx                            |    3 
 include/svx/svdogrp.hxx                           |   13 -
 include/svx/svdpage.hxx                           |   60 ++---
 reportdesign/inc/RptPage.hxx                      |    4 
 reportdesign/source/core/sdr/ReportDrawPage.cxx   |    2 
 reportdesign/source/core/sdr/RptPage.cxx          |   36 +--
 sc/inc/drawpage.hxx                               |    3 
 sc/qa/unit/ucalc.cxx                              |   14 -
 sc/qa/unit/ucalc_sort.cxx                         |    2 
 sc/source/core/data/drawpage.cxx                  |   25 +-
 sc/source/filter/excel/xichart.cxx                |    2 
 sd/inc/sdpage.hxx                                 |    5 
 sd/source/core/annotations/Annotation.cxx         |    4 
 sd/source/core/pglink.cxx                         |    2 
 sd/source/core/sdpage.cxx                         |  139 +++++------
 sd/source/core/sdpage2.cxx                        |  166 ++++++--------
 sd/source/core/undo/undoobjects.cxx               |    9 
 sd/source/filter/grf/sdgrffilter.cxx              |    2 
 sd/source/ui/func/fuconrec.cxx                    |    6 
 sd/source/ui/func/fuconstr.cxx                    |   12 -
 sd/source/ui/sidebar/DocumentHelper.cxx           |   96 +++-----
 sd/source/ui/tools/PreviewRenderer.cxx            |   14 -
 sd/source/ui/unoidl/unopage.cxx                   |  248 ++++++++++-----------
 svx/inc/sdr/properties/attributeproperties.hxx    |    2 
 svx/inc/sdr/properties/e3dsceneproperties.hxx     |    2 
 svx/inc/sdr/properties/groupproperties.hxx        |    2 
 svx/source/dialog/connctrl.cxx                    |   26 +-
 svx/source/engine3d/obj3d.cxx                     |   23 -
 svx/source/form/fmdpage.cxx                       |    2 
 svx/source/form/fmpage.cxx                        |   41 +--
 svx/source/form/fmpgeimp.cxx                      |   52 ++--
 svx/source/form/fmshimp.cxx                       |   11 
 svx/source/sdr/primitive2d/sdrtextprimitive2d.cxx |    4 
 svx/source/sdr/properties/attributeproperties.cxx |  119 +++++-----
 svx/source/sdr/properties/e3dsceneproperties.cxx  |   49 ++--
 svx/source/sdr/properties/groupproperties.cxx     |   49 ++--
 svx/source/sdr/properties/properties.cxx          |   11 
 svx/source/svdraw/svdedtv2.cxx                    |   10 
 svx/source/svdraw/svdetc.cxx                      |    6 
 svx/source/svdraw/svdobj.cxx                      |   17 -
 svx/source/svdraw/svdograf.cxx                    |    2 
 svx/source/svdraw/svdogrp.cxx                     |  148 +++++-------
 svx/source/svdraw/svdoole2.cxx                    |    2 
 svx/source/svdraw/svdpage.cxx                     |  255 +++++++++-------------
 svx/source/svdraw/svdundo.cxx                     |    8 
 svx/source/svdraw/svdviter.cxx                    |    2 
 svx/source/table/tablecontroller.cxx              |    2 
 svx/source/unodraw/UnoGraphicExporter.cxx         |    2 
 svx/source/unodraw/unopage.cxx                    |   60 ++---
 svx/source/unogallery/unogaltheme.cxx             |    2 
 sw/inc/dpage.hxx                                  |    5 
 sw/source/core/draw/dpage.cxx                     |   54 ++--
 sw/source/filter/ww8/wrtww8gr.cxx                 |    1 
 60 files changed, 898 insertions(+), 999 deletions(-)

New commits:
commit 0f65eaea0957cfa7aaf6d840391a98da63d7cba6
Author: Armin Le Grand <Armin.Le.Grand at cib.de (CIB)>
Date:   Sat Mar 10 15:38:30 2018 +0100

    SOSAW080: Adapted SdrPage/SdrModel relationship
    
    Also needed to work on copy-construction of SdrPage and hierarchy,
    quite some stuff removed, no copy-constructor anymore, no
    MigrateItemPool stuff. Builds well, test stuck, will need
    some cleanup/finetunung
    
    Change-Id: I763f39094b6a48b529a6952d01468f8776c97679

diff --git a/basctl/source/dlged/dlgedpage.cxx b/basctl/source/dlged/dlgedpage.cxx
index 1c86b93ca618..2804fd3d57ee 100644
--- a/basctl/source/dlged/dlgedpage.cxx
+++ b/basctl/source/dlged/dlgedpage.cxx
@@ -32,11 +32,12 @@ DlgEdPage::DlgEdPage(DlgEdModel& rModel, bool bMasterPage)
 {
 }
 
-DlgEdPage::DlgEdPage(const DlgEdPage& rSrcPage)
-:   SdrPage(rSrcPage)
-    ,pDlgEdForm(nullptr)
-{
-}
+// TTTT
+// DlgEdPage::DlgEdPage(const DlgEdPage& rSrcPage)
+// :   SdrPage(rSrcPage)
+//     ,pDlgEdForm(nullptr)
+// {
+// }
 
 DlgEdPage::~DlgEdPage()
 {
@@ -51,15 +52,13 @@ DlgEdPage::~DlgEdPage()
 
 SdrPage* DlgEdPage::Clone(SdrModel* const pNewModel) const
 {
-    DlgEdPage* const pNewPage = new DlgEdPage( *this );
-    DlgEdModel* pDlgEdModel = nullptr;
-    if ( pNewModel )
-    {
-        pDlgEdModel = dynamic_cast<DlgEdModel*>( pNewModel );
-        assert(pDlgEdModel);
-    }
-    pNewPage->lateInit( *this, pDlgEdModel );
-    return pNewPage;
+    DlgEdModel& rDlgEdModel(static_cast< DlgEdModel& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+    DlgEdPage* pClonedDlgEdPage(
+        new DlgEdPage(
+            rDlgEdModel,
+            IsMasterPage()));
+    pClonedDlgEdPage->SdrPage::lateInit(*this);
+    return pClonedDlgEdPage;
 }
 
 
diff --git a/basctl/source/inc/dlgedpage.hxx b/basctl/source/inc/dlgedpage.hxx
index 618b1e502aea..ab28c2d5d850 100644
--- a/basctl/source/inc/dlgedpage.hxx
+++ b/basctl/source/inc/dlgedpage.hxx
@@ -35,6 +35,7 @@ class DlgEdForm;
 class DlgEdPage final : public SdrPage
 {
     DlgEdPage& operator=(const DlgEdPage&) = delete;
+    DlgEdPage(const DlgEdPage&) = delete;
 
     DlgEdForm*      pDlgEdForm;
 
@@ -53,7 +54,7 @@ public:
     virtual SdrObject* SetObjectOrdNum(size_t nOldObjNum, size_t nNewObjNum) override;
 
 private:
-    DlgEdPage(const DlgEdPage& rSrcPage);
+    // TTTT DlgEdPage(const DlgEdPage& rSrcPage);
 };
 
 } // namespace basctl
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index 6860ef7c655b..ba500b7af919 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -561,9 +561,9 @@ bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
                         if( pSvxDrawPage )
                         {
                             mpDefaultSdrPage = pSvxDrawPage->GetSdrPage();
-                            mpSdrModel = mpDefaultSdrPage->GetModel();
+                            mpSdrModel = &mpDefaultSdrPage->getSdrModelFromSdrPage();
 
-                            if( mpSdrModel )
+                            if( mpSdrModel ) // TTTT shbe ref
                             {
                                 SdrOutliner& rOutl = mpSdrModel->GetDrawOutliner();
 
@@ -925,8 +925,8 @@ void SVGFilter::implGenerateMetaData()
         if( pSvxDrawPage )
         {
             SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage();
-            SdrModel* pSdrModel = pSdrPage->GetModel();
-            nPageNumberingType = pSdrModel->GetPageNumType();
+            SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage());
+            nPageNumberingType = rSdrModel.GetPageNumType();
 
             // That is used by CalcFieldHdl method.
             mVisiblePagePropSet.nPageNumberingType = nPageNumberingType;
@@ -1390,8 +1390,8 @@ void SVGFilter::implGetPagePropSet( const Reference< css::drawing::XDrawPage > &
                 if( pSvxDrawPage )
                 {
                     SdrPage* pSdrPage = pSvxDrawPage->GetSdrPage();
-                    SdrModel* pSdrModel = pSdrPage->GetModel();
-                    mVisiblePagePropSet.nPageNumberingType = pSdrModel->GetPageNumType();
+                    SdrModel& rSdrModel(pSdrPage->getSdrModelFromSdrPage());
+                    mVisiblePagePropSet.nPageNumberingType = rSdrModel.GetPageNumType();
                 }
             }
         }
diff --git a/include/svx/connctrl.hxx b/include/svx/connctrl.hxx
index 360ff38522da..106140dfa374 100644
--- a/include/svx/connctrl.hxx
+++ b/include/svx/connctrl.hxx
@@ -32,7 +32,7 @@ namespace vcl { class Window; }
 class SfxItemSet;
 class SdrEdgeObj;
 class SdrView;
-class SdrObjList;
+class SdrPage;
 
 /*************************************************************************
 |*
@@ -45,7 +45,7 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXConnectionPreview : public Control
 
 private:
     SdrEdgeObj*         pEdgeObj;
-    SdrObjList*         pObjList;
+    SdrPage*            pSdrPage;
     const SdrView*      pView;
 
     SVX_DLLPRIVATE void SetStyles();
diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx
index d7244844cf01..791db1a9a517 100644
--- a/include/svx/fmpage.hxx
+++ b/include/svx/fmpage.hxx
@@ -42,6 +42,7 @@ class HelpEvent;
 class SVX_DLLPUBLIC FmFormPage : public SdrPage
 {
     FmFormPage& operator=(const FmFormPage&) = delete;
+    FmFormPage(const FmFormPage&) = delete;
 
     friend class FmFormObj;
     std::unique_ptr<FmFormPageImpl>     m_pImpl;
@@ -77,9 +78,9 @@ public:
                             const HelpEvent& rEvt );
 
 protected:
-    FmFormPage(const FmFormPage& rPage);
+    // TTTT FmFormPage(const FmFormPage& rPage);
 
-    void lateInit(const FmFormPage& rPage, FmFormModel* pNewModel = nullptr);
+    void lateInit(const FmFormPage& rPage);
 };
 
 #endif // INCLUDED_SVX_FMPAGE_HXX
diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx
index 67a9df90d065..192df6d151cf 100644
--- a/include/svx/obj3d.hxx
+++ b/include/svx/obj3d.hxx
@@ -78,10 +78,10 @@ public:
 class E3dObjList final : public SdrObjList
 {
 public:
-    E3dObjList(SdrModel& rSdrModel);
+    E3dObjList();
     SVX_DLLPUBLIC virtual ~E3dObjList() override;
 
-    virtual E3dObjList* Clone() const override;
+    virtual E3dObjList* CloneSdrObjList(SdrModel* pNewModel = nullptr) const override;
 
     virtual void NbcInsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
     virtual void InsertObject(SdrObject* pObj, size_t nPos=SAL_MAX_SIZE) override;
@@ -90,8 +90,8 @@ public:
 
 private:
     E3dObjList &operator=(const E3dObjList& rSrcList) = delete;
-
-    SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList);
+    E3dObjList(const E3dObjList& rSrcList) = delete;
+// TTTT    SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList);
 };
 
 /*************************************************************************
diff --git a/include/svx/sdr/properties/properties.hxx b/include/svx/sdr/properties/properties.hxx
index ef6cccb3103d..992d9ecb4c6f 100644
--- a/include/svx/sdr/properties/properties.hxx
+++ b/include/svx/sdr/properties/properties.hxx
@@ -147,7 +147,7 @@ namespace sdr
 
             // Move local items to a new ItemPool.
             // Override this to do it for hierarchical objects like e.g. groups.
-            virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel);
+            // TTTT virtual void MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel);
 
             // Set new model.
             virtual void SetModel(SdrModel* pOldModel, SdrModel* pNewModel);
diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx
index c9729fbb73a2..6b1f78c0a910 100644
--- a/include/svx/svdobj.hxx
+++ b/include/svx/svdobj.hxx
@@ -789,7 +789,8 @@ public:
     void DeleteUserData(sal_uInt16 nNum);
 
     // switch ItemPool for this object
-    void MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel);
+    // TTTT will no longer ber needed
+    // void MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel);
 
     // access to the UNO representation of the shape
     virtual css::uno::Reference< css::uno::XInterface > getUnoShape();
diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx
index 5206e5b05f4d..7f0fb234f972 100644
--- a/include/svx/svdogrp.hxx
+++ b/include/svx/svdogrp.hxx
@@ -23,27 +23,20 @@
 #include <memory>
 #include <svx/svdobj.hxx>
 #include <svx/svxdllapi.h>
-
+#include <svx/svdpage.hxx>
 
 // Forward declarations
-
-
-class SdrObjList;
-class SdrObjListIter;
 class SfxItemSet;
 
-
 //   SdrObjGroup
-
-
 class SVX_DLLPUBLIC SdrObjGroup final : public SdrObject
 {
 private:
     virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override;
     virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override;
 
-    std::unique_ptr<SdrObjList> pSub;    // sub list (children)
-    Point                       aRefPoint; // Reference point inside the object group
+    SdrObjList                  maSdrObjList;   // sub list (children)
+    Point                       aRefPoint;      // Reference point inside the object group
 
 public:
     SdrObjGroup(SdrModel& rSdrModel);
diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx
index 41b9363839a9..de9ece6ee18f 100644
--- a/include/svx/svdpage.hxx
+++ b/include/svx/svdpage.hxx
@@ -57,32 +57,22 @@ class SvxUnoDrawPagesAccess;
 //
 //  SdrObjList
 //      E3dObjList
-//      SdrPage
-//          DlgEdPage
-//          FmFormPage
-//              ScDrawPage
-//              SdPage
-//              SwDPage
-//          OReportPage
+//      SdrPage -> see continuation there
 
 // class SdrObjList
 class SVX_DLLPUBLIC SdrObjList
 {
+private:
     SdrObjList(const SdrObjList& rSrcList) = delete;
     SdrObjList &operator=(const SdrObjList& rSrcList) = delete;
 
 private:
-    // the SdrModel this objects was created with, unchanged during SdrObjList lifetime
-    SdrModel&                   mrSdrModelFromSdrObjList;
-
-private:
     ::std::vector<SdrObject*>   maList;
 
 protected:
 friend class SdrObjListIter;
 friend class SdrEditView;
     SdrObjList* pUpList;   /// parent list
-    SdrModel*   pModel;    /// model to which the list belongs (Layer,ItemPool,Storage)
     SdrPage*    pPage;     /// Page containing the list, may be "this".
     SdrObject*  pOwnerObj; /// OwnerObject, if it's list of a Group object.
     tools::Rectangle   aOutRect;
@@ -90,25 +80,20 @@ friend class SdrEditView;
     SdrObjListKind eListKind;
     bool        bObjOrdNumsDirty;
     bool        bRectsDirty;
+
 protected:
     void RecalcRects();
-
-    SdrObjList(SdrModel& rSdrModel);
-    void lateInit(const SdrObjList& rSrcList);
+    void lateInitSdrObjList(const SdrObjList& rSrcList, SdrModel* pNewModel = nullptr);
 
 private:
     /// simple ActionChildInserted forwarder to have it on a central place
     static void impChildInserted(SdrObject const & rChild);
 public:
-    SdrObjList(SdrModel& rSdrModel, SdrPage* pNewPage);
+    SdrObjList(SdrPage* pNewPage = nullptr);
     virtual ~SdrObjList();
+    virtual SdrObjList* CloneSdrObjList(SdrModel* pNewModel = nullptr) const;
 
-    virtual SdrObjList* Clone() const;
-
-    // SdrModel access on SdrObjList level
-    SdrModel& getSdrModelFromSdrObjList() const { return mrSdrModelFromSdrObjList; }
-
-    void CopyObjects(const SdrObjList& rSrcList);
+    void CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModel = nullptr);
     /// clean up everything (without Undo)
     void    Clear();
     SdrObjListKind GetListKind() const                  { return eListKind; }
@@ -119,7 +104,6 @@ public:
     void           SetOwnerObj(SdrObject* pNewOwner)    { pOwnerObj=pNewOwner; }
     SdrPage*       GetPage() const;
     void           SetPage(SdrPage* pNewPage);
-    SdrModel*      GetModel() const;
 
     // TTTT
     // virtual void   SetModel(SdrModel* pNewModel);
@@ -371,6 +355,17 @@ public:
   Also it's possible to request and directly set the order number (ZOrder)
   of SdrObjects.
 */
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+//  SdrPage
+//      DlgEdPage
+//      FmFormPage
+//          ScDrawPage
+//          SdPage
+//          SwDPage
+//      OReportPage
+
 class SVX_DLLPUBLIC SdrPage : public SdrObjList, public virtual tools::WeakBase
 {
     // #i9076#
@@ -381,7 +376,8 @@ class SVX_DLLPUBLIC SdrPage : public SdrObjList, public virtual tools::WeakBase
     // and thus has to set mxUnoPage (it also relies on mxUnoPage not being WeakRef)
     friend class reportdesign::OSection;
 
-    SdrPage& operator=(const SdrPage& rSrcPage) = delete;
+    SdrPage& operator=(const SdrPage&) = delete;
+    SdrPage(const SdrPage&) = delete;
 
     // start PageUser section
 private:
@@ -394,6 +390,9 @@ public:
     void AddPageUser(sdr::PageUser& rNewUser);
     void RemovePageUser(sdr::PageUser& rOldUser);
 
+    // SdrModel access on SdrPage level
+    SdrModel& getSdrModelFromSdrPage() const { return mrSdrModelFromSdrPage; }
+
 protected:
     sdr::contact::ViewContact* CreateObjectSpecificViewContact();
 public:
@@ -404,6 +403,10 @@ public:
     void ActionChanged();
 
 private:
+    // the SdrModel this page was created with, unchanged during SdrPage lifetime
+    SdrModel&                   mrSdrModelFromSdrPage;
+
+private:
     sal_Int32 mnWidth;     // Seitengroesse
     sal_Int32 mnHeight;     // Seitengroesse
     sal_Int32 mnBorderLeft; // Seitenrand links
@@ -443,11 +446,11 @@ protected:
     // 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, SdrModel* pNewModel = nullptr);
+//    SdrPage(const SdrPage& rSrcPage);
+    void lateInit(const SdrPage& rSrcPage);
 
 public:
-    explicit SdrPage(SdrModel& rNewModel, bool bMasterPage=false);
+    explicit SdrPage(SdrModel& rModel, bool bMasterPage=false);
     virtual ~SdrPage() override;
 
     // TTTT
@@ -532,9 +535,6 @@ public:
         const sdr::contact::ViewObjectContact& rOriginal,
         const sdr::contact::DisplayInfo& rDisplayInfo,
         bool bEdit );
-
-private:
-    void impl_setModelForLayerAdmin(SdrModel* pNewModel);
 };
 
 
diff --git a/reportdesign/inc/RptPage.hxx b/reportdesign/inc/RptPage.hxx
index fac9855da86c..492e8c2c784c 100644
--- a/reportdesign/inc/RptPage.hxx
+++ b/reportdesign/inc/RptPage.hxx
@@ -35,13 +35,15 @@ class OReportModel;
 class REPORTDESIGN_DLLPUBLIC OReportPage : public SdrPage
 {
     OReportPage& operator=(const OReportPage&) = delete;
+    OReportPage(const OReportPage&) = delete;
 
     OReportModel&           rModel;
     css::uno::Reference< css::report::XSection > m_xSection;
     bool                    m_bSpecialInsertMode;
     std::vector<SdrObject*> m_aTemporaryObjectList;
 
-    OReportPage(const OReportPage&);
+    // TTTT
+    // OReportPage(const OReportPage&);
 
     // method to remove temporary objects, created by 'special mode'
     // (BegDragObj)
diff --git a/reportdesign/source/core/sdr/ReportDrawPage.cxx b/reportdesign/source/core/sdr/ReportDrawPage.cxx
index 568b612a175b..025bcd42bb02 100644
--- a/reportdesign/source/core/sdr/ReportDrawPage.cxx
+++ b/reportdesign/source/core/sdr/ReportDrawPage.cxx
@@ -51,7 +51,7 @@ SdrObject* OReportDrawPage::CreateSdrObject_(const uno::Reference< drawing::XSha
     if ( xReportComponent.is() )
     {
         return OObjectBase::createObject(
-            GetSdrPage()->getSdrModelFromSdrObjList(),
+            GetSdrPage()->getSdrModelFromSdrPage(),
             xReportComponent);
     }
 
diff --git a/reportdesign/source/core/sdr/RptPage.cxx b/reportdesign/source/core/sdr/RptPage.cxx
index 5c70e62c8929..3b1e4309a479 100644
--- a/reportdesign/source/core/sdr/RptPage.cxx
+++ b/reportdesign/source/core/sdr/RptPage.cxx
@@ -38,15 +38,15 @@ OReportPage::OReportPage(
 {
 }
 
-
-OReportPage::OReportPage(const OReportPage& rPage)
-:   SdrPage(rPage)
-    ,rModel(rPage.getOReportModelFromOReportPage())
-    ,m_xSection(rPage.m_xSection)
-    ,m_bSpecialInsertMode(rPage.m_bSpecialInsertMode)
-    ,m_aTemporaryObjectList(rPage.m_aTemporaryObjectList)
-{
-}
+// TTTT
+// OReportPage::OReportPage(const OReportPage& rPage)
+// :   SdrPage(rPage)
+//     ,rModel(rPage.getOReportModelFromOReportPage())
+//     ,m_xSection(rPage.m_xSection)
+//     ,m_bSpecialInsertMode(rPage.m_bSpecialInsertMode)
+//     ,m_aTemporaryObjectList(rPage.m_aTemporaryObjectList)
+// {
+// }
 
 
 OReportPage::~OReportPage()
@@ -59,17 +59,15 @@ OReportPage::~OReportPage()
 //     return Clone(nullptr);
 // }
 
-SdrPage* OReportPage::Clone( SdrModel* const pNewModel ) const
+SdrPage* OReportPage::Clone(SdrModel* pNewModel) const
 {
-    OReportPage *const pNewPage = new OReportPage( *this );
-    OReportModel* pReportModel = nullptr;
-    if ( pNewModel )
-    {
-        pReportModel = dynamic_cast<OReportModel*>( pNewModel );
-        assert( pReportModel );
-    }
-    pNewPage->lateInit( *this, pReportModel );
-    return pNewPage;
+    OReportModel& rOReportModel(static_cast< OReportModel& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+    OReportPage* pClonedOReportPage(
+        new OReportPage(
+            rOReportModel,
+            m_xSection));
+    pClonedOReportPage->SdrPage::lateInit(*this);
+    return pClonedOReportPage;
 }
 
 
diff --git a/sc/inc/drawpage.hxx b/sc/inc/drawpage.hxx
index 0f6373f37d9f..fb9b464eaff6 100644
--- a/sc/inc/drawpage.hxx
+++ b/sc/inc/drawpage.hxx
@@ -27,6 +27,7 @@ class ScDrawLayer;
 class ScDrawPage : public FmFormPage
 {
     ScDrawPage& operator=(const ScDrawPage&) = delete;
+    ScDrawPage(const ScDrawPage&) = delete;
 
 public:
     explicit ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage);
@@ -38,7 +39,7 @@ public:
     virtual css::uno::Reference< css::uno::XInterface > createUnoPage() override;
 
 private:
-    ScDrawPage(const ScDrawPage& rSrcPage);
+    // TTTT ScDrawPage(const ScDrawPage& rSrcPage);
 };
 
 #endif
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4310cc3020fb..67fd2219a780 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2708,7 +2708,7 @@ void Test::testGraphicsInGroup()
     {
         //Add a square
         tools::Rectangle aOrigRect(2,2,100,100);
-        SdrRectObj *pObj = new SdrRectObj(aOrigRect);
+        SdrRectObj *pObj = new SdrRectObj(*pDrawLayer, aOrigRect);
         pPage->InsertObject(pObj);
         const tools::Rectangle &rNewRect = pObj->GetLogicRect();
         CPPUNIT_ASSERT_EQUAL_MESSAGE("must have equal position and size",
@@ -2745,7 +2745,7 @@ void Test::testGraphicsInGroup()
     {
         // Add a circle.
         tools::Rectangle aOrigRect = tools::Rectangle(10,10,210,210); // 200 x 200
-        SdrCircObj* pObj = new SdrCircObj(OBJ_CIRC, aOrigRect);
+        SdrCircObj* pObj = new SdrCircObj(*pDrawLayer, OBJ_CIRC, aOrigRect);
         pPage->InsertObject(pObj);
         const tools::Rectangle& rNewRect = pObj->GetLogicRect();
         CPPUNIT_ASSERT_EQUAL_MESSAGE("Position and size of the circle shouldn't change when inserted into the page.",
@@ -2777,7 +2777,7 @@ void Test::testGraphicsInGroup()
         tools::Rectangle aOrigRect(10,200,110,300); // 100 x 100
         aTempPoly.append(basegfx::B2DPoint(aStartPos.X(), aStartPos.Y()));
         aTempPoly.append(basegfx::B2DPoint(aEndPos.X(), aEndPos.Y()));
-        SdrPathObj* pObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aTempPoly));
+        SdrPathObj* pObj = new SdrPathObj(*pDrawLayer, OBJ_LINE, basegfx::B2DPolyPolygon(aTempPoly));
         pObj->NbcSetLogicRect(aOrigRect);
         pPage->InsertObject(pObj);
         const tools::Rectangle& rNewRect = pObj->GetLogicRect();
@@ -2818,7 +2818,7 @@ void Test::testGraphicsOnSheetMove()
 
     // Insert an object.
     tools::Rectangle aObjRect(2,2,100,100);
-    SdrObject* pObj = new SdrRectObj(aObjRect);
+    SdrObject* pObj = new SdrRectObj(*pDrawLayer, aObjRect);
     pPage->InsertObject(pObj);
     ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0);
 
@@ -5338,7 +5338,7 @@ void Test::testNoteLifeCycle()
     SdrCaptionObj* pCaption = pNote->GetOrCreateCaption(aPos);
     CPPUNIT_ASSERT_MESSAGE("Failed to create a caption object.", pCaption);
     CPPUNIT_ASSERT_EQUAL_MESSAGE("This caption should belong to the drawing layer of the document.",
-                           m_pDoc->GetDrawLayer(), static_cast<ScDrawLayer*>(pCaption->GetModel()));
+                           m_pDoc->GetDrawLayer(), static_cast<ScDrawLayer*>(&pCaption->getSdrModelFromSdrObject()));
 
     // Copy B2 with note to a clipboard.
 
@@ -5644,7 +5644,7 @@ void Test::testAnchoredRotatedShape()
         tools::Rectangle aRect( 4000, 5000, 10000, 7000 );
 
         tools::Rectangle aRotRect( 6000, 3000, 8000, 9000 );
-        SdrRectObj *pObj = new SdrRectObj(aRect);
+        SdrRectObj *pObj = new SdrRectObj(*pDrawLayer, aRect);
         pPage->InsertObject(pObj);
         Point aRef1(pObj->GetSnapRect().Center());
         int nAngle = 9000; //90 deg.
@@ -6417,7 +6417,7 @@ void Test::testUndoDataAnchor()
 
     // Insert an object.
     tools::Rectangle aObjRect(2,1000,100,1100);
-    SdrObject* pObj = new SdrRectObj(aObjRect);
+    SdrObject* pObj = new SdrRectObj(*pDrawLayer, aObjRect);
     pPage->InsertObject(pObj);
     ScDrawLayer::SetCellAnchoredFromPosition(*pObj, *m_pDoc, 0);
 
diff --git a/sc/qa/unit/ucalc_sort.cxx b/sc/qa/unit/ucalc_sort.cxx
index 825c608f3643..e0a0dc2721d9 100644
--- a/sc/qa/unit/ucalc_sort.cxx
+++ b/sc/qa/unit/ucalc_sort.cxx
@@ -1911,7 +1911,7 @@ void Test::testSortImages()
 
     // Insert graphic in cell B2.
     const tools::Rectangle aOrigRect = tools::Rectangle(1000, 1000, 1200, 1200);
-    SdrCircObj* pObj = new SdrCircObj(OBJ_CIRC, aOrigRect);
+    SdrCircObj* pObj = new SdrCircObj(*pDrawLayer, OBJ_CIRC, aOrigRect);
     SdrPage* pPage = pDrawLayer->GetPage(0);
     CPPUNIT_ASSERT(pPage);
     pPage->InsertObject(pObj);
diff --git a/sc/source/core/data/drawpage.cxx b/sc/source/core/data/drawpage.cxx
index c7b037fc321d..c761b88ad3d9 100644
--- a/sc/source/core/data/drawpage.cxx
+++ b/sc/source/core/data/drawpage.cxx
@@ -30,10 +30,11 @@ ScDrawPage::ScDrawPage(ScDrawLayer& rNewModel, bool bMasterPage)
     SetSize( Size( LONG_MAX, LONG_MAX ) );
 }
 
-ScDrawPage::ScDrawPage(const ScDrawPage& rSrcPage)
-:   FmFormPage(rSrcPage)
-{
-}
+// TTTT
+// ScDrawPage::ScDrawPage(const ScDrawPage& rSrcPage)
+// :   FmFormPage(rSrcPage)
+// {
+// }
 
 ScDrawPage::~ScDrawPage()
 {
@@ -47,15 +48,13 @@ ScDrawPage::~ScDrawPage()
 
 ScDrawPage* ScDrawPage::Clone(SdrModel* const pNewModel) const
 {
-    ScDrawPage* const pNewPage = new ScDrawPage(*this);
-    FmFormModel* pScDrawModel = nullptr;
-    if (pNewModel)
-    {
-        pScDrawModel = dynamic_cast<FmFormModel*>(pNewModel);
-        assert(pScDrawModel);
-    }
-    pNewPage->lateInit(*this, pScDrawModel);
-    return pNewPage;
+    ScDrawLayer& rScDrawLayer(static_cast< ScDrawLayer& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+    ScDrawPage* pClonedScDrawPage(
+        new ScDrawPage(
+            rScDrawLayer,
+            IsMasterPage()));
+    pClonedScDrawPage->FmFormPage::lateInit(*this);
+    return pClonedScDrawPage;
 }
 
 css::uno::Reference< css::uno::XInterface > ScDrawPage::createUnoPage()
diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 91774388322c..3983ead921f1 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -4206,7 +4206,7 @@ void XclImpChartDrawing::ConvertObjects( XclImpDffConverter& rDffConv,
             Reference< XDrawPageSupplier > xDrawPageSupp( rxModel, UNO_QUERY_THROW );
             Reference< XDrawPage > xDrawPage( xDrawPageSupp->getDrawPage(), UNO_SET_THROW );
             pSdrPage = ::GetSdrPageFromXDrawPage( xDrawPage );
-            pSdrModel = pSdrPage ? pSdrPage->GetModel() : nullptr;
+            pSdrModel = pSdrPage ? &pSdrPage->getSdrModelFromSdrPage() : nullptr;
         }
         catch( Exception& )
         {
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index a3f51d8a516f..702c0cacfb2f 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -93,6 +93,7 @@ namespace sd {
 class SD_DLLPUBLIC SdPage final : public FmFormPage, public SdrObjUserCall
 {
     SdPage& operator=(const SdPage&) = delete;
+    SdPage(const SdPage&) = delete;
 
 friend class SdGenericDrawPage;
 friend class SdDrawPage;
@@ -147,7 +148,7 @@ friend class sd::UndoAttrObject;
     sal_Int32 mnTransitionFadeColor;
     double mfTransitionDuration;
 
-    SdPage(const SdPage& rSrcPage);
+    // TTTT SdPage(const SdPage& rSrcPage);
     void lateInit(const SdPage& rSrcPage);
 
 public:
@@ -393,6 +394,8 @@ private:
     sal_uInt16 mnPageId;
 
     /** clone the animations from this and set them to rTargetPage
+     *  TTTT what is strange, should be the other way around by
+     *  convention/convenience and makes usage a little dangerous...
     */
     void cloneAnimations( SdPage& rTargetPage ) const;
 
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx
index ce442b4f7402..38c6db785f46 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -69,7 +69,7 @@ public:
     static sal_uInt32 m_nLastId;
 
     SdPage* GetPage() const { return mpPage; }
-    SdrModel* GetModel() { return (mpPage != nullptr) ? mpPage->GetModel() : nullptr; }
+    SdrModel* GetModel() { return (mpPage != nullptr) ? &mpPage->getSdrModelFromSdrPage() : nullptr; }
     sal_uInt32 GetId() const { return m_nId; }
 
     // XInterface:
@@ -366,7 +366,7 @@ Reference< XText > SAL_CALL Annotation::getTextRange()
     osl::MutexGuard g(m_aMutex);
     if( !m_TextRange.is() && (mpPage != nullptr) )
     {
-        m_TextRange = TextApiObject::create( static_cast< SdDrawDocument* >( mpPage->GetModel() ) );
+        m_TextRange = TextApiObject::create( static_cast< SdDrawDocument* >( &mpPage->getSdrModelFromSdrPage() ) );
     }
     return Reference< XText >( m_TextRange.get() );
 }
diff --git a/sd/source/core/pglink.cxx b/sd/source/core/pglink.cxx
index 93180e1b906b..6762dcdd9bfa 100644
--- a/sd/source/core/pglink.cxx
+++ b/sd/source/core/pglink.cxx
@@ -57,7 +57,7 @@ SdPageLink::~SdPageLink()
 ::sfx2::SvBaseLink::UpdateResult SdPageLink::DataChanged(
     const OUString&, const css::uno::Any& )
 {
-    SdDrawDocument* pDoc = static_cast<SdDrawDocument*>( pPage->GetModel() );
+    SdDrawDocument* pDoc = static_cast<SdDrawDocument*>( &pPage->getSdrModelFromSdrPage() );
     sfx2::LinkManager* pLinkManager = pDoc!=nullptr ? pDoc->GetLinkManager() : nullptr;
 
     if (pLinkManager)
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index e41c9131cbb4..214e00c1ed29 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -267,7 +267,7 @@ void SdPage::EnsureMasterPageDefaultBackground()
 */
 SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect )
 {
-    ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : nullptr;
+    ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
 
     SdrObject* pSdrObj = nullptr;
@@ -279,7 +279,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
     {
         case PRESOBJ_TITLE:
         {
-            pSdrObj = new SdrRectObj(getSdrModelFromSdrObjList(), OBJ_TITLETEXT);
+            pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TITLETEXT);
 
             if (mbMaster)
             {
@@ -290,7 +290,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         case PRESOBJ_OUTLINE:
         {
-            pSdrObj = new SdrRectObj(getSdrModelFromSdrObjList(), OBJ_OUTLINETEXT);
+            pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_OUTLINETEXT);
 
             if (mbMaster)
             {
@@ -301,7 +301,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         case PRESOBJ_NOTES:
         {
-            pSdrObj = new SdrRectObj(getSdrModelFromSdrObjList(), OBJ_TEXT);
+            pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
 
             if (mbMaster)
             {
@@ -312,7 +312,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         case PRESOBJ_TEXT:
         {
-            pSdrObj = new SdrRectObj(getSdrModelFromSdrObjList(), OBJ_TEXT);
+            pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
         }
         break;
 
@@ -330,7 +330,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
             Size aSize = aOutDev.PixelToLogic(aSizePix);
             Point aPnt (0, 0);
             ::tools::Rectangle aRect (aPnt, aSize);
-            pSdrObj = new SdrGrafObj(getSdrModelFromSdrObjList(), aGraphic, aRect);
+            pSdrObj = new SdrGrafObj(getSdrModelFromSdrPage(), aGraphic, aRect);
             aOutDev.Pop();
         }
         break;
@@ -338,7 +338,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
         case PRESOBJ_MEDIA:
         case PRESOBJ_OBJECT:
         {
-            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrObjList());
+            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
             BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT);
             Graphic aGraphic( aBmpEx );
             static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic);
@@ -347,7 +347,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         case PRESOBJ_CHART:
         {
-            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrObjList());
+            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
             static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarChart" );
             BitmapEx aBmpEx(BMP_PRESOBJ_CHART);
             Graphic aGraphic( aBmpEx );
@@ -357,7 +357,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         case PRESOBJ_ORGCHART:
         {
-            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrObjList());
+            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
             static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarOrg" );
             BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART);
             Graphic aGraphic( aBmpEx );
@@ -368,7 +368,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
         case PRESOBJ_TABLE:
         case PRESOBJ_CALC:
         {
-            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrObjList());
+            pSdrObj = new SdrOle2Obj(getSdrModelFromSdrPage());
             static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarCalc" );
             BitmapEx aBmpEx(BMP_PRESOBJ_TABLE);
             Graphic aGraphic( aBmpEx );
@@ -381,7 +381,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
             // Save the first standard page at SdrPageObj
             // #i105146# We want no content to be displayed for PageKind::Handout,
             // so just never set a page as content
-            pSdrObj = new SdrPageObj(getSdrModelFromSdrObjList(), nullptr);
+            pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), nullptr);
         }
         break;
 
@@ -396,13 +396,13 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
                 nDestPageNum -= 1;
             }
 
-            if (pModel && nDestPageNum < pModel->GetPageCount())
+            if (nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
             {
-                pSdrObj = new SdrPageObj(getSdrModelFromSdrObjList(), pModel->GetPage(nDestPageNum));
+                pSdrObj = new SdrPageObj(getSdrModelFromSdrPage(), getSdrModelFromSdrPage().GetPage(nDestPageNum));
             }
             else
             {
-                pSdrObj = new SdrPageObj(getSdrModelFromSdrObjList());
+                pSdrObj = new SdrPageObj(getSdrModelFromSdrPage());
             }
 
             pSdrObj->SetResizeProtect(true);
@@ -414,7 +414,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
         case PRESOBJ_DATETIME:
         case PRESOBJ_SLIDENUMBER:
         {
-            pSdrObj = new SdrRectObj(getSdrModelFromSdrObjList(), OBJ_TEXT);
+            pSdrObj = new SdrRectObj(getSdrModelFromSdrPage(), OBJ_TEXT);
             bEmptyPresObj = false;
             bForceText = true;
         }
@@ -437,7 +437,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
             if(bVertical)
                 static_cast<SdrTextObj*>(pSdrObj)->SetVerticalWriting(true);
 
-            SfxItemSet aTempAttr( static_cast<SdDrawDocument*>(pModel)->GetPool() );
+            SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
             if( bVertical )
                 aTempAttr.Put( makeSdrTextMinFrameWidthItem( rRect.GetSize().Width() ) );
             else
@@ -479,7 +479,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
         OUString aString = GetPresObjText(eObjKind);
         if( (!aString.isEmpty() || bForceText) && dynamic_cast< const SdrTextObj *>( pSdrObj ) !=  nullptr )
         {
-            SdrOutliner* pOutliner = static_cast<SdDrawDocument*>( GetModel() )->GetInternalOutliner();
+            SdrOutliner* pOutliner = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetInternalOutliner();
 
             OutlinerMode nOutlMode = pOutliner->GetMode();
             pOutliner->Init( OutlinerMode::TextObject );
@@ -494,7 +494,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         if( (eObjKind == PRESOBJ_HEADER) || (eObjKind == PRESOBJ_FOOTER) || (eObjKind == PRESOBJ_SLIDENUMBER) || (eObjKind == PRESOBJ_DATETIME) )
         {
-            SfxItemSet aTempAttr( static_cast<SdDrawDocument*>(pModel)->GetPool() );
+            SfxItemSet aTempAttr(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool());
             aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT ) );
             aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CTL ) );
             aTempAttr.Put( SvxFontHeightItem( 493, 100, EE_CHAR_FONTHEIGHT_CJK ) );
@@ -522,7 +522,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         if (mbMaster)
         {
-            SdrLayerAdmin& rLayerAdmin = pModel->GetLayerAdmin();
+            SdrLayerAdmin& rLayerAdmin(getSdrModelFromSdrPage().GetLayerAdmin());
 
             // background objects of the master page
             pSdrObj->SetLayer( rLayerAdmin.
@@ -543,7 +543,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
             for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
             {
                 OUString aName( maLayoutName + " " + OUString::number( nLevel ) );
-                SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(pModel->GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page));
+                SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page));
                 DBG_ASSERT(pSheet, "StyleSheet for outline object not found");
                 if (pSheet)
                     pSdrObj->StartListening(*pSheet);
@@ -556,7 +556,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
              eObjKind == PRESOBJ_CALC    ||
              eObjKind == PRESOBJ_GRAPHIC )
         {
-            SfxItemSet aSet( static_cast<SdDrawDocument*>(pModel)->GetPool() );
+            SfxItemSet aSet( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
             aSet.Put( makeSdrTextContourFrameItem( true ) );
             aSet.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
 
@@ -565,7 +565,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t
 
         if( bUndo )
         {
-            pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
+            pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoNewObject(*pSdrObj));
         }
 
         if( bUndo )
@@ -604,7 +604,7 @@ SfxStyleSheet* SdPage::GetStyleSheetForMasterPageBackground() const
 
     aName += STR_LAYOUT_BACKGROUND;
 
-    SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
+    SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
     SfxStyleSheetBase*     pResult   = pStShPool->Find(aName, SfxStyleFamily::Page);
     return static_cast<SfxStyleSheet*>(pResult);
 }
@@ -651,7 +651,7 @@ SfxStyleSheet* SdPage::GetStyleSheetForPresObj(PresObjKind eObjKind) const
             break;
     }
 
-    SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
+    SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
     SfxStyleSheetBase*     pResult   = pStShPool->Find(aName, SfxStyleFamily::Page);
     return static_cast<SfxStyleSheet*>(pResult);
 }
@@ -696,7 +696,7 @@ SdStyleSheet* SdPage::getPresentationStyle( sal_uInt32 nHelpId ) const
         aStyleName += OUString::number( sal_Int32( nHelpId - HID_PSEUDOSHEET_OUTLINE ));
     }
 
-    SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
+    SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
     SfxStyleSheetBase*     pResult   = pStShPool->Find(aStyleName, SfxStyleFamily::Page);
     return dynamic_cast<SdStyleSheet*>(pResult);
 }
@@ -718,7 +718,7 @@ void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools
             case SdrUserCallType::MoveOnly:
             case SdrUserCallType::Resize:
             {
-                if (!pModel || pModel->isLocked())
+                if ( getSdrModelFromSdrPage().isLocked())
                     break;
 
                 SdrObject* pObj = const_cast<SdrObject*>(&rObj);
@@ -729,7 +729,7 @@ void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools
                     {
                         if( pObj->GetUserCall() )
                         {
-                            ::svl::IUndoManager* pUndoManager = static_cast<SdDrawDocument*>(pModel)->GetUndoManager();
+                            ::svl::IUndoManager* pUndoManager = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager();
                             const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
 
                             if( bUndo )
@@ -743,11 +743,11 @@ void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools
                     {
                         // Object of the master page changed, therefore adjust
                         // object on all pages
-                        sal_uInt16 nPageCount = static_cast<SdDrawDocument*>(pModel)->GetSdPageCount(mePageKind);
+                        sal_uInt16 nPageCount = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPageCount(mePageKind);
 
                         for (sal_uInt16 i = 0; i < nPageCount; i++)
                         {
-                            SdPage* pLoopPage = static_cast<SdDrawDocument*>(pModel)->GetSdPage(i, mePageKind);
+                            SdPage* pLoopPage = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPage(i, mePageKind);
 
                             if (pLoopPage && this == &(pLoopPage->TRG_GetMasterPage()))
                             {
@@ -777,7 +777,7 @@ void SdPage::Changed(const SdrObject& rObj, SdrUserCallType eType, const ::tools
 
 void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
 {
-    ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : nullptr;
+    ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
 
     SdPage* pMasterPage = this;
@@ -800,7 +800,7 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
         pMasterPage->EnsureMasterPageDefaultBackground();
     }
 
-    if (GetModel() && static_cast<SdDrawDocument*>(GetModel())->GetDocumentType() == DocumentType::Impress)
+    if (static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocumentType() == DocumentType::Impress)
     {
         if( mePageKind == PageKind::Handout && bInit )
         {
@@ -814,7 +814,7 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
 
                 if( bUndo )
                 {
-                    pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
+                    pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
                 }
                 else
                 {
@@ -823,7 +823,7 @@ void SdPage::CreateTitleAndLayout(bool bInit, bool bCreate )
             }
 
             std::vector< ::tools::Rectangle > aAreas;
-            CalculateHandoutAreas( *static_cast< SdDrawDocument* >(GetModel() ), pMasterPage->GetAutoLayout(), false, aAreas );
+            CalculateHandoutAreas( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()), pMasterPage->GetAutoLayout(), false, aAreas );
 
             const bool bSkip = pMasterPage->GetAutoLayout() == AUTOLAYOUT_HANDOUT3;
             std::vector< ::tools::Rectangle >::iterator iter( aAreas.begin() );
@@ -897,7 +897,7 @@ void getPresObjProp( const SdPage& rPage, const char* sObjKind, const char* sPag
 {
     bool bNoObjectFound = true;  //used to break from outer loop
 
-    const std::vector< Reference<XNode> >& objectInfo = static_cast<const SdDrawDocument*>(rPage.GetModel())->GetObjectVector();
+    const std::vector< Reference<XNode> >& objectInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetObjectVector();
     for( std::vector< Reference<XNode> >::const_iterator aIter=objectInfo.begin(); aIter != objectInfo.end(); ++aIter )
     {
         if(bNoObjectFound)
@@ -1047,8 +1047,7 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
 
     if( pObject )
     {
-        SdDrawDocument *pDoc = static_cast<SdDrawDocument*>(pModel);
-
+        SdDrawDocument* pDoc(static_cast< SdDrawDocument* >(&getSdrModelFromSdrPage()));
         const bool bUndo = pDoc->IsUndoEnabled();
         if( bUndo )
             pDoc->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoDeleteObject(*pObject));
@@ -1113,9 +1112,9 @@ void SdPage::DestroyDefaultPresObj(PresObjKind eObjKind)
                 nDestPageNum -= 1;
             }
 
-            if(nDestPageNum < pModel->GetPageCount())
+            if(nDestPageNum < getSdrModelFromSdrPage().GetPageCount())
             {
-                pRefPage = pModel->GetPage(nDestPageNum);
+                pRefPage = getSdrModelFromSdrPage().GetPage(nDestPageNum);
             }
 
             if ( pRefPage )
@@ -1362,7 +1361,7 @@ static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* r
     const Point aLayoutPos( aLayoutRect.TopLeft() );
     double propvalue[] = {0,0,0,0};
 
-    const std::vector< Reference<XNode> >& layoutInfo = static_cast<const SdDrawDocument*>(rPage.GetModel())->GetLayoutVector();
+    const std::vector< Reference<XNode> >& layoutInfo = static_cast< const SdDrawDocument& >(rPage.getSdrModelFromSdrPage()).GetLayoutVector();
     for( std::vector< Reference<XNode> >::const_iterator aIter=layoutInfo.begin(); aIter != layoutInfo.end(); ++aIter )
     {
         Reference<XNode> layoutNode = *aIter;
@@ -1521,10 +1520,10 @@ void findAutoLayoutShapesImpl( SdPage& rPage, const LayoutDescriptor& rDescripto
                         {
                             if( pOle2->IsEmpty() )
                                 bFound = true;
-                            else if( rPage.GetModel() )
+                            else
                             {
-                                SdrModel* pSdrModel = rPage.GetModel();
-                                ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
+                                ::comphelper::IEmbeddedHelper* pPersist(rPage.getSdrModelFromSdrPage().GetPersist());
+
                                 if( pPersist )
                                 {
                                     uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
@@ -1598,7 +1597,7 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
 
     const bool bSwitchLayout = eLayout != GetAutoLayout();
 
-    ::svl::IUndoManager* pUndoManager = pModel ? static_cast<SdDrawDocument*>(pModel)->GetUndoManager() : nullptr;
+    ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
 
     meAutoLayout = eLayout;
@@ -1647,7 +1646,7 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, bool bInit, bool bCreate )
                 if( pObj->IsEmptyPresObj() )
                 {
                     if( bUndo )
-                        pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
+                        pUndoManager->AddUndoAction(getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoDeleteObject(*pObj));
 
                     RemoveObject( pObj->GetOrdNum() );
 
@@ -1670,7 +1669,7 @@ void SdPage::NbcInsertObject(SdrObject* pObj, size_t nPos)
 {
     FmFormPage::NbcInsertObject(pObj, nPos);
 
-    static_cast<SdDrawDocument*>(pModel)->InsertObject(pObj);
+    static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).InsertObject(pObj);
 
     SdrLayerID nId = pObj->GetLayer();
     if( mbMaster )
@@ -1733,8 +1732,7 @@ void SdPage::onRemoveObject( SdrObject* pObject )
     {
         RemovePresObj(pObject);
 
-        if( pModel )
-            static_cast<SdDrawDocument*>(pModel)->RemoveObject(pObject);
+        static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).RemoveObject(pObject);
 
         removeAnimations( pObject );
     }
@@ -1956,7 +1954,7 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN
                             for (sal_Int32 i=1; i<=9; i++)
                             {
                                 OUString sLayoutName( aName + OUString::number( i ) );
-                                SfxStyleSheet* pOutlineSheet = static_cast<SfxStyleSheet*>(static_cast<SdDrawDocument*>(pModel)->GetStyleSheetPool()->Find(sLayoutName, SfxStyleFamily::Page));
+                                SfxStyleSheet* pOutlineSheet = static_cast<SfxStyleSheet*>(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetStyleSheetPool()->Find(sLayoutName, SfxStyleFamily::Page));
 
                                 if (pOutlineSheet)
                                 {
@@ -2077,12 +2075,11 @@ void SdPage::ScaleObjects(const Size& rNewPageSize, const ::tools::Rectangle& rN
 
 SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, PresObjKind& eObjKind, bool bVertical, const ::tools::Rectangle& rRect)
 {
-    SdDrawDocument* pModel = static_cast< SdDrawDocument* >( rPage.GetModel() );
-    DBG_ASSERT( pModel, "sd::convertPresentationObjectImpl(), no model on page!" );
-    if( !pModel || !pSourceObj )
+    SdDrawDocument& rModel(static_cast< SdDrawDocument& >(rPage.getSdrModelFromSdrPage()));
+    if( !pSourceObj )
         return pSourceObj;
 
-    ::svl::IUndoManager* pUndoManager = pModel->GetUndoManager();
+    ::svl::IUndoManager* pUndoManager = rModel.GetUndoManager();
     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && rPage.IsInserted();
 
     SdrObject* pNewObj = pSourceObj;
@@ -2096,7 +2093,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
         if(pOutlParaObj)
         {
             // assign text
-            SdOutliner* pOutl = pModel->GetInternalOutliner();
+            SdOutliner* pOutl = rModel.GetInternalOutliner();
             pOutl->Clear();
             pOutl->SetText( *pOutlParaObj );
             pOutlParaObj = pOutl->CreateParaObject();
@@ -2108,7 +2105,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
             {
                 // assign new template
                 OUString aName( rPage.GetLayoutName() + " " + OUString::number( nLevel ) );
-                SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pModel->GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page) );
+                SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( rModel.GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page) );
 
                 if (pSheet)
                 {
@@ -2125,7 +2122,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
             }
 
             // Remove LRSpace item
-            SfxItemSet aSet(pModel->GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
+            SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
 
             aSet.Put(pNewObj->GetMergedItemSet());
 
@@ -2134,7 +2131,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
             pNewObj->SetMergedItemSet(aSet);
 
             if( bUndo )
-                pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
+                pUndoManager->AddUndoAction( rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj) );
 
             // Remove outline shape from page
             rPage.RemoveObject( pSourceObj->GetOrdNum() );
@@ -2154,7 +2151,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
         if(pOutlParaObj)
         {
             // assign text
-            SdOutliner* pOutl = pModel->GetInternalOutliner();
+            SdOutliner* pOutl = rModel.GetInternalOutliner();
             pOutl->Clear();
             pOutl->SetText( *pOutlParaObj );
             pOutlParaObj = pOutl->CreateParaObject();
@@ -2163,7 +2160,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
             pNewObj->SetEmptyPresObj(false);
 
             // reset left indent
-            SfxItemSet aSet(pModel->GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
+            SfxItemSet aSet(rModel.GetPool(), svl::Items<EE_PARA_LRSPACE, EE_PARA_LRSPACE>{} );
 
             aSet.Put(pNewObj->GetMergedItemSet());
 
@@ -2180,7 +2177,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
 
             // Remove subtitle shape from page
             if( bUndo )
-                pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
+                pUndoManager->AddUndoAction(rModel.GetSdrUndoFactory().CreateUndoDeleteObject(*pSourceObj));
 
             rPage.RemoveObject( pSourceObj->GetOrdNum() );
 
@@ -2220,7 +2217,7 @@ SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourceObj, P
 */
 SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind, bool bVertical, const ::tools::Rectangle& rRect, bool bInit)
 {
-    ::svl::IUndoManager* pUndoManager = static_cast<SdDrawDocument*>(pModel)->GetUndoManager();
+    ::svl::IUndoManager* pUndoManager(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetUndoManager());
     const bool bUndo = pUndoManager && pUndoManager->IsInListAction() && IsInserted();
 
     if (!pObj && bInit)
@@ -2235,8 +2232,8 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
 
         if( bUndo )
         {
-            pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
-            pUndoManager->AddUndoAction( pModel->GetSdrUndoFactory().CreateUndoAttrObject( *pObj, true, true ) );
+            pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
+            pUndoManager->AddUndoAction( getSdrModelFromSdrPage().GetSdrUndoFactory().CreateUndoAttrObject( *pObj, true, true ) );
             pUndoManager->AddUndoAction( new UndoObjectUserCall( *pObj ) );
         }
 
@@ -2262,7 +2259,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
                 if ( pTextObject->IsAutoGrowHeight() )
                 {
                     // switch off AutoGrowHeight, set new MinHeight
-                    SfxItemSet aTempAttr( static_cast<SdDrawDocument*>(pModel)->GetPool() );
+                    SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
                     SdrMetricItem aMinHeight( makeSdrTextMinFrameHeightItem(rRect.GetSize().Height()) );
                     aTempAttr.Put( aMinHeight );
                     aTempAttr.Put( makeSdrTextAutoGrowHeightItem(false) );
@@ -2270,7 +2267,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
                     pTextObject->SetLogicRect(rRect);
 
                     // switch on AutoGrowHeight
-                    SfxItemSet aAttr( static_cast<SdDrawDocument*>(pModel)->GetPool() );
+                    SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
                     aAttr.Put( makeSdrTextAutoGrowHeightItem(true) );
 
                     pTextObject->SetMergedItemSet(aAttr);
@@ -2279,7 +2276,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
                 if ( pTextObject->IsAutoGrowWidth() )
                 {
                     // switch off AutoGrowWidth , set new MinWidth
-                    SfxItemSet aTempAttr( static_cast<SdDrawDocument*>(pModel)->GetPool() );
+                    SfxItemSet aTempAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
                     SdrMetricItem aMinWidth( makeSdrTextMinFrameWidthItem(rRect.GetSize().Width()) );
                     aTempAttr.Put( aMinWidth );
                     aTempAttr.Put( makeSdrTextAutoGrowWidthItem(false) );
@@ -2287,7 +2284,7 @@ SdrObject* SdPage::InsertAutoLayoutShape(SdrObject* pObj, PresObjKind eObjKind,
                     pTextObject->SetLogicRect(rRect);
 
                     // switch on AutoGrowWidth
-                    SfxItemSet aAttr( static_cast<SdDrawDocument*>(pModel)->GetPool() );
+                    SfxItemSet aAttr( static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetPool() );
                     aAttr.Put( makeSdrTextAutoGrowWidthItem(true) );
                     pTextObject->SetMergedItemSet(aAttr);
                 }
@@ -2389,11 +2386,11 @@ void SdPage::SetObjText(SdrTextObj* pObj, SdrOutliner* pOutliner, PresObjKind eO
 
         if (!pOutliner)
         {
-            SfxItemPool* pPool = static_cast<SdDrawDocument*>(GetModel())->GetDrawOutliner().GetEmptyItemSet().GetPool();
+            SfxItemPool* pPool(static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDrawOutliner().GetEmptyItemSet().GetPool());
             pOutl = new ::Outliner( pPool, OutlinerMode::OutlineObject );
             pOutl->SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
             pOutl->SetEditTextObjectPool(pPool);
-            pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(GetModel()->GetStyleSheetPool()));
+            pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool()));
             pOutl->EnableUndo(false);
             pOutl->SetUpdateMode( false );
         }
@@ -2549,7 +2546,7 @@ const OUString& SdPage::GetName() const
 
             aCreatedPageName = SdResId(STR_PAGE);
             aCreatedPageName += " ";
-            if( GetModel()->GetPageNumType() == css::style::NumberingType::NUMBER_NONE )
+            if( getSdrModelFromSdrPage().GetPageNumType() == css::style::NumberingType::NUMBER_NONE )
             {
                 // if the document has number none as a formatting
                 // for page numbers we still default to arabic numbering
@@ -2558,7 +2555,7 @@ const OUString& SdPage::GetName() const
             }
             else
             {
-                aCreatedPageName += static_cast<SdDrawDocument*>(GetModel())->CreatePageNumValue(nNum);
+                aCreatedPageName += static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).CreatePageNumValue(nNum);
             }
         }
         else
@@ -2721,7 +2718,7 @@ void SdPage::SetName (const OUString& rName)
 {
     OUString aOldName( GetName() );
     FmFormPage::SetName (rName);
-    static_cast<SdDrawDocument*>(pModel)->UpdatePageRelativeURLs(aOldName, rName);
+    static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).UpdatePageRelativeURLs(aOldName, rName);
     ActionChanged();
 }
 
diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx
index fee6839146ea..a484af49a60b 100644
--- a/sd/source/core/sdpage2.cxx
+++ b/sd/source/core/sdpage2.cxx
@@ -95,13 +95,13 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName,
         SdPage* pMaster;
         SdPage* pFoundMaster = nullptr;
         sal_uInt16 nMaster = 0;
-        sal_uInt16 nMasterCount = pModel->GetMasterPageCount();
+        sal_uInt16 nMasterCount = getSdrModelFromSdrPage().GetMasterPageCount();
 
         if( !bReverseOrder )
         {
             for ( nMaster = 0; nMaster < nMasterCount; nMaster++ )
             {
-                pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster));
+                pMaster = static_cast<SdPage*>(getSdrModelFromSdrPage().GetMasterPage(nMaster));
                 if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
                 {
                     pFoundMaster = pMaster;
@@ -113,7 +113,7 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName,
         {
             for ( nMaster = nMasterCount; nMaster > 0; nMaster-- )
             {
-                pMaster = static_cast<SdPage*>(pModel->GetMasterPage(nMaster - 1));
+                pMaster = static_cast<SdPage*>(getSdrModelFromSdrPage().GetMasterPage(nMaster - 1));
                 if (pMaster->GetPageKind() == mePageKind && pMaster->GetLayoutName() == maLayoutName)
                 {
                     pFoundMaster = pMaster;
@@ -126,7 +126,7 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName,
 
         // this should never happen, but we play failsafe here
         if( pFoundMaster == nullptr )
-            pFoundMaster = static_cast< SdDrawDocument *>(pModel)->GetSdPage( 0, mePageKind );
+            pFoundMaster = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetSdPage( 0, mePageKind );
 
         if( pFoundMaster )
             TRG_SetMasterPage(*pFoundMaster);
@@ -157,7 +157,7 @@ void SdPage::SetPresentationLayout(const OUString& rLayoutName,
                 OUString aFullName;
                 OUString aOldFullName;
                 SfxStyleSheetBase* pSheet = nullptr;
-                SfxStyleSheetBasePool* pStShPool = pModel->GetStyleSheetPool();
+                SfxStyleSheetBasePool* pStShPool = getSdrModelFromSdrPage().GetStyleSheetPool();
 
                 for (sal_Int16 i = -1; i < 9; i++)
                 {
@@ -261,7 +261,7 @@ void SdPage::EndListenOutlineText()
 
     if (pOutlineTextObj)
     {
-        SdStyleSheetPool* pSPool = static_cast<SdStyleSheetPool*>(pModel->GetStyleSheetPool());
+        SdStyleSheetPool* pSPool = static_cast<SdStyleSheetPool*>(getSdrModelFromSdrPage().GetStyleSheetPool());
         DBG_ASSERT(pSPool, "StyleSheetPool missing");
         OUString aTrueLayoutName(maLayoutName);
         sal_Int32 nIndex = aTrueLayoutName.indexOf( SD_LT_SEPARATOR );
@@ -316,17 +316,17 @@ bool SdPage::IsReadOnly() const
 
 void SdPage::ConnectLink()
 {
-    sfx2::LinkManager* pLinkManager = pModel!=nullptr ? pModel->GetLinkManager() : nullptr;
+    sfx2::LinkManager* pLinkManager(getSdrModelFromSdrPage().GetLinkManager());
 
     if (pLinkManager && !mpPageLink && !maFileName.isEmpty() && !maBookmarkName.isEmpty() &&
         mePageKind==PageKind::Standard && !IsMasterPage() &&
-        static_cast<SdDrawDocument*>(pModel)->IsNewOrLoadCompleted())
+        static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).IsNewOrLoadCompleted())
     {
         /**********************************************************************
         * Connect
         * Only standard pages are allowed to be linked
         **********************************************************************/
-        ::sd::DrawDocShell* pDocSh = static_cast<SdDrawDocument*>(pModel)->GetDocSh();
+        ::sd::DrawDocShell* pDocSh = static_cast< SdDrawDocument& >(getSdrModelFromSdrPage()).GetDocSh();
 
         if (!pDocSh || pDocSh->GetMedium()->GetOrigURL() != maFileName)
         {
@@ -348,7 +348,7 @@ void SdPage::ConnectLink()
 
 void SdPage::DisconnectLink()
 {
-    sfx2::LinkManager* pLinkManager = pModel!=nullptr ? pModel->GetLinkManager() : nullptr;
+    sfx2::LinkManager* pLinkManager(getSdrModelFromSdrPage().GetLinkManager());
 
     if (pLinkManager && mpPageLink)
     {
@@ -367,42 +367,43 @@ void SdPage::DisconnectLink()
 |*
 \************************************************************************/
 
-SdPage::SdPage(const SdPage& rSrcPage)
-:   FmFormPage(rSrcPage)
-,   SdrObjUserCall()
-,   mpItems(nullptr)
-,   mnPageId(mnLastPageId++)
-{
-    mePageKind           = rSrcPage.mePageKind;
-    meAutoLayout         = rSrcPage.meAutoLayout;
-
-    mbSelected           = false;
-    mnTransitionType    = rSrcPage.mnTransitionType;
-    mnTransitionSubtype = rSrcPage.mnTransitionSubtype;
-    mbTransitionDirection = rSrcPage.mbTransitionDirection;
-    mnTransitionFadeColor = rSrcPage.mnTransitionFadeColor;
-    mfTransitionDuration = rSrcPage.mfTransitionDuration;
-    mePresChange            = rSrcPage.mePresChange;
-    mfTime               = rSrcPage.mfTime;
-    mbSoundOn            = rSrcPage.mbSoundOn;
-    mbExcluded           = rSrcPage.mbExcluded;
-
-    maLayoutName         = rSrcPage.maLayoutName;
-    maSoundFile          = rSrcPage.maSoundFile;
-    mbLoopSound          = rSrcPage.mbLoopSound;
-    mbStopSound          = rSrcPage.mbStopSound;
-    maCreatedPageName.clear();
-    maFileName           = rSrcPage.maFileName;
-    maBookmarkName       = rSrcPage.maBookmarkName;
-    mbScaleObjects       = rSrcPage.mbScaleObjects;
-    mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize;
-    meCharSet            = rSrcPage.meCharSet;
-    mnPaperBin           = rSrcPage.mnPaperBin;
-
-    mpPageLink           = nullptr;    // is set when inserting via ConnectLink()
-
-    mbIsPrecious         = false;
-}
+// TTTT
+// SdPage::SdPage(const SdPage& rSrcPage)
+// :   FmFormPage(rSrcPage)
+// ,   SdrObjUserCall()
+// ,   mpItems(nullptr)
+// ,   mnPageId(mnLastPageId++)
+// {
+//     mePageKind           = rSrcPage.mePageKind;
+//     meAutoLayout         = rSrcPage.meAutoLayout;
+
+//     mbSelected           = false;
+//     mnTransitionType    = rSrcPage.mnTransitionType;
+//     mnTransitionSubtype = rSrcPage.mnTransitionSubtype;
+//     mbTransitionDirection = rSrcPage.mbTransitionDirection;
+//     mnTransitionFadeColor = rSrcPage.mnTransitionFadeColor;
+//     mfTransitionDuration = rSrcPage.mfTransitionDuration;
+//     mePresChange            = rSrcPage.mePresChange;
+//     mfTime               = rSrcPage.mfTime;
+//     mbSoundOn            = rSrcPage.mbSoundOn;
+//     mbExcluded           = rSrcPage.mbExcluded;
+
+//     maLayoutName         = rSrcPage.maLayoutName;
+//     maSoundFile          = rSrcPage.maSoundFile;
+//     mbLoopSound          = rSrcPage.mbLoopSound;
+//     mbStopSound          = rSrcPage.mbStopSound;
+//     maCreatedPageName.clear();
+//     maFileName           = rSrcPage.maFileName;
+//     maBookmarkName       = rSrcPage.maBookmarkName;
+//     mbScaleObjects       = rSrcPage.mbScaleObjects;
+//     mbBackgroundFullSize = rSrcPage.mbBackgroundFullSize;
+//     meCharSet            = rSrcPage.meCharSet;
+//     mnPaperBin           = rSrcPage.mnPaperBin;
+
+//     mpPageLink           = nullptr;    // is set when inserting via ConnectLink()
+
+//     mbIsPrecious         = false;
+// }
 
 void SdPage::lateInit(const SdPage& rSrcPage)
 {
@@ -410,8 +411,7 @@ void SdPage::lateInit(const SdPage& 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 )
+    for( std::list< SdrObject* >::const_iterator aIter = rShapeList.begin(); aIter != rShapeList.end(); ++aIter )
     {
         SdrObject* pObj = *aIter;
         InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj));
@@ -419,6 +419,22 @@ void SdPage::lateInit(const SdPage& rSrcPage)
 
     // header footer
     setHeaderFooterSettings( rSrcPage.getHeaderFooterSettings() );
+
+    // animations
+    rSrcPage.cloneAnimations(*this);
+
+    // fix user calls for duplicated slide
+    SdrObjListIter aSourceIter( rSrcPage, SdrIterMode::DeepWithGroups );
+    SdrObjListIter aTargetIter( *this, SdrIterMode::DeepWithGroups );
+
+    while( aSourceIter.IsMore() && aTargetIter.IsMore() )
+    {
+        SdrObject* pSource = aSourceIter.Next();
+        SdrObject* pTarget = aTargetIter.Next();
+
+        if( pSource->GetUserCall() )
+            pTarget->SetUserCall(this);
+    }
 }
 
 /*************************************************************************
@@ -435,27 +451,13 @@ void SdPage::lateInit(const SdPage& rSrcPage)
 
 SdrPage* SdPage::Clone(SdrModel* pNewModel) const
 {
-    DBG_ASSERT( pNewModel == nullptr, "sd::SdPage::Clone(), new page ignored, please check code! CL" );
-
-    SdPage* pNewPage = new SdPage(*this);
-    pNewPage->lateInit( *this );
-
-    cloneAnimations( *pNewPage );
-
-    // fix user calls for duplicated slide
-    SdrObjListIter aSourceIter( *this, SdrIterMode::DeepWithGroups );
-    SdrObjListIter aTargetIter( *pNewPage, SdrIterMode::DeepWithGroups );
-
-    while( aSourceIter.IsMore() && aTargetIter.IsMore() )
-    {
-        SdrObject* pSource = aSourceIter.Next();
-        SdrObject* pTarget = aTargetIter.Next();
-
-        if( pSource->GetUserCall() )
-            pTarget->SetUserCall( pNewPage );
-    }
-
-    return pNewPage;
+    SdDrawDocument& rSdDrawDocument(static_cast< SdDrawDocument& >(nullptr == pNewModel ? getSdrModelFromSdrPage() : *pNewModel));
+    SdPage* pClonedSdPage(
+        new SdPage(
+            rSdDrawDocument,
+            IsMasterPage()));
+    pClonedSdPage->lateInit(*this);
+    return pClonedSdPage;
 }
 
 /*************************************************************************
@@ -478,7 +480,7 @@ SfxStyleSheet* SdPage::GetTextStyleSheetForObject( SdrObject* pObj ) const
 SfxItemSet* SdPage::getOrCreateItems()
 {
     if( mpItems == nullptr )
-        mpItems = o3tl::make_unique<SfxItemSet>( pModel->GetItemPool(), svl::Items<SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES>{} );
+        mpItems = o3tl::make_unique<SfxItemSet>( getSdrModelFromSdrPage().GetItemPool(), svl::Items<SDRATTR_XMLATTRIBUTES, SDRATTR_XMLATTRIBUTES>{} );
 
     return mpItems.get();
 }
@@ -596,40 +598,34 @@ void SdPage::addAnnotation( const Reference< XAnnotation >& xAnnotation, int nIn
         maAnnotations.insert( maAnnotations.begin() + nIndex, xAnnotation );
     }
 
-    if( pModel && pModel->IsUndoEnabled() )
+    if( getSdrModelFromSdrPage().IsUndoEnabled() )
     {
         SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, true );
         if( pAction )
-            pModel->AddUndo( pAction );
+            getSdrModelFromSdrPage().AddUndo( pAction );
     }
 
     SetChanged();
-
-    if( pModel )
-    {
-        pModel->SetChanged();
-        NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), "OnAnnotationInserted", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
-    }
+    getSdrModelFromSdrPage().SetChanged();
+    // TTTT NotifyDocumentEvent shbe ref?
+    NotifyDocumentEvent( static_cast< SdDrawDocument* >(&getSdrModelFromSdrPage()), "OnAnnotationInserted", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
 }
 
 void SdPage::removeAnnotation( const Reference< XAnnotation >& xAnnotation )
 {
-    if( pModel && pModel->IsUndoEnabled() )
+    if( getSdrModelFromSdrPage().IsUndoEnabled() )
     {
         SdrUndoAction* pAction = CreateUndoInsertOrRemoveAnnotation( xAnnotation, false );
         if( pAction )
-            pModel->AddUndo( pAction );
+            getSdrModelFromSdrPage().AddUndo( pAction );
     }
 
     AnnotationVector::iterator iter = std::find( maAnnotations.begin(), maAnnotations.end(), xAnnotation );
     if( iter != maAnnotations.end() )
         maAnnotations.erase( iter );
 
-    if( pModel )
-    {
-        pModel->SetChanged();
-        NotifyDocumentEvent( static_cast< SdDrawDocument* >( pModel ), "OnAnnotationRemoved", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
-    }
+    getSdrModelFromSdrPage().SetChanged();
+    NotifyDocumentEvent( static_cast< SdDrawDocument* >( &getSdrModelFromSdrPage() ), "OnAnnotationRemoved", Reference<XInterface>( xAnnotation, UNO_QUERY ) );
 }
 
 void SdPage::dumpAsXml(xmlTextWriterPtr pWriter) const
diff --git a/sd/source/core/undo/undoobjects.cxx b/sd/source/core/undo/undoobjects.cxx
index bd3589c2af98..7b855d89b5fb 100644
--- a/sd/source/core/undo/undoobjects.cxx
+++ b/sd/source/core/undo/undoobjects.cxx
@@ -61,7 +61,9 @@ UndoRemovePresObjectImpl::UndoRemovePresObjectImpl( SdrObject& rObject )
             css::uno::Reference< css::drawing::XShape > xShape( rObject.getUnoShape(), css::uno::UNO_QUERY );
             if( pPage->getMainSequence()->hasEffect( xShape ) )
             {
-                mpUndoAnimation = new UndoAnimation( static_cast< SdDrawDocument* >( pPage->GetModel() ), pPage );
+                mpUndoAnimation = new UndoAnimation( // TTTT may use ref? Or just *SdrPage?
+                    static_cast< SdDrawDocument* >(&pPage->getSdrModelFromSdrPage()),
+                    pPage);
             }
         }
     }
@@ -186,7 +188,10 @@ UndoObjectSetText::UndoObjectSetText( SdrObject& rObject, sal_Int32 nText )
         css::uno::Reference< css::drawing::XShape > xShape( rObject.getUnoShape(), css::uno::UNO_QUERY );
         if( pPage->getMainSequence()->hasEffect( xShape ) )
         {
-            mpUndoAnimation.reset( new UndoAnimation( static_cast< SdDrawDocument* >( pPage->GetModel() ), pPage ) );
+            mpUndoAnimation.reset(
+                new UndoAnimation(
+                    static_cast< SdDrawDocument* >(&pPage->getSdrModelFromSdrPage()),
+                    pPage));
         }
     }
 }
diff --git a/sd/source/filter/grf/sdgrffilter.cxx b/sd/source/filter/grf/sdgrffilter.cxx
index 38988299a488..73b35d0a1901 100644
--- a/sd/source/filter/grf/sdgrffilter.cxx
+++ b/sd/source/filter/grf/sdgrffilter.cxx
@@ -208,7 +208,7 @@ bool SdGRFFilter::Import()
 
         pPage->InsertObject(
             new SdrGrafObj(
-                pPage->getSdrModelFromSdrObjList(),
+                pPage->getSdrModelFromSdrPage(),
                 aGraphic,
                 ::tools::Rectangle(aPos, aGrfSize)));
         bRet = true;
diff --git a/sd/source/ui/func/fuconrec.cxx b/sd/source/ui/func/fuconrec.cxx
index 4785d5392e7b..471a1eeb2608 100644
--- a/sd/source/ui/func/fuconrec.cxx
+++ b/sd/source/ui/func/fuconrec.cxx
@@ -482,9 +482,9 @@ void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj)
         // dimension line
         SdPage* pPage = static_cast<SdPage*>( mpView->GetSdrPageView()->GetPage() );
         OUString aName(SdResId(STR_POOLSHEET_MEASURE));
-        SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>( pPage->GetModel()->
-                                     GetStyleSheetPool()->
-                                     Find(aName, SfxStyleFamily::Para));
+        SfxStyleSheet* pSheet(
+            static_cast< SfxStyleSheet* >(
+                pPage->getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Para)));
         DBG_ASSERT(pSheet, "StyleSheet missing");
 
         if (pSheet)
diff --git a/sd/source/ui/func/fuconstr.cxx b/sd/source/ui/func/fuconstr.cxx
index 8f376fb3d72a..9e15f47a070a 100644
--- a/sd/source/ui/func/fuconstr.cxx
+++ b/sd/source/ui/func/fuconstr.cxx
@@ -318,9 +318,9 @@ void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj,
         OUString aName( pPage->GetLayoutName() );
         sal_Int32 n = aName.indexOf(SD_LT_SEPARATOR) + strlen(SD_LT_SEPARATOR);
         aName = aName.copy(0, n) + STR_LAYOUT_BACKGROUNDOBJECTS;
-        SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(pPage->GetModel()->
-                                                GetStyleSheetPool()->
-                                                Find(aName, SfxStyleFamily::Page));
+        SfxStyleSheet* pSheet(
+            static_cast< SfxStyleSheet* >(
+                pPage->getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page)));
         DBG_ASSERT(pSheet, "StyleSheet missing");
         if (pSheet)
         {
@@ -348,9 +348,9 @@ void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj,
         if ( bForceNoFillStyle )
         {
             OUString aName(SdResId(STR_POOLSHEET_OBJWITHOUTFILL));
-            SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(pPage->GetModel()->
-                                         GetStyleSheetPool()->
-                                         Find(aName, SfxStyleFamily::Para));
+            SfxStyleSheet* pSheet(
+                static_cast< SfxStyleSheet* >(
+                    pPage->getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Para)));
             DBG_ASSERT(pSheet, "Stylesheet missing");
             if (pSheet)
             {
diff --git a/sd/source/ui/sidebar/DocumentHelper.cxx b/sd/source/ui/sidebar/DocumentHelper.cxx
index cc2d2259a3b5..8eb13317fc09 100644
--- a/sd/source/ui/sidebar/DocumentHelper.cxx
+++ b/sd/source/ui/sidebar/DocumentHelper.cxx
@@ -53,14 +53,11 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument (
             break;
 
         // Check the presence of the source document.
-        SdDrawDocument* pSourceDocument = static_cast<SdDrawDocument*>(
-            pMasterPage->GetModel());
-        if (pSourceDocument == nullptr)
-            break;
+        SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage()));
 
         // When the given master page already belongs to the target document
         // then there is nothing more to do.
-        if (pSourceDocument == &rTargetDocument)
+        if (&rSourceDocument == &rTargetDocument)
         {
             pNewMasterPage = pMasterPage;
             break;
@@ -70,7 +67,7 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument (
         // present.  This is not the case when we are called during the
         // creation of the slide master page because then the notes master
         // page is not there.
-        sal_uInt16 nSourceMasterPageCount = pSourceDocument->GetMasterPageCount();
+        sal_uInt16 nSourceMasterPageCount = rSourceDocument.GetMasterPageCount();
         if (nSourceMasterPageCount%2 == 0)
             // There should be 1 handout page + n slide masters + n notes
             // masters = 2*n+1.  An even value indicates that a new slide
@@ -81,11 +78,11 @@ SdPage* DocumentHelper::CopyMasterPageToLocalDocument (
             break;
         // Get the slide master page.
         if (pMasterPage != static_cast<SdPage*>(
-            pSourceDocument->GetMasterPage(nIndex)))
+            rSourceDocument.GetMasterPage(nIndex)))
             break;
         // Get the notes master page.
         SdPage* pNotesMasterPage = static_cast<SdPage*>(
-            pSourceDocument->GetMasterPage(nIndex+1));
+            rSourceDocument.GetMasterPage(nIndex+1));
         if (pNotesMasterPage == nullptr)
             break;
 
@@ -161,7 +158,7 @@ SdPage* DocumentHelper::GetSlideForMasterPage (SdPage const * pMasterPage)
 
     SdDrawDocument* pDocument = nullptr;
     if (pMasterPage != nullptr)
-        pDocument = dynamic_cast<SdDrawDocument*>(pMasterPage->GetModel());
+        pDocument = dynamic_cast< SdDrawDocument* >(&pMasterPage->getSdrModelFromSdrPage());
 
     // Iterate over all pages and check if it references the given master
     // page.
@@ -215,10 +212,8 @@ SdPage* DocumentHelper::AddMasterPage (
             pClonedMasterPage = static_cast<SdPage*>(pMasterPage->Clone());
 
             // Copy the necessary styles.
-            SdDrawDocument* pSourceDocument
-                = static_cast<SdDrawDocument*>(pMasterPage->GetModel());
-            if (pSourceDocument != nullptr)
-                ProvideStyles (*pSourceDocument, rTargetDocument, pClonedMasterPage);
+            SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage()));
+            ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage);
 
             // Copy the precious flag.
             pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious());
@@ -310,7 +305,7 @@ void DocumentHelper::AssignMasterPageToPageList (
     ::std::vector<SdPage*> aCleanedList;
     for (iPage=rpPageList->begin(); iPage!=rpPageList->end(); ++iPage)
     {
-        OSL_ASSERT(*iPage!=nullptr && (*iPage)->GetModel() == &rTargetDocument);
+        OSL_ASSERT(*iPage!=nullptr && &(*iPage)->getSdrModelFromSdrPage() == &rTargetDocument);
         if (*iPage != nullptr && (*iPage)->GetLayoutName() != sFullLayoutName)
         {
             aCleanedList.push_back(*iPage);
@@ -358,28 +353,24 @@ SdPage* DocumentHelper::AddMasterPage (
         pClonedMasterPage->SetPrecious(pMasterPage->IsPrecious());
 
         // Copy the necessary styles.
-        SdDrawDocument* pSourceDocument
-            = static_cast<SdDrawDocument*>(pMasterPage->GetModel());
-        if (pSourceDocument != nullptr)
-        {
-            ProvideStyles (*pSourceDocument, rTargetDocument, pClonedMasterPage);
-
-            // Now that the styles are available we can insert the cloned
-            // master page.
-            rTargetDocument.InsertMasterPage (pClonedMasterPage, nInsertionIndex);
-
-            // Adapt the size of the new master page to that of the pages in
-            // the document.
-            Size aNewSize (rTargetDocument.GetSdPage(0, pMasterPage->GetPageKind())->GetSize());
-            ::tools::Rectangle aBorders (
-                pClonedMasterPage->GetLeftBorder(),
-                pClonedMasterPage->GetUpperBorder(),
-                pClonedMasterPage->GetRightBorder(),
-                pClonedMasterPage->GetLowerBorder());
-            pClonedMasterPage->ScaleObjects(aNewSize, aBorders, true);
-            pClonedMasterPage->SetSize(aNewSize);
-            pClonedMasterPage->CreateTitleAndLayout(true);
-        }
+        SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage()));
+        ProvideStyles(rSourceDocument, rTargetDocument, pClonedMasterPage);
+
+        // Now that the styles are available we can insert the cloned
+        // master page.
+        rTargetDocument.InsertMasterPage (pClonedMasterPage, nInsertionIndex);
+
+        // Adapt the size of the new master page to that of the pages in
+        // the document.
+        Size aNewSize (rTargetDocument.GetSdPage(0, pMasterPage->GetPageKind())->GetSize());
+        ::tools::Rectangle aBorders (
+            pClonedMasterPage->GetLeftBorder(),
+            pClonedMasterPage->GetUpperBorder(),
+            pClonedMasterPage->GetRightBorder(),
+            pClonedMasterPage->GetLowerBorder());
+        pClonedMasterPage->ScaleObjects(aNewSize, aBorders, true);
+        pClonedMasterPage->SetSize(aNewSize);
+        pClonedMasterPage->CreateTitleAndLayout(true);
     }
 
     return pClonedMasterPage;
@@ -406,25 +397,24 @@ void DocumentHelper::AssignMasterPageToPage (
     // Leave early when the parameters are invalid.
     if (pPage == nullptr || pMasterPage == nullptr)
         return;
-    SdDrawDocument* pDocument = dynamic_cast<SdDrawDocument*>(pPage->GetModel());
-    if (pDocument == nullptr)
-        return;
+
+    SdDrawDocument& rDocument(dynamic_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
 
     if ( ! pPage->IsMasterPage())
     {
         // 1. Remove the background object (so that, if it exists, does
         // not override the new master page) and assign the master page to
         // the regular slide.
-        pDocument->GetDocSh()->GetUndoManager()->AddUndoAction(
+        rDocument.GetDocSh()->GetUndoManager()->AddUndoAction(
             new SdBackgroundObjUndoAction(
-                *pDocument, *pPage, pPage->getSdrPageProperties().GetItemSet()),
+                rDocument, *pPage, pPage->getSdrPageProperties().GetItemSet()),
             true);
         pPage->getSdrPageProperties().PutItem(XFillStyleItem(drawing::FillStyle_NONE));
 
-        pDocument->SetMasterPage (
+        rDocument.SetMasterPage (
             (pPage->GetPageNum()-1)/2,
             rsBaseLayoutName,
-            pDocument,
+            &rDocument,
             false,
             false);
     }
@@ -432,10 +422,10 @@ void DocumentHelper::AssignMasterPageToPage (
     {
         // Find first slide that uses the master page.
         SdPage* pSlide = nullptr;
-        sal_uInt16 nPageCount = pDocument->GetSdPageCount(PageKind::Standard);
+        sal_uInt16 nPageCount = rDocument.GetSdPageCount(PageKind::Standard);
         for (sal_uInt16 nPage=0; nPage<nPageCount&&pSlide==nullptr; nPage++)
         {
-            SdrPage* pCandidate = pDocument->GetSdPage(nPage,PageKind::Standard);
+            SdrPage* pCandidate = rDocument.GetSdPage(nPage,PageKind::Standard);
             if (pCandidate != nullptr
                 && pCandidate->TRG_HasMasterPage()
                 && &(pCandidate->TRG_GetMasterPage()) == pPage)
@@ -448,10 +438,10 @@ void DocumentHelper::AssignMasterPageToPage (
         {
             // 2. Assign the given master pages to the first slide that was
             // found above that uses the master page.
-            pDocument->SetMasterPage (
+            rDocument.SetMasterPage (
                 (pSlide->GetPageNum()-1)/2,
                 rsBaseLayoutName,
-                pDocument,
+                &rDocument,
                 false,
                 false);
         }
@@ -459,7 +449,7 @@ void DocumentHelper::AssignMasterPageToPage (
         {
             // 3. Replace the master page A by a copy of the given master
             // page B.
-            pDocument->RemoveUnnecessaryMasterPages (
+            rDocument.RemoveUnnecessaryMasterPages (
                 pPage);
         }
     }
@@ -479,11 +469,9 @@ SdPage* DocumentHelper::ProvideMasterPage (
         OSL_ASSERT(pMasterPage != nullptr);
         return nullptr;
     }
-    SdDrawDocument* pSourceDocument = static_cast<SdDrawDocument*>(pMasterPage->GetModel());
-    if (pSourceDocument == nullptr)
-        return nullptr;
+    SdDrawDocument& rSourceDocument(static_cast< SdDrawDocument& >(pMasterPage->getSdrModelFromSdrPage()));
     SdPage* pNotesMasterPage = static_cast<SdPage*>(
-        pSourceDocument->GetMasterPage(pMasterPage->GetPageNum()+1));
+        rSourceDocument.GetMasterPage(pMasterPage->GetPageNum()+1));
     if (pNotesMasterPage == nullptr)
     {
         // The model is not in a valid state.  Maybe a new master page
@@ -521,7 +509,7 @@ SdPage* DocumentHelper::ProvideMasterPage (
     }
 
     // Clone the master page.
-    if (pMasterPage->GetModel() != &rTargetDocument)
+    if (&pMasterPage->getSdrModelFromSdrPage() != &rTargetDocument)
     {
         pMasterPageInDocument = AddMasterPage (rTargetDocument, pMasterPage, nInsertionIndex);
         if( rTargetDocument.IsUndoEnabled() )
@@ -532,7 +520,7 @@ SdPage* DocumentHelper::ProvideMasterPage (
         pMasterPageInDocument = pMasterPage;
 
     // Clone the notes master.
-    if (pNotesMasterPage->GetModel() != &rTargetDocument)
+    if (&pNotesMasterPage->getSdrModelFromSdrPage() != &rTargetDocument)
     {
         SdPage* pClonedNotesMasterPage
             = AddMasterPage (rTargetDocument, pNotesMasterPage, nInsertionIndex+1);
diff --git a/sd/source/ui/tools/PreviewRenderer.cxx b/sd/source/ui/tools/PreviewRenderer.cxx
index 143e2d02cb9e..44955efa2828 100644
--- a/sd/source/ui/tools/PreviewRenderer.cxx
+++ b/sd/source/ui/tools/PreviewRenderer.cxx
@@ -202,15 +202,9 @@ bool PreviewRenderer::Initialize (
     if (pPage == nullptr)
         return false;
 
-    SdrModel* pModel = pPage->GetModel();
-    if (pModel == nullptr)
-        return false;
-
     SetupOutputSize(*pPage, rPixelSize);
-
-    SdDrawDocument* pDocument
-        = static_cast<SdDrawDocument*>(pPage->GetModel());
-    DrawDocShell* pDocShell = pDocument->GetDocSh();
+    SdDrawDocument& rDocument(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
+    DrawDocShell* pDocShell = rDocument.GetDocSh();
 
     // Create view
     ProvideView (pDocShell);
@@ -260,9 +254,9 @@ bool PreviewRenderer::Initialize (
     }
 
     pPageView->SetApplicationDocumentColor(aApplicationDocumentColor);
-    SdrOutliner& rOutliner(pDocument->GetDrawOutliner());
+    SdrOutliner& rOutliner(rDocument.GetDrawOutliner());
     rOutliner.SetBackgroundColor(aApplicationDocumentColor);
-    rOutliner.SetDefaultLanguage(pDocument->GetLanguage(EE_CHAR_LANGUAGE));
+    rOutliner.SetDefaultLanguage(rDocument.GetLanguage(EE_CHAR_LANGUAGE));
     mpPreviewDevice->SetBackground(Wallpaper(aApplicationDocumentColor));
     mpPreviewDevice->Erase();
 
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 3ac7872fd6b3..cc07535eb4eb 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -407,23 +407,20 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap
         SdrObject* pObj = SvxFmDrawPage::CreateSdrObject_( xShape );
         if( pObj && ( (pObj->GetObjInventor() != SdrInventor::Default) || (pObj->GetObjIdentifier() != OBJ_PAGE) ) )
         {
-            SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(GetPage()->GetModel());
-            if( pDoc )
+            SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
+            // #i119287# similar to the code in the SdrObject methods the graphic and ole
+            // SdrObjects need another default style than the rest, see task. Adding here, too.
+            // TTTT: Same as for #i119287#: Can be removed in branch aw080 again
+            const bool bIsSdrGrafObj(dynamic_cast< const SdrGrafObj* >(pObj) !=  nullptr);
+            const bool bIsSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(pObj) !=  nullptr);
+
+            if(bIsSdrGrafObj || bIsSdrOle2Obj)
             {
-                // #i119287# similar to the code in the SdrObject methods the graphic and ole
-                // SdrObjects need another default style than the rest, see task. Adding here, too.
-                // TTTT: Same as for #i119287#: Can be removed in branch aw080 again
-                const bool bIsSdrGrafObj(dynamic_cast< const SdrGrafObj* >(pObj) !=  nullptr);
-                const bool bIsSdrOle2Obj(dynamic_cast< const SdrOle2Obj* >(pObj) !=  nullptr);
-
-                if(bIsSdrGrafObj || bIsSdrOle2Obj)
-                {
-                    pObj->NbcSetStyleSheet(pDoc->GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(), true);
-                }
-                else
-                {
-                    pObj->NbcSetStyleSheet(pDoc->GetDefaultStyleSheet(), true);
-                }
+                pObj->NbcSetStyleSheet(rDoc.GetDefaultStyleSheetForSdrGrafObjAndSdrOle2Obj(), true);
+            }
+            else
+            {
+                pObj->NbcSetStyleSheet(rDoc.GetDefaultStyleSheet(), true);
             }
         }
         return pObj;
@@ -519,9 +516,8 @@ SdrObject * SdGenericDrawPage::CreateSdrObject_( const Reference< drawing::XShap
         pPresObj = SvxFmDrawPage::CreateSdrObject_( xShape );
         if( pPresObj )
         {
-            SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(GetPage()->GetModel());
-            if( pDoc )
-                pPresObj->NbcSetStyleSheet( pDoc->GetDefaultStyleSheet(), true );
+            SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
+            pPresObj->NbcSetStyleSheet(rDoc.GetDefaultStyleSheet(), true);
             GetPage()->InsertPresObj( pPresObj, eObjKind );
         }
     }
@@ -686,21 +682,21 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
 
             if( eOri != GetPage()->GetOrientation() )
             {
-                SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(GetPage()->GetModel());
+                SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
                 const PageKind ePageKind = GetPage()->GetPageKind();
 
-                sal_uInt16 i, nPageCnt = pDoc->GetMasterSdPageCount(ePageKind);
+                sal_uInt16 i, nPageCnt = rDoc.GetMasterSdPageCount(ePageKind);
                 for (i = 0; i < nPageCnt; i++)
                 {
-                    SdPage* pPage = pDoc->GetMasterSdPage(i, ePageKind);
+                    SdPage* pPage = rDoc.GetMasterSdPage(i, ePageKind);
                     pPage->SetOrientation( eOri );
                 }
 
-                nPageCnt = pDoc->GetSdPageCount(ePageKind);
+                nPageCnt = rDoc.GetSdPageCount(ePageKind);
 
                 for (i = 0; i < nPageCnt; i++)
                 {
-                    SdPage* pPage = pDoc->GetSdPage(i, ePageKind);
+                    SdPage* pPage = rDoc.GetSdPage(i, ePageKind);
                     pPage->SetOrientation( eOri );
                 }
             }
@@ -782,10 +778,10 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
             SdrPage* pPage = GetPage();
             if( pPage )
             {
-                SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(pPage->GetModel());
-                if( pDoc->GetMasterPageCount() )
+                SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
+                if( rDoc.GetMasterPageCount() )
                 {
-                    SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
+                    SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
                     SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                     aVisibleLayers.Set(rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRND)), bVisible);
                     pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
@@ -802,10 +798,10 @@ void SAL_CALL SdGenericDrawPage::setPropertyValue( const OUString& aPropertyName
             SdrPage* pPage = GetPage();
             if( pPage )
             {
-                SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(pPage->GetModel());
-                if( pDoc->GetMasterPageCount() )
+                SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
+                if( rDoc.GetMasterPageCount() )
                 {
-                    SdrLayerAdmin& rLayerAdmin = pDoc->GetLayerAdmin();
+                    SdrLayerAdmin& rLayerAdmin = rDoc.GetLayerAdmin();
                     SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
                     aVisibleLayers.Set(rLayerAdmin.GetLayerID(SdResId(STR_LAYER_BCKGRNDOBJ)), bVisible);
                     pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
@@ -1101,39 +1097,36 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
     case WID_PAGE_PREVIEW :
     case WID_PAGE_PREVIEWMETAFILE :
         {
-            SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(GetPage()->GetModel());
-            if ( pDoc )
+            SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
+            ::sd::DrawDocShell* pDocShell = rDoc.GetDocSh();
+            if ( pDocShell )
             {
-                ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
-                if ( pDocShell )
+                sal_uInt16 nPgNum = 0;
+                sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard );
+                sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
+                while( nPgNum < nPageCount )
                 {
-                    sal_uInt16 nPgNum = 0;
-                    sal_uInt16 nPageCount = pDoc->GetSdPageCount( PageKind::Standard );
-                    sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
-                    while( nPgNum < nPageCount )
-                    {
-                        pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
-                        nPgNum++;
-                    }
-                    std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
-                    if (xMetaFile)
-                    {
-                        Size    aSize( GetPage()->GetSize() );
-                        xMetaFile->AddAction( static_cast<MetaAction*>(new MetaFillColorAction( COL_WHITE, true )), 0 );
-                        xMetaFile->AddAction( static_cast<MetaAction*>(new MetaRectAction( ::tools::Rectangle( Point(), aSize ) )), 1 );
-                        xMetaFile->SetPrefMapMode(MapMode(MapUnit::Map100thMM));
-                        xMetaFile->SetPrefSize( aSize );
-
-                        SvMemoryStream aDestStrm( 65535, 65535 );
-                        if (nEntry == WID_PAGE_PREVIEW)
-                            // Preview: WMF format.
-                            ConvertGDIMetaFileToWMF(*xMetaFile, aDestStrm, nullptr, false);
-                        else
-                            // PreviewMetafile: SVM format.
-                            xMetaFile->Write(aDestStrm);
-                        Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aDestStrm.GetData()), aDestStrm.Tell() );
-                        aAny <<= aSeq;
-                    }
+                    rDoc.SetSelected( rDoc.GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
+                    nPgNum++;
+                }
+                std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
+                if (xMetaFile)
+                {
+                    Size    aSize( GetPage()->GetSize() );
+                    xMetaFile->AddAction( static_cast<MetaAction*>(new MetaFillColorAction( COL_WHITE, true )), 0 );
+                    xMetaFile->AddAction( static_cast<MetaAction*>(new MetaRectAction( ::tools::Rectangle( Point(), aSize ) )), 1 );
+                    xMetaFile->SetPrefMapMode(MapMode(MapUnit::Map100thMM));
+                    xMetaFile->SetPrefSize( aSize );
+
+                    SvMemoryStream aDestStrm( 65535, 65535 );
+                    if (nEntry == WID_PAGE_PREVIEW)
+                        // Preview: WMF format.
+                        ConvertGDIMetaFileToWMF(*xMetaFile, aDestStrm, nullptr, false);
+                    else
+                        // PreviewMetafile: SVM format.
+                        xMetaFile->Write(aDestStrm);
+                    Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aDestStrm.GetData()), aDestStrm.Tell() );
+                    aAny <<= aSeq;
                 }
             }
         }
@@ -1141,29 +1134,26 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
 
     case WID_PAGE_PREVIEWBITMAP :
         {
-            SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(GetPage()->GetModel());
-            if ( pDoc )
+            SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(GetPage()->getSdrModelFromSdrPage()));
+            ::sd::DrawDocShell* pDocShell = rDoc.GetDocSh();
+            if ( pDocShell )
             {
-                ::sd::DrawDocShell* pDocShell = pDoc->GetDocSh();
-                if ( pDocShell )
+                sal_uInt16 nPgNum = 0;
+                sal_uInt16 nPageCount = rDoc.GetSdPageCount( PageKind::Standard );
+                sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
+                while( nPgNum < nPageCount )
                 {
-                    sal_uInt16 nPgNum = 0;
-                    sal_uInt16 nPageCount = pDoc->GetSdPageCount( PageKind::Standard );
-                    sal_uInt16 nPageNumber = static_cast<sal_uInt16>( ( GetPage()->GetPageNum() - 1 ) >> 1 );
-                    while( nPgNum < nPageCount )
-                    {
-                        pDoc->SetSelected( pDoc->GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
-                        nPgNum++;
-                    }
-                    std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
-                    BitmapEx aBitmap;
-                    if (xMetaFile && xMetaFile->CreateThumbnail(aBitmap))
-                    {
-                        SvMemoryStream aMemStream;
-                        WriteDIB(aBitmap.GetBitmap(), aMemStream, false, false);
-                        uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aMemStream.GetData()), aMemStream.Tell() );
-                        aAny <<= aSeq;
-                    }
+                    rDoc.SetSelected( rDoc.GetSdPage( nPgNum, PageKind::Standard ), nPgNum == nPageNumber );
+                    nPgNum++;
+                }
+                std::shared_ptr<GDIMetaFile> xMetaFile = pDocShell->GetPreviewMetaFile();
+                BitmapEx aBitmap;
+                if (xMetaFile && xMetaFile->CreateThumbnail(aBitmap))
+                {
+                    SvMemoryStream aMemStream;
+                    WriteDIB(aBitmap.GetBitmap(), aMemStream, false, false);
+                    uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aMemStream.GetData()), aMemStream.Tell() );
+                    aAny <<= aSeq;
                 }
             }
         }
@@ -1207,10 +1197,10 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
         SdrPage* pPage = GetPage();
         if( pPage )
         {
-            SdDrawDocument* pDoc = static_cast<SdDrawDocument*>(pPage->GetModel());
-            if( pDoc->GetMasterPageCount() )
+            SdDrawDocument& rDoc(static_cast< SdDrawDocument& >(pPage->getSdrModelFromSdrPage()));
+            if( rDoc.GetMasterPageCount() )
             {

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list