From 57533a3ddb37cd367e7ae0edfef1c8502a7d9199 Mon Sep 17 00:00:00 2001 From: Matteo Casalin Date: Sat, 3 Mar 2012 21:55:29 +0100 Subject: ValueSet: simplify calculation of item rectangle --- svtools/source/control/valueset.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'svtools') diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 8cd032be9716..e8aa9f59390f 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1758,14 +1758,11 @@ void ValueSet::ImplInsertItem( ValueSetItem *const pItem, const size_t nPos ) Rectangle ValueSet::ImplGetItemRect( size_t nPos ) const { const size_t nVisibleBegin = static_cast(mnFirstLine)*mnCols; - const size_t nMaxVisible = static_cast(mnVisLines)*mnCols; - size_t nVisibleEnd = nVisibleBegin+nMaxVisible; - if ( nVisibleEnd>mItemList.size() ) - { - nVisibleEnd = mItemList.size(); - } + const size_t nVisibleEnd = nVisibleBegin + static_cast(mnVisLines)*mnCols; - if ( nPos=nVisibleEnd ) + // Check if the item is inside the range of the displayed ones, + // taking into account that last row could be incomplete + if ( nPos=nVisibleEnd || nPos>=mItemList.size() ) return Rectangle(); nPos -= nVisibleBegin; -- cgit