LCOV - code coverage report
Current view: top level - svtools/source/control - valueset.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 480 1203 39.9 %
Date: 2012-08-25 Functions: 41 85 48.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 355 1368 26.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <tools/debug.hxx>
      30                 :            : #include <vcl/decoview.hxx>
      31                 :            : #include <vcl/svapp.hxx>
      32                 :            : #include <vcl/scrbar.hxx>
      33                 :            : #include <vcl/help.hxx>
      34                 :            : #include <com/sun/star/accessibility/AccessibleEventObject.hpp>
      35                 :            : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      36                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      37                 :            : #include <com/sun/star/lang/XComponent.hpp>
      38                 :            : #include <rtl/ustring.hxx>
      39                 :            : 
      40                 :            : #include "valueimp.hxx"
      41                 :            : 
      42                 :            : #define _SV_VALUESET_CXX
      43                 :            : #include <svtools/valueset.hxx>
      44                 :            : 
      45                 :            : namespace
      46                 :            : {
      47                 :            : 
      48                 :            : enum {
      49                 :            :     ITEM_OFFSET = 4,
      50                 :            :     ITEM_OFFSET_DOUBLE = 6,
      51                 :            :     NAME_LINE_OFF_X = 2,
      52                 :            :     NAME_LINE_OFF_Y = 2,
      53                 :            :     NAME_LINE_HEIGHT = 2,
      54                 :            :     NAME_OFFSET = 2,
      55                 :            :     SCRBAR_OFFSET = 1,
      56                 :            :     SCROLL_OFFSET = 4
      57                 :            : };
      58                 :            : 
      59                 :            : }
      60                 :            : 
      61                 :            : // ------------
      62                 :            : // - ValueSet -
      63                 :            : // ------------
      64                 :            : 
      65                 :         32 : void ValueSet::ImplInit()
      66                 :            : {
      67                 :         32 :     mpNoneItem          = NULL;
      68                 :         32 :     mpScrBar            = NULL;
      69                 :         32 :     mnItemWidth         = 0;
      70                 :         32 :     mnItemHeight        = 0;
      71                 :         32 :     mnTextOffset        = 0;
      72                 :         32 :     mnVisLines          = 0;
      73                 :         32 :     mnLines             = 0;
      74                 :         32 :     mnUserItemWidth     = 0;
      75                 :         32 :     mnUserItemHeight    = 0;
      76                 :         32 :     mnFirstLine         = 0;
      77                 :         32 :     mnSelItemId         = 0;
      78                 :         32 :     mnHighItemId        = 0;
      79                 :         32 :     mnCols              = 0;
      80                 :         32 :     mnCurCol            = 0;
      81                 :         32 :     mnUserCols          = 0;
      82                 :         32 :     mnUserVisLines      = 0;
      83                 :         32 :     mnSpacing           = 0;
      84                 :         32 :     mnFrameStyle        = 0;
      85                 :         32 :     mbFormat            = true;
      86                 :         32 :     mbHighlight         = false;
      87                 :         32 :     mbSelection         = false;
      88                 :         32 :     mbNoSelection       = true;
      89                 :         32 :     mbDrawSelection     = true;
      90                 :         32 :     mbBlackSel          = false;
      91                 :         32 :     mbDoubleSel         = false;
      92                 :         32 :     mbScroll            = false;
      93                 :         32 :     mbFullMode          = true;
      94                 :         32 :     mbHasVisibleItems   = false;
      95                 :            : 
      96                 :            :     // #106446#, #106601# force mirroring of virtual device
      97                 :         32 :     maVirDev.EnableRTL( GetParent()->IsRTLEnabled() );
      98                 :            : 
      99                 :         32 :     ImplInitSettings( true, true, true );
     100                 :         32 : }
     101                 :            : 
     102                 :            : // -----------------------------------------------------------------------
     103                 :            : 
     104                 :         15 : ValueSet::ValueSet( Window* pParent, WinBits nWinStyle, bool bDisableTransientChildren ) :
     105                 :            :     Control( pParent, nWinStyle ),
     106                 :            :     maVirDev( *this ),
     107 [ +  - ][ +  - ]:         15 :     maColor( COL_TRANSPARENT )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     108                 :            : {
     109         [ +  - ]:         15 :     ImplInit();
     110                 :         15 :     mbIsTransientChildrenDisabled = bDisableTransientChildren;
     111                 :         15 : }
     112                 :            : 
     113                 :            : // -----------------------------------------------------------------------
     114                 :            : 
     115                 :         17 : ValueSet::ValueSet( Window* pParent, const ResId& rResId, bool bDisableTransientChildren ) :
     116                 :            :     Control( pParent, rResId ),
     117                 :            :     maVirDev( *this ),
     118 [ +  - ][ +  - ]:         17 :     maColor( COL_TRANSPARENT )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     119                 :            : {
     120         [ +  - ]:         17 :     ImplInit();
     121                 :         17 :     mbIsTransientChildrenDisabled = bDisableTransientChildren;
     122                 :         17 : }
     123                 :            : 
     124                 :            : // -----------------------------------------------------------------------
     125                 :            : 
     126 [ +  - ][ +  - ]:         32 : ValueSet::~ValueSet()
     127                 :            : {
     128                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>
     129 [ +  - ][ +  - ]:         32 :           xComponent (GetAccessible(sal_False), ::com::sun::star::uno::UNO_QUERY);
     130         [ -  + ]:         32 :     if (xComponent.is())
     131 [ #  # ][ #  # ]:          0 :         xComponent->dispose ();
     132                 :            : 
     133 [ +  + ][ +  - ]:         32 :     delete mpScrBar;
     134 [ -  + ][ #  # ]:         32 :     delete mpNoneItem;
     135                 :            : 
     136         [ +  - ]:         32 :     ImplDeleteItems();
     137         [ -  + ]:         49 : }
     138                 :            : 
     139                 :            : // -----------------------------------------------------------------------
     140                 :            : 
     141                 :         97 : void ValueSet::ImplDeleteItems()
     142                 :            : {
     143                 :         97 :     const size_t n = mItemList.size();
     144                 :            : 
     145         [ +  + ]:        680 :     for ( size_t i = 0; i < n; ++i )
     146                 :            :     {
     147                 :        583 :         ValueSetItem *const pItem = mItemList[i];
     148 [ -  + ][ -  + ]:        583 :         if ( pItem->mbVisible && ImplHasAccessibleListeners() )
                 [ +  - ]
     149                 :            :         {
     150                 :          0 :             ::com::sun::star::uno::Any aOldAny, aNewAny;
     151                 :            : 
     152 [ #  # ][ #  # ]:          0 :             aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
     153         [ #  # ]:          0 :             ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
     154                 :            :         }
     155                 :            : 
     156         [ +  - ]:        583 :         delete pItem;
     157                 :            :     }
     158                 :            : 
     159                 :         97 :     mItemList.clear();
     160                 :         97 : }
     161                 :            : 
     162                 :            : // -----------------------------------------------------------------------
     163                 :            : 
     164                 :         77 : void ValueSet::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
     165                 :            : {
     166                 :         77 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     167                 :            : 
     168         [ +  + ]:         77 :     if ( bFont )
     169                 :            :     {
     170         [ +  - ]:         32 :         Font aFont;
     171         [ +  - ]:         32 :         aFont = rStyleSettings.GetAppFont();
     172 [ +  - ][ -  + ]:         32 :         if ( IsControlFont() )
     173 [ #  # ][ #  # ]:          0 :             aFont.Merge( GetControlFont() );
                 [ #  # ]
     174 [ +  - ][ +  - ]:         32 :         SetZoomedPointFont( aFont );
     175                 :            :     }
     176                 :            : 
     177 [ +  + ][ -  + ]:         77 :     if ( bForeground || bFont )
     178                 :            :     {
     179                 :         32 :         Color aColor;
     180 [ -  + ][ +  - ]:         32 :         if ( IsControlForeground() )
     181         [ #  # ]:          0 :             aColor = GetControlForeground();
     182                 :            :         else
     183                 :         32 :             aColor = rStyleSettings.GetButtonTextColor();
     184         [ +  - ]:         32 :         SetTextColor( aColor );
     185         [ +  - ]:         32 :         SetTextFillColor();
     186                 :            :     }
     187                 :            : 
     188         [ +  - ]:         77 :     if ( bBackground )
     189                 :            :     {
     190                 :         77 :         Color aColor;
     191 [ -  + ][ +  - ]:         77 :         if ( IsControlBackground() )
     192         [ #  # ]:          0 :             aColor = GetControlBackground();
     193 [ +  - ][ -  + ]:         77 :         else if ( GetStyle() & WB_MENUSTYLEVALUESET )
     194                 :          0 :             aColor = rStyleSettings.GetMenuColor();
     195 [ +  - ][ +  + ]:         77 :         else if ( IsEnabled() && (GetStyle() & WB_FLATVALUESET) )
         [ +  - ][ +  + ]
                 [ +  + ]
     196                 :         28 :             aColor = rStyleSettings.GetWindowColor();
     197                 :            :         else
     198                 :         49 :             aColor = rStyleSettings.GetFaceColor();
     199 [ +  - ][ +  - ]:         77 :         SetBackground( aColor );
                 [ +  - ]
     200                 :            :     }
     201                 :         77 : }
     202                 :            : 
     203                 :            : // -----------------------------------------------------------------------
     204                 :            : 
     205                 :          9 : void ValueSet::ImplInitScrollBar()
     206                 :            : {
     207         [ +  - ]:          9 :     if ( GetStyle() & WB_VSCROLL )
     208                 :            :     {
     209         [ +  - ]:          9 :         if ( !mpScrBar )
     210                 :            :         {
     211         [ +  - ]:          9 :             mpScrBar = new ScrollBar( this, WB_VSCROLL | WB_DRAG );
     212                 :          9 :             mpScrBar->SetScrollHdl( LINK( this, ValueSet, ImplScrollHdl ) );
     213                 :            :         }
     214                 :            :         else
     215                 :            :         {
     216                 :            :             // adapt the width because of the changed settings
     217                 :          0 :             long nScrBarWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
     218                 :          0 :             mpScrBar->SetPosSizePixel( 0, 0, nScrBarWidth, 0, WINDOW_POSSIZE_WIDTH );
     219                 :            :         }
     220                 :            :     }
     221                 :          9 : }
     222                 :            : 
     223                 :            : // -----------------------------------------------------------------------
     224                 :            : 
     225                 :        636 : void ValueSet::ImplFormatItem( ValueSetItem* pItem, Rectangle aRect )
     226                 :            : {
     227                 :        636 :     WinBits nStyle = GetStyle();
     228         [ -  + ]:        636 :     if ( nStyle & WB_ITEMBORDER )
     229                 :            :     {
     230                 :          0 :         aRect.Left()++;
     231                 :          0 :         aRect.Top()++;
     232                 :          0 :         aRect.Right()--;
     233                 :          0 :         aRect.Bottom()--;
     234         [ #  # ]:          0 :         if ( nStyle & WB_FLATVALUESET )
     235                 :            :         {
     236         [ #  # ]:          0 :             if ( nStyle  & WB_DOUBLEBORDER )
     237                 :            :             {
     238                 :          0 :                 aRect.Left()    += 2;
     239                 :          0 :                 aRect.Top()     += 2;
     240                 :          0 :                 aRect.Right()   -= 2;
     241                 :          0 :                 aRect.Bottom()  -= 2;
     242                 :            :             }
     243                 :            :             else
     244                 :            :             {
     245                 :          0 :                 aRect.Left()++;
     246                 :          0 :                 aRect.Top()++;
     247                 :          0 :                 aRect.Right()--;
     248                 :          0 :                 aRect.Bottom()--;
     249                 :            :             }
     250                 :            :         }
     251                 :            :         else
     252                 :            :         {
     253                 :          0 :             DecorationView aView( &maVirDev );
     254         [ #  # ]:          0 :             aRect = aView.DrawFrame( aRect, mnFrameStyle );
     255                 :            :         }
     256                 :            :     }
     257                 :            : 
     258         [ -  + ]:        636 :     if ( pItem == mpNoneItem )
     259         [ #  # ]:          0 :         pItem->maText = GetText();
     260                 :            : 
     261 [ +  - ][ +  - ]:        636 :     if ( (aRect.GetHeight() > 0) && (aRect.GetWidth() > 0) )
                 [ +  - ]
     262                 :            :     {
     263         [ -  + ]:        636 :         if ( pItem == mpNoneItem )
     264                 :            :         {
     265                 :          0 :             const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     266         [ #  # ]:          0 :             maVirDev.SetFont( GetFont() );
     267 [ #  # ][ #  # ]:          0 :             maVirDev.SetTextColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuTextColor() : rStyleSettings.GetWindowTextColor() );
     268         [ #  # ]:          0 :             maVirDev.SetTextFillColor();
     269 [ #  # ][ #  # ]:          0 :             maVirDev.SetFillColor( ( nStyle & WB_MENUSTYLEVALUESET ) ? rStyleSettings.GetMenuColor() : rStyleSettings.GetWindowColor() );
     270         [ #  # ]:          0 :             maVirDev.DrawRect( aRect );
     271                 :          0 :             Point   aTxtPos( aRect.Left()+2, aRect.Top() );
     272         [ #  # ]:          0 :             long    nTxtWidth = GetTextWidth( pItem->maText );
     273         [ #  # ]:          0 :             if ( nStyle & WB_RADIOSEL )
     274                 :            :             {
     275                 :          0 :                 aTxtPos.X() += 4;
     276                 :          0 :                 aTxtPos.Y() += 4;
     277                 :            :             }
     278         [ #  # ]:          0 :             if ( (aTxtPos.X()+nTxtWidth) > aRect.Right() )
     279                 :            :             {
     280 [ #  # ][ #  # ]:          0 :                 maVirDev.SetClipRegion( Region( aRect ) );
                 [ #  # ]
     281         [ #  # ]:          0 :                 maVirDev.DrawText( aTxtPos, pItem->maText );
     282         [ #  # ]:          0 :                 maVirDev.SetClipRegion();
     283                 :            :             }
     284                 :            :             else
     285         [ #  # ]:          0 :                 maVirDev.DrawText( aTxtPos, pItem->maText );
     286                 :            :         }
     287         [ -  + ]:        636 :         else if ( pItem->meType == VALUESETITEM_COLOR )
     288                 :            :         {
     289                 :          0 :             maVirDev.SetFillColor( pItem->maColor );
     290                 :          0 :             maVirDev.DrawRect( aRect );
     291                 :            :         }
     292                 :            :         else
     293                 :            :         {
     294                 :        636 :             const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     295         [ +  + ]:        636 :             if ( IsColor() )
     296                 :        396 :                 maVirDev.SetFillColor( maColor );
     297         [ -  + ]:        240 :             else if ( nStyle & WB_MENUSTYLEVALUESET )
     298                 :          0 :                 maVirDev.SetFillColor( rStyleSettings.GetMenuColor() );
     299         [ +  - ]:        240 :             else if ( IsEnabled() )
     300                 :        240 :                 maVirDev.SetFillColor( rStyleSettings.GetWindowColor() );
     301                 :            :             else
     302                 :          0 :                 maVirDev.SetFillColor( rStyleSettings.GetFaceColor() );
     303                 :        636 :             maVirDev.DrawRect( aRect );
     304                 :            : 
     305         [ -  + ]:        636 :             if ( pItem->meType == VALUESETITEM_USERDRAW )
     306                 :            :             {
     307         [ #  # ]:          0 :                 UserDrawEvent aUDEvt( &maVirDev, aRect, pItem->mnId );
     308         [ #  # ]:          0 :                 UserDraw( aUDEvt );
     309                 :            :             }
     310                 :            :             else
     311                 :            :             {
     312         [ +  - ]:        636 :                 Size    aImageSize = pItem->maImage.GetSizePixel();
     313         [ +  - ]:        636 :                 Size    aRectSize = aRect.GetSize();
     314                 :        636 :                 Point   aPos( aRect.Left(), aRect.Top() );
     315                 :        636 :                 aPos.X() += (aRectSize.Width()-aImageSize.Width())/2;
     316                 :        636 :                 aPos.Y() += (aRectSize.Height()-aImageSize.Height())/2;
     317                 :            : 
     318                 :        636 :                 sal_uInt16  nImageStyle  = 0;
     319 [ -  + ][ +  - ]:        636 :                 if( !IsEnabled() )
     320                 :          0 :                     nImageStyle  |= IMAGE_DRAW_DISABLE;
     321                 :            : 
     322   [ +  -  -  + ]:       1272 :                 if ( (aImageSize.Width()  > aRectSize.Width()) ||
                 [ -  + ]
     323                 :        636 :                      (aImageSize.Height() > aRectSize.Height()) )
     324                 :            :                 {
     325 [ #  # ][ #  # ]:          0 :                     maVirDev.SetClipRegion( Region( aRect ) );
                 [ #  # ]
     326         [ #  # ]:          0 :                     maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle);
     327         [ #  # ]:          0 :                     maVirDev.SetClipRegion();
     328                 :            :                 }
     329                 :            :                 else
     330         [ +  - ]:        636 :                     maVirDev.DrawImage( aPos, pItem->maImage, nImageStyle );
     331                 :            :             }
     332                 :            :         }
     333                 :            :     }
     334                 :        636 : }
     335                 :            : 
     336                 :            : // -----------------------------------------------------------------------
     337                 :            : 
     338                 :          0 : ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ValueSet::CreateAccessible()
     339                 :            : {
     340 [ #  # ][ #  # ]:          0 :     return new ValueSetAcc( this, mbIsTransientChildrenDisabled );
     341                 :            : }
     342                 :            : 
     343                 :            : // -----------------------------------------------------------------------
     344                 :            : 
     345                 :         83 : void ValueSet::Format()
     346                 :            : {
     347                 :         83 :     Size        aWinSize = GetOutputSizePixel();
     348                 :         83 :     size_t      nItemCount = mItemList.size();
     349         [ +  - ]:         83 :     WinBits     nStyle = GetStyle();
     350         [ +  - ]:         83 :     long        nTxtHeight = GetTextHeight();
     351                 :            :     long        nOff;
     352                 :            :     long        nNoneHeight;
     353                 :            :     long        nNoneSpace;
     354                 :         83 :     ScrollBar*  pDelScrBar = NULL;
     355                 :            : 
     356                 :            :     // consider the scrolling
     357         [ +  + ]:         83 :     if ( nStyle & WB_VSCROLL )
     358         [ +  - ]:          9 :         ImplInitScrollBar();
     359                 :            :     else
     360                 :            :     {
     361         [ -  + ]:         74 :         if ( mpScrBar )
     362                 :            :         {
     363                 :            :             // delete ScrollBar not until later, to prevent recursive calls
     364                 :          0 :             pDelScrBar = mpScrBar;
     365                 :          0 :             mpScrBar = NULL;
     366                 :            :         }
     367                 :            :     }
     368                 :            : 
     369                 :            :     // calculate item offset
     370         [ -  + ]:         83 :     if ( nStyle & WB_ITEMBORDER )
     371                 :            :     {
     372         [ #  # ]:          0 :         if ( nStyle & WB_DOUBLEBORDER )
     373                 :          0 :             nOff = ITEM_OFFSET_DOUBLE;
     374                 :            :         else
     375                 :          0 :             nOff = ITEM_OFFSET;
     376                 :            :     }
     377                 :            :     else
     378                 :         83 :         nOff = 0;
     379                 :            : 
     380                 :            :     // consider size, if NameField does exist
     381         [ -  + ]:         83 :     if ( nStyle & WB_NAMEFIELD )
     382                 :            :     {
     383                 :          0 :         mnTextOffset = aWinSize.Height()-nTxtHeight-NAME_OFFSET;
     384                 :          0 :         aWinSize.Height() -= nTxtHeight+NAME_OFFSET;
     385                 :            : 
     386         [ #  # ]:          0 :         if ( !(nStyle & WB_FLATVALUESET) )
     387                 :            :         {
     388                 :          0 :             mnTextOffset -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
     389                 :          0 :             aWinSize.Height() -= NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
     390                 :            :         }
     391                 :            :     }
     392                 :            :     else
     393                 :         83 :         mnTextOffset = 0;
     394                 :            : 
     395                 :            :     // consider offset and size, if NoneField does exist
     396         [ -  + ]:         83 :     if ( nStyle & WB_NONEFIELD )
     397                 :            :     {
     398                 :          0 :         nNoneHeight = nTxtHeight+nOff;
     399                 :          0 :         nNoneSpace = mnSpacing;
     400         [ #  # ]:          0 :         if ( nStyle & WB_RADIOSEL )
     401                 :          0 :             nNoneHeight += 8;
     402                 :            :     }
     403                 :            :     else
     404                 :            :     {
     405                 :         83 :         nNoneHeight = 0;
     406                 :         83 :         nNoneSpace = 0;
     407                 :            : 
     408         [ -  + ]:         83 :         if ( mpNoneItem )
     409                 :            :         {
     410 [ #  # ][ #  # ]:          0 :             delete mpNoneItem;
     411                 :          0 :             mpNoneItem = NULL;
     412                 :            :         }
     413                 :            :     }
     414                 :            : 
     415                 :            :     // calculate ScrollBar width
     416                 :         83 :     long nScrBarWidth = 0;
     417         [ +  + ]:         83 :     if ( mpScrBar )
     418         [ +  - ]:          9 :         nScrBarWidth = mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET;
     419                 :            : 
     420                 :            :     // calculate number of columns
     421         [ +  + ]:         83 :     if ( !mnUserCols )
     422                 :            :     {
     423         [ -  + ]:         27 :         if ( mnUserItemWidth )
     424                 :            :         {
     425                 :          0 :             mnCols = (sal_uInt16)((aWinSize.Width()-nScrBarWidth+mnSpacing) / (mnUserItemWidth+mnSpacing));
     426         [ #  # ]:          0 :             if ( !mnCols )
     427                 :          0 :                 mnCols = 1;
     428                 :            :         }
     429                 :            :         else
     430                 :         27 :             mnCols = 1;
     431                 :            :     }
     432                 :            :     else
     433                 :         56 :         mnCols = mnUserCols;
     434                 :            : 
     435                 :            :     // calculate number of rows
     436                 :         83 :     mbScroll = false;
     437                 :            :     // Floor( (M+N-1)/N )==Ceiling( M/N )
     438                 :         83 :     mnLines = (static_cast<long>(nItemCount)+mnCols-1) / mnCols;
     439         [ +  + ]:         83 :     if ( !mnLines )
     440                 :         12 :         mnLines = 1;
     441                 :            : 
     442                 :         83 :     long nCalcHeight = aWinSize.Height()-nNoneHeight;
     443         [ +  + ]:         83 :     if ( mnUserVisLines )
     444                 :         56 :         mnVisLines = mnUserVisLines;
     445         [ -  + ]:         27 :     else if ( mnUserItemHeight )
     446                 :            :     {
     447                 :          0 :         mnVisLines = (nCalcHeight-nNoneSpace+mnSpacing) / (mnUserItemHeight+mnSpacing);
     448         [ #  # ]:          0 :         if ( !mnVisLines )
     449                 :          0 :             mnVisLines = 1;
     450                 :            :     }
     451                 :            :     else
     452                 :         27 :         mnVisLines = mnLines;
     453         [ -  + ]:         83 :     if ( mnLines > mnVisLines )
     454                 :          0 :         mbScroll = true;
     455         [ +  - ]:         83 :     if ( mnLines <= mnVisLines )
     456                 :         83 :         mnFirstLine = 0;
     457                 :            :     else
     458                 :            :     {
     459         [ #  # ]:          0 :         if ( mnFirstLine > (sal_uInt16)(mnLines-mnVisLines) )
     460                 :          0 :             mnFirstLine = (sal_uInt16)(mnLines-mnVisLines);
     461                 :            :     }
     462                 :            : 
     463                 :            :     // calculate item size
     464                 :         83 :     const long nColSpace  = (mnCols-1)*mnSpacing;
     465                 :         83 :     const long nLineSpace = ((mnVisLines-1)*mnSpacing)+nNoneSpace;
     466 [ +  + ][ -  + ]:         83 :     if ( mnUserItemWidth && !mnUserCols )
     467                 :            :     {
     468                 :          0 :         mnItemWidth = mnUserItemWidth;
     469         [ #  # ]:          0 :         if ( mnItemWidth > aWinSize.Width()-nScrBarWidth-nColSpace )
     470                 :          0 :             mnItemWidth = aWinSize.Width()-nScrBarWidth-nColSpace;
     471                 :            :     }
     472                 :            :     else
     473                 :         83 :         mnItemWidth = (aWinSize.Width()-nScrBarWidth-nColSpace) / mnCols;
     474 [ +  + ][ -  + ]:         83 :     if ( mnUserItemHeight && !mnUserVisLines )
     475                 :            :     {
     476                 :          0 :         mnItemHeight = mnUserItemHeight;
     477         [ #  # ]:          0 :         if ( mnItemHeight > nCalcHeight-nNoneSpace )
     478                 :          0 :             mnItemHeight = nCalcHeight-nNoneSpace;
     479                 :            :     }
     480                 :            :     else
     481                 :            :     {
     482                 :         83 :         nCalcHeight -= nLineSpace;
     483                 :         83 :         mnItemHeight = nCalcHeight / mnVisLines;
     484                 :            :     }
     485                 :            : 
     486                 :            :     // Init VirDev
     487         [ +  - ]:         83 :     maVirDev.SetSettings( GetSettings() );
     488         [ +  - ]:         83 :     maVirDev.SetBackground( GetBackground() );
     489         [ +  - ]:         83 :     maVirDev.SetOutputSizePixel( aWinSize, sal_True );
     490                 :            : 
     491                 :            :     // nothing is changed in case of too small items
     492 [ +  + ][ -  + ]:         83 :     if ( (mnItemWidth <= 0) ||
         [ +  - ][ +  + ]
     493                 :            :          (mnItemHeight <= (( nStyle & WB_ITEMBORDER ) ? 4 : 2)) ||
     494                 :            :          !nItemCount )
     495                 :            :     {
     496                 :         27 :         mbHasVisibleItems = false;
     497                 :            : 
     498         [ -  + ]:         27 :         if ( nStyle & WB_NONEFIELD )
     499                 :            :         {
     500         [ #  # ]:          0 :             if ( mpNoneItem )
     501                 :            :             {
     502                 :          0 :                 mpNoneItem->mbVisible = false;
     503 [ #  # ][ #  # ]:          0 :                 mpNoneItem->maText = GetText();
                 [ #  # ]
     504                 :            :             }
     505                 :            :         }
     506                 :            : 
     507         [ +  + ]:        207 :         for ( size_t i = 0; i < nItemCount; i++ )
     508                 :            :         {
     509                 :        180 :             mItemList[i]->mbVisible = false;
     510                 :            :         }
     511                 :            : 
     512         [ -  + ]:         27 :         if ( mpScrBar )
     513         [ #  # ]:         27 :             mpScrBar->Hide();
     514                 :            :     }
     515                 :            :     else
     516                 :            :     {
     517                 :         56 :         mbHasVisibleItems = true;
     518                 :            : 
     519                 :            :         // determine Frame-Style
     520         [ -  + ]:         56 :         if ( nStyle & WB_DOUBLEBORDER )
     521                 :          0 :             mnFrameStyle = FRAME_DRAW_DOUBLEIN;
     522                 :            :         else
     523                 :         56 :             mnFrameStyle = FRAME_DRAW_IN;
     524                 :            : 
     525                 :            :         // determine selected color and width
     526                 :            :         // if necessary change the colors, to make the selection
     527                 :            :         // better detectable
     528                 :         56 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     529                 :         56 :         Color aHighColor( rStyleSettings.GetHighlightColor() );
     530   [ +  -  +  -  :        168 :         if ( ((aHighColor.GetRed() > 0x80) || (aHighColor.GetGreen() > 0x80) ||
          -  +  #  #  #  
              # ][ -  + ]
                 [ +  - ]
     531                 :         56 :               (aHighColor.GetBlue() > 0x80)) ||
     532                 :         56 :              ((aHighColor.GetRed() == 0x80) && (aHighColor.GetGreen() == 0x80) &&
     533                 :          0 :               (aHighColor.GetBlue() == 0x80)) )
     534                 :          0 :             mbBlackSel = true;
     535                 :            :         else
     536                 :         56 :             mbBlackSel = false;
     537                 :            : 
     538                 :            :         // draw the selection with double width if the items are bigger
     539 [ -  + ][ #  # ]:         56 :         if ( (nStyle & WB_DOUBLEBORDER) &&
                 [ #  # ]
     540                 :            :              ((mnItemWidth >= 25) && (mnItemHeight >= 20)) )
     541                 :          0 :             mbDoubleSel = true;
     542                 :            :         else
     543                 :         56 :             mbDoubleSel = false;
     544                 :            : 
     545                 :            :         // calculate offsets
     546                 :            :         long nStartX;
     547                 :            :         long nStartY;
     548         [ +  - ]:         56 :         if ( mbFullMode )
     549                 :            :         {
     550                 :         56 :             long nAllItemWidth = (mnItemWidth*mnCols)+nColSpace;
     551                 :         56 :             long nAllItemHeight = (mnItemHeight*mnVisLines)+nNoneHeight+nLineSpace;
     552                 :         56 :             nStartX = (aWinSize.Width()-nScrBarWidth-nAllItemWidth)/2;
     553                 :         56 :             nStartY = (aWinSize.Height()-nAllItemHeight)/2;
     554                 :            :         }
     555                 :            :         else
     556                 :            :         {
     557                 :          0 :             nStartX = 0;
     558                 :          0 :             nStartY = 0;
     559                 :            :         }
     560                 :            : 
     561                 :            :         // calculate and draw items
     562         [ +  - ]:         56 :         maVirDev.SetLineColor();
     563                 :         56 :         long x = nStartX;
     564                 :         56 :         long y = nStartY;
     565                 :            : 
     566                 :            :         // create NoSelection field and show it
     567         [ -  + ]:         56 :         if ( nStyle & WB_NONEFIELD )
     568                 :            :         {
     569         [ #  # ]:          0 :             if ( !mpNoneItem )
     570 [ #  # ][ #  # ]:          0 :                 mpNoneItem = new ValueSetItem( *this );
     571                 :            : 
     572                 :          0 :             mpNoneItem->mnId            = 0;
     573                 :          0 :             mpNoneItem->meType          = VALUESETITEM_NONE;
     574                 :          0 :             mpNoneItem->mbVisible       = true;
     575                 :          0 :             maNoneItemRect.Left()       = x;
     576                 :          0 :             maNoneItemRect.Top()        = y;
     577                 :          0 :             maNoneItemRect.Right()      = maNoneItemRect.Left()+aWinSize.Width()-x-1;
     578                 :          0 :             maNoneItemRect.Bottom()     = y+nNoneHeight-1;
     579                 :            : 
     580         [ #  # ]:          0 :             ImplFormatItem( mpNoneItem, maNoneItemRect );
     581                 :            : 
     582                 :          0 :             y += nNoneHeight+nNoneSpace;
     583                 :            :         }
     584                 :            : 
     585                 :            :         // draw items
     586                 :         56 :         sal_uLong nFirstItem = mnFirstLine * mnCols;
     587                 :         56 :         sal_uLong nLastItem = nFirstItem + (mnVisLines * mnCols);
     588                 :            : 
     589                 :         56 :         maItemListRect.Left() = x;
     590                 :         56 :         maItemListRect.Top() = y;
     591                 :         56 :         maItemListRect.Right() = x + mnCols*(mnItemWidth+mnSpacing) - mnSpacing - 1;
     592                 :         56 :         maItemListRect.Bottom() = y + mnVisLines*(mnItemHeight+mnSpacing) - mnSpacing - 1;
     593                 :            : 
     594         [ -  + ]:         56 :         if ( !mbFullMode )
     595                 :            :         {
     596                 :            :             // If want also draw parts of items in the last line,
     597                 :            :             // then we add one more line if parts of these line are
     598                 :            :             // visible
     599         [ #  # ]:          0 :             if ( y+(mnVisLines*(mnItemHeight+mnSpacing)) < aWinSize.Height() )
     600                 :          0 :                 nLastItem += mnCols;
     601                 :          0 :             maItemListRect.Bottom() = aWinSize.Height() - y;
     602                 :            :         }
     603         [ +  + ]:        692 :         for ( size_t i = 0; i < nItemCount; i++ )
     604                 :            :         {
     605                 :        636 :             ValueSetItem *const pItem = mItemList[i];
     606                 :            : 
     607 [ +  - ][ +  - ]:        636 :             if ( (i >= nFirstItem) && (i < nLastItem) )
     608                 :            :             {
     609 [ +  + ][ +  - ]:        636 :                 if( !pItem->mbVisible && ImplHasAccessibleListeners() )
         [ -  + ][ -  + ]
     610                 :            :                 {
     611                 :          0 :                     ::com::sun::star::uno::Any aOldAny, aNewAny;
     612                 :            : 
     613 [ #  # ][ #  # ]:          0 :                     aNewAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
     614         [ #  # ]:          0 :                     ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
     615                 :            :                 }
     616                 :            : 
     617                 :        636 :                 pItem->mbVisible = true;
     618 [ +  - ][ +  - ]:        636 :                 ImplFormatItem( pItem, Rectangle( Point(x,y), Size(mnItemWidth, mnItemHeight) ) );
     619                 :            : 
     620         [ +  + ]:        636 :                 if ( !((i+1) % mnCols) )
     621                 :            :                 {
     622                 :        232 :                     x = nStartX;
     623                 :        232 :                     y += mnItemHeight+mnSpacing;
     624                 :            :                 }
     625                 :            :                 else
     626                 :        636 :                     x += mnItemWidth+mnSpacing;
     627                 :            :             }
     628                 :            :             else
     629                 :            :             {
     630 [ #  # ][ #  # ]:          0 :                 if( pItem->mbVisible && ImplHasAccessibleListeners() )
         [ #  # ][ #  # ]
     631                 :            :                 {
     632                 :          0 :                     ::com::sun::star::uno::Any aOldAny, aNewAny;
     633                 :            : 
     634 [ #  # ][ #  # ]:          0 :                     aOldAny <<= pItem->GetAccessible( mbIsTransientChildrenDisabled );
     635         [ #  # ]:          0 :                     ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
     636                 :            :                 }
     637                 :            : 
     638                 :          0 :                 pItem->mbVisible = false;
     639                 :            :             }
     640                 :            :         }
     641                 :            : 
     642                 :            :         // arrange ScrollBar, set values and show it
     643         [ +  + ]:         56 :         if ( mpScrBar )
     644                 :            :         {
     645                 :          9 :             Point   aPos( aWinSize.Width()-nScrBarWidth+SCRBAR_OFFSET, 0 );
     646                 :          9 :             Size    aSize( nScrBarWidth-SCRBAR_OFFSET, aWinSize.Height() );
     647                 :            :             // If a none field is visible, then we center the scrollbar
     648         [ -  + ]:          9 :             if ( nStyle & WB_NONEFIELD )
     649                 :            :             {
     650                 :          0 :                 aPos.Y() = nStartY+nNoneHeight+1;
     651                 :          0 :                 aSize.Height() = ((mnItemHeight+mnSpacing)*mnVisLines)-2-mnSpacing;
     652                 :            :             }
     653         [ +  - ]:          9 :             mpScrBar->SetPosSizePixel( aPos, aSize );
     654         [ +  - ]:          9 :             mpScrBar->SetRangeMax( mnLines );
     655         [ +  - ]:          9 :             mpScrBar->SetVisibleSize( mnVisLines );
     656         [ +  - ]:          9 :             mpScrBar->SetThumbPos( (long)mnFirstLine );
     657                 :          9 :             long nPageSize = mnVisLines;
     658         [ -  + ]:          9 :             if ( nPageSize < 1 )
     659                 :          0 :                 nPageSize = 1;
     660                 :          9 :             mpScrBar->SetPageSize( nPageSize );
     661         [ +  - ]:         56 :             mpScrBar->Show();
     662                 :            :         }
     663                 :            :     }
     664                 :            : 
     665                 :            :     // waiting for the next since the formatting is finished
     666                 :         83 :     mbFormat = false;
     667                 :            : 
     668                 :            :     // delete ScrollBar
     669 [ -  + ][ #  # ]:         83 :     delete pDelScrBar;
     670                 :         83 : }
     671                 :            : 
     672                 :            : // -----------------------------------------------------------------------
     673                 :            : 
     674                 :         93 : void ValueSet::ImplDrawItemText( const XubString& rText )
     675                 :            : {
     676 [ +  - ][ -  + ]:         93 :     if ( !(GetStyle() & WB_NAMEFIELD) )
     677                 :         93 :         return;
     678                 :            : 
     679                 :          0 :     Size    aWinSize = GetOutputSizePixel();
     680         [ #  # ]:          0 :     long    nTxtWidth = GetTextWidth( rText );
     681                 :          0 :     long    nTxtOffset = mnTextOffset;
     682                 :            : 
     683                 :            :     // delete rectangle and show text
     684 [ #  # ][ #  # ]:          0 :     if ( GetStyle() & WB_FLATVALUESET )
     685                 :            :     {
     686                 :          0 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     687         [ #  # ]:          0 :         SetLineColor();
     688         [ #  # ]:          0 :         SetFillColor( rStyleSettings.GetFaceColor() );
     689 [ #  # ][ #  # ]:          0 :         DrawRect( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
     690         [ #  # ]:          0 :         SetTextColor( rStyleSettings.GetButtonTextColor() );
     691                 :            :     }
     692                 :            :     else
     693                 :            :     {
     694                 :          0 :         nTxtOffset += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
     695 [ #  # ][ #  # ]:          0 :         Erase( Rectangle( Point( 0, nTxtOffset ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
     696                 :            :     }
     697         [ #  # ]:         93 :     DrawText( Point( (aWinSize.Width()-nTxtWidth) / 2, nTxtOffset+(NAME_OFFSET/2) ), rText );
     698                 :            : }
     699                 :            : 
     700                 :            : // -----------------------------------------------------------------------
     701                 :            : 
     702                 :        129 : void ValueSet::ImplDrawSelect()
     703                 :            : {
     704         [ +  + ]:        129 :     if ( !IsReallyVisible() )
     705                 :          7 :         return;
     706                 :            : 
     707                 :        122 :     const bool bFocus = HasFocus();
     708 [ -  + ][ -  + ]:        122 :     const bool bDrawSel = !( (mbNoSelection && !mbHighlight) || (!mbDrawSelection && mbHighlight) );
         [ #  # ][ +  + ]
     709                 :            : 
     710 [ +  + ][ +  + ]:        122 :     if ( !bFocus && !bDrawSel )
     711                 :            :     {
     712         [ +  - ]:         12 :         XubString aEmptyStr;
     713         [ +  - ]:         12 :         ImplDrawItemText( aEmptyStr );
     714         [ +  - ]:         12 :         return;
     715                 :            :     }
     716                 :            : 
     717                 :        110 :     ImplDrawSelect( mnSelItemId, bFocus, bDrawSel );
     718         [ -  + ]:        110 :     if (mbHighlight)
     719                 :            :     {
     720                 :        129 :         ImplDrawSelect( mnHighItemId, bFocus, bDrawSel );
     721                 :            :     }
     722                 :            : }
     723                 :            : 
     724                 :            : // -----------------------------------------------------------------------
     725                 :            : 
     726                 :        110 : void ValueSet::ImplDrawSelect( sal_uInt16 nItemId, const bool bFocus, const bool bDrawSel )
     727                 :            : {
     728                 :            :     ValueSetItem* pItem;
     729         [ +  - ]:        110 :     Rectangle aRect;
     730         [ +  + ]:        110 :     if ( nItemId )
     731                 :            :     {
     732         [ +  - ]:         40 :         const size_t nPos = GetItemPos( nItemId );
     733                 :         40 :         pItem = mItemList[ nPos ];
     734         [ +  - ]:         40 :         aRect = ImplGetItemRect( nPos );
     735                 :            :     }
     736         [ -  + ]:         70 :     else if ( mpNoneItem )
     737                 :            :     {
     738                 :          0 :         pItem = mpNoneItem;
     739                 :          0 :         aRect = maNoneItemRect;
     740                 :            :     }
     741 [ +  + ][ +  - ]:         70 :     else if ( bFocus && (pItem = ImplGetFirstItem()) )
         [ +  - ][ +  + ]
     742                 :            :     {
     743         [ +  - ]:         50 :         aRect = ImplGetItemRect( 0 );
     744                 :            :     }
     745                 :            :     else
     746                 :            :     {
     747                 :        110 :         return;
     748                 :            :     }
     749                 :            : 
     750         [ +  + ]:         90 :     if ( pItem->mbVisible )
     751                 :            :     {
     752                 :            :         // draw selection
     753                 :         81 :         const StyleSettings&    rStyleSettings = GetSettings().GetStyleSettings();
     754         [ +  - ]:         81 :         Control::SetFillColor();
     755                 :            : 
     756                 :         81 :         Color aDoubleColor( rStyleSettings.GetHighlightColor() );
     757                 :         81 :         Color aSingleColor( rStyleSettings.GetHighlightTextColor() );
     758         [ +  - ]:         81 :         if( !mbDoubleSel )
     759                 :            :         {
     760                 :            :             /*
     761                 :            :             *  #99777# contrast enhancement for thin mode
     762                 :            :             */
     763         [ +  - ]:         81 :             const Wallpaper& rWall = GetDisplayBackground();
     764 [ +  - ][ +  - ]:         81 :             if( ! rWall.IsBitmap() && ! rWall.IsGradient() )
         [ +  - ][ +  - ]
                 [ +  - ]
     765                 :            :             {
     766         [ +  - ]:         81 :                 const Color& rBack = rWall.GetColor();
     767 [ +  - ][ -  + ]:         81 :                 if( rBack.IsDark() && ! aDoubleColor.IsBright() )
         [ #  # ][ #  # ]
                 [ -  + ]
     768                 :            :                 {
     769                 :          0 :                     aDoubleColor = Color( COL_WHITE );
     770                 :          0 :                     aSingleColor = Color( COL_BLACK );
     771                 :            :                 }
     772 [ +  - ][ +  + ]:         81 :                 else if( rBack.IsBright() && ! aDoubleColor.IsDark() )
         [ +  - ][ -  + ]
                 [ -  + ]
     773                 :            :                 {
     774                 :          0 :                     aDoubleColor = Color( COL_BLACK );
     775                 :          0 :                     aSingleColor = Color( COL_WHITE );
     776                 :            :                 }
     777                 :            :             }
     778                 :            :         }
     779                 :            : 
     780                 :            :         // specify selection output
     781         [ +  - ]:         81 :         WinBits nStyle = GetStyle();
     782         [ -  + ]:         81 :         if ( nStyle & WB_MENUSTYLEVALUESET )
     783                 :            :         {
     784         [ #  # ]:          0 :             if ( bFocus )
     785         [ #  # ]:          0 :                 ShowFocus( aRect );
     786                 :            : 
     787         [ #  # ]:          0 :             if ( bDrawSel )
     788                 :            :             {
     789 [ #  # ][ #  # ]:          0 :                 SetLineColor( mbBlackSel ? Color( COL_BLACK ) : aDoubleColor );
     790         [ #  # ]:          0 :                 DrawRect( aRect );
     791                 :            :             }
     792                 :            :         }
     793         [ -  + ]:         81 :         else if ( nStyle & WB_RADIOSEL )
     794                 :            :         {
     795                 :          0 :             aRect.Left()    += 3;
     796                 :          0 :             aRect.Top()     += 3;
     797                 :          0 :             aRect.Right()   -= 3;
     798                 :          0 :             aRect.Bottom()  -= 3;
     799         [ #  # ]:          0 :             if ( nStyle & WB_DOUBLEBORDER )
     800                 :            :             {
     801                 :          0 :                 aRect.Left()++;
     802                 :          0 :                 aRect.Top()++;
     803                 :          0 :                 aRect.Right()--;
     804                 :          0 :                 aRect.Bottom()--;
     805                 :            :             }
     806                 :            : 
     807         [ #  # ]:          0 :             if ( bFocus )
     808         [ #  # ]:          0 :                 ShowFocus( aRect );
     809                 :            : 
     810                 :          0 :             aRect.Left()++;
     811                 :          0 :             aRect.Top()++;
     812                 :          0 :             aRect.Right()--;
     813                 :          0 :             aRect.Bottom()--;
     814                 :            : 
     815         [ #  # ]:          0 :             if ( bDrawSel )
     816                 :            :             {
     817         [ #  # ]:          0 :                 SetLineColor( aDoubleColor );
     818                 :          0 :                 aRect.Left()++;
     819                 :          0 :                 aRect.Top()++;
     820                 :          0 :                 aRect.Right()--;
     821                 :          0 :                 aRect.Bottom()--;
     822         [ #  # ]:          0 :                 DrawRect( aRect );
     823                 :          0 :                 aRect.Left()++;
     824                 :          0 :                 aRect.Top()++;
     825                 :          0 :                 aRect.Right()--;
     826                 :          0 :                 aRect.Bottom()--;
     827         [ #  # ]:          0 :                 DrawRect( aRect );
     828                 :            :             }
     829                 :            :         }
     830                 :            :         else
     831                 :            :         {
     832         [ +  - ]:         81 :             if ( bDrawSel )
     833                 :            :             {
     834 [ -  + ][ +  - ]:         81 :                 SetLineColor( mbBlackSel ? Color( COL_BLACK ) : aDoubleColor );
     835         [ +  - ]:         81 :                 DrawRect( aRect );
     836                 :            :             }
     837         [ -  + ]:         81 :             if ( mbDoubleSel )
     838                 :            :             {
     839                 :          0 :                 aRect.Left()++;
     840                 :          0 :                 aRect.Top()++;
     841                 :          0 :                 aRect.Right()--;
     842                 :          0 :                 aRect.Bottom()--;
     843         [ #  # ]:          0 :                 if ( bDrawSel )
     844         [ #  # ]:          0 :                     DrawRect( aRect );
     845                 :            :             }
     846                 :         81 :             aRect.Left()++;
     847                 :         81 :             aRect.Top()++;
     848                 :         81 :             aRect.Right()--;
     849                 :         81 :             aRect.Bottom()--;
     850                 :         81 :             Rectangle aRect2 = aRect;
     851                 :         81 :             aRect.Left()++;
     852                 :         81 :             aRect.Top()++;
     853                 :         81 :             aRect.Right()--;
     854                 :         81 :             aRect.Bottom()--;
     855         [ +  - ]:         81 :             if ( bDrawSel )
     856         [ +  - ]:         81 :                 DrawRect( aRect );
     857         [ -  + ]:         81 :             if ( mbDoubleSel )
     858                 :            :             {
     859                 :          0 :                 aRect.Left()++;
     860                 :          0 :                 aRect.Top()++;
     861                 :          0 :                 aRect.Right()--;
     862                 :          0 :                 aRect.Bottom()--;
     863         [ #  # ]:          0 :                 if ( bDrawSel )
     864         [ #  # ]:          0 :                     DrawRect( aRect );
     865                 :            :             }
     866                 :            : 
     867         [ +  - ]:         81 :             if ( bDrawSel )
     868                 :            :             {
     869 [ -  + ][ +  - ]:         81 :                 SetLineColor( mbBlackSel ? Color( COL_WHITE ) : aSingleColor );
     870                 :            :             }
     871                 :            :             else
     872                 :            :             {
     873         [ #  # ]:          0 :                 SetLineColor( Color( COL_LIGHTGRAY ) );
     874                 :            :             }
     875         [ +  - ]:         81 :             DrawRect( aRect2 );
     876                 :            : 
     877         [ +  + ]:         81 :             if ( bFocus )
     878         [ +  - ]:         81 :                 ShowFocus( aRect2 );
     879                 :            :         }
     880                 :            : 
     881         [ +  - ]:        110 :         ImplDrawItemText( pItem->maText );
     882                 :            :     }
     883                 :            : }
     884                 :            : 
     885                 :            : // -----------------------------------------------------------------------
     886                 :            : 
     887                 :          0 : void ValueSet::ImplHideSelect( sal_uInt16 nItemId )
     888                 :            : {
     889         [ #  # ]:          0 :     Rectangle aRect;
     890                 :            : 
     891         [ #  # ]:          0 :     const size_t nItemPos = GetItemPos( nItemId );
     892         [ #  # ]:          0 :     if ( nItemPos != VALUESET_ITEM_NOTFOUND )
     893                 :            :     {
     894         [ #  # ]:          0 :         if ( !mItemList[nItemPos]->mbVisible )
     895                 :            :         {
     896                 :            :             return;
     897                 :            :         }
     898         [ #  # ]:          0 :         aRect = ImplGetItemRect(nItemPos);
     899                 :            :     }
     900                 :            :     else
     901                 :            :     {
     902         [ #  # ]:          0 :         if ( !mpNoneItem )
     903                 :            :         {
     904                 :            :             return;
     905                 :            :         }
     906                 :          0 :         aRect = maNoneItemRect;
     907                 :            :     }
     908                 :            : 
     909         [ #  # ]:          0 :     HideFocus();
     910                 :          0 :     const Point aPos  = aRect.TopLeft();
     911         [ #  # ]:          0 :     const Size  aSize = aRect.GetSize();
     912         [ #  # ]:          0 :     DrawOutDev( aPos, aSize, aPos, aSize, maVirDev );
     913                 :            : }
     914                 :            : 
     915                 :            : // -----------------------------------------------------------------------
     916                 :            : 
     917                 :          0 : void ValueSet::ImplHighlightItem( sal_uInt16 nItemId, bool bIsSelection )
     918                 :            : {
     919         [ #  # ]:          0 :     if ( mnHighItemId != nItemId )
     920                 :            :     {
     921                 :            :         // remember the old item to delete the previous selection
     922                 :          0 :         sal_uInt16 nOldItem = mnHighItemId;
     923                 :          0 :         mnHighItemId = nItemId;
     924                 :            : 
     925                 :            :         // don't draw the selection if nothing is selected
     926 [ #  # ][ #  # ]:          0 :         if ( !bIsSelection && mbNoSelection )
     927                 :          0 :             mbDrawSelection = false;
     928                 :            : 
     929                 :            :         // remove the old selection and draw the new one
     930                 :          0 :         ImplHideSelect( nOldItem );
     931                 :          0 :         ImplDrawSelect();
     932                 :          0 :         mbDrawSelection = true;
     933                 :            :     }
     934                 :          0 : }
     935                 :            : 
     936                 :            : // -----------------------------------------------------------------------
     937                 :            : 
     938                 :         97 : void ValueSet::ImplDraw()
     939                 :            : {
     940         [ +  + ]:         97 :     if ( mbFormat )
     941         [ +  - ]:         63 :         Format();
     942                 :            : 
     943         [ +  - ]:         97 :     HideFocus();
     944                 :            : 
     945                 :         97 :     Point   aDefPos;
     946                 :         97 :     Size    aSize = maVirDev.GetOutputSizePixel();
     947                 :            : 
     948 [ +  - ][ +  - ]:         97 :     if ( mpScrBar && mpScrBar->IsVisible() )
         [ +  + ][ +  + ]
     949                 :            :     {
     950         [ +  - ]:         19 :         Point   aScrPos = mpScrBar->GetPosPixel();
     951         [ +  - ]:         19 :         Size    aScrSize = mpScrBar->GetSizePixel();
     952                 :         19 :         Point   aTempPos( 0, aScrPos.Y() );
     953                 :         19 :         Size    aTempSize( aSize.Width(), aScrPos.Y() );
     954                 :            : 
     955         [ +  - ]:         19 :         DrawOutDev( aDefPos, aTempSize, aDefPos, aTempSize, maVirDev );
     956                 :         19 :         aTempSize.Width()   = aScrPos.X()-1;
     957                 :         19 :         aTempSize.Height()  = aScrSize.Height();
     958         [ +  - ]:         19 :         DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev );
     959                 :         19 :         aTempPos.Y()        = aScrPos.Y()+aScrSize.Height();
     960                 :         19 :         aTempSize.Width()   = aSize.Width();
     961                 :         19 :         aTempSize.Height()  = aSize.Height()-aTempPos.Y();
     962         [ +  - ]:         19 :         DrawOutDev( aTempPos, aTempSize, aTempPos, aTempSize, maVirDev );
     963                 :            :     }
     964                 :            :     else
     965         [ +  - ]:         78 :         DrawOutDev( aDefPos, aSize, aDefPos, aSize, maVirDev );
     966                 :            : 
     967                 :            :     // draw parting line to the Namefield
     968 [ +  - ][ -  + ]:         97 :     if ( GetStyle() & WB_NAMEFIELD )
     969                 :            :     {
     970 [ #  # ][ #  # ]:          0 :         if ( !(GetStyle() & WB_FLATVALUESET) )
     971                 :            :         {
     972                 :          0 :             const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     973                 :          0 :             Size aWinSize = GetOutputSizePixel();
     974                 :          0 :             Point aPos1( NAME_LINE_OFF_X, mnTextOffset+NAME_LINE_OFF_Y );
     975                 :          0 :             Point aPos2( aWinSize.Width()-(NAME_LINE_OFF_X*2), mnTextOffset+NAME_LINE_OFF_Y );
     976         [ #  # ]:          0 :             if ( !(rStyleSettings.GetOptions() & STYLE_OPTION_MONO) )
     977                 :            :             {
     978         [ #  # ]:          0 :                 SetLineColor( rStyleSettings.GetShadowColor() );
     979         [ #  # ]:          0 :                 DrawLine( aPos1, aPos2 );
     980                 :          0 :                 aPos1.Y()++;
     981                 :          0 :                 aPos2.Y()++;
     982         [ #  # ]:          0 :                 SetLineColor( rStyleSettings.GetLightColor() );
     983                 :            :             }
     984                 :            :             else
     985         [ #  # ]:          0 :                 SetLineColor( rStyleSettings.GetWindowTextColor() );
     986         [ #  # ]:          0 :             DrawLine( aPos1, aPos2 );
     987                 :            :         }
     988                 :            :     }
     989                 :            : 
     990         [ +  - ]:         97 :     ImplDrawSelect();
     991                 :         97 : }
     992                 :            : 
     993                 :            : // -----------------------------------------------------------------------
     994                 :            : 
     995                 :          0 : bool ValueSet::ImplScroll( const Point& rPos )
     996                 :            : {
     997 [ #  # ][ #  # ]:          0 :     if ( !mbScroll || !maItemListRect.IsInside(rPos) )
                 [ #  # ]
     998                 :          0 :         return false;
     999                 :            : 
    1000         [ #  # ]:          0 :     const long nScrollOffset = (mnItemHeight <= 16) ? SCROLL_OFFSET/2 : SCROLL_OFFSET;
    1001                 :          0 :     bool bScroll = false;
    1002                 :            : 
    1003         [ #  # ]:          0 :     if ( rPos.Y() <= maItemListRect.Top()+nScrollOffset )
    1004                 :            :     {
    1005         [ #  # ]:          0 :         if ( mnFirstLine > 0 )
    1006                 :            :         {
    1007                 :          0 :             --mnFirstLine;
    1008                 :          0 :             bScroll = true;
    1009                 :            :         }
    1010                 :            :     }
    1011         [ #  # ]:          0 :     else if ( rPos.Y() >= maItemListRect.Bottom()-nScrollOffset )
    1012                 :            :     {
    1013         [ #  # ]:          0 :         if ( mnFirstLine < static_cast<sal_uInt16>(mnLines-mnVisLines) )
    1014                 :            :         {
    1015                 :          0 :             ++mnFirstLine;
    1016                 :          0 :             bScroll = true;
    1017                 :            :         }
    1018                 :            :     }
    1019                 :            : 
    1020         [ #  # ]:          0 :     if ( !bScroll )
    1021                 :          0 :         return false;
    1022                 :            : 
    1023                 :          0 :     mbFormat = true;
    1024                 :          0 :     ImplDraw();
    1025                 :          0 :     return true;
    1026                 :            : }
    1027                 :            : 
    1028                 :            : // -----------------------------------------------------------------------
    1029                 :            : 
    1030                 :          0 : size_t ValueSet::ImplGetItem( const Point& rPos, bool bMove ) const
    1031                 :            : {
    1032         [ #  # ]:          0 :     if ( !mbHasVisibleItems )
    1033                 :            :     {
    1034                 :          0 :         return VALUESET_ITEM_NOTFOUND;
    1035                 :            :     }
    1036                 :            : 
    1037 [ #  # ][ #  # ]:          0 :     if ( mpNoneItem && maNoneItemRect.IsInside( rPos ) )
                 [ #  # ]
    1038                 :            :     {
    1039                 :          0 :         return VALUESET_ITEM_NONEITEM;
    1040                 :            :     }
    1041                 :            : 
    1042         [ #  # ]:          0 :     if ( maItemListRect.IsInside( rPos ) )
    1043                 :            :     {
    1044                 :          0 :         const int xc = rPos.X()-maItemListRect.Left();
    1045                 :          0 :         const int yc = rPos.Y()-maItemListRect.Top();
    1046                 :            :         // The point is inside the area of item list,
    1047                 :            :         // let's find the containing item.
    1048                 :          0 :         const int col = xc/(mnItemWidth+mnSpacing);
    1049                 :          0 :         const int x = xc%(mnItemWidth+mnSpacing);
    1050                 :          0 :         const int row = yc/(mnItemHeight+mnSpacing);
    1051                 :          0 :         const int y = yc%(mnItemHeight+mnSpacing);
    1052                 :            : 
    1053 [ #  # ][ #  # ]:          0 :         if (x<mnItemWidth && y<mnItemHeight)
    1054                 :            :         {
    1055                 :            :             // the point is inside item rect and not inside spacing
    1056                 :          0 :             const size_t item = (mnFirstLine+row)*mnCols+col;
    1057         [ #  # ]:          0 :             if (item < mItemList.size())
    1058                 :            :             {
    1059                 :          0 :                 return item;
    1060                 :            :             }
    1061                 :            :         }
    1062                 :            : 
    1063                 :            :         // return the previously selected item if spacing is set and
    1064                 :            :         // the mouse hasn't left the window yet
    1065 [ #  # ][ #  # ]:          0 :         if ( bMove && mnSpacing && mnHighItemId )
                 [ #  # ]
    1066                 :            :         {
    1067                 :          0 :             return GetItemPos( mnHighItemId );
    1068                 :            :         }
    1069                 :            :     }
    1070                 :            : 
    1071                 :          0 :     return VALUESET_ITEM_NOTFOUND;
    1072                 :            : }
    1073                 :            : 
    1074                 :            : // -----------------------------------------------------------------------
    1075                 :            : 
    1076                 :          0 : ValueSetItem* ValueSet::ImplGetItem( size_t nPos )
    1077                 :            : {
    1078         [ #  # ]:          0 :     if ( nPos == VALUESET_ITEM_NONEITEM )
    1079                 :          0 :         return mpNoneItem;
    1080                 :            :     else
    1081         [ #  # ]:          0 :         return ( nPos < mItemList.size() ) ? mItemList[nPos] : NULL;
    1082                 :            : }
    1083                 :            : 
    1084                 :            : // -----------------------------------------------------------------------
    1085                 :            : 
    1086                 :         50 : ValueSetItem* ValueSet::ImplGetFirstItem()
    1087                 :            : {
    1088         [ +  - ]:         50 :     return mItemList.size() ? mItemList[0] : NULL;
    1089                 :            : }
    1090                 :            : 
    1091                 :            : // -----------------------------------------------------------------------
    1092                 :            : 
    1093                 :          0 : sal_uInt16 ValueSet::ImplGetVisibleItemCount() const
    1094                 :            : {
    1095                 :          0 :     sal_uInt16 nRet = 0;
    1096                 :          0 :     const size_t nItemCount = mItemList.size();
    1097                 :            : 
    1098         [ #  # ]:          0 :     for ( size_t n = 0; n < nItemCount; ++n )
    1099                 :            :     {
    1100         [ #  # ]:          0 :         if ( mItemList[n]->mbVisible )
    1101                 :          0 :             ++nRet;
    1102                 :            :     }
    1103                 :            : 
    1104                 :          0 :     return nRet;
    1105                 :            : }
    1106                 :            : 
    1107                 :            : // -----------------------------------------------------------------------
    1108                 :            : 
    1109                 :          0 : ValueSetItem* ValueSet::ImplGetVisibleItem( sal_uInt16 nVisiblePos )
    1110                 :            : {
    1111                 :          0 :     const size_t nItemCount = mItemList.size();
    1112                 :            : 
    1113         [ #  # ]:          0 :     for ( size_t n = 0; n < nItemCount; ++n )
    1114                 :            :     {
    1115                 :          0 :         ValueSetItem *const pItem = mItemList[n];
    1116                 :            : 
    1117 [ #  # ][ #  # ]:          0 :         if ( pItem->mbVisible && !nVisiblePos-- )
                 [ #  # ]
    1118                 :          0 :             return pItem;
    1119                 :            :     }
    1120                 :            : 
    1121                 :          0 :     return NULL;
    1122                 :            : }
    1123                 :            : 
    1124                 :            : // -----------------------------------------------------------------------
    1125                 :            : 
    1126                 :          0 : void ValueSet::ImplFireAccessibleEvent( short nEventId, const ::com::sun::star::uno::Any& rOldValue, const ::com::sun::star::uno::Any& rNewValue )
    1127                 :            : {
    1128                 :          0 :     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
    1129                 :            : 
    1130         [ #  # ]:          0 :     if( pAcc )
    1131                 :          0 :         pAcc->FireAccessibleEvent( nEventId, rOldValue, rNewValue );
    1132                 :          0 : }
    1133                 :            : 
    1134                 :            : // -----------------------------------------------------------------------
    1135                 :            : 
    1136                 :        798 : bool ValueSet::ImplHasAccessibleListeners()
    1137                 :            : {
    1138                 :        798 :     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
    1139 [ #  # ][ -  + ]:        798 :     return( pAcc && pAcc->HasAccessibleListeners() );
    1140                 :            : }
    1141                 :            : 
    1142                 :            : // -----------------------------------------------------------------------
    1143                 :            : 
    1144                 :          0 : IMPL_LINK( ValueSet,ImplScrollHdl, ScrollBar*, pScrollBar )
    1145                 :            : {
    1146                 :          0 :     sal_uInt16 nNewFirstLine = (sal_uInt16)pScrollBar->GetThumbPos();
    1147         [ #  # ]:          0 :     if ( nNewFirstLine != mnFirstLine )
    1148                 :            :     {
    1149                 :          0 :         mnFirstLine = nNewFirstLine;
    1150                 :          0 :         mbFormat = true;
    1151                 :          0 :         ImplDraw();
    1152                 :            :     }
    1153                 :          0 :     return 0;
    1154                 :            : }
    1155                 :            : 
    1156                 :            : // -----------------------------------------------------------------------
    1157                 :            : 
    1158                 :          0 : IMPL_LINK_NOARG(ValueSet, ImplTimerHdl)
    1159                 :            : {
    1160         [ #  # ]:          0 :     ImplTracking( GetPointerPosPixel(), true );
    1161                 :          0 :     return 0;
    1162                 :            : }
    1163                 :            : 
    1164                 :            : // -----------------------------------------------------------------------
    1165                 :            : 
    1166                 :          0 : void ValueSet::ImplTracking( const Point& rPos, bool bRepeat )
    1167                 :            : {
    1168 [ #  # ][ #  # ]:          0 :     if ( bRepeat || mbSelection )
    1169                 :            :     {
    1170         [ #  # ]:          0 :         if ( ImplScroll( rPos ) )
    1171                 :            :         {
    1172         [ #  # ]:          0 :             if ( mbSelection )
    1173                 :            :             {
    1174                 :          0 :                 maTimer.SetTimeoutHdl( LINK( this, ValueSet, ImplTimerHdl ) );
    1175                 :          0 :                 maTimer.SetTimeout( GetSettings().GetMouseSettings().GetScrollRepeat() );
    1176                 :          0 :                 maTimer.Start();
    1177                 :            :             }
    1178                 :            :         }
    1179                 :            :     }
    1180                 :            : 
    1181                 :          0 :     ValueSetItem* pItem = ImplGetItem( ImplGetItem( rPos ) );
    1182         [ #  # ]:          0 :     if ( pItem )
    1183                 :            :     {
    1184         [ #  # ]:          0 :         if( GetStyle() & WB_MENUSTYLEVALUESET )
    1185                 :          0 :             mbHighlight = true;
    1186                 :            : 
    1187                 :          0 :         ImplHighlightItem( pItem->mnId );
    1188                 :            :     }
    1189                 :            :     else
    1190                 :            :     {
    1191         [ #  # ]:          0 :         if( GetStyle() & WB_MENUSTYLEVALUESET )
    1192                 :          0 :             mbHighlight = true;
    1193                 :            : 
    1194                 :          0 :         ImplHighlightItem( mnSelItemId, false );
    1195                 :            :     }
    1196                 :          0 : }
    1197                 :            : 
    1198                 :            : // -----------------------------------------------------------------------
    1199                 :            : 
    1200                 :          0 : void ValueSet::ImplEndTracking( const Point& rPos, bool bCancel )
    1201                 :            : {
    1202                 :            :     ValueSetItem* pItem;
    1203                 :            : 
    1204                 :            :     // restore the old status in case of termination
    1205         [ #  # ]:          0 :     if ( bCancel )
    1206                 :          0 :         pItem = NULL;
    1207                 :            :     else
    1208                 :          0 :         pItem = ImplGetItem( ImplGetItem( rPos ) );
    1209                 :            : 
    1210         [ #  # ]:          0 :     if ( pItem )
    1211                 :            :     {
    1212                 :          0 :         SelectItem( pItem->mnId );
    1213 [ #  # ][ #  # ]:          0 :         if ( !mbSelection && !(GetStyle() & WB_NOPOINTERFOCUS) )
                 [ #  # ]
    1214                 :          0 :             GrabFocus();
    1215                 :          0 :         mbHighlight = false;
    1216                 :          0 :         mbSelection = false;
    1217                 :          0 :         Select();
    1218                 :            :     }
    1219                 :            :     else
    1220                 :            :     {
    1221                 :          0 :         ImplHighlightItem( mnSelItemId, false );
    1222                 :          0 :         mbHighlight = false;
    1223                 :          0 :         mbSelection = false;
    1224                 :            :     }
    1225                 :          0 : }
    1226                 :            : 
    1227                 :            : // -----------------------------------------------------------------------
    1228                 :            : 
    1229                 :          0 : void ValueSet::MouseButtonDown( const MouseEvent& rMEvt )
    1230                 :            : {
    1231         [ #  # ]:          0 :     if ( rMEvt.IsLeft() )
    1232                 :            :     {
    1233                 :          0 :         ValueSetItem* pItem = ImplGetItem( ImplGetItem( rMEvt.GetPosPixel() ) );
    1234         [ #  # ]:          0 :         if ( mbSelection )
    1235                 :            :         {
    1236                 :          0 :             mbHighlight = true;
    1237         [ #  # ]:          0 :             if ( pItem )
    1238                 :            :             {
    1239                 :          0 :                 mnHighItemId = mnSelItemId;
    1240                 :          0 :                 ImplHighlightItem( pItem->mnId );
    1241                 :            :             }
    1242                 :            : 
    1243                 :          0 :             return;
    1244                 :            :         }
    1245                 :            :         else
    1246                 :            :         {
    1247 [ #  # ][ #  # ]:          0 :             if ( pItem && !rMEvt.IsMod2() )
                 [ #  # ]
    1248                 :            :             {
    1249         [ #  # ]:          0 :                 if ( rMEvt.GetClicks() == 1 )
    1250                 :            :                 {
    1251                 :          0 :                     mbHighlight  = true;
    1252                 :          0 :                     mnHighItemId = mnSelItemId;
    1253                 :          0 :                     ImplHighlightItem( pItem->mnId );
    1254                 :          0 :                     StartTracking( STARTTRACK_SCROLLREPEAT );
    1255                 :            :                 }
    1256         [ #  # ]:          0 :                 else if ( rMEvt.GetClicks() == 2 )
    1257                 :          0 :                     DoubleClick();
    1258                 :            : 
    1259                 :          0 :                 return;
    1260                 :            :             }
    1261                 :            :         }
    1262                 :            :     }
    1263                 :            : 
    1264                 :          0 :     Control::MouseButtonDown( rMEvt );
    1265                 :            : }
    1266                 :            : 
    1267                 :            : // -----------------------------------------------------------------------
    1268                 :            : 
    1269                 :          0 : void ValueSet::MouseButtonUp( const MouseEvent& rMEvt )
    1270                 :            : {
    1271                 :            :     // because of SelectionMode
    1272 [ #  # ][ #  # ]:          0 :     if ( rMEvt.IsLeft() && mbSelection )
                 [ #  # ]
    1273                 :          0 :         ImplEndTracking( rMEvt.GetPosPixel(), false );
    1274                 :            :     else
    1275                 :          0 :         Control::MouseButtonUp( rMEvt );
    1276                 :          0 : }
    1277                 :            : 
    1278                 :            : // -----------------------------------------------------------------------
    1279                 :            : 
    1280                 :          0 : void ValueSet::MouseMove( const MouseEvent& rMEvt )
    1281                 :            : {
    1282                 :            :     // because of SelectionMode
    1283 [ #  # ][ #  # ]:          0 :     if ( mbSelection || (GetStyle() & WB_MENUSTYLEVALUESET) )
                 [ #  # ]
    1284                 :          0 :         ImplTracking( rMEvt.GetPosPixel(), false );
    1285                 :          0 :     Control::MouseMove( rMEvt );
    1286                 :          0 : }
    1287                 :            : 
    1288                 :            : // -----------------------------------------------------------------------
    1289                 :            : 
    1290                 :          0 : void ValueSet::Tracking( const TrackingEvent& rTEvt )
    1291                 :            : {
    1292                 :          0 :     Point aMousePos = rTEvt.GetMouseEvent().GetPosPixel();
    1293                 :            : 
    1294         [ #  # ]:          0 :     if ( rTEvt.IsTrackingEnded() )
    1295         [ #  # ]:          0 :         ImplEndTracking( aMousePos, rTEvt.IsTrackingCanceled() );
    1296                 :            :     else
    1297         [ #  # ]:          0 :         ImplTracking( aMousePos, rTEvt.IsTrackingRepeat() );
    1298                 :          0 : }
    1299                 :            : 
    1300                 :            : // -----------------------------------------------------------------------
    1301                 :            : 
    1302                 :          0 : void ValueSet::KeyInput( const KeyEvent& rKEvt )
    1303                 :            : {
    1304                 :          0 :     size_t nLastItem = mItemList.size();
    1305                 :            : 
    1306 [ #  # ][ #  # ]:          0 :     if ( !nLastItem || !ImplGetFirstItem() )
                 [ #  # ]
    1307                 :            :     {
    1308                 :          0 :         Control::KeyInput( rKEvt );
    1309                 :          0 :         return;
    1310                 :            :     }
    1311                 :            : 
    1312                 :          0 :     --nLastItem;
    1313                 :          0 :     const size_t nCurPos = mnSelItemId ? GetItemPos( mnSelItemId )
    1314 [ #  # ][ #  # ]:          0 :                                        : mpNoneItem ? VALUESET_ITEM_NONEITEM : 0;
    1315                 :          0 :     size_t nItemPos = VALUESET_ITEM_NOTFOUND;
    1316                 :          0 :     size_t nVStep = mnCols;
    1317                 :            : 
    1318   [ #  #  #  #  :          0 :     switch ( rKEvt.GetKeyCode().GetCode() )
          #  #  #  #  #  
                      # ]
    1319                 :            :     {
    1320                 :            :         case KEY_HOME:
    1321         [ #  # ]:          0 :             nItemPos = mpNoneItem ? VALUESET_ITEM_NONEITEM : 0;
    1322                 :          0 :             break;
    1323                 :            : 
    1324                 :            :         case KEY_END:
    1325                 :          0 :             nItemPos = nLastItem;
    1326                 :          0 :             break;
    1327                 :            : 
    1328                 :            :         case KEY_LEFT:
    1329         [ #  # ]:          0 :             if (nCurPos != VALUESET_ITEM_NONEITEM)
    1330                 :            :             {
    1331         [ #  # ]:          0 :                 if (nCurPos)
    1332                 :            :                 {
    1333                 :          0 :                     nItemPos = nCurPos-1;
    1334                 :            :                 }
    1335         [ #  # ]:          0 :                 else if (mpNoneItem)
    1336                 :            :                 {
    1337                 :          0 :                     nItemPos = VALUESET_ITEM_NONEITEM;
    1338                 :            :                 }
    1339                 :            :             }
    1340                 :          0 :             break;
    1341                 :            : 
    1342                 :            :         case KEY_RIGHT:
    1343         [ #  # ]:          0 :             if (nCurPos < nLastItem)
    1344                 :            :             {
    1345         [ #  # ]:          0 :                 if (nCurPos == VALUESET_ITEM_NONEITEM)
    1346                 :            :                 {
    1347                 :          0 :                     nItemPos = 0;
    1348                 :            :                 }
    1349                 :            :                 else
    1350                 :            :                 {
    1351                 :          0 :                     nItemPos = nCurPos+1;
    1352                 :            :                 }
    1353                 :            :             }
    1354                 :          0 :             break;
    1355                 :            : 
    1356                 :            :         case KEY_PAGEUP:
    1357 [ #  # ][ #  # ]:          0 :             if (rKEvt.GetKeyCode().IsShift() || rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
         [ #  # ][ #  # ]
    1358                 :            :             {
    1359                 :          0 :                 Control::KeyInput( rKEvt );
    1360                 :          0 :                 return;
    1361                 :            :             }
    1362                 :          0 :             nVStep *= mnVisLines;
    1363                 :            :             // intentional fall-through
    1364                 :            :         case KEY_UP:
    1365         [ #  # ]:          0 :             if (nCurPos != VALUESET_ITEM_NONEITEM)
    1366                 :            :             {
    1367         [ #  # ]:          0 :                 if (nCurPos == nLastItem)
    1368                 :            :                 {
    1369                 :          0 :                     const size_t nCol = nLastItem % mnCols;
    1370         [ #  # ]:          0 :                     if (nCol < mnCurCol)
    1371                 :            :                     {
    1372                 :            :                         // Move to previous row/page, keeping the old column
    1373                 :          0 :                         nVStep -= mnCurCol - nCol;
    1374                 :            :                     }
    1375                 :            :                 }
    1376         [ #  # ]:          0 :                 if (nCurPos >= nVStep)
    1377                 :            :                 {
    1378                 :            :                     // Go up of a whole page
    1379                 :          0 :                     nItemPos = nCurPos-nVStep;
    1380                 :            :                 }
    1381         [ #  # ]:          0 :                 else if (mpNoneItem)
    1382                 :            :                 {
    1383                 :          0 :                     nItemPos = VALUESET_ITEM_NONEITEM;
    1384                 :            :                 }
    1385         [ #  # ]:          0 :                 else if (nCurPos > mnCols)
    1386                 :            :                 {
    1387                 :            :                     // Go to same column in first row
    1388                 :          0 :                     nItemPos = nCurPos % mnCols;
    1389                 :            :                 }
    1390                 :            :             }
    1391                 :          0 :             break;
    1392                 :            : 
    1393                 :            :         case KEY_PAGEDOWN:
    1394 [ #  # ][ #  # ]:          0 :             if (rKEvt.GetKeyCode().IsShift() || rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2())
         [ #  # ][ #  # ]
    1395                 :            :             {
    1396                 :          0 :                 Control::KeyInput( rKEvt );
    1397                 :          0 :                 return;
    1398                 :            :             }
    1399                 :          0 :             nVStep *= mnVisLines;
    1400                 :            :             // intentional fall-through
    1401                 :            :         case KEY_DOWN:
    1402         [ #  # ]:          0 :             if (nCurPos != nLastItem)
    1403                 :            :             {
    1404         [ #  # ]:          0 :                 if (nCurPos == VALUESET_ITEM_NONEITEM)
    1405                 :            :                 {
    1406                 :          0 :                     nItemPos = nVStep-mnCols+mnCurCol;
    1407                 :            :                 }
    1408                 :            :                 else
    1409                 :            :                 {
    1410                 :          0 :                     nItemPos = nCurPos+nVStep;
    1411                 :            :                 }
    1412         [ #  # ]:          0 :                 if (nItemPos > nLastItem)
    1413                 :            :                 {
    1414                 :          0 :                     nItemPos = nLastItem;
    1415                 :            :                 }
    1416                 :            :             }
    1417                 :          0 :             break;
    1418                 :            : 
    1419                 :            :         case KEY_RETURN:
    1420         [ #  # ]:          0 :             if (GetStyle() & WB_NO_DIRECTSELECT)
    1421                 :            :             {
    1422                 :          0 :                 Select();
    1423                 :          0 :                 break;
    1424                 :            :             }
    1425                 :            :             // intentional fall-through
    1426                 :            :         default:
    1427                 :          0 :             Control::KeyInput( rKEvt );
    1428                 :          0 :             return;
    1429                 :            :     }
    1430                 :            : 
    1431                 :            :     // This point is reached only if key travelling was used,
    1432                 :            :     // in which case selection mode should be switched off
    1433                 :          0 :     EndSelection();
    1434                 :            : 
    1435         [ #  # ]:          0 :     if ( nItemPos != VALUESET_ITEM_NOTFOUND )
    1436                 :            :     {
    1437 [ #  # ][ #  # ]:          0 :         if ( nItemPos!=VALUESET_ITEM_NONEITEM && nItemPos<nLastItem )
    1438                 :            :         {
    1439                 :            :             // update current column only in case of a new position
    1440                 :            :             // which is also not a "specially" handled one.
    1441                 :          0 :             mnCurCol = nItemPos % mnCols;
    1442                 :            :         }
    1443         [ #  # ]:          0 :         const sal_uInt16 nItemId = (nItemPos != VALUESET_ITEM_NONEITEM) ? GetItemId( nItemPos ) : 0;
    1444         [ #  # ]:          0 :         if ( nItemId != mnSelItemId )
    1445                 :            :         {
    1446                 :          0 :             SelectItem( nItemId );
    1447         [ #  # ]:          0 :             if (!(GetStyle() & WB_NO_DIRECTSELECT))
    1448                 :            :             {
    1449                 :            :                 // select only if WB_NO_DIRECTSELECT is not set
    1450                 :          0 :                 Select();
    1451                 :            :             }
    1452                 :            :         }
    1453                 :            :     }
    1454                 :            : }
    1455                 :            : 
    1456                 :            : // -----------------------------------------------------------------------
    1457                 :            : 
    1458                 :          0 : void ValueSet::Command( const CommandEvent& rCEvt )
    1459                 :            : {
    1460   [ #  #  #  #  :          0 :     if ( (rCEvt.GetCommand() == COMMAND_WHEEL) ||
           #  # ][ #  # ]
    1461                 :          0 :          (rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
    1462                 :          0 :          (rCEvt.GetCommand() == COMMAND_AUTOSCROLL) )
    1463                 :            :     {
    1464         [ #  # ]:          0 :         if ( HandleScrollCommand( rCEvt, NULL, mpScrBar ) )
    1465                 :          0 :             return;
    1466                 :            :     }
    1467                 :            : 
    1468                 :          0 :     Control::Command( rCEvt );
    1469                 :            : }
    1470                 :            : 
    1471                 :            : // -----------------------------------------------------------------------
    1472                 :            : 
    1473                 :         56 : void ValueSet::Paint( const Rectangle& )
    1474                 :            : {
    1475         [ +  + ]:         56 :     if ( GetStyle() & WB_FLATVALUESET )
    1476                 :            :     {
    1477                 :         20 :         const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
    1478         [ +  - ]:         20 :         SetLineColor();
    1479         [ +  - ]:         20 :         SetFillColor( rStyleSettings.GetFaceColor() );
    1480                 :         20 :         long nOffY = maVirDev.GetOutputSizePixel().Height();
    1481                 :         20 :         Size aWinSize = GetOutputSizePixel();
    1482 [ +  - ][ +  - ]:         20 :         DrawRect( Rectangle( Point( 0, nOffY ), Point( aWinSize.Width(), aWinSize.Height() ) ) );
    1483                 :            :     }
    1484                 :            : 
    1485                 :         56 :     ImplDraw();
    1486                 :         56 : }
    1487                 :            : 
    1488                 :            : // -----------------------------------------------------------------------
    1489                 :            : 
    1490                 :         32 : void ValueSet::GetFocus()
    1491                 :            : {
    1492                 :            :     OSL_TRACE ("value set getting focus");
    1493                 :         32 :     ImplDrawSelect();
    1494                 :         32 :     Control::GetFocus();
    1495                 :            : 
    1496                 :            :     // Tell the accessible object that we got the focus.
    1497                 :         32 :     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
    1498         [ -  + ]:         32 :     if( pAcc )
    1499                 :          0 :         pAcc->GetFocus();
    1500                 :         32 : }
    1501                 :            : 
    1502                 :            : // -----------------------------------------------------------------------
    1503                 :            : 
    1504                 :          6 : void ValueSet::LoseFocus()
    1505                 :            : {
    1506                 :            :     OSL_TRACE ("value set losing focus");
    1507 [ -  + ][ #  # ]:          6 :     if ( mbNoSelection && mnSelItemId )
    1508                 :          0 :         ImplHideSelect( mnSelItemId );
    1509                 :            :     else
    1510                 :          6 :         HideFocus();
    1511                 :          6 :     Control::LoseFocus();
    1512                 :            : 
    1513                 :            :     // Tell the accessible object that we lost the focus.
    1514                 :          6 :     ValueSetAcc* pAcc = ValueSetAcc::getImplementation( GetAccessible( sal_False ) );
    1515         [ -  + ]:          6 :     if( pAcc )
    1516                 :          0 :         pAcc->LoseFocus();
    1517                 :          6 : }
    1518                 :            : 
    1519                 :            : // -----------------------------------------------------------------------
    1520                 :            : 
    1521                 :        100 : void ValueSet::Resize()
    1522                 :            : {
    1523                 :        100 :     mbFormat = true;
    1524 [ +  + ][ +  - ]:        100 :     if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1525                 :         75 :         Invalidate();
    1526                 :        100 :     Control::Resize();
    1527                 :        100 : }
    1528                 :            : 
    1529                 :            : // -----------------------------------------------------------------------
    1530                 :            : 
    1531                 :          0 : void ValueSet::RequestHelp( const HelpEvent& rHEvt )
    1532                 :            : {
    1533         [ #  # ]:          0 :     if ( (rHEvt.GetMode() & (HELPMODE_QUICK | HELPMODE_BALLOON)) == HELPMODE_QUICK )
    1534                 :            :     {
    1535 [ #  # ][ #  # ]:          0 :         Point aPos = ScreenToOutputPixel( rHEvt.GetMousePosPixel() );
    1536         [ #  # ]:          0 :         size_t nItemPos = ImplGetItem( aPos );
    1537         [ #  # ]:          0 :         if ( nItemPos != VALUESET_ITEM_NOTFOUND )
    1538                 :            :         {
    1539         [ #  # ]:          0 :             Rectangle aItemRect = ImplGetItemRect( nItemPos );
    1540         [ #  # ]:          0 :             Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
    1541                 :          0 :             aItemRect.Left()   = aPt.X();
    1542                 :          0 :             aItemRect.Top()    = aPt.Y();
    1543 [ #  # ][ #  # ]:          0 :             aPt = OutputToScreenPixel( aItemRect.BottomRight() );
    1544                 :          0 :             aItemRect.Right()  = aPt.X();
    1545                 :          0 :             aItemRect.Bottom() = aPt.Y();
    1546 [ #  # ][ #  # ]:          0 :             Help::ShowQuickHelp( this, aItemRect, GetItemText( ImplGetItem( nItemPos )->mnId ) );
         [ #  # ][ #  # ]
    1547                 :          0 :             return;
    1548                 :            :         }
    1549                 :            :     }
    1550                 :            : 
    1551                 :          0 :     Control::RequestHelp( rHEvt );
    1552                 :            : }
    1553                 :            : 
    1554                 :            : // -----------------------------------------------------------------------
    1555                 :            : 
    1556                 :         80 : void ValueSet::StateChanged( StateChangedType nType )
    1557                 :            : {
    1558                 :         80 :     Control::StateChanged( nType );
    1559                 :            : 
    1560         [ +  + ]:         80 :     if ( nType == STATE_CHANGE_INITSHOW )
    1561                 :            :     {
    1562         [ +  - ]:         20 :         if ( mbFormat )
    1563                 :         20 :             Format();
    1564                 :            :     }
    1565         [ -  + ]:         60 :     else if ( nType == STATE_CHANGE_UPDATEMODE )
    1566                 :            :     {
    1567 [ #  # ][ #  # ]:          0 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
    1568                 :          0 :             Invalidate();
    1569                 :            :     }
    1570         [ -  + ]:         60 :     else if ( nType == STATE_CHANGE_TEXT )
    1571                 :            :     {
    1572 [ #  # ][ #  # ]:          0 :         if ( mpNoneItem && !mbFormat && IsReallyVisible() && IsUpdateMode() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1573                 :            :         {
    1574                 :          0 :             ImplFormatItem( mpNoneItem, maNoneItemRect );
    1575                 :          0 :             Invalidate( maNoneItemRect );
    1576                 :            :         }
    1577                 :            :     }
    1578 [ +  - ][ -  + ]:         60 :     else if ( (nType == STATE_CHANGE_ZOOM) ||
    1579                 :            :               (nType == STATE_CHANGE_CONTROLFONT) )
    1580                 :            :     {
    1581                 :          0 :         ImplInitSettings( true, false, false );
    1582                 :          0 :         Invalidate();
    1583                 :            :     }
    1584         [ -  + ]:         60 :     else if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
    1585                 :            :     {
    1586                 :          0 :         ImplInitSettings( false, true, false );
    1587                 :          0 :         Invalidate();
    1588                 :            :     }
    1589         [ -  + ]:         60 :     else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
    1590                 :            :     {
    1591                 :          0 :         ImplInitSettings( false, false, true );
    1592                 :          0 :         Invalidate();
    1593                 :            :     }
    1594 [ +  + ][ +  + ]:         60 :     else if ( (nType == STATE_CHANGE_STYLE) || (nType == STATE_CHANGE_ENABLE) )
    1595                 :            :     {
    1596                 :         45 :         mbFormat = true;
    1597                 :         45 :         ImplInitSettings( false, false, true );
    1598                 :         45 :         Invalidate();
    1599                 :            :     }
    1600                 :         80 : }
    1601                 :            : 
    1602                 :            : // -----------------------------------------------------------------------
    1603                 :            : 
    1604                 :          0 : void ValueSet::DataChanged( const DataChangedEvent& rDCEvt )
    1605                 :            : {
    1606                 :          0 :     Control::DataChanged( rDCEvt );
    1607                 :            : 
    1608 [ #  # ][ #  #  :          0 :     if ( (rDCEvt.GetType() == DATACHANGED_FONTS) ||
          #  #  #  #  #  
                #  #  # ]
    1609                 :          0 :          (rDCEvt.GetType() == DATACHANGED_DISPLAY) ||
    1610                 :          0 :          (rDCEvt.GetType() == DATACHANGED_FONTSUBSTITUTION) ||
    1611                 :          0 :          ((rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
    1612                 :          0 :           (rDCEvt.GetFlags() & SETTINGS_STYLE)) )
    1613                 :            :     {
    1614                 :          0 :         mbFormat = true;
    1615                 :          0 :         ImplInitSettings( true, true, true );
    1616                 :          0 :         Invalidate();
    1617                 :            :     }
    1618                 :          0 : }
    1619                 :            : 
    1620                 :            : // -----------------------------------------------------------------------
    1621                 :            : 
    1622                 :          0 : void ValueSet::Select()
    1623                 :            : {
    1624                 :          0 :     maSelectHdl.Call( this );
    1625                 :          0 : }
    1626                 :            : 
    1627                 :            : // -----------------------------------------------------------------------
    1628                 :            : 
    1629                 :          0 : void ValueSet::DoubleClick()
    1630                 :            : {
    1631                 :          0 :     maDoubleClickHdl.Call( this );
    1632                 :          0 : }
    1633                 :            : 
    1634                 :            : // -----------------------------------------------------------------------
    1635                 :            : 
    1636                 :          0 : void ValueSet::UserDraw( const UserDrawEvent& )
    1637                 :            : {
    1638                 :          0 : }
    1639                 :            : 
    1640                 :            : // -----------------------------------------------------------------------
    1641                 :            : 
    1642                 :        187 : void ValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage, size_t nPos )
    1643                 :            : {
    1644         [ +  - ]:        187 :     ValueSetItem* pItem = new ValueSetItem( *this );
    1645                 :        187 :     pItem->mnId     = nItemId;
    1646                 :        187 :     pItem->meType   = VALUESETITEM_IMAGE;
    1647                 :        187 :     pItem->maImage  = rImage;
    1648                 :        187 :     ImplInsertItem( pItem, nPos );
    1649                 :        187 : }
    1650                 :            : 
    1651                 :            : // -----------------------------------------------------------------------
    1652                 :            : 
    1653                 :          0 : void ValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor, size_t nPos )
    1654                 :            : {
    1655         [ #  # ]:          0 :     ValueSetItem* pItem = new ValueSetItem( *this );
    1656                 :          0 :     pItem->mnId     = nItemId;
    1657                 :          0 :     pItem->meType   = VALUESETITEM_COLOR;
    1658                 :          0 :     pItem->maColor  = rColor;
    1659                 :          0 :     ImplInsertItem( pItem, nPos );
    1660                 :          0 : }
    1661                 :            : 
    1662                 :            : // -----------------------------------------------------------------------
    1663                 :            : 
    1664                 :        396 : void ValueSet::InsertItem( sal_uInt16 nItemId, const Image& rImage,
    1665                 :            :                            const XubString& rText, size_t nPos )
    1666                 :            : {
    1667         [ +  - ]:        396 :     ValueSetItem* pItem = new ValueSetItem( *this );
    1668                 :        396 :     pItem->mnId     = nItemId;
    1669                 :        396 :     pItem->meType   = VALUESETITEM_IMAGE;
    1670                 :        396 :     pItem->maImage  = rImage;
    1671                 :        396 :     pItem->maText   = rText;
    1672                 :        396 :     ImplInsertItem( pItem, nPos );
    1673                 :        396 : }
    1674                 :            : 
    1675                 :            : // -----------------------------------------------------------------------
    1676                 :            : 
    1677                 :          0 : void ValueSet::InsertItem( sal_uInt16 nItemId, const Color& rColor,
    1678                 :            :                            const XubString& rText, size_t nPos )
    1679                 :            : {
    1680         [ #  # ]:          0 :     ValueSetItem* pItem = new ValueSetItem( *this );
    1681                 :          0 :     pItem->mnId     = nItemId;
    1682                 :          0 :     pItem->meType   = VALUESETITEM_COLOR;
    1683                 :          0 :     pItem->maColor  = rColor;
    1684                 :          0 :     pItem->maText   = rText;
    1685                 :          0 :     ImplInsertItem( pItem, nPos );
    1686                 :          0 : }
    1687                 :            : 
    1688                 :            : // -----------------------------------------------------------------------
    1689                 :            : 
    1690                 :          0 : void ValueSet::InsertItem( sal_uInt16 nItemId, size_t nPos )
    1691                 :            : {
    1692         [ #  # ]:          0 :     ValueSetItem* pItem = new ValueSetItem( *this );
    1693                 :          0 :     pItem->mnId     = nItemId;
    1694                 :          0 :     pItem->meType   = VALUESETITEM_USERDRAW;
    1695                 :          0 :     ImplInsertItem( pItem, nPos );
    1696                 :          0 : }
    1697                 :            : 
    1698                 :            : // -----------------------------------------------------------------------
    1699                 :            : 
    1700                 :        583 : void ValueSet::ImplInsertItem( ValueSetItem *const pItem, const size_t nPos )
    1701                 :            : {
    1702                 :            :     DBG_ASSERT( pItem->mnId, "ValueSet::InsertItem(): ItemId == 0" );
    1703                 :            :     DBG_ASSERT( GetItemPos( pItem->mnId ) == VALUESET_ITEM_NOTFOUND,
    1704                 :            :                 "ValueSet::InsertItem(): ItemId already exists" );
    1705                 :            : 
    1706         [ -  + ]:        583 :     if ( nPos < mItemList.size() ) {
    1707                 :          0 :         ValueItemList::iterator it = mItemList.begin();
    1708         [ #  # ]:          0 :         ::std::advance( it, nPos );
    1709         [ #  # ]:          0 :         mItemList.insert( it, pItem );
    1710                 :            :     } else {
    1711                 :        583 :         mItemList.push_back( pItem );
    1712                 :            :     }
    1713                 :            : 
    1714                 :        583 :     mbFormat = true;
    1715 [ +  + ][ +  - ]:        583 :     if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1716                 :        168 :         Invalidate();
    1717                 :        583 : }
    1718                 :            : 
    1719                 :            : // -----------------------------------------------------------------------
    1720                 :            : 
    1721                 :         90 : Rectangle ValueSet::ImplGetItemRect( size_t nPos ) const
    1722                 :            : {
    1723                 :         90 :     const size_t nVisibleBegin = static_cast<size_t>(mnFirstLine)*mnCols;
    1724                 :         90 :     const size_t nVisibleEnd = nVisibleBegin + static_cast<size_t>(mnVisLines)*mnCols;
    1725                 :            : 
    1726                 :            :     // Check if the item is inside the range of the displayed ones,
    1727                 :            :     // taking into account that last row could be incomplete
    1728 [ +  - ][ +  - ]:         90 :     if ( nPos<nVisibleBegin || nPos>=nVisibleEnd || nPos>=mItemList.size() )
         [ -  + ][ -  + ]
    1729                 :          0 :         return Rectangle();
    1730                 :            : 
    1731                 :         90 :     nPos -= nVisibleBegin;
    1732                 :            : 
    1733                 :         90 :     const size_t row = nPos/mnCols;
    1734                 :         90 :     const size_t col = nPos%mnCols;
    1735                 :         90 :     const long x = maItemListRect.Left()+col*(mnItemWidth+mnSpacing);
    1736                 :         90 :     const long y = maItemListRect.Top()+row*(mnItemHeight+mnSpacing);
    1737                 :            : 
    1738         [ +  - ]:         90 :     return Rectangle( Point(x, y), Size(mnItemWidth, mnItemHeight) );
    1739                 :            : }
    1740                 :            : 
    1741                 :            : // -----------------------------------------------------------------------
    1742                 :            : 
    1743                 :          0 : void ValueSet::RemoveItem( sal_uInt16 nItemId )
    1744                 :            : {
    1745                 :          0 :     size_t nPos = GetItemPos( nItemId );
    1746                 :            : 
    1747         [ #  # ]:          0 :     if ( nPos == VALUESET_ITEM_NOTFOUND )
    1748                 :          0 :         return;
    1749                 :            : 
    1750         [ #  # ]:          0 :     if ( nPos < mItemList.size() ) {
    1751                 :          0 :         ValueItemList::iterator it = mItemList.begin();
    1752         [ #  # ]:          0 :         ::std::advance( it, nPos );
    1753 [ #  # ][ #  # ]:          0 :         delete *it;
    1754         [ #  # ]:          0 :         mItemList.erase( it );
    1755                 :            :     }
    1756                 :            : 
    1757                 :            :     // reset variables
    1758 [ #  # ][ #  # ]:          0 :     if ( (mnHighItemId == nItemId) || (mnSelItemId == nItemId) )
    1759                 :            :     {
    1760                 :          0 :         mnCurCol        = 0;
    1761                 :          0 :         mnHighItemId    = 0;
    1762                 :          0 :         mnSelItemId     = 0;
    1763                 :          0 :         mbNoSelection   = true;
    1764                 :            :     }
    1765                 :            : 
    1766                 :          0 :     mbFormat = true;
    1767 [ #  # ][ #  # ]:          0 :     if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
    1768                 :          0 :         Invalidate();
    1769                 :            : }
    1770                 :            : 
    1771                 :            : // -----------------------------------------------------------------------
    1772                 :            : 
    1773                 :         65 : void ValueSet::Clear()
    1774                 :            : {
    1775                 :         65 :     ImplDeleteItems();
    1776                 :            : 
    1777                 :            :     // reset variables
    1778                 :         65 :     mnFirstLine     = 0;
    1779                 :         65 :     mnCurCol        = 0;
    1780                 :         65 :     mnHighItemId    = 0;
    1781                 :         65 :     mnSelItemId     = 0;
    1782                 :         65 :     mbNoSelection   = true;
    1783                 :            : 
    1784                 :         65 :     mbFormat = true;
    1785 [ +  - ][ +  + ]:         65 :     if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1786                 :         15 :         Invalidate();
    1787                 :         65 : }
    1788                 :            : 
    1789                 :            : // -----------------------------------------------------------------------
    1790                 :            : 
    1791                 :        717 : size_t ValueSet::GetItemCount() const
    1792                 :            : {
    1793                 :        717 :     return mItemList.size();
    1794                 :            : }
    1795                 :            : 
    1796                 :            : // -----------------------------------------------------------------------
    1797                 :            : 
    1798                 :       1027 : size_t ValueSet::GetItemPos( sal_uInt16 nItemId ) const
    1799                 :            : {
    1800         [ +  - ]:       5459 :     for ( size_t i = 0, n = mItemList.size(); i < n; ++i ) {
    1801         [ +  + ]:       5459 :         if ( mItemList[i]->mnId == nItemId ) {
    1802                 :       1027 :             return i;
    1803                 :            :         }
    1804                 :            :     }
    1805                 :       1027 :     return VALUESET_ITEM_NOTFOUND;
    1806                 :            : }
    1807                 :            : 
    1808                 :            : // -----------------------------------------------------------------------
    1809                 :            : 
    1810                 :        141 : sal_uInt16 ValueSet::GetItemId( size_t nPos ) const
    1811                 :            : {
    1812         [ +  - ]:        141 :     return ( nPos < mItemList.size() ) ? mItemList[nPos]->mnId : 0 ;
    1813                 :            : }
    1814                 :            : 
    1815                 :            : // -----------------------------------------------------------------------
    1816                 :            : 
    1817                 :          0 : sal_uInt16 ValueSet::GetItemId( const Point& rPos ) const
    1818                 :            : {
    1819                 :          0 :     size_t nItemPos = ImplGetItem( rPos );
    1820         [ #  # ]:          0 :     if ( nItemPos != VALUESET_ITEM_NOTFOUND )
    1821                 :          0 :         return GetItemId( nItemPos );
    1822                 :            : 
    1823                 :          0 :     return 0;
    1824                 :            : }
    1825                 :            : 
    1826                 :            : // -----------------------------------------------------------------------
    1827                 :            : 
    1828                 :          0 : Rectangle ValueSet::GetItemRect( sal_uInt16 nItemId ) const
    1829                 :            : {
    1830                 :          0 :     const size_t nPos = GetItemPos( nItemId );
    1831                 :            : 
    1832 [ #  # ][ #  # ]:          0 :     if ( nPos!=VALUESET_ITEM_NOTFOUND && mItemList[nPos]->mbVisible )
                 [ #  # ]
    1833                 :          0 :         return ImplGetItemRect( nPos );
    1834                 :            : 
    1835                 :          0 :     return Rectangle();
    1836                 :            : }
    1837                 :            : 
    1838                 :            : // -----------------------------------------------------------------------
    1839                 :            : 
    1840                 :          0 : void ValueSet::EnableFullItemMode( bool bFullMode )
    1841                 :            : {
    1842                 :          0 :     mbFullMode = bFullMode;
    1843                 :          0 : }
    1844                 :            : 
    1845                 :            : // -----------------------------------------------------------------------
    1846                 :            : 
    1847                 :         51 : void ValueSet::SetColCount( sal_uInt16 nNewCols )
    1848                 :            : {
    1849         [ +  + ]:         51 :     if ( mnUserCols != nNewCols )
    1850                 :            :     {
    1851                 :         49 :         mnUserCols = nNewCols;
    1852                 :         49 :         mbFormat = true;
    1853 [ +  + ][ +  - ]:         49 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1854                 :         44 :             Invalidate();
    1855                 :            :     }
    1856                 :         51 : }
    1857                 :            : 
    1858                 :            : // -----------------------------------------------------------------------
    1859                 :            : 
    1860                 :         85 : void ValueSet::SetLineCount( sal_uInt16 nNewLines )
    1861                 :            : {
    1862         [ +  + ]:         85 :     if ( mnUserVisLines != nNewLines )
    1863                 :            :     {
    1864                 :         66 :         mnUserVisLines = nNewLines;
    1865                 :         66 :         mbFormat = true;
    1866 [ +  + ][ +  - ]:         66 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1867                 :         61 :             Invalidate();
    1868                 :            :     }
    1869                 :         85 : }
    1870                 :            : 
    1871                 :            : // -----------------------------------------------------------------------
    1872                 :            : 
    1873                 :         34 : void ValueSet::SetItemWidth( long nNewItemWidth )
    1874                 :            : {
    1875         [ +  + ]:         34 :     if ( mnUserItemWidth != nNewItemWidth )
    1876                 :            :     {
    1877                 :         17 :         mnUserItemWidth = nNewItemWidth;
    1878                 :         17 :         mbFormat = true;
    1879 [ +  + ][ +  - ]:         17 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1880                 :         12 :             Invalidate();
    1881                 :            :     }
    1882                 :         34 : }
    1883                 :            : 
    1884                 :            : // -----------------------------------------------------------------------
    1885                 :            : 
    1886                 :         34 : void ValueSet::SetItemHeight( long nNewItemHeight )
    1887                 :            : {
    1888         [ +  + ]:         34 :     if ( mnUserItemHeight != nNewItemHeight )
    1889                 :            :     {
    1890                 :         17 :         mnUserItemHeight = nNewItemHeight;
    1891                 :         17 :         mbFormat = true;
    1892 [ +  + ][ +  - ]:         17 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    1893                 :         12 :             Invalidate();
    1894                 :            :     }
    1895                 :         34 : }
    1896                 :            : 
    1897                 :            : // -----------------------------------------------------------------------
    1898                 :            : 
    1899                 :         52 : void ValueSet::SelectItem( sal_uInt16 nItemId )
    1900                 :            : {
    1901                 :         52 :     size_t nItemPos = 0;
    1902                 :            : 
    1903         [ +  + ]:         52 :     if ( nItemId )
    1904                 :            :     {
    1905                 :         18 :         nItemPos = GetItemPos( nItemId );
    1906         [ -  + ]:         18 :         if ( nItemPos == VALUESET_ITEM_NOTFOUND )
    1907                 :         52 :             return;
    1908                 :            :     }
    1909                 :            : 
    1910 [ +  + ][ +  + ]:         52 :     if ( (mnSelItemId != nItemId) || mbNoSelection )
    1911                 :            :     {
    1912         [ -  + ]:         35 :         sal_uInt16 nOldItem = mnSelItemId ? mnSelItemId : 1;
    1913                 :         35 :         mnSelItemId = nItemId;
    1914                 :         35 :         mbNoSelection = false;
    1915                 :            : 
    1916 [ -  + ][ #  # ]:         35 :         bool bNewOut = !mbFormat && IsReallyVisible() && IsUpdateMode();
                 [ #  # ]
    1917                 :         35 :         bool bNewLine = false;
    1918                 :            : 
    1919                 :            :         // if necessary scroll to the visible area
    1920 [ -  + ][ #  # ]:         35 :         if ( mbScroll && nItemId )
    1921                 :            :         {
    1922                 :          0 :             sal_uInt16 nNewLine = (sal_uInt16)(nItemPos / mnCols);
    1923         [ #  # ]:          0 :             if ( nNewLine < mnFirstLine )
    1924                 :            :             {
    1925                 :          0 :                 mnFirstLine = nNewLine;
    1926                 :          0 :                 bNewLine = true;
    1927                 :            :             }
    1928         [ #  # ]:          0 :             else if ( nNewLine > (sal_uInt16)(mnFirstLine+mnVisLines-1) )
    1929                 :            :             {
    1930                 :          0 :                 mnFirstLine = (sal_uInt16)(nNewLine-mnVisLines+1);
    1931                 :          0 :                 bNewLine = true;
    1932                 :            :             }
    1933                 :            :         }
    1934                 :            : 
    1935         [ -  + ]:         35 :         if ( bNewOut )
    1936                 :            :         {
    1937         [ #  # ]:          0 :             if ( bNewLine )
    1938                 :            :             {
    1939                 :            :                 // redraw everything if the visible area has changed
    1940                 :          0 :                 mbFormat = true;
    1941                 :          0 :                 ImplDraw();
    1942                 :            :             }
    1943                 :            :             else
    1944                 :            :             {
    1945                 :            :                 // remove old selection and draw the new one
    1946                 :          0 :                 ImplHideSelect( nOldItem );
    1947                 :          0 :                 ImplDrawSelect();
    1948                 :            :             }
    1949                 :            :         }
    1950                 :            : 
    1951         [ -  + ]:         35 :         if( ImplHasAccessibleListeners() )
    1952                 :            :         {
    1953                 :            :             // focus event (deselect)
    1954         [ #  # ]:          0 :             if( nOldItem )
    1955                 :            :             {
    1956         [ #  # ]:          0 :                 const size_t nPos = GetItemPos( nItemId );
    1957                 :            : 
    1958         [ #  # ]:          0 :                 if( nPos != VALUESET_ITEM_NOTFOUND )
    1959                 :            :                 {
    1960                 :            :                     ValueItemAcc* pItemAcc = ValueItemAcc::getImplementation(
    1961         [ #  # ]:          0 :                         mItemList[nPos]->GetAccessible( mbIsTransientChildrenDisabled ) );
    1962                 :            : 
    1963         [ #  # ]:          0 :                     if( pItemAcc )
    1964                 :            :                     {
    1965                 :          0 :                         ::com::sun::star::uno::Any aOldAny, aNewAny;
    1966         [ #  # ]:          0 :                         if( !mbIsTransientChildrenDisabled )
    1967                 :            :                         {
    1968                 :            :                             aOldAny <<= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
    1969 [ #  # ][ #  # ]:          0 :                                 static_cast< ::cppu::OWeakObject* >( pItemAcc ));
    1970         [ #  # ]:          0 :                             ImplFireAccessibleEvent (::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny );
    1971                 :            :                         }
    1972                 :            :                         else
    1973                 :            :                         {
    1974         [ #  # ]:          0 :                             aOldAny <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
    1975         [ #  # ]:          0 :                             pItemAcc->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
    1976                 :          0 :                         }
    1977                 :            :                     }
    1978                 :            :                 }
    1979                 :            :             }
    1980                 :            : 
    1981                 :            :             // focus event (select)
    1982         [ #  # ]:          0 :             const size_t nPos = GetItemPos( mnSelItemId );
    1983                 :            : 
    1984                 :            :             ValueSetItem* pItem;
    1985         [ #  # ]:          0 :             if( nPos != VALUESET_ITEM_NOTFOUND )
    1986                 :          0 :                 pItem = mItemList[nPos];
    1987                 :            :             else
    1988                 :          0 :                 pItem = mpNoneItem;
    1989                 :            : 
    1990                 :          0 :             ValueItemAcc* pItemAcc = NULL;
    1991         [ #  # ]:          0 :             if (pItem != NULL)
    1992         [ #  # ]:          0 :                 pItemAcc = ValueItemAcc::getImplementation( pItem->GetAccessible( mbIsTransientChildrenDisabled ) );
    1993                 :            : 
    1994         [ #  # ]:          0 :             if( pItemAcc )
    1995                 :            :             {
    1996                 :          0 :                 ::com::sun::star::uno::Any aOldAny, aNewAny;
    1997         [ #  # ]:          0 :                 if( !mbIsTransientChildrenDisabled )
    1998                 :            :                 {
    1999                 :            :                     aNewAny <<= ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(
    2000 [ #  # ][ #  # ]:          0 :                         static_cast< ::cppu::OWeakObject* >( pItemAcc ));
    2001         [ #  # ]:          0 :                     ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, aOldAny, aNewAny );
    2002                 :            :                 }
    2003                 :            :                 else
    2004                 :            :                 {
    2005         [ #  # ]:          0 :                     aNewAny <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
    2006         [ #  # ]:          0 :                     pItemAcc->FireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny );
    2007                 :          0 :                 }
    2008                 :            :             }
    2009                 :            : 
    2010                 :            :             // selection event
    2011                 :          0 :             ::com::sun::star::uno::Any aOldAny, aNewAny;
    2012         [ #  # ]:          0 :             ImplFireAccessibleEvent( ::com::sun::star::accessibility::AccessibleEventId::SELECTION_CHANGED, aOldAny, aNewAny );
    2013                 :            :         }
    2014                 :         35 :         maHighlightHdl.Call(this);
    2015                 :            :     }
    2016                 :            : }
    2017                 :            : 
    2018                 :            : // -----------------------------------------------------------------------
    2019                 :            : 
    2020                 :          0 : void ValueSet::SetNoSelection()
    2021                 :            : {
    2022                 :          0 :     mbNoSelection   = true;
    2023                 :          0 :     mbHighlight     = false;
    2024                 :          0 :     mbSelection     = false;
    2025                 :            : 
    2026 [ #  # ][ #  # ]:          0 :     if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
    2027                 :          0 :         ImplDraw();
    2028                 :          0 : }
    2029                 :            : 
    2030                 :            : // -----------------------------------------------------------------------
    2031                 :            : 
    2032                 :          0 : void ValueSet::SetItemImage( sal_uInt16 nItemId, const Image& rImage )
    2033                 :            : {
    2034                 :          0 :     size_t nPos = GetItemPos( nItemId );
    2035                 :            : 
    2036         [ #  # ]:          0 :     if ( nPos == VALUESET_ITEM_NOTFOUND )
    2037                 :          0 :         return;
    2038                 :            : 
    2039                 :          0 :     ValueSetItem* pItem = mItemList[nPos];
    2040                 :          0 :     pItem->meType  = VALUESETITEM_IMAGE;
    2041                 :          0 :     pItem->maImage = rImage;
    2042                 :            : 
    2043 [ #  # ][ #  # ]:          0 :     if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
         [ #  # ][ #  # ]
    2044                 :            :     {
    2045         [ #  # ]:          0 :         const Rectangle aRect = ImplGetItemRect(nPos);
    2046         [ #  # ]:          0 :         ImplFormatItem( pItem, aRect );
    2047         [ #  # ]:          0 :         Invalidate( aRect );
    2048                 :            :     }
    2049                 :            :     else
    2050                 :          0 :         mbFormat = true;
    2051                 :            : }
    2052                 :            : 
    2053                 :            : // -----------------------------------------------------------------------
    2054                 :            : 
    2055                 :        141 : Image ValueSet::GetItemImage( sal_uInt16 nItemId ) const
    2056                 :            : {
    2057                 :        141 :     size_t nPos = GetItemPos( nItemId );
    2058                 :            : 
    2059         [ +  - ]:        141 :     if ( nPos != VALUESET_ITEM_NOTFOUND )
    2060                 :        141 :         return mItemList[nPos]->maImage;
    2061                 :            :     else
    2062                 :        141 :         return Image();
    2063                 :            : }
    2064                 :            : 
    2065                 :            : // -----------------------------------------------------------------------
    2066                 :            : 
    2067                 :          0 : void ValueSet::SetItemColor( sal_uInt16 nItemId, const Color& rColor )
    2068                 :            : {
    2069                 :          0 :     size_t nPos = GetItemPos( nItemId );
    2070                 :            : 
    2071         [ #  # ]:          0 :     if ( nPos == VALUESET_ITEM_NOTFOUND )
    2072                 :          0 :         return;
    2073                 :            : 
    2074                 :          0 :     ValueSetItem* pItem = mItemList[nPos];
    2075                 :          0 :     pItem->meType  = VALUESETITEM_COLOR;
    2076                 :          0 :     pItem->maColor = rColor;
    2077                 :            : 
    2078 [ #  # ][ #  # ]:          0 :     if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
         [ #  # ][ #  # ]
    2079                 :            :     {
    2080         [ #  # ]:          0 :         const Rectangle aRect = ImplGetItemRect(nPos);
    2081         [ #  # ]:          0 :         ImplFormatItem( pItem, aRect );
    2082         [ #  # ]:          0 :         Invalidate( aRect );
    2083                 :            :     }
    2084                 :            :     else
    2085                 :          0 :         mbFormat = true;
    2086                 :            : }
    2087                 :            : 
    2088                 :            : // -----------------------------------------------------------------------
    2089                 :            : 
    2090                 :          0 : Color ValueSet::GetItemColor( sal_uInt16 nItemId ) const
    2091                 :            : {
    2092                 :          0 :     size_t nPos = GetItemPos( nItemId );
    2093                 :            : 
    2094         [ #  # ]:          0 :     if ( nPos != VALUESET_ITEM_NOTFOUND )
    2095                 :          0 :         return mItemList[nPos]->maColor;
    2096                 :            :     else
    2097                 :          0 :         return Color();
    2098                 :            : }
    2099                 :            : 
    2100                 :            : // -----------------------------------------------------------------------
    2101                 :            : 
    2102                 :        396 : void ValueSet::SetItemData( sal_uInt16 nItemId, void* pData )
    2103                 :            : {
    2104                 :        396 :     size_t nPos = GetItemPos( nItemId );
    2105                 :            : 
    2106         [ -  + ]:        396 :     if ( nPos == VALUESET_ITEM_NOTFOUND )
    2107                 :        396 :         return;
    2108                 :            : 
    2109                 :        396 :     ValueSetItem* pItem = mItemList[nPos];
    2110                 :        396 :     pItem->mpData = pData;
    2111                 :            : 
    2112         [ -  + ]:        396 :     if ( pItem->meType == VALUESETITEM_USERDRAW )
    2113                 :            :     {
    2114 [ #  # ][ #  # ]:          0 :         if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
         [ #  # ][ #  # ]
    2115                 :            :         {
    2116         [ #  # ]:          0 :             const Rectangle aRect = ImplGetItemRect(nPos);
    2117         [ #  # ]:          0 :             ImplFormatItem( pItem, aRect );
    2118         [ #  # ]:          0 :             Invalidate( aRect );
    2119                 :            :         }
    2120                 :            :         else
    2121                 :          0 :             mbFormat = true;
    2122                 :            :     }
    2123                 :            : }
    2124                 :            : 
    2125                 :            : // -----------------------------------------------------------------------
    2126                 :            : 
    2127                 :        432 : void* ValueSet::GetItemData( sal_uInt16 nItemId ) const
    2128                 :            : {
    2129                 :        432 :     size_t nPos = GetItemPos( nItemId );
    2130                 :            : 
    2131         [ +  - ]:        432 :     if ( nPos != VALUESET_ITEM_NOTFOUND )
    2132                 :        432 :         return mItemList[nPos]->mpData;
    2133                 :            :     else
    2134                 :        432 :         return NULL;
    2135                 :            : }
    2136                 :            : 
    2137                 :            : // -----------------------------------------------------------------------
    2138                 :            : 
    2139                 :          0 : void ValueSet::SetItemText( sal_uInt16 nItemId, const XubString& rText )
    2140                 :            : {
    2141         [ #  # ]:          0 :     size_t nPos = GetItemPos( nItemId );
    2142                 :            : 
    2143         [ #  # ]:          0 :     if ( nPos == VALUESET_ITEM_NOTFOUND )
    2144                 :          0 :         return;
    2145                 :            : 
    2146                 :            : 
    2147                 :          0 :     ValueSetItem* pItem = mItemList[nPos];
    2148                 :            : 
    2149                 :            :     // Remember old and new name for accessibility event.
    2150                 :          0 :     ::com::sun::star::uno::Any aOldName, aNewName;
    2151         [ #  # ]:          0 :     ::rtl::OUString sString (pItem->maText);
    2152         [ #  # ]:          0 :     aOldName <<= sString;
    2153         [ #  # ]:          0 :     sString = rText;
    2154         [ #  # ]:          0 :     aNewName <<= sString;
    2155                 :            : 
    2156         [ #  # ]:          0 :     pItem->maText = rText;
    2157                 :            : 
    2158 [ #  # ][ #  # ]:          0 :     if ( !mbFormat && IsReallyVisible() && IsUpdateMode() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2159                 :            :     {
    2160                 :          0 :         sal_uInt16 nTempId = mnSelItemId;
    2161                 :            : 
    2162         [ #  # ]:          0 :         if ( mbHighlight )
    2163                 :          0 :             nTempId = mnHighItemId;
    2164                 :            : 
    2165         [ #  # ]:          0 :         if ( nTempId == nItemId )
    2166         [ #  # ]:          0 :             ImplDrawItemText( pItem->maText );
    2167                 :            :     }
    2168                 :            : 
    2169 [ #  # ][ #  # ]:          0 :     if (ImplHasAccessibleListeners())
    2170                 :            :     {
    2171                 :            :         ::com::sun::star::uno::Reference<
    2172                 :            :               ::com::sun::star::accessibility::XAccessible> xAccessible (
    2173         [ #  # ]:          0 :                   pItem->GetAccessible( mbIsTransientChildrenDisabled ) );
    2174         [ #  # ]:          0 :         static_cast<ValueItemAcc*>(xAccessible.get())->FireAccessibleEvent (
    2175                 :            :             ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED,
    2176 [ #  # ][ #  # ]:          0 :             aOldName, aNewName);
    2177                 :          0 :     }
    2178                 :            : }
    2179                 :            : 
    2180                 :            : // -----------------------------------------------------------------------
    2181                 :            : 
    2182                 :          0 : XubString ValueSet::GetItemText( sal_uInt16 nItemId ) const
    2183                 :            : {
    2184                 :          0 :     size_t nPos = GetItemPos( nItemId );
    2185                 :            : 
    2186         [ #  # ]:          0 :     if ( nPos != VALUESET_ITEM_NOTFOUND )
    2187                 :          0 :         return mItemList[nPos]->maText;
    2188                 :            :     else
    2189                 :          0 :         return XubString();
    2190                 :            : }
    2191                 :            : 
    2192                 :            : // -----------------------------------------------------------------------
    2193                 :            : 
    2194                 :         51 : void ValueSet::SetColor( const Color& rColor )
    2195                 :            : {
    2196                 :         51 :     maColor     = rColor;
    2197                 :         51 :     mbFormat    = true;
    2198 [ +  + ][ +  - ]:         51 :     if ( IsReallyVisible() && IsUpdateMode() )
                 [ +  + ]
    2199                 :         41 :         ImplDraw();
    2200                 :         51 : }
    2201                 :            : 
    2202                 :            : // -----------------------------------------------------------------------
    2203                 :            : 
    2204                 :         32 : void ValueSet::SetExtraSpacing( sal_uInt16 nNewSpacing )
    2205                 :            : {
    2206         [ -  + ]:         32 :     if ( GetStyle() & WB_ITEMBORDER )
    2207                 :            :     {
    2208                 :          0 :         mnSpacing = nNewSpacing;
    2209                 :            : 
    2210                 :          0 :         mbFormat = true;
    2211 [ #  # ][ #  # ]:          0 :         if ( IsReallyVisible() && IsUpdateMode() )
                 [ #  # ]
    2212                 :          0 :             Invalidate();
    2213                 :            :     }
    2214                 :         32 : }
    2215                 :            : 
    2216                 :            : // -----------------------------------------------------------------------
    2217                 :            : 
    2218                 :          0 : void ValueSet::StartSelection()
    2219                 :            : {
    2220                 :          0 :     mbHighlight     = true;
    2221                 :          0 :     mbSelection     = true;
    2222                 :          0 :     mnHighItemId    = mnSelItemId;
    2223                 :          0 : }
    2224                 :            : 
    2225                 :            : // -----------------------------------------------------------------------
    2226                 :            : 
    2227                 :          0 : void ValueSet::EndSelection()
    2228                 :            : {
    2229         [ #  # ]:          0 :     if ( mbHighlight )
    2230                 :            :     {
    2231         [ #  # ]:          0 :         if ( IsTracking() )
    2232                 :          0 :             EndTracking( ENDTRACK_CANCEL );
    2233                 :            : 
    2234                 :          0 :         ImplHighlightItem( mnSelItemId );
    2235                 :          0 :         mbHighlight = false;
    2236                 :            :     }
    2237                 :          0 :     mbSelection = false;
    2238                 :          0 : }
    2239                 :            : 
    2240                 :            : // -----------------------------------------------------------------------
    2241                 :            : 
    2242                 :          0 : bool ValueSet::StartDrag( const CommandEvent& rCEvt, Region& rRegion )
    2243                 :            : {
    2244         [ #  # ]:          0 :     if ( rCEvt.GetCommand() != COMMAND_STARTDRAG )
    2245                 :          0 :         return false;
    2246                 :            : 
    2247                 :            :     // if necessary abort an existing action
    2248         [ #  # ]:          0 :     EndSelection();
    2249                 :            : 
    2250                 :            :     // Check out if the the clicked on page is selected. If this is not the
    2251                 :            :     // case set it as the current item. We only check mouse actions since
    2252                 :            :     // drag-and-drop can also be triggered by the keyboard
    2253                 :            :     sal_uInt16 nSelId;
    2254         [ #  # ]:          0 :     if ( rCEvt.IsMouseEvent() )
    2255         [ #  # ]:          0 :         nSelId = GetItemId( rCEvt.GetMousePosPixel() );
    2256                 :            :     else
    2257                 :          0 :         nSelId = mnSelItemId;
    2258                 :            : 
    2259                 :            :     // don't activate dragging if no item was clicked on
    2260         [ #  # ]:          0 :     if ( !nSelId )
    2261                 :          0 :         return false;
    2262                 :            : 
    2263                 :            :     // Check out if the page was selected. If not set as current page and
    2264                 :            :     // call select.
    2265         [ #  # ]:          0 :     if ( nSelId != mnSelItemId )
    2266                 :            :     {
    2267         [ #  # ]:          0 :         SelectItem( nSelId );
    2268         [ #  # ]:          0 :         Update();
    2269         [ #  # ]:          0 :         Select();
    2270                 :            :     }
    2271                 :            : 
    2272         [ #  # ]:          0 :     Region aRegion;
    2273                 :            : 
    2274                 :            :     // assign region
    2275         [ #  # ]:          0 :     rRegion = aRegion;
    2276                 :            : 
    2277         [ #  # ]:          0 :     return true;
    2278                 :            : }
    2279                 :            : 
    2280                 :            : // -----------------------------------------------------------------------
    2281                 :            : 
    2282                 :          0 : Size ValueSet::CalcWindowSizePixel( const Size& rItemSize, sal_uInt16 nDesireCols,
    2283                 :            :                                     sal_uInt16 nDesireLines )
    2284                 :            : {
    2285                 :          0 :     size_t nCalcCols = nDesireCols;
    2286                 :          0 :     size_t nCalcLines = nDesireLines;
    2287                 :            : 
    2288         [ #  # ]:          0 :     if ( !nCalcCols )
    2289                 :            :     {
    2290         [ #  # ]:          0 :         if ( mnUserCols )
    2291                 :          0 :             nCalcCols = mnUserCols;
    2292                 :            :         else
    2293                 :          0 :             nCalcCols = 1;
    2294                 :            :     }
    2295                 :            : 
    2296         [ #  # ]:          0 :     if ( !nCalcLines )
    2297                 :            :     {
    2298                 :          0 :         nCalcLines = mnVisLines;
    2299                 :            : 
    2300         [ #  # ]:          0 :         if ( mbFormat )
    2301                 :            :         {
    2302         [ #  # ]:          0 :             if ( mnUserVisLines )
    2303                 :          0 :                 nCalcLines = mnUserVisLines;
    2304                 :            :             else
    2305                 :            :             {
    2306                 :            :                 // Floor( (M+N-1)/N )==Ceiling( M/N )
    2307                 :          0 :                 nCalcLines = (mItemList.size()+nCalcCols-1) / nCalcCols;
    2308         [ #  # ]:          0 :                 if ( !nCalcLines )
    2309                 :          0 :                     nCalcLines = 1;
    2310                 :            :             }
    2311                 :            :         }
    2312                 :            :     }
    2313                 :            : 
    2314                 :          0 :     Size        aSize( rItemSize.Width()*nCalcCols, rItemSize.Height()*nCalcLines );
    2315                 :          0 :     WinBits     nStyle = GetStyle();
    2316                 :          0 :     long        nTxtHeight = GetTextHeight();
    2317                 :            :     long        n;
    2318                 :            : 
    2319         [ #  # ]:          0 :     if ( nStyle & WB_ITEMBORDER )
    2320                 :            :     {
    2321         [ #  # ]:          0 :         if ( nStyle & WB_DOUBLEBORDER )
    2322                 :          0 :             n = ITEM_OFFSET_DOUBLE;
    2323                 :            :         else
    2324                 :          0 :             n = ITEM_OFFSET;
    2325                 :            : 
    2326                 :          0 :         aSize.Width()  += n*nCalcCols;
    2327                 :          0 :         aSize.Height() += n*nCalcLines;
    2328                 :            :     }
    2329                 :            :     else
    2330                 :          0 :         n = 0;
    2331                 :            : 
    2332         [ #  # ]:          0 :     if ( mnSpacing )
    2333                 :            :     {
    2334                 :          0 :         aSize.Width()  += mnSpacing*(nCalcCols-1);
    2335                 :          0 :         aSize.Height() += mnSpacing*(nCalcLines-1);
    2336                 :            :     }
    2337                 :            : 
    2338         [ #  # ]:          0 :     if ( nStyle & WB_NAMEFIELD )
    2339                 :            :     {
    2340                 :          0 :         aSize.Height() += nTxtHeight + NAME_OFFSET;
    2341         [ #  # ]:          0 :         if ( !(nStyle & WB_FLATVALUESET) )
    2342                 :          0 :             aSize.Height() += NAME_LINE_HEIGHT+NAME_LINE_OFF_Y;
    2343                 :            :     }
    2344                 :            : 
    2345         [ #  # ]:          0 :     if ( nStyle & WB_NONEFIELD )
    2346                 :            :     {
    2347                 :          0 :         aSize.Height() += nTxtHeight + n + mnSpacing;
    2348         [ #  # ]:          0 :         if ( nStyle & WB_RADIOSEL )
    2349                 :          0 :             aSize.Height() += 8;
    2350                 :            :     }
    2351                 :            : 
    2352                 :            :     // sum possible ScrollBar width
    2353                 :          0 :     aSize.Width() += GetScrollWidth();
    2354                 :            : 
    2355                 :          0 :     return aSize;
    2356                 :            : }
    2357                 :            : 
    2358                 :            : // -----------------------------------------------------------------------
    2359                 :            : 
    2360                 :        141 : Size ValueSet::CalcItemSizePixel( const Size& rItemSize, bool bOut ) const
    2361                 :            : {
    2362                 :        141 :     Size aSize = rItemSize;
    2363                 :            : 
    2364                 :        141 :     WinBits nStyle = GetStyle();
    2365         [ -  + ]:        141 :     if ( nStyle & WB_ITEMBORDER )
    2366                 :            :     {
    2367                 :            :         long n;
    2368                 :            : 
    2369         [ #  # ]:          0 :         if ( nStyle & WB_DOUBLEBORDER )
    2370                 :          0 :             n = ITEM_OFFSET_DOUBLE;
    2371                 :            :         else
    2372                 :          0 :             n = ITEM_OFFSET;
    2373                 :            : 
    2374         [ #  # ]:          0 :         if ( bOut )
    2375                 :            :         {
    2376                 :          0 :             aSize.Width()  += n;
    2377                 :          0 :             aSize.Height() += n;
    2378                 :            :         }
    2379                 :            :         else
    2380                 :            :         {
    2381                 :          0 :             aSize.Width()  -= n;
    2382                 :          0 :             aSize.Height() -= n;
    2383                 :            :         }
    2384                 :            :     }
    2385                 :            : 
    2386                 :        141 :     return aSize;
    2387                 :            : }
    2388                 :            : 
    2389                 :            : // -----------------------------------------------------------------------
    2390                 :            : 
    2391                 :         34 : long ValueSet::GetScrollWidth() const
    2392                 :            : {
    2393         [ -  + ]:         34 :     if ( GetStyle() & WB_VSCROLL )
    2394                 :            :     {
    2395                 :          0 :         ((ValueSet*)this)->ImplInitScrollBar();
    2396                 :          0 :         return mpScrBar->GetSizePixel().Width()+SCRBAR_OFFSET;
    2397                 :            :     }
    2398                 :            :     else
    2399                 :         34 :         return 0;
    2400                 :            : }
    2401                 :            : 
    2402                 :            : // -----------------------------------------------------------------------
    2403                 :            : 
    2404                 :          0 : void ValueSet::SetHighlightHdl( const Link& rLink )
    2405                 :            : {
    2406                 :          0 :     maHighlightHdl = rLink;
    2407                 :          0 : }
    2408                 :            : 
    2409                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10