From 53ad646f54f8aa33b86c696c04500fd08ea6f3b6 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sun, 28 Oct 2012 23:23:53 +0100 Subject: Enforce use of accessors on gen.hxx structures Change-Id: Icd1b2937fdeaba6de1877258731f53ddf996002e Reviewed-on: https://gerrit.libreoffice.org/936 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- tools/inc/tools/gen.hxx | 18 ++++++++++-------- tools/inc/tools/vector2d.hxx | 14 +++++++------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'tools') diff --git a/tools/inc/tools/gen.hxx b/tools/inc/tools/gen.hxx index 7c93792b3c4b..6c93e2b36926 100644 --- a/tools/inc/tools/gen.hxx +++ b/tools/inc/tools/gen.hxx @@ -31,9 +31,6 @@ class SvStream; class SAL_WARN_UNUSED Pair { public: - long nA; - long nB; - Pair(); Pair( long nA, long nB ); @@ -48,6 +45,10 @@ public: TOOLS_DLLPUBLIC friend SvStream& operator>>( SvStream& rIStream, Pair& rPair ); TOOLS_DLLPUBLIC friend SvStream& operator<<( SvStream& rOStream, const Pair& rPair ); + +protected: + long nA; + long nB; }; inline Pair::Pair() @@ -329,11 +330,6 @@ inline void Selection::Justify() class TOOLS_DLLPUBLIC SAL_WARN_UNUSED Rectangle { public: - long nLeft; - long nTop; - long nRight; - long nBottom; - Rectangle(); Rectangle( const Point& rLT, const Point& rRB ); Rectangle( long nLeft, long nTop, @@ -404,6 +400,12 @@ public: void setY( long n ) { nBottom += n-nTop; nTop = n; } void setWidth( long n ) { nRight = nLeft + n; } void setHeight( long n ) { nBottom = nTop + n; } + +private: + long nLeft; + long nTop; + long nRight; + long nBottom; }; inline Rectangle::Rectangle() diff --git a/tools/inc/tools/vector2d.hxx b/tools/inc/tools/vector2d.hxx index 50c6bc882859..d3d1c5c0c805 100644 --- a/tools/inc/tools/vector2d.hxx +++ b/tools/inc/tools/vector2d.hxx @@ -33,7 +33,7 @@ public: inline Vector2D() : mfX( 0.0 ), mfY( 0.0 ) {} inline Vector2D( double fX, double fY ) : mfX( fX ), mfY( fY ) {} inline Vector2D( const Vector2D& rVec ) : mfX( rVec.mfX ), mfY( rVec.mfY ) {} - inline Vector2D( const Pair& rPair ) : mfX( rPair.nA ), mfY( rPair.nB ) {}; + inline Vector2D( const Pair& rPair ) : mfX( rPair.A() ), mfY( rPair.B() ) {}; inline ~Vector2D() {} inline const double& X() const { return mfX; } @@ -79,13 +79,13 @@ public: inline sal_Bool operator!=( const Vector2D& rVec ) const { return !( *this == rVec ); } inline Vector2D& operator=( const Vector2D& rVec ) { mfX = rVec.mfX, mfY = rVec.mfY; return *this; } - inline Vector2D& operator=( const Pair& rPair ) { mfX = rPair.nA, mfY = rPair.nB; return *this; } - inline Vector2D& operator-=( const Pair& rPair ) { mfX -= rPair.nA, mfY -= rPair.nB; return *this; } - inline Vector2D& operator+=( const Pair& rPair ) { mfX += rPair.nA, mfY += rPair.nB; return *this; } - inline Vector2D& operator*=( const Pair& rPair ) { mfX *= rPair.nA, mfY *= rPair.nB; return *this; } - inline Vector2D& operator/=( const Pair& rPair ) { mfX /= rPair.nA, mfY /= rPair.nB; return *this; } + inline Vector2D& operator=( const Pair& rPair ) { mfX = rPair.A(), mfY = rPair.B(); return *this; } + inline Vector2D& operator-=( const Pair& rPair ) { mfX -= rPair.A(), mfY -= rPair.B(); return *this; } + inline Vector2D& operator+=( const Pair& rPair ) { mfX += rPair.A(), mfY += rPair.B(); return *this; } + inline Vector2D& operator*=( const Pair& rPair ) { mfX *= rPair.A(), mfY *= rPair.B(); return *this; } + inline Vector2D& operator/=( const Pair& rPair ) { mfX /= rPair.A(), mfY /= rPair.B(); return *this; } - inline sal_Bool operator==( const Pair& rPair ) const { return( mfX == rPair.nA && mfY == rPair.nB ); } + inline sal_Bool operator==( const Pair& rPair ) const { return( mfX == rPair.A() && mfY == rPair.B() ); } inline sal_Bool operator!=( const Pair& rPair ) const { return !( *this == rPair ); } inline sal_Bool IsPositive( Vector2D& rVec ) const { return( ( mfX * rVec.mfY - mfY * rVec.mfX ) >= 0.0 ); } -- cgit