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

Generated by: LCOV version 1.10