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 /svtools | |
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 'svtools')
-rw-r--r-- | svtools/source/control/tabbar.cxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/svtools/source/control/tabbar.cxx b/svtools/source/control/tabbar.cxx index 8ee61e42cb61..a14b16300b8b 100644 --- a/svtools/source/control/tabbar.cxx +++ b/svtools/source/control/tabbar.cxx @@ -864,7 +864,7 @@ void TabBar::ImplShowPage( sal_uInt16 nPos ) auto& pItem = mpImpl->mpItemList[nPos]; if (nPos < mnFirstPos) SetFirstPageId( pItem->mnId ); - else if (pItem->maRect.Right() > nWidth) + else if (!pItem->maRect.IsEmpty() && pItem->maRect.Right() > nWidth) { while (pItem->maRect.Right() > nWidth) { @@ -1868,8 +1868,8 @@ void TabBar::SetCurPageId(sal_uInt16 nPageId) if (pItem->maRect.IsEmpty()) ImplFormat(); - while ((mbMirrored ? (pItem->maRect.Left() < mnOffX) : (pItem->maRect.Right() > nWidth)) || - pItem->maRect.IsEmpty()) + while (pItem->maRect.IsEmpty() || + (mbMirrored ? (pItem->maRect.Left() < mnOffX) : (pItem->maRect.Right() > nWidth))) { sal_uInt16 nNewPos = mnFirstPos + 1; // assure at least the actual tabpages are visible as first tabpage |