1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _LINE_HXX 24 #define _LINE_HXX 25 26 #include "tools/toolsdllapi.h" 27 #include <tools/gen.hxx> 28 29 class Link; 30 31 // -------- 32 // - Line - 33 // -------- 34 35 class TOOLS_DLLPUBLIC Line 36 { 37 private: 38 39 Point maStart; 40 Point maEnd; 41 42 public: Line()43 Line() {}; Line(const Point & rStartPt,const Point & rEndPt)44 Line( const Point& rStartPt, const Point& rEndPt ) : maStart( rStartPt ), maEnd( rEndPt ) {} 45 SetStart(const Point & rStartPt)46 void SetStart( const Point& rStartPt ) { maStart = rStartPt; } GetStart() const47 const Point& GetStart() const { return maStart; } 48 SetEnd(const Point & rEndPt)49 void SetEnd( const Point& rEndPt ) { maEnd = rEndPt; } GetEnd() const50 const Point& GetEnd() const { return maEnd; } 51 Left() const52 long Left() const { return ( maStart.X() < maEnd.X() ) ? maStart.X() : maEnd.X(); } Top() const53 long Top() const { return ( maStart.Y() < maEnd.Y() ) ? maStart.Y() : maEnd.Y(); } Right() const54 long Right() const { return ( maStart.X() > maEnd.X() ) ? maStart.X() : maEnd.X(); } Bottom() const55 long Bottom() const { return ( maStart.Y() > maEnd.Y() ) ? maStart.Y() : maEnd.Y(); } 56 57 double GetLength() const; 58 59 sal_Bool Intersection( const Line& rLine, double& rIntersectionX, double& rIntersectionY ) const; 60 sal_Bool Intersection( const Line& rLine, Point& rIntersection ) const; 61 sal_Bool Intersection( const Rectangle& rRect, Line& rIntersection ) const; 62 63 double GetDistance( const double& rPtX, const double& rPtY ) const; GetDistance(const Point & rPoint) const64 double GetDistance( const Point& rPoint ) const { return( GetDistance( rPoint.X(), rPoint.Y() ) ); } 65 66 Point NearestPoint( const Point& rPoint ) const; 67 68 void Enum( const Link& rEnumLink ); 69 }; 70 71 #endif // _SV_LINE_HXX 72