summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-08 13:30:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-08 15:29:38 +0200
commit030273e2e28ef9c4d2118ca3851c64498dfe000a (patch)
tree90d6d272d8992b88366b974264fb3e28ed2acc7b /svx
parenta27eb931c22313d4dd5c73b35358c0532d20b79e (diff)
clean up SdrDragStat
- some light formatting in the header file - change aPnts from std::vector<Point*> to std::vector<Point>, no point in dynamically allocating a small value class - rename aPnts -> mvPnts - use std::unique_ptr for userdata - rename pUser to mpUserData - change some methods protected->private, since nothing external is using them Change-Id: I7a3f4c30c60ae1be3713f460fe65de95bed2f124 Reviewed-on: https://gerrit.libreoffice.org/42102 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/svdraw/svddrag.cxx37
-rw-r--r--svx/source/svdraw/svdocirc.cxx2
-rw-r--r--svx/source/svdraw/svdopath.cxx4
3 files changed, 16 insertions, 27 deletions
diff --git a/svx/source/svdraw/svddrag.cxx b/svx/source/svdraw/svddrag.cxx
index f9d943f009c5..76a7e59bceec 100644
--- a/svx/source/svdraw/svddrag.cxx
+++ b/svx/source/svdraw/svddrag.cxx
@@ -22,18 +22,16 @@
SdrDragStatUserData::~SdrDragStatUserData() = default;
+SdrDragStat::~SdrDragStat()
+{
+}
+
void SdrDragStat::Clear(bool bLeaveOne)
{
- while (!aPnts.empty()) {
- delete aPnts.back();
- aPnts.pop_back();
- }
- delete pUser;
- pUser=nullptr;
- aPnts.clear();
- if (bLeaveOne) {
- aPnts.push_back(new Point);
- }
+ mpUserData.reset();
+ mvPnts.clear();
+ if (bLeaveOne)
+ mvPnts.emplace_back();
}
void SdrDragStat::Reset()
@@ -70,33 +68,24 @@ void SdrDragStat::NextMove(const Point& rPnt)
{
aPos0=GetNow();
RealNow()=rPnt;
- Point aBla=KorregPos(GetRealNow(),GetPrev());
- Now()=aBla;
+ Now()=GetRealNow();
}
void SdrDragStat::NextPoint()
{
Point aPnt(GetNow());
- aPnts.push_back(new Point(KorregPos(GetRealNow(),aPnt)));
+ mvPnts.emplace_back(GetRealNow());
Prev()=aPnt;
}
void SdrDragStat::PrevPoint()
{
- if (aPnts.size()>=2) { // one has to remain at all times
- Point* pPnt=aPnts[aPnts.size()-2];
- aPnts.erase(aPnts.begin()+aPnts.size()-2);
- delete pPnt;
- Now()=KorregPos(GetRealNow(),GetPrev());
+ if (mvPnts.size()>=2) { // one has to remain at all times
+ mvPnts.erase(mvPnts.begin()+mvPnts.size()-2);
+ Now() = GetRealNow();
}
}
-Point SdrDragStat::KorregPos(const Point& rNow, const Point& /*rPrev*/)
-{
- Point aRet(rNow);
- return aRet;
-}
-
bool SdrDragStat::CheckMinMoved(const Point& rPnt)
{
if (!bMinMoved) {
diff --git a/svx/source/svdraw/svdocirc.cxx b/svx/source/svdraw/svdocirc.cxx
index 3ea984b4b529..d20ea32e2c16 100644
--- a/svx/source/svdraw/svdocirc.cxx
+++ b/svx/source/svdraw/svdocirc.cxx
@@ -665,7 +665,7 @@ void SdrCircObj::ImpSetCreateParams(SdrDragStat& rStat)
ImpCircUser* pU=static_cast<ImpCircUser*>(rStat.GetUser());
if (pU==nullptr) {
pU=new ImpCircUser;
- rStat.SetUser(pU);
+ rStat.SetUser(std::unique_ptr<ImpCircUser>(pU));
}
pU->SetCreateParams(rStat);
}
diff --git a/svx/source/svdraw/svdopath.cxx b/svx/source/svdraw/svdopath.cxx
index b079c6ae3393..c364746e9e37 100644
--- a/svx/source/svdraw/svdopath.cxx
+++ b/svx/source/svdraw/svdopath.cxx
@@ -1269,10 +1269,10 @@ bool ImpPathForDragAndCreate::BegCreate(SdrDragStat& rStat)
if (bMakeStartPoint) {
aPathPolygon[0][1]=rStat.GetNow();
}
- ImpPathCreateUser* pU=new ImpPathCreateUser;
+ std::unique_ptr<ImpPathCreateUser> pU(new ImpPathCreateUser);
pU->eStartKind=meObjectKind;
pU->eAktKind=meObjectKind;
- rStat.SetUser(pU);
+ rStat.SetUser(std::move(pU));
return true;
}