LCOV - code coverage report
Current view: top level - sw/source/core/bastyp - tabcol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 54 72.2 %
Date: 2012-08-25 Functions: 6 7 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 38 21.1 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "tabcol.hxx"
      30                 :            : 
      31                 :            : #include <limits.h>
      32                 :            : #include <osl/diagnose.h>
      33                 :            : 
      34                 :        148 : SwTabCols::SwTabCols( sal_uInt16 nSize ) :
      35                 :            :     nLeftMin( 0 ),
      36                 :            :     nLeft( 0 ),
      37                 :            :     nRight( 0 ),
      38                 :            :     nRightMax( 0 ),
      39                 :        148 :     bLastRowAllowedToChange( true )
      40                 :            : {
      41         [ -  + ]:        148 :     if ( nSize )
      42         [ #  # ]:          0 :         aData.reserve( nSize );
      43                 :        148 : }
      44                 :            : 
      45                 :        129 : SwTabCols::SwTabCols( const SwTabCols& rCpy ) :
      46                 :        129 :     nLeftMin( rCpy.GetLeftMin() ),
      47                 :        129 :     nLeft( rCpy.GetLeft() ),
      48                 :        129 :     nRight( rCpy.GetRight() ),
      49                 :        129 :     nRightMax( rCpy.GetRightMax() ),
      50                 :        129 :     bLastRowAllowedToChange( rCpy.IsLastRowAllowedToChange() ),
      51                 :        129 :     aData( rCpy.GetData() )
      52                 :            : {
      53                 :            : #if OSL_DEBUG_LEVEL > 0
      54                 :            :     for ( sal_uInt16 i = 0; i < Count(); ++i )
      55                 :            :     {
      56                 :            :         SwTabColsEntry aEntry1 = aData[i];
      57                 :            :         SwTabColsEntry aEntry2 = rCpy.GetData()[i];
      58                 :            :         (void) aEntry1;
      59                 :            :         (void) aEntry2;
      60                 :            :         OSL_ENSURE( aEntry1.nPos == aEntry2.nPos &&
      61                 :            :                     aEntry1.nMin == aEntry2.nMin &&
      62                 :            :                     aEntry1.nMax == aEntry2.nMax &&
      63                 :            :                     aEntry1.bHidden == aEntry2.bHidden,
      64                 :            :                     "CopyContructor of SwTabColsEntries did not succeed!" );
      65                 :            :     }
      66                 :            : #endif
      67                 :        129 : }
      68                 :            : 
      69                 :         11 : SwTabCols &SwTabCols::operator=( const SwTabCols& rCpy )
      70                 :            : {
      71                 :         11 :     nLeftMin = rCpy.GetLeftMin();
      72                 :         11 :     nLeft    = rCpy.GetLeft();
      73                 :         11 :     nRight   = rCpy.GetRight();
      74                 :         11 :     nRightMax= rCpy.GetRightMax();
      75                 :         11 :     bLastRowAllowedToChange = rCpy.IsLastRowAllowedToChange();
      76                 :            : 
      77                 :         11 :     Remove( 0, Count() );
      78                 :         11 :     aData = rCpy.GetData();
      79                 :            : 
      80                 :         11 :     return *this;
      81                 :            : }
      82                 :            : 
      83                 :          0 : sal_Bool SwTabCols::operator==( const SwTabCols& rCmp ) const
      84                 :            : {
      85                 :            :     sal_uInt16 i;
      86                 :            : 
      87         [ #  # ]:          0 :     if ( !(nLeftMin == rCmp.GetLeftMin() &&
      88                 :          0 :            nLeft    == rCmp.GetLeft()    &&
      89                 :          0 :            nRight   == rCmp.GetRight()   &&
      90                 :          0 :            nRightMax== rCmp.GetRightMax()&&
      91                 :          0 :            bLastRowAllowedToChange== rCmp.IsLastRowAllowedToChange() &&
      92 [ #  # ][ #  #  :          0 :            Count()== rCmp.Count()) )
          #  #  #  #  #  
                #  #  # ]
      93                 :          0 :         return sal_False;
      94                 :            : 
      95         [ #  # ]:          0 :     for ( i = 0; i < Count(); ++i )
      96                 :            :     {
      97                 :          0 :         SwTabColsEntry aEntry1 = aData[i];
      98                 :          0 :         SwTabColsEntry aEntry2 = rCmp.GetData()[i];
      99 [ #  # ][ #  # ]:          0 :         if ( aEntry1.nPos != aEntry2.nPos || aEntry1.bHidden != aEntry2.bHidden )
     100                 :          0 :             return sal_False;
     101                 :            :     }
     102                 :            : 
     103                 :          0 :     return sal_True;
     104                 :            : }
     105                 :            : 
     106                 :          6 : void SwTabCols::Insert( long nValue, long nMin, long nMax,
     107                 :            :                         sal_Bool bValue, sal_uInt16 nPos )
     108                 :            : {
     109                 :            :     SwTabColsEntry aEntry;
     110                 :          6 :     aEntry.nPos = nValue;
     111                 :          6 :     aEntry.nMin = nMin;
     112                 :          6 :     aEntry.nMax = nMax;
     113                 :          6 :     aEntry.bHidden = bValue;
     114 [ +  - ][ +  - ]:          6 :     aData.insert( aData.begin() + nPos, aEntry );
     115                 :          6 : }
     116                 :            : 
     117                 :        738 : void SwTabCols::Insert( long nValue, sal_Bool bValue, sal_uInt16 nPos )
     118                 :            : {
     119                 :            :     SwTabColsEntry aEntry;
     120                 :        738 :     aEntry.nPos = nValue;
     121                 :        738 :     aEntry.nMin = 0;
     122                 :        738 :     aEntry.nMax = LONG_MAX;
     123                 :        738 :     aEntry.bHidden = bValue;
     124 [ +  - ][ +  - ]:        738 :     aData.insert( aData.begin() + nPos, aEntry );
     125                 :            : 
     126                 :            : #if OSL_DEBUG_LEVEL > 1
     127                 :            :     SwTabColsEntries::iterator aPos = aData.begin();
     128                 :            :     for ( ; aPos != aData.end(); ++aPos )
     129                 :            :     {
     130                 :            :         aEntry =(*aPos);
     131                 :            :     }
     132                 :            : #endif
     133                 :        738 : }
     134                 :            : 
     135                 :        285 : void SwTabCols::Remove( sal_uInt16 nPos, sal_uInt16 nAnz )
     136                 :            : {
     137         [ +  - ]:        285 :     SwTabColsEntries::iterator aStart = aData.begin() + nPos;
     138 [ +  - ][ +  - ]:        285 :     aData.erase( aStart, aStart + nAnz );
     139                 :        285 : }
     140                 :            : 
     141                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10