LCOV - code coverage report
Current view: top level - libreoffice/svtools/source/table - tabledatawindow.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 99 0.0 %
Date: 2012-12-17 Functions: 0 13 0.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             :     /** === begin UNO using === **/
      35             :     using ::com::sun::star::uno::Any;
      36             :     /** === end UNO using === **/
      37             : 
      38             :     //==================================================================================================================
      39             :     //= TableDataWindow
      40             :     //==================================================================================================================
      41             :     //------------------------------------------------------------------------------------------------------------------
      42           0 :     TableDataWindow::TableDataWindow( TableControl_Impl& _rTableControl )
      43           0 :         :Window( &_rTableControl.getAntiImpl() )
      44             :         ,m_rTableControl( _rTableControl )
      45           0 :         ,m_nTipWindowHandle( 0 )
      46             :     {
      47             :         // by default, use the background as determined by the style settings
      48           0 :         const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() );
      49           0 :         SetBackground( Wallpaper( aWindowColor ) );
      50           0 :         SetFillColor( aWindowColor );
      51           0 :     }
      52             : 
      53             :     //------------------------------------------------------------------------------------------------------------------
      54           0 :     TableDataWindow::~TableDataWindow()
      55             :     {
      56           0 :         impl_hideTipWindow();
      57           0 :     }
      58             : 
      59             :     //------------------------------------------------------------------------------------------------------------------
      60           0 :     void TableDataWindow::Paint( const Rectangle& rUpdateRect )
      61             :     {
      62           0 :         m_rTableControl.doPaintContent( rUpdateRect );
      63           0 :     }
      64             :     //------------------------------------------------------------------------------------------------------------------
      65           0 :     void TableDataWindow::SetBackground( const Wallpaper& rColor )
      66             :     {
      67           0 :         Window::SetBackground( rColor );
      68           0 :     }
      69             :     //------------------------------------------------------------------------------------------------------------------
      70           0 :     void TableDataWindow::SetControlBackground( const Color& rColor )
      71             :     {
      72           0 :         Window::SetControlBackground( rColor );
      73           0 :     }
      74             :     //------------------------------------------------------------------------------------------------------------------
      75           0 :     void TableDataWindow::SetControlBackground()
      76             :     {
      77           0 :         Window::SetControlBackground();
      78           0 :     }
      79             : 
      80             :     //------------------------------------------------------------------------------------------------------------------
      81           0 :     void TableDataWindow::RequestHelp( const HelpEvent& rHEvt )
      82             :     {
      83           0 :         sal_uInt16 const nHelpMode = rHEvt.GetMode();
      84           0 :         if  (   ( IsMouseCaptured() )
      85             :             ||  ( ( nHelpMode & HELPMODE_QUICK ) == 0 )
      86             :             )
      87             :         {
      88           0 :             Window::RequestHelp( rHEvt );
      89           0 :             return;
      90             :         }
      91             : 
      92           0 :         ::rtl::OUString sHelpText;
      93           0 :         sal_uInt16 nHelpStyle = 0;
      94             : 
      95           0 :         Point const aMousePos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
      96           0 :         RowPos const hitRow = m_rTableControl.getRowAtPoint( aMousePos );
      97           0 :         ColPos const hitCol = m_rTableControl.getColAtPoint( aMousePos );
      98             : 
      99           0 :         PTableModel const pTableModel( m_rTableControl.getModel() );
     100           0 :         if ( ( hitCol >= 0 ) && ( hitCol < pTableModel->getColumnCount() ) )
     101             :         {
     102           0 :             if ( hitRow == ROW_COL_HEADERS )
     103             :             {
     104           0 :                 sHelpText = pTableModel->getColumnModel( hitCol )->getHelpText();
     105             :             }
     106           0 :             else if ( ( hitRow >= 0 ) && ( hitRow < pTableModel->getRowCount() ) )
     107             :             {
     108           0 :                 Any aCellToolTip;
     109           0 :                 pTableModel->getCellToolTip( hitCol, hitRow, aCellToolTip );
     110           0 :                 if ( !aCellToolTip.hasValue() )
     111             :                 {
     112             :                     // use the cell content
     113           0 :                     pTableModel->getCellContent( hitCol, hitRow, aCellToolTip );
     114             : 
     115             :                     // use the cell content as tool tip only if it doesn't fit into the cell.
     116           0 :                     bool const activeCell = ( hitRow == m_rTableControl.getCurrentRow() ) && ( hitCol == m_rTableControl.getCurrentColumn() );
     117           0 :                     bool const selectedCell = m_rTableControl.isRowSelected( hitRow );
     118             : 
     119           0 :                     Rectangle const aWindowRect( Point( 0, 0 ), GetOutputSizePixel() );
     120           0 :                     TableCellGeometry const aCell( m_rTableControl, aWindowRect, hitCol, hitRow );
     121           0 :                     Rectangle const aCellRect( aCell.getRect() );
     122             : 
     123           0 :                     PTableRenderer const pRenderer = pTableModel->getRenderer();
     124           0 :                     if ( pRenderer->FitsIntoCell( aCellToolTip, hitCol, hitRow, activeCell, selectedCell, *this, aCellRect ) )
     125           0 :                         aCellToolTip.clear();
     126             :                 }
     127             : 
     128           0 :                 pTableModel->getRenderer()->GetFormattedCellString( aCellToolTip, hitCol, hitRow, sHelpText );
     129             : 
     130           0 :                 if ( sHelpText.indexOf( '\n' ) >= 0 )
     131           0 :                     nHelpStyle = QUICKHELP_TIP_STYLE_BALLOON;
     132             :             }
     133             :         }
     134             : 
     135           0 :         if ( !sHelpText.isEmpty() )
     136             :         {
     137             :             // hide the standard (singleton) help window, so we do not have two help windows open at the same time
     138           0 :             Help::HideBalloonAndQuickHelp();
     139             : 
     140             :             Rectangle const aControlScreenRect(
     141           0 :                 OutputToScreenPixel( Point( 0, 0 ) ),
     142           0 :                 GetOutputSizePixel()
     143           0 :             );
     144             : 
     145           0 :             if ( m_nTipWindowHandle )
     146             :             {
     147           0 :                 Help::UpdateTip( m_nTipWindowHandle, this, aControlScreenRect, sHelpText );
     148             :             }
     149             :             else
     150           0 :                 m_nTipWindowHandle = Help::ShowTip( this, aControlScreenRect, sHelpText, nHelpStyle );
     151             :         }
     152             :         else
     153             :         {
     154           0 :             impl_hideTipWindow();
     155           0 :             Window::RequestHelp( rHEvt );
     156           0 :         }
     157             :     }
     158             : 
     159             :     //------------------------------------------------------------------------------------------------------------------
     160           0 :     void TableDataWindow::impl_hideTipWindow()
     161             :     {
     162           0 :         if ( m_nTipWindowHandle != 0 )
     163             :         {
     164           0 :             Help::HideTip( m_nTipWindowHandle );
     165           0 :             m_nTipWindowHandle = 0;
     166             :         }
     167           0 :     }
     168             : 
     169             :     //------------------------------------------------------------------------------------------------------------------
     170           0 :     void TableDataWindow::MouseMove( const MouseEvent& rMEvt )
     171             :     {
     172           0 :         if ( rMEvt.IsLeaveWindow() )
     173           0 :             impl_hideTipWindow();
     174             : 
     175           0 :         if ( !m_rTableControl.getInputHandler()->MouseMove( m_rTableControl, rMEvt ) )
     176             :         {
     177           0 :             Window::MouseMove( rMEvt );
     178             :         }
     179           0 :     }
     180             :     //------------------------------------------------------------------------------------------------------------------
     181           0 :     void TableDataWindow::MouseButtonDown( const MouseEvent& rMEvt )
     182             :     {
     183           0 :         impl_hideTipWindow();
     184             : 
     185           0 :         Point const aPoint = rMEvt.GetPosPixel();
     186           0 :         RowPos const hitRow = m_rTableControl.getRowAtPoint( aPoint );
     187           0 :         bool const wasRowSelected = m_rTableControl.isRowSelected( hitRow );
     188             : 
     189           0 :         if ( !m_rTableControl.getInputHandler()->MouseButtonDown( m_rTableControl, rMEvt ) )
     190             :         {
     191           0 :             Window::MouseButtonDown( rMEvt );
     192           0 :             return;
     193             :         }
     194             : 
     195           0 :         bool const isRowSelected = m_rTableControl.isRowSelected( hitRow );
     196           0 :         if ( isRowSelected != wasRowSelected )
     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           0 :     long TableDataWindow::Notify(NotifyEvent& rNEvt )
     213             :     {
     214           0 :         long nDone = 0;
     215           0 :         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           0 :         return nDone ? nDone : Window::Notify( rNEvt );
     228             :     }
     229             : //......................................................................................................................
     230             : } } // namespace svt::table
     231             : //......................................................................................................................
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10