LibreOffice Module tools (master) 1
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
tools::Rectangle Class Referencefinal

#include <gen.hxx>

Public Member Functions

constexpr Rectangle ()=default
 
constexpr Rectangle (const Point &rLT, const Point &rRB)
 
constexpr Rectangle (tools::Long mnLeft, tools::Long mnTop, tools::Long mnRight, tools::Long mnBottom)
 
constexpr Rectangle (tools::Long mnLeft, tools::Long mnTop)
 Constructs an empty Rectangle, with top/left at the specified params. More...
 
constexpr Rectangle (const Point &rLT, const Size &rSize)
 Constructs a closed interval rectangle. More...
 
constexpr tools::Long Left () const
 
constexpr tools::Long Right () const
 
constexpr tools::Long Top () const
 
constexpr tools::Long Bottom () const
 
constexpr void SetLeft (tools::Long v)
 
constexpr void SetRight (tools::Long v)
 
constexpr void SetTop (tools::Long v)
 
constexpr void SetBottom (tools::Long v)
 
constexpr Point TopLeft () const
 
constexpr Point TopRight () const
 
constexpr Point TopCenter () const
 
constexpr Point BottomLeft () const
 
constexpr Point BottomRight () const
 
constexpr Point BottomCenter () const
 
constexpr Point LeftCenter () const
 
constexpr Point RightCenter () const
 
constexpr Point Center () const
 
void Move (tools::Long nHorzMoveDelta, tools::Long nVertMoveDelta)
 Move the top and left edges by a delta, preserving width and height. More...
 
void Move (Size const &s)
 
tools::Long AdjustLeft (tools::Long nHorzMoveDelta)
 
tools::Long AdjustRight (tools::Long nHorzMoveDelta)
 
tools::Long AdjustTop (tools::Long nVertMoveDelta)
 
tools::Long AdjustBottom (tools::Long nVertMoveDelta)
 
void SetPosX (tools::Long x)
 Set the left edge of the rectangle to x, preserving the width. More...
 
void SetPosY (tools::Long y)
 Set the top edge of the rectangle to y, preserving the height. More...
 
void SetPos (const Point &rPoint)
 
void SetWidth (tools::Long)
 
void SetHeight (tools::Long)
 
void SetSize (const Size &)
 
constexpr Point GetPos () const
 
constexpr Size GetSize () const
 
constexpr tools::Long GetWidth () const
 Returns the difference between right and left, assuming the range is inclusive. More...
 
constexpr tools::Long GetHeight () const
 Returns the difference between bottom and top, assuming the range is inclusive. More...
 
tools::RectangleUnion (const tools::Rectangle &rRect)
 
tools::RectangleIntersection (const tools::Rectangle &rRect)
 
tools::Rectangle GetUnion (const tools::Rectangle &rRect) const
 
tools::Rectangle GetIntersection (const tools::Rectangle &rRect) const
 
void Normalize ()
 
bool Contains (const Point &rPOINT) const
 
bool Contains (const tools::Rectangle &rRect) const
 
bool Overlaps (const tools::Rectangle &rRect) const
 
void SetEmpty ()
 
void SetWidthEmpty ()
 
void SetHeightEmpty ()
 
constexpr bool IsEmpty () const
 
constexpr bool IsWidthEmpty () const
 
constexpr bool IsHeightEmpty () const
 
bool operator== (const tools::Rectangle &rRect) const
 
bool operator!= (const tools::Rectangle &rRect) const
 
tools::Rectangleoperator+= (const Point &rPt)
 
tools::Rectangleoperator-= (const Point &rPt)
 
tools::Long getX () const
 
tools::Long getY () const
 
tools::Long getOpenWidth () const
 Returns the difference between right and left, assuming the range includes one end, but not the other. More...
 
tools::Long getOpenHeight () const
 Returns the difference between bottom and top, assuming the range includes one end, but not the other. More...
 
void setWidth (tools::Long n)
 
void setHeight (tools::Long n)
 
rtl::OString toString () const
 Returns the string representation of the rectangle, format is "x, y, width, height". More...
 
void expand (tools::Long nExpandBy)
 Expands the rectangle in all directions by the input value. More...
 
void shrink (tools::Long nShrinkBy)
 
void SaturatingSetSize (const Size &rSize)
 Sanitizing variants for handling data from the outside. More...
 
void SaturatingSetPosX (tools::Long x)
 
void SaturatingSetPosY (tools::Long y)
 
constexpr tools::Rectangle scale (sal_Int64 nMulX, sal_Int64 nDivX, sal_Int64 nMulY, sal_Int64 nDivY) const
 

Static Public Member Functions

static constexpr Rectangle Normalize (const Point &rLT, const Point &rRB)
 

Private Attributes

tools::Long mnLeft = 0
 
tools::Long mnTop = 0
 
tools::Long mnRight = RECT_EMPTY
 
tools::Long mnBottom = RECT_EMPTY
 

Static Private Attributes

static constexpr short RECT_EMPTY = -32767
 

Friends

tools::Rectangle operator+ (const tools::Rectangle &rRect, const Point &rPt)
 
tools::Rectangle operator- (const tools::Rectangle &rRect, const Point &rPt)
 

Detailed Description

Definition at line 485 of file gen.hxx.

Constructor & Destructor Documentation

◆ Rectangle() [1/5]

constexpr tools::Rectangle::Rectangle ( )
constexprdefault

◆ Rectangle() [2/5]

constexpr tools::Rectangle::Rectangle ( const Point rLT,
const Point rRB 
)
inlineconstexpr

Definition at line 607 of file gen.hxx.

References X, and Y.

◆ Rectangle() [3/5]

constexpr tools::Rectangle::Rectangle ( tools::Long  mnLeft,
tools::Long  mnTop,
tools::Long  mnRight,
tools::Long  mnBottom 
)
inlineconstexpr

Definition at line 611 of file gen.hxx.

References mnBottom, mnLeft, mnRight, and mnTop.

◆ Rectangle() [4/5]

constexpr tools::Rectangle::Rectangle ( tools::Long  mnLeft,
tools::Long  mnTop 
)
inlineconstexpr

Constructs an empty Rectangle, with top/left at the specified params.

Definition at line 619 of file gen.hxx.

References mnLeft, and mnTop.

◆ Rectangle() [5/5]

constexpr tools::Rectangle::Rectangle ( const Point rLT,
const Size rSize 
)
inlineconstexpr

Constructs a closed interval rectangle.

Definition at line 624 of file gen.hxx.

References Height, mnBottom, mnLeft, mnRight, mnTop, Width, X, and Y.

Member Function Documentation

◆ AdjustBottom()

tools::Long tools::Rectangle::AdjustBottom ( tools::Long  nVertMoveDelta)

Definition at line 210 of file gen.cxx.

References mnBottom, and mnTop.

◆ AdjustLeft()

tools::Long tools::Rectangle::AdjustLeft ( tools::Long  nHorzMoveDelta)
inline

Definition at line 523 of file gen.hxx.

References mnLeft.

Referenced by operator+=().

◆ AdjustRight()

tools::Long tools::Rectangle::AdjustRight ( tools::Long  nHorzMoveDelta)

Definition at line 201 of file gen.cxx.

References mnLeft, and mnRight.

◆ AdjustTop()

tools::Long tools::Rectangle::AdjustTop ( tools::Long  nVertMoveDelta)
inline

Definition at line 525 of file gen.hxx.

References mnTop.

Referenced by operator+=().

◆ Bottom()

constexpr tools::Long tools::Rectangle::Bottom ( ) const
inlineconstexpr

◆ BottomCenter()

constexpr Point tools::Rectangle::BottomCenter ( ) const
inlineconstexpr

Definition at line 515 of file gen.hxx.

References Bottom, Left, and Right.

◆ BottomLeft()

constexpr Point tools::Rectangle::BottomLeft ( ) const
inlineconstexpr

Definition at line 513 of file gen.hxx.

References Bottom, and Left.

Referenced by ImplPolygon::ImplPolygon().

◆ BottomRight()

constexpr Point tools::Rectangle::BottomRight ( ) const
inlineconstexpr

Definition at line 514 of file gen.hxx.

References Bottom, and Right.

Referenced by Contains(), and ImplPolygon::ImplPolygon().

◆ Center()

constexpr Point tools::Rectangle::Center ( ) const
inlineconstexpr

Definition at line 518 of file gen.hxx.

References Bottom, Left, Right, and Top.

Referenced by ImplPolygon::ImplPolygon().

◆ Contains() [1/2]

bool tools::Rectangle::Contains ( const Point rPOINT) const

Definition at line 133 of file gen.cxx.

References mnBottom, mnLeft, mnRight, mnTop, Point::X(), and Point::Y().

Referenced by tools::Polygon::Contains().

◆ Contains() [2/2]

bool tools::Rectangle::Contains ( const tools::Rectangle rRect) const

Definition at line 161 of file gen.cxx.

References BottomRight(), and TopLeft().

◆ expand()

void tools::Rectangle::expand ( tools::Long  nExpandBy)

Expands the rectangle in all directions by the input value.

Definition at line 183 of file gen.cxx.

References AdjustLeft, and AdjustRight.

◆ GetHeight()

constexpr tools::Long tools::Rectangle::GetHeight ( ) const
inlineconstexpr

Returns the difference between bottom and top, assuming the range is inclusive.

Definition at line 710 of file gen.hxx.

References mnBottom, mnTop, and n.

Referenced by B3dTransformationSet::CalcViewport(), ImplPolygon::ImplPolygon(), tools::Polygon::Optimize(), and tools::PolyPolygon::Optimize().

◆ GetIntersection()

tools::Rectangle tools::Rectangle::GetIntersection ( const tools::Rectangle rRect) const
inline

Definition at line 732 of file gen.hxx.

References Intersection().

◆ getOpenHeight()

tools::Long tools::Rectangle::getOpenHeight ( ) const
inline

Returns the difference between bottom and top, assuming the range includes one end, but not the other.

Definition at line 576 of file gen.hxx.

References Bottom, and Top.

◆ getOpenWidth()

tools::Long tools::Rectangle::getOpenWidth ( ) const
inline

Returns the difference between right and left, assuming the range includes one end, but not the other.

Definition at line 574 of file gen.hxx.

References Left, and Right.

◆ GetPos()

constexpr Point tools::Rectangle::GetPos ( ) const
inlineconstexpr

Definition at line 536 of file gen.hxx.

References TopLeft.

◆ GetSize()

constexpr Size tools::Rectangle::GetSize ( ) const
inlineconstexpr

Definition at line 537 of file gen.hxx.

Referenced by operator+=().

◆ GetUnion()

tools::Rectangle tools::Rectangle::GetUnion ( const tools::Rectangle rRect) const
inline

Definition at line 726 of file gen.hxx.

References Union().

◆ GetWidth()

constexpr tools::Long tools::Rectangle::GetWidth ( ) const
inlineconstexpr

Returns the difference between right and left, assuming the range is inclusive.

Definition at line 694 of file gen.hxx.

References mnLeft, mnRight, and n.

Referenced by B3dTransformationSet::CalcViewport(), ImplPolygon::ImplPolygon(), tools::Polygon::Optimize(), and tools::PolyPolygon::Optimize().

◆ getX()

tools::Long tools::Rectangle::getX ( ) const
inline

Definition at line 571 of file gen.hxx.

References mnLeft.

◆ getY()

tools::Long tools::Rectangle::getY ( ) const
inline

Definition at line 572 of file gen.hxx.

References mnTop.

◆ Intersection()

tools::Rectangle & tools::Rectangle::Intersection ( const tools::Rectangle rRect)

Definition at line 92 of file gen.cxx.

References IsEmpty(), mnBottom, mnBottom, mnLeft, mnLeft, mnRight, mnRight, mnTop, mnTop, and Normalize().

Referenced by GetIntersection().

◆ IsEmpty()

constexpr bool tools::Rectangle::IsEmpty ( ) const
inlineconstexpr

◆ IsHeightEmpty()

constexpr bool tools::Rectangle::IsHeightEmpty ( ) const
inlineconstexpr

Definition at line 560 of file gen.hxx.

References mnBottom.

◆ IsWidthEmpty()

constexpr bool tools::Rectangle::IsWidthEmpty ( ) const
inlineconstexpr

Definition at line 559 of file gen.hxx.

References mnRight.

◆ Left()

constexpr tools::Long tools::Rectangle::Left ( ) const
inlineconstexpr

◆ LeftCenter()

constexpr Point tools::Rectangle::LeftCenter ( ) const
inlineconstexpr

Definition at line 516 of file gen.hxx.

References Bottom, Left, and Top.

◆ Move() [1/2]

void tools::Rectangle::Move ( Size const &  s)
inline

Definition at line 522 of file gen.hxx.

References Size::Height(), Move(), and Size::Width().

Referenced by Move().

◆ Move() [2/2]

void tools::Rectangle::Move ( tools::Long  nHorzMoveDelta,
tools::Long  nVertMoveDelta 
)
inline

Move the top and left edges by a delta, preserving width and height.

Definition at line 638 of file gen.hxx.

References mnBottom, mnLeft, mnRight, and mnTop.

◆ Normalize() [1/2]

void tools::Rectangle::Normalize ( )

Definition at line 120 of file gen.cxx.

References mnBottom, mnLeft, mnRight, and mnTop.

◆ Normalize() [2/2]

constexpr tools::Rectangle tools::Rectangle::Normalize ( const Point rLT,
const Point rRB 
)
inlinestaticconstexpr

Definition at line 631 of file gen.hxx.

References Point::X(), and Point::Y().

Referenced by tools::Polygon::Clip(), ImplPolygon::ImplPolygon(), and Intersection().

◆ operator!=()

bool tools::Rectangle::operator!= ( const tools::Rectangle rRect) const
inline

Definition at line 746 of file gen.hxx.

References mnBottom, mnBottom, mnLeft, mnLeft, mnRight, mnRight, mnTop, and mnTop.

◆ operator+=()

tools::Rectangle & tools::Rectangle::operator+= ( const Point rPt)
inline

Definition at line 754 of file gen.hxx.

References Move, Point::X(), and Point::Y().

◆ operator-=()

tools::Rectangle & tools::Rectangle::operator-= ( const Point rPt)
inline

Definition at line 760 of file gen.hxx.

References Move, Point::X(), and Point::Y().

◆ operator==()

bool tools::Rectangle::operator== ( const tools::Rectangle rRect) const
inline

Definition at line 738 of file gen.hxx.

References mnBottom, mnBottom, mnLeft, mnLeft, mnRight, mnRight, mnTop, and mnTop.

◆ Overlaps()

bool tools::Rectangle::Overlaps ( const tools::Rectangle rRect) const

Definition at line 166 of file gen.cxx.

◆ Right()

constexpr tools::Long tools::Rectangle::Right ( ) const
inlineconstexpr

◆ RightCenter()

constexpr Point tools::Rectangle::RightCenter ( ) const
inlineconstexpr

Definition at line 517 of file gen.hxx.

References Bottom, Right, and Top.

◆ SaturatingSetPosX()

void tools::Rectangle::SaturatingSetPosX ( tools::Long  x)

Definition at line 62 of file gen.cxx.

References mnLeft, mnRight, o3tl::saturating_add(), and x.

◆ SaturatingSetPosY()

void tools::Rectangle::SaturatingSetPosY ( tools::Long  y)

Definition at line 69 of file gen.cxx.

References mnBottom, mnTop, o3tl::saturating_add(), and y.

◆ SaturatingSetSize()

void tools::Rectangle::SaturatingSetSize ( const Size rSize)

Sanitizing variants for handling data from the outside.

Definition at line 45 of file gen.cxx.

References mnLeft, mnRight, o3tl::saturating_add(), SetWidthEmpty(), and Size::Width().

◆ scale()

constexpr tools::Rectangle tools::Rectangle::scale ( sal_Int64  nMulX,
sal_Int64  nDivX,
sal_Int64  nMulY,
sal_Int64  nDivY 
) const
inlineconstexpr

Definition at line 780 of file gen.hxx.

References Bottom, o3tl::convert(), Left, Right, SetBottom(), SetRight(), and Top.

Referenced by o3tl::convert().

◆ SetBottom()

constexpr void tools::Rectangle::SetBottom ( tools::Long  v)
inlineconstexpr

Definition at line 508 of file gen.hxx.

References mnBottom, and v.

Referenced by tools::GenericTypeSerializer::readRectangle(), and scale().

◆ SetEmpty()

void tools::Rectangle::SetEmpty ( )
inline

Definition at line 555 of file gen.hxx.

References mnBottom, and mnRight.

Referenced by tools::GenericTypeSerializer::readRectangle().

◆ setHeight()

void tools::Rectangle::setHeight ( tools::Long  n)
inline

Definition at line 578 of file gen.hxx.

References mnBottom, mnTop, and n.

◆ SetHeight()

void tools::Rectangle::SetHeight ( tools::Long  nHeight)
inline

Definition at line 678 of file gen.hxx.

References mnBottom, and mnTop.

◆ SetHeightEmpty()

void tools::Rectangle::SetHeightEmpty ( )
inline

Definition at line 557 of file gen.hxx.

References mnBottom.

◆ SetLeft()

constexpr void tools::Rectangle::SetLeft ( tools::Long  v)
inlineconstexpr

Definition at line 505 of file gen.hxx.

References mnLeft, and v.

Referenced by tools::GenericTypeSerializer::readRectangle().

◆ SetPos()

void tools::Rectangle::SetPos ( const Point rPoint)
inline

Definition at line 662 of file gen.hxx.

References Point::X(), and Point::Y().

◆ SetPosX()

void tools::Rectangle::SetPosX ( tools::Long  x)
inline

Set the left edge of the rectangle to x, preserving the width.

Definition at line 648 of file gen.hxx.

References mnLeft, mnRight, and x.

◆ SetPosY()

void tools::Rectangle::SetPosY ( tools::Long  y)
inline

Set the top edge of the rectangle to y, preserving the height.

Definition at line 655 of file gen.hxx.

References mnBottom, mnTop, and y.

◆ SetRight()

constexpr void tools::Rectangle::SetRight ( tools::Long  v)
inlineconstexpr

Definition at line 506 of file gen.hxx.

References mnRight, and v.

Referenced by tools::GenericTypeSerializer::readRectangle(), and scale().

◆ SetSize()

void tools::Rectangle::SetSize ( const Size rSize)
inline

Definition at line 688 of file gen.hxx.

References Size::Height(), and Size::Width().

Referenced by operator+=().

◆ SetTop()

constexpr void tools::Rectangle::SetTop ( tools::Long  v)
inlineconstexpr

Definition at line 507 of file gen.hxx.

References mnTop, and v.

Referenced by tools::GenericTypeSerializer::readRectangle().

◆ setWidth()

void tools::Rectangle::setWidth ( tools::Long  n)
inline

Definition at line 577 of file gen.hxx.

References mnLeft, mnRight, and n.

◆ SetWidth()

void tools::Rectangle::SetWidth ( tools::Long  nWidth)
inline

Definition at line 668 of file gen.hxx.

References mnLeft, and mnRight.

◆ SetWidthEmpty()

void tools::Rectangle::SetWidthEmpty ( )
inline

Definition at line 556 of file gen.hxx.

References mnRight.

Referenced by SaturatingSetSize().

◆ shrink()

void tools::Rectangle::shrink ( tools::Long  nShrinkBy)

Definition at line 191 of file gen.cxx.

References mnBottom, mnLeft, mnRight, and mnTop.

◆ Top()

constexpr tools::Long tools::Rectangle::Top ( ) const
inlineconstexpr

◆ TopCenter()

constexpr Point tools::Rectangle::TopCenter ( ) const
inlineconstexpr

Definition at line 512 of file gen.hxx.

References Left, Right, and Top.

◆ TopLeft()

constexpr Point tools::Rectangle::TopLeft ( ) const
inlineconstexpr

Definition at line 510 of file gen.hxx.

References Left, and Top.

Referenced by Contains(), and ImplPolygon::ImplPolygon().

◆ TopRight()

constexpr Point tools::Rectangle::TopRight ( ) const
inlineconstexpr

Definition at line 511 of file gen.hxx.

References Right, and Top.

Referenced by ImplPolygon::ImplPolygon().

◆ toString()

OString tools::Rectangle::toString ( ) const

Returns the string representation of the rectangle, format is "x, y, width, height".

Definition at line 172 of file gen.cxx.

References Left, and Top.

◆ Union()

tools::Rectangle & tools::Rectangle::Union ( const tools::Rectangle rRect)

Definition at line 76 of file gen.cxx.

References IsEmpty(), mnBottom, mnBottom, mnLeft, mnLeft, mnRight, mnRight, mnTop, and mnTop.

Referenced by GetUnion().

Friends And Related Function Documentation

◆ operator+

tools::Rectangle operator+ ( const tools::Rectangle rRect,
const Point rPt 
)
friend

Definition at line 768 of file gen.hxx.

◆ operator-

tools::Rectangle operator- ( const tools::Rectangle rRect,
const Point rPt 
)
friend

Definition at line 773 of file gen.hxx.

Member Data Documentation

◆ mnBottom

tools::Long tools::Rectangle::mnBottom = RECT_EMPTY
private

Definition at line 603 of file gen.hxx.

Referenced by Intersection(), operator!=(), operator==(), and Union().

◆ mnLeft

tools::Long tools::Rectangle::mnLeft = 0
private

Definition at line 600 of file gen.hxx.

Referenced by Intersection(), operator!=(), operator==(), SaturatingSetSize(), and Union().

◆ mnRight

tools::Long tools::Rectangle::mnRight = RECT_EMPTY
private

Definition at line 602 of file gen.hxx.

Referenced by Intersection(), operator!=(), operator==(), SaturatingSetSize(), and Union().

◆ mnTop

tools::Long tools::Rectangle::mnTop = 0
private

Definition at line 601 of file gen.hxx.

Referenced by Intersection(), operator!=(), operator==(), and Union().

◆ RECT_EMPTY

constexpr short tools::Rectangle::RECT_EMPTY = -32767
staticconstexprprivate

Definition at line 487 of file gen.hxx.


The documentation for this class was generated from the following files: