summaryrefslogtreecommitdiffstats
path: root/svtools
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@poste.it>2012-01-02 19:46:49 +0100
committerMatteo Casalin <matteo.casalin@poste.it>2012-01-02 19:49:05 +0100
commitca343939c03551957433708836517eb37b62e523 (patch)
tree9661fde2df30e4e5920d25537e71e692b8110afe /svtools
parentDo not repeat the same test twice (diff)
downloadcore-ca343939c03551957433708836517eb37b62e523.tar.gz
core-ca343939c03551957433708836517eb37b62e523.zip
Group a common test to avoid unnecessary calculations
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/valueset.cxx37
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;