diff options
author | Matteo Casalin <matteo.casalin@gmx.com> | 2012-02-18 16:09:42 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@gmx.com> | 2012-03-03 09:49:34 +0100 |
commit | 243fa9392f1bbfaee41571b3d227535d1c49556a (patch) | |
tree | 6cf48c2c7d1807b10bb72886699a85f127b99572 /svtools/source/control/valueset.cxx | |
parent | 8f2d3c47ad40039a842fa09d98137155dcfdfe9e (diff) |
ValueSet: replace some conditionals with simple arithmetic
Diffstat (limited to 'svtools/source/control/valueset.cxx')
-rw-r--r-- | svtools/source/control/valueset.cxx | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 715040252dc5..7f7721581d68 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -430,10 +430,9 @@ void ValueSet::Format() // calculate number of rows mbScroll = false; - mnLines = (long)mItemList.size() / mnCols; - if ( mItemList.size() % mnCols ) - mnLines++; - else if ( !mnLines ) + // Floor( (M+N-1)/N )==Ceiling( M/N ) + mnLines = (static_cast<long>(nItemCount)+mnCols-1) / mnCols; + if ( !mnLines ) mnLines = 1; long nCalcHeight = aWinSize.Height()-nNoneHeight; @@ -2298,10 +2297,9 @@ Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCol nCalcLines = mnUserVisLines; else { - nCalcLines = mItemList.size() / nCalcCols; - if ( mItemList.size() % nCalcCols ) - nCalcLines++; - else if ( !nCalcLines ) + // Floor( (M+N-1)/N )==Ceiling( M/N ) + nCalcLines = (mItemList.size()+nCalcCols-1) / nCalcCols; + if ( !nCalcLines ) nCalcLines = 1; } } |