diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-12 12:26:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-13 08:15:32 +0200 |
commit | 71eea07e1f888aea325aff2c07cd8fc6e8db4a8a (patch) | |
tree | 090243376a829ec36ccba45d312fc7b4004470c4 /svtools | |
parent | a361231b1363d072d737e9b1d411b71aa9550d84 (diff) |
handle empty tools::Rectangle in svtoools
Change-Id: Ia6c4d56e8019fd92ac69499b9902f8bd8ca27fec
Reviewed-on: https://gerrit.libreoffice.org/72187
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/hatchwindow/ipwin.cxx | 32 | ||||
-rw-r--r-- | svtools/source/hatchwindow/ipwin.hxx | 5 |
2 files changed, 21 insertions, 16 deletions
diff --git a/svtools/source/hatchwindow/ipwin.cxx b/svtools/source/hatchwindow/ipwin.cxx index adb751941456..f5235535a33b 100644 --- a/svtools/source/hatchwindow/ipwin.cxx +++ b/svtools/source/hatchwindow/ipwin.cxx @@ -45,8 +45,10 @@ SvResizeHelper::SvResizeHelper() |* |* Description: the eight handles to magnify *************************************************************************/ -void SvResizeHelper::FillHandleRectsPixel( tools::Rectangle aRects[ 8 ] ) const +std::array<tools::Rectangle,8> SvResizeHelper::FillHandleRectsPixel() const { + std::array<tools::Rectangle,8> aRects; + // only because of EMPTY_RECT Point aBottomRight = aOuter.BottomRight(); @@ -80,6 +82,7 @@ void SvResizeHelper::FillHandleRectsPixel( tools::Rectangle aRects[ 8 ] ) const aRects[ 7 ] = tools::Rectangle( Point( aOuter.Left(), aOuter.Center().Y() - aBorder.Height() / 2 ), aBorder ); + return aRects; } /************************************************************************* @@ -87,20 +90,26 @@ void SvResizeHelper::FillHandleRectsPixel( tools::Rectangle aRects[ 8 ] ) const |* |* Description: the four edges are calculated *************************************************************************/ -void SvResizeHelper::FillMoveRectsPixel( tools::Rectangle aRects[ 4 ] ) const +std::array<tools::Rectangle,4> SvResizeHelper::FillMoveRectsPixel() const { + std::array<tools::Rectangle,4> aRects; + // upper aRects[ 0 ] = aOuter; aRects[ 0 ].SetBottom( aRects[ 0 ].Top() + aBorder.Height() -1 ); // right aRects[ 1 ] = aOuter; - aRects[ 1 ].SetLeft( aRects[ 1 ].Right() - aBorder.Width() -1 ); + if (!aOuter.IsWidthEmpty()) + aRects[ 1 ].SetLeft( aRects[ 1 ].Right() - aBorder.Width() -1 ); // lower aRects[ 2 ] = aOuter; - aRects[ 2 ].SetTop( aRects[ 2 ].Bottom() - aBorder.Height() -1 ); + if (!aOuter.IsHeightEmpty()) + aRects[ 2 ].SetTop( aRects[ 2 ].Bottom() - aBorder.Height() -1 ); // left aRects[ 3 ] = aOuter; aRects[ 3 ].SetRight( aRects[ 3 ].Left() + aBorder.Width() -1 ); + + return aRects; } /************************************************************************* @@ -116,15 +125,13 @@ void SvResizeHelper::Draw(vcl::RenderContext& rRenderContext) rRenderContext.SetFillColor( COL_LIGHTGRAY ); rRenderContext.SetLineColor(); - tools::Rectangle aMoveRects[ 4 ]; - FillMoveRectsPixel( aMoveRects ); + std::array<tools::Rectangle,4> aMoveRects = FillMoveRectsPixel(); sal_uInt16 i; for (i = 0; i < 4; i++) rRenderContext.DrawRect(aMoveRects[i]); // draw handles rRenderContext.SetFillColor(Color()); // black - tools::Rectangle aRects[ 8 ]; - FillHandleRectsPixel(aRects); + std::array<tools::Rectangle,8> aRects = FillHandleRectsPixel(); for (i = 0; i < 8; i++) rRenderContext.DrawRect( aRects[ i ] ); rRenderContext.Pop(); @@ -137,8 +144,7 @@ void SvResizeHelper::Draw(vcl::RenderContext& rRenderContext) *************************************************************************/ void SvResizeHelper::InvalidateBorder( vcl::Window * pWin ) { - tools::Rectangle aMoveRects[ 4 ]; - FillMoveRectsPixel( aMoveRects ); + std::array<tools::Rectangle,4> aMoveRects = FillMoveRectsPixel(); for(const auto & rMoveRect : aMoveRects) pWin->Invalidate( rMoveRect ); } @@ -172,14 +178,12 @@ short SvResizeHelper::SelectMove( vcl::Window * pWin, const Point & rPos ) { if( -1 == nGrab ) { - tools::Rectangle aRects[ 8 ]; - FillHandleRectsPixel( aRects ); + std::array<tools::Rectangle,8> aRects = FillHandleRectsPixel(); for( sal_uInt16 i = 0; i < 8; i++ ) if( aRects[ i ].IsInside( rPos ) ) return i; // Move-Rect overlaps Handles - tools::Rectangle aMoveRects[ 4 ]; - FillMoveRectsPixel( aMoveRects ); + std::array<tools::Rectangle,4> aMoveRects = FillMoveRectsPixel(); for(const auto & rMoveRect : aMoveRects) if( rMoveRect.IsInside( rPos ) ) return 8; diff --git a/svtools/source/hatchwindow/ipwin.hxx b/svtools/source/hatchwindow/ipwin.hxx index 47c033cdc255..cacf743278dc 100644 --- a/svtools/source/hatchwindow/ipwin.hxx +++ b/svtools/source/hatchwindow/ipwin.hxx @@ -22,6 +22,7 @@ #include <tools/gen.hxx> #include <vcl/window.hxx> +#include <array> /********************** SvResizeHelper *********************************** *************************************************************************/ @@ -48,8 +49,8 @@ public: } // Clockwise, start at upper left - void FillHandleRectsPixel( tools::Rectangle aRects[ 8 ] ) const; - void FillMoveRectsPixel( tools::Rectangle aRects[ 4 ] ) const; + std::array<tools::Rectangle,8> FillHandleRectsPixel() const; + std::array<tools::Rectangle,4> FillMoveRectsPixel() const; void Draw(vcl::RenderContext& rRenderContext); void InvalidateBorder( vcl::Window * ); bool SelectBegin( vcl::Window *, const Point & rPos ); |