diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-12 12:28:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-05-13 08:15:43 +0200 |
commit | 630db80d17616d635cf2e5f1d5a0852428b794a3 (patch) | |
tree | 956dcce67bd5836ce7a06357576d5398d359248c | |
parent | 71eea07e1f888aea325aff2c07cd8fc6e8db4a8a (diff) |
handle empty tools::Rectangle in vcl
Change-Id: I64b5c3c5a19408febe7753db6ea403b91f7f5c83
Reviewed-on: https://gerrit.libreoffice.org/72188
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 6 | ||||
-rw-r--r-- | vcl/source/filter/wmf/emfwr.cxx | 6 | ||||
-rw-r--r-- | vcl/source/outdev/map.cxx | 12 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx | 12 |
4 files changed, 24 insertions, 12 deletions
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index ea9cfcee05f1..d5b9eeeeacfa 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -544,11 +544,13 @@ tools::Rectangle TabControl::ImplGetTabRect( sal_uInt16 nItemPos, long nWidth, l nLastPos = 0; tools::Rectangle aRect = ImplGetTabRect( nLastPos, nWidth, nHeight ); + if (aRect.IsEmpty()) + return aRect; long nW = nWidth-TAB_OFFSET*2; long nH = nHeight-aRect.Bottom()-TAB_OFFSET*2; aRect = (nW > 0 && nH > 0) - ? tools::Rectangle( Point( TAB_OFFSET, aRect.Bottom()+TAB_OFFSET ), Size( nW, nH ) ) - : tools::Rectangle(); + ? tools::Rectangle( Point( TAB_OFFSET, aRect.Bottom()+TAB_OFFSET ), Size( nW, nH ) ) + : tools::Rectangle(); return aRect; } diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index c3200c53020d..17d23f787aa9 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -607,11 +607,13 @@ void EMFWriter::ImplWriteSize( const Size& rSize) void EMFWriter::ImplWriteRect( const tools::Rectangle& rRect ) { const tools::Rectangle aRect( OutputDevice::LogicToLogic ( rRect, maVDev->GetMapMode(), maDestMapMode )); + auto right = aRect.IsWidthEmpty() ? aRect.Left() : aRect.Right(); + auto bottom = aRect.IsHeightEmpty() ? aRect.Top() : aRect.Bottom(); m_rStm .WriteInt32( aRect.Left() ) .WriteInt32( aRect.Top() ) - .WriteInt32( aRect.Right() ) - .WriteInt32( aRect.Bottom() ); + .WriteInt32( right ) + .WriteInt32( bottom ); } void EMFWriter::ImplWritePolygonRecord( const tools::Polygon& rPoly, bool bClose ) diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index 60da88618fba..5a91bfb274c3 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -1863,10 +1863,14 @@ tools::Rectangle OutputDevice::LogicToLogic( const tools::Rectangle& rRectSource { ENTER3( eUnitSource, eUnitDest ); - return tools::Rectangle( fn3( rRectSource.Left(), nNumerator, nDenominator ), - fn3( rRectSource.Top(), nNumerator, nDenominator ), - fn3( rRectSource.Right(), nNumerator, nDenominator ), - fn3( rRectSource.Bottom(), nNumerator, nDenominator ) ); + auto left = fn3( rRectSource.Left(), nNumerator, nDenominator ); + auto top = fn3( rRectSource.Top(), nNumerator, nDenominator ); + if (rRectSource.IsEmpty()) + return tools::Rectangle( left, top ); + + auto right = fn3( rRectSource.Right(), nNumerator, nDenominator ); + auto bottom = fn3( rRectSource.Bottom(), nNumerator, nDenominator ); + return tools::Rectangle(left, top, right, bottom); } else { diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx index 51a83dd7705b..0de96d2be4ca 100644 --- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx @@ -731,15 +731,19 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context, { tools::Rectangle aBtn1Rect = NWGetScrollButtonRect(ControlPart::ButtonLeft, aTrackRect); tools::Rectangle aBtn2Rect = NWGetScrollButtonRect(ControlPart::ButtonRight, aTrackRect); - aTrackRect.SetLeft( aBtn1Rect.Right() ); - aTrackRect.SetRight( aBtn2Rect.Left() ); + if (!aBtn1Rect.IsWidthEmpty()) + aTrackRect.SetLeft( aBtn1Rect.Right() ); + if (!aBtn2Rect.IsWidthEmpty()) + aTrackRect.SetRight( aBtn2Rect.Left() ); } else { tools::Rectangle aBtn1Rect = NWGetScrollButtonRect(ControlPart::ButtonUp, aTrackRect); tools::Rectangle aBtn2Rect = NWGetScrollButtonRect(ControlPart::ButtonDown, aTrackRect); - aTrackRect.SetTop( aBtn1Rect.Bottom() + 1 ); - aTrackRect.SetBottom( aBtn2Rect.Top() ); + if (!aBtn1Rect.IsHeightEmpty()) + aTrackRect.SetTop( aBtn1Rect.Bottom() + 1 ); + if (!aBtn2Rect.IsHeightEmpty()) + aTrackRect.SetBottom( aBtn2Rect.Top() ); } GtkStyleContext* pScrollbarTroughStyle = scrollbarOrientation == GTK_ORIENTATION_VERTICAL ? |