svtools/source/control/valueset.cxx | 52 +++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 18 deletions(-)
New commits: commit 77090e4e2515aefe547618487cdc96fde567e595 Author: David Tardon <dtar...@redhat.com> Date: Tue Nov 1 10:10:03 2011 +0100 remove superfluous casts diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index a3d38f0..1a75dd2 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1438,8 +1438,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) else if ( nCalcPos >= mnCols ) // we can go up { if ( nCalcPos >= ( nLineCount * mnCols ) ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos - ( nLineCount * mnCols )); + nItemPos = nCalcPos - ( nLineCount * mnCols ); else // Go to the first line. This can only happen for KEY_PAGEUP nItemPos = nCalcPos % mnCols; @@ -1482,8 +1481,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) else if ( nCalcPos + mnCols <= nLastItem ) // we can go down { if ( nCalcPos + ( nLineCount * mnCols ) <= nLastItem ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos + ( nLineCount * mnCols )); + nItemPos = nCalcPos + ( nLineCount * mnCols ); else // Go to the last line. This can only happen for KEY_PAGEDOWN nItemPos = lcl_gotoLastLine(nLastItem, mnCols, nCalcPos); commit 3acbdb2dee458cba6904a636733f1777b47e9fc1 Author: David Tardon <dtar...@redhat.com> Date: Tue Nov 1 10:07:44 2011 +0100 let PgUp/Down go to the first/last line diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 5834f59..a3d38f0 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1318,6 +1318,20 @@ void ValueSet::Tracking( const TrackingEvent& rTEvt ) // ----------------------------------------------------------------------- +namespace +{ + +size_t +lcl_gotoLastLine(size_t const nLastPos, size_t const nCols, size_t const nCurPos) +{ + size_t nItemPos = ((((nLastPos+1)/nCols)-1)*nCols)+(nCurPos%nCols); + if ( nItemPos+nCols <= nLastPos ) + nItemPos = nItemPos + nCols; + return nItemPos; +} + +} + void ValueSet::KeyInput( const KeyEvent& rKEvt ) { size_t nLastItem = mpImpl->mpItemList->size(); @@ -1419,16 +1433,18 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) if ( nLastItem+1 <= mnCols ) nItemPos = mnCurCol; else - { - nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(mnCurCol%mnCols); - if ( nItemPos+mnCols <= nLastItem ) - nItemPos = nItemPos + mnCols; - } + nItemPos = lcl_gotoLastLine(nLastItem, mnCols, mnCurCol); } - else if ( nCalcPos >= ( nLineCount * mnCols ) ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos - ( nLineCount * mnCols )); - else + else if ( nCalcPos >= mnCols ) // we can go up + { + if ( nCalcPos >= ( nLineCount * mnCols ) ) + nItemPos = sal::static_int_cast< sal_uInt16 >( + nCalcPos - ( nLineCount * mnCols )); + else + // Go to the first line. This can only happen for KEY_PAGEUP + nItemPos = nCalcPos % mnCols; + } + else // wrap around { if ( mpNoneItem ) { @@ -1440,11 +1456,7 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) if ( nLastItem+1 <= mnCols ) nItemPos = nCalcPos; else - { - nItemPos = ((((nLastItem+1)/mnCols)-1)*mnCols)+(nCalcPos%mnCols); - if ( nItemPos+mnCols <= nLastItem ) - nItemPos = nItemPos + mnCols; - } + nItemPos = lcl_gotoLastLine(nLastItem, mnCols, nCalcPos); } } nCalcPos = nItemPos; @@ -1467,10 +1479,16 @@ void ValueSet::KeyInput( const KeyEvent& rKEvt ) { if ( nCalcPos == VALUESET_ITEM_NONEITEM ) nItemPos = mnCurCol; - else if ( nCalcPos + ( nLineCount * mnCols ) <= nLastItem ) - nItemPos = sal::static_int_cast< sal_uInt16 >( - nCalcPos + ( nLineCount * mnCols )); - else + else if ( nCalcPos + mnCols <= nLastItem ) // we can go down + { + if ( nCalcPos + ( nLineCount * mnCols ) <= nLastItem ) + nItemPos = sal::static_int_cast< sal_uInt16 >( + nCalcPos + ( nLineCount * mnCols )); + else + // Go to the last line. This can only happen for KEY_PAGEDOWN + nItemPos = lcl_gotoLastLine(nLastItem, mnCols, nCalcPos); + } + else // wrap around { { if ( mpNoneItem ) _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits