diff options
Diffstat (limited to 'include/svx')
56 files changed, 549 insertions, 310 deletions
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/cube3d.hxx b/include/svx/cube3d.hxx index 4a74777e0cff..95acaab386cd 100644 --- a/include/svx/cube3d.hxx +++ b/include/svx/cube3d.hxx @@ -54,17 +54,23 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC E3dCubeObj final : public E3dCompoundObject // BOOLeans bool bPosIsCenter : 1; - void SetDefaultAttributes(E3dDefaultAttributes& rDefault); + void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override; public: - E3dCubeObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& aPos, const basegfx::B3DVector& r3DSize); - E3dCubeObj(); + E3dCubeObj(SdrModel& rSdrModel, + const E3dDefaultAttributes& rDefault, + const basegfx::B3DPoint& aPos, + const basegfx::B3DVector& r3DSize); + E3dCubeObj(SdrModel& rSdrModel); virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual E3dCubeObj* Clone() const override; + virtual E3dCubeObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dCubeObj& operator=(const E3dCubeObj& rObj); // Set local parameters with geometry recreation void SetCubePos(const basegfx::B3DPoint& rNew); diff --git a/include/svx/deflt3d.hxx b/include/svx/deflt3d.hxx index e69a62a1625e..e08e9945fa96 100644 --- a/include/svx/deflt3d.hxx +++ b/include/svx/deflt3d.hxx @@ -65,13 +65,13 @@ public: void Reset(); // Cube object - const basegfx::B3DPoint& GetDefaultCubePos() { return aDefaultCubePos; } - const basegfx::B3DVector& GetDefaultCubeSize() { return aDefaultCubeSize; } + const basegfx::B3DPoint& GetDefaultCubePos() const { return aDefaultCubePos; } + const basegfx::B3DVector& GetDefaultCubeSize() const { return aDefaultCubeSize; } bool GetDefaultCubePosIsCenter() const { return bDefaultCubePosIsCenter; } // Sphere object - const basegfx::B3DPoint& GetDefaultSphereCenter() { return aDefaultSphereCenter; } - const basegfx::B3DVector& GetDefaultSphereSize() { return aDefaultSphereSize; } + const basegfx::B3DPoint& GetDefaultSphereCenter() const { return aDefaultSphereCenter; } + const basegfx::B3DVector& GetDefaultSphereSize() const { return aDefaultSphereSize; } // Lathe object bool GetDefaultLatheSmoothed() const { return bDefaultLatheSmoothed; } diff --git a/include/svx/e3dsceneupdater.hxx b/include/svx/e3dsceneupdater.hxx index ad01d667b4f5..e6800e845e01 100644 --- a/include/svx/e3dsceneupdater.hxx +++ b/include/svx/e3dsceneupdater.hxx @@ -50,7 +50,7 @@ class SVX_DLLPUBLIC E3DModifySceneSnapRectUpdater // of the to-be-changed 3D object when the scene has a 3d transformation // stack at construction time. In all other cases it's set to zero and // no action needs to be taken - E3dScene* mpScene; + E3dScene* mpScene; // the 3d transformation stack at the time of construction, valid when // mpScene is not zero @@ -58,7 +58,7 @@ class SVX_DLLPUBLIC E3DModifySceneSnapRectUpdater public: // the constructor evaluates and sets the members at construction time - E3DModifySceneSnapRectUpdater(const SdrObject* pObject); + E3DModifySceneSnapRectUpdater(const SdrObject* mpObject); // the destructor will take action if mpScene is not zero and modify the // 2D geomeztry of the target scene diff --git a/include/svx/e3dundo.hxx b/include/svx/e3dundo.hxx index 8be61b7b9e0e..17335ea1e8e0 100644 --- a/include/svx/e3dundo.hxx +++ b/include/svx/e3dundo.hxx @@ -31,17 +31,15 @@ \************************************************************************/ class SAL_WARN_UNUSED E3dUndoAction : public SdrUndoAction { - protected: - E3dObject *pMy3DObj; + E3dObject& mrMy3DObj; public: - E3dUndoAction (SdrModel *pModel, - E3dObject *p3DObj) : - SdrUndoAction (*pModel), - pMy3DObj (p3DObj) - { - } + E3dUndoAction(E3dObject &r3DObj) + : SdrUndoAction(r3DObj.getSdrModelFromSdrObject()), + mrMy3DObj(r3DObj) + { + } virtual ~E3dUndoAction () override; @@ -55,25 +53,25 @@ class SAL_WARN_UNUSED E3dUndoAction : public SdrUndoAction \************************************************************************/ class SAL_WARN_UNUSED E3dRotateUndoAction : public E3dUndoAction { - basegfx::B3DHomMatrix aMyOldRotation; - basegfx::B3DHomMatrix aMyNewRotation; - - public: - E3dRotateUndoAction (SdrModel *pModel, - E3dObject *p3DObj, - const basegfx::B3DHomMatrix &aOldRotation, - const basegfx::B3DHomMatrix &aNewRotation) : - E3dUndoAction (pModel, p3DObj), - aMyOldRotation (aOldRotation), - aMyNewRotation (aNewRotation) - { - } - - virtual ~E3dRotateUndoAction () override; - - virtual void Undo() override; - virtual void Redo() override; - +private: + basegfx::B3DHomMatrix maMyOldRotation; + basegfx::B3DHomMatrix maMyNewRotation; + +public: + E3dRotateUndoAction( + E3dObject& r3DObj, + const basegfx::B3DHomMatrix &aOldRotation, + const basegfx::B3DHomMatrix &aNewRotation) + : E3dUndoAction(r3DObj), + maMyOldRotation(aOldRotation), + maMyNewRotation(aNewRotation) + { + } + + virtual ~E3dRotateUndoAction () override; + + virtual void Undo() override; + virtual void Redo() override; }; /************************************************************************\ @@ -83,16 +81,16 @@ class SAL_WARN_UNUSED E3dRotateUndoAction : public E3dUndoAction \************************************************************************/ class SAL_WARN_UNUSED SVX_DLLPUBLIC E3dAttributesUndoAction : public SdrUndoAction { +private: using SdrUndoAction::Repeat; - SdrObject* pObject; - - const SfxItemSet aNewSet; - const SfxItemSet aOldSet; + SdrObject& mrObject; + const SfxItemSet maNewSet; + const SfxItemSet maOldSet; public: - E3dAttributesUndoAction( SdrModel &rModel, - E3dObject* pInObject, + E3dAttributesUndoAction( + E3dObject& rInObject, const SfxItemSet& rNewSet, const SfxItemSet& rOldSet); diff --git a/include/svx/extedit.hxx b/include/svx/extedit.hxx index 5ee2864a94a2..82afea29c83f 100644 --- a/include/svx/extedit.hxx +++ b/include/svx/extedit.hxx @@ -43,18 +43,20 @@ class FmFormView; class SdrObject; class SAL_WARN_UNUSED SVX_DLLPUBLIC SdrExternalToolEdit - : public ExternalToolEdit - , public SfxListener +: public ExternalToolEdit + ,public SfxListener { private: - FmFormView * m_pView; - SdrObject * m_pObj; + FmFormView* m_pView; + SdrObject* m_pObj; SAL_DLLPRIVATE virtual void Update(Graphic&) override; SAL_DLLPRIVATE virtual void Notify(SfxBroadcaster&, const SfxHint&) override; public: - SdrExternalToolEdit(FmFormView * pView, SdrObject * pObj); + SdrExternalToolEdit( + FmFormView* pView, + SdrObject* pObj); }; #endif diff --git a/include/svx/extrud3d.hxx b/include/svx/extrud3d.hxx index 1b78d4547740..5c121343af4d 100644 --- a/include/svx/extrud3d.hxx +++ b/include/svx/extrud3d.hxx @@ -40,12 +40,15 @@ private: virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override; virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override; - void SetDefaultAttributes(E3dDefaultAttributes const & rDefault); + void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); public: - - E3dExtrudeObj(E3dDefaultAttributes const & rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth); - E3dExtrudeObj(); + E3dExtrudeObj( + SdrModel& rSdrModel, + const E3dDefaultAttributes& rDefault, + const basegfx::B2DPolyPolygon& rPP, + double fDepth); + E3dExtrudeObj(SdrModel& rSdrModel); // PercentDiagonal: 0..100, before 0.0..0.5 sal_uInt16 GetPercentDiagonal() const @@ -81,7 +84,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; - virtual E3dExtrudeObj* Clone() const override; + virtual E3dExtrudeObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dExtrudeObj& operator=(const E3dExtrudeObj& rObj); // TakeObjName...() is for the display in the UI (for example "3 frames selected") virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/fmpage.hxx b/include/svx/fmpage.hxx index 808d814452b1..2605a6067517 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; @@ -52,10 +53,7 @@ public: explicit FmFormPage(FmFormModel& rModel, bool bMasterPage=false); virtual ~FmFormPage() override; - virtual void SetModel(SdrModel* pNewModel) override; - - virtual SdrPage* Clone() const override; - virtual SdrPage* Clone(SdrModel* pNewModel) const override; + virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const override; virtual void InsertObject(SdrObject* pObj, size_t nPos = SAL_MAX_SIZE) override; @@ -75,9 +73,8 @@ public: const HelpEvent& rEvt ); protected: - FmFormPage(const FmFormPage& rPage); - - void lateInit(const FmFormPage& rPage, FmFormModel* pNewModel = nullptr); + // lateInit -> copyValuesToClonedInstance (?) + void lateInit(const FmFormPage& rPage); }; #endif // INCLUDED_SVX_FMPAGE_HXX diff --git a/include/svx/fmview.hxx b/include/svx/fmview.hxx index a4245150337a..d0a7eb79836f 100644 --- a/include/svx/fmview.hxx +++ b/include/svx/fmview.hxx @@ -61,8 +61,10 @@ class SVX_DLLPUBLIC FmFormView : public E3dView void Init(); public: + FmFormView( + SdrModel& rSdrModel, + OutputDevice* pOut); - FmFormView(FmFormModel* pModel, OutputDevice* pOut); virtual ~FmFormView() override; /** create a control pair (label/bound control) for the database field description given. diff --git a/include/svx/graphctl.hxx b/include/svx/graphctl.hxx index 85ecc62e904f..f32454a56ae4 100644 --- a/include/svx/graphctl.hxx +++ b/include/svx/graphctl.hxx @@ -141,10 +141,13 @@ protected: } public: - GraphCtrlView(SdrModel* pModel, GraphCtrl* pWindow) - : SdrView(pModel, pWindow) - , rGraphCtrl(*pWindow) - {} + GraphCtrlView( + SdrModel& rSdrModel, + GraphCtrl* pWindow) + : SdrView(rSdrModel, pWindow) + ,rGraphCtrl(*pWindow) + { + } }; #endif // INCLUDED_SVX_GRAPHCTL_HXX diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx index 3c5a0e23b015..89df10369045 100644 --- a/include/svx/lathe3d.hxx +++ b/include/svx/lathe3d.hxx @@ -39,11 +39,14 @@ class SVX_DLLPUBLIC E3dLatheObj final : public E3dCompoundObject virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override; virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override; - void SetDefaultAttributes(E3dDefaultAttributes const & rDefault); + void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); public: - E3dLatheObj(E3dDefaultAttributes const & rDefault, const basegfx::B2DPolyPolygon& rPoly2D); - E3dLatheObj(); + E3dLatheObj( + SdrModel& rSdrModel, + const E3dDefaultAttributes& rDefault, + const basegfx::B2DPolyPolygon& rPoly2D); + E3dLatheObj(SdrModel& rSdrModel); // HorizontalSegments: sal_uInt32 GetHorizontalSegments() const @@ -87,7 +90,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; - virtual E3dLatheObj* Clone() const override; + virtual E3dLatheObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dLatheObj& operator=(const E3dLatheObj& rObj); virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx index 87117cc5d203..7ad18848d4cd 100644 --- a/include/svx/obj3d.hxx +++ b/include/svx/obj3d.hxx @@ -81,6 +81,8 @@ public: E3dObjList(); SVX_DLLPUBLIC virtual ~E3dObjList() 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; virtual SdrObject* NbcRemoveObject(size_t nObjNum) override; @@ -88,8 +90,7 @@ public: private: E3dObjList &operator=(const E3dObjList& rSrcList) = delete; - - SVX_DLLPUBLIC E3dObjList(const E3dObjList& rSrcList); + E3dObjList(const E3dObjList& rSrcList) = delete; }; /************************************************************************* @@ -131,7 +132,7 @@ protected: // E3dObject is only a helper class (for E3DScene and E3DCompoundObject) // and no instances should be created from anyone, so i move the constructors // to protected area - E3dObject(); + E3dObject(SdrModel& rSdrModel); public: virtual void RecalcSnapRect() override; @@ -148,7 +149,6 @@ public: virtual void SetObjList(SdrObjList* pNewObjList) override; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void NbcMove(const Size& rSize) override; virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; virtual SdrObjList* GetSubList() const override; @@ -183,7 +183,7 @@ public: // TakeObjName...() is for the display in the UI, for example "3 frames selected". virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual E3dObject* Clone() const override; + virtual E3dObject* Clone(SdrModel* pTargetModel = nullptr) const override; E3dObject& operator=( const E3dObject& rObj ); virtual SdrObjGeoData *NewGeoData() const override; @@ -232,7 +232,7 @@ protected: public: - E3dCompoundObject(); + E3dCompoundObject(SdrModel& rSdrModel); virtual ~E3dCompoundObject() override; virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; @@ -242,7 +242,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual void RecalcSnapRect() override; - virtual E3dCompoundObject* Clone() const override; + virtual E3dCompoundObject* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dCompoundObject& operator=(const E3dCompoundObject& rObj); bool IsAOrdNumRemapCandidate(E3dScene*& prScene) const; }; diff --git a/include/svx/polygn3d.hxx b/include/svx/polygn3d.hxx index 98778dd493e3..9f5acca38ce2 100644 --- a/include/svx/polygn3d.hxx +++ b/include/svx/polygn3d.hxx @@ -43,10 +43,11 @@ public: void SetPolyNormals3D(const basegfx::B3DPolyPolygon& rNewPolyPoly3D); void SetPolyTexture2D(const basegfx::B2DPolyPolygon& rNewPolyPoly2D); + E3dPolygonObj( + SdrModel& rSdrModel, + const basegfx::B3DPolyPolygon& rPolyPoly3D); + E3dPolygonObj(SdrModel& rSdrModel); - E3dPolygonObj(const basegfx::B3DPolyPolygon& rPolyPoly3D); - - E3dPolygonObj(); virtual ~E3dPolygonObj() override; const basegfx::B3DPolyPolygon& GetPolyPolygon3D() const { return aPolyPoly3D; } @@ -56,7 +57,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual E3dPolygonObj* Clone() const override; + virtual E3dPolygonObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dPolygonObj& operator=(const E3dPolygonObj& rObj); // LineOnly? bool GetLineOnly() const { return bLineOnly; } diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx index b6562093a6f1..eef2c0422ba9 100644 --- a/include/svx/scene3d.hxx +++ b/include/svx/scene3d.hxx @@ -90,7 +90,7 @@ protected: void ImpCleanup3DDepthMapper(); public: - E3dScene(); + E3dScene(SdrModel& rSdrModel); virtual ~E3dScene() override; virtual void SetBoundRectDirty() override; @@ -130,7 +130,7 @@ public: const Camera3D& GetCamera() const { return aCamera; } void removeAllNonSelectedObjects(); - virtual E3dScene* Clone() const override; + virtual E3dScene* Clone(SdrModel* pTargetModel = nullptr) const override; E3dScene& operator=(const E3dScene&); virtual SdrObjGeoData *NewGeoData() const override; diff --git a/include/svx/sdr/properties/defaultproperties.hxx b/include/svx/sdr/properties/defaultproperties.hxx index fec5963d4e7d..b3395386f833 100644 --- a/include/svx/sdr/properties/defaultproperties.hxx +++ b/include/svx/sdr/properties/defaultproperties.hxx @@ -54,6 +54,9 @@ namespace sdr // react on ItemSet changes virtual void ItemSetChanged(const SfxItemSet& rSet) override; + // check if SfxItemSet exists + bool HasSfxItemSet() const { return bool(mpItemSet); } + public: // basic constructor explicit DefaultProperties(SdrObject& rObj); diff --git a/include/svx/sdr/properties/properties.hxx b/include/svx/sdr/properties/properties.hxx index 71dad7f567fb..3bfca7630efe 100644 --- a/include/svx/sdr/properties/properties.hxx +++ b/include/svx/sdr/properties/properties.hxx @@ -44,6 +44,32 @@ namespace sdr } } +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// BaseProperties +// DefaultProperties ->SfxItemSet +// AttributeProperties ->SfxStyleSheet +// E3dProperties +// E3dCompoundProperties +// E3dExtrudeProperties +// E3dLatheProperties +// E3dSphereProperties +// E3dSceneProperties +// TextProperties ->maVersion +// ConnectorProperties +// CustomShapeProperties +// MeasureProperties +// RectangleProperties +// CaptionProperties +// CircleProperties +// GraphicProperties +// OleProperties +// CellProperties +// TableProperties +// GroupProperties +// EmptyProperties +// PageProperties + namespace sdr { namespace properties @@ -141,13 +167,6 @@ namespace sdr // Get the installed StyleSheet. virtual SfxStyleSheet* GetStyleSheet() const = 0; - // 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); - - // Set new model. - virtual void SetModel(SdrModel* pOldModel, SdrModel* pNewModel); - // force all attributes which come from styles to hard attributes // to be able to live without the style. virtual void ForceStyleToHardAttributes(); diff --git a/include/svx/sdr/table/tablecontroller.hxx b/include/svx/sdr/table/tablecontroller.hxx index 6a999a78b344..fe03d7353a2b 100644 --- a/include/svx/sdr/table/tablecontroller.hxx +++ b/include/svx/sdr/table/tablecontroller.hxx @@ -29,7 +29,7 @@ #include <svx/svdotable.hxx> #include <svx/svdview.hxx> -class SdrObjEditView; +class SdrView; class SdrObject; class SfxItemSet; class SvxBoxInfoItem; @@ -39,10 +39,12 @@ namespace sdr { namespace table { class TableModel; -class SVX_DLLPUBLIC SvxTableController: public sdr::SelectionController +class SVX_DLLPUBLIC SvxTableController : public sdr::SelectionController { public: - SVX_DLLPRIVATE SvxTableController( SdrObjEditView* pView, const SdrTableObj* pObj ); + SVX_DLLPRIVATE SvxTableController( + SdrView& rView, + const SdrTableObj& rObj); SVX_DLLPRIVATE virtual ~SvxTableController() override; // from sdr::SelectionController @@ -76,7 +78,10 @@ public: SVX_DLLPRIVATE void DistributeRows(); SVX_DLLPRIVATE void SetVertical( sal_uInt16 nSId ); - SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( SdrObjEditView* pView, const SdrTableObj* pObj, const rtl::Reference< sdr::SelectionController >& xRefController ); + SVX_DLLPRIVATE static rtl::Reference< sdr::SelectionController > create( + SdrView& rView, + const SdrTableObj& rObj, + const rtl::Reference< sdr::SelectionController >& xRefController); SVX_DLLPRIVATE void MergeAttrFromSelectedCells(SfxItemSet& rAttr, bool bOnlyHardAttr) const; SVX_DLLPRIVATE void SetAttrToSelectedCells(const SfxItemSet& rAttr, bool bReplaceAll); @@ -93,7 +98,7 @@ public: SVX_DLLPRIVATE virtual bool GetMarkedObjModel( SdrPage* pNewPage ) override; SVX_DLLPRIVATE virtual bool PasteObjModel( const SdrModel& rModel ) override; - SVX_DLLPRIVATE virtual bool hasSelectedCells() const override { return mbCellSelectionMode || mpView->IsTextEdit(); } + SVX_DLLPRIVATE virtual bool hasSelectedCells() const override { return mbCellSelectionMode || mrView.IsTextEdit(); } /// @see sdr::SelectionController::setCursorLogicPosition(). SVX_DLLPRIVATE virtual bool setCursorLogicPosition(const Point& rPosition, bool bPoint) override; @@ -174,17 +179,16 @@ private: CellPos maMouseDownPos; bool mbLeftButtonDown; sdr::overlay::OverlayObjectList* mpSelectionOverlay; - - SdrView* mpView; + SdrView& mrView; tools::WeakReference<SdrTableObj> mxTableObj; - SdrModel* mpModel; - css::uno::Reference< css::util::XModifyListener > mxModifyListener; - ImplSVEvent * mnUpdateEvent; }; -rtl::Reference< sdr::SelectionController > CreateTableController( SdrObjEditView* pView, const SdrTableObj* pObj, const rtl::Reference< sdr::SelectionController >& xRefController ); +rtl::Reference< sdr::SelectionController > CreateTableController( + SdrView& rView, + const SdrTableObj& rObj, + const rtl::Reference< sdr::SelectionController >& xRefController ); } } diff --git a/include/svx/sphere3d.hxx b/include/svx/sphere3d.hxx index 9c4bc5d21468..e5534e528fa9 100644 --- a/include/svx/sphere3d.hxx +++ b/include/svx/sphere3d.hxx @@ -35,16 +35,19 @@ private: virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override; virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override; - void SetDefaultAttributes(E3dDefaultAttributes& rDefault); + void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); public: - E3dSphereObj(E3dDefaultAttributes& rDefault, const basegfx::B3DPoint& rCenter, const basegfx::B3DVector& r3DSize); + E3dSphereObj( + SdrModel& rSdrModel, + const E3dDefaultAttributes& rDefault, + const basegfx::B3DPoint& rCenter, + const basegfx::B3DVector& r3DSize); // FG: This constructor is only called from MakeObject from the 3d-Objectfactory // when a document with a sphere is loaded. This constructor does not call // CreateSphere, or create any spheres. - enum Dummy { DUMMY }; - E3dSphereObj(Dummy dummy); + E3dSphereObj(SdrModel& rSdrModel); // horizontal segments: sal_uInt32 GetHorizontalSegments() const @@ -57,7 +60,10 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual SdrObject* DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual E3dSphereObj* Clone() const override; + virtual E3dSphereObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + E3dSphereObj& operator=(const E3dSphereObj& rObj); const basegfx::B3DPoint& Center() const { return aCenter; } const basegfx::B3DVector& Size() const { return aSize; } diff --git a/include/svx/svdcrtv.hxx b/include/svx/svdcrtv.hxx index 3b71a5088510..47858b29cf4e 100644 --- a/include/svx/svdcrtv.hxx +++ b/include/svx/svdcrtv.hxx @@ -31,7 +31,7 @@ class SdrObjConnection; class ImplConnectMarkerOverlay; class ImpSdrCreateViewExtraData; -class SVX_DLLPUBLIC SdrCreateView: public SdrDragView +class SVX_DLLPUBLIC SdrCreateView : public SdrDragView { friend class SdrPageView; @@ -69,7 +69,10 @@ protected: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrCreateView(SdrModel* pModel1, OutputDevice* pOut); + SdrCreateView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrCreateView() override; public: diff --git a/include/svx/svddrgv.hxx b/include/svx/svddrgv.hxx index 19b56414e9b0..180d8cc09269 100644 --- a/include/svx/svddrgv.hxx +++ b/include/svx/svddrgv.hxx @@ -25,7 +25,7 @@ class SdrUndoGeoObj; -class SVX_DLLPUBLIC SdrDragView: public SdrExchangeView +class SVX_DLLPUBLIC SdrDragView : public SdrExchangeView { friend class SdrPageView; friend class SdrDragMethod; @@ -69,7 +69,10 @@ protected: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrDragView(SdrModel* pModel1, OutputDevice* pOut); + SdrDragView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrDragView() override; public: diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx index 0c1e2f6a9dc1..51dbb4872e51 100644 --- a/include/svx/svdedtv.hxx +++ b/include/svx/svdedtv.hxx @@ -68,7 +68,7 @@ namespace o3tl template<> struct typed_flags<SdrInsertFlags> : is_typed_flags<SdrInsertFlags, 0x1f> {}; } -class SVX_DLLPUBLIC SdrEditView: public SdrMarkView +class SVX_DLLPUBLIC SdrEditView : public SdrMarkView { friend class SdrPageView; friend class SdrDragDistort; @@ -163,7 +163,10 @@ protected: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrEditView(SdrModel* pModel1, OutputDevice* pOut); + SdrEditView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrEditView() override; public: diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx index 324a611d96eb..70472aab20b2 100644 --- a/include/svx/svdedxv.hxx +++ b/include/svx/svdedxv.hxx @@ -58,7 +58,7 @@ enum class SdrEndTextEditKind // - macromod -class SVX_DLLPUBLIC SdrObjEditView: public SdrGlueEditView, public EditViewCallbacks +class SVX_DLLPUBLIC SdrObjEditView : public SdrGlueEditView, public EditViewCallbacks { friend class SdrPageView; friend class ImpSdrEditPara; @@ -150,7 +150,10 @@ protected: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrObjEditView(SdrModel* pModel1, OutputDevice* pOut); + SdrObjEditView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrObjEditView() override; public: diff --git a/include/svx/svdglev.hxx b/include/svx/svdglev.hxx index 10645f0a5aaa..be365e368c7e 100644 --- a/include/svx/svdglev.hxx +++ b/include/svx/svdglev.hxx @@ -29,7 +29,7 @@ class SdrGluePoint; // Edit GluePoints at the objects (GluePoints for connector) -class SVX_DLLPUBLIC SdrGlueEditView: public SdrPolyEditView +class SVX_DLLPUBLIC SdrGlueEditView : public SdrPolyEditView { // copy marked GluePoints and mark instead of the old ones void ImpCopyMarkedGluePoints(); @@ -40,7 +40,10 @@ class SVX_DLLPUBLIC SdrGlueEditView: public SdrPolyEditView protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrGlueEditView(SdrModel* pModel1, OutputDevice* pOut); + SdrGlueEditView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrGlueEditView() override; public: diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx index 981b1e29e5d1..36e80416087b 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -166,7 +166,10 @@ protected: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrMarkView(SdrModel* pModel1, OutputDevice* pOut); + SdrMarkView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrMarkView() override; public: diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index 85f5e9dc68ca..3ce7833ca8c8 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -98,15 +98,8 @@ public: css::uno::Reference< css::drawing::XCustomShapeEngine > const & GetCustomShapeEngine() const; -// SVX_DLLPRIVATE css::uno::Sequence< css::uno::Reference< css::drawing::XCustomShapeHandle > > -// SdrObjCustomShape::GetInteraction( const SdrObjCustomShape* pCustomShape ) const; -// #i47293# -// SVX_DLLPRIVATE std::vector< css::uno::Reference< css::drawing::XCustomShapeHandle > > GetFixedInteractionHandle() const; - SVX_DLLPRIVATE std::vector< SdrCustomShapeInteraction > GetInteractionHandles() const; - SVX_DLLPRIVATE void DragCreateObject( SdrDragStat& rDrag ); - SVX_DLLPRIVATE void DragResizeCustomShape( const tools::Rectangle& rNewRect ); SVX_DLLPRIVATE void DragMoveCustomShapeHdl( const Point& rDestination, const sal_uInt16 nCustomShapeHdlNum, bool bMoveCalloutRectangle ); @@ -147,7 +140,7 @@ public: double GetObjectRotation() const { return fObjectRotation;} double GetExtraTextRotation( const bool bPreRotation = false ) const; - SdrObjCustomShape(); + SdrObjCustomShape(SdrModel& rSdrModel); virtual ~SdrObjCustomShape() override; /* is merging default attributes from type-shape into the SdrCustomShapeGeometryItem. If pType @@ -172,8 +165,6 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; - virtual void SetModel(SdrModel* pNewModel) override; - virtual void Move(const Size& rSiz) override; virtual void Shear(const Point& rRef, long nAngle, double tn, bool bVShear) override; virtual void SetSnapRect(const tools::Rectangle& rRect) override; @@ -216,7 +207,7 @@ public: virtual void TakeTextAnchorRect( tools::Rectangle& rAnchorRect ) const override; virtual void TakeTextRect( SdrOutliner& rOutliner, tools::Rectangle& rTextRect, bool bNoEditText, tools::Rectangle* pAnchorRect, bool bLineWidth = true ) const override; - virtual SdrObjCustomShape* Clone() const override; + virtual SdrObjCustomShape* Clone(SdrModel* pTargetModel = nullptr) const override; SdrObjCustomShape& operator=(const SdrObjCustomShape& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdoattr.hxx b/include/svx/svdoattr.hxx index 10c163b3b9b0..a39a91957841 100644 --- a/include/svx/svdoattr.hxx +++ b/include/svx/svdoattr.hxx @@ -28,20 +28,14 @@ #include <svx/svdattr.hxx> #include <svx/svxdllapi.h> - // Initial Declarations - - class SfxPoolItem; class SfxSetItem; class SdrOutliner; class SfxItemSet; class SfxItemPool; - // SdrAttrObj - - class SVX_DLLPUBLIC SdrAttrObj : public SdrObject { private: @@ -59,7 +53,7 @@ protected: /// Detects when a stylesheet is changed virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; - SdrAttrObj(); + SdrAttrObj(SdrModel& rSdrModel); virtual ~SdrAttrObj() override; public: @@ -71,8 +65,6 @@ public: bool HasLine() const; virtual const tools::Rectangle& GetSnapRect() const override; - - virtual void SetModel(SdrModel* pNewModel) override; }; diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 3f01cbb82ff6..7d033605933a 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -74,10 +74,11 @@ class SdrLayerIDSet; class OutputDevice; class Fraction; -namespace basegfx { -class B2DPoint; -class B2DPolyPolygon; -class B2DHomMatrix; +namespace basegfx +{ + class B2DPoint; + class B2DPolyPolygon; + class B2DHomMatrix; } namespace sdr @@ -103,6 +104,8 @@ namespace svx class PropertyChangeNotifier; } +class SvxShape; + enum SdrObjKind { OBJ_NONE = 0, /// abstract object (SdrObject) OBJ_GRUP = 1, /// object group @@ -265,9 +268,45 @@ public: SdrObjTransformInfoRec(); }; -/// Abstract DrawObject +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// SdrObject +// SdrAttrObj +// E3dObject +// E3dCompoundObject +// E3dCubeObj +// E3dExtrudeObj +// E3dLatheObj +// E3dPolygonObj +// E3dSphereObj +// E3dScene +// SdrTextObj +// SdrObjCustomShape +// OCustomShape +// SdrEdgeObj +// SdrMeasureObj +// SdrPathObj +// SdrRectObj +// SdrCaptionObj +// SdrCircObj +// SdrGrafObj +// SdrMediaObj +// SdrOle2Obj +// OOle2Obj +// SdrUnoObj +// DlgEdObj +// DlgEdForm +// OUnoObject +// FmFormObj +// SdrTableObj +// SdrObjGroup +// SdrPageObj +// SdrVirtObj +// SwDrawVirtObj +// SwVirtFlyDrawObj +// SwFlyDrawObj -class SvxShape; +/// Abstract DrawObject class SVX_DLLPUBLIC SdrObject: public SfxListener, public virtual tools::WeakBase { private: @@ -296,8 +335,16 @@ private: public: const SdrObject* getFillGeometryDefiningShape() const { return mpFillGeometryDefiningShape; } +private: + // the SdrModel this objects was created with, unchanged during SdrObject lifetime + SdrModel& mrSdrModelFromSdrObject; + public: - SdrObject(); + // A SdrObject always needs a SdrModel for lifetime (Pool, ...) + SdrObject(SdrModel& rSdrModel); + + // SdrModel access on SdrObject level + SdrModel& getSdrModelFromSdrObject() const { return mrSdrModelFromSdrObject; } void AddObjectUser(sdr::ObjectUser& rNewUser); void RemoveObjectUser(sdr::ObjectUser& rOldUser); @@ -341,9 +388,6 @@ public: virtual void SetPage(SdrPage* pNewPage); SdrPage* GetPage() const { return pPage;} - - virtual void SetModel(SdrModel* pNewModel); - SdrModel* GetModel() const { return pModel;} SfxItemPool & GetObjectItemPool() const; void AddListener(SfxListener& rListener); @@ -438,7 +482,7 @@ public: // Returns a copy of the object. Every inherited class must reimplement this (in class Foo // it should be sufficient to do "virtual Foo* Clone() const { return CloneHelper< Foo >(); }". // Note that this function uses operator= internally. - virtual SdrObject* Clone() const; + virtual SdrObject* Clone(SdrModel* pTargetModel = nullptr) const; // implemented mainly for the purposes of Clone() SdrObject& operator=(const SdrObject& rObj); @@ -724,7 +768,9 @@ public: // when there is no filled new polygon created from line-to-polygon conversion, // specially used for XLINE_DASH and 3D conversion SdrObject* ConvertToContourObj(SdrObject* pRet, bool bForceLineDash = false) const; - static SdrObject* ImpConvertToContourObj(SdrObject* pRet, bool bForceLineDash); +private: + SdrObject* ImpConvertToContourObj(bool bForceLineDash); +public: // if true, reference onto an object bool IsVirtualObj() const { return bVirtObj;} @@ -762,9 +808,6 @@ public: // removes the record from the list and performs delete (FreeMem+Dtor). void DeleteUserData(sal_uInt16 nNum); - // switch ItemPool for this object - void MigrateItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel); - // access to the UNO representation of the shape virtual css::uno::Reference< css::uno::XInterface > getUnoShape(); @@ -867,7 +910,6 @@ protected: tools::Rectangle aOutRect; // surrounding rectangle for Paint (incl. LineWdt, ...) Point aAnchor; // anchor position (Writer) SdrPage* pPage; - SdrModel* pModel; SdrObjUserCall* pUserCall; std::unique_ptr<SdrObjPlusData> pPlusData; // Broadcaster, UserData, connectors, ... (this is the Bitsack) @@ -909,7 +951,6 @@ protected: void ImpForcePlusData(); - OUString GetAngleStr(long nAngle) const; OUString GetMetrStr(long nVal) const; /// A derived class must override these 3 methods if it has own geometric @@ -945,7 +986,7 @@ protected: virtual void impl_setUnoShape( const css::uno::Reference< css::uno::XInterface >& _rxUnoShape ); // helper function for reimplementing Clone(). - template< typename T > T* CloneHelper() const; + template< typename T > T* CloneHelper(SdrModel* pTargetModel) const; private: struct Impl; @@ -1006,6 +1047,7 @@ struct SdrObjCreatorParams { SdrInventor nInventor; sal_uInt16 nObjIdentifier; + SdrModel& rSdrModel; }; /** @@ -1019,23 +1061,40 @@ struct SdrObjCreatorParams class SVX_DLLPUBLIC SdrObjFactory { public: - static SdrObject* MakeNewObject(SdrInventor nInventor, sal_uInt16 nObjIdentifier, SdrPage* pPage, SdrModel* pModel=nullptr); - static SdrObject* MakeNewObject(SdrInventor nInventor, sal_uInt16 nObjIdentifier, const tools::Rectangle& rSnapRect, SdrPage* pPage); + static SdrObject* MakeNewObject( + SdrModel& rSdrModel, + SdrInventor nInventor, + sal_uInt16 nObjIdentifier, + SdrPage* pPage = nullptr, + const tools::Rectangle* pSnapRect = nullptr); + static void InsertMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink); static void RemoveMakeObjectHdl(Link<SdrObjCreatorParams, SdrObject*> const & rLink); private: - static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory( SdrInventor nInventor, sal_uInt16 nIdentifier ); + static SVX_DLLPRIVATE SdrObject* CreateObjectFromFactory( + SdrModel& rSdrModel, + SdrInventor nInventor, + sal_uInt16 nIdentifier); SdrObjFactory() = delete; }; -template< typename T > T* SdrObject::CloneHelper() const +template< typename T > T* SdrObject::CloneHelper(SdrModel* pTargetModel) const { OSL_ASSERT( typeid( T ) == typeid( *this )); - T* pObj = dynamic_cast< T* >( SdrObjFactory::MakeNewObject(GetObjInventor(),GetObjIdentifier(),nullptr)); - if (pObj!=nullptr) - *pObj=*static_cast< const T* >( this ); + T* pObj = dynamic_cast< T* >( + SdrObjFactory::MakeNewObject( + nullptr == pTargetModel ? getSdrModelFromSdrObject() : *pTargetModel, + GetObjInventor(), + GetObjIdentifier())); + + if(nullptr != pObj) + { + // use ::operator=() + *pObj = *static_cast< const T* >( this ); + } + return pObj; } diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx index 3dd68293708a..baa0e0390bd6 100644 --- a/include/svx/svdocapt.hxx +++ b/include/svx/svdocapt.hxx @@ -25,28 +25,20 @@ // Forward Declarations - - class ImpCaptParams; namespace sdr { namespace properties { class CaptionProperties; }} - // Helper Class SdrCaptObjGeoData - - class SdrCaptObjGeoData : public SdrTextObjGeoData { public: tools::Polygon aTailPoly; }; - // SdrCaptionObj - - class SVX_DLLPUBLIC SdrCaptionObj : public SdrRectObj { private: @@ -73,13 +65,20 @@ private: SVX_DLLPRIVATE void ImpRecalcTail(); public: - SdrCaptionObj(); - SdrCaptionObj(const tools::Rectangle& rRect, const Point& rTail); + SdrCaptionObj(SdrModel& rSdrModel); + SdrCaptionObj( + SdrModel& rSdrModel, + const tools::Rectangle& rRect, + const Point& rTail); + virtual ~SdrCaptionObj() override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; - virtual SdrCaptionObj* Clone() const override; + virtual SdrCaptionObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + SdrCaptionObj& operator=(const SdrCaptionObj& rObj); // for calc: special shadow only for text box void SetSpecialTextBoxShadow() { mbSpecialTextBoxShadow = true; } @@ -92,7 +91,6 @@ public: virtual OUString TakeObjNamePlural() const override; virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; virtual sal_uInt32 GetHdlCount() const override; diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx index d3bc9c2116f5..fc3045585aa6 100644 --- a/include/svx/svdocirc.hxx +++ b/include/svx/svdocirc.hxx @@ -66,14 +66,25 @@ private: virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; public: - SdrCircObj(SdrObjKind eNewKind); // Circ, CArc, Sect or CCut - SdrCircObj(SdrObjKind eNewKind, const tools::Rectangle& rRect); + SdrCircObj( + SdrModel& rSdrModel, + SdrObjKind eNewKind); // Circ, CArc, Sect or CCut + SdrCircObj( + SdrModel& rSdrModel, + SdrObjKind eNewKind, + const tools::Rectangle& rRect); // 0=0.00Deg=3h 9000=90.00Deg=12h 18000=180.00Deg=9h 27000=270.00Deg=6h // The circle is build up from StartAngle to EndWink anti-clockwise. // If nNewStartAngle==nNewEndWink, then arc has an angle of 0 degrees. // If nNewStartAngle+36000==nNewEndWink, then the arc has angle of 360 degrees. - SdrCircObj(SdrObjKind eNewKind, const tools::Rectangle& rRect, long nNewStartAngle, long nNewEndWink); + SdrCircObj( + SdrModel& rSdrModel, + SdrObjKind eNewKind, + const tools::Rectangle& rRect, + long nNewStartAngle, + long nNewEndWink); + virtual ~SdrCircObj() override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; @@ -83,7 +94,11 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrCircObj* Clone() const override; + virtual SdrCircObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + SdrCircObj& operator=(const SdrCircObj& rObj); + virtual void RecalcSnapRect() override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx index 5b11da0feaef..ae28ad7103be 100644 --- a/include/svx/svdoedge.hxx +++ b/include/svx/svdoedge.hxx @@ -187,8 +187,7 @@ protected: void ImpSetEdgeInfoToAttr(); // copying values from the aEdgeInfo to the pool public: - - SdrEdgeObj(); + SdrEdgeObj(SdrModel& rSdrModel); virtual ~SdrEdgeObj() override; SdrObjConnection& GetConnection(bool bTail1) { return *(bTail1 ? &aCon1 : &aCon2); } @@ -214,7 +213,7 @@ public: virtual void RecalcSnapRect() override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual SdrEdgeObj* Clone() const override; + virtual SdrEdgeObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrEdgeObj& operator=(const SdrEdgeObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 65b934847489..d11a289060f8 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -129,10 +129,16 @@ private: public: - SdrGrafObj(); - SdrGrafObj(const Graphic& rGrf); - SdrGrafObj(const Graphic& rGrf, const tools::Rectangle& rRect); - virtual ~SdrGrafObj() override; + SdrGrafObj(SdrModel& rSdrModel); + SdrGrafObj( + SdrModel& rSdrModel, + const Graphic& rGrf); + SdrGrafObj( + SdrModel& rSdrModel, + const Graphic& rGrf, + const tools::Rectangle& rRect); + + virtual ~SdrGrafObj() override; void SetGraphicObject( const GraphicObject& rGrfObj ); const GraphicObject& GetGraphicObject(bool bForceSwapIn = false) const; @@ -143,9 +149,7 @@ public: const Graphic& GetGraphic() const; Graphic GetTransformedGraphic( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const; - GraphicType GetGraphicType() const; - GraphicAttr GetGraphicAttr( SdrGrafObjTransformsAttrs nTransformFlags = SdrGrafObjTransformsAttrs::ALL ) const; // Keep ATM for SD. @@ -182,7 +186,7 @@ public: // #i25616# virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; - virtual SdrGrafObj* Clone() const override; + virtual SdrGrafObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrGrafObj& operator=(const SdrGrafObj& rObj); virtual sal_uInt32 GetHdlCount() const override; @@ -197,7 +201,6 @@ public: bool HasGDIMetaFile() const; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; bool isEmbeddedVectorGraphicData() const; GDIMetaFile getMetafileFromEmbeddedVectorGraphicData() const; diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx index f15a9b92fb47..7f0fb234f972 100644 --- a/include/svx/svdogrp.hxx +++ b/include/svx/svdogrp.hxx @@ -23,30 +23,23 @@ #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(); + SdrObjGroup(SdrModel& rSdrModel); virtual ~SdrObjGroup() override; virtual void SetBoundRectDirty() override; @@ -56,13 +49,12 @@ public: virtual void NbcSetLayer(SdrLayerID nLayer) override; virtual void SetObjList(SdrObjList* pNewObjList) override; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual SdrObjList* GetSubList() const override; virtual const tools::Rectangle& GetCurrentBoundRect() const override; virtual const tools::Rectangle& GetSnapRect() const override; - virtual SdrObjGroup* Clone() const override; + virtual SdrObjGroup* Clone(SdrModel* pTargetModel = nullptr) const override; SdrObjGroup& operator=(const SdrObjGroup& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index be2ce849890b..00a4a9567546 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -85,14 +85,20 @@ protected: virtual void RestGeoData(const SdrObjGeoData& rGeo) override; public: - SdrMeasureObj(); - SdrMeasureObj(const Point& rPt1, const Point& rPt2); + SdrMeasureObj(SdrModel& rSdrModel); + SdrMeasureObj( + SdrModel& rSdrModel, + const Point& rPt1, + const Point& rPt2); virtual ~SdrMeasureObj() override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual SdrMeasureObj* Clone() const override; + virtual SdrMeasureObj* Clone(SdrModel* pTargetModel = nullptr) const override; + + // implemented mainly for the purposes of Clone() + SdrMeasureObj& operator=(const SdrMeasureObj& rObj); virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx index 43356da4e302..a45410f76bdf 100644 --- a/include/svx/svdomedia.hxx +++ b/include/svx/svdomedia.hxx @@ -37,10 +37,12 @@ class SVX_DLLPUBLIC SdrMediaObj final : public SdrRectObj public: - SdrMediaObj(); - SdrMediaObj( const tools::Rectangle& rRect ); + SdrMediaObj(SdrModel& rSdrModel); + SdrMediaObj( + SdrModel& rSdrModel, + const tools::Rectangle& rRect); - virtual ~SdrMediaObj() override; + virtual ~SdrMediaObj() override; virtual bool HasTextEdit() const override; @@ -50,7 +52,7 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrMediaObj* Clone() const override; + virtual SdrMediaObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrMediaObj& operator=(const SdrMediaObj& rObj); virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override; diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx index edeccfa5984a..b170f6ac6d03 100644 --- a/include/svx/svdoole2.hxx +++ b/include/svx/svdoole2.hxx @@ -60,6 +60,8 @@ private: SVX_DLLPRIVATE SdrObject* createSdrGrafObjReplacement(bool bAddText) const; SVX_DLLPRIVATE void ImpSetVisAreaSize(); + SVX_DLLPRIVATE void Init(); + protected: virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override; virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override; @@ -67,8 +69,15 @@ protected: public: OUString GetStyleString(); - SdrOle2Obj( bool bFrame_ = false ); - SdrOle2Obj( const svt::EmbeddedObjectRef& rNewObjRef, const OUString& rNewObjName, const tools::Rectangle& rNewRect ); + SdrOle2Obj( + SdrModel& rSdrModel, + bool bFrame_ = false); + SdrOle2Obj( + SdrModel& rSdrModel, + const svt::EmbeddedObjectRef& rNewObjRef, + const OUString& rNewObjName, + const tools::Rectangle& rNewRect); + virtual ~SdrOle2Obj() override; const svt::EmbeddedObjectRef& getEmbeddedObjectRef() const; @@ -112,7 +121,6 @@ public: void AbandonObject(); virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pModel) override; /** Change the IsClosedObj attribute @@ -129,7 +137,7 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrOle2Obj* Clone() const override; + virtual SdrOle2Obj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrOle2Obj& assignFrom(const SdrOle2Obj& rObj); SdrOle2Obj& operator=(const SdrOle2Obj& rObj); diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx index 8893e812d783..1f349a9a38ad 100644 --- a/include/svx/svdopage.hxx +++ b/include/svx/svdopage.hxx @@ -41,8 +41,14 @@ protected: virtual sdr::properties::BaseProperties* CreateObjectSpecificProperties() override; public: - SdrPageObj(SdrPage* pNewPage = nullptr); - SdrPageObj(const tools::Rectangle& rRect, SdrPage* pNewPage = nullptr); + SdrPageObj( + SdrModel& rSdrModel, + SdrPage* pNewPage = nullptr); + SdrPageObj( + SdrModel& rSdrModel, + const tools::Rectangle& rRect, + SdrPage* pNewPage = nullptr); + virtual ~SdrPageObj() override; SdrPage* GetReferencedPage() const { return mpShownPage;} @@ -53,7 +59,7 @@ public: virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; - virtual SdrPageObj* Clone() const override; + virtual SdrPageObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrPageObj& operator=(const SdrPageObj& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx index e32ccf5116df..6c21fd06571a 100644 --- a/include/svx/svdopath.hxx +++ b/include/svx/svdopath.hxx @@ -62,14 +62,20 @@ private: ImpPathForDragAndCreate& impGetDAC() const; public: - SdrPathObj(SdrObjKind eNewKind); - SdrPathObj(SdrObjKind eNewKind, const basegfx::B2DPolyPolygon& rPathPoly); + SdrPathObj( + SdrModel& rSdrModel, + SdrObjKind eNewKind); + SdrPathObj( + SdrModel& rSdrModel, + SdrObjKind eNewKind, + const basegfx::B2DPolyPolygon& rPathPoly); + virtual ~SdrPathObj() override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual SdrPathObj* Clone() const override; + virtual SdrPathObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrPathObj& operator=(const SdrPathObj& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx index 729d3f221a05..f9c1c34fd145 100644 --- a/include/svx/svdorect.hxx +++ b/include/svx/svdorect.hxx @@ -66,14 +66,22 @@ public: * * Constructor of a rectangular drawing object */ - SdrRectObj(); - SdrRectObj(const tools::Rectangle& rRect); + SdrRectObj(SdrModel& rSdrModel); + SdrRectObj( + SdrModel& rSdrModel, + const tools::Rectangle& rRect); SdrRectObj& operator=(const SdrRectObj& rCopy); // Constructor of a text frame - SdrRectObj(SdrObjKind eNewTextKind); - SdrRectObj(SdrObjKind eNewTextKind, const tools::Rectangle& rRect); + SdrRectObj( + SdrModel& rSdrModel, + SdrObjKind eNewTextKind); + SdrRectObj( + SdrModel& rSdrModel, + SdrObjKind eNewTextKind, + const tools::Rectangle& rRect); + virtual ~SdrRectObj() override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; @@ -83,7 +91,7 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrRectObj* Clone() const override; + virtual SdrRectObj* Clone(SdrModel* pTargetModel = nullptr) const override; virtual void RecalcSnapRect() override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override; diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index c33551cccac7..7c5e30ec4e8d 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -98,13 +98,20 @@ class SVX_DLLPUBLIC SdrTableObj : public ::SdrTextObj friend class SdrTableObjImpl; public: - SdrTableObj(SdrModel* _pModel); - SdrTableObj(SdrModel* _pModel, const ::tools::Rectangle& rNewRect, sal_Int32 nColumns, sal_Int32 nRows); - virtual ~SdrTableObj() override; + SdrTableObj(SdrModel& rSdrModel); + SdrTableObj( + SdrModel& rSdrModel, + const ::tools::Rectangle& rNewRect, + sal_Int32 nColumns, + sal_Int32 nRows); + virtual ~SdrTableObj() override; // Table stuff - SdrTableObj* CloneRange( const CellPos& rStartPos, const CellPos& rEndPos ); + SdrTableObj* CloneRange( + const CellPos& rStartPos, + const CellPos& rEndPos, + SdrModel& rTargetModel); void DistributeColumns( sal_Int32 nFirstColumn, sal_Int32 nLastColumn ); void DistributeRows( sal_Int32 nFirstRow, sal_Int32 nLastRow ); @@ -184,7 +191,6 @@ public: virtual bool IsFontwork() const override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; virtual void SetChanged() override; @@ -193,7 +199,7 @@ public: virtual bool AdjustTextFrameWidthAndHeight() override; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrTableObj* Clone() const override; + virtual SdrTableObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrTableObj& operator=(const SdrTableObj& rObj); virtual void RecalcSnapRect() override; virtual const tools::Rectangle& GetSnapRect() const override; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 277f51ebba2c..13ff8940d0c1 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -136,16 +136,13 @@ class SVX_DLLPUBLIC SdrTextObj : public SdrAttrObj, public svx::ITextProvider { private: // Cell needs access to ImpGetDrawOutliner(); - friend class sdr::table::Cell; friend class sdr::table::SdrTableRtfExporter; friend class sdr::table::SdrTableRTFParser; - friend class TextChain; friend class TextChainFlow; friend class EditingTextChainFlow; - // CustomShapeproperties need to access the "bTextFrame" member: friend class sdr::properties::CustomShapeProperties; @@ -272,7 +269,6 @@ private: SVX_DLLPRIVATE void ImpRegisterLink(); SVX_DLLPRIVATE void ImpDeregisterLink(); SVX_DLLPRIVATE ImpSdrObjTextLinkUserData* GetLinkUserData() const; -// void ImpCheckItemSetChanges(const SfxItemSet& rAttr); /** Appends the style family to a provided style name */ static void AppendFamilyToStyleName(OUString& styleName, SfxStyleFamily family); @@ -306,12 +302,19 @@ protected: virtual void AdaptTextMinSize(); // constructors for labeled graphical objects - SdrTextObj(); - SdrTextObj(const tools::Rectangle& rNewRect); + SdrTextObj(SdrModel& rSdrModel); + SdrTextObj( + SdrModel& rSdrModel, + const tools::Rectangle& rNewRect); // constructors for text frames - SdrTextObj(SdrObjKind eNewTextKind); - SdrTextObj(SdrObjKind eNewTextKind, const tools::Rectangle& rNewRect); + SdrTextObj( + SdrModel& rSdrModel, + SdrObjKind eNewTextKind); + SdrTextObj( + SdrModel& rSdrModel, + SdrObjKind eNewTextKind, + const tools::Rectangle& rNewRect); virtual ~SdrTextObj() override; @@ -434,7 +437,6 @@ public: SdrTextAniDirection GetTextAniDirection() const; virtual void SetPage(SdrPage* pNewPage) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; @@ -442,7 +444,7 @@ public: virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual SdrTextObj* Clone() const override; + virtual SdrTextObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrTextObj& operator=(const SdrTextObj& rObj); virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; virtual basegfx::B2DPolyPolygon TakeContour() const override; diff --git a/include/svx/svdouno.hxx b/include/svx/svdouno.hxx index 48098ae65b37..d9dfb5d6acd2 100644 --- a/include/svx/svdouno.hxx +++ b/include/svx/svdouno.hxx @@ -61,15 +61,19 @@ private: public: - explicit SdrUnoObj(const OUString& rModelName); - SdrUnoObj(const OUString& rModelName, + explicit SdrUnoObj( + SdrModel& rSdrModel, + const OUString& rModelName); + SdrUnoObj( + SdrModel& rSdrModel, + const OUString& rModelName, const css::uno::Reference< css::lang::XMultiServiceFactory >& rxSFac); virtual ~SdrUnoObj() override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual sal_uInt16 GetObjIdentifier() const override; - virtual SdrUnoObj* Clone() const override; + virtual SdrUnoObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrUnoObj& operator= (const SdrUnoObj& rObj); virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override; virtual void NbcSetLayer(SdrLayerID nLayer) override; @@ -77,10 +81,6 @@ public: // SpecialDrag support virtual bool hasSpecialDrag() const override; - // FullDrag support - virtual bool supportsFullDrag() const override; - virtual SdrObject* getFullDragClone() const override; - virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx index c6d626e1305f..9e4e6d9ed179 100644 --- a/include/svx/svdovirt.hxx +++ b/include/svx/svdovirt.hxx @@ -37,7 +37,7 @@ protected: virtual sdr::contact::ViewContact* CreateObjectSpecificViewContact() override; SdrObject& rRefObj; // Referenced drawing object - tools::Rectangle aSnapRect; + tools::Rectangle aSnapRect; protected: virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; @@ -47,12 +47,14 @@ protected: virtual void RestGeoData(const SdrObjGeoData& rGeo) override; public: - SdrVirtObj(SdrObject& rNewObj); + SdrVirtObj( + SdrModel& rSdrModel, + SdrObject& rNewObj); virtual ~SdrVirtObj() override; + SdrObject& ReferencedObj(); const SdrObject& GetReferencedObj() const; virtual void NbcSetAnchorPos(const Point& rAnchorPos) override; - virtual void SetModel(SdrModel* pNewModel) override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual SdrInventor GetObjInventor() const override; @@ -62,7 +64,7 @@ public: virtual const tools::Rectangle& GetCurrentBoundRect() const override; virtual const tools::Rectangle& GetLastBoundRect() const override; virtual void RecalcBoundRect() override; - virtual SdrVirtObj* Clone() const override; + virtual SdrVirtObj* Clone(SdrModel* pTargetModel = nullptr) const override; SdrVirtObj& operator=(const SdrVirtObj& rObj); virtual OUString TakeObjNameSingul() const override; diff --git a/include/svx/svdpage.hxx b/include/svx/svdpage.hxx index 1a7fdb59a7fa..1ea8f1f57358 100644 --- a/include/svx/svdpage.hxx +++ b/include/svx/svdpage.hxx @@ -53,21 +53,26 @@ class Color; class SfxStyleSheet; class SvxUnoDrawPagesAccess; -// class SdrObjList +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// SdrObjList +// E3dObjList +// SdrPage -> see continuation there +// class SdrObjList class SVX_DLLPUBLIC SdrObjList { +private: SdrObjList(const SdrObjList& rSrcList) = delete; SdrObjList &operator=(const SdrObjList& rSrcList) = delete; private: - ::std::vector<SdrObject*> maList; + ::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; @@ -75,20 +80,20 @@ friend class SdrEditView; SdrObjListKind eListKind; bool bObjOrdNumsDirty; bool bRectsDirty; + protected: void RecalcRects(); - - SdrObjList(); - 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* pNewModel, SdrPage* pNewPage); + SdrObjList(SdrPage* pNewPage = nullptr); virtual ~SdrObjList(); + virtual SdrObjList* CloneSdrObjList(SdrModel* pNewModel = nullptr) const; - 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; } @@ -99,8 +104,7 @@ public: void SetOwnerObj(SdrObject* pNewOwner) { pOwnerObj=pNewOwner; } SdrPage* GetPage() const; void SetPage(SdrPage* pNewPage); - SdrModel* GetModel() const; - virtual void SetModel(SdrModel* pNewModel); + /// recalculate order numbers / ZIndex void RecalcObjOrdNums(); bool IsObjOrdNumsDirty() const { return bObjOrdNumsDirty; } @@ -348,6 +352,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# @@ -358,7 +373,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: @@ -371,6 +387,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: @@ -381,6 +400,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 @@ -420,14 +443,13 @@ 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); + void lateInit(const SdrPage& rSrcPage); public: - explicit SdrPage(SdrModel& rNewModel, bool bMasterPage=false); + explicit SdrPage(SdrModel& rModel, bool bMasterPage=false); virtual ~SdrPage() override; - virtual SdrPage* Clone() const; - virtual SdrPage* Clone(SdrModel* pNewModel) const; + + virtual SdrPage* Clone(SdrModel* pNewModel = nullptr) const; bool IsMasterPage() const { return mbMaster; } void SetInserted(bool bNew = true); bool IsInserted() const { return mbInserted; } @@ -458,8 +480,6 @@ public: sal_Int32 GetRightBorder() const; sal_Int32 GetLowerBorder() const; - virtual void SetModel(SdrModel* pNewModel) override; - // New MasterPage interface bool TRG_HasMasterPage() const { return (nullptr != mpMasterPageDescriptor); } void TRG_SetMasterPage(SdrPage& rNew); @@ -505,9 +525,6 @@ public: const sdr::contact::ViewObjectContact& rOriginal, const sdr::contact::DisplayInfo& rDisplayInfo, bool bEdit ); - -private: - void impl_setModelForLayerAdmin(SdrModel* pNewModel); }; diff --git a/include/svx/svdpntv.hxx b/include/svx/svdpntv.hxx index eb48416af426..2405ad9ca4b5 100644 --- a/include/svx/svdpntv.hxx +++ b/include/svx/svdpntv.hxx @@ -100,12 +100,39 @@ BitmapEx SVX_DLLPUBLIC convertMetafileToBitmapEx( const basegfx::B2DRange& rTargetRange, const sal_uInt32 nMaximumQuadraticPixels); +//////////////////////////////////////////////////////////////////////////////////////////////////// +// +// SdrPaintView +// SdrSnapView +// SdrMarkView +// SdrEditView +// SdrPolyEditView +// SdrGlueEditView +// SdrObjEditView +// SdrExchangeView +// SdrDragView +// SdrCreateView +// SdrView +// DlgEdView +// GraphCtrlView +// E3dView +// DrawViewWrapper +// FmFormView +// ScDrawView +// sd::View (may have more?) +// sd::DrawView +// SwDrawView +// OSectionView class SVX_DLLPUBLIC SdrPaintView : public SfxListener, public SfxRepeatTarget, public SfxBroadcaster, public ::utl::ConfigurationListener { +private: friend class SdrPageView; friend class SdrGrafObj; + // the SdrModel this view was created with, unchanged during lifetime + SdrModel& mrSdrModelFromSdrView; + SdrPageView* mpPageView; protected: SdrModel* mpModel; @@ -238,10 +265,13 @@ protected: virtual void ModelHasChanged(); // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrPaintView(SdrModel* pModel1, OutputDevice* pOut); + // A SdrView always needs a SdrModel for lifetime (Pool, ...) + SdrPaintView(SdrModel& rSdrModel, OutputDevice* pOut); virtual ~SdrPaintView() override; public: + // SdrModel access on SdrView level + SdrModel& getSdrModelFromSdrView() const { return mrSdrModelFromSdrView; } virtual void ClearPageView(); SdrModel* GetModel() const { return mpModel; } diff --git a/include/svx/svdpoev.hxx b/include/svx/svdpoev.hxx index c7a33bac1683..187eadd4ca12 100644 --- a/include/svx/svdpoev.hxx +++ b/include/svx/svdpoev.hxx @@ -25,7 +25,7 @@ #include <svx/ipolypolygoneditorcontroller.hxx> -class SVX_DLLPUBLIC SdrPolyEditView: public SdrEditView, public IPolyPolygonEditorController +class SVX_DLLPUBLIC SdrPolyEditView : public SdrEditView, public IPolyPolygonEditorController { friend class SdrEditView; @@ -45,7 +45,10 @@ private: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrPolyEditView(SdrModel* pModel1, OutputDevice* pOut); + SdrPolyEditView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrPolyEditView() override; public: diff --git a/include/svx/svdsnpv.hxx b/include/svx/svdsnpv.hxx index a90bdf34d392..0a40c9ac59ac 100644 --- a/include/svx/svdsnpv.hxx +++ b/include/svx/svdsnpv.hxx @@ -90,7 +90,7 @@ enum class SdrCrookMode { // #114409#-1 Migrate PageOrigin class ImplPageOriginOverlay; -class SVX_DLLPUBLIC SdrSnapView: public SdrPaintView +class SVX_DLLPUBLIC SdrSnapView : public SdrPaintView { protected: // #114409#-1 Migrate PageOrigin @@ -127,7 +127,10 @@ protected: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrSnapView(SdrModel* pModel1, OutputDevice* pOut); + SdrSnapView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~SdrSnapView() override; public: diff --git a/include/svx/svdtext.hxx b/include/svx/svdtext.hxx index 020d8a483b4b..11b91f028fb8 100644 --- a/include/svx/svdtext.hxx +++ b/include/svx/svdtext.hxx @@ -47,7 +47,6 @@ public: explicit SdrText( SdrTextObj& rObject ); virtual ~SdrText() override; - virtual void SetModel(SdrModel* pNewModel); void ForceOutlinerParaObject( OutlinerMode nOutlMode ); virtual void SetOutlinerParaObject( OutlinerParaObject* pTextObject ); @@ -60,7 +59,8 @@ public: // return a text-specific ItemSet virtual const SfxItemSet& GetItemSet() const; - SdrModel* GetModel() const { return mpModel; } + // This class does not need an own SdrModel reference - always + // has the SdrTextObj working with so can use SdrModel::getSdrModelFromSdrObject() SdrTextObj& GetObject() const { return mrObject; } /** returns the current OutlinerParaObject and removes it from this instance */ @@ -76,7 +76,6 @@ protected: private: std::unique_ptr<OutlinerParaObject> mpOutlinerParaObject; SdrTextObj& mrObject; - SdrModel* mpModel; bool mbPortionInfoChecked; }; diff --git a/include/svx/svdview.hxx b/include/svx/svdview.hxx index e9d0f51aa476..2bab7eaed548 100644 --- a/include/svx/svdview.hxx +++ b/include/svx/svdview.hxx @@ -144,7 +144,7 @@ public: }; -class SVX_DLLPUBLIC SdrView: public SdrCreateView, public virtual tools::WeakBase +class SVX_DLLPUBLIC SdrView : public SdrCreateView, public virtual tools::WeakBase { friend class SdrPageView; @@ -156,7 +156,10 @@ protected: SvtAccessibilityOptions maAccessibilityOptions; public: - explicit SdrView(SdrModel* pModel1, OutputDevice* pOut = nullptr); + explicit SdrView( + SdrModel& rSdrModel, + OutputDevice* pOut = nullptr); + virtual ~SdrView() override; // The default value for all dispatchers is activated. If the app for example diff --git a/include/svx/svdxcgv.hxx b/include/svx/svdxcgv.hxx index 8c4deca123b9..52dc63b1a282 100644 --- a/include/svx/svdxcgv.hxx +++ b/include/svx/svdxcgv.hxx @@ -25,7 +25,7 @@ #include <vcl/gdimtf.hxx> #include <svx/svxdllapi.h> -class SVX_DLLPUBLIC SdrExchangeView: public SdrObjEditView +class SVX_DLLPUBLIC SdrExchangeView : public SdrObjEditView { friend class SdrPageView; @@ -40,7 +40,9 @@ protected: protected: // #i71538# make constructors of SdrView sub-components protected to avoid incomplete incarnations which may get casted to SdrView - SdrExchangeView(SdrModel* pModel1, OutputDevice* pOut); + SdrExchangeView( + SdrModel& rSdrModel, + OutputDevice* pOut); public: // Output all marked objects on the specified OutputDevice @@ -72,20 +74,16 @@ public: Graphic GetAllMarkedGraphic() const; - /** Generate a Graphic for the given draw object in the given model + /** Generate a Graphic for the given draw object - @param pModel - Must not be NULL. Denotes the draw model the object is a part - of. - - @param pObj + @param rSdrObject The object (can also be a group object) to retrieve a Graphic - for. Must not be NULL. + for. @return a graphical representation of the given object, as it appears on screen (e.g. with rotation, if any, applied). */ - static Graphic GetObjGraphic( const SdrModel* pModel, const SdrObject* pObj ); + static Graphic GetObjGraphic(const SdrObject& rSdrObject); // The new Draw objects are marked for all paste methods. // If bAddMark is true, the new Draw objects are added to an existing diff --git a/include/svx/svxdlg.hxx b/include/svx/svxdlg.hxx index 77f4437f8ae9..ae84bb361a92 100644 --- a/include/svx/svxdlg.hxx +++ b/include/svx/svxdlg.hxx @@ -464,7 +464,7 @@ public: const sal_uInt16 _nInitiallySelectedEvent ) = 0; - virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, SdrModel* pModel, const SdrObject* pObj )=0; + virtual VclPtr<SfxAbstractTabDialog> CreateSvxFormatCellsDialog( const SfxItemSet* pAttr, const SdrModel& rModel, const SdrObject* pObj )=0; virtual VclPtr<SvxAbstractSplitTableDialog> CreateSvxSplitTableDialog(weld::Window* pParent, bool bIsTableVertical, long nMaxVertical) = 0; diff --git a/include/svx/unomod.hxx b/include/svx/unomod.hxx index 630c51ce52e4..04571c9071b2 100644 --- a/include/svx/unomod.hxx +++ b/include/svx/unomod.hxx @@ -32,6 +32,10 @@ SVX_DLLPUBLIC css::uno::Reference< css::container::XIndexReplace > SvxCreateNumR class SVX_DLLPUBLIC SvxUnoDrawMSFactory : public css::lang::XMultiServiceFactory { +protected: + /** abstract SdrModel provider */ + virtual SdrModel* getSdrModelFromUnoModel() const = 0; //TTTT make reference return + public: SvxUnoDrawMSFactory() throw() {}; diff --git a/include/svx/unomodel.hxx b/include/svx/unomodel.hxx index ab9ab9ed2cec..e637e4486d2a 100644 --- a/include/svx/unomodel.hxx +++ b/include/svx/unomodel.hxx @@ -31,11 +31,12 @@ class SdrModel; -class SVX_DLLPUBLIC SvxUnoDrawingModel : public SfxBaseModel, // implements SfxListener, OWEAKOBJECT & other - public SvxFmMSFactory, - public css::drawing::XDrawPagesSupplier, - public css::lang::XServiceInfo, - public css::ucb::XAnyCompareFactory +class SVX_DLLPUBLIC SvxUnoDrawingModel +: public SfxBaseModel, // implements SfxListener, OWEAKOBJECT & other + public SvxFmMSFactory, + public css::drawing::XDrawPagesSupplier, + public css::lang::XServiceInfo, + public css::ucb::XAnyCompareFactory { friend class SvxUnoDrawPagesAccess; @@ -53,6 +54,10 @@ private: css::uno::Sequence< css::uno::Type > maTypeSequence; +protected: + // SvxUnoDrawMSFactory + virtual SdrModel* getSdrModelFromUnoModel() const override; + public: SvxUnoDrawingModel( SdrModel* pDoc ) throw(); virtual ~SvxUnoDrawingModel() throw() override; diff --git a/include/svx/unopage.hxx b/include/svx/unopage.hxx index 6f84e72b8e66..eefc11c61b2b 100644 --- a/include/svx/unopage.hxx +++ b/include/svx/unopage.hxx @@ -68,8 +68,8 @@ class SVX_DLLPUBLIC SvxDrawPage : public ::cppu::WeakAggImplHelper6< css::drawin protected: cppu::OBroadcastHelper mrBHelper; - SdrPage* mpPage; - SdrModel* mpModel; + SdrPage* mpPage; // TTTT should be reference + SdrModel* mpModel; // TTTT probably not needed -> use from SdrPage SdrView* mpView; void SelectObjectsInView( const css::uno::Reference< css::drawing::XShapes >& aShapes, SdrPageView* pPageView ) throw (); @@ -83,7 +83,6 @@ class SVX_DLLPUBLIC SvxDrawPage : public ::cppu::WeakAggImplHelper6< css::drawin // Internals SdrPage* GetSdrPage() const { return mpPage; } - void ChangeModel( SdrModel* pNewModel ); // Creation of a SdrObject and insertion into the SdrPage SdrObject *CreateSdrObject( const css::uno::Reference< css::drawing::XShape >& xShape, bool bBeginning = false ) throw(); diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx index 4bb90d88ee0e..422f6b13b446 100644 --- a/include/svx/unoshape.hxx +++ b/include/svx/unoshape.hxx @@ -137,8 +137,10 @@ protected: const SvxItemPropertySet* mpPropSet; const SfxItemPropertyMapEntry* maPropMapEntries; - ::tools::WeakReference< SdrObject > mpObj; - SdrModel* mpModel; +private: + ::tools::WeakReference< SdrObject > mpSdrObjectWeakReference; + +protected: // translations for writer, which works in TWIPS void ForceMetricToItemPoolMetric(Pair& rPoint) const throw(); void ForceMetricToItemPoolMetric(Point& rPoint) const throw() { ForceMetricToItemPoolMetric(rPoint.toPair()); } @@ -206,10 +208,13 @@ public: void TakeSdrObjectOwnership(); bool HasSdrObjectOwnership() const; - void ChangeModel( SdrModel* pNewModel ); + // used exclusively by SdrObject + void InvalidateSdrObject(); + + // Encapsulated access to SdrObject + SdrObject* GetSdrObject() const { return mpSdrObjectWeakReference.get(); } + bool HasSdrObject() const { return mpSdrObjectWeakReference.is(); } - void InvalidateSdrObject() { mpObj.reset( nullptr ); }; - SdrObject* GetSdrObject() const {return mpObj.get();} void SetShapeType( const OUString& ShapeType ) { maShapeType = ShapeType; } /// @throws css::uno::RuntimeException css::uno::Any GetBitmap( bool bMetaFile = false ) const; diff --git a/include/svx/unoshtxt.hxx b/include/svx/unoshtxt.hxx index f38cf8a62d0f..f16358d2432d 100644 --- a/include/svx/unoshtxt.hxx +++ b/include/svx/unoshtxt.hxx @@ -77,8 +77,6 @@ public: virtual Point LogicToPixel( const Point&, const MapMode& ) const override; virtual Point PixelToLogic( const Point&, const MapMode& ) const override; - void ChangeModel( SdrModel* pNewModel ); - void UpdateOutliner(); private: diff --git a/include/svx/view3d.hxx b/include/svx/view3d.hxx index 48ff9b6f12b2..be4381c21351 100644 --- a/include/svx/view3d.hxx +++ b/include/svx/view3d.hxx @@ -63,7 +63,10 @@ protected: void BreakSingle3DObj(E3dObject* pObj); public: - E3dView(SdrModel* pModel, OutputDevice* pOut); + E3dView( + SdrModel& rSdrModel, + OutputDevice* pOut); + virtual ~E3dView() override; // Output all marked Objects on the given OutputDevice. |