LCOV - code coverage report
Current view: top level - svtools/source/table - tabledatawindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 98 0.0 %
Date: 2012-08-25 Functions: 0 13 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 164 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       4                 :            :  *
       5                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       6                 :            :  *
       7                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       8                 :            :  *
       9                 :            :  * This file is part of OpenOffice.org.
      10                 :            :  *
      11                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      12                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      13                 :            :  * only, as published by the Free Software Foundation.
      14                 :            :  *
      15                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      16                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      17                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18                 :            :  * GNU Lesser General Public License version 3 for more details
      19                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      20                 :            :  *
      21                 :            :  * You should have received a copy of the GNU Lesser General Public License
      22                 :            :  * version 3 along with OpenOffice.org.  If not, see
      23                 :            :  * <http://www.openoffice.org/license.html>
      24                 :            :  * for a copy of the LGPLv3 License.
      25                 :            :  *
      26                 :            : ************************************************************************/
      27                 :            : 
      28                 :            : 
      29                 :            : #include "svtools/table/tablecontrol.hxx"
      30                 :            : 
      31                 :            : #include "tabledatawindow.hxx"
      32                 :            : #include "tablecontrol_impl.hxx"
      33                 :            : #include "tablegeometry.hxx"
      34                 :            : #include "cellvalueconversion.hxx"
      35                 :            : 
      36                 :            : #include <vcl/help.hxx>
      37                 :            : 
      38                 :            : //......................................................................................................................
      39                 :            : namespace svt { namespace table
      40                 :            : {
      41                 :            : //......................................................................................................................
      42                 :            : 
      43                 :            :     /** === begin UNO using === **/
      44                 :            :     using ::com::sun::star::uno::Any;
      45                 :            :     /** === end UNO using === **/
      46                 :            : 
      47                 :            :     //==================================================================================================================
      48                 :            :     //= TableDataWindow
      49                 :            :     //==================================================================================================================
      50                 :            :     //------------------------------------------------------------------------------------------------------------------
      51                 :          0 :     TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl )
      52                 :          0 :         :Window( &_rTableControl.getAntiImpl() )
      53                 :            :         ,m_rTableControl( _rTableControl )
      54 [ #  # ][ #  # ]:          0 :         ,m_nTipWindowHandle( 0 )
                 [ #  # ]
      55                 :            :     {
      56                 :            :         // by default, use the background as determined by the style settings
      57                 :          0 :         const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() );
      58 [ #  # ][ #  # ]:          0 :         SetBackground( Wallpaper( aWindowColor ) );
                 [ #  # ]
      59         [ #  # ]:          0 :         SetFillColor( aWindowColor );
      60                 :          0 :     }
      61                 :            : 
      62                 :            :     //------------------------------------------------------------------------------------------------------------------
      63                 :          0 :     TableDataWindow::~TableDataWindow()
      64                 :            :     {
      65         [ #  # ]:          0 :         impl_hideTipWindow();
      66         [ #  # ]:          0 :     }
      67                 :            : 
      68                 :            :     //------------------------------------------------------------------------------------------------------------------
      69                 :          0 :     void TableDataWindow::Paint( const Rectangle& rUpdateRect )
      70                 :            :     {
      71                 :          0 :         m_rTableControl.doPaintContent( rUpdateRect );
      72                 :          0 :     }
      73                 :            :     //------------------------------------------------------------------------------------------------------------------
      74                 :          0 :     void TableDataWindow::SetBackground( const Wallpaper& rColor )
      75                 :            :     {
      76                 :          0 :         Window::SetBackground( rColor );
      77                 :          0 :     }
      78                 :            :     //------------------------------------------------------------------------------------------------------------------
      79                 :          0 :     void TableDataWindow::SetControlBackground( const Color& rColor )
      80                 :            :     {
      81                 :          0 :         Window::SetControlBackground( rColor );
      82                 :          0 :     }
      83                 :            :     //------------------------------------------------------------------------------------------------------------------
      84                 :          0 :     void TableDataWindow::SetControlBackground()
      85                 :            :     {
      86                 :          0 :         Window::SetControlBackground();
      87                 :          0 :     }
      88                 :            : 
      89                 :            :     //------------------------------------------------------------------------------------------------------------------
      90                 :          0 :     void TableDataWindow::RequestHelp( const HelpEvent& rHEvt )
      91                 :            :     {
      92                 :          0 :         sal_uInt16 const nHelpMode = rHEvt.GetMode();
      93 [ #  # ][ #  # ]:          0 :         if  (   ( IsMouseCaptured() )
         [ #  # ][ #  # ]
      94                 :            :             ||  ( ( nHelpMode & HELPMODE_QUICK ) == 0 )
      95                 :            :             )
      96                 :            :         {
      97         [ #  # ]:          0 :             Window::RequestHelp( rHEvt );
      98                 :          0 :             return;
      99                 :            :         }
     100                 :            : 
     101                 :          0 :         ::rtl::OUString sHelpText;
     102                 :          0 :         sal_uInt16 nHelpStyle = 0;
     103                 :            : 
     104 [ #  # ][ #  # ]:          0 :         Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
     105         [ #  # ]:          0 :         RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos );
     106         [ #  # ]:          0 :         ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos );
     107                 :            : 
     108         [ #  # ]:          0 :         PTableModel const pTableModel( m_rTableControl.getModel() );
     109 [ #  # ][ #  # ]:          0 :         if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) )
         [ #  # ][ #  # ]
     110                 :            :         {
     111         [ #  # ]:          0 :             if ( hitRow == ROW_COL_HEADERS )
     112                 :            :             {
     113 [ #  # ][ #  # ]:          0 :                 sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText();
         [ #  # ][ #  # ]
                 [ #  # ]
     114                 :            :             }
     115 [ #  # ][ #  # ]:          0 :             else if ( ( hitRow >= 0 ) && ( hitRow < pTableModel->getRowCount() ) )
         [ #  # ][ #  # ]
     116                 :            :             {
     117                 :          0 :                 Any aCellToolTip;
     118         [ #  # ]:          0 :                 pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip );
     119         [ #  # ]:          0 :                 if ( !aCellToolTip.hasValue() )
     120                 :            :                 {
     121                 :            :                     // use the cell content
     122         [ #  # ]:          0 :                     pTableModel->getCellContent( hitCol, hitRow, aCellToolTip );
     123                 :            : 
     124                 :            :                     // use the cell content as tool tip only if it doesn't fit into the cell.
     125 [ #  # ][ #  # ]:          0 :                     bool const activeCell = ( hitRow == m_rTableControl.getCurrentRow() ) && ( hitCol == m_rTableControl.getCurrentColumn() );
         [ #  # ][ #  # ]
     126         [ #  # ]:          0 :                     bool const selectedCell = m_rTableControl.isRowSelected( hitRow );
     127                 :            : 
     128         [ #  # ]:          0 :                     Rectangle const aWindowRect( Point( 0, 0 ), GetOutputSizePixel() );
     129         [ #  # ]:          0 :                     TableCellGeometry const aCell( m_rTableControl, aWindowRect, hitCol, hitRow );
     130         [ #  # ]:          0 :                     Rectangle const aCellRect( aCell.getRect() );
     131                 :            : 
     132         [ #  # ]:          0 :                     PTableRenderer const pRenderer = pTableModel->getRenderer();
     133 [ #  # ][ #  # ]:          0 :                     if ( pRenderer->FitsIntoCell( aCellToolTip, hitCol, hitRow, activeCell, selectedCell, *this, aCellRect ) )
     134         [ #  # ]:          0 :                         aCellToolTip.clear();
     135                 :            :                 }
     136                 :            : 
     137         [ #  # ]:          0 :                 sHelpText = CellValueConversion::convertToString( aCellToolTip );
     138                 :            : 
     139         [ #  # ]:          0 :                 if ( sHelpText.indexOf( '\n' ) >= 0 )
     140                 :          0 :                     nHelpStyle = QUICKHELP_TIP_STYLE_BALLOON;
     141                 :            :             }
     142                 :            :         }
     143                 :            : 
     144         [ #  # ]:          0 :         if ( !sHelpText.isEmpty() )
     145                 :            :         {
     146                 :            :             Rectangle const aControlScreenRect(
     147                 :          0 :                 OutputToScreenPixel( Point( 0, 0 ) ),
     148                 :          0 :                 GetOutputSizePixel()
     149 [ #  # ][ #  # ]:          0 :             );
     150                 :            : 
     151         [ #  # ]:          0 :             if ( m_nTipWindowHandle )
     152 [ #  # ][ #  # ]:          0 :                 Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText );
                 [ #  # ]
     153                 :            :             else
     154 [ #  # ][ #  # ]:          0 :                 m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle );
                 [ #  # ]
     155                 :            :         }
     156                 :            :         else
     157 [ #  # ][ #  # ]:          0 :             impl_hideTipWindow();
     158                 :            :     }
     159                 :            : 
     160                 :            :     //------------------------------------------------------------------------------------------------------------------
     161                 :          0 :     void TableDataWindow::impl_hideTipWindow()
     162                 :            :     {
     163         [ #  # ]:          0 :         if ( m_nTipWindowHandle != 0 )
     164                 :            :         {
     165                 :          0 :             Help::HideTip( m_nTipWindowHandle );
     166                 :          0 :             m_nTipWindowHandle = 0;
     167                 :            :         }
     168                 :          0 :     }
     169                 :            : 
     170                 :            :     //------------------------------------------------------------------------------------------------------------------
     171                 :          0 :     void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
     172                 :            :     {
     173         [ #  # ]:          0 :         if ( rMEvt.IsLeaveWindow() )
     174                 :          0 :             impl_hideTipWindow();
     175                 :            : 
     176         [ #  # ]:          0 :         if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) )
     177                 :            :         {
     178                 :          0 :             Window::MouseMove( rMEvt );
     179                 :            :         }
     180                 :          0 :     }
     181                 :            :     //------------------------------------------------------------------------------------------------------------------
     182                 :          0 :     void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt )
     183                 :            :     {
     184         [ #  # ]:          0 :         impl_hideTipWindow();
     185                 :            : 
     186                 :          0 :         Point const aPoint = rMEvt.GetPosPixel();
     187         [ #  # ]:          0 :         RowPos const hitRow = m_rTableControl.getRowAtPoint( aPoint );
     188         [ #  # ]:          0 :         bool const wasRowSelected = m_rTableControl.isRowSelected( hitRow );
     189                 :            : 
     190 [ #  # ][ #  # ]:          0 :         if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) )
     191                 :            :         {
     192         [ #  # ]:          0 :             Window::MouseButtonDown( rMEvt );
     193                 :          0 :             return;
     194                 :            :         }
     195                 :            : 
     196         [ #  # ]:          0 :         bool const isRowSelected = m_rTableControl.isRowSelected( hitRow );
     197         [ #  # ]:          0 :         if ( isRowSelected != wasRowSelected )
     198                 :            :         {
     199         [ #  # ]:          0 :             m_aSelectHdl.Call( NULL );
     200                 :            :         }
     201         [ #  # ]:          0 :         m_aMouseButtonDownHdl.Call((MouseEvent*) &rMEvt);
     202                 :            :     }
     203                 :            : 
     204                 :            :     //------------------------------------------------------------------------------------------------------------------
     205                 :          0 :     void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt )
     206                 :            :     {
     207         [ #  # ]:          0 :         if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) )
     208                 :          0 :             Window::MouseButtonUp( rMEvt );
     209                 :            : 
     210                 :          0 :         m_aMouseButtonUpHdl.Call((MouseEvent*) &rMEvt);
     211                 :          0 :         m_rTableControl.getAntiImpl().GrabFocus();
     212                 :          0 :     }
     213                 :            : 
     214                 :            :     //------------------------------------------------------------------------------------------------------------------
     215                 :          0 :     long TableDataWindow::Notify(NotifyEvent& rNEvt )
     216                 :            :     {
     217                 :          0 :         long nDone = 0;
     218         [ #  # ]:          0 :         if ( rNEvt.GetType() == EVENT_COMMAND )
     219                 :            :         {
     220                 :          0 :             const CommandEvent& rCEvt = *rNEvt.GetCommandEvent();
     221         [ #  # ]:          0 :             if ( rCEvt.GetCommand() == COMMAND_WHEEL )
     222                 :            :             {
     223                 :          0 :                 const CommandWheelData* pData = rCEvt.GetWheelData();
     224 [ #  # ][ #  # ]:          0 :                 if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) )
                 [ #  # ]
     225                 :            :                 {
     226                 :          0 :                     nDone = HandleScrollCommand( rCEvt, m_rTableControl.getHorzScrollbar(), m_rTableControl.getVertScrollbar() );
     227                 :            :                 }
     228                 :            :             }
     229                 :            :         }
     230         [ #  # ]:          0 :         return nDone ? nDone : Window::Notify( rNEvt );
     231                 :            :     }
     232                 :            : //......................................................................................................................
     233                 :            : } } // namespace svt::table
     234                 :            : //......................................................................................................................
     235                 :            : 
     236                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10