fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / subtotalparam.cxx
blob2cf17fdd6e96f8c9753ce34194fb4d1d0491f4db
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include "subtotalparam.hxx"
12 #include <osl/diagnose.h>
14 ScSubTotalParam::ScSubTotalParam()
16 for ( sal_uInt16 i=0; i<MAXSUBTOTAL; i++ )
18 nSubTotals[i] = 0;
19 pSubTotals[i] = NULL;
20 pFunctions[i] = NULL;
23 Clear();
26 ScSubTotalParam::ScSubTotalParam( const ScSubTotalParam& r ) :
27 nCol1(r.nCol1),nRow1(r.nRow1),nCol2(r.nCol2),nRow2(r.nRow2),nUserIndex(r.nUserIndex),
28 bRemoveOnly(r.bRemoveOnly),bReplace(r.bReplace),bPagebreak(r.bPagebreak),bCaseSens(r.bCaseSens),
29 bDoSort(r.bDoSort),bAscending(r.bAscending),bUserDef(r.bUserDef),
30 bIncludePattern(r.bIncludePattern)
32 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
34 bGroupActive[i] = r.bGroupActive[i];
35 nField[i] = r.nField[i];
37 if ( (r.nSubTotals[i] > 0) && r.pSubTotals[i] && r.pFunctions[i] )
39 nSubTotals[i] = r.nSubTotals[i];
40 pSubTotals[i] = new SCCOL [r.nSubTotals[i]];
41 pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]];
43 for (SCCOL j=0; j<r.nSubTotals[i]; j++)
45 pSubTotals[i][j] = r.pSubTotals[i][j];
46 pFunctions[i][j] = r.pFunctions[i][j];
49 else
51 nSubTotals[i] = 0;
52 pSubTotals[i] = NULL;
53 pFunctions[i] = NULL;
58 void ScSubTotalParam::Clear()
60 nCol1=nCol2= 0;
61 nRow1=nRow2 = 0;
62 nUserIndex = 0;
63 bPagebreak=bCaseSens=bUserDef=bIncludePattern=bRemoveOnly = false;
64 bAscending=bReplace=bDoSort = true;
66 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
68 bGroupActive[i] = false;
69 nField[i] = 0;
71 if ( (nSubTotals[i] > 0) && pSubTotals[i] && pFunctions[i] )
73 for ( SCCOL j=0; j<nSubTotals[i]; j++ ) {
74 pSubTotals[i][j] = 0;
75 pFunctions[i][j] = SUBTOTAL_FUNC_NONE;
81 ScSubTotalParam& ScSubTotalParam::operator=( const ScSubTotalParam& r )
83 nCol1 = r.nCol1;
84 nRow1 = r.nRow1;
85 nCol2 = r.nCol2;
86 nRow2 = r.nRow2;
87 bRemoveOnly = r.bRemoveOnly;
88 bReplace = r.bReplace;
89 bPagebreak = r.bPagebreak;
90 bCaseSens = r.bCaseSens;
91 bDoSort = r.bDoSort;
92 bAscending = r.bAscending;
93 bUserDef = r.bUserDef;
94 nUserIndex = r.nUserIndex;
95 bIncludePattern = r.bIncludePattern;
97 for (sal_uInt16 i=0; i<MAXSUBTOTAL; i++)
99 bGroupActive[i] = r.bGroupActive[i];
100 nField[i] = r.nField[i];
101 nSubTotals[i] = r.nSubTotals[i];
103 if ( pSubTotals[i] ) delete [] pSubTotals[i];
104 if ( pFunctions[i] ) delete [] pFunctions[i];
106 if ( r.nSubTotals[i] > 0 )
108 pSubTotals[i] = new SCCOL [r.nSubTotals[i]];
109 pFunctions[i] = new ScSubTotalFunc [r.nSubTotals[i]];
111 for (SCCOL j=0; j<r.nSubTotals[i]; j++)
113 pSubTotals[i][j] = r.pSubTotals[i][j];
114 pFunctions[i][j] = r.pFunctions[i][j];
117 else
119 nSubTotals[i] = 0;
120 pSubTotals[i] = NULL;
121 pFunctions[i] = NULL;
125 return *this;
128 bool ScSubTotalParam::operator==( const ScSubTotalParam& rOther ) const
130 bool bEqual = (nCol1 == rOther.nCol1)
131 && (nRow1 == rOther.nRow1)
132 && (nCol2 == rOther.nCol2)
133 && (nRow2 == rOther.nRow2)
134 && (nUserIndex == rOther.nUserIndex)
135 && (bRemoveOnly == rOther.bRemoveOnly)
136 && (bReplace == rOther.bReplace)
137 && (bPagebreak == rOther.bPagebreak)
138 && (bDoSort == rOther.bDoSort)
139 && (bCaseSens == rOther.bCaseSens)
140 && (bAscending == rOther.bAscending)
141 && (bUserDef == rOther.bUserDef)
142 && (bIncludePattern== rOther.bIncludePattern);
144 if ( bEqual )
146 bEqual = true;
147 for ( sal_uInt16 i=0; i<MAXSUBTOTAL && bEqual; i++ )
149 bEqual = (bGroupActive[i] == rOther.bGroupActive[i])
150 && (nField[i] == rOther.nField[i])
151 && (nSubTotals[i] == rOther.nSubTotals[i]);
153 if ( bEqual && (nSubTotals[i] > 0) )
155 for (SCCOL j=0; (j<nSubTotals[i]) && bEqual; j++)
157 bEqual = bEqual
158 && (pSubTotals[i][j] == rOther.pSubTotals[i][j])
159 && (pFunctions[i][j] == rOther.pFunctions[i][j]);
165 return bEqual;
168 void ScSubTotalParam::SetSubTotals( sal_uInt16 nGroup,
169 const SCCOL* ptrSubTotals,
170 const ScSubTotalFunc* ptrFunctions,
171 sal_uInt16 nCount )
173 OSL_ENSURE( (nGroup <= MAXSUBTOTAL),
174 "ScSubTotalParam::SetSubTotals(): nGroup > MAXSUBTOTAL!" );
175 OSL_ENSURE( ptrSubTotals,
176 "ScSubTotalParam::SetSubTotals(): ptrSubTotals == NULL!" );
177 OSL_ENSURE( ptrFunctions,
178 "ScSubTotalParam::SetSubTotals(): ptrFunctions == NULL!" );
179 OSL_ENSURE( (nCount > 0),
180 "ScSubTotalParam::SetSubTotals(): nCount <= 0!" );
182 if ( ptrSubTotals && ptrFunctions && (nCount > 0) && (nGroup <= MAXSUBTOTAL) )
184 // 0 is interpreted as 1, otherwise decrementing the array index
185 if (nGroup != 0)
186 nGroup--;
188 delete [] pSubTotals[nGroup];
189 delete [] pFunctions[nGroup];
191 pSubTotals[nGroup] = new SCCOL [nCount];
192 pFunctions[nGroup] = new ScSubTotalFunc [nCount];
193 nSubTotals[nGroup] = static_cast<SCCOL>(nCount);
195 for ( sal_uInt16 i=0; i<nCount; i++ )
197 pSubTotals[nGroup][i] = ptrSubTotals[i];
198 pFunctions[nGroup][i] = ptrFunctions[i];
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */