merge the formfield patch from ooo-build
[ooovba.git] / binfilter / inc / bf_sc / dociter.hxx
blobbbb1a124eecc33f1d2b5beeb23c85d0557a9149f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dociter.hxx,v $
10 * $Revision: 1.7 $
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 ************************************************************************/
31 #ifndef SC_DOCITER_HXX
32 #define SC_DOCITER_HXX
34 #ifndef _SOLAR_H
35 #include <tools/solar.h>
36 #endif
38 #ifndef SC_SCGLOB_HXX
39 #include "global.hxx"
40 #endif
41 namespace binfilter {
43 class ScDocument;
44 class ScBaseCell;
45 class ScPatternAttr;
46 class ScAttrArray;
47 class ScAttrIterator;
49 class ScValueIterator // alle Zahlenwerte in einem Bereich durchgehen
51 private:
52 double fNextValue;
53 ScDocument* pDoc;
54 const ScAttrArray* pAttrArray;
55 ULONG nNumFormat; // fuer CalcAsShown
56 ULONG nNumFmtIndex;
57 USHORT nStartCol;
58 USHORT nStartRow;
59 USHORT nStartTab;
60 USHORT nEndCol;
61 USHORT nEndRow;
62 USHORT nEndTab;
63 USHORT nCol;
64 USHORT nRow;
65 USHORT nTab;
66 USHORT nColRow;
67 USHORT nNextRow;
68 USHORT nAttrEndRow;
69 short nNumFmtType;
70 BOOL bNumValid;
71 BOOL bSubTotal;
72 BOOL bNextValid;
73 BOOL bCalcAsShown;
74 BOOL bTextAsZero;
76 BOOL GetThis(double& rValue, USHORT& rErr);
77 public:
78 ScValueIterator(ScDocument* pDocument,
79 const ScRange& rRange, BOOL bSTotal = FALSE,
80 BOOL bTextAsZero = FALSE );
81 void GetCurNumFmtInfo( short& nType, ULONG& nIndex );
82 BOOL GetFirst(double& rValue, USHORT& rErr);
83 BOOL GetNext(double& rValue, USHORT& rErr)
85 return bNextValid ? ( bNextValid = FALSE, rValue = fNextValue,
86 rErr = 0, nRow = nNextRow,
87 ++nColRow, bNumValid = FALSE, TRUE )
88 : ( ++nRow, GetThis(rValue, rErr) );
92 class ScQueryValueIterator // alle Zahlenwerte in einem Bereich durchgehen
94 private:
95 ScQueryParam aParam;
96 ScDocument* pDoc;
97 ScAttrArray* pAttrArray;
98 ULONG nNumFormat; // fuer CalcAsShown
99 ULONG nNumFmtIndex;
100 USHORT nCol;
101 USHORT nRow;
102 USHORT nColRow;
103 USHORT nAttrEndRow;
104 USHORT nTab;
105 short nNumFmtType;
106 BOOL bCalcAsShown;
108 BOOL GetThis(double& rValue, USHORT& rErr);
109 public:
110 ScQueryValueIterator(ScDocument* pDocument, USHORT nTable,
111 const ScQueryParam& aParam);
112 BOOL GetFirst(double& rValue, USHORT& rErr);
113 BOOL GetNext(double& rValue, USHORT& rErr);
114 void GetCurNumFmtInfo( short& nType, ULONG& nIndex )
115 { nType = nNumFmtType; nIndex = nNumFmtIndex; }
118 class ScCellIterator // alle Zellen in einem Bereich durchgehen
119 { // bei SubTotal aber keine ausgeblendeten und
120 private: // SubTotalZeilen
121 ScDocument* pDoc;
122 USHORT nStartCol;
123 USHORT nStartRow;
124 USHORT nStartTab;
125 USHORT nEndCol;
126 USHORT nEndRow;
127 USHORT nEndTab;
128 USHORT nCol;
129 USHORT nRow;
130 USHORT nTab;
131 USHORT nColRow;
132 BOOL bSubTotal;
134 ScBaseCell* GetThis();
135 public:
136 ScCellIterator(ScDocument* pDocument,
137 USHORT nSCol, USHORT nSRow, USHORT nSTab,
138 USHORT nECol, USHORT nERow, USHORT nETab,
139 BOOL bSTotal = FALSE);
140 ScCellIterator(ScDocument* pDocument,
141 const ScRange& rRange, BOOL bSTotal = FALSE);
142 ScBaseCell* GetFirst();
143 ScBaseCell* GetNext();
144 USHORT GetCol() { return nCol; }
145 USHORT GetRow() { return nRow; }
146 USHORT GetTab() { return nTab; }
149 class ScQueryCellIterator // alle nichtleeren Zellen in einem Bereich
150 { // durchgehen
151 enum StopOnMismatchBits
153 nStopOnMismatchDisabled = 0x00,
154 nStopOnMismatchEnabled = 0x01,
155 nStopOnMismatchOccured = 0x02,
156 nStopOnMismatchExecuted = nStopOnMismatchEnabled | nStopOnMismatchOccured
159 enum TestEqualConditionBits
161 nTestEqualConditionDisabled = 0x00,
162 nTestEqualConditionEnabled = 0x01,
163 nTestEqualConditionMatched = 0x02,
164 nTestEqualConditionFulfilled = nTestEqualConditionEnabled | nTestEqualConditionMatched
167 private:
168 ScQueryParam aParam;
169 ScDocument* pDoc;
170 ScAttrArray* pAttrArray;
171 ULONG nNumFormat;
172 USHORT nTab;
173 USHORT nCol;
174 USHORT nRow;
175 USHORT nColRow;
176 USHORT nAttrEndRow;
177 BYTE nStopOnMismatch;
178 BYTE nTestEqualCondition;
179 BOOL bAdvanceQuery;
181 ScBaseCell* GetThis();
182 public:
183 ScQueryCellIterator(ScDocument* pDocument, USHORT nTable,
184 const ScQueryParam& aParam, BOOL bMod = TRUE);
185 // fuer bMod = FALSE muss der QueryParam
186 // weiter aufgefuellt sein (bIsString)
187 ScBaseCell* GetFirst();
188 ScBaseCell* GetNext();
189 USHORT GetCol() { return nCol; }
190 USHORT GetRow() { return nRow; }
191 ULONG GetNumberFormat();
193 // setzt alle Entry.nField einen weiter, wenn Spalte
194 // wechselt, fuer ScInterpreter ScHLookup()
195 void SetAdvanceQueryParamEntryField( BOOL bVal )
196 { bAdvanceQuery = bVal; }
197 void AdvanceQueryParamEntryField();
199 /** If set, iterator stops on first non-matching cell
200 content. May be used in SC_LESS_EQUAL queries where a
201 cell range is assumed to be sorted; stops on first
202 value being greater than the queried value and
203 GetFirst()/GetNext() return NULL. StoppedOnMismatch()
204 returns TRUE then.
205 However, the iterator's conditions are not set to end
206 all queries, GetCol() and GetRow() return values for
207 the non-matching cell, further GetNext() calls may be
208 executed. */
209 void SetStopOnMismatch( BOOL bVal )
211 nStopOnMismatch = (bVal ? nStopOnMismatchEnabled :
212 nStopOnMismatchDisabled);
214 BOOL StoppedOnMismatch() const
215 { return nStopOnMismatch == nStopOnMismatchExecuted; }
217 /** If set, an additional test for SC_EQUAL condition is
218 executed in ScTable::ValidQuery() if SC_LESS_EQUAL or
219 SC_GREATER_EQUAL conditions are to be tested. May be
220 used where a cell range is assumed to be sorted to stop
221 if an equal match is found. */
222 void SetTestEqualCondition( BOOL bVal )
224 nTestEqualCondition = (bVal ?
225 nTestEqualConditionEnabled :
226 nTestEqualConditionDisabled);
228 BOOL IsEqualConditionFulfilled() const
229 { return nTestEqualCondition == nTestEqualConditionFulfilled; }
231 /** In a range assumed to be sorted find either the first
232 equal entry or the last being less than (or greater
233 than) the queried value. Continues searching for an
234 equal entry even if the last entry matching the range
235 is found, in case the data is not sorted. Used by the
236 interpreter for LOOKUP() and similar. Column and row
237 position of the found entry are returned, otherwise
238 invalid.
239 @ATTENTION! StopOnMismatch, TestEqualCondition and
240 the internal query params are in an undefined state
241 upon return! */
242 BOOL FindEqualOrSortedLastInRange( USHORT& nFoundCol, USHORT& nFoundRow );
245 class ScDocAttrIterator // alle Attribut-Bereiche
247 private:
248 ScDocument* pDoc;
249 USHORT nTab;
250 USHORT nEndCol;
251 USHORT nStartRow;
252 USHORT nEndRow;
253 USHORT nCol;
254 ScAttrIterator* pColIter;
256 public:
257 ScDocAttrIterator(ScDocument* pDocument, USHORT nTable,
258 USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2);
259 ~ScDocAttrIterator();
261 const ScPatternAttr* GetNext( USHORT& rCol, USHORT& rRow1, USHORT& rRow2 );
264 class ScAttrRectIterator // alle Attribut-Bereiche, auch Bereiche ueber mehrere Spalten
266 private:
267 ScDocument* pDoc;
268 USHORT nTab;
269 USHORT nEndCol;
270 USHORT nStartRow;
271 USHORT nEndRow;
272 USHORT nIterStartCol;
273 USHORT nIterEndCol;
274 ScAttrIterator* pColIter;
276 public:
277 ScAttrRectIterator(ScDocument* pDocument, USHORT nTable,
278 USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2);
279 ~ScAttrRectIterator();
281 void DataChanged();
282 const ScPatternAttr* GetNext( USHORT& rCol1, USHORT& rCol2, USHORT& rRow1, USHORT& rRow2 );
285 class ScHorizontalCellIterator // alle nichtleeren Zellen in einem Bereich
286 { // zeilenweise durchgehen
287 private:
288 ScDocument* pDoc;
289 USHORT nTab;
290 USHORT nStartCol;
291 USHORT nEndCol;
292 USHORT nEndRow;
293 USHORT* pNextRows;
294 USHORT* pNextIndices;
295 USHORT nCol;
296 USHORT nRow;
297 BOOL bMore;
299 public:
300 ScHorizontalCellIterator(ScDocument* pDocument, USHORT nTable,
301 USHORT nCol1, USHORT nRow1, USHORT nCol2, USHORT nRow2);
302 ~ScHorizontalCellIterator();
304 ScBaseCell* GetNext( USHORT& rCol, USHORT& rRow );
305 BOOL ReturnNext( USHORT& rCol, USHORT& rRow );
307 private:
308 void Advance();
313 // gibt alle Bereiche mit nicht-Default-Formatierung zurueck (horizontal)
318 // gibt nichtleere Zellen und Bereiche mit Formatierung zurueck (horizontal)
322 } //namespace binfilter
323 #endif