diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-10-01 10:25:00 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-10-02 00:35:35 +0200 |
commit | 48895bef52bd59e30751ece0c8a8d57ef7864936 (patch) | |
tree | 31b59bd0d08afcfbff78552ae9e483bf4f7d9ea2 /sw/inc/swrect.hxx | |
parent | d7397d36b3c801681a802f4f2f16aec0c01a76db (diff) |
make some simple SwRect functions inline
They are not trivial, but having them inline should still give
the compiler more chances to optimize these.
Change-Id: Ia296282b64f64c801a057332047c12576d1d9604
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122912
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'sw/inc/swrect.hxx')
-rw-r--r-- | sw/inc/swrect.hxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sw/inc/swrect.hxx b/sw/inc/swrect.hxx index 3ba1f67d0882..039d2b414704 100644 --- a/sw/inc/swrect.hxx +++ b/sw/inc/swrect.hxx @@ -315,6 +315,51 @@ inline SwRect::SwRect( tools::Long X, tools::Long Y, tools::Long W, tools::Long { } +inline Point SwRect::Center() const +{ + return Point( Left() + Width() / 2, + Top() + Height() / 2 ); +} + +inline bool SwRect::Contains( const SwRect& rRect ) const +{ + const tools::Long nRight = Right(); + const tools::Long nBottom = Bottom(); + const tools::Long nrRight = rRect.Right(); + const tools::Long nrBottom= rRect.Bottom(); + return (Left() <= rRect.Left()) && (rRect.Left()<= nRight) && + (Left() <= nrRight) && (nrRight <= nRight) && + (Top() <= rRect.Top()) && (rRect.Top() <= nBottom) && + (Top() <= nrBottom) && (nrBottom <= nBottom); +} + +inline bool SwRect::Contains( const Point& rPoint ) const +{ + return (Left() <= rPoint.X()) && + (Top() <= rPoint.Y()) && + (Right() >= rPoint.X()) && + (Bottom()>= rPoint.Y()); +} + +// mouse moving of table borders +inline bool SwRect::IsNear( const Point& rPoint, tools::Long nTolerance ) const +{ + bool bIsNearby = (((Left() - nTolerance) <= rPoint.X()) && + ((Top() - nTolerance) <= rPoint.Y()) && + ((Right() + nTolerance) >= rPoint.X()) && + ((Bottom() + nTolerance) >= rPoint.Y())); + return Contains(rPoint) || bIsNearby; +} + +inline bool SwRect::Overlaps( const SwRect& rRect ) const +{ + return (Top() <= rRect.Bottom()) && + (Left() <= rRect.Right()) && + (Right() >= rRect.Left()) && + (Bottom()>= rRect.Top()); +} + + template< typename charT, typename traits > inline std::basic_ostream<charT, traits> & operator <<( std::basic_ostream<charT, traits> & stream, const SwRect& rectangle ) |