LCOV - code coverage report
Current view: top level - svtools/source/table - tablegeometry.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 50 0.0 %
Date: 2014-04-14 Functions: 0 8 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 "tablegeometry.hxx"
      22             : #include "tablecontrol_impl.hxx"
      23             : 
      24             : 
      25             : namespace svt { namespace table
      26             : {
      27             : 
      28             : 
      29             : 
      30             :     //= TableRowGeometry
      31             : 
      32             : 
      33           0 :     TableRowGeometry::TableRowGeometry( TableControl_Impl const & _rControl, Rectangle const & _rBoundaries,
      34             :             RowPos const _nRow, bool const i_allowVirtualRows )
      35             :         :TableGeometry( _rControl, _rBoundaries )
      36             :         ,m_nRowPos( _nRow )
      37           0 :         ,m_bAllowVirtualRows( i_allowVirtualRows )
      38             :     {
      39           0 :         if ( m_nRowPos == ROW_COL_HEADERS )
      40             :         {
      41           0 :             m_aRect.Top() = 0;
      42           0 :             m_aRect.Bottom() = m_rControl.m_nColHeaderHeightPixel - 1;
      43             :         }
      44             :         else
      45             :         {
      46           0 :             impl_initRect();
      47             :         }
      48           0 :     }
      49             : 
      50             : 
      51           0 :     void TableRowGeometry::impl_initRect()
      52             :     {
      53           0 :         if ( ( m_nRowPos >= m_rControl.m_nTopRow ) && impl_isValidRow( m_nRowPos ) )
      54             :         {
      55           0 :             m_aRect.Top() = m_rControl.m_nColHeaderHeightPixel + ( m_nRowPos - m_rControl.m_nTopRow ) * m_rControl.m_nRowHeightPixel;
      56           0 :             m_aRect.Bottom() = m_aRect.Top() + m_rControl.m_nRowHeightPixel - 1;
      57             :         }
      58             :         else
      59           0 :             m_aRect.SetEmpty();
      60           0 :     }
      61             : 
      62             : 
      63           0 :     bool TableRowGeometry::impl_isValidRow( RowPos const i_row ) const
      64             :     {
      65           0 :         return m_bAllowVirtualRows || ( i_row < m_rControl.m_pModel->getRowCount() );
      66             :     }
      67             : 
      68             : 
      69           0 :     bool TableRowGeometry::moveDown()
      70             :     {
      71           0 :         if ( m_nRowPos == ROW_COL_HEADERS )
      72             :         {
      73           0 :             m_nRowPos = m_rControl.m_nTopRow;
      74           0 :             impl_initRect();
      75             :         }
      76             :         else
      77             :         {
      78           0 :             if ( impl_isValidRow( ++m_nRowPos ) )
      79           0 :                 m_aRect.Move( 0, m_rControl.m_nRowHeightPixel );
      80             :             else
      81           0 :                 m_aRect.SetEmpty();
      82             :         }
      83           0 :         return isValid();
      84             :     }
      85             : 
      86             : 
      87             :     //= TableColumnGeometry
      88             : 
      89             : 
      90           0 :     TableColumnGeometry::TableColumnGeometry( TableControl_Impl const & _rControl, Rectangle const & _rBoundaries,
      91             :             ColPos const _nCol, bool const i_allowVirtualColumns )
      92             :         :TableGeometry( _rControl, _rBoundaries )
      93             :         ,m_nColPos( _nCol )
      94           0 :         ,m_bAllowVirtualColumns( i_allowVirtualColumns )
      95             :     {
      96           0 :         if ( m_nColPos == COL_ROW_HEADERS )
      97             :         {
      98           0 :             m_aRect.Left() = 0;
      99           0 :             m_aRect.Right() = m_rControl.m_nRowHeaderWidthPixel - 1;
     100             :         }
     101             :         else
     102             :         {
     103           0 :             impl_initRect();
     104             :         }
     105           0 :     }
     106             : 
     107             : 
     108           0 :     void TableColumnGeometry::impl_initRect()
     109             :     {
     110           0 :         ColPos nLeftColumn = m_rControl.m_nLeftColumn;
     111           0 :         if ( ( m_nColPos >= nLeftColumn ) && impl_isValidColumn( m_nColPos ) )
     112             :         {
     113           0 :             m_aRect.Left() = m_rControl.m_nRowHeaderWidthPixel;
     114             :             // TODO: take into account any possibly frozen columns
     115             : 
     116           0 :             for ( ColPos col = nLeftColumn; col < m_nColPos; ++col )
     117           0 :                 m_aRect.Left() += m_rControl.m_aColumnWidths[ col ].getWidth();
     118           0 :             m_aRect.Right() = m_aRect.Left() + m_rControl.m_aColumnWidths[ m_nColPos ].getWidth() - 1;
     119             :         }
     120             :         else
     121           0 :             m_aRect.SetEmpty();
     122           0 :     }
     123             : 
     124             : 
     125           0 :     bool TableColumnGeometry::impl_isValidColumn( ColPos const i_column ) const
     126             :     {
     127           0 :         return m_bAllowVirtualColumns || ( i_column < ColPos( m_rControl.m_aColumnWidths.size() ) );
     128             :     }
     129             : 
     130             : 
     131           0 :     bool TableColumnGeometry::moveRight()
     132             :     {
     133           0 :         if ( m_nColPos == COL_ROW_HEADERS )
     134             :         {
     135           0 :             m_nColPos = m_rControl.m_nLeftColumn;
     136           0 :             impl_initRect();
     137             :         }
     138             :         else
     139             :         {
     140           0 :             if ( impl_isValidColumn( ++m_nColPos ) )
     141             :             {
     142           0 :                 m_aRect.Left() = m_aRect.Right() + 1;
     143           0 :                 m_aRect.Right() += m_rControl.m_aColumnWidths[ m_nColPos ].getWidth();
     144             :             }
     145             :             else
     146           0 :                 m_aRect.SetEmpty();
     147             :         }
     148             : 
     149           0 :         return isValid();
     150             :     }
     151             : 
     152             : 
     153             : } } // namespace svt::table
     154             : 
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10