summaryrefslogtreecommitdiff
path: root/include
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 /include
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 'include')
-rw-r--r--include/svx/svddrag.hxx53
1 files changed, 26 insertions, 27 deletions
diff --git a/include/svx/svddrag.hxx b/include/svx/svddrag.hxx
index 608d32bfdfbd..4766863a045d 100644
--- a/include/svx/svddrag.hxx
+++ b/include/svx/svddrag.hxx
@@ -25,6 +25,7 @@
#include <tools/fract.hxx>
#include <svx/svxdllapi.h>
+#include <memory>
#include <vector>
// Status information for specialized object dragging. In order for the model
@@ -47,7 +48,7 @@ protected:
SdrHdl* pHdl; // The Handle for the User
SdrView* pView;
SdrPageView* pPageView;
- std::vector<Point*> aPnts; // All previous Points: [0]=Start, [Count()-2]=Prev
+ std::vector<Point> mvPnts; // All previous Points: [0]=Start, [Count()-2]=Prev
Point aRef1; // Referencepoint: Resize fixed point, (axis of rotation,
Point aRef2; // axis of reflection, ...)
Point aPos0; // Position at the last Event
@@ -72,26 +73,25 @@ protected:
bool bOrtho8;
SdrDragMethod* pDragMethod;
+ std::unique_ptr<SdrDragStatUserData> mpUserData; // Userdata
-protected:
void Clear(bool bLeaveOne);
- Point& Pnt(sal_uIntPtr nNum) { return *aPnts[nNum]; }
-//public:
- SdrDragStatUserData* pUser; // Userdata
+protected:
+ Point& Pnt(sal_uIntPtr nNum) { return mvPnts[nNum]; }
public:
- SdrDragStat(): aPnts() { pUser=nullptr; Reset(); }
- ~SdrDragStat() { Clear(false); }
+ SdrDragStat() { Reset(); }
+ ~SdrDragStat();
void Reset();
SdrView* GetView() const { return pView; }
void SetView(SdrView* pV) { pView=pV; }
SdrPageView* GetPageView() const { return pPageView; }
void SetPageView(SdrPageView* pPV) { pPageView=pPV; }
- const Point& GetPoint(sal_uIntPtr nNum) const { return *aPnts[nNum]; }
- sal_uIntPtr GetPointCount() const { return aPnts.size(); }
+ const Point& GetPoint(sal_uIntPtr nNum) const { return mvPnts[nNum]; }
+ sal_uIntPtr GetPointCount() const { return mvPnts.size(); }
const Point& GetStart() const { return GetPoint(0); }
Point& Start() { return Pnt(0); }
const Point& GetPrev() const { return GetPoint(GetPointCount()-(GetPointCount()>=2 ? 2:1)); }
- Point& Prev() { return Pnt(GetPointCount()-(GetPointCount()>=2 ? 2:1)); }
+ Point& Prev() { return Pnt(GetPointCount()-(GetPointCount()>=2 ? 2:1)); }
const Point& GetPos0() const { return aPos0; }
const Point& GetNow() const { return GetPoint(GetPointCount()-1); }
Point& Now() { return Pnt(GetPointCount()-1); }
@@ -103,8 +103,8 @@ public:
Point& Ref2() { return aRef2; }
const SdrHdl* GetHdl() const { return pHdl; }
void SetHdl(SdrHdl* pH) { pHdl=pH; }
- SdrDragStatUserData* GetUser() const { return pUser; }
- void SetUser(SdrDragStatUserData* pU) { pUser=pU; }
+ SdrDragStatUserData* GetUser() const { return mpUserData.get(); }
+ void SetUser(std::unique_ptr<SdrDragStatUserData> pU) { mpUserData = std::move(pU); }
bool IsShown() const { return bShown; }
void SetShown(bool bOn) { bShown=bOn; }
@@ -143,25 +143,24 @@ public:
bool IsMouseDown() const { return !bMouseIsUp; }
void SetMouseDown(bool bDown) { bMouseIsUp=!bDown; }
- static Point KorregPos(const Point& rNow, const Point& rPrev);
- void Reset(const Point& rPnt);
- void NextMove(const Point& rPnt);
- void NextPoint();
- void PrevPoint();
- bool CheckMinMoved(const Point& rPnt);
- long GetDX() const { return GetNow().X()-GetPrev().X(); }
- long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
- Fraction GetXFact() const;
- Fraction GetYFact() const;
+ void Reset(const Point& rPnt);
+ void NextMove(const Point& rPnt);
+ void NextPoint();
+ void PrevPoint();
+ bool CheckMinMoved(const Point& rPnt);
+ long GetDX() const { return GetNow().X()-GetPrev().X(); }
+ long GetDY() const { return GetNow().Y()-GetPrev().Y(); }
+ Fraction GetXFact() const;
+ Fraction GetYFact() const;
- SdrDragMethod* GetDragMethod() const { return pDragMethod; }
- void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; }
+ SdrDragMethod* GetDragMethod() const { return pDragMethod; }
+ void SetDragMethod(SdrDragMethod* pMth) { pDragMethod=pMth; }
- const tools::Rectangle& GetActionRect() const { return aActionRect; }
- void SetActionRect(const tools::Rectangle& rR) { aActionRect=rR; }
+ const tools::Rectangle& GetActionRect() const { return aActionRect; }
+ void SetActionRect(const tools::Rectangle& rR) { aActionRect=rR; }
// Also considering 1stPointAsCenter
- void TakeCreateRect(tools::Rectangle& rRect) const;
+ void TakeCreateRect(tools::Rectangle& rRect) const;
};
#endif // INCLUDED_SVX_SVDDRAG_HXX