[Libreoffice-commits] .: 2 commits - svtools/source
Matteo Casalin
mcasalin at kemper.freedesktop.org
Mon Jan 2 10:49:51 PST 2012
svtools/source/control/valueset.cxx | 49 +++++++++++++++---------------------
1 file changed, 21 insertions(+), 28 deletions(-)
New commits:
commit ca343939c03551957433708836517eb37b62e523
Author: Matteo Casalin <matteo.casalin at poste.it>
Date: Mon Jan 2 19:46:49 2012 +0100
Group a common test to avoid unnecessary calculations
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 97ecc03..84f472f 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;
commit fe36838f9db5fef3c281b677c64b4db0519c9d4d
Author: Matteo Casalin <matteo.casalin at poste.it>
Date: Mon Dec 26 10:38:25 2011 +0100
Do not repeat the same test twice
diff --git a/svtools/source/control/valueset.cxx b/svtools/source/control/valueset.cxx
index 576a091..97ecc03 100644
--- a/svtools/source/control/valueset.cxx
+++ b/svtools/source/control/valueset.cxx
@@ -700,16 +700,10 @@ void ValueSet::ImplDrawSelect()
if ( !IsReallyVisible() )
return;
- sal_Bool bFocus = HasFocus();
- sal_Bool bDrawSel;
+ const bool bFocus = HasFocus();
+ const bool bDrawSel = !( (mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight) );
- if ( (mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight) )
- bDrawSel = sal_False;
- else
- bDrawSel = sal_True;
-
- if ( !bFocus &&
- ((mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight)) )
+ if ( !bFocus && !bDrawSel )
{
XubString aEmptyStr;
ImplDrawItemText( aEmptyStr );
More information about the Libreoffice-commits
mailing list