[Libreoffice-commits] core.git: include/tools tools/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Tue Aug 17 09:25:19 UTC 2021
include/tools/gen.hxx | 9 ++++++++-
tools/source/generic/gen.cxx | 9 ---------
2 files changed, 8 insertions(+), 10 deletions(-)
New commits:
commit 28708b5b7ad12bc30f02142c990e5ad4128af912
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Sat Aug 14 22:08:17 2021 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Aug 17 11:24:46 2021 +0200
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 at collabora.com>
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 )
More information about the Libreoffice-commits
mailing list