LCOV - code coverage report
Current view: top level - sc/source/core/data - subtotalparam.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 65 106 61.3 %
Date: 2014-04-11 Functions: 4 6 66.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             : 
      10             : 
      11             : #include "subtotalparam.hxx"
      12             : 
      13         231 : ScSubTotalParam::ScSubTotalParam()
      14             : {
      15         924 :     for ( sal_uInt16 i=0; i<MAXSUBTOTAL; i++ )
      16             :     {
      17         693 :         nSubTotals[i] = 0;
      18         693 :         pSubTotals[i] = NULL;
      19         693 :         pFunctions[i] = NULL;
      20             :     }
      21             : 
      22         231 :     Clear();
      23         231 : }
      24             : 
      25         474 : 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         474 :         bIncludePattern(r.bIncludePattern)
      30             : {
      31        1896 :     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
      32             :     {
      33        1422 :         bGroupActive[i] = r.bGroupActive[i];
      34        1422 :         nField[i]       = r.nField[i];
      35             : 
      36        1422 :         if ( (r.nSubTotals[i] > 0) && r.pSubTotals[i] && r.pFunctions[i] )
      37             :         {
      38           4 :             nSubTotals[i] = r.nSubTotals[i];
      39           4 :             pSubTotals[i] = new SCCOL   [r.nSubTotals[i]];
      40           4 :             pFunctions[i] = new ScSubTotalFunc  [r.nSubTotals[i]];
      41             : 
      42           8 :             for (SCCOL j=0; j<r.nSubTotals[i]; j++)
      43             :             {
      44           4 :                 pSubTotals[i][j] = r.pSubTotals[i][j];
      45           4 :                 pFunctions[i][j] = r.pFunctions[i][j];
      46           4 :             }
      47             :         }
      48             :         else
      49             :         {
      50        1418 :             nSubTotals[i] = 0;
      51        1418 :             pSubTotals[i] = NULL;
      52        1418 :             pFunctions[i] = NULL;
      53             :         }
      54             :     }
      55         474 : }
      56             : 
      57         231 : void ScSubTotalParam::Clear()
      58             : {
      59         231 :     nCol1=nCol2= 0;
      60         231 :     nRow1=nRow2 = 0;
      61         231 :     nUserIndex = 0;
      62         231 :     bPagebreak=bCaseSens=bUserDef=bIncludePattern=bRemoveOnly = false;
      63         231 :     bAscending=bReplace=bDoSort = true;
      64             : 
      65         924 :     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
      66             :     {
      67         693 :         bGroupActive[i] = false;
      68         693 :         nField[i]       = 0;
      69             : 
      70         693 :         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         231 : }
      79             : 
      80         187 : ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r )
      81             : {
      82         187 :     nCol1           = r.nCol1;
      83         187 :     nRow1           = r.nRow1;
      84         187 :     nCol2           = r.nCol2;
      85         187 :     nRow2           = r.nRow2;
      86         187 :     bRemoveOnly     = r.bRemoveOnly;
      87         187 :     bReplace        = r.bReplace;
      88         187 :     bPagebreak      = r.bPagebreak;
      89         187 :     bCaseSens       = r.bCaseSens;
      90         187 :     bDoSort         = r.bDoSort;
      91         187 :     bAscending      = r.bAscending;
      92         187 :     bUserDef        = r.bUserDef;
      93         187 :     nUserIndex      = r.nUserIndex;
      94         187 :     bIncludePattern = r.bIncludePattern;
      95             : 
      96         748 :     for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
      97             :     {
      98         561 :         bGroupActive[i] = r.bGroupActive[i];
      99         561 :         nField[i]       = r.nField[i];
     100         561 :         nSubTotals[i]   = r.nSubTotals[i];
     101             : 
     102         561 :         if ( pSubTotals[i] ) delete [] pSubTotals[i];
     103         561 :         if ( pFunctions[i] ) delete [] pFunctions[i];
     104             : 
     105         561 :         if ( r.nSubTotals[i] > 0 )
     106             :         {
     107         163 :             pSubTotals[i] = new SCCOL   [r.nSubTotals[i]];
     108         163 :             pFunctions[i] = new ScSubTotalFunc  [r.nSubTotals[i]];
     109             : 
     110         328 :             for (SCCOL j=0; j<r.nSubTotals[i]; j++)
     111             :             {
     112         165 :                 pSubTotals[i][j] = r.pSubTotals[i][j];
     113         165 :                 pFunctions[i][j] = r.pFunctions[i][j];
     114             :             }
     115             :         }
     116             :         else
     117             :         {
     118         398 :             nSubTotals[i] = 0;
     119         398 :             pSubTotals[i] = NULL;
     120         398 :             pFunctions[i] = NULL;
     121             :         }
     122             :     }
     123             : 
     124         187 :     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