1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pivot.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 Folgende Reihenfolge beim Aufbau der Pivot-Tabelle unbedingt einzuhalten:
35 pPivot->SetColFields(aColArr, aColCount)
36 pPivot->SetRowFields(aRowArr, aRowCount)
37 pPivot->SetDataFields(aDataArr, aDataCount)
38 if (pPivot->CreateData())
44 ausserdem ist sicherzustellen, dass entweder das ColArr oder das RowArr
45 einen PivotDataField Eintrag enthalten
55 //STRIP008 class SubTotal;
57 #ifndef SC_COLLECT_HXX
58 #include "collect.hxx"
61 #define PIVOT_DATA_FIELD (MAXCOL + 1)
62 #define PIVOT_FUNC_REF (MAXCOL + 1)
64 #define PIVOT_STYLE_INNER 0
65 #define PIVOT_STYLE_RESULT 1
66 #define PIVOT_STYLE_CATEGORY 2
67 #define PIVOT_STYLE_TITLE 3
68 #define PIVOT_STYLE_FIELDNAME 4
69 #define PIVOT_STYLE_TOP 5
75 class ScMultipleReadHeader
;
76 class ScMultipleWriteHeader
;
88 nDataIndex
= nRecCount
= nIndex
= 0;
89 nFuncMask
= PIVOT_FUNC_NONE
;
93 typedef PivotField PivotFieldArr
[PIVOT_MAXFIELD
];
95 class PivotStrCollection
: public StrCollection
97 ScUserListData
* pUserData
;
99 PivotStrCollection(USHORT nLim
= 4, USHORT nDel
= 4, BOOL bDup
= FALSE
) :
100 StrCollection ( nLim
, nDel
, bDup
),
102 PivotStrCollection(const PivotStrCollection
& rPivotStrCollection
) :
103 StrCollection ( rPivotStrCollection
),
104 pUserData ( rPivotStrCollection
.pUserData
) {}
106 virtual short Compare(DataObject
* pKey1
, DataObject
* pKey2
) const;
108 TypedStrData
* operator[]( const USHORT nIndex
) const
109 { return (TypedStrData
*)At(nIndex
); }
110 void SetUserData(ScUserListData
* pData
)
111 { pUserData
= pData
; }
112 const String
& GetString(USHORT nIndex
)
113 { return ((TypedStrData
*)At(nIndex
))->GetString(); }
114 short GetIndex(TypedStrData
* pData
) const;
117 class ScPivot
: public DataObject
123 BOOL bIgnoreEmpty
; // Flags aus Dialog
130 USHORT nColNameCount
;
131 String
* pColNames
; // Array
145 USHORT nDataStartCol
;
146 USHORT nDataStartRow
;
152 PivotFieldArr aColArr
;
153 PivotFieldArr aRowArr
;
154 PivotFieldArr aDataArr
;
156 PivotStrCollection
* pColList
[PIVOT_MAXFIELD
]; // pro Zeile alle Eintraege
157 PivotStrCollection
* pRowList
[PIVOT_MAXFIELD
];
158 PivotStrCollection
* pDataList
; // Shortcut auf Col/RowList mit Daten
160 SubTotal
** ppDataArr
;
168 PivotColRef
* pColRef
;
174 ScPivot(ScDocument
* pDocument
);
175 ScPivot(const ScPivot
& rPivot
);
178 virtual DataObject
* Clone() const;
181 BOOL
Load(SvStream
& rStream
, ScMultipleReadHeader
& rHdr
);
182 BOOL
Store(SvStream
& rStream
, ScMultipleWriteHeader
& rHdr
) const;
184 void SetQuery(const ScQueryParam
& rQuery
);
185 void GetQuery(ScQueryParam
& rQuery
) const;
187 void SetHeader(BOOL bHeader
);
188 void SetIgnoreEmpty(BOOL bIgnore
);
189 BOOL
GetIgnoreEmpty() const;
190 void SetDetectCat(BOOL bDetect
);
191 BOOL
GetDetectCat() const;
192 void SetMakeTotalCol(BOOL bSet
);
193 BOOL
GetMakeTotalCol() const;
194 void SetMakeTotalRow(BOOL bSet
);
195 BOOL
GetMakeTotalRow() const;
197 void SetName(const String
& rNew
);
198 const String
& GetName() const;
199 void SetTag(const String
& rNew
);
200 const String
& GetTag() const;
202 void SetSrcArea(USHORT nCol1
, USHORT nRow1
, USHORT nCol2
, USHORT nRow2
, USHORT nTab
);
203 void GetSrcArea(USHORT
& rCol1
, USHORT
& rRow1
, USHORT
& rCol2
, USHORT
& rRow2
, USHORT
& rTab
) const;
204 ScRange
GetSrcArea() const;
206 void SetDestPos(USHORT nCol
, USHORT nRow
, USHORT nTab
);
207 void GetDestArea(USHORT
& rCol1
, USHORT
& rRow1
, USHORT
& rCol2
, USHORT
& rRow2
, USHORT
& rTab
) const;
208 ScRange
GetDestArea() const;
210 void SetColFields(const PivotField
* pFieldArr
, short nCount
);
211 void GetColFields(PivotField
* pFieldArr
, short& rCount
) const;
212 short GetColFieldCount() const { return nColCount
; }
214 void SetRowFields(const PivotField
* pFieldArr
, short nCount
);
215 void GetRowFields(PivotField
* pFieldArr
, short& rCount
) const;
216 short GetRowFieldCount() const { return nRowCount
; }
218 void SetDataFields(const PivotField
* pFieldArr
, short nCount
);
219 void GetDataFields(PivotField
* pFieldArr
, short& rCount
) const;
221 void GetParam( ScPivotParam
& rParam
, ScQueryParam
& rQuery
, ScArea
& rSrcArea
) const;
222 void SetParam( const ScPivotParam
& rParam
, const ScQueryParam
& rQuery
,
223 const ScArea
& rSrcArea
);
225 BOOL
CreateData(BOOL bKeepDest
= FALSE
);
229 // Referenz-Anpassung:
231 void MoveSrcArea( USHORT nNewCol
, USHORT nNewRow
, USHORT nNewTab
);
232 void MoveDestArea( USHORT nNewCol
, USHORT nNewRow
, USHORT nNewTab
);
236 void CreateFieldData();
239 USHORT
GetCategoryRow( USHORT nCol
, USHORT nRow
);
242 //------------------------------------------------------------------------
243 class ScPivotCollection
: public Collection
249 ScPivotCollection(USHORT nLim
= 4, USHORT nDel
= 4, ScDocument
* pDocument
= NULL
) :
250 Collection ( nLim
, nDel
),
251 pDoc ( pDocument
) {}
252 ScPivotCollection(const ScPivotCollection
& rScPivotCollection
) :
253 Collection ( rScPivotCollection
),
254 pDoc ( rScPivotCollection
.pDoc
) {}
256 ScPivot
* operator[]( const USHORT nIndex
) const {return (ScPivot
*)At(nIndex
);}
258 BOOL
Load( SvStream
& rStream
);
259 BOOL
Store( SvStream
& rStream
) const;
261 void UpdateReference(UpdateRefMode eUpdateRefMode
,
262 USHORT nCol1
, USHORT nRow1
, USHORT nTab1
,
263 USHORT nCol2
, USHORT nRow2
, USHORT nTab2
,
264 short nDx
, short nDy
, short nDz
);
267 String
CreateNewName( USHORT nMin
= 1 ) const;
270 //------------------------------------------------------------------------
275 BOOL bIsValue
; // Summe oder Anzahl im Data-Feld
279 LabelData( const String
& rColName
,
282 USHORT nMask
= PIVOT_FUNC_NONE
)
286 { pStrColName
= new String( rColName
); }
288 LabelData( const LabelData
& rCpy
)
290 bIsValue (rCpy
.bIsValue
),
291 nFuncMask (rCpy
.nFuncMask
)
292 { pStrColName
= new String( *(rCpy
.pStrColName
) ); }
295 { delete pStrColName
; }
297 LabelData
& operator=( const LabelData
& r
)
300 bIsValue
= r
.bIsValue
;
301 nFuncMask
= r
.nFuncMask
;
302 pStrColName
= new String( *(r
.pStrColName
) );
309 } //namespace binfilter