diff options
author | Philipp Lohmann <pl@openoffice.org> | 2010-12-14 18:11:40 +0100 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2010-12-14 18:12:43 +0100 |
commit | 2e9c605e95d9f3e3a0fc5bf2e4eecb514a984d6e (patch) | |
tree | aaa5efd7c452fc6b2a63dc16d7936891813b99c8 /vcl | |
parent | c449af3cd0dcf4487afc6b90085774392a46170d (diff) |
TabControl::ImplGetTabRect negative height gives BadAlloc
Fix from i#116120
Signed-off-by: Thorsten Behrens <tbehrens@novell.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/control/tabctrl.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx index 8cc7bb221a09..e94691f42da7 100644 --- a/vcl/source/control/tabctrl.cxx +++ b/vcl/source/control/tabctrl.cxx @@ -443,15 +443,18 @@ Size TabControl::ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth ) Rectangle TabControl::ImplGetTabRect( USHORT nItemPos, long nWidth, long nHeight ) { Size aWinSize = Control::GetOutputSizePixel(); - if ( nWidth == -1 ) + if ( nWidth < 0 ) nWidth = aWinSize.Width(); - if ( nHeight == -1 ) + if ( nHeight < 0 ) nHeight = aWinSize.Height(); if ( mpTabCtrlData->maItemList.empty() ) { - return Rectangle( Point( TAB_OFFSET, TAB_OFFSET ), - Size( nWidth-TAB_OFFSET*2, nHeight-TAB_OFFSET*2 ) ); + long nW = nWidth-TAB_OFFSET*2; + long nH = nHeight-TAB_OFFSET*2; + return (nW > 0 && nH > 0) + ? Rectangle( Point( TAB_OFFSET, TAB_OFFSET ), Size( nW, nH ) ) + : Rectangle(); } if ( nItemPos == TAB_PAGERECT ) @@ -463,9 +466,11 @@ Rectangle TabControl::ImplGetTabRect( USHORT nItemPos, long nWidth, long nHeight nLastPos = 0; Rectangle aRect = ImplGetTabRect( nLastPos, nWidth, nHeight ); - aRect = Rectangle( Point( TAB_OFFSET, aRect.Bottom()+TAB_OFFSET ), - Size( nWidth-TAB_OFFSET*2, - nHeight-aRect.Bottom()-TAB_OFFSET*2 ) ); + long nW = nWidth-TAB_OFFSET*2; + long nH = nHeight-aRect.Bottom()-TAB_OFFSET*2; + aRect = (nW > 0 && nH > 0) + ? Rectangle( Point( TAB_OFFSET, aRect.Bottom()+TAB_OFFSET ), Size( nW, nH ) ) + : Rectangle(); return aRect; } |