summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-02-09 13:42:22 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-02-10 07:35:41 +0100
commit09cb778b6eb7d3a5b9029965a1320b49c90e7295 (patch)
tree63d75bc66ddbe4af5f6a52f4a0d65e9b199dbae7 /sw
parentccdee8eebaa56619248e35001017226eecfe4e83 (diff)
clean up SdrObject cloning
using operator= implies that overwriting an SdrObject is a useful operation, but that is not at all true - they are typically linked into and referred to by many other things. So rather use a copy-constructor. Also clean up a couple of weird "do some stuff after the clone" code into the main copy constructor. Change-Id: Iefc1481b527602748b5f3abed06e7cca66c0581c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110633 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/dcontact.hxx3
-rw-r--r--sw/source/core/draw/dcontact.cxx31
2 files changed, 18 insertions, 16 deletions
diff --git a/sw/inc/dcontact.hxx b/sw/inc/dcontact.hxx
index 07114eedf59d..539819ec1e14 100644
--- a/sw/inc/dcontact.hxx
+++ b/sw/inc/dcontact.hxx
@@ -233,12 +233,13 @@ class SwDrawVirtObj final : public SdrVirtObj
SdrModel& rSdrModel,
SdrObject& _rNewObj,
SwDrawContact& _rDrawContact);
+ // copy constructor
+ SwDrawVirtObj(SdrModel& rSdrModel, SwDrawVirtObj const & rSource);
/// access to offset
virtual Point GetOffset() const override;
virtual SwDrawVirtObj* CloneSdrObject(SdrModel& rTargetModel) const override;
- SwDrawVirtObj& operator= (const SwDrawVirtObj& rObj);
/// connection to writer layout
const SwAnchoredObject& GetAnchoredObj() const { return maAnchoredDrawObj; }
diff --git a/sw/source/core/draw/dcontact.cxx b/sw/source/core/draw/dcontact.cxx
index 3d7fdc18120d..d1250d5305de 100644
--- a/sw/source/core/draw/dcontact.cxx
+++ b/sw/source/core/draw/dcontact.cxx
@@ -2205,29 +2205,30 @@ SwDrawVirtObj::SwDrawVirtObj(
NbcMove( Size( -16000, -16000 ) );
}
-SwDrawVirtObj::~SwDrawVirtObj()
+SwDrawVirtObj::SwDrawVirtObj(
+ SdrModel& rSdrModel,
+ SwDrawVirtObj const & rSource)
+: SdrVirtObj(rSdrModel, rSource),
+ maAnchoredDrawObj(),
+ mrDrawContact(rSource.mrDrawContact)
{
-}
+ // #i26791#
+ maAnchoredDrawObj.SetDrawObj( *this );
+
+ // #i35635# - set initial position out of sight
+ NbcMove( Size( -16000, -16000 ) );
-SwDrawVirtObj& SwDrawVirtObj::operator=( const SwDrawVirtObj& rObj )
-{
- SdrVirtObj::operator=(rObj);
// Note: Members <maAnchoredDrawObj> and <mrDrawContact>
// haven't to be considered.
- return *this;
}
-SwDrawVirtObj* SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
+SwDrawVirtObj::~SwDrawVirtObj()
{
- SwDrawVirtObj* pObj = new SwDrawVirtObj(
- rTargetModel,
- rRefObj,
- mrDrawContact);
-
- pObj->operator=( *this );
- // Note: Member <maAnchoredDrawObj> hasn't to be considered.
+}
- return pObj;
+SwDrawVirtObj* SwDrawVirtObj::CloneSdrObject(SdrModel& rTargetModel) const
+{
+ return new SwDrawVirtObj(rTargetModel, *this);
}
const SwFrame* SwDrawVirtObj::GetAnchorFrame() const