summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-06-05 15:24:04 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-06-07 11:01:37 +0200
commita46a257794f1f53b294735fc876c394be23a3811 (patch)
tree9eb4fb72df2cc9e2acdf3edffe0a72f67f90b9fa /vcl
parent43ddddb703bcdb9430752af63ae46527f737f874 (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')
-rw-r--r--vcl/osx/salnativewidgets.cxx2
-rw-r--r--vcl/source/control/tabctrl.cxx2
-rw-r--r--vcl/source/gdi/mtfxmldump.cxx2
-rw-r--r--vcl/source/outdev/rect.cxx3
-rw-r--r--vcl/source/treelist/treelistbox.cxx2
-rw-r--r--vcl/win/gdi/salnativewidgets-luna.cxx3
6 files changed, 10 insertions, 4 deletions
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index ad1362d438de..481d7a90e5fe 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -1017,6 +1017,8 @@ bool AquaSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPa
tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion )
{
+ if (rControlRegion.IsEmpty()) // nothing to do
+ return false;
bool toReturn = false;
tools::Rectangle aCtrlBoundRect( rControlRegion );
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);
}
}
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 422a86c27045..1b49bfba61ad 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -1155,6 +1155,9 @@ bool WinSalGraphics::drawNativeControl( ControlType nType,
bool bOk = false;
HTHEME hTheme = nullptr;
+ if (rControlRegion.IsEmpty()) // nothing to do
+ return true;
+
tools::Rectangle buttonRect = rControlRegion;
tools::Rectangle cacheRect = rControlRegion;
Size keySize = cacheRect.GetSize();