LCOV - code coverage report
Current view: top level - sc/source/core/data - subtotalparam.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 106 0.0 %
Date: 2014-04-14 Functions: 0 6 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             : 
      10             : 
      11             : #include "subtotalparam.hxx"
      12             : 
      13           0 : ScSubTotalParam::ScSubTotalParam()
      14             : {
      15           0 :     for ( sal_uInt16 i=0; i<MAXSUBTOTAL; i++ )
      16             :     {
      17           0 :         nSubTotals[i] = 0;
      18           0 :         pSubTotals[i] = NULL;
      19           0 :         pFunctions[i] = NULL;
      20             :     }
      21             : 
      22           0 :     Clear();
      23           0 : }
      24             : 
      25           0 : ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam& r ) :
      26             :         nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),nUserIndex(r.nUserIndex),
      27             :         bRemoveOnly(r.bRemoveOnly),bReplace(r.bReplace),bPagebreak(r.bPagebreak),bCaseSens(r.bCaseSens),
      28             :         bDoSort(r.bDoSort),bAscending(r.bAscending),bUserDef(r.bUserDef),
      29           0 :         bIncludePattern(r.bIncludePattern)
      30             : {
      31           0 :     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
      32             :     {
      33           0 :         bGroupActive[i] = r.bGroupActive[i];
      34           0 :         nField[i]       = r.nField[i];
      35             : 
      36           0 :         if ( (r.nSubTotals[i] > 0) && r.pSubTotals[i] && r.pFunctions[i] )
      37             :         {
      38           0 :             nSubTotals[i] = r.nSubTotals[i];
      39           0 :             pSubTotals[i] = new SCCOL   [r.nSubTotals[i]];
      40           0 :             pFunctions[i] = new ScSubTotalFunc  [r.nSubTotals[i]];
      41             : 
      42           0 :             for (SCCOL j=0; j<r.nSubTotals[i]; j++)
      43             :             {
      44           0 :                 pSubTotals[i][j] = r.pSubTotals[i][j];
      45           0 :                 pFunctions[i][j] = r.pFunctions[i][j];
      46           0 :             }
      47             :         }
      48             :         else
      49             :         {
      50           0 :             nSubTotals[i] = 0;
      51           0 :             pSubTotals[i] = NULL;
      52           0 :             pFunctions[i] = NULL;
      53             :         }
      54             :     }
      55           0 : }
      56             : 
      57           0 : void ScSubTotalParam::Clear()
      58             : {
      59           0 :     nCol1=nCol2= 0;
      60           0 :     nRow1=nRow2 = 0;
      61           0 :     nUserIndex = 0;
      62           0 :     bPagebreak=bCaseSens=bUserDef=bIncludePattern=bRemoveOnly = false;
      63           0 :     bAscending=bReplace=bDoSort = true;
      64             : 
      65           0 :     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
      66             :     {
      67           0 :         bGroupActive[i] = false;
      68           0 :         nField[i]       = 0;
      69             : 
      70           0 :         if ( (nSubTotals[i] > 0) && pSubTotals[i] && pFunctions[i] )
      71             :         {
      72           0 :             for ( SCCOL j=0; j<nSubTotals[i]; j++ ) {
      73           0 :                 pSubTotals[i][j] = 0;
      74           0 :                 pFunctions[i][j] = SUBTOTAL_FUNC_NONE;
      75             :             }
      76             :         }
      77             :     }
      78           0 : }
      79             : 
      80           0 : ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r )
      81             : {
      82           0 :     nCol1           = r.nCol1;
      83           0 :     nRow1           = r.nRow1;
      84           0 :     nCol2           = r.nCol2;
      85           0 :     nRow2           = r.nRow2;
      86           0 :     bRemoveOnly     = r.bRemoveOnly;
      87           0 :     bReplace        = r.bReplace;
      88           0 :     bPagebreak      = r.bPagebreak;
      89           0 :     bCaseSens       = r.bCaseSens;
      90           0 :     bDoSort         = r.bDoSort;
      91           0 :     bAscending      = r.bAscending;
      92           0 :     bUserDef        = r.bUserDef;
      93           0 :     nUserIndex      = r.nUserIndex;
      94           0 :     bIncludePattern = r.bIncludePattern;
      95             : 
      96           0 :     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
      97             :     {
      98           0 :         bGroupActive[i] = r.bGroupActive[i];
      99           0 :         nField[i]       = r.nField[i];
     100           0 :         nSubTotals[i]   = r.nSubTotals[i];
     101             : 
     102           0 :         if ( pSubTotals[i] ) delete [] pSubTotals[i];
     103           0 :         if ( pFunctions[i] ) delete [] pFunctions[i];
     104             : 
     105           0 :         if ( r.nSubTotals[i] > 0 )
     106             :         {
     107           0 :             pSubTotals[i] = new SCCOL   [r.nSubTotals[i]];
     108           0 :             pFunctions[i] = new ScSubTotalFunc  [r.nSubTotals[i]];
     109             : 
     110           0 :             for (SCCOL j=0; j<r.nSubTotals[i]; j++)
     111             :             {
     112           0 :                 pSubTotals[i][j] = r.pSubTotals[i][j];
     113           0 :                 pFunctions[i][j] = r.pFunctions[i][j];
     114             :             }
     115             :         }
     116             :         else
     117             :         {
     118           0 :             nSubTotals[i] = 0;
     119           0 :             pSubTotals[i] = NULL;
     120           0 :             pFunctions[i] = NULL;
     121             :         }
     122             :     }
     123             : 
     124           0 :     return *this;
     125             : }
     126             : 
     127           0 : bool ScSubTotalParam::operator==( const ScSubTotalParam& rOther ) const
     128             : {
     129           0 :     bool bEqual =   (nCol1          == rOther.nCol1)
     130           0 :                  && (nRow1          == rOther.nRow1)
     131           0 :                  && (nCol2          == rOther.nCol2)
     132           0 :                  && (nRow2          == rOther.nRow2)
     133           0 :                  && (nUserIndex     == rOther.nUserIndex)
     134           0 :                  && (bRemoveOnly    == rOther.bRemoveOnly)
     135           0 :                  && (bReplace       == rOther.bReplace)
     136           0 :                  && (bPagebreak     == rOther.bPagebreak)
     137           0 :                  && (bDoSort        == rOther.bDoSort)
     138           0 :                  && (bCaseSens      == rOther.bCaseSens)
     139           0 :                  && (bAscending     == rOther.bAscending)
     140           0 :                  && (bUserDef       == rOther.bUserDef)
     141           0 :                  && (bIncludePattern== rOther.bIncludePattern);
     142             : 
     143           0 :     if ( bEqual )
     144             :     {
     145           0 :         bEqual = true;
     146           0 :         for ( sal_uInt16 i=0; i<MAXSUBTOTAL && bEqual; i++ )
     147             :         {
     148           0 :             bEqual =   (bGroupActive[i] == rOther.bGroupActive[i])
     149           0 :                     && (nField[i]       == rOther.nField[i])
     150           0 :                     && (nSubTotals[i]   == rOther.nSubTotals[i]);
     151             : 
     152           0 :             if ( bEqual && (nSubTotals[i] > 0) )
     153             :             {
     154           0 :                 for (SCCOL j=0; (j<nSubTotals[i]) && bEqual; j++)
     155             :                 {
     156             :                     bEqual =   bEqual
     157           0 :                             && (pSubTotals[i][j] == rOther.pSubTotals[i][j])
     158           0 :                             && (pFunctions[i][j] == rOther.pFunctions[i][j]);
     159             :                 }
     160             :             }
     161             :         }
     162             :     }
     163             : 
     164           0 :     return bEqual;
     165             : }
     166             : 
     167           0 : void ScSubTotalParam::SetSubTotals( sal_uInt16 nGroup,
     168             :                                     const SCCOL* ptrSubTotals,
     169             :                                     const ScSubTotalFunc* ptrFunctions,
     170             :                                     sal_uInt16 nCount )
     171             : {
     172             :     OSL_ENSURE( (nGroup <= MAXSUBTOTAL),
     173             :                 "ScSubTotalParam::SetSubTotals(): nGroup > MAXSUBTOTAL!" );
     174             :     OSL_ENSURE( ptrSubTotals,
     175             :                 "ScSubTotalParam::SetSubTotals(): ptrSubTotals == NULL!" );
     176             :     OSL_ENSURE( ptrFunctions,
     177             :                 "ScSubTotalParam::SetSubTotals(): ptrFunctions == NULL!" );
     178             :     OSL_ENSURE( (nCount > 0),
     179             :                 "ScSubTotalParam::SetSubTotals(): nCount <= 0!" );
     180             : 
     181           0 :     if ( ptrSubTotals && ptrFunctions && (nCount > 0) && (nGroup <= MAXSUBTOTAL) )
     182             :     {
     183             :         // 0 wird als 1 aufgefasst, sonst zum Array-Index dekrementieren
     184           0 :         if (nGroup != 0)
     185           0 :             nGroup--;
     186             : 
     187           0 :         delete [] pSubTotals[nGroup];
     188           0 :         delete [] pFunctions[nGroup];
     189             : 
     190           0 :         pSubTotals[nGroup] = new SCCOL      [nCount];
     191           0 :         pFunctions[nGroup] = new ScSubTotalFunc [nCount];
     192           0 :         nSubTotals[nGroup] = static_cast<SCCOL>(nCount);
     193             : 
     194           0 :         for ( sal_uInt16 i=0; i<nCount; i++ )
     195             :         {
     196           0 :             pSubTotals[nGroup][i] = ptrSubTotals[i];
     197           0 :             pFunctions[nGroup][i] = ptrFunctions[i];
     198             :         }
     199             :     }
     200           0 : }
     201             : 
     202             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10