diff options
author | Matteo Casalin <matteo.casalin@gmx.com> | 2012-03-03 21:55:29 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@gmx.com> | 2012-04-03 20:49:07 +0200 |
commit | 57533a3ddb37cd367e7ae0edfef1c8502a7d9199 (patch) | |
tree | b78ffdff13fdfceeffb3f479af35336b5ed8ce95 /svtools | |
parent | e7e882715872303dc8feabc899ceab572d1c2337 (diff) |
ValueSet: simplify calculation of item rectangle
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/valueset.cxx | 11 |
1 files changed, 4 insertions, 7 deletions
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<size_t>(mnFirstLine)*mnCols; - const size_t nMaxVisible = static_cast<size_t>(mnVisLines)*mnCols; - size_t nVisibleEnd = nVisibleBegin+nMaxVisible; - if ( nVisibleEnd>mItemList.size() ) - { - nVisibleEnd = mItemList.size(); - } + const size_t nVisibleEnd = nVisibleBegin + static_cast<size_t>(mnVisLines)*mnCols; - if ( nPos<nVisibleBegin || 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<nVisibleBegin || nPos>=nVisibleEnd || nPos>=mItemList.size() ) return Rectangle(); nPos -= nVisibleBegin; |