LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/bastyp - tabcol.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 54 72.2 %
Date: 2012-12-27 Functions: 6 7 85.7 %
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             : #include "tabcol.hxx"
      21             : 
      22             : #include <limits.h>
      23             : #include <osl/diagnose.h>
      24             : 
      25          99 : SwTabCols::SwTabCols( sal_uInt16 nSize ) :
      26             :     nLeftMin( 0 ),
      27             :     nLeft( 0 ),
      28             :     nRight( 0 ),
      29             :     nRightMax( 0 ),
      30          99 :     bLastRowAllowedToChange( true )
      31             : {
      32          99 :     if ( nSize )
      33           0 :         aData.reserve( nSize );
      34          99 : }
      35             : 
      36          77 : SwTabCols::SwTabCols( const SwTabCols& rCpy ) :
      37          77 :     nLeftMin( rCpy.GetLeftMin() ),
      38          77 :     nLeft( rCpy.GetLeft() ),
      39          77 :     nRight( rCpy.GetRight() ),
      40          77 :     nRightMax( rCpy.GetRightMax() ),
      41          77 :     bLastRowAllowedToChange( rCpy.IsLastRowAllowedToChange() ),
      42         385 :     aData( rCpy.GetData() )
      43             : {
      44             : #if OSL_DEBUG_LEVEL > 0
      45             :     for ( sal_uInt16 i = 0; i < Count(); ++i )
      46             :     {
      47             :         SwTabColsEntry aEntry1 = aData[i];
      48             :         SwTabColsEntry aEntry2 = rCpy.GetData()[i];
      49             :         (void) aEntry1;
      50             :         (void) aEntry2;
      51             :         OSL_ENSURE( aEntry1.nPos == aEntry2.nPos &&
      52             :                     aEntry1.nMin == aEntry2.nMin &&
      53             :                     aEntry1.nMax == aEntry2.nMax &&
      54             :                     aEntry1.bHidden == aEntry2.bHidden,
      55             :                     "CopyContructor of SwTabColsEntries did not succeed!" );
      56             :     }
      57             : #endif
      58          77 : }
      59             : 
      60           9 : SwTabCols &SwTabCols::operator=( const SwTabCols& rCpy )
      61             : {
      62           9 :     nLeftMin = rCpy.GetLeftMin();
      63           9 :     nLeft    = rCpy.GetLeft();
      64           9 :     nRight   = rCpy.GetRight();
      65           9 :     nRightMax= rCpy.GetRightMax();
      66           9 :     bLastRowAllowedToChange = rCpy.IsLastRowAllowedToChange();
      67             : 
      68           9 :     Remove( 0, Count() );
      69           9 :     aData = rCpy.GetData();
      70             : 
      71           9 :     return *this;
      72             : }
      73             : 
      74           0 : bool SwTabCols::operator==( const SwTabCols& rCmp ) const
      75             : {
      76             :     sal_uInt16 i;
      77             : 
      78           0 :     if ( !(nLeftMin == rCmp.GetLeftMin() &&
      79           0 :            nLeft    == rCmp.GetLeft()    &&
      80           0 :            nRight   == rCmp.GetRight()   &&
      81           0 :            nRightMax== rCmp.GetRightMax()&&
      82           0 :            bLastRowAllowedToChange== rCmp.IsLastRowAllowedToChange() &&
      83           0 :            Count()== rCmp.Count()) )
      84           0 :         return false;
      85             : 
      86           0 :     for ( i = 0; i < Count(); ++i )
      87             :     {
      88           0 :         SwTabColsEntry aEntry1 = aData[i];
      89           0 :         SwTabColsEntry aEntry2 = rCmp.GetData()[i];
      90           0 :         if ( aEntry1.nPos != aEntry2.nPos || aEntry1.bHidden != aEntry2.bHidden )
      91           0 :             return sal_False;
      92             :     }
      93             : 
      94           0 :     return true;
      95             : }
      96             : 
      97          17 : void SwTabCols::Insert( long nValue, long nMin, long nMax,
      98             :                         sal_Bool bValue, sal_uInt16 nPos )
      99             : {
     100             :     SwTabColsEntry aEntry;
     101          17 :     aEntry.nPos = nValue;
     102          17 :     aEntry.nMin = nMin;
     103          17 :     aEntry.nMax = nMax;
     104          17 :     aEntry.bHidden = bValue;
     105          17 :     aData.insert( aData.begin() + nPos, aEntry );
     106          17 : }
     107             : 
     108         301 : void SwTabCols::Insert( long nValue, sal_Bool bValue, sal_uInt16 nPos )
     109             : {
     110             :     SwTabColsEntry aEntry;
     111         301 :     aEntry.nPos = nValue;
     112         301 :     aEntry.nMin = 0;
     113         301 :     aEntry.nMax = LONG_MAX;
     114         301 :     aEntry.bHidden = bValue;
     115         301 :     aData.insert( aData.begin() + nPos, aEntry );
     116             : 
     117             : #if OSL_DEBUG_LEVEL > 1
     118             :     SwTabColsEntries::iterator aPos = aData.begin();
     119             :     for ( ; aPos != aData.end(); ++aPos )
     120             :     {
     121             :         aEntry =(*aPos);
     122             :     }
     123             : #endif
     124         301 : }
     125             : 
     126         189 : void SwTabCols::Remove( sal_uInt16 nPos, sal_uInt16 nAnz )
     127             : {
     128         189 :     SwTabColsEntries::iterator aStart = aData.begin() + nPos;
     129         189 :     aData.erase( aStart, aStart + nAnz );
     130         189 : }
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10