summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-08-14 22:08:17 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2021-08-17 11:24:46 +0200
commit28708b5b7ad12bc30f02142c990e5ad4128af912 (patch)
treeb3a25f28020dd2693dcbc0e8e66ea2656f1fc351
parent8e5cb2bcae998b8606de12c7bc4cde1f98346190 (diff)
Simplify and inline tools::Rectangle::Justify
Change-Id: I535fb70fa532d98542ac30e0b2053bdaa6b94383 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120494 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--include/tools/gen.hxx9
-rw-r--r--tools/source/generic/gen.cxx9
2 files changed, 8 insertions, 10 deletions
diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx
index 2d23b693fa50..5cc23bf83654 100644
--- a/include/tools/gen.hxx
+++ b/include/tools/gen.hxx
@@ -472,7 +472,7 @@ public:
constexpr Rectangle( tools::Long nLeft, tools::Long nTop );
constexpr Rectangle( const Point& rLT, const Size& rSize );
- static Rectangle Justify( const Point& rLT, const Point& rRB );
+ inline constexpr static Rectangle Justify(const Point& rLT, const Point& rRB);
constexpr tools::Long Left() const { return nLeft; }
constexpr tools::Long Right() const { return IsWidthEmpty() ? nLeft : nRight; }
@@ -626,6 +626,13 @@ constexpr inline tools::Rectangle::Rectangle( const Point& rLT, const Size& rSiz
, nBottom(rSize.Height() ? nTop + (rSize.Height() + (rSize.Height() > 0 ? -1 : 1)) : RECT_EMPTY)
{}
+constexpr inline tools::Rectangle tools::Rectangle::Justify(const Point& rLT, const Point& rRB)
+{
+ const std::pair<tools::Long, tools::Long> aLeftRight = std::minmax(rLT.X(), rRB.X());
+ const std::pair<tools::Long, tools::Long> aTopBottom = std::minmax(rLT.Y(), rRB.Y());
+ return { aLeftRight.first, aTopBottom.first, aLeftRight.second, aTopBottom.second };
+}
+
inline void tools::Rectangle::Move( tools::Long nHorzMove, tools::Long nVertMove )
{
nLeft += nHorzMove;
diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx
index 4d365a575808..027c7b9356b1 100644
--- a/tools/source/generic/gen.cxx
+++ b/tools/source/generic/gen.cxx
@@ -35,15 +35,6 @@ OString Pair::toString() const
return OString::number(A()) + ", " + OString::number(B());
}
-tools::Rectangle tools::Rectangle::Justify( const Point& rLT, const Point& rRB )
-{
- tools::Long nLeft = std::min(rLT.X(), rRB.X());
- tools::Long nTop = std::min(rLT.Y(), rRB.Y());
- tools::Long nRight = std::max(rLT.X(), rRB.X());
- tools::Long nBottom = std::max(rLT.Y(), rRB.Y());
- return Rectangle( nLeft, nTop, nRight, nBottom );
-}
-
void tools::Rectangle::SetSize( const Size& rSize )
{
if ( rSize.Width() < 0 )