From 5519a3d4073ae4f04f8e1aa453fbc0ea9c8e19e4 Mon Sep 17 00:00:00 2001 From: "Armin Le Grand (collabora)" Date: Thu, 9 Jul 2026 20:52:38 +0200 Subject: [PATCH] Correct StyleSheet handling when cloning to different Model II Until now the 'local' StyleSheet got set, but that may not be the same as the original. It was/gets identified just by searching by name and type, not comparing content. What to do? We could... (a) the Style-Friendly way: - check if StyleSheet is identical - if not, create a new in-between StyleSheet hosting missing Items - if yes, use, done. (b) the pragmatic/practical way: - Just hard-attribute the Items that are detected as different similar to what BurnInStyleSheetAttributes does/did, but only for a view differing Items (b) is the most simple for now, but will lead to more hard attributes. The other possibilities will be better in the long term. For now, I will use (b). Note that there are more cases in that VERY complex and grown stuff emerging from SdDrawDocument::PasteBookmarkAsPage. More things will need to be fixed, see this as a 1st step. Needed to adapt postProcessAfterCloneToDifferentModel due to UT testTdf96206 failing, see comment there for details. That 1st implementation showed weaknesses with those Items critical and only on MasterPages, so decided to give up on that and implement ContentCompare to SdPage::Equals. That was easier than thought: No parameter needed, only used by InsertBookmarkAsPage_FindDuplicateLayouts::operator(). Thus, SdPage::Equals needs no change, just SdrObject::Equals. Due to still problems with Items corrected in Objects on MasterPages I will for now exclude this. Could now isolate remaining problems, these are defaults and/or PresObj things on MasterPages. Important is that I can completely correct all Items for all Objects in postProcessAfterCloneToDifferentModel. I can react to these false-positives in the ContentCompare in SdrObject::Equals. Signed-off-by: Armin Le Grand (collabora) Change-Id: I10e17c8d6a893dbe92ab716182f07bafce1f3284 Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/6595 Tested-by: Jenkins CPCI Reviewed-by: Armin Le Grand (cherry picked from commit 92ffaeac04c5c8586006b026f29ce12fba3674f1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211729 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- basctl/source/dlged/dlgedobj.cxx | 2 +- basctl/source/inc/dlgedobj.hxx | 6 +- include/svx/annotation/AnnotationObject.hxx | 2 +- include/svx/cube3d.hxx | 5 +- include/svx/lathe3d.hxx | 5 +- include/svx/obj3d.hxx | 11 +- include/svx/scene3d.hxx | 4 +- .../svx/sdr/properties/defaultproperties.hxx | 6 +- include/svx/sdr/properties/properties.hxx | 13 +- include/svx/sphere3d.hxx | 6 +- include/svx/svdoashp.hxx | 5 +- include/svx/svdobj.hxx | 11 +- include/svx/svdocapt.hxx | 5 +- include/svx/svdocirc.hxx | 6 +- include/svx/svdoedge.hxx | 4 +- include/svx/svdograf.hxx | 5 +- include/svx/svdogrp.hxx | 4 +- include/svx/svdomeas.hxx | 4 +- include/svx/svdomedia.hxx | 5 +- include/svx/svdoole2.hxx | 6 +- include/svx/svdopage.hxx | 3 +- include/svx/svdopath.hxx | 5 +- include/svx/svdorect.hxx | 5 +- include/svx/svdotable.hxx | 3 +- include/svx/svdotext.hxx | 4 +- include/svx/svdouno.hxx | 3 +- include/svx/svdovirt.hxx | 3 +- reportdesign/inc/RptObject.hxx | 4 +- reportdesign/source/core/sdr/RptObject.cxx | 4 +- sd/qa/unit/uiimpress.cxx | 2 +- svx/inc/extrud3d.hxx | 6 +- svx/inc/polygn3d.hxx | 4 +- .../sdr/properties/attributeproperties.hxx | 9 +- svx/inc/sdr/properties/captionproperties.hxx | 6 +- svx/inc/sdr/properties/cellproperties.hxx | 2 +- svx/inc/sdr/properties/circleproperties.hxx | 6 +- .../sdr/properties/connectorproperties.hxx | 6 +- .../sdr/properties/customshapeproperties.hxx | 7 +- .../sdr/properties/e3dcompoundproperties.hxx | 8 +- .../sdr/properties/e3dextrudeproperties.hxx | 6 +- svx/inc/sdr/properties/e3dlatheproperties.hxx | 6 +- svx/inc/sdr/properties/e3dproperties.hxx | 6 +- svx/inc/sdr/properties/e3dsceneproperties.hxx | 6 +- .../sdr/properties/e3dsphereproperties.hxx | 6 +- svx/inc/sdr/properties/emptyproperties.hxx | 6 +- svx/inc/sdr/properties/graphicproperties.hxx | 6 +- svx/inc/sdr/properties/groupproperties.hxx | 7 +- svx/inc/sdr/properties/measureproperties.hxx | 6 +- svx/inc/sdr/properties/oleproperties.hxx | 6 +- svx/inc/sdr/properties/pageproperties.hxx | 6 +- .../sdr/properties/rectangleproperties.hxx | 6 +- svx/inc/sdr/properties/textproperties.hxx | 7 +- svx/source/annotation/AnnotationObject.cxx | 2 +- svx/source/engine3d/cube3d.cxx | 2 +- svx/source/engine3d/extrud3d.cxx | 2 +- svx/source/engine3d/lathe3d.cxx | 2 +- svx/source/engine3d/obj3d.cxx | 4 +- svx/source/engine3d/polygn3d.cxx | 2 +- svx/source/engine3d/scene3d.cxx | 2 +- svx/source/engine3d/sphere3d.cxx | 2 +- svx/source/form/fmobj.cxx | 2 +- svx/source/inc/fmobj.hxx | 4 +- .../sdr/properties/attributeproperties.cxx | 157 +++++++++++------- .../sdr/properties/captionproperties.cxx | 2 +- .../sdr/properties/circleproperties.cxx | 2 +- .../sdr/properties/connectorproperties.cxx | 2 +- .../sdr/properties/customshapeproperties.cxx | 2 +- .../sdr/properties/defaultproperties.cxx | 2 +- .../sdr/properties/e3dcompoundproperties.cxx | 2 +- .../sdr/properties/e3dextrudeproperties.cxx | 2 +- .../sdr/properties/e3dlatheproperties.cxx | 2 +- svx/source/sdr/properties/e3dproperties.cxx | 2 +- .../sdr/properties/e3dsceneproperties.cxx | 2 +- .../sdr/properties/e3dsphereproperties.cxx | 2 +- svx/source/sdr/properties/emptyproperties.cxx | 2 +- .../sdr/properties/graphicproperties.cxx | 2 +- svx/source/sdr/properties/groupproperties.cxx | 2 +- .../sdr/properties/measureproperties.cxx | 2 +- svx/source/sdr/properties/oleproperties.cxx | 2 +- svx/source/sdr/properties/pageproperties.cxx | 2 +- svx/source/sdr/properties/properties.cxx | 9 + .../sdr/properties/rectangleproperties.cxx | 2 +- svx/source/sdr/properties/textproperties.cxx | 2 +- svx/source/svdraw/svdoashp.cxx | 2 +- svx/source/svdraw/svdobj.cxx | 101 ++++++++++- svx/source/svdraw/svdocapt.cxx | 2 +- svx/source/svdraw/svdocirc.cxx | 2 +- svx/source/svdraw/svdoedge.cxx | 2 +- svx/source/svdraw/svdograf.cxx | 2 +- svx/source/svdraw/svdogrp.cxx | 2 +- svx/source/svdraw/svdomeas.cxx | 2 +- svx/source/svdraw/svdomedia.cxx | 2 +- svx/source/svdraw/svdoole2.cxx | 2 +- svx/source/svdraw/svdopage.cxx | 2 +- svx/source/svdraw/svdopath.cxx | 2 +- svx/source/svdraw/svdorect.cxx | 2 +- svx/source/svdraw/svdotext.cxx | 2 +- svx/source/svdraw/svdouno.cxx | 2 +- svx/source/svdraw/svdovirt.cxx | 2 +- svx/source/table/cell.cxx | 2 +- svx/source/table/svdotable.cxx | 6 +- sw/inc/dcontact.hxx | 5 +- sw/source/core/draw/dcontact.cxx | 2 +- sw/source/core/draw/dflyobj.cxx | 2 +- sw/source/core/inc/dflyobj.hxx | 7 +- 105 files changed, 400 insertions(+), 268 deletions(-) diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx index b65fd897a6b2..c70b74f6a415 100644 --- a/basctl/source/dlged/dlgedobj.cxx +++ b/basctl/source/dlged/dlgedobj.cxx @@ -901,7 +901,7 @@ SdrObjKind DlgEdObj::GetObjIdentifier() const } } -rtl::Reference DlgEdObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference DlgEdObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new DlgEdObj(rTargetModel, *this); } diff --git a/basctl/source/inc/dlgedobj.hxx b/basctl/source/inc/dlgedobj.hxx index 469628ae75fe..488fc9b737f9 100644 --- a/basctl/source/inc/dlgedobj.hxx +++ b/basctl/source/inc/dlgedobj.hxx @@ -47,15 +47,15 @@ class DlgEdObj: public SdrUnoObj friend class DlgEdPropListenerImpl; friend class DlgEdForm; -private: bool bIsListening; rtl::Reference pDlgEdForm; rtl::Reference m_xPropertyChangeListener; rtl::Reference m_xContainerListener; -private: DlgEditor& GetDialogEditor (); + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; // not working yet + protected: DlgEdObj(SdrModel& rSdrModel); // copy constructor @@ -98,8 +98,6 @@ public: virtual SdrInventor GetObjInventor() const override; virtual SdrObjKind GetObjIdentifier() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; // not working yet - // FullDrag support virtual rtl::Reference getFullDragClone() const override; diff --git a/include/svx/annotation/AnnotationObject.hxx b/include/svx/annotation/AnnotationObject.hxx index 79732042465f..922c3a1d5b60 100644 --- a/include/svx/annotation/AnnotationObject.hxx +++ b/include/svx/annotation/AnnotationObject.hxx @@ -38,7 +38,7 @@ public: void setup(); - rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; + rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; SdrObjKind GetObjIdentifier() const override; OUString TakeObjNameSingul() const override; diff --git a/include/svx/cube3d.hxx b/include/svx/cube3d.hxx index 3c8323197f8e..96075956819e 100644 --- a/include/svx/cube3d.hxx +++ b/include/svx/cube3d.hxx @@ -54,10 +54,11 @@ class SAL_WARN_UNUSED E3dCubeObj final : public E3dCompoundObject void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); virtual std::unique_ptr CreateObjectSpecificViewContact() override; -private: // protected destructor - due to final, make private virtual ~E3dCubeObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SVXCORE_DLLPUBLIC E3dCubeObj(SdrModel& rSdrModel, const E3dDefaultAttributes& rDefault, @@ -69,8 +70,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual rtl::Reference DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - // Set local parameters with geometry recreation void SetCubePos(const basegfx::B3DPoint& rNew); const basegfx::B3DPoint& GetCubePos() const { return m_aCubePos; } diff --git a/include/svx/lathe3d.hxx b/include/svx/lathe3d.hxx index d442119ad430..53abedc97056 100644 --- a/include/svx/lathe3d.hxx +++ b/include/svx/lathe3d.hxx @@ -47,10 +47,11 @@ class E3dLatheObj final : public E3dCompoundObject virtual std::unique_ptr CreateObjectSpecificProperties() override; void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); -private: // protected destructor - due to final, make private virtual ~E3dLatheObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SVXCORE_DLLPUBLIC E3dLatheObj( SdrModel& rSdrModel, @@ -101,8 +102,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - virtual rtl::Reference DoConvertToPolyObj(bool bBezier, bool bAddText) const override; // TakeObjName...() is for the display in the UI, for example "3 frames selected". diff --git a/include/svx/obj3d.hxx b/include/svx/obj3d.hxx index 26f7a56d1d5d..d632c0059eb1 100644 --- a/include/svx/obj3d.hxx +++ b/include/svx/obj3d.hxx @@ -61,11 +61,12 @@ public: class SVXCORE_DLLPUBLIC E3dObject : public SdrAttrObj { -private: // Allow everything for E3dObjList and E3dDragMethod friend class E3dDragMethod; - protected: + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + +protected: virtual std::unique_ptr CreateObjectSpecificProperties() override; basegfx::B3DRange maLocalBoundVol; // surrounding volume of the object (from the geometry generation) @@ -125,7 +126,6 @@ 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 rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual std::unique_ptr NewGeoData() const override; virtual void SaveGeoData(SdrObjGeoData& rGeo) const override; @@ -152,13 +152,14 @@ public: class SVXCORE_DLLPUBLIC E3dCompoundObject : public E3dObject { -private: // to allow sdr::properties::E3dCompoundProperties access to SetGeometryValid() friend class sdr::properties::E3dCompoundProperties; friend class sdr::properties::E3dExtrudeProperties; friend class sdr::properties::E3dLatheProperties; friend class sdr::properties::E3dSphereProperties; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + protected: virtual std::unique_ptr CreateObjectSpecificProperties() override; @@ -179,8 +180,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual void RecalcSnapRect() override; - - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; }; #endif // INCLUDED_SVX_OBJ3D_HXX diff --git a/include/svx/scene3d.hxx b/include/svx/scene3d.hxx index 02da7a56495f..86158da94d71 100644 --- a/include/svx/scene3d.hxx +++ b/include/svx/scene3d.hxx @@ -73,6 +73,8 @@ class SVXCORE_DLLPUBLIC E3dScene final : public E3dObject, public SdrObjList void SetDefaultAttributes(); void ImpCleanup3DDepthMapper(); + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: E3dScene(SdrModel& rSdrModel); E3dScene(SdrModel& rSdrModel, E3dScene const &); @@ -120,8 +122,6 @@ public: const Camera3D& GetCamera() const { return m_aCamera; } void removeAllNonSelectedObjects(); - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - virtual std::unique_ptr NewGeoData() const override; virtual void SaveGeoData(SdrObjGeoData& rGeo) const override; virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override; diff --git a/include/svx/sdr/properties/defaultproperties.hxx b/include/svx/sdr/properties/defaultproperties.hxx index 06ba74845630..d41606892426 100644 --- a/include/svx/sdr/properties/defaultproperties.hxx +++ b/include/svx/sdr/properties/defaultproperties.hxx @@ -41,6 +41,9 @@ namespace sdr::properties // Make sure the pool outlives any use via moItemSet: rtl::Reference m_itemPoolHolder; + // Clone() operator, normally just calls the local copy constructor + SAL_DLLPRIVATE virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + protected: // the to be used ItemSet mutable std::optional moItemSet; @@ -81,9 +84,6 @@ namespace sdr::properties SAL_DLLPRIVATE void dumpAsXml(xmlTextWriterPtr pWriter) const override; - // Clone() operator, normally just calls the local copy constructor - SAL_DLLPRIVATE virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // get itemset SAL_DLLPRIVATE virtual const SfxItemSet& GetObjectItemSet() const override; diff --git a/include/svx/sdr/properties/properties.hxx b/include/svx/sdr/properties/properties.hxx index dce0c01c1e2b..1d4e199aaffb 100644 --- a/include/svx/sdr/properties/properties.hxx +++ b/include/svx/sdr/properties/properties.hxx @@ -72,15 +72,16 @@ namespace sdr::properties { class SVXCORE_DLLPUBLIC BaseProperties { - private: // the owner of this Properties. Set from constructor and not // to be changed in any way. SdrObject& mrObject; + // thje Clone-implementations, overloaded for each derivation + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const = 0; + protected: // internal access to SdrObject const SdrObject& GetSdrObject() const; - SdrObject& GetSdrObject(); public: @@ -90,11 +91,17 @@ namespace sdr::properties // destructor virtual ~BaseProperties(); + // create needed SfxItemSet, overloaded in all derivations as needed virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool) = 0; + // Regulates Styles/Items between models when a Clone to another model + // was done. This is needed to evtl. also clone Styles and/or attributes + // to target model + virtual void postProcessAfterCloneToDifferentModel(const SdrObject& rSrcObj); + // Clone() operator, normally just calls the local copy constructor, // see above. - virtual std::unique_ptr Clone(SdrObject& rObj) const = 0; + std::unique_ptr Clone(SdrObject& rObj) const; // Get the local ItemSet. This directly returns the local ItemSet of the object. No // merging of ItemSets is done for e.g. Group objects. diff --git a/include/svx/sphere3d.hxx b/include/svx/sphere3d.hxx index 42bd8ebbfa53..500a03ccd58e 100644 --- a/include/svx/sphere3d.hxx +++ b/include/svx/sphere3d.hxx @@ -34,7 +34,6 @@ class E3dDefaultAttributes; */ class E3dSphereObj final : public E3dCompoundObject { -private: basegfx::B3DPoint m_aCenter; basegfx::B3DVector m_aSize; @@ -42,10 +41,11 @@ private: virtual std::unique_ptr CreateObjectSpecificProperties() override; void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); -private: // protected destructor - due to final, make private virtual ~E3dSphereObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SVXCORE_DLLPUBLIC E3dSphereObj( SdrModel& rSdrModel, @@ -70,8 +70,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual rtl::Reference DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - const basegfx::B3DPoint& Center() const { return m_aCenter; } const basegfx::B3DVector& Size() const { return m_aSize; } diff --git a/include/svx/svdoashp.hxx b/include/svx/svdoashp.hxx index b57f1a3f89eb..138da821537c 100644 --- a/include/svx/svdoashp.hxx +++ b/include/svx/svdoashp.hxx @@ -74,11 +74,12 @@ struct SdrCustomShapeInteraction class SVXCORE_DLLPUBLIC SdrObjCustomShape : public SdrTextObj { -private: // fObjectRotation is containing the object rotation in degrees. double m_fObjectRotation; bool mbAdjustingTextFrameWidthAndHeight; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + protected: virtual std::unique_ptr CreateObjectSpecificViewContact() override; virtual void setUnoShape(const css::uno::Reference& rxUnoShape) override; @@ -113,7 +114,6 @@ public: // returns the new text rect that corresponds to the current logic rect, the return value can be empty if nothing changed. tools::Rectangle ImpCalculateTextFrame( const bool bHgt, const bool bWdt ); -public: // #i37011# const SdrObject* GetSdrObjectFromCustomShape() const; const SdrObject* GetSdrObjectShadowFromCustomShape() const; @@ -209,7 +209,6 @@ 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 rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index 351f3ff7101e..f675fe93b10c 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -254,6 +254,9 @@ private: friend class SdrVirtObj; friend class SdrRectObj; + // Returns a copy of the object. Every inherited class must reimplement this. + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const = 0; + // OperationSmiley: Allow at each SdrObject to set a FillGeometryDefiningShape, // so that for SdrObjects where this is set, the definition of a defined FillStyle // will use this, but the local geometry will be filled. This allows to fill @@ -452,8 +455,12 @@ public: // means no change of the rotation point (only centered) and no shear allowed virtual bool HasLimitedRotation() const; - // Returns a copy of the object. Every inherited class must reimplement this. - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const = 0; + // Returns a copy of the object. Internally uses the virtual and + // overridden method implCloneSdrObject that is implemented for each + // derivation. If cloned to another SdrModel it will support calling + // postProcessAfterCloneToDifferentModel + rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const; + // helper, since Clone always return the type of the current subclass template static rtl::Reference Clone(T const & rObj, SdrModel& rTargetModel) diff --git a/include/svx/svdocapt.hxx b/include/svx/svdocapt.hxx index 4b0f593a147e..35ca8bfde6cd 100644 --- a/include/svx/svdocapt.hxx +++ b/include/svx/svdocapt.hxx @@ -40,7 +40,6 @@ public: // SdrCaptionObj class SVXCORE_DLLPUBLIC SdrCaptionObj final : public SdrRectObj { -private: // to allow sdr::properties::CaptionProperties access to ImpRecalcTail() friend class sdr::properties::CaptionProperties; friend class SdrTextObj; // for ImpRecalcTail() during AutoGrow @@ -71,6 +70,8 @@ private: // protected destructor SAL_DLLPRIVATE virtual ~SdrCaptionObj() override; + SAL_DLLPRIVATE virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SAL_DLLPRIVATE SdrCaptionObj(SdrModel& rSdrModel); @@ -84,8 +85,6 @@ public: SAL_DLLPRIVATE virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; SAL_DLLPRIVATE virtual SdrObjKind GetObjIdentifier() const override; - SAL_DLLPRIVATE virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - // for calc: special shadow only for text box void SetSpecialTextBoxShadow() { mbSpecialTextBoxShadow = true; } bool GetSpecialTextBoxShadow() const { return mbSpecialTextBoxShadow; } diff --git a/include/svx/svdocirc.hxx b/include/svx/svdocirc.hxx index 322ac1bbf383..a642eec936d8 100644 --- a/include/svx/svdocirc.hxx +++ b/include/svx/svdocirc.hxx @@ -42,7 +42,6 @@ extern SVXCORE_DLLPUBLIC SdrCircKind ToSdrCircKind(SdrObjKind); class SVXCORE_DLLPUBLIC SdrCircObj final : public SdrRectObj { -private: // to allow sdr::properties::CircleProperties access to ImpSetAttrToCircInfo() friend class sdr::properties::CircleProperties; @@ -64,10 +63,11 @@ private: SAL_DLLPRIVATE virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; -private: // protected destructor - due to final, make private SAL_DLLPRIVATE virtual ~SdrCircObj() override; + SAL_DLLPRIVATE virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SAL_DLLPRIVATE SdrCircObj( SdrModel& rSdrModel, @@ -99,8 +99,6 @@ public: SAL_DLLPRIVATE virtual OUString TakeObjNameSingul() const override; SAL_DLLPRIVATE virtual OUString TakeObjNamePlural() const override; - SAL_DLLPRIVATE virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - SAL_DLLPRIVATE virtual void RecalcSnapRect() override; SAL_DLLPRIVATE virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; SAL_DLLPRIVATE virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; diff --git a/include/svx/svdoedge.hxx b/include/svx/svdoedge.hxx index 2c1e4684a408..6089b215301d 100644 --- a/include/svx/svdoedge.hxx +++ b/include/svx/svdoedge.hxx @@ -134,7 +134,6 @@ public: /// Utility class SdrEdgeObj class SVXCORE_DLLPUBLIC SdrEdgeObj final : public SdrTextObj { -private: // to allow sdr::properties::ConnectorProperties access to ImpSetAttrToEdgeInfo() friend class sdr::properties::ConnectorProperties; @@ -169,6 +168,8 @@ private: // to a correct state for first real layouting bool mbSuppressed : 1; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: // Interface to default connect suppression void SetSuppressDefaultConnect(bool bNew) { mbSuppressDefaultConnect = bNew; } @@ -224,7 +225,6 @@ public: SAL_DLLPRIVATE virtual void RecalcSnapRect() override; SAL_DLLPRIVATE virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; SAL_DLLPRIVATE virtual OUString TakeObjNameSingul() const override; SAL_DLLPRIVATE virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdograf.hxx b/include/svx/svdograf.hxx index 20cbd6aa3c1c..d407950399c5 100644 --- a/include/svx/svdograf.hxx +++ b/include/svx/svdograf.hxx @@ -66,7 +66,6 @@ class SdrGraphicLink; */ class SVXCORE_DLLPUBLIC SdrGrafObj final : public SdrRectObj { -private: // to allow sdr::properties::GraphicProperties access to SetXPolyDirty() friend class sdr::properties::GraphicProperties; @@ -109,6 +108,8 @@ private: // protected destructor SAL_DLLPRIVATE virtual ~SdrGrafObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SdrGrafObj(SdrModel& rSdrModel); // Copy constructor @@ -166,8 +167,6 @@ public: SAL_DLLPRIVATE virtual OUString TakeObjNameSingul() const override; SAL_DLLPRIVATE virtual OUString TakeObjNamePlural() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - SAL_DLLPRIVATE virtual sal_uInt32 GetHdlCount() const override; SAL_DLLPRIVATE virtual void AddToHdlList(SdrHdlList& rHdlList) const override; diff --git a/include/svx/svdogrp.hxx b/include/svx/svdogrp.hxx index 08de5020cba7..61be5586b716 100644 --- a/include/svx/svdogrp.hxx +++ b/include/svx/svdogrp.hxx @@ -47,6 +47,8 @@ private: // the DiagramHelper if this SdrObjGroup host a Diagram std::shared_ptr< svx::diagram::DiagramHelper_svx > mp_DiagramHelper; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SdrObjGroup(SdrModel& rSdrModel); // Copy constructor @@ -74,8 +76,6 @@ public: virtual const tools::Rectangle& GetCurrentBoundRect() const override; virtual const tools::Rectangle& GetSnapRect() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdomeas.hxx b/include/svx/svdomeas.hxx index 77309db6af9d..a7db2f06bdda 100644 --- a/include/svx/svdomeas.hxx +++ b/include/svx/svdomeas.hxx @@ -43,7 +43,6 @@ public: class SVXCORE_DLLPUBLIC SdrMeasureObj final : public SdrTextObj { -private: // to allow sdr::properties::MeasureProperties access to SetTextDirty() friend class sdr::properties::MeasureProperties; friend class SdrMeasureField; @@ -76,6 +75,8 @@ private: SAL_DLLPRIVATE virtual void SaveGeoData(SdrObjGeoData& rGeo) const override; SAL_DLLPRIVATE virtual void RestoreGeoData(const SdrObjGeoData& rGeo) override; + SAL_DLLPRIVATE virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SAL_DLLPRIVATE SdrMeasureObj(SdrModel& rSdrModel); // Copy constructor @@ -89,7 +90,6 @@ public: SAL_DLLPRIVATE virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; SAL_DLLPRIVATE virtual SdrObjKind GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - SAL_DLLPRIVATE virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; SAL_DLLPRIVATE virtual OUString TakeObjNameSingul() const override; SAL_DLLPRIVATE virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdomedia.hxx b/include/svx/svdomedia.hxx index 9869758d6d74..ce9ddb5774ff 100644 --- a/include/svx/svdomedia.hxx +++ b/include/svx/svdomedia.hxx @@ -34,10 +34,11 @@ class SVXCORE_DLLPUBLIC SdrMediaObj final : public SdrRectObj friend class sdr::contact::ViewContactOfSdrMediaObj; friend class SdrMediaLink; -private: // protected destructor - due to final, make private SAL_DLLPRIVATE virtual ~SdrMediaObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SAL_DLLPRIVATE SdrMediaObj(SdrModel& rSdrModel); // Copy constructor @@ -54,8 +55,6 @@ public: SAL_DLLPRIVATE virtual OUString TakeObjNameSingul() const override; SAL_DLLPRIVATE virtual OUString TakeObjNamePlural() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - virtual void AdjustToMaxRect( const tools::Rectangle& rMaxRect, bool bShrinkOnly = false ) override; void setURL(const OUString& rURL, const OUString& rReferer); diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx index 63707fc8d6f7..f16089ede671 100644 --- a/include/svx/svdoole2.hxx +++ b/include/svx/svdoole2.hxx @@ -45,10 +45,8 @@ class SvxOle2Shape; class SVXCORE_DLLPUBLIC SdrOle2Obj : public SdrRectObj { -private: std::unique_ptr mpImpl; -private: SVX_DLLPRIVATE void Connect_Impl(SvxOle2Shape* pCreator = nullptr); SVX_DLLPRIVATE void Disconnect_Impl(); SVX_DLLPRIVATE void AddListeners_Impl(); @@ -61,6 +59,8 @@ private: SVX_DLLPRIVATE void Init(); + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + protected: virtual std::unique_ptr CreateObjectSpecificViewContact() override; virtual std::unique_ptr CreateObjectSpecificProperties() override; @@ -140,8 +140,6 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - virtual void NbcMove(const Size& rSize) override; virtual void NbcResize(const Point& rRef, double xFact, double yFact) override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; diff --git a/include/svx/svdopage.hxx b/include/svx/svdopage.hxx index 279c75c758a6..5d0650b7fe6c 100644 --- a/include/svx/svdopage.hxx +++ b/include/svx/svdopage.hxx @@ -41,6 +41,8 @@ private: // protected destructor virtual ~SdrPageObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SdrPageObj( SdrModel& rSdrModel, @@ -60,7 +62,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdopath.hxx b/include/svx/svdopath.hxx index 3d63acf27fe4..b440fa5dfe49 100644 --- a/include/svx/svdopath.hxx +++ b/include/svx/svdopath.hxx @@ -41,7 +41,6 @@ public: class SVXCORE_DLLPUBLIC SdrPathObj final : public SdrTextObj { -private: friend class ImpPathForDragAndCreate; virtual std::unique_ptr CreateObjectSpecificViewContact() override; @@ -59,10 +58,11 @@ private: void ImpForceLineAngle(); ImpPathForDragAndCreate& impGetDAC() const; -private: // protected destructor - due to final, make private virtual ~SdrPathObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SdrPathObj( SdrModel& rSdrModel, @@ -77,7 +77,6 @@ public: virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual SdrObjKind GetObjIdentifier() const override; virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/include/svx/svdorect.hxx b/include/svx/svdorect.hxx index a50a5524daeb..9a3f7d3f0b50 100644 --- a/include/svx/svdorect.hxx +++ b/include/svx/svdorect.hxx @@ -37,18 +37,18 @@ namespace sdr::properties { /// Rectangle objects (rectangle, circle, ...) class SVXCORE_DLLPUBLIC SdrRectObj : public SdrTextObj { -private: // to allow sdr::properties::RectangleProperties access to SetXPolyDirty() friend class sdr::properties::RectangleProperties; friend class SdrTextObj; // Due to SetXPolyDirty for GrowAdjust + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + protected: virtual std::unique_ptr CreateObjectSpecificViewContact() override; virtual std::unique_ptr CreateObjectSpecificProperties() override; std::optional mpXPoly; -protected: XPolygon ImpCalcXPoly(const tools::Rectangle& rRect1, tools::Long nRad1) const; void SetXPolyDirty(); @@ -82,7 +82,6 @@ public: virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual void RecalcSnapRect() override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; virtual void NbcSetLogicRect(const tools::Rectangle& rRect, bool bAdaptTextMinSize = true) override; diff --git a/include/svx/svdotable.hxx b/include/svx/svdotable.hxx index 17ebb8692a8c..bf552e92f09a 100644 --- a/include/svx/svdotable.hxx +++ b/include/svx/svdotable.hxx @@ -93,6 +93,8 @@ class SVXCORE_DLLPUBLIC SdrTableObj final : public ::SdrTextObj // protected destructor virtual ~SdrTableObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SdrTableObj(SdrModel& rSdrModel); // Copy constructor @@ -203,7 +205,6 @@ public: virtual bool AdjustTextFrameWidthAndHeight() override; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual void RecalcSnapRect() override; virtual const tools::Rectangle& GetSnapRect() const override; virtual void NbcSetSnapRect(const tools::Rectangle& rRect) override; diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 0a7d9db01fc5..8e1da77ccaec 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -119,7 +119,6 @@ namespace sdr::properties // SdrTextObj class SVXCORE_DLLPUBLIC SdrTextObj : public SdrAttrObj, public svx::ITextProvider { -private: // Cell needs access to ImpGetDrawOutliner(); friend class sdr::table::Cell; friend class sdr::table::SdrTableRtfExporter; @@ -132,6 +131,8 @@ private: // CustomShapeproperties need to access the "mbTextFrame" member: friend class sdr::properties::CustomShapeProperties; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + protected: virtual std::unique_ptr CreateObjectSpecificProperties() override; virtual std::unique_ptr CreateObjectSpecificViewContact() override; @@ -463,7 +464,6 @@ public: virtual void TakeUnrotatedSnapRect(tools::Rectangle& rRect) const; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual basegfx::B2DPolyPolygon TakeXorPoly() const override; virtual basegfx::B2DPolyPolygon TakeContour() const override; virtual void RecalcSnapRect() override; diff --git a/include/svx/svdouno.hxx b/include/svx/svdouno.hxx index bebd81fa6259..c7ccd903b43f 100644 --- a/include/svx/svdouno.hxx +++ b/include/svx/svdouno.hxx @@ -48,6 +48,8 @@ class SVXCORE_DLLPUBLIC SdrUnoObj : public SdrRectObj OUString m_aUnoControlModelTypeName; OUString m_aUnoControlTypeName; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + protected: css::uno::Reference< css::awt::XControlModel > m_xUnoControlModel; // Can also be set from outside @@ -71,7 +73,6 @@ public: virtual void TakeObjInfo(SdrObjTransformInfoRec& rInfo) const override; virtual SdrObjKind GetObjIdentifier() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual void NbcResize(const Point& rRef, double xFact, double yFact) override; virtual void NbcSetLayer(SdrLayerID nLayer) override; diff --git a/include/svx/svdovirt.hxx b/include/svx/svdovirt.hxx index 13671663b8f9..e16352dd68c0 100644 --- a/include/svx/svdovirt.hxx +++ b/include/svx/svdovirt.hxx @@ -30,6 +30,8 @@ class SVXCORE_DLLPUBLIC SdrVirtObj : public SdrObject { SdrVirtObj(const SdrVirtObj&) = delete; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: virtual sdr::properties::BaseProperties& GetProperties() const override; @@ -81,7 +83,6 @@ public: virtual const tools::Rectangle& GetCurrentBoundRect() const override; virtual const tools::Rectangle& GetLastBoundRect() const override; virtual void RecalcBoundRect() override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx index 0ccb5ba5eec6..b11ef62fb1ac 100644 --- a/reportdesign/inc/RptObject.hxx +++ b/reportdesign/inc/RptObject.hxx @@ -182,7 +182,7 @@ public: virtual SdrObjKind GetObjIdentifier() const override; virtual SdrInventor GetObjInventor() const override; // Clone() should make a complete copy of the object. - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; virtual void initializeOle() override; void initializeChart( const css::uno::Reference< css::frame::XModel>& _xModel); @@ -262,7 +262,7 @@ public: virtual css::uno::Reference< css::drawing::XShape > getUnoShape() override; virtual SdrObjKind GetObjIdentifier() const override; virtual SdrInventor GetObjInventor() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; private: virtual void setUnoShape( const css::uno::Reference< css::drawing::XShape >& rxUnoShape ) override; diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx index c451206fd82e..ae9003e61753 100644 --- a/reportdesign/source/core/sdr/RptObject.cxx +++ b/reportdesign/source/core/sdr/RptObject.cxx @@ -903,7 +903,7 @@ void OUnoObject::setUnoShape( const uno::Reference< drawing::XShape >& rxUnoShap releaseUnoShape(); } -rtl::Reference OUnoObject::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference OUnoObject::implCloneSdrObject(SdrModel& rTargetModel) const { return new OUnoObject(rTargetModel, *this); } @@ -1116,7 +1116,7 @@ static uno::Reference< chart2::data::XDatabaseDataProvider > lcl_getDataProvider } // Clone() should make a complete copy of the object. -rtl::Reference OOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference OOle2Obj::implCloneSdrObject(SdrModel& rTargetModel) const { return new OOle2Obj(rTargetModel, *this); } diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index 97132449fb03..e49a8b1e42ec 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -849,7 +849,7 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf96708) const sal_uInt16 nMasterPageCnt2 = pDoc->GetMasterSdPageCount(PageKind::Standard); //FIXME: tdf#151802: Number of master pages should be 4, it's 5 instead - //CPPUNIT_ASSERT_EQUAL(nMasterPageCnt1, nMasterPageCnt2); + // CPPUNIT_ASSERT_EQUAL(nMasterPageCnt1, nMasterPageCnt2); CPPUNIT_ASSERT_EQUAL(sal_uInt16(5), nMasterPageCnt2); } diff --git a/svx/inc/extrud3d.hxx b/svx/inc/extrud3d.hxx index cd6c2e00972b..3d0f40413619 100644 --- a/svx/inc/extrud3d.hxx +++ b/svx/inc/extrud3d.hxx @@ -37,7 +37,6 @@ class E3dDefaultAttributes; class SAL_WARN_UNUSED E3dExtrudeObj final : public E3dCompoundObject { -private: // to allow sdr::properties::E3dExtrudeProperties access to SetGeometryValid() friend class sdr::properties::E3dExtrudeProperties; @@ -48,10 +47,11 @@ private: virtual std::unique_ptr CreateObjectSpecificProperties() override; void SetDefaultAttributes(const E3dDefaultAttributes& rDefault); -private: // protected destructor - due to final, make private virtual ~E3dExtrudeObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SVXCORE_DLLPUBLIC E3dExtrudeObj( SdrModel& rSdrModel, @@ -95,8 +95,6 @@ public: virtual SdrObjKind GetObjIdentifier() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - // TakeObjName...() is for the display in the UI (for example "3 frames selected") virtual OUString TakeObjNameSingul() const override; virtual OUString TakeObjNamePlural() const override; diff --git a/svx/inc/polygn3d.hxx b/svx/inc/polygn3d.hxx index 1a9a645b9faa..5c2236dd6610 100644 --- a/svx/inc/polygn3d.hxx +++ b/svx/inc/polygn3d.hxx @@ -39,6 +39,8 @@ class E3dPolygonObj final : public E3dCompoundObject // protected destructor virtual ~E3dPolygonObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: void SetPolyPolygon3D(const basegfx::B3DPolyPolygon& rNewPolyPoly3D); void SetPolyNormals3D(const basegfx::B3DPolyPolygon& rNewPolyPoly3D); @@ -57,8 +59,6 @@ public: virtual rtl::Reference DoConvertToPolyObj(bool bBezier, bool bAddText) const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - // LineOnly? bool GetLineOnly() const { return bLineOnly; } void SetLineOnly(bool bNew); diff --git a/svx/inc/sdr/properties/attributeproperties.hxx b/svx/inc/sdr/properties/attributeproperties.hxx index adc303de00a6..93cad9e3b395 100644 --- a/svx/inc/sdr/properties/attributeproperties.hxx +++ b/svx/inc/sdr/properties/attributeproperties.hxx @@ -29,6 +29,12 @@ namespace sdr::properties { class AttributeProperties : public DefaultProperties, public SfxListener, public svl::StyleSheetUser { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + + // Regulates Styles/Items between models + virtual void postProcessAfterCloneToDifferentModel(const SdrObject& rSrcObj) override; + // core to set parent at SfxItemSet and to execute the hard attribute computations void ImpSetParentAtSfxItemSet(bool bDontRemoveHardAttr); @@ -58,9 +64,6 @@ namespace sdr::properties AttributeProperties(const AttributeProperties& rProps, SdrObject& rObj); public: - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // Get the local ItemSet. This directly returns the local ItemSet of the object. No // merging of ItemSets is done for e.g. Group objects. virtual const SfxItemSet& GetObjectItemSet() const override final; diff --git a/svx/inc/sdr/properties/captionproperties.hxx b/svx/inc/sdr/properties/captionproperties.hxx index 20d2e3b0636f..647914e82394 100644 --- a/svx/inc/sdr/properties/captionproperties.hxx +++ b/svx/inc/sdr/properties/captionproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class CaptionProperties final : public RectangleProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // create a new itemset virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; @@ -43,9 +46,6 @@ namespace sdr::properties // destructor virtual ~CaptionProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // set a new StyleSheet and broadcast virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; diff --git a/svx/inc/sdr/properties/cellproperties.hxx b/svx/inc/sdr/properties/cellproperties.hxx index ba023b9059be..7ed3a857d79a 100644 --- a/svx/inc/sdr/properties/cellproperties.hxx +++ b/svx/inc/sdr/properties/cellproperties.hxx @@ -61,7 +61,7 @@ public: ~CellProperties(); // Clone() operator, normally just calls the local copy constructor - std::unique_ptr Clone(SdrObject& rObj) const override; + std::unique_ptr implCloneProperties(SdrObject& rObj) const override; void ForceDefaultAttributes() override; diff --git a/svx/inc/sdr/properties/circleproperties.hxx b/svx/inc/sdr/properties/circleproperties.hxx index bb70bc814ae6..8f920fd89f40 100644 --- a/svx/inc/sdr/properties/circleproperties.hxx +++ b/svx/inc/sdr/properties/circleproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class CircleProperties final : public RectangleProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // create a new itemset virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; @@ -43,9 +46,6 @@ namespace sdr::properties // destructor virtual ~CircleProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // set a new StyleSheet and broadcast virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; diff --git a/svx/inc/sdr/properties/connectorproperties.hxx b/svx/inc/sdr/properties/connectorproperties.hxx index b0d66de6544d..bc4dd3e75df3 100644 --- a/svx/inc/sdr/properties/connectorproperties.hxx +++ b/svx/inc/sdr/properties/connectorproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class ConnectorProperties final : public TextProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // create a new itemset virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; @@ -43,9 +46,6 @@ namespace sdr::properties // destructor virtual ~ConnectorProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // set a new StyleSheet and broadcast virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; diff --git a/svx/inc/sdr/properties/customshapeproperties.hxx b/svx/inc/sdr/properties/customshapeproperties.hxx index 4f7e60f3cd43..7b54f2efbee0 100644 --- a/svx/inc/sdr/properties/customshapeproperties.hxx +++ b/svx/inc/sdr/properties/customshapeproperties.hxx @@ -27,7 +27,9 @@ namespace sdr::properties { class CustomShapeProperties final : public TextProperties { - private: + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + void UpdateTextFrameStatus(bool bInvalidateRenderGeometry); // create a new itemset @@ -72,9 +74,6 @@ namespace sdr::properties // destructor virtual ~CustomShapeProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // This is the notifier from SfxListener virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; }; diff --git a/svx/inc/sdr/properties/e3dcompoundproperties.hxx b/svx/inc/sdr/properties/e3dcompoundproperties.hxx index 6dc9afd4d356..c4232eeba378 100644 --- a/svx/inc/sdr/properties/e3dcompoundproperties.hxx +++ b/svx/inc/sdr/properties/e3dcompoundproperties.hxx @@ -27,7 +27,10 @@ namespace sdr::properties { class E3dCompoundProperties : public E3dProperties { - protected: + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + + protected: // Called after ItemChange() is done for all items. virtual void PostItemChange(const sal_uInt16 nWhich) override; @@ -41,9 +44,6 @@ namespace sdr::properties // destructor virtual ~E3dCompoundProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // Get merged ItemSet. Normally, this maps directly to GetObjectItemSet(), but may // be overridden e.g for group objects to return a merged ItemSet of the object. // When using this method the returned ItemSet may contain items in the state diff --git a/svx/inc/sdr/properties/e3dextrudeproperties.hxx b/svx/inc/sdr/properties/e3dextrudeproperties.hxx index 072b1c796919..e1be2fe05be4 100644 --- a/svx/inc/sdr/properties/e3dextrudeproperties.hxx +++ b/svx/inc/sdr/properties/e3dextrudeproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class E3dExtrudeProperties final : public E3dCompoundProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // Called after ItemChange() is done for all items. virtual void PostItemChange(const sal_uInt16 nWhich) override; @@ -39,9 +42,6 @@ namespace sdr::properties // destructor virtual ~E3dExtrudeProperties() override; - - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; }; } // end of namespace sdr::properties diff --git a/svx/inc/sdr/properties/e3dlatheproperties.hxx b/svx/inc/sdr/properties/e3dlatheproperties.hxx index 56e46fb8b578..a2e18968121b 100644 --- a/svx/inc/sdr/properties/e3dlatheproperties.hxx +++ b/svx/inc/sdr/properties/e3dlatheproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class E3dLatheProperties final : public E3dCompoundProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // Called after ItemChange() is done for all items. virtual void PostItemChange(const sal_uInt16 nWhich) override; @@ -39,9 +42,6 @@ namespace sdr::properties // destructor virtual ~E3dLatheProperties() override; - - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; }; } // end of namespace sdr::properties diff --git a/svx/inc/sdr/properties/e3dproperties.hxx b/svx/inc/sdr/properties/e3dproperties.hxx index 4e93d5887cd9..b8cca761b595 100644 --- a/svx/inc/sdr/properties/e3dproperties.hxx +++ b/svx/inc/sdr/properties/e3dproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class E3dProperties : public AttributeProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + protected: // create a new itemset virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; @@ -43,9 +46,6 @@ namespace sdr::properties // destructor virtual ~E3dProperties() override; - - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; }; } // end of namespace sdr::properties diff --git a/svx/inc/sdr/properties/e3dsceneproperties.hxx b/svx/inc/sdr/properties/e3dsceneproperties.hxx index d1c10fc73afb..b5ff6b24d703 100644 --- a/svx/inc/sdr/properties/e3dsceneproperties.hxx +++ b/svx/inc/sdr/properties/e3dsceneproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class E3dSceneProperties final : public E3dProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // Called after ItemChange() is done for all items. virtual void PostItemChange(const sal_uInt16 nWhich) override; @@ -40,9 +43,6 @@ namespace sdr::properties // destructor virtual ~E3dSceneProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // get merged ItemSet. Normally, this maps directly to GetObjectItemSet(), but may // be overridden e.g for group objects to return a merged ItemSet of the object. // When using this method the returned ItemSet may contain items in the state diff --git a/svx/inc/sdr/properties/e3dsphereproperties.hxx b/svx/inc/sdr/properties/e3dsphereproperties.hxx index 61870c939d6d..937c79debbf2 100644 --- a/svx/inc/sdr/properties/e3dsphereproperties.hxx +++ b/svx/inc/sdr/properties/e3dsphereproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class E3dSphereProperties final : public E3dCompoundProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // Called after ItemChange() is done for all items. virtual void PostItemChange(const sal_uInt16 nWhich) override; @@ -39,9 +42,6 @@ namespace sdr::properties // destructor virtual ~E3dSphereProperties() override; - - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; }; } // end of namespace sdr::properties diff --git a/svx/inc/sdr/properties/emptyproperties.hxx b/svx/inc/sdr/properties/emptyproperties.hxx index 65cc0a85c743..f9363a0d78d5 100644 --- a/svx/inc/sdr/properties/emptyproperties.hxx +++ b/svx/inc/sdr/properties/emptyproperties.hxx @@ -30,13 +30,13 @@ namespace sdr::properties { class EmptyProperties final : public BaseProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + public: // basic constructor explicit EmptyProperties(SdrObject& rObj); - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // create a new object specific itemset with object specific ranges. virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool) override; diff --git a/svx/inc/sdr/properties/graphicproperties.hxx b/svx/inc/sdr/properties/graphicproperties.hxx index e1ab266ce058..96089310b8b3 100644 --- a/svx/inc/sdr/properties/graphicproperties.hxx +++ b/svx/inc/sdr/properties/graphicproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class GraphicProperties final : public RectangleProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // apply the correct SfyStyleSheet from SdrObject's SdrModel virtual void applyDefaultStyleSheetFromSdrModel() override; @@ -46,9 +49,6 @@ namespace sdr::properties // destructor virtual ~GraphicProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // set a new StyleSheet and broadcast virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; diff --git a/svx/inc/sdr/properties/groupproperties.hxx b/svx/inc/sdr/properties/groupproperties.hxx index a2f83af65c7c..a2974a6a10f4 100644 --- a/svx/inc/sdr/properties/groupproperties.hxx +++ b/svx/inc/sdr/properties/groupproperties.hxx @@ -28,8 +28,12 @@ namespace sdr::properties { class GroupProperties final : public BaseProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // the to be used ItemSet mutable std::optional moMergedItemSet; + public: // basic constructor explicit GroupProperties(SdrObject& rObj); @@ -40,9 +44,6 @@ namespace sdr::properties // create a new object specific itemset with object specific ranges. virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool) override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // get itemset virtual const SfxItemSet& GetObjectItemSet() const override; diff --git a/svx/inc/sdr/properties/measureproperties.hxx b/svx/inc/sdr/properties/measureproperties.hxx index 7d85743489ad..7c70c1984a25 100644 --- a/svx/inc/sdr/properties/measureproperties.hxx +++ b/svx/inc/sdr/properties/measureproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class MeasureProperties final : public TextProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // create a new itemset virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; @@ -43,9 +46,6 @@ namespace sdr::properties // destructor virtual ~MeasureProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // set a new StyleSheet and broadcast virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; diff --git a/svx/inc/sdr/properties/oleproperties.hxx b/svx/inc/sdr/properties/oleproperties.hxx index 2a35c3ad0ec4..f4753967f122 100644 --- a/svx/inc/sdr/properties/oleproperties.hxx +++ b/svx/inc/sdr/properties/oleproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class OleProperties final : public RectangleProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // apply the correct SfyStyleSheet from SdrObject's SdrModel virtual void applyDefaultStyleSheetFromSdrModel() override; @@ -39,9 +42,6 @@ namespace sdr::properties // destructor virtual ~OleProperties() override; - - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; }; } // end of namespace sdr::properties diff --git a/svx/inc/sdr/properties/pageproperties.hxx b/svx/inc/sdr/properties/pageproperties.hxx index 6ec599e80a04..0828cfeac268 100644 --- a/svx/inc/sdr/properties/pageproperties.hxx +++ b/svx/inc/sdr/properties/pageproperties.hxx @@ -28,6 +28,9 @@ namespace sdr::properties { class PageProperties final : public BaseProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + // the to be used ItemSet mutable std::optional mxEmptyItemSet; @@ -44,9 +47,6 @@ namespace sdr::properties // create a new object specific itemset with object specific ranges. virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& pPool) override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - virtual const SfxItemSet& GetObjectItemSet() const override; // get the installed StyleSheet diff --git a/svx/inc/sdr/properties/rectangleproperties.hxx b/svx/inc/sdr/properties/rectangleproperties.hxx index bcef4f758f7a..fb5aed74bc96 100644 --- a/svx/inc/sdr/properties/rectangleproperties.hxx +++ b/svx/inc/sdr/properties/rectangleproperties.hxx @@ -27,6 +27,9 @@ namespace sdr::properties { class RectangleProperties : public TextProperties { + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + protected: // react on ItemSet changes virtual void ItemSetChanged(std::span< const SfxPoolItem* const > aChangedItems, sal_uInt16 nDeletedWhich, bool bAdjustTextFrameWidthAndHeight = true) override; @@ -41,9 +44,6 @@ namespace sdr::properties // destructor virtual ~RectangleProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // set a new StyleSheet and broadcast virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; diff --git a/svx/inc/sdr/properties/textproperties.hxx b/svx/inc/sdr/properties/textproperties.hxx index 980096229253..f6b152aee1b3 100644 --- a/svx/inc/sdr/properties/textproperties.hxx +++ b/svx/inc/sdr/properties/textproperties.hxx @@ -28,10 +28,12 @@ namespace sdr::properties { class TextProperties : public AttributeProperties { - private: // #i101556# versioning support sal_uInt32 maVersion; + // Clone() operator, normally just calls the local copy constructor + virtual std::unique_ptr implCloneProperties(SdrObject& rObj) const override; + protected: // create a new itemset virtual SfxItemSet CreateObjectSpecificItemSet(SfxItemPool& rPool) override; @@ -55,9 +57,6 @@ namespace sdr::properties // destructor virtual ~TextProperties() override; - // Clone() operator, normally just calls the local copy constructor - virtual std::unique_ptr Clone(SdrObject& rObj) const override; - // set a new StyleSheet and broadcast virtual void SetStyleSheet(SfxStyleSheet* pNewStyleSheet, bool bDontRemoveHardAttr, bool bBroadcast, bool bAdjustTextFrameWidthAndHeight = true) override; diff --git a/svx/source/annotation/AnnotationObject.cxx b/svx/source/annotation/AnnotationObject.cxx index 75de32522e92..d84e83c3461c 100644 --- a/svx/source/annotation/AnnotationObject.cxx +++ b/svx/source/annotation/AnnotationObject.cxx @@ -232,7 +232,7 @@ OUString AnnotationObject::TakeObjNameSingul() const OUString AnnotationObject::TakeObjNamePlural() const { return u"Annotations"_ustr; } -rtl::Reference AnnotationObject::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference AnnotationObject::implCloneSdrObject(SdrModel& rTargetModel) const { return new AnnotationObject(rTargetModel, *this); } diff --git a/svx/source/engine3d/cube3d.cxx b/svx/source/engine3d/cube3d.cxx index 42a215dd3477..ecda75591485 100644 --- a/svx/source/engine3d/cube3d.cxx +++ b/svx/source/engine3d/cube3d.cxx @@ -95,7 +95,7 @@ rtl::Reference E3dCubeObj::DoConvertToPolyObj(bool /*bBezier*/, bool return nullptr; } -rtl::Reference E3dCubeObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dCubeObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dCubeObj(rTargetModel, *this); } diff --git a/svx/source/engine3d/extrud3d.cxx b/svx/source/engine3d/extrud3d.cxx index fa9b73e02797..a58ce4915f68 100644 --- a/svx/source/engine3d/extrud3d.cxx +++ b/svx/source/engine3d/extrud3d.cxx @@ -112,7 +112,7 @@ SdrObjKind E3dExtrudeObj::GetObjIdentifier() const return SdrObjKind::E3D_Extrusion; } -rtl::Reference E3dExtrudeObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dExtrudeObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dExtrudeObj(rTargetModel, *this); } diff --git a/svx/source/engine3d/lathe3d.cxx b/svx/source/engine3d/lathe3d.cxx index e8664cb949ad..22ab4f70d0fb 100644 --- a/svx/source/engine3d/lathe3d.cxx +++ b/svx/source/engine3d/lathe3d.cxx @@ -117,7 +117,7 @@ SdrObjKind E3dLatheObj::GetObjIdentifier() const return SdrObjKind::E3D_Lathe; } -rtl::Reference E3dLatheObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dLatheObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dLatheObj(rTargetModel, *this); } diff --git a/svx/source/engine3d/obj3d.cxx b/svx/source/engine3d/obj3d.cxx index 0955681dbc4c..9422d961402f 100644 --- a/svx/source/engine3d/obj3d.cxx +++ b/svx/source/engine3d/obj3d.cxx @@ -397,7 +397,7 @@ OUString E3dObject::TakeObjNamePlural() const return SvxResId(STR_ObjNamePluralObj3d); } -rtl::Reference E3dObject::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dObject::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dObject(rTargetModel, *this); } @@ -593,7 +593,7 @@ void E3dCompoundObject::RecalcSnapRect() sal_Int32(ceil(aSnapRange.getMaxX())), sal_Int32(ceil(aSnapRange.getMaxY()))); } -rtl::Reference E3dCompoundObject::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dCompoundObject::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dCompoundObject(rTargetModel, *this); } diff --git a/svx/source/engine3d/polygn3d.cxx b/svx/source/engine3d/polygn3d.cxx index 3303cfe77d60..1b71210fcbc2 100644 --- a/svx/source/engine3d/polygn3d.cxx +++ b/svx/source/engine3d/polygn3d.cxx @@ -223,7 +223,7 @@ rtl::Reference E3dPolygonObj::DoConvertToPolyObj(bool /*bBezier*/, return nullptr; } -rtl::Reference E3dPolygonObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dPolygonObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dPolygonObj(rTargetModel, *this); } diff --git a/svx/source/engine3d/scene3d.cxx b/svx/source/engine3d/scene3d.cxx index fb1151cceb74..0c59b2c2b9d6 100644 --- a/svx/source/engine3d/scene3d.cxx +++ b/svx/source/engine3d/scene3d.cxx @@ -439,7 +439,7 @@ void E3dScene::removeAllNonSelectedObjects() } } -rtl::Reference E3dScene::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dScene::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dScene(rTargetModel, *this); } diff --git a/svx/source/engine3d/sphere3d.cxx b/svx/source/engine3d/sphere3d.cxx index 35c6dc0135d2..a3a75ae55067 100644 --- a/svx/source/engine3d/sphere3d.cxx +++ b/svx/source/engine3d/sphere3d.cxx @@ -99,7 +99,7 @@ rtl::Reference E3dSphereObj::DoConvertToPolyObj(bool /*bBezier*/, boo return nullptr; } -rtl::Reference E3dSphereObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference E3dSphereObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new E3dSphereObj(rTargetModel, *this); } diff --git a/svx/source/form/fmobj.cxx b/svx/source/form/fmobj.cxx index 6a82eef6b2d3..b1e4b0e5de49 100644 --- a/svx/source/form/fmobj.cxx +++ b/svx/source/form/fmobj.cxx @@ -358,7 +358,7 @@ SdrObjKind FmFormObj::GetObjIdentifier() const return SdrObjKind::UNO; } -rtl::Reference FmFormObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference FmFormObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new FmFormObj(rTargetModel, *this); } diff --git a/svx/source/inc/fmobj.hxx b/svx/source/inc/fmobj.hxx index d19399a737ee..629e2f201db0 100644 --- a/svx/source/inc/fmobj.hxx +++ b/svx/source/inc/fmobj.hxx @@ -50,6 +50,8 @@ class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) FmFormObj final : public SdrUnoObj // protected destructor SAL_DLLPRIVATE virtual ~FmFormObj() override; + SAL_DLLPRIVATE virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: FmFormObj( SdrModel& rSdrModel, @@ -79,8 +81,6 @@ public: SAL_DLLPRIVATE virtual SdrObjKind GetObjIdentifier() const override; SAL_DLLPRIVATE virtual void NbcReformatText() override; - SAL_DLLPRIVATE virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - SAL_DLLPRIVATE static css::uno::Reference< css::uno::XInterface> ensureModelEnv( const css::uno::Reference< css::uno::XInterface>& _rSourceContainer, const css::uno::Reference< css::form::XForms>& _rTopLevelDestContainer); diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx index 3ccf39277635..53c79dbef826 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -144,74 +144,103 @@ namespace sdr::properties : DefaultProperties(rProps, rObj), mpStyleSheet(nullptr) { - SfxStyleSheet* pTargetStyleSheet(rProps.GetStyleSheet()); + const bool bModelChange(&rObj.getSdrModelFromSdrObject() != &rProps.GetSdrObject().getSdrModelFromSdrObject()); - if(pTargetStyleSheet) + if (bModelChange) { - const bool bModelChange(&rObj.getSdrModelFromSdrObject() != &rProps.GetSdrObject().getSdrModelFromSdrObject()); - - if(bModelChange) - { - // tdf#117506 - // The error shows that it is definitely necessary to solve this problem. - // Interestingly I already had a note here for 'work needed'. - // Checked in libreoffice-6-0 what happened there. In principle, the whole - // ::Clone of SdrPage and SdrObject happened in the same SdrModel, only - // afterwards a ::SetModel was used at the cloned SdrPage which went through - // all layers. The StyleSheet-problem was solved in - // AttributeProperties::MoveToItemPool at the end. There, a StyleSheet with the - // same name was searched for in the target-SdrModel. - // Start by resetting the current TargetStyleSheet so that nothing goes wrong - // when we do not find a fitting TargetStyleSheet. - // Note: The test for SdrModelChange above was wrong (compared the already set - // new SdrObject), so this never triggered and pTargetStyleSheet was never set to - // nullptr before. This means that a StyleSheet from another SdrModel was used - // which of course is very dangerous. Interestingly did not crash since when that - // other SdrModel was destroyed the ::Notify mechanism still worked reliably - // and disconnected these Properties successfully from the alien-StyleSheet. - pTargetStyleSheet = nullptr; - - // Check if we have a TargetStyleSheetPool at the target-SdrModel. This *should* - // be the case already (SdrModel::Merge and SdDrawDocument::InsertBookmarkAsPage - // have already cloned the StyleSheets to the target-SdrModel when used in Draw/impress). - // If none is found, ImpGetDefaultStyleSheet will be used to set a 'default' - // StyleSheet as StyleSheet implicitly later (that's what happened in the task, - // thus the FillStyle changed to the 'default' Blue). - // Note: It *may* be necessary to do more for StyleSheets, e.g. clone/copy the - // StyleSheet Hierarchy from the source SdrModel and/or add the Items from there - // as hard attributes. If needed, have a look at the older AttributeProperties::SetModel - // implementation from e.g. libreoffice-6-0. - SfxStyleSheetBasePool* pTargetStyleSheetPool(rObj.getSdrModelFromSdrObject().GetStyleSheetPool()); - - if(nullptr != pTargetStyleSheetPool) - { - // If we have a TargetStyleSheetPool, search for the used StyleSheet - // in the target SdrModel using the Name from the original StyleSheet - // in the source-SdrModel. - pTargetStyleSheet = dynamic_cast< SfxStyleSheet* >( - pTargetStyleSheetPool->Find( - rProps.GetStyleSheet()->GetName(), - rProps.GetStyleSheet()->GetFamily())); - } - } - } - - if(!pTargetStyleSheet) - return; - - if(HasSfxItemSet()) - { - // The SfxItemSet has been cloned and exists, - // we can directly set the SfxStyleSheet at it - ImpAddStyleSheet(pTargetStyleSheet, true); + // use default; will be corrected/handled in call to + // postProcessAfterCloneToDifferentModel below. Thus, + // also do not yet call ImpAddStyleSheet here + mpStyleSheet = GetSdrObject().getSdrModelFromSdrObject().GetDefaultStyleSheet(); } else { - // No SfxItemSet exists yet (there is none in - // the source, so none was cloned). Remember the - // SfxStyleSheet to set it when the SfxItemSet - // got constructed on-demand - mpStyleSheet = pTargetStyleSheet; + // copy existing one + mpStyleSheet = rProps.GetStyleSheet(); + + // add StyleSheet && establish the parent-links in the SfxItemSet + ImpAddStyleSheet(mpStyleSheet, true); + } + } + + void AttributeProperties::postProcessAfterCloneToDifferentModel(const SdrObject& rSrcObj) + { + SdrModel& rDstModel(GetSdrObject().getSdrModelFromSdrObject()); + const bool bModelChange(&rSrcObj.getSdrModelFromSdrObject() != &rDstModel); + + if (!bModelChange) + return; + + // guarantee SfxItemSet existence + DefaultProperties::GetObjectItemSet(); + const sdr::properties::BaseProperties& rSource(rSrcObj.GetProperties()); + SfxStyleSheet* pNewStyleSheet(nullptr); + + if (rDstModel.GetStyleSheetPool()) + { + SfxStyleSheet* pSourceStyleSheet(rSource.GetStyleSheet()); + + if (pSourceStyleSheet) + { + // If we have a TargetStyleSheetPool, search for the used StyleSheet + // in the target SdrModel using the Name from the original StyleSheet + // in the source-SdrModel. + // That will/should work always since Paste from another model will + // in a 1st step copy non-existing StyleSheets to destination model + pNewStyleSheet = dynamic_cast< SfxStyleSheet* >( + rDstModel.GetStyleSheetPool()->Find( + pSourceStyleSheet->GetName(), + pSourceStyleSheet->GetFamily())); + } + } + + // fallback: every SdrObject *should* have a StyleSheet, use + // default from the model + if(!pNewStyleSheet) + pNewStyleSheet = rDstModel.GetDefaultStyleSheet(); + + if(!pNewStyleSheet) + // may still have no StyleSheet, was so before, too, but + // should not happen since a DefaultStyleSheet should + // always be there + return; + + // add StyleSheet && establish the parent-links in the SfxItemSet + if (GetStyleSheet() != pNewStyleSheet) + { + ImpRemoveStyleSheet(); + ImpAddStyleSheet(pNewStyleSheet, true); + } + + if (HasSfxItemSet()) + { + // here we have a model change and a StyleSheet set,. but that + // StyleSheet was found by looking for name & type. It may + // *not* be identical to the StyleSheet from the Source. + + // What to do? We could... + // (a) the Style-friendly way: + // - check if StyleSheet is identical + // - if not, create a new in-between StyleSheet hosting missing Items + // - if yes, use, done. + // (b) the pragmatic/practical way: + // - Just hard-attribute the Items that are detected as different + // similar to what BurnInStyleSheetAttributes does/did, but only + // for differing Items here + // + // (b)) is the most simple for now, but will lead to more hard + // attributes. The other possibilities will be better in the + // long term. For now, I will use (b). + SfxWhichIter aIter(rSource.GetObjectItemSet()); + + for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich()) + { + const SfxPoolItem& rOld(rSource.GetItem(nWhich)); + const SfxPoolItem& rNew(GetItem(nWhich)); + + if (!SfxPoolItem::areSame(rOld, rNew)) + SetObjectItemDirect(rOld); + } } } @@ -220,7 +249,7 @@ namespace sdr::properties ImpRemoveStyleSheet(); } - std::unique_ptr AttributeProperties::Clone(SdrObject&) const + std::unique_ptr AttributeProperties::implCloneProperties(SdrObject&) const { assert(false && "this class is effectively abstract, should only be instantiating subclasses"); abort(); diff --git a/svx/source/sdr/properties/captionproperties.cxx b/svx/source/sdr/properties/captionproperties.cxx index 958f9eecf080..dd71a6640791 100644 --- a/svx/source/sdr/properties/captionproperties.cxx +++ b/svx/source/sdr/properties/captionproperties.cxx @@ -57,7 +57,7 @@ namespace sdr::properties { } - std::unique_ptr CaptionProperties::Clone(SdrObject& rObj) const + std::unique_ptr CaptionProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new CaptionProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/circleproperties.cxx b/svx/source/sdr/properties/circleproperties.cxx index 217b9e7b257e..404023e507d8 100644 --- a/svx/source/sdr/properties/circleproperties.cxx +++ b/svx/source/sdr/properties/circleproperties.cxx @@ -61,7 +61,7 @@ namespace sdr::properties { } - std::unique_ptr CircleProperties::Clone(SdrObject& rObj) const + std::unique_ptr CircleProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new CircleProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/connectorproperties.cxx b/svx/source/sdr/properties/connectorproperties.cxx index e5e29de75979..778681834821 100644 --- a/svx/source/sdr/properties/connectorproperties.cxx +++ b/svx/source/sdr/properties/connectorproperties.cxx @@ -59,7 +59,7 @@ namespace sdr::properties { } - std::unique_ptr ConnectorProperties::Clone(SdrObject& rObj) const + std::unique_ptr ConnectorProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new ConnectorProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/customshapeproperties.cxx b/svx/source/sdr/properties/customshapeproperties.cxx index c63d7e4a4b3c..d56b32a4b278 100644 --- a/svx/source/sdr/properties/customshapeproperties.cxx +++ b/svx/source/sdr/properties/customshapeproperties.cxx @@ -195,7 +195,7 @@ namespace sdr::properties { } - std::unique_ptr CustomShapeProperties::Clone(SdrObject& rObj) const + std::unique_ptr CustomShapeProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new CustomShapeProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/defaultproperties.cxx b/svx/source/sdr/properties/defaultproperties.cxx index cf2d196f3862..f5a551137660 100644 --- a/svx/source/sdr/properties/defaultproperties.cxx +++ b/svx/source/sdr/properties/defaultproperties.cxx @@ -88,7 +88,7 @@ namespace sdr::properties } } - std::unique_ptr DefaultProperties::Clone(SdrObject& rObj) const + std::unique_ptr DefaultProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new DefaultProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/e3dcompoundproperties.cxx b/svx/source/sdr/properties/e3dcompoundproperties.cxx index 8ad00d6092b9..755af4c8f2c9 100644 --- a/svx/source/sdr/properties/e3dcompoundproperties.cxx +++ b/svx/source/sdr/properties/e3dcompoundproperties.cxx @@ -39,7 +39,7 @@ namespace sdr::properties { } - std::unique_ptr E3dCompoundProperties::Clone(SdrObject& rObj) const + std::unique_ptr E3dCompoundProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new E3dCompoundProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/e3dextrudeproperties.cxx b/svx/source/sdr/properties/e3dextrudeproperties.cxx index 9b9ffd8be9ab..3caac2b5816e 100644 --- a/svx/source/sdr/properties/e3dextrudeproperties.cxx +++ b/svx/source/sdr/properties/e3dextrudeproperties.cxx @@ -37,7 +37,7 @@ namespace sdr::properties { } - std::unique_ptr E3dExtrudeProperties::Clone(SdrObject& rObj) const + std::unique_ptr E3dExtrudeProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new E3dExtrudeProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/e3dlatheproperties.cxx b/svx/source/sdr/properties/e3dlatheproperties.cxx index feb546534d47..329ed34eac37 100644 --- a/svx/source/sdr/properties/e3dlatheproperties.cxx +++ b/svx/source/sdr/properties/e3dlatheproperties.cxx @@ -37,7 +37,7 @@ namespace sdr::properties { } - std::unique_ptr E3dLatheProperties::Clone(SdrObject& rObj) const + std::unique_ptr E3dLatheProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new E3dLatheProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/e3dproperties.cxx b/svx/source/sdr/properties/e3dproperties.cxx index 2cd011ffbb55..672b2249ae81 100644 --- a/svx/source/sdr/properties/e3dproperties.cxx +++ b/svx/source/sdr/properties/e3dproperties.cxx @@ -55,7 +55,7 @@ namespace sdr::properties { } - std::unique_ptr E3dProperties::Clone(SdrObject& rObj) const + std::unique_ptr E3dProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new E3dProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/e3dsceneproperties.cxx b/svx/source/sdr/properties/e3dsceneproperties.cxx index 1716eece9a20..3ca38beacc04 100644 --- a/svx/source/sdr/properties/e3dsceneproperties.cxx +++ b/svx/source/sdr/properties/e3dsceneproperties.cxx @@ -42,7 +42,7 @@ namespace sdr::properties { } - std::unique_ptr E3dSceneProperties::Clone(SdrObject& rObj) const + std::unique_ptr E3dSceneProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new E3dSceneProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/e3dsphereproperties.cxx b/svx/source/sdr/properties/e3dsphereproperties.cxx index 66f01748f293..88a456cc228a 100644 --- a/svx/source/sdr/properties/e3dsphereproperties.cxx +++ b/svx/source/sdr/properties/e3dsphereproperties.cxx @@ -37,7 +37,7 @@ namespace sdr::properties { } - std::unique_ptr E3dSphereProperties::Clone(SdrObject& rObj) const + std::unique_ptr E3dSphereProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new E3dSphereProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/emptyproperties.cxx b/svx/source/sdr/properties/emptyproperties.cxx index 6f7b0f6876e5..3b56b8fa5122 100644 --- a/svx/source/sdr/properties/emptyproperties.cxx +++ b/svx/source/sdr/properties/emptyproperties.cxx @@ -31,7 +31,7 @@ namespace sdr::properties { } - std::unique_ptr EmptyProperties::Clone(SdrObject& rObj) const + std::unique_ptr EmptyProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new EmptyProperties(rObj)); } diff --git a/svx/source/sdr/properties/graphicproperties.cxx b/svx/source/sdr/properties/graphicproperties.cxx index 53c97e817952..730ec5314905 100644 --- a/svx/source/sdr/properties/graphicproperties.cxx +++ b/svx/source/sdr/properties/graphicproperties.cxx @@ -89,7 +89,7 @@ namespace sdr::properties { } - std::unique_ptr GraphicProperties::Clone(SdrObject& rObj) const + std::unique_ptr GraphicProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new GraphicProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/groupproperties.cxx b/svx/source/sdr/properties/groupproperties.cxx index 51e6a7d922e9..c4cb117bbbe6 100644 --- a/svx/source/sdr/properties/groupproperties.cxx +++ b/svx/source/sdr/properties/groupproperties.cxx @@ -38,7 +38,7 @@ namespace sdr::properties { } - std::unique_ptr GroupProperties::Clone(SdrObject& rObj) const + std::unique_ptr GroupProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new GroupProperties(rObj)); } diff --git a/svx/source/sdr/properties/measureproperties.cxx b/svx/source/sdr/properties/measureproperties.cxx index dd235aab8fe4..9ae9461eac8e 100644 --- a/svx/source/sdr/properties/measureproperties.cxx +++ b/svx/source/sdr/properties/measureproperties.cxx @@ -67,7 +67,7 @@ namespace sdr::properties { } - std::unique_ptr MeasureProperties::Clone(SdrObject& rObj) const + std::unique_ptr MeasureProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new MeasureProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/oleproperties.cxx b/svx/source/sdr/properties/oleproperties.cxx index 5310e74e30c6..ecb6b0b38b08 100644 --- a/svx/source/sdr/properties/oleproperties.cxx +++ b/svx/source/sdr/properties/oleproperties.cxx @@ -56,7 +56,7 @@ namespace sdr::properties { } - std::unique_ptr OleProperties::Clone(SdrObject& rObj) const + std::unique_ptr OleProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new OleProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/pageproperties.cxx b/svx/source/sdr/properties/pageproperties.cxx index 6b532d2d487b..9b5479ac9220 100644 --- a/svx/source/sdr/properties/pageproperties.cxx +++ b/svx/source/sdr/properties/pageproperties.cxx @@ -41,7 +41,7 @@ namespace sdr::properties { } - std::unique_ptr PageProperties::Clone(SdrObject& rObj) const + std::unique_ptr PageProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new PageProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/properties.cxx b/svx/source/sdr/properties/properties.cxx index 612813bb1aac..401a1fc3085b 100644 --- a/svx/source/sdr/properties/properties.cxx +++ b/svx/source/sdr/properties/properties.cxx @@ -40,6 +40,15 @@ namespace sdr::properties { } + void BaseProperties::postProcessAfterCloneToDifferentModel(const SdrObject& /*rSrcObj*/) + { + } + + std::unique_ptr BaseProperties::Clone(SdrObject& rObj) const + { + return implCloneProperties(rObj); + } + const SdrObject& BaseProperties::GetSdrObject() const { return mrObject; diff --git a/svx/source/sdr/properties/rectangleproperties.cxx b/svx/source/sdr/properties/rectangleproperties.cxx index 9242fa5f9ac5..619927399556 100644 --- a/svx/source/sdr/properties/rectangleproperties.cxx +++ b/svx/source/sdr/properties/rectangleproperties.cxx @@ -37,7 +37,7 @@ namespace sdr::properties { } - std::unique_ptr RectangleProperties::Clone(SdrObject& rObj) const + std::unique_ptr RectangleProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new RectangleProperties(*this, rObj)); } diff --git a/svx/source/sdr/properties/textproperties.cxx b/svx/source/sdr/properties/textproperties.cxx index b1a3d7a98ca0..afa93e40bfda 100644 --- a/svx/source/sdr/properties/textproperties.cxx +++ b/svx/source/sdr/properties/textproperties.cxx @@ -78,7 +78,7 @@ namespace sdr::properties { } - std::unique_ptr TextProperties::Clone(SdrObject& rObj) const + std::unique_ptr TextProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new TextProperties(*this, rObj)); } diff --git a/svx/source/svdraw/svdoashp.cxx b/svx/source/svdraw/svdoashp.cxx index 0af41c392f2e..0a07b633180b 100644 --- a/svx/source/svdraw/svdoashp.cxx +++ b/svx/source/svdraw/svdoashp.cxx @@ -2788,7 +2788,7 @@ void SdrObjCustomShape::NbcSetOutlinerParaObject(std::optional SdrObjCustomShape::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrObjCustomShape::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrObjCustomShape(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index 4eea5bda4ef4..f47485bc983f 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -110,8 +110,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -1214,6 +1216,19 @@ bool SdrObject::HasLimitedRotation() const return false; } +rtl::Reference SdrObject::CloneSdrObject(SdrModel& rTargetModel) const +{ + if (&rTargetModel == &getSdrModelFromSdrObject()) + // clone to same model, simple method + return implCloneSdrObject(rTargetModel); + + // clone to different model, need to do more for creating a valid + // Style and Properties + rtl::Reference aRetval(implCloneSdrObject(rTargetModel)); + aRetval->GetProperties().postProcessAfterCloneToDifferentModel(*this); + return aRetval; +} + OUString SdrObject::TakeObjNameSingul() const { OUString sName(SvxResId(STR_ObjNameSingulNONE)); @@ -1920,7 +1935,7 @@ bool SdrObject::HasTextEdit() const bool SdrObject::Equals(const SdrObject& rOtherObj) const { - return (m_aAnchor.X() == rOtherObj.m_aAnchor.X() && m_aAnchor.Y() == rOtherObj.m_aAnchor.Y() && + const bool bEqual(m_aAnchor.X() == rOtherObj.m_aAnchor.X() && m_aAnchor.Y() == rOtherObj.m_aAnchor.Y() && m_nOrdNum == rOtherObj.m_nOrdNum && mnNavigationPosition == rOtherObj.mnNavigationPosition && mbSupportTextIndentingOnLineWidthChange == rOtherObj.mbSupportTextIndentingOnLineWidthChange && m_aCustomPromptText == rOtherObj.m_aCustomPromptText && @@ -1929,7 +1944,87 @@ bool SdrObject::Equals(const SdrObject& rOtherObj) const m_bNotVisibleAsMaster == rOtherObj.m_bNotVisibleAsMaster && m_bEmptyPresObj == rOtherObj.m_bEmptyPresObj && mbVisible == rOtherObj.mbVisible && m_bNoPrint == rOtherObj.m_bNoPrint && m_bSizProt == rOtherObj.m_bSizProt && m_bMovProt == rOtherObj.m_bMovProt && m_bVirtObj == rOtherObj.m_bVirtObj && - mnLayerID == rOtherObj.mnLayerID && GetMergedItemSet().Equals(rOtherObj.GetMergedItemSet(), false) ); + mnLayerID == rOtherObj.mnLayerID && IsGroupObject() == rOtherObj.IsGroupObject()); + + if (!bEqual) + // compare results *without* Items are already not equal, done + return false; + + if (IsGroupObject()) + { + // for GroupObjects, do what was done before. NOTE: This will create + // merged ItemSets for Group content, not sure if that is needed. + // It would also be possible to enter content & compare recursively + return GetMergedItemSet().Equals(rOtherObj.GetMergedItemSet(), false); + } + + // Do ContentCompare - Items are compared including parent e.g. Styles. + // The check above what was done before is more 'hard' in the sense that + // it WILL fail for same Item content when e.g. count of hard Items differs, + // but with parent ItemSet is actually equal. ContentCompare is necessary + // after e.g. in AttributeProperties::postProcessAfterCloneToDifferentModel + // the Items of an Object were hard-set/corrected + const SfxItemSet& rSrcItemSet(GetObjectItemSet()); + const SfxItemSet& rDstItemSet(rOtherObj.GetObjectItemSet()); + SfxWhichIter aIter(rSrcItemSet); + const SdrPage* pPage(getSdrPageFromSdrObject()); + const bool bOnMasterPage(nullptr != pPage && pPage->IsMasterPage()); + + for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich()) + { + const SfxPoolItem& rOld(rSrcItemSet.Get(nWhich)); + const SfxPoolItem& rNew(rDstItemSet.Get(nWhich)); + + if (!SfxPoolItem::areSame(rOld, rNew)) + { + if (bOnMasterPage) + { + // we have strange effects for Items in Objects on MasterPages on + // some Items that seem to be corrected/set different due to being + // PresObjs or defaults or similar on MasterPage. React on those + // on MasterPages + switch (nWhich) + { + case XATTRSET_LINE: + case XATTRSET_FILL: + // these Items are not really used (maybe removed), + // ignore. Diffs come from these being SfxSetItems + // on different models with slightly different defaults + // in the contained complete default SfxItemSet + continue; + + // somewhere defaults for some objects seem to be set on MasterPages + // that define Items (here: for XATTR_FILLGRADIENT and FillStyle_BITMAP). + // These can be ignored when the FillStyle does not *use* these anyways. + // Better do this already for all FillStyles, you never know. + case XATTR_FILLCOLOR: + if (drawing::FillStyle_SOLID != rSrcItemSet.Get(XATTR_FILLSTYLE).GetValue()) + continue; + break; + case XATTR_FILLGRADIENT: + if (drawing::FillStyle_GRADIENT != rSrcItemSet.Get(XATTR_FILLSTYLE).GetValue()) + continue; + break; + case XATTR_FILLHATCH: + if (drawing::FillStyle_HATCH != rSrcItemSet.Get(XATTR_FILLSTYLE).GetValue()) + continue; + break; + case XATTR_FILLBITMAP: + if (drawing::FillStyle_BITMAP != rSrcItemSet.Get(XATTR_FILLSTYLE).GetValue()) + continue; + break; + + default: break; + } + } + + // Item is different, done + return false; + } + } + + // all Items are Content-Equal + return true; } void SdrObject::dumpAsXml(xmlTextWriterPtr pWriter) const @@ -3461,7 +3556,7 @@ public: { } - rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override + rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override { return new EmptyObject(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdocapt.cxx b/svx/source/svdraw/svdocapt.cxx index d9c45cb2f5a8..1f21395e3323 100644 --- a/svx/source/svdraw/svdocapt.cxx +++ b/svx/source/svdraw/svdocapt.cxx @@ -232,7 +232,7 @@ SdrObjKind SdrCaptionObj::GetObjIdentifier() const return SdrObjKind::Caption; } -rtl::Reference SdrCaptionObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrCaptionObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrCaptionObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx index 12a04b95ed19..9d68ef5e4288 100644 --- a/svx/source/svdraw/svdocirc.cxx +++ b/svx/source/svdraw/svdocirc.cxx @@ -370,7 +370,7 @@ OUString SdrCircObj::TakeObjNamePlural() const return SvxResId(pID); } -rtl::Reference SdrCircObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrCircObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrCircObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdoedge.cxx b/svx/source/svdraw/svdoedge.cxx index b0cb26dae6ab..0d23a5d9eecd 100644 --- a/svx/source/svdraw/svdoedge.cxx +++ b/svx/source/svdraw/svdoedge.cxx @@ -1721,7 +1721,7 @@ void SdrEdgeObj::Reformat() } } -rtl::Reference SdrEdgeObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrEdgeObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrEdgeObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index 5c21e9ff74c2..b3d163290f00 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -856,7 +856,7 @@ rtl::Reference SdrGrafObj::getFullDragClone() const return pRetval; } -rtl::Reference SdrGrafObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrGrafObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrGrafObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdogrp.cxx b/svx/source/svdraw/svdogrp.cxx index 1760373fe791..a426b2f8c36c 100644 --- a/svx/source/svdraw/svdogrp.cxx +++ b/svx/source/svdraw/svdogrp.cxx @@ -268,7 +268,7 @@ const tools::Rectangle& SdrObjGroup::GetSnapRect() const } } -rtl::Reference SdrObjGroup::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrObjGroup::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrObjGroup(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdomeas.cxx b/svx/source/svdraw/svdomeas.cxx index 074676ef1015..c520810f16d0 100644 --- a/svx/source/svdraw/svdomeas.cxx +++ b/svx/source/svdraw/svdomeas.cxx @@ -703,7 +703,7 @@ void SdrMeasureObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const } } -rtl::Reference SdrMeasureObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrMeasureObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrMeasureObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index 8f9d251171a4..3cdfa995359f 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -207,7 +207,7 @@ OUString SdrMediaObj::TakeObjNamePlural() const return SvxResId(STR_ObjNamePluralMEDIA); } -rtl::Reference SdrMediaObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrMediaObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrMediaObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 69902e416175..90107e4e1ce5 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -1577,7 +1577,7 @@ OUString SdrOle2Obj::TakeObjNamePlural() const return SvxResId(mpImpl->mbFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2); } -rtl::Reference SdrOle2Obj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrOle2Obj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrOle2Obj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdopage.cxx b/svx/source/svdraw/svdopage.cxx index 448758646afe..a04c84c3f6b2 100644 --- a/svx/source/svdraw/svdopage.cxx +++ b/svx/source/svdraw/svdopage.cxx @@ -151,7 +151,7 @@ void SdrPageObj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const rInfo.bCanConvToPolyLineToArea=false; } -rtl::Reference SdrPageObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrPageObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrPageObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx index dc55745b9505..ed713ad2751e 100644 --- a/svx/source/svdraw/svdopath.cxx +++ b/svx/source/svdraw/svdopath.cxx @@ -1821,7 +1821,7 @@ SdrObjKind SdrPathObj::GetObjIdentifier() const return meKind; } -rtl::Reference SdrPathObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrPathObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrPathObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdorect.cxx b/svx/source/svdraw/svdorect.cxx index 836422abebeb..0c31fbc8f027 100644 --- a/svx/source/svdraw/svdorect.cxx +++ b/svx/source/svdraw/svdorect.cxx @@ -214,7 +214,7 @@ OUString SdrRectObj::TakeObjNamePlural() const return SvxResId(pResId); } -rtl::Reference SdrRectObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrRectObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrRectObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index d8bb27266a09..684060b611ea 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1055,7 +1055,7 @@ OUString SdrTextObj::TakeObjNamePlural() const return sName; } -rtl::Reference SdrTextObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrTextObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrTextObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdouno.cxx b/svx/source/svdraw/svdouno.cxx index 0726d31ef4c4..3d690f889b9d 100644 --- a/svx/source/svdraw/svdouno.cxx +++ b/svx/source/svdraw/svdouno.cxx @@ -274,7 +274,7 @@ OUString SdrUnoObj::TakeObjNamePlural() const return SvxResId(STR_ObjNamePluralUno); } -rtl::Reference SdrUnoObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrUnoObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrUnoObj(rTargetModel, *this); } diff --git a/svx/source/svdraw/svdovirt.cxx b/svx/source/svdraw/svdovirt.cxx index 3bcd8202ef1d..dcba9c00707b 100644 --- a/svx/source/svdraw/svdovirt.cxx +++ b/svx/source/svdraw/svdovirt.cxx @@ -200,7 +200,7 @@ void SdrVirtObj::RecalcBoundRect() setOutRectangle(aRectangle); } -rtl::Reference SdrVirtObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrVirtObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrVirtObj(rTargetModel, *this); // TTTT not sure if the above works - how could SdrObjFactory::MakeNewObject diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 49189685be31..06bfbb189e2e 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -174,7 +174,7 @@ SdrText* CellTextProvider::getText(sal_Int32 nIndex) const { } - std::unique_ptr CellProperties::Clone(SdrObject& rObj) const + std::unique_ptr CellProperties::implCloneProperties(SdrObject& rObj) const { OSL_FAIL("CellProperties::Clone(), does not work yet!"); return std::unique_ptr(new CellProperties(*this, rObj,nullptr)); diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 38b16e05706e..dbbad0f788a2 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -99,7 +99,7 @@ public: TableProperties(const TableProperties& rProps, SdrObject& rObj ); // Clone() operator, normally just calls the local copy constructor - std::unique_ptr Clone(SdrObject& rObj) const override; + std::unique_ptr implCloneProperties(SdrObject& rObj) const override; virtual void ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem = nullptr) override; }; @@ -116,7 +116,7 @@ TableProperties::TableProperties(const TableProperties& rProps, SdrObject& rObj) { } -std::unique_ptr TableProperties::Clone(SdrObject& rObj) const +std::unique_ptr TableProperties::implCloneProperties(SdrObject& rObj) const { return std::unique_ptr(new TableProperties(*this, rObj)); } @@ -1782,7 +1782,7 @@ OUString SdrTableObj::TakeObjNamePlural() const } -rtl::Reference SdrTableObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SdrTableObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SdrTableObj(rTargetModel, *this); } diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx index 5e87b3e58d5f..dca8508977b1 100644 --- a/sw/inc/dcontact.hxx +++ b/sw/inc/dcontact.hxx @@ -209,7 +209,6 @@ public: in later headers. */ class SwDrawVirtObj final : public SdrVirtObj { - private: // data for connection to writer layout /** anchored drawing object instance for the 'virtual' drawing object */ @@ -228,6 +227,8 @@ class SwDrawVirtObj final : public SdrVirtObj // protected destructor virtual ~SwDrawVirtObj() override; + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SwDrawVirtObj( SdrModel& rSdrModel, @@ -239,8 +240,6 @@ class SwDrawVirtObj final : public SdrVirtObj /// access to offset virtual Point GetOffset() const override; - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - /// connection to writer layout const SwAnchoredObject& GetAnchoredObj() const { return maAnchoredDrawObj; } SwAnchoredObject& AnchoredObj() { return maAnchoredDrawObj; } diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx index eb2d208a5069..bffb0c4df509 100644 --- a/sw/source/core/draw/dcontact.cxx +++ b/sw/source/core/draw/dcontact.cxx @@ -2343,7 +2343,7 @@ SwDrawVirtObj::~SwDrawVirtObj() { } -rtl::Reference SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SwDrawVirtObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SwDrawVirtObj(rTargetModel, *this); } diff --git a/sw/source/core/draw/dflyobj.cxx b/sw/source/core/draw/dflyobj.cxx index 446fc2b1ea46..36397d3fab20 100644 --- a/sw/source/core/draw/dflyobj.cxx +++ b/sw/source/core/draw/dflyobj.cxx @@ -145,7 +145,7 @@ SdrObjKind SwFlyDrawObj::GetObjIdentifier() const return SdrObjKind::SwFlyDrawObjIdentifier; } -rtl::Reference SwFlyDrawObj::CloneSdrObject(SdrModel& rTargetModel) const +rtl::Reference SwFlyDrawObj::implCloneSdrObject(SdrModel& rTargetModel) const { return new SwFlyDrawObj(rTargetModel); } diff --git a/sw/source/core/inc/dflyobj.hxx b/sw/source/core/inc/dflyobj.hxx index 1ebcf2cecd43..e58d87452880 100644 --- a/sw/source/core/inc/dflyobj.hxx +++ b/sw/source/core/inc/dflyobj.hxx @@ -33,7 +33,6 @@ class SwFrameFormat; // DrawObjects for Flys class SwFlyDrawObj final : public SdrObject { -private: virtual std::unique_ptr CreateObjectSpecificProperties() override; bool mbIsTextBox; @@ -44,12 +43,12 @@ private: // protected destructor virtual ~SwFlyDrawObj() override; + // for instantiation of this class while loading (via factory + virtual rtl::Reference implCloneSdrObject(SdrModel& rTargetModel) const override; + public: SwFlyDrawObj(SdrModel& rSdrModel); - // for instantiation of this class while loading (via factory - virtual rtl::Reference CloneSdrObject(SdrModel& rTargetModel) const override; - virtual SdrInventor GetObjInventor() const override; virtual SdrObjKind GetObjIdentifier() const override; virtual bool IsTextBox() const override { return mbIsTextBox; }