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

Generated by: LCOV version 1.10