summaryrefslogtreecommitdiff
path: root/include/tools
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2022-06-14 05:37:30 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2022-06-17 20:41:28 +0200
commit80d801cf07b6583e824ad89c3c750b076118f41d (patch)
tree359abf430ee078db1eccd888408dfb8e0d0a4456 /include/tools
parente2a8b4a420ab0f726c43ec6c609d17211cd6ed11 (diff)
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 <glogow@fbihome.de>
Diffstat (limited to 'include/tools')
-rw-r--r--include/tools/gen.hxx30
1 files changed, 29 insertions, 1 deletions
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;