diff options
author | Matteo Casalin <matteo.casalin@poste.it> | 2012-01-02 19:46:49 +0100 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@poste.it> | 2012-01-02 19:49:05 +0100 |
commit | ca343939c03551957433708836517eb37b62e523 (patch) | |
tree | 9661fde2df30e4e5920d25537e71e692b8110afe /svtools | |
parent | fe36838f9db5fef3c281b677c64b4db0519c9d4d (diff) |
Group a common test to avoid unnecessary calculations
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/valueset.cxx | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx index 97ecc035c302..84f472ff4fee 100644 --- a/svtools/source/control/valueset.cxx +++ b/svtools/source/control/valueset.cxx @@ -1033,35 +1033,34 @@ sal_Bool ValueSet::ImplScroll( const Point& rPos ) size_t ValueSet::ImplGetItem( const Point& rPos, sal_Bool bMove ) const { - if ( mpNoneItem ) + if ( mpNoneItem && mpNoneItem->maRect.IsInside( rPos ) ) { - if ( mpNoneItem->maRect.IsInside( rPos ) ) - return VALUESET_ITEM_NONEITEM; + return VALUESET_ITEM_NONEITEM; } - Point aDefPos; - Rectangle aWinRect( aDefPos, maVirDev.GetOutputSizePixel() ); + const Rectangle aWinRect( Point(), maVirDev.GetOutputSizePixel() ); - size_t nItemCount = mpImpl->mpItemList->size(); - for ( size_t i = 0; i < nItemCount; i++ ) + if ( aWinRect.IsInside( rPos ) ) { - ValueSetItem* pItem = (*mpImpl->mpItemList)[ i ]; - if ( pItem->maRect.IsInside( rPos ) ) + // The point is inside the ValueSet window, + // let's find the containing item. + const size_t nItemCount = mpImpl->mpItemList->size(); + for ( size_t i = 0; i < nItemCount; ++i ) { - if ( aWinRect.IsInside( rPos ) ) + ValueSetItem *const pItem = (*mpImpl->mpItemList)[ i ]; + if ( pItem->maRect.IsInside( rPos ) ) + { return i; - else - return VALUESET_ITEM_NOTFOUND; + } } - } - // Wenn Spacing gesetzt ist, wird der vorher selektierte - // Eintrag zurueckgegeben, wenn die Maus noch nicht das Fenster - // verlassen hat - if ( bMove && mnSpacing && mnHighItemId ) - { - if ( aWinRect.IsInside( rPos ) ) + // Wenn Spacing gesetzt ist, wird der vorher selektierte + // Eintrag zurueckgegeben, wenn die Maus noch nicht das Fenster + // verlassen hat + if ( bMove && mnSpacing && mnHighItemId ) + { return GetItemPos( mnHighItemId ); + } } return VALUESET_ITEM_NOTFOUND; |