svx: make SdrObject abstract by making CloneSdrObject pure virtual

This change makes SdrObject an abstract class that can't be as
we don't want it to be instantiated. With this the ClonseSdrObject
became a pure virtual function.

With this change also the SwFlyDrawObj needs a implementation of
the CloneSdrFunction, which was previously provided by SdrObject.

Change-Id: I2efb8c1e6fac12b17ce497285067029d7da1c1fd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148239
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
Tomaž Vajngerl
2023-03-05 01:41:21 +00:00
committed by Tomaž Vajngerl
parent 89d19cf6e7
commit b53b01a050
4 changed files with 17 additions and 8 deletions
+1 -1
View File
@@ -442,7 +442,7 @@ public:
virtual bool HasLimitedRotation() const;
// Returns a copy of the object. Every inherited class must reimplement this.
virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const;
virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const = 0;
// helper, since Clone always return the type of the current subclass
template<class T>
static rtl::Reference<T> Clone(T const & rObj, SdrModel& rTargetModel)
+1 -6
View File
@@ -1048,11 +1048,6 @@ bool SdrObject::HasLimitedRotation() const
return false;
}
rtl::Reference<SdrObject> SdrObject::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SdrObject(rTargetModel, *this);
}
OUString SdrObject::TakeObjNameSingul() const
{
OUString sName(SvxResId(STR_ObjNameSingulNONE));
@@ -3329,7 +3324,7 @@ rtl::Reference<SdrObject> SdrObjFactory::MakeNewObject(
}
}
break;
case SdrObjKind::NONE : pObj=new SdrObject(rSdrModel); break;
case SdrObjKind::NONE : pObj = nullptr; break;
case SdrObjKind::Group : pObj=new SdrObjGroup(rSdrModel); break;
case SdrObjKind::Polygon : pObj=new SdrPathObj(rSdrModel, SdrObjKind::Polygon ); break;
case SdrObjKind::PolyLine : pObj=new SdrPathObj(rSdrModel, SdrObjKind::PolyLine ); break;
+11
View File
@@ -130,6 +130,12 @@ SwFlyDrawObj::SwFlyDrawObj(SdrModel& rSdrModel)
{
}
SwFlyDrawObj::SwFlyDrawObj(SdrModel& rSdrModel, SwFlyDrawObj const& rSource)
: SdrObject(rSdrModel, rSource)
, mbIsTextBox(false)
{
}
SwFlyDrawObj::~SwFlyDrawObj()
{
}
@@ -145,6 +151,11 @@ SdrObjKind SwFlyDrawObj::GetObjIdentifier() const
return SdrObjKind::SwFlyDrawObjIdentifier;
}
rtl::Reference<SdrObject> SwFlyDrawObj::CloneSdrObject(SdrModel& rTargetModel) const
{
return new SwFlyDrawObj(rTargetModel);
}
// TODO: Need own primitive to get the FlyFrame paint working
namespace drawinglayer::primitive2d
{
+4 -1
View File
@@ -44,8 +44,11 @@ private:
public:
SwFlyDrawObj(SdrModel& rSdrModel);
SwFlyDrawObj(SdrModel& rSdrModel, SwFlyDrawObj const& rSource);
// for instantiation of this class while loading (via factory
virtual rtl::Reference<SdrObject> CloneSdrObject(SdrModel& rTargetModel) const override;
// for instantiation of this class while loading (via factory)
virtual SdrInventor GetObjInventor() const override;
virtual SdrObjKind GetObjIdentifier() const override;
virtual bool IsTextBox() const override { return mbIsTextBox; }