LCOV - code coverage report
Current view: top level - svtools/source/brwbox - brwbox2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 371 1052 35.3 %
Date: 2012-08-25 Functions: 16 62 25.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 403 1529 26.4 %

           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 <svtools/brwbox.hxx>
      31                 :            : #include "datwin.hxx"
      32                 :            : #include <svtools/colorcfg.hxx>
      33                 :            : #include <vcl/salgtype.hxx>
      34                 :            : 
      35                 :            : #include <tools/multisel.hxx>
      36                 :            : #include <algorithm>
      37                 :            : 
      38                 :            : using namespace ::com::sun::star::datatransfer;
      39                 :            : 
      40                 :            : #define getDataWindow() ((BrowserDataWin*)pDataWin)
      41                 :            : 
      42                 :            : 
      43                 :            : //===================================================================
      44                 :            : 
      45                 :            : DBG_NAMEEX(BrowseBox)
      46                 :            : 
      47                 :            : //===================================================================
      48                 :            : 
      49                 :            : extern const char* BrowseBoxCheckInvariants( const void * pVoid );
      50                 :            : 
      51                 :            : //===================================================================
      52                 :            : 
      53                 :          0 : void BrowseBox::StartDrag( sal_Int8 /* _nAction */, const Point& /* _rPosPixel */ )
      54                 :            : {
      55                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
      56                 :            :     // not interested in this event
      57                 :          0 : }
      58                 :            : 
      59                 :            : //===================================================================
      60                 :            : 
      61                 :          0 : sal_Int8 BrowseBox::AcceptDrop( const AcceptDropEvent& _rEvt )
      62                 :            : {
      63                 :          0 :     BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin);
      64         [ #  # ]:          0 :     AcceptDropEvent aTransformed( _rEvt );
      65 [ #  # ][ #  # ]:          0 :     aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) );
      66 [ #  # ][ #  # ]:          0 :     return pDataWindow->AcceptDrop( aTransformed );
      67                 :            : }
      68                 :            : 
      69                 :            : //===================================================================
      70                 :            : 
      71                 :          0 : sal_Int8 BrowseBox::ExecuteDrop( const ExecuteDropEvent& _rEvt )
      72                 :            : {
      73                 :          0 :     BrowserDataWin* pDataWindow = static_cast<BrowserDataWin*>(pDataWin);
      74         [ #  # ]:          0 :     ExecuteDropEvent aTransformed( _rEvt );
      75 [ #  # ][ #  # ]:          0 :     aTransformed.maPosPixel = pDataWindow->ScreenToOutputPixel( OutputToScreenPixel( _rEvt.maPosPixel ) );
      76 [ #  # ][ #  # ]:          0 :     return pDataWindow->ExecuteDrop( aTransformed );
      77                 :            : }
      78                 :            : 
      79                 :            : //===================================================================
      80                 :            : 
      81                 :          0 : sal_Int8 BrowseBox::AcceptDrop( const BrowserAcceptDropEvent& )
      82                 :            : {
      83                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
      84                 :            :     // not interested in this event
      85                 :          0 :     return DND_ACTION_NONE;
      86                 :            : }
      87                 :            : 
      88                 :            : //===================================================================
      89                 :            : 
      90                 :          0 : sal_Int8 BrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& )
      91                 :            : {
      92                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
      93                 :            :     // not interested in this event
      94                 :          0 :     return DND_ACTION_NONE;
      95                 :            : }
      96                 :            : 
      97                 :            : //===================================================================
      98                 :            : 
      99                 :          0 : void* BrowseBox::implGetDataFlavors() const
     100                 :            : {
     101         [ #  # ]:          0 :     if (static_cast<BrowserDataWin*>(pDataWin)->bCallingDropCallback)
     102                 :          0 :         return &static_cast<BrowserDataWin*>(pDataWin)->GetDataFlavorExVector();
     103                 :          0 :     return &GetDataFlavorExVector();
     104                 :            : }
     105                 :            : 
     106                 :            : //===================================================================
     107                 :            : 
     108                 :          0 : sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat )
     109                 :            : {
     110         [ #  # ]:          0 :     if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback )
     111                 :          0 :         return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _nFormat );
     112                 :            : 
     113                 :          0 :     return DropTargetHelper::IsDropFormatSupported( _nFormat );
     114                 :            : }
     115                 :            : 
     116                 :            : //===================================================================
     117                 :            : 
     118                 :          0 : sal_Bool BrowseBox::IsDropFormatSupported( SotFormatStringId _nFormat ) const
     119                 :            : {
     120                 :          0 :     return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _nFormat );
     121                 :            : }
     122                 :            : 
     123                 :            : //===================================================================
     124                 :            : 
     125                 :          0 : sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor )
     126                 :            : {
     127         [ #  # ]:          0 :     if ( static_cast< BrowserDataWin* >( pDataWin )->bCallingDropCallback )
     128                 :          0 :         return static_cast< BrowserDataWin* >( pDataWin )->IsDropFormatSupported( _rFlavor );
     129                 :            : 
     130                 :          0 :     return DropTargetHelper::IsDropFormatSupported( _rFlavor );
     131                 :            : }
     132                 :            : 
     133                 :            : //===================================================================
     134                 :            : 
     135                 :          0 : sal_Bool BrowseBox::IsDropFormatSupported( const DataFlavor& _rFlavor ) const
     136                 :            : {
     137                 :          0 :     return const_cast< BrowseBox* >( this )->IsDropFormatSupported( _rFlavor );
     138                 :            : }
     139                 :            : 
     140                 :            : //===================================================================
     141                 :            : 
     142                 :          0 : void BrowseBox::Command( const CommandEvent& rEvt )
     143                 :            : {
     144         [ #  # ]:          0 :     if ( !getDataWindow()->bInCommand )
     145                 :          0 :         Control::Command( rEvt );
     146                 :          0 : }
     147                 :            : 
     148                 :            : //===================================================================
     149                 :            : 
     150                 :        557 : void BrowseBox::StateChanged( StateChangedType nStateChange )
     151                 :            : {
     152                 :        557 :     Control::StateChanged( nStateChange );
     153                 :            : 
     154         [ +  + ]:        557 :     if ( STATE_CHANGE_MIRRORING == nStateChange )
     155                 :            :     {
     156                 :         98 :         getDataWindow()->EnableRTL( IsRTLEnabled() );
     157                 :            : 
     158                 :         98 :         HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar;
     159         [ +  - ]:         98 :         if ( pHeaderBar )
     160                 :         98 :             pHeaderBar->EnableRTL( IsRTLEnabled() );
     161                 :         98 :         aHScroll.EnableRTL( IsRTLEnabled() );
     162         [ +  - ]:         98 :         if( pVScroll )
     163                 :         98 :             pVScroll->EnableRTL( IsRTLEnabled() );
     164                 :         98 :         Resize();
     165                 :            :     }
     166         [ +  + ]:        459 :     else if ( STATE_CHANGE_INITSHOW == nStateChange )
     167                 :            :     {
     168                 :         67 :         bBootstrapped = sal_True; // must be set first!
     169                 :            : 
     170                 :         67 :         Resize();
     171         [ +  - ]:         67 :         if ( bMultiSelection )
     172         [ +  - ]:         67 :             uRow.pSel->SetTotalRange( Range( 0, nRowCount - 1 ) );
     173         [ +  + ]:         67 :         if ( nRowCount == 0 )
     174                 :         65 :             nCurRow = BROWSER_ENDOFSELECTION;
     175         [ -  + ]:          2 :         else if ( nCurRow == BROWSER_ENDOFSELECTION )
     176                 :          0 :             nCurRow = 0;
     177                 :            : 
     178                 :            : 
     179         [ -  + ]:         67 :         if ( HasFocus() )
     180                 :            :         {
     181                 :          0 :             bSelectionIsVisible = sal_True;
     182                 :          0 :             bHasFocus = sal_True;
     183                 :            :         }
     184                 :         67 :         UpdateScrollbars();
     185                 :         67 :         AutoSizeLastColumn();
     186                 :         67 :         CursorMoved();
     187                 :            :     }
     188         [ -  + ]:        392 :     else if (STATE_CHANGE_ZOOM == nStateChange)
     189                 :            :     {
     190                 :          0 :         pDataWin->SetZoom(GetZoom());
     191                 :          0 :         HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar;
     192         [ #  # ]:          0 :         if (pHeaderBar)
     193                 :          0 :             pHeaderBar->SetZoom(GetZoom());
     194                 :            : 
     195                 :            :         // let the columns calculate their new widths and adjust the header bar
     196         [ #  # ]:          0 :         for ( size_t nPos = 0; nPos < pCols->size(); ++nPos )
     197                 :            :         {
     198                 :          0 :             (*pCols)[ nPos ]->ZoomChanged(GetZoom());
     199         [ #  # ]:          0 :             if ( pHeaderBar )
     200                 :          0 :                 pHeaderBar->SetItemSize( (*pCols)[ nPos ]->GetId(), (*pCols)[ nPos ]->Width() );
     201                 :            :         }
     202                 :            : 
     203                 :            :         // all our controls have to be repositioned
     204                 :          0 :         Resize();
     205                 :            :     }
     206         [ +  + ]:        392 :     else if (STATE_CHANGE_ENABLE == nStateChange)
     207                 :            :     {
     208                 :            :         // do we have a handle column?
     209 [ +  - ][ +  - ]:         12 :         sal_Bool bHandleCol = !pCols->empty() && (0 == (*pCols)[ 0 ]->GetId());
     210                 :            :         // do we have a header bar?
     211                 :         12 :         sal_Bool bHeaderBar = (NULL != static_cast<BrowserDataWin&>(GetDataWindow()).pHeaderBar);
     212                 :            : 
     213 [ +  - ][ +  - ]:         12 :         if  (   nTitleLines
                 [ +  - ]
     214                 :            :             &&  (   !bHeaderBar
     215                 :            :                 ||  bHandleCol
     216                 :            :                 )
     217                 :            :             )
     218                 :            :             // we draw the text in our header bar in a color dependent on the enabled state. So if this state changed
     219                 :            :             // -> redraw
     220 [ +  - ][ +  - ]:         12 :             Invalidate(Rectangle(Point(0, 0), Size(GetOutputSizePixel().Width(), GetTitleHeight() - 1)));
     221                 :            :     }
     222                 :        557 : }
     223                 :            : 
     224                 :            : //===================================================================
     225                 :            : 
     226                 :          0 : void BrowseBox::Select()
     227                 :            : {
     228                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     229                 :          0 : }
     230                 :            : 
     231                 :            : //-------------------------------------------------------------------
     232                 :            : 
     233                 :          0 : void BrowseBox::DoubleClick( const BrowserMouseEvent & )
     234                 :            : {
     235                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     236                 :          0 : }
     237                 :            : 
     238                 :            : //-------------------------------------------------------------------
     239                 :            : 
     240                 :          0 : long BrowseBox::QueryMinimumRowHeight()
     241                 :            : {
     242                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     243                 :          0 :     return CalcZoom( 5 );
     244                 :            : }
     245                 :            : 
     246                 :            : //-------------------------------------------------------------------
     247                 :            : 
     248                 :          0 : void BrowseBox::ImplStartTracking()
     249                 :            : {
     250                 :            :     DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants );
     251                 :          0 : }
     252                 :            : 
     253                 :            : //-------------------------------------------------------------------
     254                 :            : 
     255                 :          0 : void BrowseBox::ImplTracking()
     256                 :            : {
     257                 :            :     DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants );
     258                 :          0 : }
     259                 :            : 
     260                 :            : //-------------------------------------------------------------------
     261                 :            : 
     262                 :          0 : void BrowseBox::ImplEndTracking()
     263                 :            : {
     264                 :            :     DBG_CHKTHIS( BrowseBox, BrowseBoxCheckInvariants );
     265                 :          0 : }
     266                 :            : 
     267                 :            : //-------------------------------------------------------------------
     268                 :            : 
     269                 :          0 : void BrowseBox::RowHeightChanged()
     270                 :            : {
     271                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     272                 :          0 : }
     273                 :            : 
     274                 :            : //-------------------------------------------------------------------
     275                 :            : 
     276                 :          0 : long BrowseBox::QueryColumnResize( sal_uInt16, long nWidth )
     277                 :            : {
     278                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     279                 :          0 :     return nWidth;
     280                 :            : }
     281                 :            : 
     282                 :            : //-------------------------------------------------------------------
     283                 :            : 
     284                 :          0 : void BrowseBox::ColumnResized( sal_uInt16 )
     285                 :            : {
     286                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     287                 :          0 : }
     288                 :            : 
     289                 :            : //-------------------------------------------------------------------
     290                 :            : 
     291                 :          0 : void BrowseBox::ColumnMoved( sal_uInt16 )
     292                 :            : {
     293                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     294                 :          0 : }
     295                 :            : 
     296                 :            : //-------------------------------------------------------------------
     297                 :            : 
     298                 :          0 : void BrowseBox::StartScroll()
     299                 :            : {
     300                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     301                 :          0 :     DoHideCursor( "StartScroll" );
     302                 :          0 : }
     303                 :            : 
     304                 :            : //-------------------------------------------------------------------
     305                 :            : 
     306                 :          0 : void BrowseBox::EndScroll()
     307                 :            : {
     308                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     309                 :          0 :     UpdateScrollbars();
     310                 :          0 :     AutoSizeLastColumn();
     311                 :          0 :     DoShowCursor( "EndScroll" );
     312                 :          0 : }
     313                 :            : 
     314                 :            : //-------------------------------------------------------------------
     315                 :            : 
     316                 :            : #ifdef _MSC_VER
     317                 :            : #pragma optimize( "", off )
     318                 :            : #endif
     319                 :            : 
     320                 :          0 : void BrowseBox::ToggleSelection( sal_Bool bForce )
     321                 :            : {
     322                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     323                 :            : 
     324                 :            :     // selection highlight-toggling allowed?
     325         [ #  # ]:          0 :     if ( bHideSelect )
     326                 :            :         return;
     327 [ #  # ][ #  # ]:          0 :     if ( !bForce &&
         [ #  # ][ #  # ]
                 [ #  # ]
     328         [ #  # ]:          0 :          ( bNotToggleSel || !IsUpdateMode() || !bSelectionIsVisible ) )
     329                 :            :         return;
     330                 :            : 
     331                 :            :     // only highlight painted areas!
     332                 :          0 :     bNotToggleSel = sal_True;
     333                 :            :     if ( sal_False && !getDataWindow()->bInPaint )
     334                 :            :         pDataWin->Update();
     335                 :            : 
     336                 :            :     // accumulate areas of rows to highlight
     337         [ #  # ]:          0 :     RectangleList aHighlightList;
     338                 :          0 :     long nLastRowInRect = 0; // for the CFront
     339                 :            : 
     340                 :            :     // don't highlight handle column
     341         [ #  # ]:          0 :     BrowserColumn *pFirstCol = pCols->empty() ? NULL : (*pCols)[ 0 ];
     342 [ #  # ][ #  # ]:          0 :     long nOfsX = (!pFirstCol || pFirstCol->GetId()) ? 0 : pFirstCol->Width();
     343                 :            : 
     344                 :            :     // accumulate old row selection
     345                 :            :     long nBottomRow = nTopRow +
     346         [ #  # ]:          0 :         pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight();
     347 [ #  # ][ #  # ]:          0 :     if ( nBottomRow > GetRowCount() && GetRowCount() )
         [ #  # ][ #  # ]
                 [ #  # ]
     348         [ #  # ]:          0 :         nBottomRow = GetRowCount();
     349 [ #  # ][ #  # ]:          0 :     for ( long nRow = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     350                 :            :           nRow != BROWSER_ENDOFSELECTION && nRow <= nBottomRow;
     351                 :          0 :           nRow = bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION )
     352                 :            :     {
     353         [ #  # ]:          0 :         if ( nRow < nTopRow )
     354                 :          0 :             continue;
     355                 :            : 
     356                 :            :         Rectangle aAddRect(
     357         [ #  # ]:          0 :             Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
     358 [ #  # ][ #  # ]:          0 :             Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
                 [ #  # ]
     359 [ #  # ][ #  # ]:          0 :         if ( aHighlightList.size() && nLastRowInRect == ( nRow - 1 ) )
                 [ #  # ]
     360 [ #  # ][ #  # ]:          0 :             aHighlightList[ 0 ]->Union( aAddRect );
     361                 :            :         else
     362 [ #  # ][ #  # ]:          0 :             aHighlightList.insert( aHighlightList.begin(), new Rectangle( aAddRect ) );
     363                 :          0 :         nLastRowInRect = nRow;
     364                 :            :     }
     365                 :            : 
     366                 :            :     // unhighlight the old selection (if any)
     367         [ #  # ]:          0 :     for ( size_t i = aHighlightList.size(); i > 0; )
     368                 :            :     {
     369         [ #  # ]:          0 :         Rectangle *pRect = aHighlightList[ --i ];
     370         [ #  # ]:          0 :         pDataWin->Invalidate( *pRect );
     371                 :          0 :         delete pRect;
     372                 :            :     }
     373                 :          0 :     aHighlightList.clear();
     374                 :            : 
     375                 :            :     // unhighlight old column selection (if any)
     376 [ #  # ][ #  # ]:          0 :     for ( long nColId = pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION;
         [ #  # ][ #  # ]
     377                 :            :           nColId != BROWSER_ENDOFSELECTION;
     378                 :          0 :           nColId = pColSel->NextSelected() )
     379                 :            :     {
     380                 :            :         Rectangle aRect( GetFieldRectPixel(nCurRow,
     381                 :          0 :                                            (*pCols)[ nColId ]->GetId(),
     382         [ #  # ]:          0 :                                            sal_False ) );
     383                 :          0 :         aRect.Left() -= MIN_COLUMNWIDTH;
     384                 :          0 :         aRect.Right() += MIN_COLUMNWIDTH;
     385                 :          0 :         aRect.Top() = 0;
     386                 :          0 :         aRect.Bottom() = pDataWin->GetOutputSizePixel().Height();
     387         [ #  # ]:          0 :         pDataWin->Invalidate( aRect );
     388                 :            :     }
     389                 :            : 
     390                 :          0 :     bNotToggleSel = sal_False;
     391                 :            : }
     392                 :            : 
     393                 :            : #ifdef _MSC_VER
     394                 :            : #pragma optimize( "", on )
     395                 :            : #endif
     396                 :            : 
     397                 :            : //-------------------------------------------------------------------
     398                 :            : 
     399                 :        264 : void BrowseBox::DrawCursor()
     400                 :            : {
     401                 :        264 :     sal_Bool bReallyHide = sal_False;
     402         [ -  + ]:        264 :     if ( SMART_CURSOR_HIDE == bHideCursor )
     403                 :            :     {
     404 [ #  # ][ #  # ]:          0 :         if ( !GetSelectRowCount() && !GetSelectColumnCount() )
         [ #  # ][ #  # ]
                 [ #  # ]
     405                 :          0 :             bReallyHide = sal_True;
     406                 :            :     }
     407         [ -  + ]:        264 :     else if ( HARD_CURSOR_HIDE == bHideCursor )
     408                 :            :     {
     409                 :          0 :         bReallyHide = sal_True;
     410                 :            :     }
     411                 :            : 
     412 [ +  - ][ +  - ]:        264 :     bReallyHide |= !bSelectionIsVisible || !IsUpdateMode() || bScrolling || nCurRow < 0;
         [ +  + ][ +  - ]
                 [ +  - ]
     413                 :            : 
     414 [ +  - ][ +  - ]:        264 :     if (PaintCursorIfHiddenOnce())
     415         [ +  - ]:        264 :         bReallyHide |= ( GetCursorHideCount() > 1 );
     416                 :            :     else
     417         [ #  # ]:          0 :         bReallyHide |= ( GetCursorHideCount() > 0 );
     418                 :            : 
     419                 :            :     // no cursor on handle column
     420         [ -  + ]:        264 :     if ( nCurColId == HandleColumnId )
     421         [ #  # ]:          0 :         nCurColId = GetColumnId(1);
     422                 :            : 
     423                 :            :     // calculate cursor rectangle
     424         [ +  - ]:        264 :     Rectangle aCursor;
     425         [ +  - ]:        264 :     if ( bColumnCursor )
     426                 :            :     {
     427         [ +  - ]:        264 :         aCursor = GetFieldRectPixel( nCurRow, nCurColId, sal_False );
     428                 :        264 :         aCursor.Left() -= MIN_COLUMNWIDTH;
     429                 :        264 :         aCursor.Right() += 1;
     430                 :        264 :         aCursor.Bottom() += 1;
     431                 :            :     }
     432                 :            :     else
     433                 :            :         aCursor = Rectangle(
     434                 :          0 :             Point( ( !pCols->empty() && (*pCols)[ 0 ]->GetId() == 0 ) ?
     435                 :          0 :                         (*pCols)[ 0 ]->Width() : 0,
     436         [ #  # ]:          0 :                         (nCurRow - nTopRow) * GetDataRowHeight() + 1 ),
     437                 :          0 :             Size( pDataWin->GetOutputSizePixel().Width() + 1,
     438   [ #  #  #  #  :          0 :                   GetDataRowHeight() - 2 ) );
           #  # ][ #  # ]
     439         [ +  - ]:        264 :     if ( bHLines )
     440                 :            :     {
     441         [ -  + ]:        264 :         if ( !bMultiSelection )
     442                 :          0 :             --aCursor.Top();
     443                 :        264 :         --aCursor.Bottom();
     444                 :            :     }
     445                 :            : 
     446         [ +  + ]:        264 :     if (m_aCursorColor == COL_TRANSPARENT)
     447                 :            :     {
     448                 :            :         // on these platforms, the StarView focus works correctly
     449         [ +  - ]:        240 :         if ( bReallyHide )
     450         [ +  - ]:        240 :             ((Control*)pDataWin)->HideFocus();
     451                 :            :         else
     452         [ #  # ]:          0 :             ((Control*)pDataWin)->ShowFocus( aCursor );
     453                 :            :     }
     454                 :            :     else
     455                 :            :     {
     456         [ +  - ]:         24 :         Color rCol = bReallyHide ? pDataWin->GetFillColor() : m_aCursorColor;
     457                 :         24 :         Color aOldFillColor = pDataWin->GetFillColor();
     458                 :         24 :         Color aOldLineColor = pDataWin->GetLineColor();
     459         [ +  - ]:         24 :         pDataWin->SetFillColor();
     460         [ +  - ]:         24 :         pDataWin->SetLineColor( rCol );
     461         [ +  - ]:         24 :         pDataWin->DrawRect( aCursor );
     462         [ +  - ]:         24 :         pDataWin->SetLineColor( aOldLineColor );
     463         [ +  - ]:         24 :         pDataWin->SetFillColor( aOldFillColor );
     464                 :            :     }
     465                 :        264 : }
     466                 :            : 
     467                 :            : //-------------------------------------------------------------------
     468                 :            : 
     469                 :          0 : sal_uLong BrowseBox::GetColumnWidth( sal_uInt16 nId ) const
     470                 :            : {
     471                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     472                 :            : 
     473                 :          0 :     sal_uInt16 nItemPos = GetColumnPos( nId );
     474         [ #  # ]:          0 :     if ( nItemPos >= pCols->size() )
     475                 :          0 :         return 0;
     476                 :          0 :     return (*pCols)[ nItemPos ]->Width();
     477                 :            : }
     478                 :            : 
     479                 :            : //-------------------------------------------------------------------
     480                 :            : 
     481                 :        161 : sal_uInt16 BrowseBox::GetColumnId( sal_uInt16 nPos ) const
     482                 :            : {
     483                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     484                 :            : 
     485         [ +  + ]:        161 :     if ( nPos >= pCols->size() )
     486                 :         40 :         return BROWSER_INVALIDID;
     487                 :        161 :     return (*pCols)[ nPos ]->GetId();
     488                 :            : }
     489                 :            : 
     490                 :            : //-------------------------------------------------------------------
     491                 :            : 
     492                 :        319 : sal_uInt16 BrowseBox::GetColumnPos( sal_uInt16 nId ) const
     493                 :            : {
     494                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     495                 :            : 
     496         [ +  + ]:       1884 :     for ( sal_uInt16 nPos = 0; nPos < pCols->size(); ++nPos )
     497         [ +  + ]:       1882 :         if ( (*pCols)[ nPos ]->GetId() == nId )
     498                 :        317 :             return nPos;
     499                 :        319 :     return BROWSER_INVALIDID;
     500                 :            : }
     501                 :            : 
     502                 :            : //-------------------------------------------------------------------
     503                 :            : 
     504                 :          0 : sal_Bool BrowseBox::IsFrozen( sal_uInt16 nColumnId ) const
     505                 :            : {
     506                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     507                 :            : 
     508         [ #  # ]:          0 :     for ( size_t nPos = 0; nPos < pCols->size(); ++nPos )
     509         [ #  # ]:          0 :         if ( (*pCols)[ nPos ]->GetId() == nColumnId )
     510                 :          0 :             return (*pCols)[ nPos ]->IsFrozen();
     511                 :          0 :     return sal_False;
     512                 :            : }
     513                 :            : 
     514                 :            : //-------------------------------------------------------------------
     515                 :            : 
     516                 :          0 : void BrowseBox::ExpandRowSelection( const BrowserMouseEvent& rEvt )
     517                 :            : {
     518                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     519                 :            : 
     520                 :          0 :     DoHideCursor( "ExpandRowSelection" );
     521                 :            : 
     522                 :            :     // expand the last selection
     523         [ #  # ]:          0 :     if ( bMultiSelection )
     524                 :            :     {
     525                 :          0 :         Range aJustifiedRange( aSelRange );
     526                 :          0 :         aJustifiedRange.Justify();
     527                 :            : 
     528                 :          0 :         sal_Bool bSelectThis = ( bSelect != aJustifiedRange.IsInside( rEvt.GetRow() ) );
     529                 :            : 
     530         [ #  # ]:          0 :         if ( aJustifiedRange.IsInside( rEvt.GetRow() ) )
     531                 :            :         {
     532                 :            :             // down and up
     533         [ #  # ]:          0 :             while ( rEvt.GetRow() < aSelRange.Max() )
     534                 :            :             {   // ZTC/Mac bug - don't put these statements together!
     535         [ #  # ]:          0 :                 SelectRow( aSelRange.Max(), bSelectThis, sal_True );
     536                 :          0 :                 --aSelRange.Max();
     537                 :            :             }
     538         [ #  # ]:          0 :             while ( rEvt.GetRow() > aSelRange.Max() )
     539                 :            :             {   // ZTC/Mac bug - don't put these statements together!
     540         [ #  # ]:          0 :                 SelectRow( aSelRange.Max(), bSelectThis, sal_True );
     541                 :          0 :                 ++aSelRange.Max();
     542                 :            :             }
     543                 :            :         }
     544                 :            :         else
     545                 :            :         {
     546                 :            :             // up and down
     547                 :          0 :             sal_Bool bOldSelecting = bSelecting;
     548                 :          0 :             bSelecting = sal_True;
     549         [ #  # ]:          0 :             while ( rEvt.GetRow() < aSelRange.Max() )
     550                 :            :             {   // ZTC/Mac bug - don't put these statements together!
     551                 :          0 :                 --aSelRange.Max();
     552 [ #  # ][ #  # ]:          0 :                 if ( !IsRowSelected( aSelRange.Max() ) )
     553                 :            :                 {
     554         [ #  # ]:          0 :                     SelectRow( aSelRange.Max(), bSelectThis, sal_True );
     555                 :          0 :                     bSelect = sal_True;
     556                 :            :                 }
     557                 :            :             }
     558         [ #  # ]:          0 :             while ( rEvt.GetRow() > aSelRange.Max() )
     559                 :            :             {   // ZTC/Mac bug - don't put these statements together!
     560                 :          0 :                 ++aSelRange.Max();
     561 [ #  # ][ #  # ]:          0 :                 if ( !IsRowSelected( aSelRange.Max() ) )
     562                 :            :                 {
     563         [ #  # ]:          0 :                     SelectRow( aSelRange.Max(), bSelectThis, sal_True );
     564                 :          0 :                     bSelect = sal_True;
     565                 :            :                 }
     566                 :            :             }
     567                 :          0 :             bSelecting = bOldSelecting;
     568         [ #  # ]:          0 :             if ( bSelect )
     569         [ #  # ]:          0 :                 Select();
     570                 :            :         }
     571                 :            :     }
     572                 :            :     else
     573 [ #  # ][ #  # ]:          0 :         if ( !bMultiSelection || !IsRowSelected( rEvt.GetRow() ) )
                 [ #  # ]
     574                 :          0 :             SelectRow( rEvt.GetRow(), sal_True );
     575                 :            : 
     576                 :          0 :     GoToRow( rEvt.GetRow(), sal_False );
     577                 :          0 :     DoShowCursor( "ExpandRowSelection" );
     578                 :          0 : }
     579                 :            : 
     580                 :            : //-------------------------------------------------------------------
     581                 :            : 
     582                 :        497 : void BrowseBox::Resize()
     583                 :            : {
     584                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     585 [ +  + ][ +  - ]:        497 :     if ( !bBootstrapped && IsReallyVisible() )
         [ -  + ][ -  + ]
     586         [ #  # ]:          0 :         BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
     587         [ -  + ]:        497 :     if ( pCols->empty() )
     588                 :            :     {
     589                 :          0 :         getDataWindow()->bResizeOnPaint = sal_True;
     590                 :        497 :         return;
     591                 :            :     }
     592                 :        497 :     getDataWindow()->bResizeOnPaint = sal_False;
     593                 :            : 
     594                 :            :     // calc the size of the scrollbars
     595                 :            :     // (we can't ask the scrollbars for their widths cause if we're zoomed they still have to be
     596                 :            :     // resized - which is done in UpdateScrollbars)
     597                 :        497 :     sal_uLong nSBSize = GetSettings().GetStyleSettings().GetScrollBarSize();
     598 [ -  + ][ +  - ]:        497 :     if (IsZoom())
     599 [ #  # ][ #  # ]:          0 :         nSBSize = (sal_uLong)(nSBSize * (double)GetZoom());
     600                 :            : 
     601         [ +  - ]:        497 :     DoHideCursor( "Resize" );
     602                 :        497 :     sal_uInt16 nOldVisibleRows = 0;
     603                 :            :     //fdo#42694, post #i111125# GetDataRowHeight() can be 0
     604 [ +  - ][ +  - ]:        497 :     if (GetDataRowHeight())
     605         [ +  - ]:        497 :         nOldVisibleRows = (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
     606                 :            : 
     607                 :            :     // did we need a horizontal scroll bar or is there a Control Area?
     608 [ +  - ][ +  + ]:        994 :     if ( !getDataWindow()->bNoHScroll &&
                 [ +  + ]
     609         [ +  - ]:        497 :          ( ( pCols->size() - FrozenColCount() ) > 1 ) )
     610         [ +  - ]:        245 :         aHScroll.Show();
     611                 :            :     else
     612         [ +  - ]:        252 :         aHScroll.Hide();
     613                 :            : 
     614                 :            :     // calculate the size of the data window
     615         [ +  - ]:        497 :     long nDataHeight = GetOutputSizePixel().Height() - GetTitleHeight();
     616 [ +  - ][ +  + ]:        497 :     if ( aHScroll.IsVisible() || ( nControlAreaWidth != USHRT_MAX ) )
         [ +  + ][ +  + ]
     617                 :        271 :         nDataHeight -= nSBSize;
     618                 :            : 
     619                 :        497 :     long nDataWidth = GetOutputSizePixel().Width();
     620 [ +  + ][ +  - ]:        497 :     if ( pVScroll->IsVisible() )
     621                 :         74 :         nDataWidth -= nSBSize;
     622                 :            : 
     623                 :            :     // adjust position and size of data window
     624                 :            :     pDataWin->SetPosSizePixel(
     625                 :        497 :         Point( 0, GetTitleHeight() ),
     626 [ +  - ][ +  - ]:        497 :         Size( nDataWidth, nDataHeight ) );
     627                 :            : 
     628                 :        497 :     sal_uInt16 nVisibleRows = 0;
     629                 :            : 
     630 [ +  - ][ +  - ]:        497 :     if (GetDataRowHeight())
     631         [ +  - ]:        497 :         nVisibleRows = (sal_uInt16)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
     632                 :            : 
     633                 :            :     // TopRow is unchanged, but the number of visible lines has changed.
     634         [ +  + ]:        497 :     if ( nVisibleRows != nOldVisibleRows )
     635         [ +  - ]:        115 :         VisibleRowsChanged(nTopRow, nVisibleRows);
     636                 :            : 
     637         [ +  - ]:        497 :     UpdateScrollbars();
     638                 :            : 
     639                 :            :     // Control-Area
     640         [ +  - ]:        497 :     Rectangle aInvalidArea( GetControlArea() );
     641                 :        497 :     aInvalidArea.Right() = GetOutputSizePixel().Width();
     642                 :        497 :     aInvalidArea.Left() = 0;
     643         [ +  - ]:        497 :     Invalidate( aInvalidArea );
     644                 :            : 
     645                 :            :     // external header-bar
     646                 :        497 :     HeaderBar* pHeaderBar = getDataWindow()->pHeaderBar;
     647         [ +  - ]:        497 :     if ( pHeaderBar )
     648                 :            :     {
     649                 :            :         // take the handle column into account
     650                 :        497 :         BrowserColumn *pFirstCol = (*pCols)[ 0 ];
     651         [ +  - ]:        497 :         long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
     652 [ +  - ][ +  - ]:        497 :         pHeaderBar->SetPosSizePixel( Point( nOfsX, 0 ), Size( GetOutputSizePixel().Width() - nOfsX, GetTitleHeight() ) );
     653                 :            :     }
     654                 :            : 
     655         [ +  - ]:        497 :     AutoSizeLastColumn(); // adjust last column width
     656         [ +  - ]:        497 :     DoShowCursor( "Resize" );
     657                 :            : }
     658                 :            : 
     659                 :            : //-------------------------------------------------------------------
     660                 :            : 
     661                 :        118 : void BrowseBox::Paint( const Rectangle& rRect )
     662                 :            : {
     663                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
     664                 :            : 
     665                 :            :     // initializations
     666 [ +  + ][ +  - ]:        118 :     if ( !bBootstrapped && IsReallyVisible() )
                 [ +  + ]
     667                 :          8 :         BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
     668         [ -  + ]:        118 :     if ( pCols->empty() )
     669                 :        118 :         return;
     670                 :            : 
     671                 :        118 :     BrowserColumn *pFirstCol = (*pCols)[ 0 ];
     672 [ +  - ][ +  - ]:        118 :     sal_Bool bHandleCol = pFirstCol && pFirstCol->GetId() == 0;
     673                 :        118 :     sal_Bool bHeaderBar = getDataWindow()->pHeaderBar != NULL;
     674                 :            : 
     675                 :            :     // draw delimitational lines
     676         [ +  - ]:        118 :     if ( !getDataWindow()->bNoHScroll )
     677         [ +  - ]:        118 :         DrawLine( Point( 0, aHScroll.GetPosPixel().Y() ),
     678                 :        118 :                   Point( GetOutputSizePixel().Width(),
     679         [ +  - ]:        354 :                          aHScroll.GetPosPixel().Y() ) );
     680                 :            : 
     681         [ +  - ]:        118 :     if ( nTitleLines )
     682                 :            :     {
     683         [ -  + ]:        118 :         if ( !bHeaderBar )
     684         [ #  # ]:          0 :             DrawLine( Point( 0, GetTitleHeight() - 1 ),
     685                 :          0 :                       Point( GetOutputSizePixel().Width(),
     686         [ #  # ]:          0 :                              GetTitleHeight() - 1 ) );
     687         [ +  - ]:        118 :         else if ( bHandleCol )
     688         [ +  - ]:        118 :             DrawLine( Point( 0, GetTitleHeight() - 1 ),
     689         [ +  - ]:        236 :                       Point( pFirstCol->Width(), GetTitleHeight() - 1 ) );
     690                 :            :     }
     691                 :            : 
     692                 :            :     // Title Bar
     693                 :            :     // If there is a handle column and if the  header bar is available, only
     694                 :            :     // take the HandleColumn into account
     695 [ +  - ][ +  - ]:        118 :     if ( nTitleLines && (!bHeaderBar || bHandleCol) )
                 [ +  - ]
     696                 :            :     {
     697                 :            :         // iterate through columns to redraw
     698                 :        118 :         long nX = 0;
     699                 :            :         size_t nCol;
     700   [ +  +  +  - ]:        670 :         for ( nCol = 0;
                 [ +  + ]
     701                 :        434 :               nCol < pCols->size() && nX < rRect.Right();
     702                 :            :               ++nCol )
     703                 :            :         {
     704                 :            :             // skip invisible columns between frozen and scrollable area
     705 [ +  + ][ -  + ]:        198 :             if ( nCol < nFirstCol && !(*pCols)[ nCol ]->IsFrozen() )
                 [ -  + ]
     706                 :          0 :                 nCol = nFirstCol;
     707                 :            : 
     708                 :            :             // only the handle column?
     709 [ +  - ][ +  - ]:        198 :             if (bHeaderBar && bHandleCol && nCol > 0)
                 [ +  + ]
     710                 :         80 :                 break;
     711                 :            : 
     712                 :        118 :             BrowserColumn *pCol = (*pCols)[ nCol ];
     713                 :            : 
     714                 :            :             // draw the column and increment position
     715         [ +  + ]:        118 :             if ( pCol->Width() > 4 )
     716                 :            :             {
     717                 :            :                 ButtonFrame aButtonFrame( Point( nX, 0 ),
     718         [ +  - ]:         78 :                     Size( pCol->Width()-1, GetTitleHeight()-1 ),
     719 [ +  - ][ +  - ]:        156 :                     pCol->Title(), sal_False, sal_False, !IsEnabled());
     720         [ +  - ]:         78 :                 aButtonFrame.Draw( *this );
     721                 :         78 :                 DrawLine( Point( nX + pCol->Width() - 1, 0 ),
     722 [ +  - ][ +  - ]:        156 :                    Point( nX + pCol->Width() - 1, GetTitleHeight()-1 ) );
                 [ +  - ]
     723                 :            :             }
     724                 :            :             else
     725                 :            :             {
     726                 :         40 :                 Color aOldFillColor = GetFillColor();
     727         [ +  - ]:         40 :                 SetFillColor( Color( COL_BLACK ) );
     728 [ +  - ][ +  - ]:         40 :                 DrawRect( Rectangle( Point( nX, 0 ), Size( pCol->Width(), GetTitleHeight() - 1 ) ) );
                 [ +  - ]
     729         [ +  - ]:         40 :                 SetFillColor( aOldFillColor );
     730                 :            :             }
     731                 :            : 
     732                 :            :             // skip column
     733                 :        118 :             nX += pCol->Width();
     734                 :            :         }
     735                 :            : 
     736                 :            :         // retouching
     737 [ -  + ][ #  # ]:        118 :         if ( !bHeaderBar && nCol == pCols->size() )
                 [ -  + ]
     738                 :            :         {
     739                 :          0 :             const StyleSettings &rSettings = GetSettings().GetStyleSettings();
     740                 :          0 :             Color aColFace( rSettings.GetFaceColor() );
     741                 :          0 :             Color aOldFillColor = GetFillColor();
     742                 :          0 :             Color aOldLineColor = GetLineColor();
     743         [ #  # ]:          0 :             SetFillColor( aColFace );
     744         [ #  # ]:          0 :             SetLineColor( aColFace );
     745                 :            :             DrawRect( Rectangle(
     746                 :            :                 Point( nX, 0 ),
     747 [ #  # ][ #  # ]:          0 :                 Point( rRect.Right(), GetTitleHeight() - 2 ) ) );
                 [ #  # ]
     748         [ #  # ]:          0 :             SetFillColor( aOldFillColor);
     749         [ #  # ]:          0 :             SetLineColor( aOldLineColor);
     750                 :            :         }
     751                 :            :     }
     752                 :            : }
     753                 :            : 
     754                 :            : //-------------------------------------------------------------------
     755                 :            : 
     756                 :         16 : void BrowseBox::PaintRow( OutputDevice&, const Rectangle& )
     757                 :            : {
     758                 :         16 : }
     759                 :            : 
     760                 :            : //-------------------------------------------------------------------
     761                 :            : 
     762                 :          0 : void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags )
     763                 :            : {
     764                 :          0 :     sal_Bool bDrawSelection = (nFlags & WINDOW_DRAW_NOSELECTION) == 0;
     765                 :            : 
     766                 :            :     // we need pixel coordinates
     767         [ #  # ]:          0 :     Size aRealSize = pDev->LogicToPixel(rSize);
     768         [ #  # ]:          0 :     Point aRealPos = pDev->LogicToPixel(rPos);
     769                 :            : 
     770 [ #  # ][ #  # ]:          0 :     if ((rSize.Width() < 3) || (rSize.Height() < 3))
                 [ #  # ]
     771                 :            :         // we want to have two pixels frame ...
     772                 :          0 :         return;
     773                 :            : 
     774         [ #  # ]:          0 :     Font aFont = GetDataWindow().GetDrawPixelFont( pDev );
     775                 :            :         // the 'normal' painting uses always the data window as device to output to, so we have to calc the new font
     776                 :            :         // relative to the data wins current settings
     777                 :            : 
     778         [ #  # ]:          0 :     pDev->Push();
     779         [ #  # ]:          0 :     pDev->SetMapMode();
     780         [ #  # ]:          0 :     pDev->SetFont( aFont );
     781                 :            : 
     782                 :            :     // draw a frame
     783                 :          0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     784         [ #  # ]:          0 :     pDev->SetLineColor(rStyleSettings.GetDarkShadowColor());
     785                 :          0 :     pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()),
     786         [ #  # ]:          0 :                    Point(aRealPos.X(), aRealPos.Y() + aRealSize.Height() - 1));
     787                 :          0 :     pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()),
     788         [ #  # ]:          0 :                    Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y()));
     789         [ #  # ]:          0 :     pDev->SetLineColor(rStyleSettings.GetShadowColor());
     790                 :          0 :     pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + 1),
     791         [ #  # ]:          0 :                    Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1));
     792                 :          0 :     pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1),
     793         [ #  # ]:          0 :                    Point(aRealPos.X() + 1, aRealPos.Y() + aRealSize.Height() - 1));
     794                 :            : 
     795                 :          0 :     HeaderBar* pBar = getDataWindow()->pHeaderBar;
     796                 :            : 
     797                 :            :     // we're drawing onto a foreign device, so we have to fake the DataRowHeight for the subsequent ImplPaintData
     798                 :            :     // (as it is based on the settings of our data window, not the foreign device)
     799         [ #  # ]:          0 :     if (!nDataRowHeight)
     800         [ #  # ]:          0 :         ImpGetDataRowHeight();
     801 [ #  # ][ #  # ]:          0 :     long nHeightLogic = PixelToLogic(Size(0, nDataRowHeight), MAP_10TH_MM).Height();
                 [ #  # ]
     802 [ #  # ][ #  # ]:          0 :     long nForeignHeightPixel = pDev->LogicToPixel(Size(0, nHeightLogic), MAP_10TH_MM).Height();
                 [ #  # ]
     803                 :            : 
     804                 :          0 :     long nOriginalHeight = nDataRowHeight;
     805                 :          0 :     nDataRowHeight = nForeignHeightPixel;
     806                 :            : 
     807                 :            :     // this counts for the column widths, too
     808                 :            :     size_t nPos;
     809         [ #  # ]:          0 :     for ( nPos = 0; nPos < pCols->size(); ++nPos )
     810                 :            :     {
     811                 :          0 :         BrowserColumn* pCurrent = (*pCols)[ nPos ];
     812                 :            : 
     813 [ #  # ][ #  # ]:          0 :         long nWidthLogic = PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width();
                 [ #  # ]
     814 [ #  # ][ #  # ]:          0 :         long nForeignWidthPixel = pDev->LogicToPixel(Size(nWidthLogic, 0), MAP_10TH_MM).Width();
                 [ #  # ]
     815                 :            : 
     816 [ #  # ][ #  # ]:          0 :         pCurrent->SetWidth(nForeignWidthPixel, GetZoom());
     817         [ #  # ]:          0 :         if ( pBar )
     818         [ #  # ]:          0 :             pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() );
     819                 :            :     }
     820                 :            : 
     821                 :            :     // a smaller area for the content
     822                 :          0 :     ++aRealPos.X();
     823                 :          0 :     ++aRealPos.Y();
     824                 :          0 :     aRealSize.Width() -= 2;
     825                 :          0 :     aRealSize.Height() -= 2;
     826                 :            : 
     827                 :            :     // let the header bar draw itself
     828         [ #  # ]:          0 :     if ( pBar )
     829                 :            :     {
     830                 :            :         // the title height with respect to the font set for the given device
     831 [ #  # ][ #  # ]:          0 :         long nTitleHeight = PixelToLogic(Size(0, GetTitleHeight()), MAP_10TH_MM).Height();
         [ #  # ][ #  # ]
     832 [ #  # ][ #  # ]:          0 :         nTitleHeight = pDev->LogicToPixel(Size(0, nTitleHeight), MAP_10TH_MM).Height();
                 [ #  # ]
     833                 :            : 
     834         [ #  # ]:          0 :         BrowserColumn* pFirstCol = !pCols->empty() ? (*pCols)[ 0 ] : NULL;
     835                 :            : 
     836 [ #  # ][ #  # ]:          0 :         Point aHeaderPos(pFirstCol && (pFirstCol->GetId() == 0) ? pFirstCol->Width() : 0, 0);
     837                 :          0 :         Size aHeaderSize(aRealSize.Width() - aHeaderPos.X(), nTitleHeight);
     838                 :            : 
     839                 :          0 :         aHeaderPos += aRealPos;
     840                 :            :             // do this before converting to logics !
     841                 :            : 
     842                 :            :         // the header's draw expects logic coordinates, again
     843         [ #  # ]:          0 :         aHeaderPos = pDev->PixelToLogic(aHeaderPos);
     844         [ #  # ]:          0 :         aHeaderSize = pDev->PixelToLogic(aHeaderSize);
     845                 :            : 
     846         [ #  # ]:          0 :         pBar->Draw(pDev, aHeaderPos, aHeaderSize, nFlags);
     847                 :            : 
     848                 :            :         // draw the "upper left cell" (the intersection between the header bar and the handle column)
     849 [ #  # ][ #  # ]:          0 :         if (( pFirstCol->GetId() == 0 ) && ( pFirstCol->Width() > 4 ))
                 [ #  # ]
     850                 :            :         {
     851                 :            :             ButtonFrame aButtonFrame( aRealPos,
     852                 :          0 :                 Size( pFirstCol->Width()-1, nTitleHeight-1 ),
     853 [ #  # ][ #  # ]:          0 :                 pFirstCol->Title(), sal_False, sal_False, !IsEnabled());
     854         [ #  # ]:          0 :             aButtonFrame.Draw( *pDev );
     855                 :            : 
     856         [ #  # ]:          0 :             pDev->Push( PUSH_LINECOLOR );
     857         [ #  # ]:          0 :             pDev->SetLineColor( Color( COL_BLACK ) );
     858                 :            : 
     859                 :          0 :             pDev->DrawLine( Point( aRealPos.X(), aRealPos.Y() + nTitleHeight-1 ),
     860         [ #  # ]:          0 :                Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) );
     861                 :          0 :             pDev->DrawLine( Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() ),
     862         [ #  # ]:          0 :                Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) );
     863                 :            : 
     864 [ #  # ][ #  # ]:          0 :             pDev->Pop();
     865                 :            :         }
     866                 :            : 
     867                 :          0 :         aRealPos.Y() += aHeaderSize.Height();
     868                 :          0 :         aRealSize.Height() -= aHeaderSize.Height();
     869                 :            :     }
     870                 :            : 
     871                 :            :     // draw our own content (with clipping)
     872 [ #  # ][ #  # ]:          0 :     Region aRegion(Rectangle(aRealPos, aRealSize));
     873 [ #  # ][ #  # ]:          0 :     pDev->SetClipRegion( pDev->PixelToLogic( aRegion ) );
                 [ #  # ]
     874                 :            : 
     875                 :            :     // do we have to paint the background
     876 [ #  # ][ #  # ]:          0 :     sal_Bool bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && GetDataWindow().IsControlBackground();
                 [ #  # ]
     877         [ #  # ]:          0 :     if ( bBackground )
     878                 :            :     {
     879         [ #  # ]:          0 :         Rectangle aRect( aRealPos, aRealSize );
     880 [ #  # ][ #  # ]:          0 :         pDev->SetFillColor( GetDataWindow().GetControlBackground() );
     881         [ #  # ]:          0 :         pDev->DrawRect( aRect );
     882                 :            :     }
     883                 :            : 
     884 [ #  # ][ #  # ]:          0 :     ImplPaintData( *pDev, Rectangle( aRealPos, aRealSize ), sal_True, bDrawSelection );
     885                 :            : 
     886                 :            :     // restore the column widths/data row height
     887                 :          0 :     nDataRowHeight = nOriginalHeight;
     888         [ #  # ]:          0 :     for ( nPos = 0; nPos < pCols->size(); ++nPos )
     889                 :            :     {
     890                 :          0 :         BrowserColumn* pCurrent = (*pCols)[ nPos ];
     891                 :            : 
     892 [ #  # ][ #  # ]:          0 :         long nForeignWidthLogic = pDev->PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width();
                 [ #  # ]
     893 [ #  # ][ #  # ]:          0 :         long nWidthPixel = LogicToPixel(Size(nForeignWidthLogic, 0), MAP_10TH_MM).Width();
                 [ #  # ]
     894                 :            : 
     895 [ #  # ][ #  # ]:          0 :         pCurrent->SetWidth(nWidthPixel, GetZoom());
     896         [ #  # ]:          0 :         if ( pBar )
     897         [ #  # ]:          0 :             pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() );
     898                 :            :     }
     899                 :            : 
     900 [ #  # ][ #  # ]:          0 :     pDev->Pop();
                 [ #  # ]
     901                 :            : }
     902                 :            : 
     903                 :            : //-------------------------------------------------------------------
     904                 :            : 
     905                 :        118 : void BrowseBox::ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, sal_Bool _bForeignDevice, sal_Bool _bDrawSelections)
     906                 :            : {
     907         [ -  + ]:        118 :     Point aOverallAreaPos = _bForeignDevice ? _rRect.TopLeft() : Point(0,0);
     908 [ -  + ][ #  # ]:        118 :     Size aOverallAreaSize = _bForeignDevice ? _rRect.GetSize() : GetDataWindow().GetOutputSizePixel();
     909 [ -  + ][ #  # ]:        118 :     Point aOverallAreaBRPos = _bForeignDevice ? _rRect.BottomRight() : Point( aOverallAreaSize.Width(), aOverallAreaSize.Height() );
     910                 :            : 
     911         [ +  - ]:        118 :     long nDataRowHeigt = GetDataRowHeight();
     912                 :            : 
     913                 :            :     // compute relative rows to redraw
     914                 :        118 :     sal_uLong nRelTopRow = 0;
     915                 :        118 :     sal_uLong nRelBottomRow = aOverallAreaSize.Height();
     916 [ +  - ][ +  - ]:        118 :     if (!_bForeignDevice && nDataRowHeigt)
     917                 :            :     {
     918                 :        118 :         nRelTopRow = ((sal_uLong)_rRect.Top() / nDataRowHeigt);
     919                 :        118 :         nRelBottomRow = (sal_uLong)(_rRect.Bottom()) / nDataRowHeigt;
     920                 :            :     }
     921                 :            : 
     922                 :            :     // cache frequently used values
     923                 :        118 :     Point aPos( aOverallAreaPos.X(), nRelTopRow * nDataRowHeigt + aOverallAreaPos.Y() );
     924         [ +  - ]:        118 :     _rOut.SetLineColor( Color( COL_WHITE ) );
     925                 :        118 :     const AllSettings& rAllSets = _rOut.GetSettings();
     926                 :        118 :     const StyleSettings &rSettings = rAllSets.GetStyleSettings();
     927                 :        118 :     const Color &rHighlightTextColor = rSettings.GetHighlightTextColor();
     928                 :        118 :     const Color &rHighlightFillColor = rSettings.GetHighlightColor();
     929                 :        118 :     Color aOldTextColor = _rOut.GetTextColor();
     930                 :        118 :     Color aOldFillColor = _rOut.GetFillColor();
     931                 :        118 :     Color aOldLineColor = _rOut.GetLineColor();
     932         [ +  - ]:        118 :     long nHLineX = 0 == (*pCols)[ 0 ]->GetId() ? (*pCols)[ 0 ]->Width() : 0;
     933                 :        118 :     nHLineX += aOverallAreaPos.X();
     934                 :            : 
     935 [ +  - ][ +  - ]:        118 :     Color aDelimiterLineColor( ::svtools::ColorConfig().GetColorValue( ::svtools::CALCGRID ).nColor );
                 [ +  - ]
     936                 :            : 
     937                 :            :     // redraw the invalid fields
     938 [ +  + ][ +  + ]:        134 :     for ( sal_uLong nRelRow = nRelTopRow;
                 [ +  + ]
     939                 :            :           nRelRow <= nRelBottomRow && (sal_uLong)nTopRow+nRelRow < (sal_uLong)nRowCount;
     940                 :         16 :           ++nRelRow, aPos.Y() += nDataRowHeigt )
     941                 :            :     {
     942                 :            :         // get row
     943                 :            :         // check valid area, to be on the safe side:
     944                 :            :         DBG_ASSERT( (sal_uInt16)(nTopRow+nRelRow) < nRowCount, "BrowseBox::ImplPaintData: invalid seek" );
     945 [ +  - ][ -  + ]:         16 :         if ( (nTopRow+long(nRelRow)) < 0 || (sal_uInt16)(nTopRow+nRelRow) >= nRowCount )
     946                 :          0 :             continue;
     947                 :            : 
     948                 :            :         // prepare row
     949                 :         16 :         sal_uLong nRow = nTopRow+nRelRow;
     950         [ +  - ]:         16 :         if ( !SeekRow( nRow) ) {
     951                 :            :             OSL_FAIL("BrowseBox::ImplPaintData: SeekRow failed");
     952                 :            :         }
     953         [ +  - ]:         16 :         _rOut.SetClipRegion();
     954                 :         16 :         aPos.X() = aOverallAreaPos.X();
     955                 :            : 
     956                 :            : 
     957                 :            :         // #73325# don't paint the row outside the painting rectangle (DG)
     958                 :            :         // prepare auto-highlight
     959                 :         16 :         Rectangle aRowRect( Point( _rRect.TopLeft().X(), aPos.Y() ),
     960 [ +  - ][ +  - ]:         32 :                 Size( _rRect.GetSize().Width(), nDataRowHeigt ) );
     961         [ +  - ]:         16 :         PaintRow( _rOut, aRowRect );
     962                 :            : 
     963                 :            :         sal_Bool bRowSelected   =   _bDrawSelections
     964                 :         16 :                             &&  !bHideSelect
     965 [ +  - ][ +  - ]:         16 :                             &&  IsRowSelected( nRow );
         [ +  - ][ -  + ]
     966         [ -  + ]:         16 :         if ( bRowSelected )
     967                 :            :         {
     968         [ #  # ]:          0 :             _rOut.SetTextColor( rHighlightTextColor );
     969         [ #  # ]:          0 :             _rOut.SetFillColor( rHighlightFillColor );
     970         [ #  # ]:          0 :             _rOut.SetLineColor();
     971         [ #  # ]:          0 :             _rOut.DrawRect( aRowRect );
     972                 :            :         }
     973                 :            : 
     974                 :            :         // iterate through columns to redraw
     975                 :            :         size_t nCol;
     976         [ +  - ]:        144 :         for ( nCol = 0; nCol < pCols->size(); ++nCol )
     977                 :            :         {
     978                 :            :             // get column
     979                 :        144 :             BrowserColumn *pCol = (*pCols)[ nCol ];
     980                 :            : 
     981                 :            :             // at end of invalid area
     982         [ +  + ]:        144 :             if ( aPos.X() >= _rRect.Right() )
     983                 :         16 :                 break;
     984                 :            : 
     985                 :            :             // skip invisible colums between frozen and scrollable area
     986 [ +  + ][ -  + ]:        128 :             if ( nCol < nFirstCol && !pCol->IsFrozen() )
                 [ -  + ]
     987                 :            :             {
     988                 :          0 :                 nCol = nFirstCol;
     989         [ #  # ]:          0 :                 pCol = (nCol < pCols->size() ) ? (*pCols)[ nCol ] : NULL;
     990         [ #  # ]:          0 :                 if (!pCol)
     991                 :            :                 {   // FS - 21.05.99 - 66325
     992                 :            :                     // actually this has been fixed elsewhere (in the right place),
     993                 :            :                     // but let's make sure...
     994                 :            :                     OSL_FAIL("BrowseBox::PaintData : nFirstCol is probably invalid !");
     995                 :          0 :                     break;
     996                 :            :                 }
     997                 :            :             }
     998                 :            : 
     999                 :            :             // prepare Column-AutoHighlight
    1000                 :            :             sal_Bool bColAutoHighlight  =   _bDrawSelections
    1001                 :            :                                     &&  bColumnCursor
    1002 [ +  - ][ +  - ]:        128 :                                     &&  IsColumnSelected( pCol->GetId() );
         [ +  - ][ -  + ]
    1003         [ -  + ]:        128 :             if ( bColAutoHighlight )
    1004                 :            :             {
    1005         [ #  # ]:          0 :                 _rOut.SetClipRegion();
    1006         [ #  # ]:          0 :                 _rOut.SetTextColor( rHighlightTextColor );
    1007         [ #  # ]:          0 :                 _rOut.SetFillColor( rHighlightFillColor );
    1008         [ #  # ]:          0 :                 _rOut.SetLineColor();
    1009                 :            :                 Rectangle aFieldRect( aPos,
    1010         [ #  # ]:          0 :                         Size( pCol->Width(), nDataRowHeigt ) );
    1011         [ #  # ]:          0 :                 _rOut.DrawRect( aFieldRect );
    1012                 :            :             }
    1013                 :            : 
    1014 [ -  + ][ #  # ]:        128 :             if (!m_bFocusOnlyCursor && (pCol->GetId() == GetCurColumnId()) && (nRow == (sal_uLong)GetCurRow()))
         [ #  # ][ -  + ]
    1015         [ #  # ]:          0 :                 DrawCursor();
    1016                 :            : 
    1017                 :            :             // draw a single field.
    1018                 :            :             // else something is drawn to, e.g. handle column
    1019         [ +  - ]:        128 :             if (pCol->Width())
    1020                 :            :             {
    1021                 :            :                 // clip the column's output to the field area
    1022         [ -  + ]:        128 :                 if (_bForeignDevice)
    1023                 :            :                 {   // (not necessary if painting onto the data window)
    1024                 :          0 :                     Size aFieldSize(pCol->Width(), nDataRowHeigt);
    1025                 :            : 
    1026         [ #  # ]:          0 :                     if (aPos.X() + aFieldSize.Width() > aOverallAreaBRPos.X())
    1027                 :          0 :                         aFieldSize.Width() = aOverallAreaBRPos.X() - aPos.X();
    1028                 :            : 
    1029         [ #  # ]:          0 :                     if (aPos.Y() + aFieldSize.Height() > aOverallAreaBRPos.Y() + 1)
    1030                 :            :                     {
    1031                 :            :                         // for non-handle cols we don't clip vertically : we just don't draw the cell if the line isn't completely visible
    1032         [ #  # ]:          0 :                         if (pCol->GetId() != 0)
    1033                 :          0 :                             continue;
    1034                 :          0 :                         aFieldSize.Height() = aOverallAreaBRPos.Y() + 1 - aPos.Y();
    1035                 :            :                     }
    1036                 :            : 
    1037 [ #  # ][ #  # ]:          0 :                     Region aClipToField(Rectangle(aPos, aFieldSize));
    1038 [ #  # ][ #  # ]:          0 :                     _rOut.SetClipRegion(aClipToField);
    1039                 :            :                 }
    1040         [ +  - ]:        128 :                 pCol->Draw( *this, _rOut, aPos, sal_False );
    1041         [ -  + ]:        128 :                 if (_bForeignDevice)
    1042         [ #  # ]:          0 :                     _rOut.SetClipRegion();
    1043                 :            :             }
    1044                 :            : 
    1045                 :            :             // reset Column-auto-highlight
    1046         [ -  + ]:        128 :             if ( bColAutoHighlight )
    1047                 :            :             {
    1048         [ #  # ]:          0 :                 _rOut.SetTextColor( aOldTextColor );
    1049         [ #  # ]:          0 :                 _rOut.SetFillColor( aOldFillColor );
    1050         [ #  # ]:          0 :                 _rOut.SetLineColor( aOldLineColor );
    1051                 :            :             }
    1052                 :            : 
    1053                 :            :             // skip column
    1054                 :        128 :             aPos.X() += pCol->Width();
    1055                 :            :         }
    1056                 :            : 
    1057                 :            :         // reset auto-highlight
    1058         [ -  + ]:         16 :         if ( bRowSelected )
    1059                 :            :         {
    1060         [ #  # ]:          0 :             _rOut.SetTextColor( aOldTextColor );
    1061         [ #  # ]:          0 :             _rOut.SetFillColor( aOldFillColor );
    1062         [ #  # ]:          0 :             _rOut.SetLineColor( aOldLineColor );
    1063                 :            :         }
    1064                 :            : 
    1065         [ +  - ]:         16 :         if ( bHLines )
    1066                 :            :         {
    1067                 :            :             // draw horizontal delimitation lines
    1068         [ +  - ]:         16 :             _rOut.SetClipRegion();
    1069         [ +  - ]:         16 :             _rOut.Push( PUSH_LINECOLOR );
    1070         [ +  - ]:         16 :             _rOut.SetLineColor( aDelimiterLineColor );
    1071                 :         16 :             long nY = aPos.Y() + nDataRowHeigt - 1;
    1072         [ +  + ]:         16 :             if (nY <= aOverallAreaBRPos.Y())
    1073                 :            :                 _rOut.DrawLine( Point( nHLineX, nY ),
    1074                 :            :                                 Point( bVLines
    1075 [ +  - ][ +  - ]:         28 :                                         ? std::min(long(long(aPos.X()) - 1), aOverallAreaBRPos.X())
                 [ #  # ]
    1076                 :          0 :                                         : aOverallAreaBRPos.X(),
    1077 [ +  - ][ +  - ]:         28 :                                       nY ) );
    1078         [ +  - ]:         16 :             _rOut.Pop();
    1079                 :            :         }
    1080                 :            :     }
    1081                 :            : 
    1082         [ +  + ]:        118 :     if (aPos.Y() > aOverallAreaBRPos.Y() + 1)
    1083                 :          2 :         aPos.Y() = aOverallAreaBRPos.Y() + 1;
    1084                 :            :         // needed for some of the following drawing
    1085                 :            : 
    1086                 :            :     // retouching
    1087         [ +  - ]:        118 :     _rOut.SetClipRegion();
    1088                 :        118 :     aOldLineColor = _rOut.GetLineColor();
    1089                 :        118 :     aOldFillColor = _rOut.GetFillColor();
    1090         [ +  - ]:        118 :     _rOut.SetFillColor( rSettings.GetFaceColor() );
    1091 [ +  - ][ +  - ]:        118 :     if ( !pCols->empty() && ( (*pCols)[ 0 ]->GetId() == 0 ) && ( aPos.Y() <= _rRect.Bottom() ) )
         [ +  + ][ +  + ]
    1092                 :            :     {
    1093                 :            :         // fill rectangle gray below handle column
    1094                 :            :         // DG: fill it only until the end of the drawing rect and not to the end, as this may overpaint handle columns
    1095         [ +  - ]:        116 :         _rOut.SetLineColor( Color( COL_BLACK ) );
    1096                 :            :         _rOut.DrawRect( Rectangle(
    1097                 :        116 :             Point( aOverallAreaPos.X() - 1, aPos.Y() - 1 ),
    1098                 :        116 :             Point( aOverallAreaPos.X() + (*pCols)[ 0 ]->Width() - 1,
    1099 [ +  - ][ +  - ]:        348 :                    _rRect.Bottom() + 1) ) );
    1100                 :            :     }
    1101         [ +  - ]:        118 :     _rOut.SetFillColor( aOldFillColor );
    1102                 :            : 
    1103                 :            :     // draw vertical delimitational line between frozen and scrollable cols
    1104         [ +  - ]:        118 :     _rOut.SetLineColor( COL_BLACK );
    1105         [ +  - ]:        118 :     long nFrozenWidth = GetFrozenWidth()-1;
    1106                 :        118 :     _rOut.DrawLine( Point( aOverallAreaPos.X() + nFrozenWidth, aPos.Y() ),
    1107                 :        118 :                    Point( aOverallAreaPos.X() + nFrozenWidth, bHLines
    1108                 :        118 :                             ? aPos.Y() - 1
    1109 [ +  - ][ +  - ]:        472 :                             : aOverallAreaBRPos.Y() ) );
    1110                 :            : 
    1111                 :            :     // draw vertical delimitational lines?
    1112         [ +  - ]:        118 :     if ( bVLines )
    1113                 :            :     {
    1114         [ +  - ]:        118 :         _rOut.SetLineColor( aDelimiterLineColor );
    1115                 :        118 :         Point aVertPos( aOverallAreaPos.X() - 1, aOverallAreaPos.Y() );
    1116                 :        118 :         long nDeltaY = aOverallAreaBRPos.Y();
    1117         [ +  + ]:        407 :         for ( size_t nCol = 0; nCol < pCols->size(); ++nCol )
    1118                 :            :         {
    1119                 :            :             // get column
    1120                 :        289 :             BrowserColumn *pCol = (*pCols)[ nCol ];
    1121                 :            : 
    1122                 :            :             // skip invisible columns between frozen and scrollable area
    1123 [ -  + ][ -  + ]:        289 :             if ( nCol < nFirstCol && !pCol->IsFrozen() )
                 [ +  + ]
    1124                 :            :             {
    1125                 :          0 :                 nCol = nFirstCol;
    1126                 :          0 :                 pCol = (*pCols)[ nCol ];
    1127                 :            :             }
    1128                 :            : 
    1129                 :            :             // skip column
    1130                 :        289 :             aVertPos.X() += pCol->Width();
    1131                 :            : 
    1132                 :            :             // at end of invalid area
    1133                 :            :             // invalid area is first reached when X > Right
    1134                 :            :             // and not >=
    1135         [ +  + ]:        289 :             if ( aVertPos.X() > _rRect.Right() )
    1136                 :         18 :                 break;
    1137                 :            : 
    1138                 :            :             // draw a single line
    1139         [ +  + ]:        271 :             if ( pCol->GetId() != 0 )
    1140                 :        169 :                 _rOut.DrawLine( aVertPos, Point( aVertPos.X(),
    1141                 :            :                                bHLines
    1142                 :        169 :                                 ? aPos.Y() - 1
    1143 [ +  - ][ +  - ]:        507 :                                 : aPos.Y() + nDeltaY ) );
    1144                 :            :         }
    1145                 :            :     }
    1146                 :            : 
    1147         [ +  - ]:        118 :     _rOut.SetLineColor( aOldLineColor );
    1148                 :        118 : }
    1149                 :            : 
    1150                 :            : //-------------------------------------------------------------------
    1151                 :            : 
    1152                 :        118 : void BrowseBox::PaintData( Window& rWin, const Rectangle& rRect )
    1153                 :            : {
    1154                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1155 [ -  + ][ #  # ]:        118 :     if ( !bBootstrapped && IsReallyVisible() )
                 [ -  + ]
    1156                 :          0 :         BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
    1157                 :            : 
    1158                 :            :     // initializations
    1159 [ +  - ][ +  - ]:        118 :     if ( !pCols || pCols->empty() || !rWin.IsUpdateMode() )
         [ -  + ][ -  + ]
    1160                 :        118 :         return;
    1161         [ -  + ]:        118 :     if ( getDataWindow()->bResizeOnPaint )
    1162                 :          0 :         Resize();
    1163                 :            :     // MI: who was that? Window::Update();
    1164                 :            : 
    1165                 :        118 :     ImplPaintData(rWin, rRect, sal_False, sal_True);
    1166                 :            : }
    1167                 :            : 
    1168                 :            : //-------------------------------------------------------------------
    1169                 :            : 
    1170                 :        972 : void BrowseBox::UpdateScrollbars()
    1171                 :            : {
    1172                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1173                 :            : 
    1174 [ +  + ][ +  - ]:        972 :     if ( !bBootstrapped || !IsUpdateMode() )
         [ +  + ][ +  + ]
    1175                 :            :         return;
    1176                 :            : 
    1177                 :            :     // protect against recursion
    1178                 :        542 :     BrowserDataWin *pBDW = (BrowserDataWin*) pDataWin;
    1179         [ -  + ]:        542 :     if ( pBDW->bInUpdateScrollbars )
    1180                 :            :     {
    1181                 :          0 :         pBDW->bHadRecursion = sal_True;
    1182                 :            :         return;
    1183                 :            :     }
    1184                 :        542 :     pBDW->bInUpdateScrollbars = sal_True;
    1185                 :            : 
    1186                 :            :     // the size of the corner window (and the width of the VSB/height of the HSB)
    1187                 :        542 :     sal_uLong nCornerSize = GetSettings().GetStyleSettings().GetScrollBarSize();
    1188 [ -  + ][ +  - ]:        542 :     if (IsZoom())
    1189 [ #  # ][ #  # ]:          0 :         nCornerSize = (sal_uLong)(nCornerSize * (double)GetZoom());
    1190                 :            : 
    1191                 :        542 :     sal_Bool bNeedsVScroll = sal_False;
    1192                 :        542 :     long nMaxRows = 0;
    1193 [ +  - ][ +  - ]:        542 :     if (GetDataRowHeight())
    1194                 :            :     {
    1195                 :            :         // needs VScroll?
    1196 [ +  - ][ +  - ]:        542 :         nMaxRows = (pDataWin->GetSizePixel().Height()) / GetDataRowHeight();
    1197                 :            :         bNeedsVScroll =    getDataWindow()->bAutoVScroll
    1198                 :            :                             ?   nTopRow || ( nRowCount > nMaxRows )
    1199 [ +  + ][ +  - ]:        542 :                             :   !getDataWindow()->bNoVScroll;
                 [ +  + ]
    1200                 :            :     }
    1201         [ +  - ]:        542 :     Size aDataWinSize = pDataWin->GetSizePixel();
    1202         [ +  + ]:        542 :     if ( !bNeedsVScroll )
    1203                 :            :     {
    1204 [ +  - ][ +  + ]:        248 :         if ( pVScroll->IsVisible() )
    1205                 :            :         {
    1206         [ +  - ]:          2 :             pVScroll->Hide();
    1207                 :          2 :             Size aNewSize( aDataWinSize );
    1208                 :          2 :             aNewSize.Width() = GetOutputSizePixel().Width();
    1209                 :          2 :             aDataWinSize = aNewSize;
    1210                 :            :         }
    1211                 :            :     }
    1212 [ +  - ][ +  + ]:        294 :     else if ( !pVScroll->IsVisible() )
    1213                 :            :     {
    1214                 :         36 :         Size aNewSize( aDataWinSize );
    1215                 :         36 :         aNewSize.Width() = GetOutputSizePixel().Width() - nCornerSize;
    1216                 :         36 :         aDataWinSize = aNewSize;
    1217                 :            :     }
    1218                 :            : 
    1219                 :            :     // needs HScroll?
    1220         [ +  - ]:        542 :     sal_uLong nLastCol = GetColumnAtXPosPixel( aDataWinSize.Width() - 1 );
    1221                 :            : 
    1222         [ +  - ]:        542 :     sal_uInt16 nFrozenCols = FrozenColCount();
    1223                 :            :     sal_Bool bNeedsHScroll =    getDataWindow()->bAutoHScroll
    1224                 :        250 :                         ?   ( nFirstCol > nFrozenCols ) || ( nLastCol <= pCols->size() )
    1225         [ +  + ]:        792 :                         :   !getDataWindow()->bNoHScroll;
           [ +  -  +  + ]
    1226         [ +  + ]:        542 :     if ( !bNeedsHScroll )
    1227                 :            :     {
    1228 [ +  - ][ +  + ]:        246 :         if ( aHScroll.IsVisible() )
    1229                 :            :         {
    1230         [ +  - ]:        141 :             aHScroll.Hide();
    1231                 :            :         }
    1232         [ +  - ]:        246 :         aDataWinSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight();
    1233         [ +  + ]:        246 :         if ( nControlAreaWidth != USHRT_MAX )
    1234                 :         60 :             aDataWinSize.Height() -= nCornerSize;
    1235                 :            :     }
    1236 [ +  - ][ +  + ]:        296 :     else if ( !aHScroll.IsVisible() )
    1237                 :            :     {
    1238                 :         30 :         Size aNewSize( aDataWinSize );
    1239         [ +  - ]:         30 :         aNewSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight() - nCornerSize;
    1240                 :         30 :         aDataWinSize = aNewSize;
    1241                 :            :     }
    1242                 :            : 
    1243                 :            :     // adjust position and Width of horizontal scrollbar
    1244                 :            :     sal_uLong nHScrX = nControlAreaWidth == USHRT_MAX
    1245                 :            :         ? 0
    1246         [ +  + ]:        542 :         : nControlAreaWidth;
    1247                 :            : 
    1248                 :            :     aHScroll.SetPosSizePixel(
    1249                 :        542 :         Point( nHScrX, GetOutputSizePixel().Height() - nCornerSize ),
    1250         [ +  - ]:       1084 :         Size( aDataWinSize.Width() - nHScrX, nCornerSize ) );
    1251                 :            : 
    1252                 :            :     // total scrollable columns
    1253                 :        542 :     short nScrollCols = short(pCols->size()) - (short)nFrozenCols;
    1254                 :            : 
    1255                 :            :     // visible columns
    1256                 :            :     short nVisibleHSize = nLastCol == BROWSER_INVALIDID
    1257                 :        484 :         ? (short)( pCols->size() - nFirstCol )
    1258         [ +  + ]:       1026 :         : (short)( nLastCol - nFirstCol );
    1259                 :            : 
    1260                 :        542 :     short nRange = Max( nScrollCols, (short)0 );
    1261         [ +  - ]:        542 :     aHScroll.SetVisibleSize( nVisibleHSize );
    1262         [ +  - ]:        542 :     aHScroll.SetRange( Range( 0, nRange ));
    1263 [ +  + ][ +  - ]:        542 :     if ( bNeedsHScroll && !aHScroll.IsVisible() )
         [ +  + ][ +  + ]
    1264         [ +  - ]:         30 :         aHScroll.Show();
    1265                 :            : 
    1266                 :            :     // adjust position and height of vertical scrollbar
    1267                 :        542 :     pVScroll->SetPageSize( nMaxRows );
    1268                 :            : 
    1269         [ -  + ]:        542 :     if ( nTopRow > nRowCount )
    1270                 :            :     {
    1271                 :          0 :         nTopRow = nRowCount - 1;
    1272                 :            :         OSL_FAIL("BrowseBox: nTopRow > nRowCount");
    1273                 :            :     }
    1274                 :            : 
    1275         [ -  + ]:        542 :     if ( pVScroll->GetThumbPos() != nTopRow )
    1276         [ #  # ]:          0 :         pVScroll->SetThumbPos( nTopRow );
    1277                 :        542 :     long nVisibleSize = Min( Min( nRowCount, nMaxRows ), long(nRowCount-nTopRow) );
    1278 [ +  - ][ +  + ]:        542 :     pVScroll->SetVisibleSize( nVisibleSize ? nVisibleSize : 1 );
    1279         [ +  - ]:        542 :     pVScroll->SetRange( Range( 0, nRowCount ) );
    1280                 :            :     pVScroll->SetPosSizePixel(
    1281                 :        542 :         Point( aDataWinSize.Width(), GetTitleHeight() ),
    1282   [ +  -  +  - ]:       1084 :         Size( nCornerSize, aDataWinSize.Height()) );
    1283         [ +  - ]:        542 :     long nLclDataRowHeight = GetDataRowHeight();
    1284 [ +  - ][ +  + ]:        542 :     if ( nLclDataRowHeight > 0 && nRowCount < long( aDataWinSize.Height() / nLclDataRowHeight ) )
                 [ +  + ]
    1285         [ +  - ]:        514 :         ScrollRows( -nTopRow );
    1286 [ +  + ][ +  - ]:        542 :     if ( bNeedsVScroll && !pVScroll->IsVisible() )
         [ +  + ][ +  + ]
    1287         [ +  - ]:         36 :         pVScroll->Show();
    1288                 :            : 
    1289                 :            :     pDataWin->SetPosSizePixel(
    1290                 :        542 :         Point( 0, GetTitleHeight() ),
    1291 [ +  - ][ +  - ]:        542 :         aDataWinSize );
    1292                 :            : 
    1293                 :            :     // needs corner-window?
    1294                 :            :     // (do that AFTER positioning BOTH scrollbars)
    1295                 :        542 :     sal_uLong nActualCorderWidth = 0;
    1296 [ +  - ][ +  + ]:        542 :     if (aHScroll.IsVisible() && pVScroll && pVScroll->IsVisible() )
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
    1297                 :            :     {
    1298                 :            :         // if we have both scrollbars, the corner window fills the point of intersection of these two
    1299                 :        294 :         nActualCorderWidth = nCornerSize;
    1300                 :            :     }
    1301 [ +  - ][ +  + ]:        248 :     else if ( !aHScroll.IsVisible() && ( nControlAreaWidth != USHRT_MAX ) )
         [ +  + ][ +  + ]
    1302                 :            :     {
    1303                 :            :         // if we have no horizontal scrollbar, but a control area, we need the corner window to
    1304                 :            :         // fill the space between the control are and the right border
    1305                 :         60 :         nActualCorderWidth = GetOutputSizePixel().Width() - nControlAreaWidth;
    1306                 :            :     }
    1307         [ +  + ]:        542 :     if ( nActualCorderWidth )
    1308                 :            :     {
    1309         [ +  + ]:        354 :         if ( !getDataWindow()->pCornerWin )
    1310 [ +  - ][ +  - ]:         42 :             getDataWindow()->pCornerWin = new ScrollBarBox( this, 0 );
    1311                 :            :         getDataWindow()->pCornerWin->SetPosSizePixel(
    1312         [ +  - ]:        354 :             Point( GetOutputSizePixel().Width() - nActualCorderWidth, aHScroll.GetPosPixel().Y() ),
    1313         [ +  - ]:        708 :             Size( nActualCorderWidth, nCornerSize ) );
    1314         [ +  - ]:        354 :         getDataWindow()->pCornerWin->Show();
    1315                 :            :     }
    1316                 :            :     else
    1317 [ +  + ][ +  - ]:        188 :         DELETEZ( getDataWindow()->pCornerWin );
    1318                 :            : 
    1319                 :            :     // scroll headerbar, if necessary
    1320         [ +  - ]:        542 :     if ( getDataWindow()->pHeaderBar )
    1321                 :            :     {
    1322                 :        542 :         long nWidth = 0;
    1323 [ +  + ][ +  + ]:       2056 :         for ( size_t nCol = 0;
                 [ +  + ]
    1324                 :       1028 :               nCol < pCols->size() && nCol < nFirstCol;
    1325                 :            :               ++nCol )
    1326                 :            :         {
    1327                 :            :             // not the handle column
    1328         [ -  + ]:        486 :             if ( (*pCols)[ nCol ]->GetId() )
    1329                 :          0 :                 nWidth += (*pCols)[ nCol ]->Width();
    1330                 :            :         }
    1331                 :            : 
    1332         [ +  - ]:        542 :         getDataWindow()->pHeaderBar->SetOffset( nWidth );
    1333                 :            :     }
    1334                 :            : 
    1335                 :        542 :     pBDW->bInUpdateScrollbars = sal_False;
    1336         [ -  + ]:        542 :     if ( pBDW->bHadRecursion )
    1337                 :            :     {
    1338                 :          0 :         pBDW->bHadRecursion = sal_False;
    1339         [ #  # ]:        972 :         UpdateScrollbars();
    1340                 :            :     }
    1341                 :            : }
    1342                 :            : 
    1343                 :            : //-------------------------------------------------------------------
    1344                 :            : 
    1345                 :         84 : void BrowseBox::SetUpdateMode( sal_Bool bUpdate )
    1346                 :            : {
    1347                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1348                 :            : 
    1349                 :         84 :     sal_Bool bWasUpdate = IsUpdateMode();
    1350         [ -  + ]:         84 :     if ( bWasUpdate == bUpdate )
    1351                 :         84 :         return;
    1352                 :            : 
    1353                 :         84 :     Control::SetUpdateMode( bUpdate );
    1354                 :            :     // If WB_CLIPCHILDREN is st at the BrowseBox (to minimize flicker),
    1355                 :            :     // the data window is not invalidated by SetUpdateMode.
    1356         [ +  + ]:         84 :     if( bUpdate )
    1357                 :         42 :         getDataWindow()->Invalidate();
    1358                 :         84 :     getDataWindow()->SetUpdateMode( bUpdate );
    1359                 :            : 
    1360                 :            : 
    1361         [ +  + ]:         84 :     if ( bUpdate )
    1362                 :            :     {
    1363         [ +  + ]:         42 :         if ( bBootstrapped )
    1364                 :            :         {
    1365                 :          2 :             UpdateScrollbars();
    1366                 :          2 :             AutoSizeLastColumn();
    1367                 :            :         }
    1368                 :         42 :         DoShowCursor( "SetUpdateMode" );
    1369                 :            :     }
    1370                 :            :     else
    1371                 :         42 :         DoHideCursor( "SetUpdateMode" );
    1372                 :            : }
    1373                 :            : 
    1374                 :            : //-------------------------------------------------------------------
    1375                 :            : 
    1376                 :        200 : sal_Bool BrowseBox::GetUpdateMode() const
    1377                 :            : {
    1378                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1379                 :            : 
    1380                 :        200 :     return getDataWindow()->IsUpdateMode();
    1381                 :            : }
    1382                 :            : 
    1383                 :            : //-------------------------------------------------------------------
    1384                 :            : 
    1385                 :        118 : long BrowseBox::GetFrozenWidth() const
    1386                 :            : {
    1387                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1388                 :            : 
    1389                 :        118 :     long nWidth = 0;
    1390   [ +  +  +  + ]:        670 :     for ( size_t nCol = 0;
                 [ +  + ]
    1391                 :        434 :           nCol < pCols->size() && (*pCols)[ nCol ]->IsFrozen();
    1392                 :            :           ++nCol )
    1393                 :        118 :         nWidth += (*pCols)[ nCol ]->Width();
    1394                 :        118 :     return nWidth;
    1395                 :            : }
    1396                 :            : 
    1397                 :            : //-------------------------------------------------------------------
    1398                 :            : 
    1399                 :        204 : void BrowseBox::ColumnInserted( sal_uInt16 nPos )
    1400                 :            : {
    1401                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1402                 :            : 
    1403         [ +  - ]:        204 :     if ( pColSel )
    1404                 :        204 :         pColSel->Insert( nPos );
    1405                 :        204 :     UpdateScrollbars();
    1406                 :        204 : }
    1407                 :            : 
    1408                 :            : //-------------------------------------------------------------------
    1409                 :            : 
    1410                 :       1403 : sal_uInt16 BrowseBox::FrozenColCount() const
    1411                 :            : {
    1412                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1413                 :            :     sal_uInt16 nCol;
    1414   [ +  +  +  + ]:       6421 :     for ( nCol = 0;
                 [ +  + ]
    1415                 :       5018 :           nCol < pCols->size() && (*pCols)[ nCol ]->IsFrozen();
    1416                 :            :           ++nCol )
    1417                 :            :         /* empty loop */;
    1418                 :       1403 :     return nCol;
    1419                 :            : }
    1420                 :            : 
    1421                 :            : //-------------------------------------------------------------------
    1422                 :            : 
    1423                 :          0 : IMPL_LINK(BrowseBox,ScrollHdl,ScrollBar*,pBar)
    1424                 :            : {
    1425                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1426                 :            : 
    1427         [ #  # ]:          0 :     if ( pBar->GetDelta() == 0 )
    1428                 :          0 :         return 0;
    1429                 :            : 
    1430 [ #  # ][ #  # ]:          0 :     if ( pBar->GetDelta() < 0 && getDataWindow()->bNoScrollBack )
                 [ #  # ]
    1431                 :            :     {
    1432                 :          0 :         UpdateScrollbars();
    1433                 :          0 :         return 0;
    1434                 :            :     }
    1435                 :            : 
    1436         [ #  # ]:          0 :     if ( pBar == &aHScroll )
    1437                 :          0 :         ScrollColumns( aHScroll.GetDelta() );
    1438         [ #  # ]:          0 :     if ( pBar == pVScroll )
    1439                 :          0 :         ScrollRows( pVScroll->GetDelta() );
    1440                 :            : 
    1441                 :          0 :     return 0;
    1442                 :            : }
    1443                 :            : 
    1444                 :            : //-------------------------------------------------------------------
    1445                 :            : 
    1446                 :          0 : IMPL_LINK_NOARG(BrowseBox, EndScrollHdl)
    1447                 :            : {
    1448                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1449                 :            : 
    1450         [ #  # ]:          0 :     if ( getDataWindow()->bNoScrollBack )
    1451                 :            :     {
    1452                 :          0 :         EndScroll();
    1453                 :          0 :         return 0;
    1454                 :            :     }
    1455                 :            : 
    1456                 :          0 :     return 0;
    1457                 :            : }
    1458                 :            : 
    1459                 :            : //-------------------------------------------------------------------
    1460                 :            : 
    1461                 :          0 : IMPL_LINK( BrowseBox, StartDragHdl, HeaderBar*, pBar )
    1462                 :            : {
    1463                 :          0 :     pBar->SetDragSize( pDataWin->GetOutputSizePixel().Height() );
    1464                 :          0 :     return 0;
    1465                 :            : }
    1466                 :            : 
    1467                 :            : //-------------------------------------------------------------------
    1468                 :            : // usually only the first column was resized
    1469                 :            : #ifdef _MSC_VER
    1470                 :            : #pragma optimize("",off)
    1471                 :            : #endif
    1472                 :            : 
    1473                 :          0 : void BrowseBox::MouseButtonDown( const MouseEvent& rEvt )
    1474                 :            : {
    1475                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1476                 :            : 
    1477                 :          0 :     GrabFocus();
    1478                 :            : 
    1479                 :            :     // only mouse events in the title-line are supported
    1480                 :          0 :     const Point &rEvtPos = rEvt.GetPosPixel();
    1481         [ #  # ]:          0 :     if ( rEvtPos.Y() >= GetTitleHeight() )
    1482                 :          0 :         return;
    1483                 :            : 
    1484                 :          0 :     long nX = 0;
    1485                 :          0 :     long nWidth = GetOutputSizePixel().Width();
    1486 [ #  # ][ #  # ]:          0 :     for ( size_t nCol = 0; nCol < pCols->size() && nX < nWidth; ++nCol )
                 [ #  # ]
    1487                 :            :     {
    1488                 :            :         // is this column visible?
    1489                 :          0 :         BrowserColumn *pCol = (*pCols)[ nCol ];
    1490 [ #  # ][ #  # ]:          0 :         if ( pCol->IsFrozen() || nCol >= nFirstCol )
                 [ #  # ]
    1491                 :            :         {
    1492                 :            :             // compute right end of column
    1493                 :          0 :             long nR = nX + pCol->Width() - 1;
    1494                 :            : 
    1495                 :            :             // at the end of a column (and not handle column)?
    1496 [ #  # ][ #  # ]:          0 :             if ( pCol->GetId() && Abs( nR - rEvtPos.X() ) < 2 )
                 [ #  # ]
    1497                 :            :             {
    1498                 :            :                 // start resizing the column
    1499                 :          0 :                 bResizing = sal_True;
    1500                 :          0 :                 nResizeCol = nCol;
    1501                 :          0 :                 nDragX = nResizeX = rEvtPos.X();
    1502         [ #  # ]:          0 :                 SetPointer( Pointer( POINTER_HSPLIT ) );
    1503                 :          0 :                 CaptureMouse();
    1504                 :            :                 pDataWin->DrawLine( Point( nDragX, 0 ),
    1505         [ #  # ]:          0 :                     Point( nDragX, pDataWin->GetSizePixel().Height() ) );
    1506                 :          0 :                 nMinResizeX = nX + MIN_COLUMNWIDTH;
    1507                 :          0 :                 return;
    1508                 :            :             }
    1509 [ #  # ][ #  # ]:          0 :             else if ( nX < rEvtPos.X() && nR > rEvtPos.X() )
                 [ #  # ]
    1510                 :            :             {
    1511                 :            :                 MouseButtonDown( BrowserMouseEvent(
    1512 [ #  # ][ #  # ]:          0 :                     this, rEvt, -1, nCol, pCol->GetId(), Rectangle() ) );
    1513                 :          0 :                 return;
    1514                 :            :             }
    1515                 :          0 :             nX = nR + 1;
    1516                 :            :         }
    1517                 :            :     }
    1518                 :            : 
    1519                 :            :     // event occurred out of data area
    1520         [ #  # ]:          0 :     if ( rEvt.IsRight() )
    1521                 :            :         pDataWin->Command(
    1522 [ #  # ][ #  # ]:          0 :             CommandEvent( Point( 1, LONG_MAX ), COMMAND_CONTEXTMENU, sal_True ) );
    1523                 :            :     else
    1524                 :          0 :         SetNoSelection();
    1525                 :            : }
    1526                 :            : 
    1527                 :            : #ifdef _MSC_VER
    1528                 :            : #pragma optimize("",on)
    1529                 :            : #endif
    1530                 :            : 
    1531                 :            : //-------------------------------------------------------------------
    1532                 :            : 
    1533                 :          0 : void BrowseBox::MouseMove( const MouseEvent& rEvt )
    1534                 :            : {
    1535                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1536                 :            :     OSL_TRACE( "BrowseBox::MouseMove( MouseEvent )" );
    1537                 :            : 
    1538                 :          0 :     Pointer aNewPointer;
    1539                 :            : 
    1540                 :          0 :     sal_uInt16 nX = 0;
    1541   [ #  #  #  # ]:          0 :     for ( size_t nCol = 0;
                 [ #  # ]
    1542                 :          0 :           nCol < pCols->size() &&
    1543         [ #  # ]:          0 :             ( nX + (*pCols)[ nCol ]->Width() ) < sal_uInt16(GetOutputSizePixel().Width());
    1544                 :            :           ++nCol )
    1545                 :            :         // is this column visible?
    1546 [ #  # ][ #  # ]:          0 :         if ( (*pCols)[ nCol ]->IsFrozen() || nCol >= nFirstCol )
                 [ #  # ]
    1547                 :            :         {
    1548                 :            :             // compute right end of column
    1549                 :          0 :             BrowserColumn *pCol = (*pCols)[ nCol ];
    1550                 :          0 :             sal_uInt16 nR = (sal_uInt16)(nX + pCol->Width() - 1);
    1551                 :            : 
    1552                 :            :             // show resize-pointer?
    1553   [ #  #  #  # ]:          0 :             if ( bResizing || ( pCol->GetId() &&
         [ #  # ][ #  # ]
    1554                 :          0 :                  Abs( ((long) nR ) - rEvt.GetPosPixel().X() ) < MIN_COLUMNWIDTH ) )
    1555                 :            :             {
    1556                 :          0 :                 aNewPointer = Pointer( POINTER_HSPLIT );
    1557         [ #  # ]:          0 :                 if ( bResizing )
    1558                 :            :                 {
    1559                 :            :                     // delete old auxiliary line
    1560         [ #  # ]:          0 :                     pDataWin->HideTracking() ;
    1561                 :            : 
    1562                 :            :                     // check allowed width and new delta
    1563                 :          0 :                     nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX );
    1564                 :          0 :                     long nDeltaX = nDragX - nResizeX;
    1565         [ #  # ]:          0 :                     sal_uInt16 nId = GetColumnId(nResizeCol);
    1566         [ #  # ]:          0 :                     sal_uLong nOldWidth = GetColumnWidth(nId);
    1567         [ #  # ]:          0 :                     nDragX = QueryColumnResize( GetColumnId(nResizeCol),
    1568         [ #  # ]:          0 :                                     nOldWidth + nDeltaX )
    1569                 :          0 :                              + nResizeX - nOldWidth;
    1570                 :            : 
    1571                 :            :                     // draw new auxiliary line
    1572                 :            :                     pDataWin->ShowTracking( Rectangle( Point( nDragX, 0 ),
    1573         [ #  # ]:          0 :                             Size( 1, pDataWin->GetSizePixel().Height() ) ),
    1574 [ #  # ][ #  # ]:          0 :                             SHOWTRACK_SPLIT|SHOWTRACK_WINDOW );
    1575                 :            :                 }
    1576                 :            : 
    1577                 :            :             }
    1578                 :            : 
    1579                 :          0 :             nX = nR + 1;
    1580                 :            :         }
    1581                 :            : 
    1582         [ #  # ]:          0 :     SetPointer( aNewPointer );
    1583                 :          0 : }
    1584                 :            : 
    1585                 :            : //-------------------------------------------------------------------
    1586                 :            : 
    1587                 :          0 : void BrowseBox::MouseButtonUp( const MouseEvent & rEvt )
    1588                 :            : {
    1589                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1590                 :            : 
    1591         [ #  # ]:          0 :     if ( bResizing )
    1592                 :            :     {
    1593                 :            :         // delete auxiliary line
    1594                 :          0 :         pDataWin->HideTracking();
    1595                 :            : 
    1596                 :            :         // width changed?
    1597                 :          0 :         nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX );
    1598         [ #  # ]:          0 :         if ( (nDragX - nResizeX) != (long)(*pCols)[ nResizeCol ]->Width() )
    1599                 :            :         {
    1600                 :            :             // resize column
    1601                 :          0 :             long nMaxX = pDataWin->GetSizePixel().Width();
    1602                 :          0 :             nDragX = Min( nDragX, nMaxX );
    1603                 :          0 :             long nDeltaX = nDragX - nResizeX;
    1604                 :          0 :             sal_uInt16 nId = GetColumnId(nResizeCol);
    1605                 :          0 :             SetColumnWidth( GetColumnId(nResizeCol), GetColumnWidth(nId) + nDeltaX );
    1606                 :          0 :             ColumnResized( nId );
    1607                 :            :         }
    1608                 :            : 
    1609                 :            :         // end action
    1610         [ #  # ]:          0 :         SetPointer( Pointer() );
    1611                 :          0 :         ReleaseMouse();
    1612                 :          0 :         bResizing = sal_False;
    1613                 :            :     }
    1614                 :            :     else
    1615                 :            :         MouseButtonUp( BrowserMouseEvent( (BrowserDataWin*)pDataWin,
    1616                 :          0 :                 MouseEvent( Point( rEvt.GetPosPixel().X(),
    1617                 :          0 :                         rEvt.GetPosPixel().Y() - pDataWin->GetPosPixel().Y() ),
    1618                 :          0 :                     rEvt.GetClicks(), rEvt.GetMode(), rEvt.GetButtons(),
    1619 [ #  # ][ #  # ]:          0 :                     rEvt.GetModifier() ) ) );
                 [ #  # ]
    1620                 :          0 : }
    1621                 :            : 
    1622                 :            : //-------------------------------------------------------------------
    1623                 :            : 
    1624                 :            : sal_Bool bExtendedMode = sal_False;
    1625                 :            : sal_Bool bFieldMode = sal_False;
    1626                 :            : 
    1627                 :          0 : void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt )
    1628                 :            : {
    1629                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1630                 :            : 
    1631                 :          0 :     GrabFocus();
    1632                 :            : 
    1633                 :            :     // adjust selection while and after double-click
    1634         [ #  # ]:          0 :     if ( rEvt.GetClicks() == 2 )
    1635                 :            :     {
    1636                 :          0 :         SetNoSelection();
    1637         [ #  # ]:          0 :         if ( rEvt.GetRow() >= 0 )
    1638                 :            :         {
    1639                 :          0 :             GoToRow( rEvt.GetRow() );
    1640                 :          0 :             SelectRow( rEvt.GetRow(), sal_True, sal_False );
    1641                 :            :         }
    1642                 :            :         else
    1643                 :            :         {
    1644 [ #  # ][ #  # ]:          0 :             if ( bColumnCursor && rEvt.GetColumn() != 0 )
                 [ #  # ]
    1645                 :            :             {
    1646         [ #  # ]:          0 :                 if ( rEvt.GetColumn() < pCols->size() )
    1647                 :          0 :                     SelectColumnPos( rEvt.GetColumn(), sal_True, sal_False);
    1648                 :            :             }
    1649                 :            :         }
    1650                 :          0 :         DoubleClick( rEvt );
    1651                 :            :     }
    1652                 :            :     // selections
    1653         [ #  # ]:          0 :     else if ( ( rEvt.GetMode() & ( MOUSE_SELECT | MOUSE_SIMPLECLICK ) ) &&
           [ #  #  #  # ]
                 [ #  # ]
    1654                 :          0 :          ( bColumnCursor || rEvt.GetRow() >= 0 ) )
    1655                 :            :     {
    1656         [ #  # ]:          0 :         if ( rEvt.GetClicks() == 1 )
    1657                 :            :         {
    1658                 :            :             // initialise flags
    1659                 :          0 :             bHit            = sal_False;
    1660                 :            :             a1stPoint       =
    1661                 :          0 :             a2ndPoint       = PixelToLogic( rEvt.GetPosPixel() );
    1662                 :            : 
    1663                 :            :             // selection out of range?
    1664         [ #  # ]:          0 :             if ( rEvt.GetRow() >= nRowCount ||
           [ #  #  #  # ]
    1665                 :          0 :                  rEvt.GetColumnId() == BROWSER_INVALIDID )
    1666                 :            :             {
    1667                 :          0 :                 SetNoSelection();
    1668                 :          0 :                 return;
    1669                 :            :             }
    1670                 :            : 
    1671                 :            :             // while selecting, no cursor
    1672                 :          0 :             bSelecting = sal_True;
    1673                 :          0 :             DoHideCursor( "MouseButtonDown" );
    1674                 :            : 
    1675                 :            :             // DataRow?
    1676         [ #  # ]:          0 :             if ( rEvt.GetRow() >= 0 )
    1677                 :            :             {
    1678                 :            :                 // line selection?
    1679 [ #  # ][ #  # ]:          0 :                 if ( rEvt.GetColumnId() == HandleColumnId || !bColumnCursor )
                 [ #  # ]
    1680                 :            :                 {
    1681         [ #  # ]:          0 :                     if ( bMultiSelection )
    1682                 :            :                     {
    1683                 :            :                         // remove column-selection, if exists
    1684 [ #  # ][ #  # ]:          0 :                         if ( pColSel && pColSel->GetSelectCount() )
                 [ #  # ]
    1685                 :            :                         {
    1686                 :          0 :                             ToggleSelection();
    1687         [ #  # ]:          0 :                             if ( bMultiSelection )
    1688                 :          0 :                                 uRow.pSel->SelectAll(sal_False);
    1689                 :            :                             else
    1690                 :          0 :                                 uRow.nSel = BROWSER_ENDOFSELECTION;
    1691         [ #  # ]:          0 :                             if ( pColSel )
    1692                 :          0 :                                 pColSel->SelectAll(sal_False);
    1693                 :          0 :                             bSelect = sal_True;
    1694                 :            :                         }
    1695                 :            : 
    1696                 :            :                         // expanding mode?
    1697         [ #  # ]:          0 :                         if ( rEvt.GetMode() & MOUSE_RANGESELECT )
    1698                 :            :                         {
    1699                 :            :                             // select the further touched rows too
    1700                 :          0 :                             bSelect = sal_True;
    1701                 :          0 :                             ExpandRowSelection( rEvt );
    1702                 :          0 :                             return;
    1703                 :            :                         }
    1704                 :            : 
    1705                 :            :                         // click in the selected area?
    1706         [ #  # ]:          0 :                         else if ( IsRowSelected( rEvt.GetRow() ) )
    1707                 :            :                         {
    1708                 :            :                             // wait for Drag&Drop
    1709                 :          0 :                             bHit = sal_True;
    1710                 :            :                             bExtendedMode = MOUSE_MULTISELECT ==
    1711                 :          0 :                                     ( rEvt.GetMode() & MOUSE_MULTISELECT );
    1712                 :          0 :                             return;
    1713                 :            :                         }
    1714                 :            : 
    1715                 :            :                         // extension mode?
    1716         [ #  # ]:          0 :                         else if ( rEvt.GetMode() & MOUSE_MULTISELECT )
    1717                 :            :                         {
    1718                 :            :                             // determine the new selection range
    1719                 :            :                             // and selection/deselection
    1720                 :          0 :                             aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
    1721                 :            :                             SelectRow( rEvt.GetRow(),
    1722                 :          0 :                                     !uRow.pSel->IsSelected( rEvt.GetRow() ) );
    1723                 :          0 :                             bSelect = sal_True;
    1724                 :          0 :                             return;
    1725                 :            :                         }
    1726                 :            :                     }
    1727                 :            : 
    1728                 :            :                     // select directly
    1729                 :          0 :                     SetNoSelection();
    1730                 :          0 :                     GoToRow( rEvt.GetRow() );
    1731                 :          0 :                     SelectRow( rEvt.GetRow(), sal_True );
    1732                 :          0 :                     aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
    1733                 :          0 :                     bSelect = sal_True;
    1734                 :            :                 }
    1735                 :            :                 else // Column/Field-Selection
    1736                 :            :                 {
    1737                 :            :                     // click in selected column
    1738   [ #  #  #  # ]:          0 :                     if ( IsColumnSelected( rEvt.GetColumn() ) ||
                 [ #  # ]
    1739                 :          0 :                          IsRowSelected( rEvt.GetRow() ) )
    1740                 :            :                     {
    1741                 :          0 :                         bHit = sal_True;
    1742                 :          0 :                         bFieldMode = sal_True;
    1743                 :          0 :                         return;
    1744                 :            :                     }
    1745                 :            : 
    1746                 :          0 :                     SetNoSelection();
    1747                 :          0 :                     GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() );
    1748                 :          0 :                     bSelect = sal_True;
    1749                 :            :                 }
    1750                 :            :             }
    1751                 :            :             else
    1752                 :            :             {
    1753 [ #  # ][ #  # ]:          0 :                 if ( bMultiSelection && rEvt.GetColumnId() == HandleColumnId )
                 [ #  # ]
    1754                 :            :                 {
    1755                 :            :                     // toggle all-selection
    1756         [ #  # ]:          0 :                     if ( uRow.pSel->GetSelectCount() > ( GetRowCount() / 2 ) )
    1757                 :          0 :                         SetNoSelection();
    1758                 :            :                     else
    1759                 :          0 :                         SelectAll();
    1760                 :            :                 }
    1761                 :            :                 else
    1762                 :          0 :                     SelectColumnId( rEvt.GetColumnId(), sal_True, sal_False );
    1763                 :            :             }
    1764                 :            : 
    1765                 :            :             // turn cursor on again, if necessary
    1766                 :          0 :             bSelecting = sal_False;
    1767                 :          0 :             DoShowCursor( "MouseButtonDown" );
    1768         [ #  # ]:          0 :             if ( bSelect )
    1769                 :          0 :                 Select();
    1770                 :            :         }
    1771                 :            :     }
    1772                 :            : }
    1773                 :            : 
    1774                 :            : //-------------------------------------------------------------------
    1775                 :            : 
    1776                 :          0 : void BrowseBox::MouseMove( const BrowserMouseEvent& )
    1777                 :            : {
    1778                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1779                 :          0 : }
    1780                 :            : 
    1781                 :            : //-------------------------------------------------------------------
    1782                 :            : 
    1783                 :          0 : void BrowseBox::MouseButtonUp( const BrowserMouseEvent &rEvt )
    1784                 :            : {
    1785                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1786                 :            : 
    1787                 :            :     // D&D was possible, but did not occur
    1788         [ #  # ]:          0 :     if ( bHit )
    1789                 :            :     {
    1790                 :          0 :         aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
    1791         [ #  # ]:          0 :         if ( bExtendedMode )
    1792                 :          0 :             SelectRow( rEvt.GetRow(), sal_False );
    1793                 :            :         else
    1794                 :            :         {
    1795                 :          0 :             SetNoSelection();
    1796         [ #  # ]:          0 :             if ( bFieldMode )
    1797                 :          0 :                 GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() );
    1798                 :            :             else
    1799                 :            :             {
    1800                 :          0 :                 GoToRow( rEvt.GetRow() );
    1801                 :          0 :                 SelectRow( rEvt.GetRow(), sal_True );
    1802                 :            :             }
    1803                 :            :         }
    1804                 :          0 :         bSelect = sal_True;
    1805                 :          0 :         bExtendedMode = sal_False;
    1806                 :          0 :         bFieldMode = sal_False;
    1807                 :          0 :         bHit = sal_False;
    1808                 :            :     }
    1809                 :            : 
    1810                 :            :     // activate cursor
    1811         [ #  # ]:          0 :     if ( bSelecting )
    1812                 :            :     {
    1813                 :          0 :         bSelecting = sal_False;
    1814                 :          0 :         DoShowCursor( "MouseButtonUp" );
    1815         [ #  # ]:          0 :         if ( bSelect )
    1816                 :          0 :             Select();
    1817                 :            :     }
    1818                 :          0 : }
    1819                 :            : 
    1820                 :            : //-------------------------------------------------------------------
    1821                 :            : 
    1822                 :          0 : void BrowseBox::KeyInput( const KeyEvent& rEvt )
    1823                 :            : {
    1824         [ #  # ]:          0 :     if ( !ProcessKey( rEvt ) )
    1825                 :          0 :         Control::KeyInput( rEvt );
    1826                 :          0 : }
    1827                 :            : 
    1828                 :            : //-------------------------------------------------------------------
    1829                 :            : 
    1830                 :          0 : sal_Bool BrowseBox::ProcessKey( const KeyEvent& rEvt )
    1831                 :            : {
    1832                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1833                 :            : 
    1834                 :          0 :     sal_uInt16 nCode = rEvt.GetKeyCode().GetCode();
    1835                 :          0 :     sal_Bool   bShift = rEvt.GetKeyCode().IsShift();
    1836                 :          0 :     sal_Bool   bCtrl = rEvt.GetKeyCode().IsMod1();
    1837                 :          0 :     sal_Bool   bAlt = rEvt.GetKeyCode().IsMod2();
    1838                 :            : 
    1839                 :          0 :     sal_uInt16 nId = BROWSER_NONE;
    1840                 :            : 
    1841 [ #  # ][ #  # ]:          0 :     if ( !bAlt && !bCtrl && !bShift )
                 [ #  # ]
    1842                 :            :     {
    1843   [ #  #  #  #  :          0 :         switch ( nCode )
             #  #  #  #  
                      # ]
    1844                 :            :         {
    1845                 :          0 :             case KEY_DOWN:          nId = BROWSER_CURSORDOWN; break;
    1846                 :          0 :             case KEY_UP:            nId = BROWSER_CURSORUP; break;
    1847                 :          0 :             case KEY_HOME:          nId = BROWSER_CURSORHOME; break;
    1848                 :          0 :             case KEY_END:           nId = BROWSER_CURSOREND; break;
    1849                 :            :             case KEY_TAB:
    1850         [ #  # ]:          0 :                 if ( !bColumnCursor )
    1851                 :          0 :                     break;
    1852                 :          0 :             case KEY_RIGHT:         nId = BROWSER_CURSORRIGHT; break;
    1853                 :          0 :             case KEY_LEFT:          nId = BROWSER_CURSORLEFT; break;
    1854                 :          0 :             case KEY_SPACE:         nId = BROWSER_SELECT; break;
    1855                 :            :         }
    1856         [ #  # ]:          0 :         if ( BROWSER_NONE != nId )
    1857                 :          0 :             SetNoSelection();
    1858                 :            : 
    1859      [ #  #  # ]:          0 :         switch ( nCode )
    1860                 :            :         {
    1861                 :          0 :             case KEY_PAGEDOWN:      nId = BROWSER_CURSORPAGEDOWN; break;
    1862                 :          0 :             case KEY_PAGEUP:        nId = BROWSER_CURSORPAGEUP; break;
    1863                 :            :         }
    1864                 :            :     }
    1865                 :            : 
    1866 [ #  # ][ #  # ]:          0 :     if ( !bAlt && !bCtrl && bShift )
                 [ #  # ]
    1867   [ #  #  #  #  :          0 :         switch ( nCode )
                   #  # ]
    1868                 :            :         {
    1869                 :          0 :             case KEY_DOWN:          nId = BROWSER_SELECTDOWN; break;
    1870                 :          0 :             case KEY_UP:            nId = BROWSER_SELECTUP; break;
    1871                 :            :             case KEY_TAB:
    1872         [ #  # ]:          0 :                 if ( !bColumnCursor )
    1873                 :          0 :                     break;
    1874                 :          0 :                                     nId = BROWSER_CURSORLEFT; break;
    1875                 :          0 :             case KEY_HOME:          nId = BROWSER_SELECTHOME; break;
    1876                 :          0 :             case KEY_END:           nId = BROWSER_SELECTEND; break;
    1877                 :            :         }
    1878                 :            : 
    1879                 :            : 
    1880 [ #  # ][ #  # ]:          0 :     if ( !bAlt && bCtrl && !bShift )
                 [ #  # ]
    1881   [ #  #  #  #  :          0 :         switch ( nCode )
          #  #  #  #  #  
                      # ]
    1882                 :            :         {
    1883                 :          0 :             case KEY_DOWN:          nId = BROWSER_CURSORDOWN; break;
    1884                 :          0 :             case KEY_UP:            nId = BROWSER_CURSORUP; break;
    1885                 :          0 :             case KEY_PAGEDOWN:      nId = BROWSER_CURSORENDOFFILE; break;
    1886                 :          0 :             case KEY_PAGEUP:        nId = BROWSER_CURSORTOPOFFILE; break;
    1887                 :          0 :             case KEY_HOME:          nId = BROWSER_CURSORTOPOFSCREEN; break;
    1888                 :          0 :             case KEY_END:           nId = BROWSER_CURSORENDOFSCREEN; break;
    1889                 :          0 :             case KEY_SPACE:         nId = BROWSER_ENHANCESELECTION; break;
    1890                 :          0 :             case KEY_LEFT:          nId = BROWSER_MOVECOLUMNLEFT; break;
    1891                 :          0 :             case KEY_RIGHT:         nId = BROWSER_MOVECOLUMNRIGHT; break;
    1892                 :            :         }
    1893                 :            : 
    1894         [ #  # ]:          0 :     if ( nId != BROWSER_NONE )
    1895                 :          0 :         Dispatch( nId );
    1896                 :          0 :     return nId != BROWSER_NONE;
    1897                 :            : }
    1898                 :            : 
    1899                 :            : //-------------------------------------------------------------------
    1900                 :            : 
    1901                 :          0 : void BrowseBox::Dispatch( sal_uInt16 nId )
    1902                 :            : {
    1903                 :            :     DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
    1904                 :            : 
    1905         [ #  # ]:          0 :     long nRowsOnPage = pDataWin->GetSizePixel().Height() / GetDataRowHeight();
    1906                 :          0 :     sal_Bool bDone = sal_False;
    1907                 :            : 
    1908   [ #  #  #  #  :          0 :     switch ( nId )
          #  #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
    1909                 :            :     {
    1910                 :            :         case BROWSER_SELECTCOLUMN:
    1911         [ #  # ]:          0 :             if ( ColCount() )
    1912                 :          0 :                 SelectColumnId( GetCurColumnId() );
    1913                 :          0 :             break;
    1914                 :            : 
    1915                 :            :         case BROWSER_CURSORDOWN:
    1916         [ #  # ]:          0 :             if ( ( GetCurRow() + 1 ) < nRowCount )
    1917                 :          0 :                 bDone = GoToRow( GetCurRow() + 1, sal_False );
    1918                 :          0 :             break;
    1919                 :            :         case BROWSER_CURSORUP:
    1920         [ #  # ]:          0 :             if ( GetCurRow() > 0 )
    1921                 :          0 :                 bDone = GoToRow( GetCurRow() - 1, sal_False );
    1922                 :          0 :             break;
    1923                 :            :         case BROWSER_SELECTHOME:
    1924         [ #  # ]:          0 :             if ( GetRowCount() )
    1925                 :            :             {
    1926                 :          0 :                 DoHideCursor( "BROWSER_SELECTHOME" );
    1927         [ #  # ]:          0 :                 for ( long nRow = GetCurRow(); nRow >= 0; --nRow )
    1928                 :          0 :                     SelectRow( nRow );
    1929                 :          0 :                 GoToRow( 0, sal_True );
    1930                 :          0 :                 DoShowCursor( "BROWSER_SELECTHOME" );
    1931                 :            :             }
    1932                 :          0 :             break;
    1933                 :            :         case BROWSER_SELECTEND:
    1934         [ #  # ]:          0 :             if ( GetRowCount() )
    1935                 :            :             {
    1936                 :          0 :                 DoHideCursor( "BROWSER_SELECTEND" );
    1937                 :          0 :                 long nRows = GetRowCount();
    1938         [ #  # ]:          0 :                 for ( long nRow = GetCurRow(); nRow < nRows; ++nRow )
    1939                 :          0 :                     SelectRow( nRow );
    1940                 :          0 :                 GoToRow( GetRowCount() - 1, sal_True );
    1941                 :          0 :                 DoShowCursor( "BROWSER_SELECTEND" );
    1942                 :            :             }
    1943                 :          0 :             break;
    1944                 :            :         case BROWSER_SELECTDOWN:
    1945                 :            :         {
    1946 [ #  # ][ #  # ]:          0 :             if ( GetRowCount() && ( GetCurRow() + 1 ) < nRowCount )
                 [ #  # ]
    1947                 :            :             {
    1948                 :            :                 // deselect the current row, if it isn't the first
    1949                 :            :                 // and there is no other selected row above
    1950                 :          0 :                 long nRow = GetCurRow();
    1951                 :          0 :                 sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) ||
    1952 [ #  # ][ #  # ]:          0 :                                  GetSelectRowCount() == 1 || IsRowSelected( nRow - 1 ) );
                 [ #  # ]
    1953                 :          0 :                 SelectRow( nRow, bLocalSelect, sal_True );
    1954                 :          0 :                 bDone = GoToRow( GetCurRow() + 1 , sal_False );
    1955         [ #  # ]:          0 :                 if ( bDone )
    1956                 :          0 :                     SelectRow( GetCurRow(), sal_True, sal_True );
    1957                 :            :             }
    1958                 :            :             else
    1959                 :          0 :                 bDone = ScrollRows( 1 ) != 0;
    1960                 :          0 :             break;
    1961                 :            :         }
    1962                 :            :         case BROWSER_SELECTUP:
    1963         [ #  # ]:          0 :             if ( GetRowCount() )
    1964                 :            :             {
    1965                 :            :                 // deselect the current row, if it isn't the first
    1966                 :            :                 // and there is no other selected row under
    1967                 :          0 :                 long nRow = GetCurRow();
    1968                 :          0 :                 sal_Bool bLocalSelect = ( !IsRowSelected( nRow ) ||
    1969 [ #  # ][ #  # ]:          0 :                                  GetSelectRowCount() == 1 || IsRowSelected( nRow + 1 ) );
                 [ #  # ]
    1970                 :          0 :                 SelectRow( nCurRow, bLocalSelect, sal_True );
    1971                 :          0 :                 bDone = GoToRow( nRow - 1 , sal_False );
    1972         [ #  # ]:          0 :                 if ( bDone )
    1973                 :          0 :                     SelectRow( GetCurRow(), sal_True, sal_True );
    1974                 :            :             }
    1975                 :          0 :             break;
    1976                 :            :         case BROWSER_CURSORPAGEDOWN:
    1977                 :          0 :             bDone = (sal_Bool)ScrollRows( nRowsOnPage );
    1978                 :          0 :             break;
    1979                 :            :         case BROWSER_CURSORPAGEUP:
    1980                 :          0 :             bDone = (sal_Bool)ScrollRows( -nRowsOnPage );
    1981                 :          0 :             break;
    1982                 :            :         case BROWSER_CURSOREND:
    1983         [ #  # ]:          0 :             if ( bColumnCursor )
    1984                 :            :             {
    1985                 :          0 :                 sal_uInt16 nNewId = GetColumnId(ColCount() -1);
    1986 [ #  # ][ #  # ]:          0 :                 bDone = nNewId != HandleColumnId && GoToColumnId( nNewId );
    1987                 :          0 :                 break;
    1988                 :            :             }
    1989                 :            :         case BROWSER_CURSORENDOFFILE:
    1990                 :          0 :             bDone = GoToRow( nRowCount - 1, sal_False );
    1991                 :          0 :             break;
    1992                 :            :         case BROWSER_CURSORRIGHT:
    1993         [ #  # ]:          0 :             if ( bColumnCursor )
    1994                 :            :             {
    1995                 :          0 :                 sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) + 1;
    1996                 :          0 :                 sal_uInt16 nNewId = GetColumnId( nNewPos );
    1997         [ #  # ]:          0 :                 if (nNewId != BROWSER_INVALIDID)    // At end of row ?
    1998                 :          0 :                     bDone = GoToColumnId( nNewId );
    1999                 :            :                 else
    2000                 :            :                 {
    2001                 :          0 :                     sal_uInt16 nColId = GetColumnId(0);
    2002 [ #  # ][ #  # ]:          0 :                     if ( nColId == BROWSER_INVALIDID || nColId == HandleColumnId )
    2003                 :          0 :                         nColId = GetColumnId(1);
    2004         [ #  # ]:          0 :                     if ( GetRowCount() )
    2005 [ #  # ][ #  # ]:          0 :                         bDone = ( nCurRow < GetRowCount() - 1 ) && GoToRowColumnId( nCurRow + 1, nColId );
    2006         [ #  # ]:          0 :                     else if ( ColCount() )
    2007                 :          0 :                         GoToColumnId( nColId );
    2008                 :            :                 }
    2009                 :            :             }
    2010                 :            :             else
    2011                 :          0 :                 bDone = ScrollColumns( 1 ) != 0;
    2012                 :          0 :             break;
    2013                 :            :         case BROWSER_CURSORHOME:
    2014         [ #  # ]:          0 :             if ( bColumnCursor )
    2015                 :            :             {
    2016                 :          0 :                 sal_uInt16 nNewId = GetColumnId(1);
    2017 [ #  # ][ #  # ]:          0 :                 bDone = (nNewId != HandleColumnId) && GoToColumnId( nNewId );
    2018                 :          0 :                 break;
    2019                 :            :             }
    2020                 :            :         case BROWSER_CURSORTOPOFFILE:
    2021                 :          0 :             bDone = GoToRow( 0, sal_False );
    2022                 :          0 :             break;
    2023                 :            :         case BROWSER_CURSORLEFT:
    2024         [ #  # ]:          0 :             if ( bColumnCursor )
    2025                 :            :             {
    2026                 :          0 :                 sal_uInt16 nNewPos = GetColumnPos( GetCurColumnId() ) - 1;
    2027                 :          0 :                 sal_uInt16 nNewId = GetColumnId( nNewPos );
    2028         [ #  # ]:          0 :                 if (nNewId != HandleColumnId)
    2029                 :          0 :                     bDone = GoToColumnId( nNewId );
    2030                 :            :                 else
    2031                 :            :                 {
    2032         [ #  # ]:          0 :                     if ( GetRowCount() )
    2033 [ #  # ][ #  # ]:          0 :                         bDone = (nCurRow > 0) && GoToRowColumnId(nCurRow - 1, GetColumnId(ColCount() -1));
    2034         [ #  # ]:          0 :                     else if ( ColCount() )
    2035                 :          0 :                         GoToColumnId( GetColumnId(ColCount() -1) );
    2036                 :            :                 }
    2037                 :            :             }
    2038                 :            :             else
    2039                 :          0 :                 bDone = ScrollColumns( -1 ) != 0;
    2040                 :          0 :             break;
    2041                 :            :         case BROWSER_ENHANCESELECTION:
    2042         [ #  # ]:          0 :             if ( GetRowCount() )
    2043                 :          0 :                 SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_True );
    2044                 :          0 :             bDone = sal_True;
    2045                 :          0 :             break;
    2046                 :            :         case BROWSER_SELECT:
    2047         [ #  # ]:          0 :             if ( GetRowCount() )
    2048                 :          0 :                 SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), sal_False );
    2049                 :          0 :             bDone = sal_True;
    2050                 :          0 :             break;
    2051                 :            :         case BROWSER_MOVECOLUMNLEFT:
    2052                 :            :         case BROWSER_MOVECOLUMNRIGHT:
    2053                 :            :             { // check if column moving is allowed
    2054                 :          0 :                 BrowserHeader* pHeaderBar = getDataWindow()->pHeaderBar;
    2055 [ #  # ][ #  # ]:          0 :                 if ( pHeaderBar && pHeaderBar->IsDragable() )
                 [ #  # ]
    2056                 :            :                 {
    2057                 :          0 :                     sal_uInt16 nColId = GetCurColumnId();
    2058                 :          0 :                     sal_Bool bColumnSelected = IsColumnSelected(nColId);
    2059                 :          0 :                     sal_uInt16 nNewPos = GetColumnPos(nColId);
    2060                 :          0 :                     sal_Bool bMoveAllowed = sal_False;
    2061 [ #  # ][ #  # ]:          0 :                     if ( BROWSER_MOVECOLUMNLEFT == nId && nNewPos > 1 )
    2062                 :          0 :                         --nNewPos,bMoveAllowed = sal_True;
    2063 [ #  # ][ #  # ]:          0 :                     else if ( BROWSER_MOVECOLUMNRIGHT == nId && nNewPos < (ColCount()-1) )
                 [ #  # ]
    2064                 :          0 :                         ++nNewPos,bMoveAllowed = sal_True;
    2065                 :            : 
    2066         [ #  # ]:          0 :                     if ( bMoveAllowed )
    2067                 :            :                     {
    2068                 :          0 :                         SetColumnPos( nColId, nNewPos );
    2069                 :          0 :                         ColumnMoved( nColId );
    2070                 :          0 :                         MakeFieldVisible(GetCurRow(),nColId,sal_True);
    2071         [ #  # ]:          0 :                         if ( bColumnSelected )
    2072                 :          0 :                             SelectColumnId(nColId);
    2073                 :            :                     }
    2074                 :            :                 }
    2075                 :            :             }
    2076                 :          0 :             break;
    2077                 :            :     }
    2078                 :            : 
    2079                 :            :     //! return bDone;
    2080                 :          0 : }
    2081                 :            : 
    2082                 :            : //-------------------------------------------------------------------
    2083                 :            : 
    2084                 :         80 : void BrowseBox::SetCursorColor(const Color& _rCol)
    2085                 :            : {
    2086         [ -  + ]:         80 :     if (_rCol == m_aCursorColor)
    2087                 :         80 :         return;
    2088                 :            : 
    2089                 :            :     // ensure the cursor is hidden
    2090                 :         80 :     DoHideCursor("SetCursorColor");
    2091         [ +  + ]:         80 :     if (!m_bFocusOnlyCursor)
    2092                 :          8 :         DoHideCursor("SetCursorColor - force");
    2093                 :            : 
    2094                 :         80 :     m_aCursorColor = _rCol;
    2095                 :            : 
    2096         [ +  + ]:         80 :     if (!m_bFocusOnlyCursor)
    2097                 :          8 :         DoShowCursor("SetCursorColor - force");
    2098                 :         80 :     DoShowCursor("SetCursorColor");
    2099                 :            : }
    2100                 :            : // -----------------------------------------------------------------------------
    2101                 :          0 : Rectangle BrowseBox::calcHeaderRect(sal_Bool _bIsColumnBar,sal_Bool _bOnScreen)
    2102                 :            : {
    2103                 :          0 :     Window* pParent = NULL;
    2104         [ #  # ]:          0 :     if ( !_bOnScreen )
    2105         [ #  # ]:          0 :         pParent = GetAccessibleParentWindow();
    2106                 :            : 
    2107                 :          0 :     Point aTopLeft;
    2108                 :            :     long nWidth;
    2109                 :            :     long nHeight;
    2110         [ #  # ]:          0 :     if ( _bIsColumnBar )
    2111                 :            :     {
    2112                 :          0 :         nWidth = GetDataWindow().GetOutputSizePixel().Width();
    2113         [ #  # ]:          0 :         nHeight = GetDataRowHeight();
    2114                 :            :     }
    2115                 :            :     else
    2116                 :            :     {
    2117         [ #  # ]:          0 :         aTopLeft.Y() = GetDataRowHeight();
    2118         [ #  # ]:          0 :         nWidth = GetColumnWidth(0);
    2119 [ #  # ][ #  # ]:          0 :         nHeight = GetWindowExtentsRelative( pParent ).GetHeight() - aTopLeft.Y() - GetControlArea().GetSize().B();
         [ #  # ][ #  # ]
    2120                 :            :     }
    2121         [ #  # ]:          0 :     aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft();
    2122         [ #  # ]:          0 :     return Rectangle(aTopLeft,Size(nWidth,nHeight));
    2123                 :            : }
    2124                 :            : // -----------------------------------------------------------------------------
    2125                 :          0 : Rectangle BrowseBox::calcTableRect(sal_Bool _bOnScreen)
    2126                 :            : {
    2127                 :          0 :     Window* pParent = NULL;
    2128         [ #  # ]:          0 :     if ( !_bOnScreen )
    2129         [ #  # ]:          0 :         pParent = GetAccessibleParentWindow();
    2130                 :            : 
    2131         [ #  # ]:          0 :     Rectangle aRect( GetWindowExtentsRelative( pParent ) );
    2132         [ #  # ]:          0 :     Rectangle aRowBar = calcHeaderRect(sal_False,pParent == NULL);
    2133                 :            : 
    2134                 :          0 :     long nX = aRowBar.Right() - aRect.Left();
    2135                 :          0 :     long nY = aRowBar.Top() - aRect.Top();
    2136         [ #  # ]:          0 :     Size aSize(aRect.GetSize());
    2137                 :            : 
    2138 [ #  # ][ #  # ]:          0 :     return Rectangle(aRowBar.TopRight(), Size(aSize.A() - nX, aSize.B() - nY - aHScroll.GetSizePixel().Height()) );
                 [ #  # ]
    2139                 :            : }
    2140                 :            : // -----------------------------------------------------------------------------
    2141                 :          0 : Rectangle BrowseBox::GetFieldRectPixelAbs( sal_Int32 _nRowId,sal_uInt16 _nColId, sal_Bool /*_bIsHeader*/, sal_Bool _bOnScreen )
    2142                 :            : {
    2143                 :          0 :     Window* pParent = NULL;
    2144         [ #  # ]:          0 :     if ( !_bOnScreen )
    2145         [ #  # ]:          0 :         pParent = GetAccessibleParentWindow();
    2146                 :            : 
    2147         [ #  # ]:          0 :     Rectangle aRect = GetFieldRectPixel(_nRowId,_nColId,_bOnScreen);
    2148                 :            : 
    2149                 :          0 :     Point aTopLeft = aRect.TopLeft();
    2150         [ #  # ]:          0 :     aTopLeft += GetWindowExtentsRelative( pParent ).TopLeft();
    2151                 :            : 
    2152 [ #  # ][ #  # ]:          0 :     return Rectangle(aTopLeft,aRect.GetSize());
    2153                 :            : }
    2154                 :            : 
    2155                 :            : // ------------------------------------------------------------------------- EOF
    2156                 :            : 
    2157                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10