LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svtools/source/table - tabledatawindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 24 103 23.3 %
Date: 2013-07-09 Functions: 9 15 60.0 %
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             : 
      21             : #include "svtools/table/tablecontrol.hxx"
      22             : 
      23             : #include "tabledatawindow.hxx"
      24             : #include "tablecontrol_impl.hxx"
      25             : #include "tablegeometry.hxx"
      26             : 
      27             : #include <vcl/help.hxx>
      28             : 
      29             : //......................................................................................................................
      30             : namespace svt { namespace table
      31             : {
      32             : //......................................................................................................................
      33             : 
      34             :     using ::com::sun::star::uno::Any;
      35             : 
      36             :     //==================================================================================================================
      37             :     //= TableDataWindow
      38             :     //==================================================================================================================
      39             :     //------------------------------------------------------------------------------------------------------------------
      40           1 :     TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl )
      41           1 :         :Window( &_rTableControl.getAntiImpl() )
      42             :         ,m_rTableControl( _rTableControl )
      43           1 :         ,m_nTipWindowHandle( 0 )
      44             :     {
      45             :         // by default, use the background as determined by the style settings
      46           1 :         const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() );
      47           1 :         SetBackground( Wallpaper( aWindowColor ) );
      48           1 :         SetFillColor( aWindowColor );
      49           1 :     }
      50             : 
      51             :     //------------------------------------------------------------------------------------------------------------------
      52           3 :     TableDataWindow::~TableDataWindow()
      53             :     {
      54           1 :         impl_hideTipWindow();
      55           2 :     }
      56             : 
      57             :     //------------------------------------------------------------------------------------------------------------------
      58           2 :     void TableDataWindow::Paint( const Rectangle& rUpdateRect )
      59             :     {
      60           2 :         m_rTableControl.doPaintContent( rUpdateRect );
      61           2 :     }
      62             :     //------------------------------------------------------------------------------------------------------------------
      63           1 :     void TableDataWindow::SetBackground( const Wallpaper& rColor )
      64             :     {
      65           1 :         Window::SetBackground( rColor );
      66           1 :     }
      67             :     //------------------------------------------------------------------------------------------------------------------
      68           0 :     void TableDataWindow::SetControlBackground( const Color& rColor )
      69             :     {
      70           0 :         Window::SetControlBackground( rColor );
      71           0 :     }
      72             :     //------------------------------------------------------------------------------------------------------------------
      73           0 :     void TableDataWindow::SetControlBackground()
      74             :     {
      75           0 :         Window::SetControlBackground();
      76           0 :     }
      77             : 
      78             :     //------------------------------------------------------------------------------------------------------------------
      79           0 :     void TableDataWindow::RequestHelp( const HelpEvent& rHEvt )
      80             :     {
      81           0 :         sal_uInt16 const nHelpMode = rHEvt.GetMode();
      82           0 :         if  (   ( IsMouseCaptured() )
      83           0 :             ||  ( ( nHelpMode & HELPMODE_QUICK ) == 0 )
      84             :             )
      85             :         {
      86           0 :             Window::RequestHelp( rHEvt );
      87           0 :             return;
      88             :         }
      89             : 
      90           0 :         OUString sHelpText;
      91           0 :         sal_uInt16 nHelpStyle = 0;
      92             : 
      93           0 :         Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
      94           0 :         RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos );
      95           0 :         ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos );
      96             : 
      97           0 :         PTableModel const pTableModel( m_rTableControl.getModel() );
      98           0 :         if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) )
      99             :         {
     100           0 :             if ( hitRow == ROW_COL_HEADERS )
     101             :             {
     102           0 :                 sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText();
     103             :             }
     104           0 :             else if ( ( hitRow >= 0 ) && ( hitRow < pTableModel->getRowCount() ) )
     105             :             {
     106           0 :                 Any aCellToolTip;
     107           0 :                 pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip );
     108           0 :                 if ( !aCellToolTip.hasValue() )
     109             :                 {
     110             :                     // use the cell content
     111           0 :                     pTableModel->getCellContent( hitCol, hitRow, aCellToolTip );
     112             : 
     113             :                     // use the cell content as tool tip only if it doesn't fit into the cell.
     114           0 :                     bool const activeCell = ( hitRow == m_rTableControl.getCurrentRow() ) && ( hitCol == m_rTableControl.getCurrentColumn() );
     115           0 :                     bool const selectedCell = m_rTableControl.isRowSelected( hitRow );
     116             : 
     117           0 :                     Rectangle const aWindowRect( Point( 0, 0 ), GetOutputSizePixel() );
     118           0 :                     TableCellGeometry const aCell( m_rTableControl, aWindowRect, hitCol, hitRow );
     119           0 :                     Rectangle const aCellRect( aCell.getRect() );
     120             : 
     121           0 :                     PTableRenderer const pRenderer = pTableModel->getRenderer();
     122           0 :                     if ( pRenderer->FitsIntoCell( aCellToolTip, hitCol, hitRow, activeCell, selectedCell, *this, aCellRect ) )
     123           0 :                         aCellToolTip.clear();
     124             :                 }
     125             : 
     126           0 :                 pTableModel->getRenderer()->GetFormattedCellString( aCellToolTip, hitCol, hitRow, sHelpText );
     127             : 
     128           0 :                 if ( sHelpText.indexOf( '\n' ) >= 0 )
     129           0 :                     nHelpStyle = QUICKHELP_TIP_STYLE_BALLOON;
     130             :             }
     131             :         }
     132             : 
     133           0 :         if ( !sHelpText.isEmpty() )
     134             :         {
     135             :             // hide the standard (singleton) help window, so we do not have two help windows open at the same time
     136           0 :             Help::HideBalloonAndQuickHelp();
     137             : 
     138             :             Rectangle const aControlScreenRect(
     139           0 :                 OutputToScreenPixel( Point( 0, 0 ) ),
     140           0 :                 GetOutputSizePixel()
     141           0 :             );
     142             : 
     143           0 :             if ( m_nTipWindowHandle )
     144             :             {
     145           0 :                 Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText );
     146             :             }
     147             :             else
     148           0 :                 m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle );
     149             :         }
     150             :         else
     151             :         {
     152           0 :             impl_hideTipWindow();
     153           0 :             Window::RequestHelp( rHEvt );
     154           0 :         }
     155             :     }
     156             : 
     157             :     //------------------------------------------------------------------------------------------------------------------
     158           1 :     void TableDataWindow::impl_hideTipWindow()
     159             :     {
     160           1 :         if ( m_nTipWindowHandle != 0 )
     161             :         {
     162           0 :             Help::HideTip( m_nTipWindowHandle );
     163           0 :             m_nTipWindowHandle = 0;
     164             :         }
     165           1 :     }
     166             : 
     167             :     //------------------------------------------------------------------------------------------------------------------
     168           0 :     void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
     169             :     {
     170           0 :         if ( rMEvt.IsLeaveWindow() )
     171           0 :             impl_hideTipWindow();
     172             : 
     173           0 :         if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) )
     174             :         {
     175           0 :             Window::MouseMove( rMEvt );
     176             :         }
     177           0 :     }
     178             :     //------------------------------------------------------------------------------------------------------------------
     179           0 :     void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt )
     180             :     {
     181           0 :         impl_hideTipWindow();
     182             : 
     183           0 :         Point const aPoint = rMEvt.GetPosPixel();
     184           0 :         RowPos const hitRow = m_rTableControl.getRowAtPoint( aPoint );
     185           0 :         bool const wasRowSelected = m_rTableControl.isRowSelected( hitRow );
     186           0 :         size_t const nPrevSelRowCount = m_rTableControl.getSelectedRowCount();
     187             : 
     188           0 :         if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) )
     189             :         {
     190           0 :             Window::MouseButtonDown( rMEvt );
     191           0 :             return;
     192             :         }
     193             : 
     194           0 :         bool const isRowSelected = m_rTableControl.isRowSelected( hitRow );
     195           0 :         size_t const nCurSelRowCount = m_rTableControl.getSelectedRowCount();
     196           0 :         if ( isRowSelected != wasRowSelected || nCurSelRowCount != nPrevSelRowCount )
     197             :         {
     198           0 :             m_aSelectHdl.Call( NULL );
     199             :         }
     200             :     }
     201             : 
     202             :     //------------------------------------------------------------------------------------------------------------------
     203           0 :     void TableDataWindow::MouseButtonUp( const MouseEvent& rMEvt )
     204             :     {
     205           0 :         if ( !m_rTableControl.getInputHandler()->MouseButtonUp( m_rTableControl, rMEvt ) )
     206           0 :             Window::MouseButtonUp( rMEvt );
     207             : 
     208           0 :         m_rTableControl.getAntiImpl().GrabFocus();
     209           0 :     }
     210             : 
     211             :     //------------------------------------------------------------------------------------------------------------------
     212           1 :     long TableDataWindow::Notify(NotifyEvent& rNEvt )
     213             :     {
     214           1 :         long nDone = 0;
     215           1 :         if ( rNEvt.GetType() == EVENT_COMMAND )
     216             :         {
     217           0 :             const CommandEvent& rCEvt = *rNEvt.GetCommandEvent();
     218           0 :             if ( rCEvt.GetCommand() == COMMAND_WHEEL )
     219             :             {
     220           0 :                 const CommandWheelData* pData = rCEvt.GetWheelData();
     221           0 :                 if( !pData->GetModifier() && ( pData->GetMode() == COMMAND_WHEEL_SCROLL ) )
     222             :                 {
     223           0 :                     nDone = HandleScrollCommand( rCEvt, m_rTableControl.getHorzScrollbar(), m_rTableControl.getVertScrollbar() );
     224             :                 }
     225             :             }
     226             :         }
     227           1 :         return nDone ? nDone : Window::Notify( rNEvt );
     228             :     }
     229             : //......................................................................................................................
     230         465 : } } // namespace svt::table
     231             : //......................................................................................................................
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10