include/tools/gen.hxx | 30 +++++++++++++++++++++++++++++- tools/source/generic/gen.cxx | 17 ----------------- 2 files changed, 29 insertions(+), 18 deletions(-)
New commits: commit 80d801cf07b6583e824ad89c3c750b076118f41d Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Tue Jun 14 05:37:30 2022 +0200 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Fri Jun 17 20:41:28 2022 +0200 Rectangle: split SetSize into SetWidth/SetHeight ... and inline the functions. Change-Id: I9285c72e8524f8f0a2d242bfd4cd29edf6d1ed73 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135811 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/include/tools/gen.hxx b/include/tools/gen.hxx index 7a8e66e2a6ff..ab8b443ca403 100644 --- a/include/tools/gen.hxx +++ b/include/tools/gen.hxx @@ -537,7 +537,9 @@ public: /// Set the top edge of the rectangle to y, preserving the height inline void SetPosY(tools::Long y); inline void SetPos( const Point& rPoint ); - void SetSize( const Size& rSize ); + inline void SetWidth(tools::Long); + inline void SetHeight(tools::Long); + inline void SetSize(const Size&); constexpr Point GetPos() const { return TopLeft(); } constexpr Size GetSize() const { return { GetWidth(), GetHeight() }; } @@ -671,6 +673,32 @@ inline void tools::Rectangle::SetPos( const Point& rPoint ) SetPosY(rPoint.Y()); } +inline void tools::Rectangle::SetWidth(tools::Long nWidth) +{ + if (nWidth < 0) + nRight = nLeft + nWidth + 1; + else if (nWidth > 0) + nRight = nLeft + nWidth - 1; + else + SetWidthEmpty(); +} + +inline void tools::Rectangle::SetHeight(tools::Long nHeight) +{ + if (nHeight < 0) + nBottom = nTop + nHeight + 1; + else if (nHeight > 0) + nBottom = nTop + nHeight - 1; + else + SetHeightEmpty(); +} + +inline void tools::Rectangle::SetSize(const Size& rSize) +{ + SetWidth(rSize.Width()); + SetHeight(rSize.Height()); +} + constexpr inline tools::Long tools::Rectangle::GetWidth() const { tools::Long n = 0; diff --git a/tools/source/generic/gen.cxx b/tools/source/generic/gen.cxx index 27120d6abbd1..069b7482cfba 100644 --- a/tools/source/generic/gen.cxx +++ b/tools/source/generic/gen.cxx @@ -42,23 +42,6 @@ size_t Pair::GetHashValue() const return hash; } -void tools::Rectangle::SetSize( const Size& rSize ) -{ - if ( rSize.Width() < 0 ) - nRight = nLeft + rSize.Width() +1; - else if ( rSize.Width() > 0 ) - nRight = nLeft + rSize.Width() -1; - else - SetWidthEmpty(); - - if ( rSize.Height() < 0 ) - nBottom = nTop + rSize.Height() +1; - else if ( rSize.Height() > 0 ) - nBottom = nTop + rSize.Height() -1; - else - SetHeightEmpty(); -} - void tools::Rectangle::SaturatingSetSize(const Size& rSize) { if (rSize.Width() < 0)