summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-04-24 15:06:13 +0200
committerNoel Grandin <noel@peralex.com>2015-04-29 10:41:40 +0200
commit2a6806a81b3fd9218af18c685b2ede36a86956f6 (patch)
treea99801054274dbda906b1a46908e3467671554d3
parent62f9bc737c928ceed89af09ff927c92bea4896ca (diff)
convert SDRSNAP_ constants to scoped enum
Change-Id: Ida0b0e3f017c53588ea9208d078c24948a63eb92
-rw-r--r--include/svx/svddrgmt.hxx2
-rw-r--r--include/svx/svdsnpv.hxx23
-rw-r--r--svx/source/svdraw/svddrgmt.cxx6
-rw-r--r--svx/source/svdraw/svdsnpv.cxx18
4 files changed, 29 insertions, 20 deletions
diff --git a/include/svx/svddrgmt.hxx b/include/svx/svddrgmt.hxx
index 0e4603d649ea..530517a3f12d 100644
--- a/include/svx/svddrgmt.hxx
+++ b/include/svx/svddrgmt.hxx
@@ -169,7 +169,7 @@ protected:
const Rectangle& GetDragLimitRect() { return getSdrDragView().aDragLimit; }
const SdrMarkList& GetMarkedObjectList() { return getSdrDragView().GetMarkedObjectList(); }
Point GetSnapPos(const Point& rPt) const { return getSdrDragView().GetSnapPos(rPt,getSdrDragView().pMarkedPV); }
- sal_uInt16 SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
+ SdrSnap SnapPos(Point& rPt) const { return getSdrDragView().SnapPos(rPt,getSdrDragView().pMarkedPV); }
inline const Rectangle& GetMarkedRect() const;
SdrPageView* GetDragPV() const;
SdrObject* GetDragObj() const;
diff --git a/include/svx/svdsnpv.hxx b/include/svx/svdsnpv.hxx
index 66d630263330..8f2eeea7e102 100644
--- a/include/svx/svdsnpv.hxx
+++ b/include/svx/svdsnpv.hxx
@@ -23,12 +23,21 @@
#include <svx/svdpntv.hxx>
#include <svx/svdhlpln.hxx>
#include <svx/svxdllapi.h>
+#include <o3tl/typed_flags_set.hxx>
-#define SDRSNAP_NOTSNAPPED 0x0000
-#define SDRSNAP_XSNAPPED 0x0001
-#define SDRSNAP_YSNAPPED 0x0002
-#define SDRSNAP_XYSNAPPED 0x0003
+/** return value for SnapPos() method */
+enum class SdrSnap
+{
+ NOTSNAPPED = 0x00,
+ XSNAPPED = 0x01,
+ YSNAPPED = 0x02,
+ XYSNAPPED = XSNAPPED | YSNAPPED,
+};
+namespace o3tl
+{
+ template<> struct typed_flags<SdrSnap> : is_typed_flags<SdrSnap, 3> {};
+}
// SDRCROOK_STRETCH is not implemented yet!
enum SdrCrookMode {
@@ -112,9 +121,9 @@ public:
void SetActualWin(const OutputDevice* pWin) { SdrPaintView::SetActualWin(pWin); if (pWin!=NULL) RecalcLogicSnapMagnetic(*pWin); }
// Coordinates referred to the view!
- // Returnvalues are SDRSNAP_NOTSNAPPED,SDRSNAP_XSNAPPED,
- // SDRSNAP_YSNAPPED or SDRSNAP_XYSNAPPED
- sal_uInt16 SnapPos(Point& rPnt, const SdrPageView* pPV) const;
+ // Returnvalues are SdrSnap::NOTSNAPPED,SdrSnap::XSNAPPED,
+ // SdrSnap::YSNAPPED or SdrSnap::XYSNAPPED
+ SdrSnap SnapPos(Point& rPnt, const SdrPageView* pPV) const;
Point GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const;
void CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const;
diff --git a/svx/source/svdraw/svddrgmt.cxx b/svx/source/svdraw/svddrgmt.cxx
index 0d0c1a518349..c68b62adf128 100644
--- a/svx/source/svdraw/svddrgmt.cxx
+++ b/svx/source/svdraw/svddrgmt.cxx
@@ -1557,10 +1557,10 @@ basegfx::B2DHomMatrix SdrDragMove::getCurrentTransformation()
void SdrDragMove::ImpCheckSnap(const Point& rPt)
{
Point aPt(rPt);
- sal_uInt16 nRet=SnapPos(aPt);
+ SdrSnap nRet=SnapPos(aPt);
aPt-=rPt;
- if ((nRet & SDRSNAP_XSNAPPED) !=0)
+ if (nRet & SdrSnap::XSNAPPED)
{
if (bXSnapped)
{
@@ -1576,7 +1576,7 @@ void SdrDragMove::ImpCheckSnap(const Point& rPt)
}
}
- if ((nRet & SDRSNAP_YSNAPPED) !=0)
+ if (nRet & SdrSnap::YSNAPPED)
{
if (bYSnapped)
{
diff --git a/svx/source/svdraw/svdsnpv.cxx b/svx/source/svdraw/svdsnpv.cxx
index d87e109d2673..c692a3ac5066 100644
--- a/svx/source/svdraw/svdsnpv.cxx
+++ b/svx/source/svdraw/svdsnpv.cxx
@@ -282,14 +282,14 @@ Point SdrSnapView::GetSnapPos(const Point& rPnt, const SdrPageView* pPV) const
}
#define NOT_SNAPPED 0x7FFFFFFF
-sal_uInt16 SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
+SdrSnap SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
{
- if (!bSnapEnab) return SDRSNAP_NOTSNAPPED;
+ if (!bSnapEnab) return SdrSnap::NOTSNAPPED;
long x=rPnt.X();
long y=rPnt.Y();
if (pPV==NULL) {
pPV=GetSdrPageView();
- if (pPV==NULL) return SDRSNAP_NOTSNAPPED;
+ if (pPV==NULL) return SdrSnap::NOTSNAPPED;
}
long dx=NOT_SNAPPED;
@@ -424,9 +424,9 @@ sal_uInt16 SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
dy = 0;
}
}
- sal_uInt16 bRet=SDRSNAP_NOTSNAPPED;
- if (dx==NOT_SNAPPED) dx=0; else bRet|=SDRSNAP_XSNAPPED;
- if (dy==NOT_SNAPPED) dy=0; else bRet|=SDRSNAP_YSNAPPED;
+ SdrSnap bRet=SdrSnap::NOTSNAPPED;
+ if (dx==NOT_SNAPPED) dx=0; else bRet|=SdrSnap::XSNAPPED;
+ if (dy==NOT_SNAPPED) dy=0; else bRet|=SdrSnap::YSNAPPED;
rPnt.X()=x+dx;
rPnt.Y()=y+dy;
return bRet;
@@ -435,9 +435,9 @@ sal_uInt16 SdrSnapView::SnapPos(Point& rPnt, const SdrPageView* pPV) const
void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBestXSnap, long& nBestYSnap, bool& bXSnapped, bool& bYSnapped) const
{
Point aPt(rPt);
- sal_uInt16 nRet=SnapPos(aPt,pPV);
+ SdrSnap nRet=SnapPos(aPt,pPV);
aPt-=rPt;
- if ((nRet & SDRSNAP_XSNAPPED) !=0) {
+ if (nRet & SdrSnap::XSNAPPED) {
if (bXSnapped) {
if (std::abs(aPt.X())<std::abs(nBestXSnap)) {
nBestXSnap=aPt.X();
@@ -447,7 +447,7 @@ void SdrSnapView::CheckSnap(const Point& rPt, const SdrPageView* pPV, long& nBes
bXSnapped=true;
}
}
- if ((nRet & SDRSNAP_YSNAPPED) !=0) {
+ if (nRet & SdrSnap::YSNAPPED) {
if (bYSnapped) {
if (std::abs(aPt.Y())<std::abs(nBestYSnap)) {
nBestYSnap=aPt.Y();