Kaydet (Commit) 51091148 authored tarafından Norbert Thiebaud's avatar Norbert Thiebaud

Put Line under tools namespace

Change-Id: I7442848951c0d4579fb2a2a3eef3bfed7135aac4
Reviewed-on: https://gerrit.libreoffice.org/17791Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
üst ef46917f
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#undef Line
#undef Point #undef Point
#undef Size #undef Size
#undef TimeValue #undef TimeValue
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#define Line MacOSLine
#define Point MacOSPoint #define Point MacOSPoint
#define Size MacOSSize #define Size MacOSSize
#define TimeValue MacOSTimeValue #define TimeValue MacOSTimeValue
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
#include <tools/toolsdllapi.h> #include <tools/toolsdllapi.h>
#include <tools/gen.hxx> #include <tools/gen.hxx>
namespace tools
{
class TOOLS_DLLPUBLIC Line class TOOLS_DLLPUBLIC Line
{ {
private: private:
...@@ -40,13 +43,15 @@ public: ...@@ -40,13 +43,15 @@ public:
double GetLength() const; double GetLength() const;
bool Intersection( const Line& rLine, double& rIntersectionX, double& rIntersectionY ) const; bool Intersection( const tools::Line& rLine, double& rIntersectionX, double& rIntersectionY ) const;
bool Intersection( const Line& rLine, Point& rIntersection ) const; bool Intersection( const tools::Line& rLine, Point& rIntersection ) const;
double GetDistance( const double& rPtX, const double& rPtY ) const; double GetDistance( const double& rPtX, const double& rPtY ) const;
double GetDistance( const Point& rPoint ) const { return( GetDistance( rPoint.X(), rPoint.Y() ) ); } double GetDistance( const Point& rPoint ) const { return( GetDistance( rPoint.X(), rPoint.Y() ) ); }
}; };
} // namespace tools
#endif #endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -80,7 +80,9 @@ class TextRectInfo; ...@@ -80,7 +80,9 @@ class TextRectInfo;
class FontMetric; class FontMetric;
class GDIMetaFile; class GDIMetaFile;
class GfxLink; class GfxLink;
class Line; namespace tools {
class Line;
}
class LineInfo; class LineInfo;
class AlphaMask; class AlphaMask;
class FontCharMap; class FontCharMap;
...@@ -972,7 +974,7 @@ public: ...@@ -972,7 +974,7 @@ public:
private: private:
SAL_DLLPRIVATE void CalcHatchValues( const Rectangle& rRect, long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 ); SAL_DLLPRIVATE void CalcHatchValues( const Rectangle& rRect, long nDist, sal_uInt16 nAngle10, Point& rPt1, Point& rPt2, Size& rInc, Point& rEndPt1 );
SAL_DLLPRIVATE void DrawHatchLine( const Line& rLine, const tools::PolyPolygon& rPolyPoly, Point* pPtBuffer, bool bMtf ); SAL_DLLPRIVATE void DrawHatchLine( const tools::Line& rLine, const tools::PolyPolygon& rPolyPoly, Point* pPtBuffer, bool bMtf );
///@} ///@}
......
...@@ -93,7 +93,7 @@ namespace { ...@@ -93,7 +93,7 @@ namespace {
// Otherwise, compute the distance to the center of the rectangle. // Otherwise, compute the distance to the center of the rectangle.
if ( !rRect.IsInside( rPoint ) ) if ( !rRect.IsInside( rPoint ) )
{ {
Line aLine( rPoint, rRect.Center( ) ); tools::Line aLine( rPoint, rRect.Center( ) );
nDist = aLine.GetLength( ); nDist = aLine.GetLength( );
} }
......
...@@ -24,6 +24,9 @@ ...@@ -24,6 +24,9 @@
#include <cstdlib> #include <cstdlib>
#include <math.h> #include <math.h>
namespace tools
{
double Line::GetLength() const double Line::GetLength() const
{ {
return hypot( maStart.X() - maEnd.X(), maStart.Y() - maEnd.Y() ); return hypot( maStart.X() - maEnd.X(), maStart.Y() - maEnd.Y() );
...@@ -46,7 +49,7 @@ bool Line::Intersection( const Line& rLine, Point& rIntersection ) const ...@@ -46,7 +49,7 @@ bool Line::Intersection( const Line& rLine, Point& rIntersection ) const
return bRet; return bRet;
} }
bool Line::Intersection( const Line& rLine, double& rIntersectionX, double& rIntersectionY ) const bool Line::Intersection( const tools::Line& rLine, double& rIntersectionX, double& rIntersectionY ) const
{ {
const double fAx = maEnd.X() - maStart.X(); const double fAx = maEnd.X() - maStart.X();
const double fAy = maEnd.Y() - maStart.Y(); const double fAy = maEnd.Y() - maStart.Y();
...@@ -134,4 +137,6 @@ double Line::GetDistance( const double& rPtX, const double& rPtY ) const ...@@ -134,4 +137,6 @@ double Line::GetDistance( const double& rPtX, const double& rPtY ) const
return fDist; return fDist;
} }
} //namespace tools
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -178,7 +178,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& ...@@ -178,7 +178,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 ); CalcHatchValues( aRect, nWidth, rHatch.GetAngle(), aPt1, aPt2, aInc, aEndPt1 );
do do
{ {
DrawHatchLine( Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );
aPt1.X() += aInc.Width(); aPt1.Y() += aInc.Height(); aPt1.X() += aInc.Width(); aPt1.Y() += aInc.Height();
aPt2.X() += aInc.Width(); aPt2.Y() += aInc.Height(); aPt2.X() += aInc.Width(); aPt2.Y() += aInc.Height();
} }
...@@ -190,7 +190,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& ...@@ -190,7 +190,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900, aPt1, aPt2, aInc, aEndPt1 ); CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 900, aPt1, aPt2, aInc, aEndPt1 );
do do
{ {
DrawHatchLine( Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );
aPt1.X() += aInc.Width(); aPt1.Y() += aInc.Height(); aPt1.X() += aInc.Width(); aPt1.Y() += aInc.Height();
aPt2.X() += aInc.Width(); aPt2.Y() += aInc.Height(); aPt2.X() += aInc.Width(); aPt2.Y() += aInc.Height();
} }
...@@ -202,7 +202,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch& ...@@ -202,7 +202,7 @@ void OutputDevice::DrawHatch( const tools::PolyPolygon& rPolyPoly, const Hatch&
CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450, aPt1, aPt2, aInc, aEndPt1 ); CalcHatchValues( aRect, nWidth, rHatch.GetAngle() + 450, aPt1, aPt2, aInc, aEndPt1 );
do do
{ {
DrawHatchLine( Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf ); DrawHatchLine( tools::Line( aPt1, aPt2 ), rPolyPoly, pPtBuffer.get(), bMtf );
aPt1.X() += aInc.Width(); aPt1.Y() += aInc.Height(); aPt1.X() += aInc.Width(); aPt1.Y() += aInc.Height();
aPt2.X() += aInc.Width(); aPt2.Y() += aInc.Height(); aPt2.X() += aInc.Width(); aPt2.Y() += aInc.Height();
} }
...@@ -321,7 +321,7 @@ void OutputDevice::CalcHatchValues( const Rectangle& rRect, long nDist, sal_uInt ...@@ -321,7 +321,7 @@ void OutputDevice::CalcHatchValues( const Rectangle& rRect, long nDist, sal_uInt
} }
} }
void OutputDevice::DrawHatchLine( const Line& rLine, const tools::PolyPolygon& rPolyPoly, void OutputDevice::DrawHatchLine( const tools::Line& rLine, const tools::PolyPolygon& rPolyPoly,
Point* pPtBuffer, bool bMtf ) Point* pPtBuffer, bool bMtf )
{ {
assert(!is_double_buffered_window()); assert(!is_double_buffered_window());
...@@ -335,7 +335,7 @@ void OutputDevice::DrawHatchLine( const Line& rLine, const tools::PolyPolygon& r ...@@ -335,7 +335,7 @@ void OutputDevice::DrawHatchLine( const Line& rLine, const tools::PolyPolygon& r
if( rPoly.GetSize() > 1 ) if( rPoly.GetSize() > 1 )
{ {
Line aCurSegment( rPoly[ 0 ], Point() ); tools::Line aCurSegment( rPoly[ 0 ], Point() );
for( long i = 1, nCount = rPoly.GetSize(); i <= nCount; i++ ) for( long i = 1, nCount = rPoly.GetSize(); i <= nCount; i++ )
{ {
...@@ -347,7 +347,7 @@ void OutputDevice::DrawHatchLine( const Line& rLine, const tools::PolyPolygon& r ...@@ -347,7 +347,7 @@ void OutputDevice::DrawHatchLine( const Line& rLine, const tools::PolyPolygon& r
if( ( fabs( fX - aCurSegment.GetStart().X() ) <= 0.0000001 ) && if( ( fabs( fX - aCurSegment.GetStart().X() ) <= 0.0000001 ) &&
( fabs( fY - aCurSegment.GetStart().Y() ) <= 0.0000001 ) ) ( fabs( fY - aCurSegment.GetStart().Y() ) <= 0.0000001 ) )
{ {
const Line aPrevSegment( rPoly[ (sal_uInt16)( ( i > 1 ) ? ( i - 2 ) : ( nCount - 1 ) ) ], aCurSegment.GetStart() ); const tools::Line aPrevSegment( rPoly[ (sal_uInt16)( ( i > 1 ) ? ( i - 2 ) : ( nCount - 1 ) ) ], aCurSegment.GetStart() );
const double fPrevDistance = rLine.GetDistance( aPrevSegment.GetStart() ); const double fPrevDistance = rLine.GetDistance( aPrevSegment.GetStart() );
const double fCurDistance = rLine.GetDistance( aCurSegment.GetEnd() ); const double fCurDistance = rLine.GetDistance( aCurSegment.GetEnd() );
...@@ -360,7 +360,7 @@ void OutputDevice::DrawHatchLine( const Line& rLine, const tools::PolyPolygon& r ...@@ -360,7 +360,7 @@ void OutputDevice::DrawHatchLine( const Line& rLine, const tools::PolyPolygon& r
else if( ( fabs( fX - aCurSegment.GetEnd().X() ) <= 0.0000001 ) && else if( ( fabs( fX - aCurSegment.GetEnd().X() ) <= 0.0000001 ) &&
( fabs( fY - aCurSegment.GetEnd().Y() ) <= 0.0000001 ) ) ( fabs( fY - aCurSegment.GetEnd().Y() ) <= 0.0000001 ) )
{ {
const Line aNextSegment( aCurSegment.GetEnd(), rPoly[ (sal_uInt16)( ( i + 1 ) % nCount ) ] ); const tools::Line aNextSegment( aCurSegment.GetEnd(), rPoly[ (sal_uInt16)( ( i + 1 ) % nCount ) ] );
if( ( fabs( rLine.GetDistance( aNextSegment.GetEnd() ) ) <= 0.0000001 ) && if( ( fabs( rLine.GetDistance( aNextSegment.GetEnd() ) ) <= 0.0000001 ) &&
( rLine.GetDistance( aCurSegment.GetStart() ) > 0.0 ) ) ( rLine.GetDistance( aCurSegment.GetStart() ) > 0.0 ) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment