sw/source/core/bastyp/swrect.cxx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
New commits: commit 7cc0d390e41f9f3c312aca6977a946c358eb1f3e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sun Apr 19 20:16:36 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Apr 20 08:13:09 2020 +0200 fix SwRect::Intersection the comment is correct, the code not so much Change-Id: Ia0d87538c440bcc0133ed870a4404ecad5b24eba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92506 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/bastyp/swrect.cxx b/sw/source/core/bastyp/swrect.cxx index 09246fe2c70e..d443c85d99c3 100644 --- a/sw/source/core/bastyp/swrect.cxx +++ b/sw/source/core/bastyp/swrect.cxx @@ -77,19 +77,15 @@ SwRect& SwRect::Intersection( const SwRect& rRect ) return *this; } -SwRect& SwRect::Intersection_( const SwRect& rRect ) +SwRect& SwRect::Intersection_( const SwRect& rOther ) { // get smaller right and lower, and greater left and upper edge - if ( Left() < rRect.Left() ) - Left( rRect.Left() ); - if ( Top() < rRect.Top() ) - Top( rRect.Top() ); - long n = rRect.Right(); - if ( Right() > n ) - Right( n ); - n = rRect.Bottom(); - if ( Bottom() > n ) - Bottom( n ); + auto left = std::max( m_Point.X(), rOther.m_Point.X() ); + auto top = std::max( m_Point.Y(), rOther.m_Point.Y() ); + long right = std::min( m_Point.X() + m_Size.Width(), rOther.m_Point.X() + rOther.m_Size.Width() ); + auto bottom = std::min( m_Point.Y() + m_Size.Height(), rOther.m_Point.Y() + rOther.m_Size.Height() ); + + *this = SwRect( left, top, right - left, bottom - top ); return *this; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits