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 | |
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')
-rw-r--r-- | sw/inc/swrect.hxx | 45 | ||||
-rw-r--r-- | sw/source/core/bastyp/swrect.cxx | 44 |
2 files changed, 45 insertions, 44 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 ) diff --git a/sw/source/core/bastyp/swrect.cxx b/sw/source/core/bastyp/swrect.cxx index 8f94cef23727..0825696f45c6 100644 --- a/sw/source/core/bastyp/swrect.cxx +++ b/sw/source/core/bastyp/swrect.cxx @@ -32,12 +32,6 @@ SwRect::SwRect( const tools::Rectangle &rRect ) : m_Size.setHeight(rRect.IsHeightEmpty() ? 0 : rRect.Bottom() - rRect.Top() + 1); } -Point SwRect::Center() const -{ - return Point( Left() + Width() / 2, - Top() + Height() / 2 ); -} - SwRect& SwRect::Union( const SwRect& rRect ) { if ( Top() > rRect.Top() ) @@ -90,44 +84,6 @@ SwRect& SwRect::Intersection_( const SwRect& rOther ) return *this; } -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); -} - -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 -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; -} - -bool SwRect::Overlaps( const SwRect& rRect ) const -{ - return (Top() <= rRect.Bottom()) && - (Left() <= rRect.Right()) && - (Right() >= rRect.Left()) && - (Bottom()>= rRect.Top()); -} - void SwRect::Justify() { if ( m_Size.getHeight() < 0 ) |