LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/brwbox - brwbox2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 378 1066 35.5 %
Date: 2013-07-09 Functions: 18 64 28.1 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10