diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-06-05 15:24:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-06-07 11:01:37 +0200 |
commit | a46a257794f1f53b294735fc876c394be23a3811 (patch) | |
tree | 9eb4fb72df2cc9e2acdf3edffe0a72f67f90b9fa /vcl/source | |
parent | 43ddddb703bcdb9430752af63ae46527f737f874 (diff) |
improve empty tools::Rectangle (width)
This is the width part, the height part will come next.
Instead of storing "empty" as a special value (which is easy to get
wrong, eg. some image filters pass in that special value, expecting it
to be a valid width), just use separate boolean values for width and
height empty.
Also lots of code was calling GetBottom() or GetRight() on an
empty rectangle, getting back that magic value and doing calculations
on it, resulting in completely bogus data.
So
(1) make the various Rectangle methods do something reasonable
when the empty flags are set
(2) fix various other code to handle empty better
(3) assert when code accesses Bottom or Right and the empty flag
is set.
Change-Id: I1163378cd2773dd8b386210f83400bb6b4701069
Reviewed-on: https://gerrit.libreoffice.org/73564
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/mtfxmldump.cxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/rect.cxx | 3 | ||||
-rw-r--r-- | vcl/source/treelist/treelistbox.cxx | 2 |
4 files changed, 5 insertions, 4 deletions
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index d5b9eeeeacfa..eeede1ae1e1c 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -2123,7 +2123,7 @@ Size TabControl::calculateRequisition() const tools::Rectangle aTabRect = pThis->ImplGetTabRect(nPos, aOptimalPageSize.Width(), LONG_MAX); if (aTabRect.Bottom() > nTabLabelsBottom) nTabLabelsBottom = aTabRect.Bottom(); - if (aTabRect.Right() > nTabLabelsRight) + if (!aTabRect.IsEmpty() && aTabRect.Right() > nTabLabelsRight) nTabLabelsRight = aTabRect.Right(); } diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx index 8c168a89d4c4..3f681a08a674 100644 --- a/vcl/source/gdi/mtfxmldump.cxx +++ b/vcl/source/gdi/mtfxmldump.cxx @@ -459,7 +459,7 @@ void writeRectangle(tools::XmlWriter& rWriter, tools::Rectangle const& rRectangl { rWriter.attribute("left", rRectangle.Left()); rWriter.attribute("top", rRectangle.Top()); - rWriter.attribute("right", rRectangle.Right()); + rWriter.attribute("right", rRectangle.IsWidthEmpty() ? -32767 : rRectangle.Right()); rWriter.attribute("bottom", rRectangle.Bottom()); } diff --git a/vcl/source/outdev/rect.cxx b/vcl/source/outdev/rect.cxx index 67343278a1be..14d341ac6b8f 100644 --- a/vcl/source/outdev/rect.cxx +++ b/vcl/source/outdev/rect.cxx @@ -376,7 +376,8 @@ BmpMirrorFlags AdjustTwoRect( SalTwoRect& rTwoRect, const Size& rSizePix ) void AdjustTwoRect( SalTwoRect& rTwoRect, const tools::Rectangle& rValidSrcRect ) { - if( ( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= rValidSrcRect.Right() ) || + long right = rValidSrcRect.IsEmpty() ? rValidSrcRect.Left() : rValidSrcRect.Right(); + if( ( rTwoRect.mnSrcX < rValidSrcRect.Left() ) || ( rTwoRect.mnSrcX >= right ) || ( rTwoRect.mnSrcY < rValidSrcRect.Top() ) || ( rTwoRect.mnSrcY >= rValidSrcRect.Bottom() ) || ( ( rTwoRect.mnSrcX + rTwoRect.mnSrcWidth ) > rValidSrcRect.Right() ) || ( ( rTwoRect.mnSrcY + rTwoRect.mnSrcHeight ) > rValidSrcRect.Bottom() ) ) diff --git a/vcl/source/treelist/treelistbox.cxx b/vcl/source/treelist/treelistbox.cxx index f42aac4983af..b91fb5552d61 100644 --- a/vcl/source/treelist/treelistbox.cxx +++ b/vcl/source/treelist/treelistbox.cxx @@ -2770,7 +2770,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, long nLine, vcl::Render { rRenderContext.SetFillColor(aBackgroundColor); // this case may occur for smaller horizontal resizes - if (aRect.Left() < aRect.Right()) + if (!aRect.IsEmpty() && (aRect.Left() < aRect.Right())) rRenderContext.DrawRect(aRect); } } |