Update ooo320-m1
[ooovba.git] / applied_patches / 0189-calc-perf-table-hidden-flags.diff
blobdf109a0ef99af5fc160914b72afdaa7477272558
1 diff --git sc/inc/column.hxx sc/inc/column.hxx
2 index 3aa524f..1d7cd5f 100644
3 --- sc/inc/column.hxx
4 +++ sc/inc/column.hxx
5 @@ -213,10 +213,10 @@ public:
6 // UpdateSelectionFunction: Mehrfachselektion
7 void UpdateSelectionFunction( const ScMarkData& rMark,
8 ScFunctionData& rData,
9 - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags,
10 + ScFlatBoolRowSegments& rHiddenRows,
11 BOOL bDoExclude, SCROW nExStartRow, SCROW nExEndRow );
12 void UpdateAreaFunction( ScFunctionData& rData,
13 - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags,
14 + ScFlatBoolRowSegments& rHiddenRows,
15 SCROW nStartRow, SCROW nEndRow );
17 void CopyToColumn(SCROW nRow1, SCROW nRow2, USHORT nFlags, BOOL bMarked,
18 diff --git sc/inc/document.hxx sc/inc/document.hxx
19 index 6fef3aa..9ef314f 100644
20 --- sc/inc/document.hxx
21 +++ sc/inc/document.hxx
22 @@ -420,16 +420,11 @@ private:
24 sal_Int16 mnNamedRangesLockCount;
26 - inline BOOL RowHidden( SCROW nRow, SCTAB nTab ); // FillInfo
28 public:
29 SC_DLLPUBLIC ULONG GetCellCount() const; // alle Zellen
30 ULONG GetWeightedCount() const; // Formeln und Edit staerker gewichtet
31 ULONG GetCodeCount() const; // RPN-Code in Formeln
32 DECL_LINK( GetUserDefinedColor, USHORT * );
33 - BOOL RowFiltered( SCROW nRow, SCTAB nTab ) const; // FillInfo
34 - BOOL ColFiltered( SCCOL nCol, SCTAB nTab ) const; // FillInfo
35 - // Numberformatter
37 public:
38 SC_DLLPUBLIC ScDocument( ScDocumentMode eMode = SCDOCMODE_DOCUMENT,
39 @@ -1247,7 +1242,6 @@ public:
40 SCTAB nTab, double fScale ) const;
41 SC_DLLPUBLIC inline USHORT FastGetRowHeight( SCROW nRow, SCTAB nTab ) const;
42 inline SCROW FastGetRowForHeight( SCTAB nTab, ULONG nHeight ) const;
43 - inline SCROW FastGetFirstNonHiddenRow( SCROW nStartRow, SCTAB nTab ) const;
44 /** No check for flags whether row is hidden, height value
45 is returned unconditionally. */
46 inline USHORT FastGetOriginalRowHeight( SCROW nRow, SCTAB nTab ) const;
47 @@ -1299,6 +1293,26 @@ public:
48 ::com::sun::star::uno::Sequence<
49 ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
51 + SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
52 + SC_DLLPUBLIC bool RowHidden(SCROW nRow, SCTAB nTab, SCROW& rLastRow);
53 + SC_DLLPUBLIC bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
54 + SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL& rLastCol);
55 + SC_DLLPUBLIC bool ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
56 + SC_DLLPUBLIC void SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden);
57 + SC_DLLPUBLIC void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden);
58 + SC_DLLPUBLIC SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
59 + SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
60 + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
62 + bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
63 + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
64 + bool ColFiltered(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
65 + SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
66 + SC_DLLPUBLIC void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bFiltered);
67 + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
68 + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
69 + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab);
71 /**
72 * Write all column row flags to table's flag data, because not all column
73 * row attributes are stored in the flag data members. This is necessary
74 @@ -1327,8 +1341,6 @@ public:
75 BOOL GetColDefault( SCTAB nTab, SCCOL nCol, SCROW nLastRow, SCROW& nDefault);
76 BOOL GetRowDefault( SCTAB nTab, SCROW nRow, SCCOL nLastCol, SCCOL& nDefault);
78 - BOOL IsFiltered( SCROW nRow, SCTAB nTab ) const;
80 BOOL UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, BOOL bShow );
81 BOOL UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, BOOL bShow );
83 @@ -1807,58 +1819,24 @@ inline void ScDocument::SetSortParam( ScSortParam& rParam, SCTAB nTab )
84 inline ULONG ScDocument::FastGetScaledRowHeight( SCROW nStartRow, SCROW nEndRow,
85 SCTAB nTab, double fScale ) const
87 - return pTab[nTab]->pRowFlags->SumScaledCoupledArrayForCondition( nStartRow,
88 - nEndRow, CR_HIDDEN, 0, *(pTab[nTab]->pRowHeight), fScale);
89 + ULONG nHeight = FastGetRowHeight(nStartRow, nEndRow, nTab);
90 + return nHeight * fScale;
93 inline USHORT ScDocument::FastGetRowHeight( SCROW nRow, SCTAB nTab ) const
95 - return ( pTab[nTab]->pRowFlags->GetValue(nRow) & CR_HIDDEN ) ? 0 :
96 - pTab[nTab]->pRowHeight->GetValue(nRow);
97 + return pTab[nTab]->GetRowHeight(nRow);
100 inline SCROW ScDocument::FastGetRowForHeight( SCTAB nTab, ULONG nHeight ) const
102 - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
103 - *(pTab[nTab]->pRowFlags), 0, MAXROW, CR_HIDDEN, 0,
104 - *(pTab[nTab]->pRowHeight));
105 - ULONG nSum = 0;
106 - for ( ; aIter; aIter.NextRange() )
108 - ULONG nNew = *aIter * (aIter.GetRangeEnd() - aIter.GetRangeStart() + 1);
109 - if (nSum + nNew > nHeight)
111 - for ( ; aIter && nSum <= nHeight; ++aIter )
113 - nSum += *aIter;
115 - return aIter.GetPos();
117 - nSum += nNew;
119 - return aIter.GetPos();
122 -inline SCROW ScDocument::FastGetFirstNonHiddenRow( SCROW nStartRow, SCTAB nTab) const
124 - return pTab[nTab]->pRowFlags->GetFirstForCondition( nStartRow, MAXROW,
125 - CR_HIDDEN, 0);
126 + return pTab[nTab]->GetRowForHeight(nHeight);
129 inline USHORT ScDocument::FastGetOriginalRowHeight( SCROW nRow, SCTAB nTab ) const
131 return pTab[nTab]->pRowHeight->GetValue(nRow);
134 -inline BOOL ScDocument::ColFiltered( SCCOL nCol, SCTAB nTab ) const
136 - return ( pTab[nTab]->pColFlags[nCol] & CR_FILTERED) != 0;
139 -inline BOOL ScDocument::RowFiltered( SCROW nRow, SCTAB nTab ) const
141 - return pTab[nTab]->IsFiltered(nRow);
144 #endif
146 diff --git sc/inc/olinetab.hxx sc/inc/olinetab.hxx
147 index 456d223..a71519b 100644
148 --- sc/inc/olinetab.hxx
149 +++ sc/inc/olinetab.hxx
150 @@ -39,6 +39,7 @@
151 #define SC_OL_MAXDEPTH 7
153 class SvStream;
154 +class ScTable;
157 class ScOutlineEntry : public ScDataObject
158 @@ -126,9 +127,7 @@ public:
159 void InsertSpace( SCCOLROW nStartPos, SCSIZE nSize );
160 BOOL DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize );
162 - BOOL ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos,
163 - BOOL bShow,
164 - const ScBitMaskCompressedArray< SCCOLROW, BYTE>& rHiddenFlags );
165 + bool ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol );
167 void RemoveAll();
169 diff --git sc/inc/table.hxx sc/inc/table.hxx
170 index 6045438..0ace618 100644
171 --- sc/inc/table.hxx
172 +++ sc/inc/table.hxx
173 @@ -43,6 +43,7 @@
175 #include <memory>
176 #include <set>
177 +#include <boost/shared_ptr.hpp>
179 namespace utl {
180 class SearchParam;
181 @@ -83,7 +84,9 @@ struct RowInfo;
182 struct ScFunctionData;
183 struct ScLineFlags;
184 class CollatorWrapper;
185 struct ScSetStringParam;
186 +class ScFlatBoolRowSegments;
187 +class ScFlatBoolColSegments;
189 class ScTable
191 @@ -125,6 +128,10 @@ private:
193 BYTE* pColFlags;
194 ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags;
195 + ::boost::shared_ptr<ScFlatBoolColSegments> mpHiddenCols;
196 + ::boost::shared_ptr<ScFlatBoolRowSegments> mpHiddenRows;
197 + ::boost::shared_ptr<ScFlatBoolColSegments> mpFilteredCols;
198 + ::boost::shared_ptr<ScFlatBoolRowSegments> mpFilteredRows;
200 ::std::set<SCROW> maRowPageBreaks;
201 ::std::set<SCROW> maRowManualBreaks;
202 @@ -471,7 +478,7 @@ public:
203 SCCOL& rCol, SCROW& rRow, ScMarkData& rMark,
204 String& rUndoStr, ScDocument* pUndoDoc);
206 - void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 ) const;
207 + void FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 );
209 void GetBorderLines( SCCOL nCol, SCROW nRow,
210 const SvxBorderLine** ppLeft, const SvxBorderLine** ppTop,
211 @@ -593,19 +600,29 @@ public:
212 // nPPT fuer Test auf Veraenderung
213 void SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual );
215 - USHORT GetColWidth( SCCOL nCol ) const;
216 - USHORT GetRowHeight( SCROW nRow ) const;
217 - ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const;
218 - ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const;
219 - ULONG GetColOffset( SCCOL nCol ) const;
220 - ULONG GetRowOffset( SCROW nRow ) const;
221 + USHORT GetColWidth( SCCOL nCol );
222 + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow );
223 + ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow );
224 + ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale );
225 + ULONG GetColOffset( SCCOL nCol );
226 + ULONG GetRowOffset( SCROW nRow );
228 + /**
229 + * Get the last row such that the height of row 0 to the end row is as
230 + * high as possible without exceeding the specified height value.
232 + * @param nHeight maximum desired height
233 + *
234 + * @return SCROW last row of the range within specified height.
235 + */
236 + SCROW GetRowForHeight(ULONG nHeight);
238 USHORT GetOriginalWidth( SCCOL nCol ) const;
239 USHORT GetOriginalHeight( SCROW nRow ) const;
241 - USHORT GetCommonWidth( SCCOL nEndCol ) const;
242 + USHORT GetCommonWidth( SCCOL nEndCol );
244 - SCROW GetHiddenRowCount( SCROW nRow ) const;
245 + SCROW GetHiddenRowCount( SCROW nRow );
247 void ShowCol(SCCOL nCol, BOOL bShow);
248 void ShowRow(SCROW nRow, BOOL bShow);
249 @@ -626,8 +643,6 @@ public:
250 /// @return the index of the last changed row (flags and row height, auto pagebreak is ignored).
251 SCROW GetLastChangedRow() const;
253 - BOOL IsFiltered(SCROW nRow) const;
255 BYTE GetColFlags( SCCOL nCol ) const;
256 BYTE GetRowFlags( SCROW nRow ) const;
258 @@ -656,6 +671,34 @@ public:
259 void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
260 ::com::sun::star::uno::Sequence<
261 ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const;
263 + bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
264 + bool RowHidden(SCROW nRow, SCROW& rLastRow);
265 + bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow);
266 + bool ColHidden(SCCOL nCol, SCCOL& rLastCol);
267 + bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
268 + void SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden);
269 + void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden);
270 + void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
271 + void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
272 + SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow);
273 + SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow);
274 + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow);
275 + sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow);
277 + SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol);
279 + bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL);
280 + bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL);
281 + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow);
282 + void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol);
283 + void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow);
284 + void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered);
285 + void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered);
286 + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow);
287 + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow);
288 + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow);
290 void SyncColRowFlags();
292 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
293 @@ -786,7 +829,7 @@ private:
295 SCSIZE FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
296 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
297 - const ScPatternAttr* pPattern, const SfxItemSet* pCondSet ) const;
298 + const ScPatternAttr* pPattern, const SfxItemSet* pCondSet );
300 // idle calculation of OutputDevice text width for cell
301 // also invalidates script type, broadcasts for "calc as shown"
302 diff --git sc/source/core/data/column2.cxx sc/source/core/data/column2.cxx
303 index 2291859..c97fbda 100644
304 --- sc/source/core/data/column2.cxx
305 +++ sc/source/core/data/column2.cxx
306 @@ -69,6 +69,7 @@
307 #include "compiler.hxx" // ScTokenArray GetCodeLen
308 #include "dbcolect.hxx"
309 #include "fillinfo.hxx"
310 +#include "segmenttree.hxx"
312 #include <math.h>
314 @@ -1785,7 +1786,7 @@ void lcl_UpdateSubTotal( ScFunctionData& rData, ScBaseCell* pCell )
315 // Mehrfachselektion:
316 void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark,
317 ScFunctionData& rData,
318 - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags,
319 + ScFlatBoolRowSegments& rHiddenRows,
320 BOOL bDoExclude, SCROW nExStartRow, SCROW nExEndRow )
322 SCSIZE nIndex;
323 @@ -1793,7 +1794,8 @@ void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark,
324 while (aDataIter.Next( nIndex ))
326 SCROW nRow = pItems[nIndex].nRow;
327 - if ( !pRowFlags || !( pRowFlags->GetValue(nRow) & CR_HIDDEN ) )
328 + bool bRowHidden = rHiddenRows.getValue(nRow);
329 + if ( !bRowHidden )
330 if ( !bDoExclude || nRow < nExStartRow || nRow > nExEndRow )
331 lcl_UpdateSubTotal( rData, pItems[nIndex].pCell );
333 @@ -1801,7 +1803,7 @@ void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark,
335 // bei bNoMarked die Mehrfachselektion weglassen
336 void ScColumn::UpdateAreaFunction( ScFunctionData& rData,
337 - const ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags,
338 + ScFlatBoolRowSegments& rHiddenRows,
339 SCROW nStartRow, SCROW nEndRow )
341 SCSIZE nIndex;
342 @@ -1809,7 +1811,8 @@ void ScColumn::UpdateAreaFunction( ScFunctionData& rData,
343 while ( nIndex<nCount && pItems[nIndex].nRow<=nEndRow )
345 SCROW nRow = pItems[nIndex].nRow;
346 - if ( !pRowFlags || !( pRowFlags->GetValue(nRow) & CR_HIDDEN ) )
347 + bool bRowHidden = rHiddenRows.getValue(nRow);
348 + if ( !bRowHidden )
349 lcl_UpdateSubTotal( rData, pItems[nIndex].pCell );
350 ++nIndex;
352 diff --git sc/source/core/data/dociter.cxx sc/source/core/data/dociter.cxx
353 index 911d473..055c64f 100644
354 --- sc/source/core/data/dociter.cxx
355 +++ sc/source/core/data/dociter.cxx
356 @@ -334,7 +334,7 @@ BOOL ScValueIterator::GetThis(double& rValue, USHORT& rErr)
357 if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow )
359 nRow = pCol->pItems[nColRow].nRow + 1;
360 - if ( !bSubTotal || !pDoc->pTab[nTab]->IsFiltered( nRow-1 ) )
361 + if ( !bSubTotal || !pDoc->pTab[nTab]->RowFiltered( nRow-1 ) )
363 ScBaseCell* pCell = pCol->pItems[nColRow].pCell;
364 ++nColRow;
365 @@ -725,7 +725,7 @@ ScBaseCell* ScCellIterator::GetThis()
366 if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow )
368 nRow = pCol->pItems[nColRow].nRow;
369 - if ( !bSubTotal || !pDoc->pTab[nTab]->IsFiltered( nRow ) )
370 + if ( !bSubTotal || !pDoc->pTab[nTab]->RowFiltered( nRow ) )
372 ScBaseCell* pCell = pCol->pItems[nColRow].pCell;
374 diff --git sc/source/core/data/documen3.cxx sc/source/core/data/documen3.cxx
375 index 17ae763..4cff6f3 100644
376 --- sc/source/core/data/documen3.cxx
377 +++ sc/source/core/data/documen3.cxx
378 @@ -1123,15 +1123,6 @@ BOOL ScDocument::SearchAndReplace(const SvxSearchItem& rSearchItem,
379 return bFound;
382 -BOOL ScDocument::IsFiltered( SCROW nRow, SCTAB nTab ) const
384 - if (VALIDTAB(nTab))
385 - if (pTab[nTab])
386 - return pTab[nTab]->IsFiltered( nRow );
387 - DBG_ERROR("Falsche Tabellennummer");
388 - return 0;
391 // Outline anpassen
393 BOOL ScDocument::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, BOOL bShow )
394 @@ -1558,46 +1549,43 @@ ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect )
395 nTwips = (long) (aPosRect.Top() / HMM_PER_TWIPS);
397 SCROW nY1 = 0;
398 - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
399 - *(pTable->GetRowFlagsArray()), nY1, MAXROW, CR_HIDDEN, 0,
400 - *(pTable->GetRowHeightArray()));
401 bEnd = FALSE;
402 - while (!bEnd && aIter)
403 + for (SCROW i = nY1; i <= MAXROW && !bEnd; ++i)
405 - nY1 = aIter.GetPos();
406 - nAdd = (long) *aIter;
407 + if (pTable->RowHidden(i))
408 + continue;
410 + nY1 = i;
411 + nAdd = static_cast<long>(pTable->GetRowHeight(i));
412 if (nSize+nAdd <= nTwips+1 && nY1<MAXROW)
414 nSize += nAdd;
415 ++nY1;
416 - ++aIter;
418 else
419 bEnd = TRUE;
421 - if (!aIter)
422 - nY1 = aIter.GetIterEnd(); // all hidden down to the bottom
423 + if (!bEnd)
424 + nY1 = MAXROW; // all hidden down to the bottom
426 nTwips = (long) (aPosRect.Bottom() / HMM_PER_TWIPS);
428 SCROW nY2 = nY1;
429 - aIter.NewLimits( nY2, MAXROW);
430 bEnd = FALSE;
431 - while (!bEnd && aIter)
432 + for (SCROW i = nY2; i <= MAXROW && !bEnd; ++i)
434 - nY2 = aIter.GetPos();
435 - nAdd = (long) *aIter;
436 + nY2 = i;
437 + nAdd = static_cast<long>(pTable->GetRowHeight(i));
438 if (nSize+nAdd < nTwips && nY2<MAXROW)
440 nSize += nAdd;
441 ++nY2;
442 - ++aIter;
444 else
445 bEnd = TRUE;
447 - if (!aIter)
448 - nY2 = aIter.GetIterEnd(); // all hidden down to the bottom
449 + if (!bEnd)
450 + nY2 = MAXROW; // all hidden down to the bottom
452 return ScRange( nX1,nY1,nTab, nX2,nY2,nTab );
454 @@ -1635,24 +1623,33 @@ void lcl_SnapVer( ScTable* pTable, long& rVal, SCROW& rStartRow )
455 SCROW nRow = 0;
456 long nTwips = (long) (rVal / HMM_PER_TWIPS);
457 long nSnap = 0;
458 - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
459 - *(pTable->GetRowFlagsArray()), nRow, MAXROW, CR_HIDDEN, 0,
460 - *(pTable->GetRowHeightArray()));
461 - while ( aIter )
463 + bool bFound = false;
464 + for (SCROW i = nRow; i <= MAXROW; ++i)
466 - nRow = aIter.GetPos();
467 - long nAdd = *aIter;
468 + SCROW nLastRow;
469 + if (pTable->RowHidden(i, NULL, &nLastRow))
471 + i = nLastRow;
472 + continue;
475 + nRow = i;
476 + long nAdd = pTable->GetRowHeight(i);
477 if ( nSnap + nAdd/2 < nTwips || nRow < rStartRow )
479 nSnap += nAdd;
480 ++nRow;
481 - ++aIter;
483 else
485 + bFound = true;
486 break;
489 - if (!aIter)
490 + if (!bFound)
491 nRow = MAXROW; // all hidden down to the bottom
493 rVal = (long) ( nSnap * HMM_PER_TWIPS );
494 rStartRow = nRow;
496 diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
497 index 8151aec..9374c35 100644
498 --- sc/source/core/data/document.cxx
499 +++ sc/source/core/data/document.cxx
500 @@ -97,6 +97,7 @@
501 #include "clipparam.hxx"
503 #include <map>
504 +#include <limits>
506 namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
507 using ::com::sun::star::uno::Sequence;
508 @@ -1951,9 +1952,6 @@ void ScDocument::CopyNonFilteredFromClip( SCCOL nCol1, SCROW nRow1,
509 while ( nFlagTab < MAXTAB && !ppClipTab[nFlagTab] )
510 ++nFlagTab;
512 - const ScBitMaskCompressedArray< SCROW, BYTE> & rSourceFlags =
513 - pCBFCP->pClipDoc->GetRowFlagsArray( nFlagTab);
515 SCROW nSourceRow = rClipStartRow;
516 SCROW nSourceEnd = 0;
517 if (pCBFCP->pClipDoc->GetClipParam().maRanges.Count())
518 @@ -1963,12 +1961,15 @@ void ScDocument::CopyNonFilteredFromClip( SCCOL nCol1, SCROW nRow1,
519 while ( nSourceRow <= nSourceEnd && nDestRow <= nRow2 )
521 // skip filtered rows
522 - nSourceRow = rSourceFlags.GetFirstForCondition( nSourceRow, nSourceEnd, CR_FILTERED, 0);
523 + nSourceRow = pCBFCP->pClipDoc->FirstNonFilteredRow(nSourceRow, nSourceEnd, nFlagTab);
525 if ( nSourceRow <= nSourceEnd )
527 // look for more non-filtered rows following
528 - SCROW nFollow = rSourceFlags.GetBitStateEnd( nSourceRow, CR_FILTERED, 0) - nSourceRow;
529 + SCROW nLastRow = nSourceRow;
530 + pCBFCP->pClipDoc->RowFiltered(nSourceRow, nFlagTab, NULL, &nLastRow);
531 + SCROW nFollow = nLastRow - nSourceRow;
533 if (nFollow > nSourceEnd - nSourceRow)
534 nFollow = nSourceEnd - nSourceRow;
535 if (nFollow > nRow2 - nDestRow)
536 @@ -2376,8 +2377,7 @@ void ScDocument::GetClipArea(SCCOL& nClipX, SCROW& nClipY, BOOL bIncludeFiltered
537 while ( nCountTab < MAXTAB && !pTab[nCountTab] )
538 ++nCountTab;
540 - SCROW nResult = GetRowFlagsArray( nCountTab).CountForCondition(
541 - nStartRow, nEndRow, CR_FILTERED, 0);
542 + SCROW nResult = CountNonFilteredRows(nStartRow, nEndRow, nCountTab);
544 if ( nResult > 0 )
545 nClipY = nResult - 1;
546 @@ -2416,8 +2416,13 @@ BOOL ScDocument::HasClipFilteredRows()
547 if (!rClipRanges.Count())
548 return false;
550 - return GetRowFlagsArray( nCountTab).HasCondition( rClipRanges.First()->aStart.Row(),
551 - rClipRanges.First()->aEnd.Row(), CR_FILTERED, CR_FILTERED);
552 + for (ScRange* p = rClipRanges.First(); p; p = rClipRanges.Next())
554 + bool bAnswer = pTab[nCountTab]->HasFilteredRows(p->aStart.Row(), p->aEnd.Row());
555 + if (bAnswer)
556 + return true;
558 + return false;
562 @@ -3118,8 +3123,7 @@ ULONG ScDocument::GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) con
563 ULONG ScDocument::FastGetRowHeight( SCROW nStartRow, SCROW nEndRow,
564 SCTAB nTab ) const
566 - return pTab[nTab]->pRowFlags->SumCoupledArrayForCondition( nStartRow,
567 - nEndRow, CR_HIDDEN, 0, *(pTab[nTab]->pRowHeight));
568 + return GetRowHeight(nStartRow, nEndRow, nTab);
571 ULONG ScDocument::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow,
572 @@ -3431,6 +3435,163 @@ Sequence<TablePageBreakData> ScDocument::GetRowBreakData(SCTAB nTab) const
573 return pTab[nTab]->GetRowBreakData();
576 +bool ScDocument::RowHidden(SCROW nRow, SCTAB nTab, SCROW* pFirstRow, SCROW* pLastRow)
578 + if (!ValidTab(nTab) || !pTab[nTab])
579 + return false;
581 + return pTab[nTab]->RowHidden(nRow, pFirstRow, pLastRow);
584 +bool ScDocument::RowHidden(SCROW nRow, SCTAB nTab, SCROW& rLastRow)
586 + if (!ValidTab(nTab) || !pTab[nTab])
588 + rLastRow = nRow;
589 + return false;
592 + return pTab[nTab]->RowHidden(nRow, rLastRow);
596 +bool ScDocument::HasHiddenRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
598 + if (!ValidTab(nTab) || !pTab[nTab])
599 + return false;
601 + return pTab[nTab]->HasHiddenRows(nStartRow, nEndRow);
604 +bool ScDocument::ColHidden(SCCOL nCol, SCTAB nTab, SCCOL& rLastCol)
606 + if (!ValidTab(nTab) || !pTab[nTab])
608 + rLastCol = nCol;
609 + return false;
612 + return pTab[nTab]->ColHidden(nCol, rLastCol);
615 +bool ScDocument::ColHidden(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol, SCCOL* pLastCol)
617 + if (!ValidTab(nTab) || !pTab[nTab])
619 + if (pFirstCol)
620 + *pFirstCol = nCol;
621 + if (pLastCol)
622 + *pLastCol = nCol;
623 + return false;
626 + return pTab[nTab]->ColHidden(nCol, pFirstCol, pLastCol);
629 +void ScDocument::SetRowHidden(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bHidden)
631 + if (!ValidTab(nTab) || !pTab[nTab])
632 + return;
634 + pTab[nTab]->SetRowHidden(nStartRow, nEndRow, bHidden);
637 +void ScDocument::SetColHidden(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bHidden)
639 + if (!ValidTab(nTab) || !pTab[nTab])
640 + return;
642 + pTab[nTab]->SetColHidden(nStartCol, nEndCol, bHidden);
645 +SCROW ScDocument::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
647 + if (!ValidTab(nTab) || !pTab[nTab])
648 + return ::std::numeric_limits<SCROW>::max();;
650 + return pTab[nTab]->FirstVisibleRow(nStartRow, nEndRow);
653 +SCROW ScDocument::LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
655 + if (!ValidTab(nTab) || !pTab[nTab])
656 + return ::std::numeric_limits<SCROW>::max();;
658 + return pTab[nTab]->LastVisibleRow(nStartRow, nEndRow);
661 +SCROW ScDocument::CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
663 + if (!ValidTab(nTab) || !pTab[nTab])
664 + return 0;
666 + return pTab[nTab]->CountVisibleRows(nStartRow, nEndRow);
669 +bool ScDocument::RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow, SCROW* pLastRow)
671 + if (!ValidTab(nTab) || !pTab[nTab])
672 + return false;
674 + return pTab[nTab]->RowFiltered(nRow, pFirstRow, pLastRow);
677 +bool ScDocument::HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
679 + if (!ValidTab(nTab) || !pTab[nTab])
680 + return false;
682 + return pTab[nTab]->HasFilteredRows(nStartRow, nEndRow);
685 +bool ScDocument::ColFiltered(SCCOL nCol, SCTAB nTab, SCCOL* pFirstCol, SCCOL* pLastCol)
687 + if (!ValidTab(nTab) || !pTab[nTab])
688 + return false;
690 + return pTab[nTab]->ColFiltered(nCol, pFirstCol, pLastCol);
693 +void ScDocument::SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered)
695 + if (!ValidTab(nTab) || !pTab[nTab])
696 + return;
698 + pTab[nTab]->SetRowFiltered(nStartRow, nEndRow, bFiltered);
701 +void ScDocument::SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, SCTAB nTab, bool bFiltered)
703 + if (!ValidTab(nTab) || !pTab[nTab])
704 + return;
706 + pTab[nTab]->SetColFiltered(nStartCol, nEndCol, bFiltered);
709 +SCROW ScDocument::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
711 + if (!ValidTab(nTab) || !pTab[nTab])
712 + return ::std::numeric_limits<SCROW>::max();;
714 + return pTab[nTab]->FirstNonFilteredRow(nStartRow, nEndRow);
717 +SCROW ScDocument::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
719 + if (!ValidTab(nTab) || !pTab[nTab])
720 + return ::std::numeric_limits<SCROW>::max();;
722 + return pTab[nTab]->LastNonFilteredRow(nStartRow, nEndRow);
725 +SCROW ScDocument::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab)
727 + if (!ValidTab(nTab) || !pTab[nTab])
728 + return 0;
730 + return pTab[nTab]->CountNonFilteredRows(nStartRow, nEndRow);
733 void ScDocument::SyncColRowFlags()
735 for (SCTAB i = 0; i <= nMaxTableNumber; ++i)
736 diff --git sc/source/core/data/drwlayer.cxx sc/source/core/data/drwlayer.cxx
737 index 94708e1..03c48f5 100644
738 --- sc/source/core/data/drwlayer.cxx
739 +++ sc/source/core/data/drwlayer.cxx
740 @@ -610,12 +610,14 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b
742 //! nicht mehrere Undos fuer ein Objekt erzeugen (hinteres kann dann weggelassen werden)
744 + SCCOL nLastCol;
745 + SCROW nLastRow;
746 if( bValid1 )
748 Point aPos( pDoc->GetColOffset( nCol1, nTab1 ), pDoc->GetRowOffset( nRow1, nTab1 ) );
749 - if( (pDoc->GetColFlags( nCol1, nTab1 ) & CR_HIDDEN) == 0 )
750 + if (!pDoc->ColHidden(nCol1, nTab1, nLastCol))
751 aPos.X() += pDoc->GetColWidth( nCol1, nTab1 ) / 4;
752 - if( (pDoc->GetRowFlags( nRow1, nTab1 ) & CR_HIDDEN) == 0 )
753 + if (!pDoc->RowHidden(nRow1, nTab1, nLastRow))
754 aPos.Y() += pDoc->GetRowHeight( nRow1, nTab1 ) / 2;
755 TwipsToMM( aPos.X() );
756 TwipsToMM( aPos.Y() );
757 @@ -647,9 +649,9 @@ void ScDrawLayer::RecalcPos( SdrObject* pObj, const ScDrawObjData& rData, bool b
758 if( bValid2 )
760 Point aPos( pDoc->GetColOffset( nCol2, nTab2 ), pDoc->GetRowOffset( nRow2, nTab2 ) );
761 - if( (pDoc->GetColFlags( nCol2, nTab2 ) & CR_HIDDEN) == 0 )
762 + if (!pDoc->ColHidden(nCol2, nTab2, nLastCol))
763 aPos.X() += pDoc->GetColWidth( nCol2, nTab2 ) / 4;
764 - if( (pDoc->GetRowFlags( nRow2, nTab2 ) & CR_HIDDEN) == 0 )
765 + if (!pDoc->RowHidden(nRow2, nTab2, nLastRow))
766 aPos.Y() += pDoc->GetRowHeight( nRow2, nTab2 ) / 2;
767 TwipsToMM( aPos.X() );
768 TwipsToMM( aPos.Y() );
769 diff --git sc/source/core/data/fillinfo.cxx sc/source/core/data/fillinfo.cxx
770 index 54ffe10..e875167 100644
771 --- sc/source/core/data/fillinfo.cxx
772 +++ sc/source/core/data/fillinfo.cxx
773 @@ -55,7 +55,6 @@
774 #include "conditio.hxx"
775 #include "stlpool.hxx"
778 // -----------------------------------------------------------------------
780 const USHORT ROWINFO_MAX = 1024;
781 @@ -100,11 +99,13 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY,
782 rStartY = nY;
783 BOOL bHOver = pInfo->bHOverlapped;
784 BOOL bVOver = pInfo->bVOverlapped;
785 + SCCOL nLastCol;
786 + SCROW nLastRow;
788 while (bHOver) // nY konstant
790 --rStartX;
791 - if (rStartX >= (SCsCOL) nX1 && (pDoc->GetColFlags(rStartX,nTab) & CR_HIDDEN) == 0)
792 + if (rStartX >= (SCsCOL) nX1 && !pDoc->ColHidden(rStartX, nTab, nLastCol))
794 bHOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bHOverlapped;
795 bVOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bVOverlapped;
796 @@ -126,8 +127,8 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY,
797 --nArrY; // lokale Kopie !
799 if (rStartX >= (SCsCOL) nX1 && rStartY >= (SCsROW) nY1 &&
800 - (pDoc->GetColFlags(rStartX,nTab) & CR_HIDDEN) == 0 &&
801 - (pDoc->GetRowFlags(rStartY,nTab) & CR_HIDDEN) == 0 &&
802 + !pDoc->ColHidden(rStartX, nTab, nLastCol) &&
803 + !pDoc->RowHidden(rStartY, nTab, nLastRow) &&
804 (SCsROW) pRowInfo[nArrY].nRowNo == rStartY)
806 bHOver = pRowInfo[nArrY].pCellInfo[rStartX+1].bHOverlapped;
807 @@ -144,8 +145,8 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY,
809 const ScMergeAttr* pMerge;
810 if (rStartX >= (SCsCOL) nX1 && rStartY >= (SCsROW) nY1 &&
811 - (pDoc->GetColFlags(rStartX,nTab) & CR_HIDDEN) == 0 &&
812 - (pDoc->GetRowFlags(rStartY,nTab) & CR_HIDDEN) == 0 &&
813 + !pDoc->ColHidden(rStartX, nTab, nLastCol) &&
814 + !pDoc->RowHidden(rStartY, nTab, nLastRow) &&
815 (SCsROW) pRowInfo[nArrY].nRowNo == rStartY)
817 pMerge = (const ScMergeAttr*) &pRowInfo[nArrY].pCellInfo[rStartX+1].pPatternAttr->
818 @@ -158,12 +159,6 @@ void lcl_GetMergeRange( SCsCOL nX, SCsROW nY, SCSIZE nArrY,
819 rEndY = rStartY + pMerge->GetRowMerge() - 1;
822 -inline BOOL ScDocument::RowHidden( SCROW nRow, SCTAB nTab )
824 - return ( pTab[nTab]->pRowFlags->GetValue(nRow) & CR_HIDDEN ) != 0;
828 #define CELLINFO(x,y) pRowInfo[nArrY+y].pCellInfo[nArrX+x]
830 void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
831 @@ -359,7 +354,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
832 nX = nArrX-1;
833 if ( ValidCol(nX) )
835 - if ( (GetColFlags(nX,nTab) & CR_HIDDEN) == 0 ) // Spalte nicht versteckt
836 + if (!ColHidden(nX, nTab))
838 USHORT nThisWidth = (USHORT) (GetColWidth( nX, nTab ) * nScaleX);
839 if (!nThisWidth)
840 @@ -379,7 +374,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
841 // #i58049#, #i57939# Hidden columns must be skipped here, or their attributes
842 // will disturb the output
844 - if ( (GetColFlags(nX,nTab) & CR_HIDDEN) == 0 ) // column not hidden
845 + // TODO: Optimize this loop.
846 + if (!ColHidden(nX, nTab))
848 USHORT nThisWidth = (USHORT) (GetColWidth( nX, nTab ) * nScaleX);
849 if (!nThisWidth)
850 @@ -484,7 +480,14 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
854 - if ( nArrY==0 || !RowHidden( nCurRow,nTab ) )
855 +#define NEW_METHOD 1
856 +#if NEW_METHOD
857 + SCROW nLastHiddenRow = -1;
858 + bool bRowHidden = RowHidden(nCurRow, nTab, nLastHiddenRow);
859 +#else
860 + bool bRowHidden = RowHidden(nCurRow, nTab);
861 +#endif
862 + if ( nArrY==0 || !bRowHidden )
864 RowInfo* pThisRowInfo = &pRowInfo[nArrY];
865 if (pBackground != pDefBackground) // Spalten-HG == Standard ?
866 @@ -554,6 +557,14 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
868 ++nArrY;
870 +#if NEW_METHOD
871 + else if (bRowHidden && nLastHiddenRow >= 0)
873 + nCurRow = nLastHiddenRow;
874 + if (nCurRow > nThisRow)
875 + nCurRow = nThisRow;
877 +#endif
878 ++nCurRow;
880 while (nCurRow <= nThisRow && nCurRow <= nYExtra);
881 diff --git sc/source/core/data/olinetab.cxx sc/source/core/data/olinetab.cxx
882 index a30065e..cc4f7f6 100644
883 --- sc/source/core/data/olinetab.cxx
884 +++ sc/source/core/data/olinetab.cxx
885 @@ -44,6 +44,7 @@
886 #include "global.hxx"
887 #include "rechead.hxx"
888 #include "address.hxx"
889 +#include "table.hxx"
891 //------------------------------------------------------------------------
893 @@ -640,8 +641,7 @@ BOOL ScOutlineArray::DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize )
894 return bNeedSave;
897 -BOOL ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos,
898 - BOOL bShow, const ScBitMaskCompressedArray< SCCOLROW, BYTE>& rHiddenFlags )
899 +bool ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol )
901 BOOL bModified = FALSE;
902 ScSubOutlineIterator aIter( this );
903 @@ -657,9 +657,7 @@ BOOL ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos,
905 // #i12341# hide if all columns/rows are hidden, show if at least one
906 // is visible
908 - SCCOLROW nEnd = rHiddenFlags.GetBitStateEnd( nEntryStart,
909 - CR_HIDDEN, CR_HIDDEN);
910 + SCCOLROW nEnd = rTable.LastHiddenColRow(nEntryStart, bCol);
911 BOOL bAllHidden = (nEntryEnd <= nEnd && nEnd <
912 ::std::numeric_limits<SCCOLROW>::max());
914 diff --git sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
915 index 6a672e8..862508b 100644
916 --- sc/source/core/data/table1.cxx
917 +++ sc/source/core/data/table1.cxx
918 @@ -115,6 +115,7 @@
919 #include "hints.hxx" // fuer Paint-Broadcast
920 #include "prnsave.hxx"
921 #include "tabprotection.hxx"
922 +#include "segmenttree.hxx"
924 // STATIC DATA -----------------------------------------------------------
926 @@ -138,6 +139,10 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
927 pRowHeight( NULL ),
928 pColFlags( NULL ),
929 pRowFlags( NULL ),
930 + mpHiddenCols(new ScFlatBoolColSegments),
931 + mpHiddenRows(new ScFlatBoolRowSegments),
932 + mpFilteredCols(new ScFlatBoolColSegments),
933 + mpFilteredRows(new ScFlatBoolRowSegments),
934 pOutlineTable( NULL ),
935 bTableAreaValid( FALSE ),
936 bVisible( TRUE ),
937 @@ -888,9 +893,10 @@ BOOL ScTable::ValidNextPos( SCCOL nCol, SCROW nRow, const ScMarkData& rMark,
938 // auf der naechsten Zelle landet, auch wenn die geschuetzt/nicht markiert ist.
939 //! per Extra-Parameter steuern, nur fuer Cursor-Bewegung ???
941 - if ( pRowFlags && ( pRowFlags->GetValue(nRow) & CR_HIDDEN ) )
942 + if (RowHidden(nRow))
943 return FALSE;
944 - if ( pColFlags && ( pColFlags[nCol] & CR_HIDDEN ) )
946 + if (ColHidden(nCol))
947 return FALSE;
950 @@ -917,8 +923,8 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
952 BOOL bUp = ( nMovY < 0 );
953 nRow = rMark.GetNextMarked( nCol, nRow, bUp );
954 - while ( VALIDROW(nRow) && ((pRowFlags && (pRowFlags->GetValue(nRow) & CR_HIDDEN)) ||
955 - pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) )
956 + while ( VALIDROW(nRow) &&
957 + (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) )
959 // #53697# ausgeblendete ueberspringen (s.o.)
960 nRow += nMovY;
961 @@ -928,7 +934,7 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
962 while ( nRow < 0 || nRow > MAXROW )
964 nCol = sal::static_int_cast<SCsCOL>( nCol + static_cast<SCsCOL>(nMovY) );
965 - while ( VALIDCOL(nCol) && pColFlags && (pColFlags[nCol] & CR_HIDDEN) )
966 + while ( VALIDCOL(nCol) && ColHidden(nCol) )
967 nCol = sal::static_int_cast<SCsCOL>( nCol + static_cast<SCsCOL>(nMovY) ); // #53697# skip hidden rows (see above)
968 if (nCol < 0)
970 @@ -947,8 +953,8 @@ void ScTable::GetNextPos( SCCOL& rCol, SCROW& rRow, SCsCOL nMovX, SCsROW nMovY,
971 else if (nRow > MAXROW)
972 nRow = 0;
973 nRow = rMark.GetNextMarked( nCol, nRow, bUp );
974 - while ( VALIDROW(nRow) && ((pRowFlags && (pRowFlags->GetValue(nRow) & CR_HIDDEN)) ||
975 - pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) )
976 + while ( VALIDROW(nRow) &&
977 + (RowHidden(nRow) || pDocument->HasAttrib(nCol, nRow, nTab, nCol, nRow, nTab, HASATTR_OVERLAPPED)) )
979 // #53697# ausgeblendete ueberspringen (s.o.)
980 nRow += nMovY;
981 @@ -1336,19 +1342,14 @@ void ScTable::ExtendPrintArea( OutputDevice* pDev,
983 SCSIZE nIndex;
984 SCCOL nPrintCol = rEndCol;
985 - SCSIZE nRowFlagsIndex;
986 - SCROW nRowFlagsEndRow;
987 - BYTE nRowFlag = pRowFlags->GetValue( nStartRow, nRowFlagsIndex, nRowFlagsEndRow);
988 for (SCROW nRow = nStartRow; nRow<=nEndRow; nRow++)
990 - if (nRow > nRowFlagsEndRow)
991 - nRowFlag = pRowFlags->GetNextValue( nRowFlagsIndex, nRowFlagsEndRow);
992 - if ( ( nRowFlag & CR_HIDDEN ) == 0 )
993 + if (!RowHidden(nRow))
995 SCCOL nDataCol = rEndCol;
996 while (nDataCol > 0 && ( bEmpty[nDataCol] || !aCol[nDataCol].Search(nRow,nIndex) ) )
997 --nDataCol;
998 - if ( ( pColFlags[nDataCol] & CR_HIDDEN ) == 0 )
999 + if (!ColHidden(nDataCol))
1001 ScBaseCell* pCell = aCol[nDataCol].GetCell(nRow);
1002 if (pCell)
1003 diff --git sc/source/core/data/table2.cxx sc/source/core/data/table2.cxx
1004 index 972ec16..889510f 100644
1005 --- sc/source/core/data/table2.cxx
1006 +++ sc/source/core/data/table2.cxx
1007 @@ -132,6 +132,9 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
1009 if (pOutlineTable)
1010 pOutlineTable->InsertRow( nStartRow, nSize );
1012 + mpFilteredRows->insertSegment(nStartRow, nSize, true);
1013 + mpHiddenRows->insertSegment(nStartRow, nSize, true);
1016 for (SCCOL j=nStartCol; j<=nEndCol; j++)
1017 @@ -159,6 +162,9 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
1018 if (pOutlineTable->DeleteRow( nStartRow, nSize ))
1019 if (pUndoOutline)
1020 *pUndoOutline = TRUE;
1022 + mpFilteredRows->removeSegment(nStartRow, nStartRow+nSize);
1023 + mpHiddenRows->removeSegment(nStartRow, nStartRow+nSize);
1026 { // scope for bulk broadcast
1027 @@ -205,6 +211,9 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
1029 if (pOutlineTable)
1030 pOutlineTable->InsertCol( nStartCol, nSize );
1032 + mpHiddenCols->insertSegment(nStartCol, nSize, true);
1033 + mpFilteredCols->insertSegment(nStartCol, nSize, true);
1037 @@ -260,6 +269,9 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
1038 if (pOutlineTable->DeleteCol( nStartCol, nSize ))
1039 if (pUndoOutline)
1040 *pUndoOutline = TRUE;
1042 + mpHiddenCols->removeSegment(nStartCol, nStartCol+nSize);
1043 + mpFilteredCols->removeSegment(nStartCol, nStartCol+nSize);
1047 @@ -357,20 +369,21 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1048 // copy widths/heights, and only "hidden", "filtered" and "manual" flags
1049 // also for all preceding columns/rows, to have valid positions for drawing objects
1051 - if (pColFlags && pTable->pColFlags && pColWidth && pTable->pColWidth)
1052 + if (pColWidth && pTable->pColWidth)
1053 for (i=0; i<=nCol2; i++)
1055 - pTable->pColFlags[i] = pColFlags[i] & CR_HIDDEN;
1056 pTable->pColWidth[i] = pColWidth[i];
1059 + pTable->CopyColHidden(*this, 0, nCol2);
1060 + pTable->CopyColFiltered(*this, 0, nCol2);
1062 if (pRowFlags && pTable->pRowFlags && pRowHeight && pTable->pRowHeight)
1064 - pTable->pRowFlags->CopyFromAnded( *pRowFlags, 0, nRow2,
1065 - (CR_HIDDEN | CR_FILTERED | CR_MANUALSIZE));
1066 + pTable->pRowFlags->CopyFromAnded( *pRowFlags, 0, nRow2, CR_MANUALSIZE);
1067 pTable->pRowHeight->CopyFrom( *pRowHeight, 0, nRow2);
1070 + pTable->CopyRowHidden(*this, 0, nRow2);
1071 + pTable->CopyRowFiltered(*this, 0, nRow2);
1073 // ggf. Formeln durch Werte ersetzen
1075 @@ -660,10 +673,12 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1076 if (bWidth)
1077 for (SCCOL i=nCol1; i<=nCol2; i++)
1079 - bool bHiddenChange = ( pDestTab->pColFlags[i] & CR_HIDDEN ) != ( pColFlags[i] & CR_HIDDEN );
1080 + bool bThisHidden = ColHidden(i);
1081 + bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden);
1082 bool bChange = bHiddenChange || (pDestTab->pColWidth[i] != pColWidth[i]);
1083 pDestTab->pColWidth[i] = pColWidth[i];
1084 pDestTab->pColFlags[i] = pColFlags[i];
1085 + pDestTab->SetColHidden(i, i, bThisHidden);
1086 //! Aenderungen zusammenfassen?
1087 if (bHiddenChange && pCharts)
1088 pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab ));
1089 @@ -685,8 +700,10 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1090 // TODO: might need some performance improvement, block
1091 // operations instead of single GetValue()/SetValue() calls.
1092 BYTE nThisRowFlags = pRowFlags->GetValue(i);
1093 - bool bHiddenChange = ( pDestTab->pRowFlags->GetValue(i) & CR_HIDDEN ) != ( nThisRowFlags & CR_HIDDEN );
1094 + bool bThisHidden = RowHidden(i);
1095 + bool bHiddenChange = (pDestTab->RowHidden(i) != bThisHidden);
1096 pDestTab->pRowFlags->SetValue( i, nThisRowFlags );
1097 + pDestTab->SetRowHidden(i, i, bThisHidden);
1098 //! Aenderungen zusammenfassen?
1099 if (bHiddenChange && pCharts)
1100 pCharts->SetRangeDirty(ScRange( 0, i, nTab, MAXCOL, i, nTab ));
1101 @@ -1299,7 +1316,7 @@ BOOL ScTable::IsBlockEmpty( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
1103 SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2,
1104 SCCOL nCol, SCROW nAttrRow1, SCROW nAttrRow2, SCSIZE nArrY,
1105 - const ScPatternAttr* pPattern, const SfxItemSet* pCondSet ) const
1106 + const ScPatternAttr* pPattern, const SfxItemSet* pCondSet )
1108 // Rueckgabe = neues nArrY
1110 @@ -1332,7 +1349,7 @@ SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCO
1112 for ( SCROW nRow = nAttrRow1; nRow <= nAttrRow2; nRow++ )
1114 - if ( !(pRowFlags->GetValue(nRow) & CR_HIDDEN) )
1115 + if (!RowHidden(nRow))
1117 BOOL bHitOne = TRUE;
1118 if ( nCol > nX2+1 )
1119 @@ -1366,7 +1383,7 @@ SCSIZE ScTable::FillMaxRot( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCO
1120 return nArrY;
1123 -void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 ) const
1124 +void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCCOL nX2 )
1126 if ( !pColWidth || !pRowHeight || !pColFlags || !pRowFlags )
1128 @@ -1381,7 +1398,7 @@ void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCC
1130 for (SCCOL nCol=0; nCol<=MAXCOL; nCol++)
1132 - if ( !(pColFlags[nCol] & CR_HIDDEN) )
1133 + if (!ColHidden(nCol))
1135 SCSIZE nArrY = 0;
1136 ScDocAttrIterator aIter( pDocument, nTab, nCol, nY1, nCol, nY2 );
1137 @@ -2160,13 +2177,13 @@ void ScTable::SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual )
1141 -USHORT ScTable::GetColWidth( SCCOL nCol ) const
1142 +USHORT ScTable::GetColWidth( SCCOL nCol )
1144 DBG_ASSERT(VALIDCOL(nCol),"Falsche Spaltennummer");
1146 if (VALIDCOL(nCol) && pColFlags && pColWidth)
1148 - if ( pColFlags[nCol] & CR_HIDDEN )
1149 + if (ColHidden(nCol))
1150 return 0;
1151 else
1152 return pColWidth[nCol];
1153 @@ -2187,7 +2204,7 @@ USHORT ScTable::GetOriginalWidth( SCCOL nCol ) const // immer die eingestellte
1157 -USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) const
1158 +USHORT ScTable::GetCommonWidth( SCCOL nEndCol )
1160 // get the width that is used in the largest continuous column range (up to nEndCol)
1162 @@ -2199,24 +2216,24 @@ USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) const
1164 USHORT nMaxWidth = 0;
1165 USHORT nMaxCount = 0;
1166 - USHORT nRangeStart = 0;
1167 + SCCOL nRangeStart = 0;
1168 while ( nRangeStart <= nEndCol )
1170 // skip hidden columns
1171 - while ( nRangeStart <= nEndCol && (pColFlags[nRangeStart] & CR_HIDDEN) )
1172 + while ( nRangeStart <= nEndCol && ColHidden(nRangeStart) )
1173 ++nRangeStart;
1174 if ( nRangeStart <= nEndCol )
1176 USHORT nThisCount = 0;
1177 USHORT nThisWidth = pColWidth[nRangeStart];
1178 - USHORT nRangeEnd = nRangeStart;
1179 + SCCOL nRangeEnd = nRangeStart;
1180 while ( nRangeEnd <= nEndCol && pColWidth[nRangeEnd] == nThisWidth )
1182 ++nThisCount;
1183 ++nRangeEnd;
1185 // skip hidden columns
1186 - while ( nRangeEnd <= nEndCol && (pColFlags[nRangeEnd] & CR_HIDDEN) )
1187 + while ( nRangeEnd <= nEndCol && ColHidden(nRangeEnd) )
1188 ++nRangeEnd;
1191 @@ -2234,13 +2251,13 @@ USHORT ScTable::GetCommonWidth( SCCOL nEndCol ) const
1195 -USHORT ScTable::GetRowHeight( SCROW nRow ) const
1196 +USHORT ScTable::GetRowHeight( SCROW nRow )
1198 DBG_ASSERT(VALIDROW(nRow),"Falsche Zeilennummer");
1200 - if (VALIDROW(nRow) && pRowFlags && pRowHeight)
1201 + if (VALIDROW(nRow) && pRowHeight)
1203 - if ( pRowFlags->GetValue(nRow) & CR_HIDDEN )
1204 + if (RowHidden(nRow))
1205 return 0;
1206 else
1207 return pRowHeight->GetValue(nRow);
1208 @@ -2250,28 +2267,53 @@ USHORT ScTable::GetRowHeight( SCROW nRow ) const
1212 -ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const
1213 +ULONG ScTable::GetRowHeight( SCROW nStartRow, SCROW nEndRow )
1215 DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer");
1217 - if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowFlags && pRowHeight)
1218 + if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowHeight)
1220 - return pRowFlags->SumCoupledArrayForCondition( nStartRow, nEndRow,
1221 - CR_HIDDEN, 0, *pRowHeight);
1222 + ULONG nHeight = 0;
1223 + SCROW nRow = nStartRow;
1224 + while (nRow <= nEndRow)
1226 + SCROW nLastRow = -1;
1227 + if (!RowHidden(nRow, nLastRow))
1229 + if (nLastRow > nEndRow)
1230 + nLastRow = nEndRow;
1231 + nHeight += pRowFlags->SumCoupledArrayForCondition(nRow, nLastRow, 0, 0, *pRowHeight);
1233 + nRow = nLastRow + 1;
1235 + return nHeight;
1237 else
1238 return (ULONG) ((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight);
1242 -ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const
1243 +ULONG ScTable::GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale )
1245 DBG_ASSERT(VALIDROW(nStartRow) && VALIDROW(nEndRow),"Falsche Zeilennummer");
1247 - if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowFlags && pRowHeight)
1248 + if (VALIDROW(nStartRow) && VALIDROW(nEndRow) && pRowHeight)
1250 - return pRowFlags->SumScaledCoupledArrayForCondition( nStartRow,
1251 - nEndRow, CR_HIDDEN, 0, *pRowHeight, fScale);
1252 + ULONG nHeight = 0;
1253 + SCROW nRow = nStartRow;
1254 + while (nRow <= nEndRow)
1256 + SCROW nLastRow = -1;
1257 + if (!RowHidden(nRow, nLastRow))
1259 + if (nLastRow > nEndRow)
1260 + nLastRow = nEndRow;
1261 + nHeight += pRowFlags->SumScaledCoupledArrayForCondition(
1262 + nRow, nLastRow, 0, 0, *pRowHeight, fScale);
1264 + nRow = nLastRow + 1;
1266 + return nHeight;
1268 else
1269 return (ULONG) ((nEndRow - nStartRow + 1) * ScGlobal::nStdRowHeight * fScale);
1270 @@ -2292,18 +2334,16 @@ USHORT ScTable::GetOriginalHeight( SCROW nRow ) const // non-0 even if hidden
1271 // Spalten-/Zeilen-Flags
1274 -SCROW ScTable::GetHiddenRowCount( SCROW nRow ) const
1275 +SCROW ScTable::GetHiddenRowCount( SCROW nRow )
1277 - SCROW nEndRow = nRow;
1278 - if ( pRowFlags )
1280 - nEndRow = pRowFlags->GetBitStateEnd( nRow, CR_HIDDEN, CR_HIDDEN);
1281 - if (ValidRow(nEndRow))
1282 - ++nEndRow;
1283 - else
1284 - nEndRow = nRow;
1286 - return nEndRow - nRow;
1287 + if (!ValidRow(nRow))
1288 + return 0;
1290 + SCROW nLastRow = -1;
1291 + if (!RowHidden(nRow, nLastRow) || !ValidRow(nLastRow))
1292 + return 0;
1294 + return nLastRow - nRow + 1;
1298 @@ -2311,9 +2351,9 @@ SCROW ScTable::GetHiddenRowCount( SCROW nRow ) const
1300 void ScTable::ShowCol(SCCOL nCol, BOOL bShow)
1302 - if (VALIDCOL(nCol) && pColFlags)
1303 + if (VALIDCOL(nCol))
1305 - BOOL bWasVis = ( pColFlags[nCol] & CR_HIDDEN ) == 0;
1306 + bool bWasVis = !ColHidden(nCol);
1307 if (bWasVis != bShow)
1309 nRecalcLvl++;
1310 @@ -2327,10 +2367,8 @@ void ScTable::ShowCol(SCCOL nCol, BOOL bShow)
1311 pDrawLayer->WidthChanged( nTab, nCol, -(long) pColWidth[nCol] );
1314 - if (bShow)
1315 - pColFlags[nCol] &= ~CR_HIDDEN;
1316 - else
1317 - pColFlags[nCol] |= CR_HIDDEN;
1318 + SetColHidden(nCol, nCol, !bShow);
1320 if( !--nRecalcLvl )
1321 SetDrawPageSize();
1323 @@ -2350,8 +2388,7 @@ void ScTable::ShowRow(SCROW nRow, BOOL bShow)
1325 if (VALIDROW(nRow) && pRowFlags)
1327 - BYTE nFlags = pRowFlags->GetValue(nRow);
1328 - BOOL bWasVis = ( nFlags & CR_HIDDEN ) == 0;
1329 + bool bWasVis = !RowHidden(nRow);
1330 if (bWasVis != bShow)
1332 nRecalcLvl++;
1333 @@ -2365,10 +2402,10 @@ void ScTable::ShowRow(SCROW nRow, BOOL bShow)
1334 pDrawLayer->HeightChanged( nTab, nRow, -(long) pRowHeight->GetValue(nRow) );
1337 + SetRowHidden(nRow, nRow, !bShow);
1338 if (bShow)
1339 - pRowFlags->SetValue( nRow, nFlags & ~(CR_HIDDEN | CR_FILTERED));
1340 - else
1341 - pRowFlags->SetValue( nRow, nFlags | CR_HIDDEN);
1342 + SetRowFiltered(nRow, nRow, false);
1344 if( !--nRecalcLvl )
1345 SetDrawPageSize();
1347 @@ -2390,8 +2427,7 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow)
1349 if (VALIDROW(nRow) && pRowFlags)
1351 - BYTE nFlags = pRowFlags->GetValue(nRow);
1352 - BOOL bWasVis = ( nFlags & CR_HIDDEN ) == 0;
1353 + bool bWasVis = !RowHidden(nRow);
1354 nRecalcLvl++;
1355 InitializeNoteCaptions();
1356 if (bWasVis != bShow)
1357 @@ -2407,10 +2443,10 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow)
1360 // Filter-Flag immer setzen, auch wenn Hidden unveraendert
1361 - if (bShow)
1362 - pRowFlags->SetValue( nRow, nFlags & ~(CR_HIDDEN | CR_FILTERED));
1363 - else
1364 - pRowFlags->SetValue( nRow, nFlags | (CR_HIDDEN | CR_FILTERED));
1366 + SetRowHidden(nRow, nRow, !bShow);
1367 + SetRowFiltered(nRow, nRow, !bShow);
1369 if( !--nRecalcLvl )
1370 SetDrawPageSize();
1372 @@ -2440,12 +2476,11 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
1373 InitializeNoteCaptions();
1374 while (nStartRow <= nRow2)
1376 - BYTE nOldFlag = pRowFlags->GetValue(nStartRow) & CR_HIDDEN;
1377 - SCROW nEndRow = pRowFlags->GetBitStateEnd( nStartRow, CR_HIDDEN, nOldFlag);
1378 + SCROW nEndRow = -1;
1379 + bool bWasVis = !RowHidden(nStartRow, nEndRow);
1380 if (nEndRow > nRow2)
1381 nEndRow = nRow2;
1383 - BOOL bWasVis = ( nOldFlag == 0 );
1384 BOOL bChanged = ( bWasVis != bShow );
1385 if ( bChanged )
1387 @@ -2460,10 +2495,8 @@ void ScTable::DBShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
1391 - if (bShow)
1392 - pRowFlags->AndValue( nStartRow, nEndRow, sal::static_int_cast<BYTE>(~(CR_HIDDEN | CR_FILTERED)) );
1393 - else
1394 - pRowFlags->OrValue( nStartRow, nEndRow, (CR_HIDDEN | CR_FILTERED));
1395 + SetRowHidden(nStartRow, nEndRow, !bShow);
1396 + SetRowFiltered(nStartRow, nEndRow, !bShow);
1398 if ( bChanged )
1400 @@ -2493,12 +2526,11 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
1401 InitializeNoteCaptions();
1402 while (nStartRow <= nRow2)
1404 - BYTE nOldFlag = pRowFlags->GetValue(nStartRow) & CR_HIDDEN;
1405 - SCROW nEndRow = pRowFlags->GetBitStateEnd( nStartRow, CR_HIDDEN, nOldFlag);
1406 + SCROW nEndRow = -1;
1407 + bool bWasVis = !RowHidden(nStartRow, nEndRow);
1408 if (nEndRow > nRow2)
1409 nEndRow = nRow2;
1411 - BOOL bWasVis = ( nOldFlag == 0 );
1412 BOOL bChanged = ( bWasVis != bShow );
1413 if ( bChanged )
1415 @@ -2513,10 +2545,9 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
1419 + SetRowHidden(nStartRow, nEndRow, !bShow);
1420 if (bShow)
1421 - pRowFlags->AndValue( nStartRow, nEndRow, sal::static_int_cast<BYTE>(~(CR_HIDDEN | CR_FILTERED)) );
1422 - else
1423 - pRowFlags->OrValue( nStartRow, nEndRow, CR_HIDDEN);
1424 + SetRowFiltered(nStartRow, nEndRow, false);
1426 if ( bChanged )
1428 @@ -2534,16 +2565,6 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
1432 -BOOL ScTable::IsFiltered(SCROW nRow) const
1434 - if (VALIDROW(nRow) && pRowFlags)
1435 - return ( pRowFlags->GetValue(nRow) & CR_FILTERED ) != 0;
1437 - DBG_ERROR("Falsche Zeilennummer oder keine Flags");
1438 - return FALSE;
1442 void ScTable::SetColFlags( SCCOL nCol, BYTE nNewFlags )
1444 if (VALIDCOL(nCol) && pColFlags)
1445 @@ -2641,7 +2662,7 @@ BOOL ScTable::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, BOOL bShow )
1446 if (pOutlineTable && pColFlags)
1448 ScBitMaskCompressedArray< SCCOLROW, BYTE> aArray( MAXCOL, pColFlags, MAXCOLCOUNT);
1449 - return pOutlineTable->GetColArray()->ManualAction( nStartCol, nEndCol, bShow, aArray );
1450 + return pOutlineTable->GetColArray()->ManualAction( nStartCol, nEndCol, bShow, *this, true );
1452 else
1453 return FALSE;
1454 @@ -2651,7 +2672,7 @@ BOOL ScTable::UpdateOutlineCol( SCCOL nStartCol, SCCOL nEndCol, BOOL bShow )
1455 BOOL ScTable::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, BOOL bShow )
1457 if (pOutlineTable && pRowFlags)
1458 - return pOutlineTable->GetRowArray()->ManualAction( nStartRow, nEndRow, bShow, *pRowFlags );
1459 + return pOutlineTable->GetRowArray()->ManualAction( nStartRow, nEndRow, bShow, *this, false );
1460 else
1461 return FALSE;
1463 @@ -2659,54 +2680,58 @@ BOOL ScTable::UpdateOutlineRow( SCROW nStartRow, SCROW nEndRow, BOOL bShow )
1465 void ScTable::ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
1467 - if (pColFlags)
1469 - while ( rX1>0 ? (pColFlags[rX1-1] & CR_HIDDEN) : FALSE )
1470 - --rX1;
1471 - while ( rX2<MAXCOL ? (pColFlags[rX2+1] & CR_HIDDEN) : FALSE )
1472 - ++rX2;
1474 - if (pRowFlags)
1475 + // Column-wise expansion
1477 + while (rX1 > 0 && ColHidden(rX1-1))
1478 + --rX1;
1480 + while (rX2 < MAXCOL && ColHidden(rX2+1))
1481 + ++rX2;
1483 + // Row-wise expansion
1485 + if (rY1 > 0)
1487 - if (rY1 > 0)
1488 + ScFlatBoolRowSegments::RangeData aData;
1489 + if (mpHiddenRows->getRangeData(rY1-1, aData) && aData.mbValue)
1491 - SCROW nStartRow = pRowFlags->GetBitStateStart( rY1-1, CR_HIDDEN, CR_HIDDEN);
1492 + SCROW nStartRow = aData.mnRow1;
1493 if (ValidRow(nStartRow))
1494 rY1 = nStartRow;
1496 - if (rY2 < MAXROW)
1498 - SCROW nEndRow = pRowFlags->GetBitStateEnd( rY2+1, CR_HIDDEN, CR_HIDDEN);
1499 - if (ValidRow(nEndRow))
1500 - rY2 = nEndRow;
1503 + if (rY2 < MAXROW)
1505 + SCROW nEndRow = -1;
1506 + if (RowHidden(rY2+1, nEndRow) && ValidRow(nEndRow))
1507 + rY2 = nEndRow;
1512 void ScTable::StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 )
1514 - if (pColFlags)
1516 - while ( rX2>rX1 && (pColFlags[rX2] & CR_HIDDEN) )
1517 - --rX2;
1518 - while ( rX2>rX1 && (pColFlags[rX1] & CR_HIDDEN) )
1519 - ++rX1;
1521 - if (pRowFlags)
1522 + while ( rX2>rX1 && ColHidden(rX2) )
1523 + --rX2;
1524 + while ( rX2>rX1 && ColHidden(rX1) )
1525 + ++rX1;
1527 + if (rY1 < rY2)
1529 - if (rY1 < rY2)
1530 + ScFlatBoolRowSegments::RangeData aData;
1531 + if (mpHiddenRows->getRangeData(rY2, aData) && aData.mbValue)
1533 - SCROW nStartRow = pRowFlags->GetBitStateStart( rY2, CR_HIDDEN, CR_HIDDEN);
1534 + SCROW nStartRow = aData.mnRow1;
1535 if (ValidRow(nStartRow) && nStartRow >= rY1)
1536 rY2 = nStartRow;
1538 - if (rY1 < rY2)
1540 - SCROW nEndRow = pRowFlags->GetBitStateEnd( rY1, CR_HIDDEN, CR_HIDDEN);
1541 - if (ValidRow(nEndRow) && nEndRow <= rY2)
1542 - rY1 = nEndRow;
1546 + if (rY1 < rY2)
1548 + SCROW nEndRow = -1;
1549 + if (RowHidden(rY1, nEndRow) && ValidRow(nEndRow) && nEndRow <= rY2)
1550 + rY1 = nEndRow;
1554 @@ -2868,16 +2893,16 @@ BOOL ScTable::RefVisible(ScFormulaCell* pCell)
1556 if (pCell->HasOneReference(aRef))
1558 - if (aRef.aStart.Col()==aRef.aEnd.Col() && aRef.aStart.Tab()==aRef.aEnd.Tab() && pRowFlags)
1559 + if (aRef.aStart.Col()==aRef.aEnd.Col() && aRef.aStart.Tab()==aRef.aEnd.Tab())
1561 - // while ((value & CR_FILTERED) == CR_FILTERED)
1562 - // most times will be faster than
1563 - // while ((value & CR_FILTERED) == 0)
1564 - SCROW nEndRow = pRowFlags->GetBitStateEnd( aRef.aStart.Row(),
1565 - CR_FILTERED, CR_FILTERED);
1566 + SCROW nEndRow;
1567 + if (!RowFiltered(aRef.aStart.Row(), NULL, &nEndRow))
1568 + // row not filtered.
1569 + nEndRow = ::std::numeric_limits<SCROW>::max();
1571 if (!ValidRow(nEndRow) || nEndRow < aRef.aEnd.Row())
1572 return TRUE; // at least partly visible
1573 - return FALSE; // completely unvisible
1574 + return FALSE; // completely invisible
1578 @@ -2914,7 +2939,7 @@ void ScTable::SetDrawPageSize()
1582 -ULONG ScTable::GetRowOffset( SCROW nRow ) const
1583 +ULONG ScTable::GetRowOffset( SCROW nRow )
1585 ULONG n = 0;
1586 if ( pRowFlags && pRowHeight )
1587 @@ -2924,8 +2949,7 @@ ULONG ScTable::GetRowOffset( SCROW nRow ) const
1588 else if (nRow == 1)
1589 return GetRowHeight(0);
1591 - n = pRowFlags->SumCoupledArrayForCondition( 0, nRow-1, CR_HIDDEN, 0,
1592 - *pRowHeight);
1593 + n = GetTotalRowHeight(0, nRow-1);
1594 #ifdef DBG_UTIL
1595 if (n == ::std::numeric_limits<unsigned long>::max())
1596 DBG_ERRORFILE("ScTable::GetRowOffset: row heights overflow");
1597 @@ -2938,18 +2962,42 @@ ULONG ScTable::GetRowOffset( SCROW nRow ) const
1598 return n;
1601 +SCROW ScTable::GetRowForHeight(ULONG nHeight)
1603 + sal_uInt32 nSum = 0;
1605 + ScFlatBoolRowSegments::RangeData aData;
1606 + for (SCROW nRow = 0; nRow <= MAXROW; ++nRow)
1608 + if (!mpHiddenRows->getRangeData(nRow, aData))
1609 + break;
1611 + if (aData.mbValue)
1613 + nRow = aData.mnRow2;
1614 + continue;
1617 + sal_uInt32 nNew = pRowHeight->GetValue(nRow);
1618 + nSum += nNew;
1619 + if (nSum > nHeight)
1621 + return nRow < MAXROW ? nRow + 1 : MAXROW;
1624 + return -1;
1628 -ULONG ScTable::GetColOffset( SCCOL nCol ) const
1629 +ULONG ScTable::GetColOffset( SCCOL nCol )
1631 ULONG n = 0;
1632 - if ( pColFlags && pColWidth )
1633 + if ( pColWidth )
1635 SCCOL i;
1636 - BYTE* pFlags = pColFlags;
1637 - USHORT* pWidth = pColWidth;
1638 - for( i = 0; i < nCol; i++, pFlags++, pWidth++ )
1639 - if( !( *pFlags & CR_HIDDEN ) )
1640 - n += *pWidth;
1641 + for( i = 0; i < nCol; i++ )
1642 + if (!ColHidden(i))
1643 + n += pColWidth[i];
1645 else
1647 diff --git sc/source/core/data/table3.cxx sc/source/core/data/table3.cxx
1648 index 4d3b4de..cbf417b 100644
1649 --- sc/source/core/data/table3.cxx
1650 +++ sc/source/core/data/table3.cxx
1651 @@ -603,14 +603,17 @@ void ScTable::SwapRow(SCROW nRow1, SCROW nRow2)
1655 - if (bGlobalKeepQuery && pRowFlags)
1656 + if (bGlobalKeepQuery)
1658 - BYTE nRow1Flags = pRowFlags->GetValue(nRow1);
1659 - BYTE nRow2Flags = pRowFlags->GetValue(nRow2);
1660 - BYTE nFlags1 = nRow1Flags & ( CR_HIDDEN | CR_FILTERED );
1661 - BYTE nFlags2 = nRow2Flags & ( CR_HIDDEN | CR_FILTERED );
1662 - pRowFlags->SetValue( nRow1, (nRow1Flags & ~( CR_HIDDEN | CR_FILTERED )) | nFlags2);
1663 - pRowFlags->SetValue( nRow2, (nRow2Flags & ~( CR_HIDDEN | CR_FILTERED )) | nFlags1);
1664 + bool bRow1Hidden = RowHidden(nRow1);
1665 + bool bRow2Hidden = RowHidden(nRow2);
1666 + SetRowHidden(nRow1, nRow1, bRow2Hidden);
1667 + SetRowHidden(nRow2, nRow2, bRow1Hidden);
1669 + bool bRow1Filtered = RowFiltered(nRow1);
1670 + bool bRow2Filtered = RowFiltered(nRow2);
1671 + SetRowFiltered(nRow1, nRow1, bRow2Filtered);
1672 + SetRowFiltered(nRow2, nRow2, bRow1Filtered);
1676 @@ -991,13 +994,6 @@ BOOL ScTable::DoSubTotals( ScSubTotalParam& rParam )
1677 SetString( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, nTab, aOutString );
1678 ApplyStyle( nGroupCol[aRowEntry.nGroupNo], aRowEntry.nDestRow, *pStyle );
1680 -/* if (rParam.bPagebreak && nRow < MAXROW)
1682 - BYTE nFlags = GetRowFlags( nRow+1 );
1683 - nFlags |= CR_MANUALBREAK;
1684 - SetRowFlags( nRow+1, nFlags );
1687 ++nRow;
1688 ++nEndRow;
1689 aRowEntry.nSubStartRow = nRow;
1690 @@ -1011,11 +1007,7 @@ BOOL ScTable::DoSubTotals( ScSubTotalParam& rParam )
1694 - if (!pRowFlags)
1695 - bBlockVis = TRUE;
1696 - else
1697 - if ( (pRowFlags->GetValue(nRow) & CR_FILTERED) == 0 )
1698 - bBlockVis = TRUE;
1699 + bBlockVis = !RowFiltered(nRow);
1702 else
1703 @@ -2051,8 +2043,8 @@ void ScTable::UpdateSelectionFunction( ScFunctionData& rData,
1704 SCCOL nCol;
1705 if ( rMark.IsMultiMarked() )
1706 for (nCol=0; nCol<=MAXCOL && !rData.bError; nCol++)
1707 - if ( !pColFlags || !( pColFlags[nCol] & CR_HIDDEN ) )
1708 - aCol[nCol].UpdateSelectionFunction( rMark, rData, pRowFlags,
1709 + if ( !pColFlags || !ColHidden(nCol) )
1710 + aCol[nCol].UpdateSelectionFunction( rMark, rData, *mpHiddenRows,
1711 bSingle && ( nCol >= nStartCol && nCol <= nEndCol ),
1712 nStartRow, nEndRow );
1714 @@ -2060,8 +2052,8 @@ void ScTable::UpdateSelectionFunction( ScFunctionData& rData,
1716 if ( bSingle && !rMark.IsMarkNegative() )
1717 for (nCol=nStartCol; nCol<=nEndCol && !rData.bError; nCol++)
1718 - if ( !pColFlags || !( pColFlags[nCol] & CR_HIDDEN ) )
1719 - aCol[nCol].UpdateAreaFunction( rData, pRowFlags, nStartRow, nEndRow );
1720 + if ( !pColFlags || !ColHidden(nCol) )
1721 + aCol[nCol].UpdateAreaFunction( rData, *mpHiddenRows, nStartRow, nEndRow );
1724 void ScTable::FindConditionalFormat( ULONG nKey, ScRangeList& rList )
1725 diff --git sc/source/core/data/table5.cxx sc/source/core/data/table5.cxx
1726 index 48f7110..7e7cab9 100644
1727 --- sc/source/core/data/table5.cxx
1728 +++ sc/source/core/data/table5.cxx
1729 @@ -53,9 +53,11 @@
1730 #include "brdcst.hxx"
1731 #include "tabprotection.hxx"
1732 #include "globstr.hrc"
1733 +#include "segmenttree.hxx"
1734 #include <com/sun/star/sheet/TablePageBreakData.hpp>
1736 #include <algorithm>
1737 +#include <limits>
1739 using ::com::sun::star::uno::Sequence;
1740 using ::com::sun::star::sheet::TablePageBreakData;
1741 @@ -168,7 +170,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
1742 for (nX=nStartCol; nX<=nEndCol; nX++)
1744 BOOL bStartOfPage = FALSE;
1745 - long nThisX = ( pColFlags[nX] & CR_HIDDEN ) ? 0 : pColWidth[nX];
1746 + long nThisX = ColHidden(nX) ? 0 : pColWidth[nX];
1747 bool bManualBreak = HasColManualBreak(nX);
1748 if ( (nSizeX+nThisX > nPageSizeX) || (bManualBreak && !bSkipBreaks) )
1750 @@ -185,7 +187,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
1752 // subtract size of repeat columns from page size
1753 for (SCCOL i=nRepeatStartX; i<=nRepeatEndX; i++)
1754 - nPageSizeX -= ( pColFlags[i] & CR_HIDDEN ) ? 0 : pColWidth[i];
1755 + nPageSizeX -= ColHidden(i) ? 0 : pColWidth[i];
1756 while (nX<=nRepeatEndX)
1757 RemoveColBreak(++nX, true, false);
1758 bColFound = TRUE;
1759 @@ -204,8 +206,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
1760 for (SCROW nY = nStartRow; nY <= nEndRow; ++nY)
1762 BOOL bStartOfPage = FALSE;
1763 - BYTE nFlags = pRowFlags->GetValue(nY);
1764 - long nThisY = (nFlags & CR_HIDDEN) ? 0 : pRowHeight->GetValue(nY);
1765 + long nThisY = RowHidden(nY) ? 0 : pRowHeight->GetValue(nY);
1766 bool bManualBreak = HasRowManualBreak(nY);
1767 if ( (nSizeY+nThisY > nPageSizeY) || (bManualBreak && !bSkipBreaks) )
1769 @@ -221,8 +222,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
1770 if ( bStartOfPage && bRepeatRow && nY>nRepeatStartY && !bRowFound )
1772 // subtract size of repeat rows from page size
1773 - unsigned long nHeights = pRowFlags->SumCoupledArrayForCondition(
1774 - nRepeatStartY, nRepeatEndY, CR_HIDDEN, 0, *pRowHeight);
1775 + unsigned long nHeights = GetTotalRowHeight(nRepeatStartY, nRepeatEndY);
1776 #ifdef DBG_UTIL
1777 if (nHeights == ::std::numeric_limits<unsigned long>::max())
1778 DBG_ERRORFILE("ScTable::UpdatePageBreaks: row heights overflow");
1779 @@ -416,12 +416,516 @@ Sequence<TablePageBreakData> ScTable::GetRowBreakData() const
1780 return aSeq;
1783 -void ScTable::SyncColRowFlags()
1784 +bool ScTable::RowHidden(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow)
1786 + if (!ValidRow(nRow))
1787 + return true;
1789 + ScFlatBoolRowSegments::RangeData aData;
1790 + if (!mpHiddenRows->getRangeData(nRow, aData))
1791 + // search failed.
1792 + return true;
1794 + if (pFirstRow)
1795 + *pFirstRow = aData.mnRow1;
1796 + if (pLastRow)
1797 + *pLastRow = aData.mnRow2;
1799 + return aData.mbValue;
1803 +bool ScTable::RowHidden(SCROW nRow, SCROW& rLastRow)
1805 + rLastRow = nRow;
1806 + if (!ValidRow(nRow))
1807 + return true;
1809 + ScFlatBoolRowSegments::RangeData aData;
1810 + if (!mpHiddenRows->getRangeData(nRow, aData))
1811 + // search failed.
1812 + return true;
1814 + rLastRow = aData.mnRow2;
1815 + return aData.mbValue;
1818 +bool ScTable::HasHiddenRows(SCROW nStartRow, SCROW nEndRow)
1820 + SCROW nRow = nStartRow;
1821 + while (nRow <= nEndRow)
1823 + SCROW nLastRow = -1;
1824 + bool bHidden = RowHidden(nRow, nLastRow);
1825 + if (bHidden)
1826 + return true;
1828 + nRow = nLastRow + 1;
1830 + return false;
1833 +bool ScTable::ColHidden(SCCOL nCol, SCCOL& rLastCol)
1835 + rLastCol = nCol;
1836 + if (!ValidCol(nCol))
1837 + return true;
1839 + ScFlatBoolColSegments::RangeData aData;
1840 + if (!mpHiddenCols->getRangeData(nCol, aData))
1841 + return true;
1843 + rLastCol = aData.mnCol2;
1844 + return aData.mbValue;
1847 +bool ScTable::ColHidden(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol)
1849 + if (!ValidCol(nCol))
1850 + return true;
1852 + ScFlatBoolColSegments::RangeData aData;
1853 + if (!mpHiddenCols->getRangeData(nCol, aData))
1854 + return true;
1856 + if (pFirstCol)
1857 + *pFirstCol = aData.mnCol1;
1858 + if (pLastCol)
1859 + *pLastCol = aData.mnCol2;
1861 + return aData.mbValue;
1864 +void ScTable::SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden)
1866 + if (bHidden)
1867 + mpHiddenRows->setTrue(nStartRow, nEndRow);
1868 + else
1869 + mpHiddenRows->setFalse(nStartRow, nEndRow);
1871 +#if 0
1872 + // Remove this once the refactoring is complete.
1873 + if (bHidden)
1874 + pRowFlags->OrValue(nStartRow, nEndRow, CR_HIDDEN);
1875 + else
1876 + pRowFlags->AndValue(nStartRow, nEndRow, ~CR_HIDDEN);
1877 +#endif
1880 +void ScTable::SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden)
1882 + if (bHidden)
1883 + mpHiddenCols->setTrue(nStartCol, nEndCol);
1884 + else
1885 + mpHiddenCols->setFalse(nStartCol, nEndCol);
1886 +#if 0
1887 + for (SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol)
1889 + if (bHidden)
1890 + pColFlags[nCol] |= CR_HIDDEN;
1891 + else
1892 + pColFlags[nCol] &= ~CR_HIDDEN;
1894 +#endif
1897 +void ScTable::CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol)
1899 + SCCOL nCol = nStartCol;
1900 + while (nCol <= nEndCol)
1902 + SCCOL nLastCol;
1903 + bool bHidden = rTable.ColHidden(nCol, NULL, &nLastCol);
1904 + if (nLastCol > nEndCol)
1905 + nLastCol = nEndCol;
1907 + SetColHidden(nCol, nLastCol, bHidden);
1908 + nCol = nLastCol + 1;
1912 +void ScTable::CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow)
1914 + SCROW nRow = nStartRow;
1915 + while (nRow <= nEndRow)
1917 + SCROW nLastRow = -1;
1918 + bool bHidden = rTable.RowHidden(nRow, nLastRow);
1919 + if (nLastRow > nEndRow)
1920 + nLastRow = nEndRow;
1921 + SetRowHidden(nRow, nLastRow, bHidden);
1922 + nRow = nLastRow + 1;
1926 +SCROW ScTable::FirstVisibleRow(SCROW nStartRow, SCROW nEndRow)
1928 + SCROW nRow = nStartRow;
1929 + ScFlatBoolRowSegments::RangeData aData;
1930 + while (nRow <= nEndRow)
1932 + if (!ValidRow(nRow))
1933 + break;
1935 + if (!mpHiddenRows->getRangeData(nRow, aData))
1936 + // failed to get range data.
1937 + break;
1939 + if (!aData.mbValue)
1940 + // visible row found
1941 + return nRow;
1943 + nRow = aData.mnRow2 + 1;
1946 + return ::std::numeric_limits<SCROW>::max();
1949 +SCROW ScTable::LastVisibleRow(SCROW nStartRow, SCROW nEndRow)
1951 + SCROW nRow = nEndRow;
1952 + ScFlatBoolRowSegments::RangeData aData;
1953 + while (nRow >= nStartRow)
1955 + if (!ValidRow(nRow))
1956 + break;
1958 + if (!mpHiddenRows->getRangeData(nRow, aData))
1959 + // failed to get range data.
1960 + break;
1962 + if (!aData.mbValue)
1963 + // visible row found
1964 + return nRow;
1966 + nRow = aData.mnRow1 - 1;
1969 + return ::std::numeric_limits<SCROW>::max();
1972 +SCROW ScTable::CountVisibleRows(SCROW nStartRow, SCROW nEndRow)
1974 + SCROW nCount = 0;
1975 + SCROW nRow = nStartRow;
1976 + ScFlatBoolRowSegments::RangeData aData;
1977 + while (nRow <= nEndRow)
1979 + if (!mpHiddenRows->getRangeData(nRow, aData))
1980 + break;
1982 + if (aData.mnRow2 > nEndRow)
1983 + aData.mnRow2 = nEndRow;
1985 + if (!aData.mbValue)
1986 + nCount += aData.mnRow2 - nRow + 1;
1988 + nRow = aData.mnRow2 + 1;
1990 + return nCount;
1993 +sal_uInt32 ScTable::GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow)
1995 + sal_uInt32 nHeight = 0;
1996 + SCROW nRow = nStartRow;
1997 + ScFlatBoolRowSegments::RangeData aData;
1998 + while (nRow <= nEndRow)
2000 + if (!mpHiddenRows->getRangeData(nRow, aData))
2001 + break;
2003 + if (aData.mnRow2 > nEndRow)
2004 + aData.mnRow2 = nEndRow;
2006 + if (!aData.mbValue)
2007 + // visible row range.
2008 + nHeight += pRowHeight->SumValues(nRow, aData.mnRow2);
2010 + nRow = aData.mnRow2 + 1;
2013 + return nHeight;
2016 +SCCOLROW ScTable::LastHiddenColRow(SCCOLROW nPos, bool bCol)
2018 + if (bCol)
2020 + SCCOL nCol = static_cast<SCCOL>(nPos);
2021 + if (ColHidden(nCol))
2023 + for (SCCOL i = nCol+1; i <= MAXCOL; ++i)
2025 + if (!ColHidden(nCol))
2026 + return nCol - 1;
2030 + else
2032 + SCROW nRow = static_cast<SCROW>(nPos);
2033 + SCROW nLastRow;
2034 + if (RowHidden(nRow, NULL, &nLastRow))
2035 + return static_cast<SCCOLROW>(nLastRow);
2037 + return ::std::numeric_limits<SCCOLROW>::max();
2040 +bool ScTable::RowFiltered(SCROW nRow, SCROW* pFirstRow, SCROW* pLastRow)
2042 +#if 1
2043 + if (!ValidRow(nRow))
2044 + return false;
2046 + ScFlatBoolRowSegments::RangeData aData;
2047 + if (!mpFilteredRows->getRangeData(nRow, aData))
2048 + // search failed.
2049 + return false;
2051 + if (pFirstRow)
2052 + *pFirstRow = aData.mnRow1;
2053 + if (pLastRow)
2054 + *pLastRow = aData.mnRow2;
2056 + return aData.mbValue;
2057 +#else
2058 + if (pFirstRow)
2059 + *pFirstRow = nRow;
2060 + if (pLastRow)
2061 + *pLastRow = nRow;
2062 + return (pRowFlags->GetValue(nRow) & CR_FILTERED) == CR_FILTERED;
2063 +#endif
2066 +bool ScTable::ColFiltered(SCCOL nCol, SCCOL* pFirstCol, SCCOL* pLastCol)
2068 +#if 1
2069 + if (!ValidCol(nCol))
2070 + return false;
2072 + ScFlatBoolColSegments::RangeData aData;
2073 + if (!mpFilteredCols->getRangeData(nCol, aData))
2074 + // search failed.
2075 + return false;
2077 + if (pFirstCol)
2078 + *pFirstCol = aData.mnCol1;
2079 + if (pLastCol)
2080 + *pLastCol = aData.mnCol2;
2082 + return aData.mbValue;
2083 +#else
2084 + if (pFirstCol)
2085 + *pFirstCol = nCol;
2086 + if (pLastCol)
2087 + *pLastCol = nCol;
2088 + return (pColFlags[nCol] & CR_FILTERED) == CR_FILTERED;
2089 +#endif
2092 +bool ScTable::HasFilteredRows(SCROW nStartRow, SCROW nEndRow)
2094 + SCROW nRow = nStartRow;
2095 + while (nRow <= nEndRow)
2097 + SCROW nLastRow = nRow;
2098 + bool bFiltered = RowFiltered(nRow, NULL, &nLastRow);
2099 + if (bFiltered)
2100 + return true;
2102 + nRow = nLastRow + 1;
2104 + return false;
2107 +void ScTable::CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol)
2109 + SCCOL nCol = nStartCol;
2110 + while (nCol <= nEndCol)
2112 + SCCOL nLastCol;
2113 + bool bFiltered = rTable.ColFiltered(nCol, NULL, &nLastCol);
2114 + if (nLastCol > nEndCol)
2115 + nLastCol = nEndCol;
2117 + SetColFiltered(nCol, nLastCol, bFiltered);
2118 + nCol = nLastCol + 1;
2122 +void ScTable::CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow)
2124 + SCROW nRow = nStartRow;
2125 + while (nRow <= nEndRow)
2127 + SCROW nLastRow = -1;
2128 + bool bFiltered = rTable.RowFiltered(nRow, NULL, &nLastRow);
2129 + if (nLastRow > nEndRow)
2130 + nLastRow = nEndRow;
2131 + SetRowFiltered(nRow, nLastRow, bFiltered);
2132 + nRow = nLastRow + 1;
2136 +void ScTable::SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered)
2138 + if (bFiltered)
2139 + mpFilteredRows->setTrue(nStartRow, nEndRow);
2140 + else
2141 + mpFilteredRows->setFalse(nStartRow, nEndRow);
2143 +#if 0
2144 + // Remove this once the refactoring is complete.
2145 + if (bFiltered)
2146 + pRowFlags->OrValue(nStartRow, nEndRow, CR_FILTERED);
2147 + else
2148 + pRowFlags->AndValue(nStartRow, nEndRow, ~CR_FILTERED);
2149 +#endif
2152 +void ScTable::SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered)
2154 + if (bFiltered)
2155 + mpFilteredCols->setTrue(nStartCol, nEndCol);
2156 + else
2157 + mpFilteredCols->setFalse(nStartCol, nEndCol);
2159 +#if 0
2160 + // Remove this once the refactoring is complete.
2161 + for (SCCOL nCol = nStartCol; nCol <= nEndCol; ++nCol)
2163 + if (bFiltered)
2164 + pColFlags[nCol] |= CR_FILTERED;
2165 + else
2166 + pColFlags[nCol] &= ~CR_FILTERED;
2168 +#endif
2171 +SCROW ScTable::FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow)
2173 + SCROW nRow = nStartRow;
2174 + ScFlatBoolRowSegments::RangeData aData;
2175 + while (nRow <= nEndRow)
2177 + if (!ValidRow(nRow))
2178 + break;
2180 + if (!mpFilteredRows->getRangeData(nRow, aData))
2181 + // failed to get range data.
2182 + break;
2184 + if (!aData.mbValue)
2185 + // non-filtered row found
2186 + return nRow;
2188 + nRow = aData.mnRow2 + 1;
2191 + return ::std::numeric_limits<SCROW>::max();
2194 +SCROW ScTable::LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow)
2196 + SCROW nRow = nEndRow;
2197 + ScFlatBoolRowSegments::RangeData aData;
2198 + while (nRow >= nStartRow)
2200 + if (!ValidRow(nRow))
2201 + break;
2203 + if (!mpFilteredRows->getRangeData(nRow, aData))
2204 + // failed to get range data.
2205 + break;
2207 + if (!aData.mbValue)
2208 + // non-filtered row found
2209 + return nRow;
2211 + nRow = aData.mnRow1 - 1;
2214 + return ::std::numeric_limits<SCROW>::max();
2217 +SCROW ScTable::CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow)
2219 + SCROW nCount = 0;
2220 + SCROW nRow = nStartRow;
2221 + ScFlatBoolRowSegments::RangeData aData;
2222 + while (nRow <= nEndRow)
2224 + if (!mpFilteredRows->getRangeData(nRow, aData))
2225 + break;
2227 + if (aData.mnRow2 > nEndRow)
2228 + aData.mnRow2 = nEndRow;
2230 + if (!aData.mbValue)
2231 + nCount += aData.mnRow2 - nRow + 1;
2233 + nRow = aData.mnRow2 + 1;
2235 + return nCount;
2238 +namespace {
2240 +void lcl_syncFlags(ScFlatBoolColSegments& rColSegments, ScFlatBoolRowSegments& rRowSegments,
2241 + BYTE* pColFlags, ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags, const BYTE nFlagMask)
2243 using ::sal::static_int_cast;
2245 - // For now, we only need to sync the manual breaks.
2246 + pRowFlags->AndValue(0, MAXROW, static_int_cast<BYTE>(~nFlagMask));
2247 + for (SCCOL i = 0; i <= MAXCOL; ++i)
2248 + pColFlags[i] &= static_int_cast<BYTE>(~nFlagMask);
2251 + // row hidden flags.
2253 + SCROW nRow = 0;
2254 + ScFlatBoolRowSegments::RangeData aData;
2255 + while (nRow <= MAXROW)
2257 + if (!rRowSegments.getRangeData(nRow, aData))
2258 + break;
2260 + if (aData.mbValue)
2261 + pRowFlags->OrValue(nRow, aData.mnRow2, static_int_cast<BYTE>(nFlagMask));
2263 + nRow = aData.mnRow2 + 1;
2268 + // column hidden flags.
2270 + SCCOL nCol = 0;
2271 + ScFlatBoolColSegments::RangeData aData;
2272 + while (nCol <= MAXCOL)
2274 + if (!rColSegments.getRangeData(nCol, aData))
2275 + break;
2277 + if (aData.mbValue)
2279 + for (SCCOL i = nCol; i <= aData.mnCol2; ++i)
2280 + pColFlags[i] |= nFlagMask;
2283 + nCol = aData.mnCol2 + 1;
2290 +void ScTable::SyncColRowFlags()
2292 + using ::sal::static_int_cast;
2294 + // Manual breaks.
2295 pRowFlags->AndValue(0, MAXROW, static_int_cast<BYTE>(~CR_MANUALBREAK));
2296 for (SCCOL i = 0; i <= MAXCOL; ++i)
2297 pColFlags[i] &= static_int_cast<BYTE>(~CR_MANUALBREAK);
2298 @@ -439,6 +943,10 @@ void ScTable::SyncColRowFlags()
2299 itr != itrEnd; ++itr)
2300 pColFlags[*itr] |= CR_MANUALBREAK;
2303 + // Hidden flags.
2304 + lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, pColFlags, pRowFlags, CR_HIDDEN);
2305 + lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, pColFlags, pRowFlags, CR_FILTERED);
2308 void ScTable::SetPageSize( const Size& rSize )
2309 diff --git sc/source/core/tool/chartarr.cxx sc/source/core/tool/chartarr.cxx
2310 index 5445a9d..5951957 100644
2311 --- sc/source/core/tool/chartarr.cxx
2312 +++ sc/source/core/tool/chartarr.cxx
2313 @@ -47,6 +47,9 @@
2314 #include "cell.hxx"
2315 #include "docoptio.hxx"
2317 +#include <vector>
2319 +using ::std::vector;
2321 // -----------------------------------------------------------------------
2323 @@ -166,11 +169,17 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2325 SCCOL nStrCol = nCol1; // fuer Beschriftung merken
2326 SCROW nStrRow = nRow1;
2327 - // Beschriftungen auch nach HiddenCols finden
2328 - while ( (pDocument->GetColFlags( nCol1, nTab1) & CR_HIDDEN) != 0 )
2329 - nCol1++;
2330 - nRow1 = pDocument->GetRowFlagsArray( nTab1).GetFirstForCondition( nRow1,
2331 - nRow2, CR_HIDDEN, 0);
2332 + // Skip hidden columns.
2333 + // TODO: make use of last column value once implemented.
2334 + SCCOL nLastCol = -1;
2335 + while (pDocument->ColHidden(nCol1, nTab1, nLastCol))
2336 + ++nCol1;
2338 + // Skip hidden rows.
2339 + SCROW nLastRow = -1;
2340 + if (pDocument->RowHidden(nRow1, nTab1, nLastRow))
2341 + nRow1 = nLastRow + 1;
2343 // falls alles hidden ist, bleibt die Beschriftung am Anfang
2344 if ( nCol1 <= nCol2 )
2346 @@ -184,17 +193,33 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2349 SCSIZE nTotalCols = ( nCol1 <= nCol2 ? nCol2 - nCol1 + 1 : 0 );
2350 - SCCOL* pCols = new SCCOL[nTotalCols > 0 ? nTotalCols : 1];
2351 - SCSIZE nColCount = 0;
2352 + vector<SCCOL> aCols;
2353 + aCols.reserve(nTotalCols);
2354 for (SCSIZE i=0; i<nTotalCols; i++)
2355 - if ((pDocument->GetColFlags(sal::static_int_cast<SCCOL>(nCol1+i),nTab1)&CR_HIDDEN)==0)
2356 - pCols[nColCount++] = sal::static_int_cast<SCCOL>(nCol1+i);
2358 + SCCOL nThisCol = sal::static_int_cast<SCCOL>(nCol1+i);
2359 + if (!pDocument->ColHidden(nThisCol, nTab1, nLastCol))
2360 + aCols.push_back(nThisCol);
2362 + SCSIZE nColCount = aCols.size();
2364 SCSIZE nTotalRows = ( nRow1 <= nRow2 ? nRow2 - nRow1 + 1 : 0 );
2365 - SCROW* pRows = new SCROW[nTotalRows > 0 ? nTotalRows : 1];
2366 - SCSIZE nRowCount = (nTotalRows ?
2367 - pDocument->GetRowFlagsArray( nTab1).FillArrayForCondition( nRow1,
2368 - nRow2, CR_HIDDEN, 0, pRows, nTotalRows) : 0);
2369 + vector<SCROW> aRows;
2370 + aRows.reserve(nTotalRows);
2371 + if (nRow1 <= nRow2)
2373 + // Get all visible rows between nRow1 and nRow2.
2374 + SCROW nThisRow = nRow1;
2375 + while (nThisRow <= nRow2)
2377 + if (pDocument->RowHidden(nThisRow, nTab1, nLastRow))
2378 + nThisRow = nLastRow;
2379 + else
2380 + aRows.push_back(nThisRow);
2381 + ++nThisRow;
2384 + SCSIZE nRowCount = aRows.size();
2386 // May happen at least with more than 32k rows.
2387 if (nColCount > SHRT_MAX || nRowCount > SHRT_MAX)
2388 @@ -208,13 +233,13 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2390 bValidData = FALSE;
2391 nColCount = 1;
2392 - pCols[0] = nStrCol;
2393 + aCols.push_back(nStrCol);
2395 if ( !nRowCount )
2397 bValidData = FALSE;
2398 nRowCount = 1;
2399 - pRows[0] = nStrRow;
2400 + aRows.push_back(nStrRow);
2404 @@ -237,7 +262,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2406 double nVal = DBL_MIN; // Hack fuer Chart, um leere Zellen zu erkennen
2408 - pDocument->GetCell( pCols[nCol], pRows[nRow], nTab1, pCell );
2409 + pDocument->GetCell( aCols[nCol], aRows[nRow], nTab1, pCell );
2410 if (pCell)
2412 CellType eType = pCell->GetCellType();
2413 @@ -247,8 +272,8 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2414 if ( bCalcAsShown && nVal != 0.0 )
2416 sal_uInt32 nFormat;
2417 - pDocument->GetNumberFormat( pCols[nCol],
2418 - pRows[nRow], nTab1, nFormat );
2419 + pDocument->GetNumberFormat( aCols[nCol],
2420 + aRows[nRow], nTab1, nFormat );
2421 nVal = pDocument->RoundValueAsShown( nVal, nFormat );
2424 @@ -280,13 +305,13 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2426 String aString, aColStr;
2427 if (HasColHeaders())
2428 - pDocument->GetString( pCols[nCol], nStrRow, nTab1, aString );
2429 + pDocument->GetString( aCols[nCol], nStrRow, nTab1, aString );
2430 if ( !aString.Len() )
2432 aString = ScGlobal::GetRscString(STR_COLUMN);
2433 aString += ' ';
2434 // aString += String::CreateFromInt32( pCols[nCol]+1 );
2435 - ScAddress aPos( pCols[ nCol ], 0, 0 );
2436 + ScAddress aPos( aCols[ nCol ], 0, 0 );
2437 aPos.Format( aColStr, SCA_VALID_COL, NULL );
2438 aString += aColStr;
2440 @@ -306,14 +331,14 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2441 String aString;
2442 if (HasRowHeaders())
2444 - ScAddress aAddr( nStrCol, pRows[nRow], nTab1 );
2445 - pDocument->GetString( nStrCol, pRows[nRow], nTab1, aString );
2446 + ScAddress aAddr( nStrCol, aRows[nRow], nTab1 );
2447 + pDocument->GetString( nStrCol, aRows[nRow], nTab1, aString );
2449 if ( !aString.Len() )
2451 aString = ScGlobal::GetRscString(STR_ROW);
2452 aString += ' ';
2453 - aString += String::CreateFromInt32( pRows[nRow]+1 );
2454 + aString += String::CreateFromInt32( aRows[nRow]+1 );
2456 pMemChart->SetRowText( static_cast<short>(nRow), aString);
2458 @@ -349,11 +374,6 @@ ScMemChart* ScChartArray::CreateMemChartSingle()
2459 // SetExtraStrings( *pMemChart );
2462 - // Aufraeumen
2464 - delete[] pRows;
2465 - delete[] pCols;
2467 return pMemChart;
2470 diff --git sc/source/filter/excel/colrowst.cxx sc/source/filter/excel/colrowst.cxx
2471 index 174ab20..45d3c9e 100644
2472 --- sc/source/filter/excel/colrowst.cxx
2473 +++ sc/source/filter/excel/colrowst.cxx
2474 @@ -309,7 +309,7 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab )
2475 rDoc.ShowRow( nScRow, nScTab, FALSE );
2476 // #i38093# rows hidden by filter need extra flag
2477 if( (nFirstFilterScRow <= nScRow) && (nScRow <= nLastFilterScRow) )
2478 - rDoc.SetRowFlags( nScRow, nScTab, rDoc.GetRowFlags( nScRow, nScTab ) | CR_FILTERED );
2479 + rDoc.SetRowFiltered(nScRow, nScRow, nScTab, true);
2483 diff --git sc/source/filter/excel/xetable.cxx sc/source/filter/excel/xetable.cxx
2484 index 2aef64c..2816daf 100644
2485 --- sc/source/filter/excel/xetable.cxx
2486 +++ sc/source/filter/excel/xetable.cxx
2487 @@ -1604,8 +1604,7 @@ XclExpColinfo::XclExpColinfo( const XclExpRoot& rRoot,
2488 mnWidth = XclTools::GetXclColumnWidth( nScWidth, GetCharWidth() );
2490 // column flags
2491 - BYTE nScColFlags = rDoc.GetColFlags( nScCol, nScTab );
2492 - ::set_flag( mnFlags, EXC_COLINFO_HIDDEN, (nScColFlags & CR_HIDDEN) != 0 );
2493 + ::set_flag( mnFlags, EXC_COLINFO_HIDDEN, rDoc.ColHidden(nScCol, nScTab) );
2495 // outline data
2496 rOutlineBfr.Update( nScCol );
2497 @@ -1830,7 +1829,7 @@ XclExpRow::XclExpRow( const XclExpRoot& rRoot, sal_uInt16 nXclRow,
2499 BYTE nRowFlags = GetDoc().GetRowFlags( nScRow, nScTab );
2500 bool bUserHeight = ::get_flag< BYTE >( nRowFlags, CR_MANUALSIZE );
2501 - bool bHidden = ::get_flag< BYTE >( nRowFlags, CR_HIDDEN );
2502 + bool bHidden = GetDoc().RowHidden(nScRow, nScTab);
2503 ::set_flag( mnFlags, EXC_ROW_UNSYNCED, bUserHeight );
2504 ::set_flag( mnFlags, EXC_ROW_HIDDEN, bHidden );
2506 diff --git sc/source/filter/excel/xlescher.cxx sc/source/filter/excel/xlescher.cxx
2507 index bea2ed1..98312a2 100644
2508 --- sc/source/filter/excel/xlescher.cxx
2509 +++ sc/source/filter/excel/xlescher.cxx
2510 @@ -136,21 +136,20 @@ void lclGetRowFromY(
2511 // rnStartH in conjunction with nXclStartRow is used as buffer for previously calculated height
2512 long nTwipsY = static_cast< long >( nY / fScale + 0.5 );
2513 long nRowH = 0;
2514 - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
2515 - rDoc.GetRowFlagsArray( nScTab), static_cast<SCROW>(nXclStartRow),
2516 - MAXROW, CR_HIDDEN, 0, rDoc.GetRowHeightArray( nScTab));
2517 - for ( ; aIter; ++aIter )
2518 + bool bFound = false;
2519 + for (SCROW nRow = static_cast<SCROW>(nXclStartRow); nRow <= MAXROW; ++nRow)
2521 - nRowH = *aIter;
2522 + nRowH = rDoc.GetRowHeight(nRow, nScTab);
2523 if( rnStartH + nRowH > nTwipsY )
2525 - rnXclRow = static_cast< sal_uInt16 >( aIter.GetPos() );
2526 + rnXclRow = static_cast< sal_uInt16 >(nRow);
2527 + bFound = true;
2528 break;
2530 rnStartH += nRowH;
2532 - if (!aIter)
2533 - rnXclRow = static_cast< sal_uInt16 >( aIter.GetIterEnd() ); // down to the bottom..
2534 + if (!bFound)
2535 + rnXclRow = static_cast<sal_uInt16>(MAXROW);
2536 rnOffset = static_cast< sal_uInt16 >( nRowH ? ((nTwipsY - rnStartH) * 256.0 / nRowH + 0.5) : 0 );
2539 diff --git sc/source/filter/html/htmlexp.cxx sc/source/filter/html/htmlexp.cxx
2540 index ecb2b2a..9698b9d 100644
2541 --- sc/source/filter/html/htmlexp.cxx
2542 +++ sc/source/filter/html/htmlexp.cxx
2543 @@ -749,7 +749,7 @@ void ScHTMLExport::WriteTables()
2544 SCCOL nCol;
2545 for ( nCol=nStartCol; nCol<=nEndCol; nCol++ )
2547 - if ( !(pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) )
2548 + if ( !pDoc->ColHidden(nCol, nTab) )
2549 ++nColCnt;
2551 (((aByteStrOut += ' ') += OOO_STRING_SVTOOLS_HTML_O_cols) += '=') += ByteString::CreateFromInt32( nColCnt );
2552 @@ -770,7 +770,7 @@ void ScHTMLExport::WriteTables()
2553 aByteStr += '=';
2554 for ( nCol=nStartCol; nCol<=nEndCol; nCol++ )
2556 - if ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN )
2557 + if ( pDoc->ColHidden(nCol, nTab) )
2558 continue; // for
2560 aByteStrOut = aByteStr;
2561 @@ -785,14 +785,12 @@ void ScHTMLExport::WriteTables()
2562 // At least old (3.x, 4.x?) Netscape doesn't follow <TABLE COLS=n> and
2563 // <COL WIDTH=x> specified, but needs a width at every column.
2564 bTableDataWidth = TRUE; // widths in first row
2565 - bool bHasHiddenRows = pDoc->GetRowFlagsArray( nTab).HasCondition(
2566 - nStartRow, nEndRow, CR_HIDDEN, CR_HIDDEN);
2567 + bool bHasHiddenRows = pDoc->HasHiddenRows(nStartRow, nEndRow, nTab);
2568 for ( SCROW nRow=nStartRow; nRow<=nEndRow; nRow++ )
2570 - if ( bHasHiddenRows && (pDoc->GetRowFlags( nRow, nTab ) & CR_HIDDEN) )
2571 + if ( bHasHiddenRows && pDoc->RowHidden(nRow, nTab) )
2573 - nRow = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition(
2574 - nRow+1, nEndRow, CR_HIDDEN, 0);
2575 + nRow = pDoc->FirstVisibleRow(nRow+1, nEndRow, nTab);
2576 --nRow;
2577 continue; // for
2579 @@ -801,7 +799,7 @@ void ScHTMLExport::WriteTables()
2580 bTableDataHeight = TRUE; // height at every first cell of each row
2581 for ( SCCOL nCol2=nStartCol; nCol2<=nEndCol; nCol2++ )
2583 - if ( pDoc->GetColFlags( nCol2, nTab ) & CR_HIDDEN )
2584 + if ( pDoc->ColHidden(nCol2, nTab) )
2585 continue; // for
2587 if ( nCol2 == nEndCol )
2588 diff --git sc/source/filter/lotus/lotimpop.cxx sc/source/filter/lotus/lotimpop.cxx
2589 index 17a48cb..8d887b0 100644
2590 --- sc/source/filter/lotus/lotimpop.cxx
2591 +++ sc/source/filter/lotus/lotimpop.cxx
2592 @@ -183,8 +183,7 @@ void ImportLotus::Hiddencolumn( UINT16 nRecLen )
2594 Read( nCol );
2596 - pD->SetColFlags( static_cast<SCCOL> (nCol), static_cast<SCTAB> (nLTab), pD->GetColFlags( static_cast<SCCOL> (nCol), static_cast<SCTAB> (nLTab) ) | CR_HIDDEN );
2598 + pD->SetColHidden(static_cast<SCCOL>(nCol), static_cast<SCCOL>(nCol), static_cast<SCTAB>(nLTab), true);
2599 nCnt--;
2602 diff --git sc/source/filter/lotus/op.cxx sc/source/filter/lotus/op.cxx
2603 index 028993b..eb7d043 100644
2604 --- sc/source/filter/lotus/op.cxx
2605 +++ sc/source/filter/lotus/op.cxx
2606 @@ -229,7 +229,7 @@ void OP_ColumnWidth( SvStream& r, UINT16 /*n*/ )
2607 nBreite = ( UINT16 ) ( TWIPS_PER_CHAR * nWidthSpaces );
2608 else
2610 - pDoc->SetColFlags( static_cast<SCCOL> (nCol), 0, pDoc->GetColFlags( static_cast<SCCOL> (nCol), 0 ) | CR_HIDDEN );
2611 + pDoc->SetColHidden(static_cast<SCCOL>(nCol), static_cast<SCCOL>(nCol), 0, true);
2612 nBreite = nDefWidth;
2615 @@ -338,7 +338,7 @@ void OP_HiddenCols( SvStream& r, UINT16 /*n*/ )
2617 if( nAkt & 0x01 ) // unterstes Bit gesetzt?
2618 // -> Hidden Col
2619 - pDoc->SetColFlags( nCount, 0, pDoc->GetColFlags( nCount, 0 ) | CR_HIDDEN );
2620 + pDoc->SetColHidden(nCount, nCount, 0, true);
2622 nCount++;
2623 nAkt = nAkt / 2; // der Naechste bitte...
2624 diff --git sc/source/filter/rtf/expbase.cxx sc/source/filter/rtf/expbase.cxx
2625 index 2c2cf22..98aef5e 100644
2626 --- sc/source/filter/rtf/expbase.cxx
2627 +++ sc/source/filter/rtf/expbase.cxx
2628 @@ -78,16 +78,13 @@ BOOL ScExportBase::GetDataArea( SCTAB nTab, SCCOL& nStartCol,
2629 BOOL ScExportBase::TrimDataArea( SCTAB nTab, SCCOL& nStartCol,
2630 SCROW& nStartRow, SCCOL& nEndCol, SCROW& nEndRow ) const
2632 - while ( nStartCol <= nEndCol &&
2633 - pDoc->GetColFlags( nStartCol, nTab ) & CR_HIDDEN )
2634 + SCCOL nLastCol;
2635 + while ( nStartCol <= nEndCol && pDoc->ColHidden(nStartCol, nTab, nLastCol))
2636 ++nStartCol;
2637 - while ( nStartCol <= nEndCol &&
2638 - pDoc->GetColFlags( nEndCol, nTab ) & CR_HIDDEN )
2639 + while ( nStartCol <= nEndCol && pDoc->ColHidden(nEndCol, nTab, nLastCol))
2640 --nEndCol;
2641 - nStartRow = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition( nStartRow,
2642 - nEndRow, CR_HIDDEN, 0);
2643 - nEndRow = pDoc->GetRowFlagsArray( nTab).GetLastForCondition( nStartRow,
2644 - nEndRow, CR_HIDDEN, 0);
2645 + nStartRow = pDoc->FirstVisibleRow(nStartRow, nEndRow, nTab);
2646 + nEndRow = pDoc->LastVisibleRow(nStartRow, nEndRow, nTab);
2647 return nStartCol <= nEndCol && nStartRow <= nEndRow && nEndRow !=
2648 ::std::numeric_limits<SCROW>::max();
2650 diff --git sc/source/filter/starcalc/scflt.cxx sc/source/filter/starcalc/scflt.cxx
2651 index 8c98903..a456235 100644
2652 --- sc/source/filter/starcalc/scflt.cxx
2653 +++ sc/source/filter/starcalc/scflt.cxx
2654 @@ -1551,14 +1551,12 @@ void Sc10Import::LoadTables()
2655 rStream >> DataValue;
2656 if (DataValue != 0)
2658 - BYTE nFlags = 0;
2659 bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
2660 bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
2661 - if ((DataValue & crfHidden) == crfHidden)
2662 - nFlags |= CR_HIDDEN;
2663 + bool bHidden = ((DataValue & crfHidden) == crfHidden);
2664 for (SCCOL k = static_cast<SCCOL>(DataStart); k <= static_cast<SCCOL>(DataEnd); k++)
2665 - {
2666 - pDoc->SetColFlags(k, static_cast<SCTAB> (TabNo), nFlags);
2668 + pDoc->SetColHidden(k, k, static_cast<SCTAB>(TabNo), bHidden);
2669 pDoc->SetColBreak(k, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
2672 @@ -1603,14 +1601,12 @@ void Sc10Import::LoadTables()
2673 rStream >> DataValue;
2674 if (DataValue != 0)
2676 - BYTE nFlags = 0;
2677 bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
2678 bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
2679 - if ((DataValue & crfHidden) == crfHidden)
2680 - nFlags |= CR_HIDDEN;
2681 + bool bHidden = ((DataValue & crfHidden) == crfHidden);
2682 for (SCROW l = static_cast<SCROW>(DataStart); l <= static_cast<SCROW>(DataEnd); l++)
2684 - pDoc->SetRowFlags(l, static_cast<SCTAB> (TabNo), nFlags);
2685 + pDoc->SetRowHidden(l, l, static_cast<SCTAB> (TabNo), bHidden);
2686 pDoc->SetRowBreak(l, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
2689 diff --git sc/source/ui/Accessibility/AccessibleCellBase.cxx sc/source/ui/Accessibility/AccessibleCellBase.cxx
2690 index d112ea0..046b4ce 100644
2691 --- sc/source/ui/Accessibility/AccessibleCellBase.cxx
2692 +++ sc/source/ui/Accessibility/AccessibleCellBase.cxx
2693 @@ -95,10 +95,12 @@ sal_Bool SAL_CALL ScAccessibleCellBase::isVisible( )
2694 sal_Bool bVisible(sal_True);
2695 if (mpDoc)
2697 - BYTE nColFlags = mpDoc->GetColFlags(maCellAddress.Col(), maCellAddress.Tab());
2698 - BYTE nRowFlags = mpDoc->GetRowFlags(maCellAddress.Row(), maCellAddress.Tab());
2699 - if (((nColFlags & CR_HIDDEN) == CR_HIDDEN) || ((nColFlags & CR_FILTERED) == CR_FILTERED) ||
2700 - ((nRowFlags & CR_HIDDEN) == CR_HIDDEN) || ((nRowFlags & CR_FILTERED) == CR_FILTERED))
2701 + bool bColHidden = mpDoc->ColHidden(maCellAddress.Col(), maCellAddress.Tab());
2702 + bool bRowHidden = mpDoc->RowHidden(maCellAddress.Row(), maCellAddress.Tab());
2703 + bool bColFiltered = mpDoc->ColFiltered(maCellAddress.Col(), maCellAddress.Tab());
2704 + bool bRowFiltered = mpDoc->RowFiltered(maCellAddress.Row(), maCellAddress.Tab());
2706 + if (bColHidden || bColFiltered || bRowHidden || bRowFiltered)
2707 bVisible = sal_False;
2709 return bVisible;
2710 diff --git sc/source/ui/app/inputwin.cxx sc/source/ui/app/inputwin.cxx
2711 index 80625f0..754e110 100644
2712 --- sc/source/ui/app/inputwin.cxx
2713 +++ sc/source/ui/app/inputwin.cxx
2714 @@ -294,7 +294,7 @@ sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const
2715 SCROW nRow(pRange->aStart.Row());
2716 while (!bSubTotal && nRow <= nRowEnd)
2718 - if (pDoc->IsFiltered(nRow, nTab))
2719 + if (pDoc->RowFiltered(nRow, nTab))
2720 bSubTotal = sal_True;
2721 else
2722 ++nRow;
2723 diff --git sc/source/ui/app/transobj.cxx sc/source/ui/app/transobj.cxx
2724 index b35d177..87f888c 100644
2725 --- sc/source/ui/app/transobj.cxx
2726 +++ sc/source/ui/app/transobj.cxx
2727 @@ -605,25 +605,24 @@ void ScTransferObj::InitDocShell()
2728 // widths / heights
2729 // (must be copied before CopyFromClip, for drawing objects)
2731 - SCCOL nCol;
2732 + SCCOL nCol, nLastCol;
2733 SCROW nRow;
2734 SCTAB nSrcTab = aBlock.aStart.Tab();
2735 pDestDoc->SetLayoutRTL(0, pDoc->IsLayoutRTL(nSrcTab));
2736 for (nCol=nStartX; nCol<=nEndX; nCol++)
2737 - if ( pDoc->GetColFlags( nCol, nSrcTab ) & CR_HIDDEN )
2738 + if ( pDoc->ColHidden(nCol, nSrcTab, nLastCol) )
2739 pDestDoc->ShowCol( nCol, 0, FALSE );
2740 else
2741 pDestDoc->SetColWidth( nCol, 0, pDoc->GetColWidth( nCol, nSrcTab ) );
2743 ScBitMaskCompressedArray< SCROW, BYTE> & rDestRowFlags =
2744 pDestDoc->GetRowFlagsArrayModifiable(0);
2745 - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray(
2746 - nSrcTab), nStartY, nEndY);
2747 - for ( ; aIter; ++aIter )
2749 + for (SCROW nRow = nStartY; nRow <= nEndY; ++nRow)
2751 - nRow = aIter.GetPos();
2752 - BYTE nSourceFlags = *aIter;
2753 - if ( nSourceFlags & CR_HIDDEN )
2754 + BYTE nSourceFlags = pDoc->GetRowFlags(nRow, nSrcTab);
2755 + SCROW nLastRow = -1;
2756 + if ( pDoc->RowHidden(nRow, nSrcTab, nLastRow) )
2757 pDestDoc->ShowRow( nRow, 0, FALSE );
2758 else
2760 diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
2761 index bb7cdef..6dbec45 100644
2762 --- sc/source/ui/docshell/docfunc.cxx
2763 +++ sc/source/ui/docshell/docfunc.cxx
2764 @@ -2980,7 +2980,9 @@ BOOL ScDocFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa
2765 for (SCROW nRow=nStartNo; nRow<=nEndNo; nRow++)
2767 BYTE nOld = pDoc->GetRowFlags(nRow,nTab);
2768 - if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) )
2769 + SCROW nLastRow = -1;
2770 + bool bHidden = pDoc->RowHidden(nRow, nTab, nLastRow);
2771 + if ( !bHidden && ( nOld & CR_MANUALSIZE ) )
2772 pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE );
2775 @@ -3015,8 +3017,8 @@ BOOL ScDocFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pRa
2777 for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
2779 - if ( eMode != SC_SIZE_VISOPT ||
2780 - (pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0 )
2781 + SCCOL nLastCol = -1;
2782 + if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab, nLastCol) )
2784 USHORT nThisSize = nSizeTwips;
2786 diff --git sc/source/ui/docshell/impex.cxx sc/source/ui/docshell/impex.cxx
2787 index 08dfcfb..6df6637 100644
2788 --- sc/source/ui/docshell/impex.cxx
2789 +++ sc/source/ui/docshell/impex.cxx
2790 @@ -1444,7 +1444,7 @@ BOOL ScImportExport::Doc2Text( SvStream& rStrm )
2792 for (nRow = nStartRow; nRow <= nEndRow; nRow++)
2794 - if (bIncludeFiltered || !pDoc->IsFiltered( nRow, aRange.aStart.Tab() ))
2795 + if (bIncludeFiltered || !pDoc->RowFiltered( nRow, aRange.aStart.Tab() ))
2797 for (nCol = nStartCol; nCol <= nEndCol; nCol++)
2799 diff --git sc/source/ui/docshell/olinefun.cxx sc/source/ui/docshell/olinefun.cxx
2800 index 01b4f9a..fd120a8 100644
2801 --- sc/source/ui/docshell/olinefun.cxx
2802 +++ sc/source/ui/docshell/olinefun.cxx
2803 @@ -411,7 +411,7 @@ BOOL ScOutlineDocFunc::SelectLevel( SCTAB nTab, BOOL bColumns, USHORT nLevel,
2804 if ( bColumns )
2805 pDoc->ShowCol( static_cast<SCCOL>(i), nTab, bShow );
2806 else
2807 - if ( !bShow || !pDoc->IsFiltered( i,nTab ) )
2808 + if ( !bShow || !pDoc->RowFiltered( i,nTab ) )
2809 pDoc->ShowRow( i, nTab, bShow );
2812 @@ -509,7 +509,7 @@ BOOL ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, BOOL bRecord,
2815 for ( i=nMin; i<=nMax; i++ )
2816 - if ( !pDoc->IsFiltered( i,nTab ) ) // weggefilterte nicht einblenden
2817 + if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden
2818 pDoc->ShowRow( i, nTab, TRUE );
2820 pDoc->UpdatePageBreaks( nTab );
2821 @@ -669,7 +669,7 @@ BOOL ScOutlineDocFunc::ShowOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, US
2822 if ( bColumns )
2823 pDoc->ShowCol( static_cast<SCCOL>(i), nTab, TRUE );
2824 else
2825 - if ( !pDoc->IsFiltered( i,nTab ) ) // weggefilterte nicht einblenden
2826 + if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden
2827 pDoc->ShowRow( i, nTab, TRUE );
2830 diff --git sc/source/ui/inc/viewutil.hxx sc/source/ui/inc/viewutil.hxx
2831 index 55f0039..18b4d68 100644
2832 --- sc/source/ui/inc/viewutil.hxx
2833 +++ sc/source/ui/inc/viewutil.hxx
2834 @@ -71,10 +71,10 @@ public:
2836 static sal_Int32 GetTransliterationType( USHORT nSlotID );
2838 - static bool HasFiltered( const ScRange& rRange, const ScDocument* pDoc );
2839 + static bool HasFiltered( const ScRange& rRange, ScDocument* pDoc );
2840 /** Fit a range to cover nRows number of unfiltered rows.
2841 @return <TRUE/> if the resulting range covers nRows unfiltered rows. */
2842 - static bool FitToUnfilteredRows( ScRange & rRange, const ScDocument * pDoc, size_t nRows );
2843 + static bool FitToUnfilteredRows( ScRange & rRange, ScDocument * pDoc, size_t nRows );
2844 static void UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc );
2846 static void HideDisabledSlot( SfxItemSet& rSet, SfxBindings& rBindings, USHORT nSlotId );
2847 diff --git sc/source/ui/undo/undoblk.cxx sc/source/ui/undo/undoblk.cxx
2848 index f92adea..002aa14 100644
2849 --- sc/source/ui/undo/undoblk.cxx
2850 +++ sc/source/ui/undo/undoblk.cxx
2851 @@ -1152,10 +1152,10 @@ ScUndoDragDrop::ScUndoDragDrop( ScDocShell* pNewDocShell,
2852 BOOL bIncludeFiltered = bCut;
2853 if ( !bIncludeFiltered )
2855 - // manually find number of non-filtered rows
2856 - SCROW nPastedCount = pDocShell->GetDocument()->GetRowFlagsArray(
2857 - aSrcRange.aStart.Tab()).CountForCondition(
2858 - aSrcRange.aStart.Row(), aSrcRange.aEnd.Row(), CR_FILTERED, 0);
2859 + // find number of non-filtered rows
2860 + SCROW nPastedCount = pDocShell->GetDocument()->CountNonFilteredRows(
2861 + aSrcRange.aStart.Row(), aSrcRange.aEnd.Row(), aSrcRange.aStart.Tab());
2863 if ( nPastedCount == 0 )
2864 nPastedCount = 1;
2865 aDestEnd.SetRow( aNewDestPos.Row() + nPastedCount - 1 );
2866 diff --git sc/source/ui/undo/undoblk3.cxx sc/source/ui/undo/undoblk3.cxx
2867 index c6dba05..cb6f62c 100644
2868 --- sc/source/ui/undo/undoblk3.cxx
2869 +++ sc/source/ui/undo/undoblk3.cxx
2870 @@ -1082,17 +1082,20 @@ void __EXPORT ScUndoAutoFormat::Redo()
2871 aDestMark.MarkToMulti();
2873 // wie SC_SIZE_VISOPT
2874 + SCROW nLastRow = -1;
2875 for (SCROW nRow=nStartY; nRow<=nEndY; nRow++)
2877 BYTE nOld = pDoc->GetRowFlags(nRow,nTab);
2878 - if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) )
2879 + bool bHidden = pDoc->RowHidden(nRow, nTab, nLastRow);
2880 + if ( !bHidden && ( nOld & CR_MANUALSIZE ) )
2881 pDoc->SetRowFlags( nRow, nTab, nOld & ~CR_MANUALSIZE );
2883 pDoc->SetOptimalHeight( nStartY, nEndY, nTab, 0, &aVirtDev,
2884 nPPTX, nPPTY, aZoomX, aZoomY, FALSE );
2886 + SCCOL nLastCol = -1;
2887 for (SCCOL nCol=nStartX; nCol<=nEndX; nCol++)
2888 - if ((pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0)
2889 + if (!pDoc->ColHidden(nCol, nTab, nLastCol))
2891 USHORT nThisSize = STD_EXTRA_WIDTH + pDoc->GetOptimalColWidth( nCol, nTab,
2892 &aVirtDev, nPPTX, nPPTY, aZoomX, aZoomY, bFormula,
2893 diff --git sc/source/ui/unoobj/cellsuno.cxx sc/source/ui/unoobj/cellsuno.cxx
2894 index 520a788..37eb67c 100644
2895 --- sc/source/ui/unoobj/cellsuno.cxx
2896 +++ sc/source/ui/unoobj/cellsuno.cxx
2897 @@ -3379,18 +3379,25 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryVisibleC
2898 ScMarkData aMarkData(*GetMarkData());
2900 ScDocument* pDoc = pDocShell->GetDocument();
2901 - for (SCCOL nCol=0; nCol<=MAXCOL; nCol++)
2902 - if (pDoc->GetColFlags(nCol,nTab) & CR_HIDDEN)
2903 - aMarkData.SetMultiMarkArea( ScRange( nCol,0,nTab, nCol,MAXROW,nTab ), FALSE );
2905 - //! nur bis zur letzten selektierten Zeile testen?
2906 - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray( nTab), 0, MAXROW);
2907 - do
2909 - if (*aIter & CR_HIDDEN)
2910 - aMarkData.SetMultiMarkArea( ScRange( 0, aIter.GetRangeStart(),
2911 - nTab, MAXCOL, aIter.GetRangeEnd(), nTab ), FALSE );
2912 - } while (aIter.NextRange());
2913 + SCCOL nCol = 0, nLastCol;
2914 + while (nCol <= MAXCOL)
2916 + if (pDoc->ColHidden(nCol, nTab, nLastCol))
2917 + // hidden columns. Unselect them.
2918 + aMarkData.SetMultiMarkArea(ScRange(nCol, 0, nTab, nLastCol, MAXROW, nTab), false);
2920 + nCol = nLastCol + 1;
2923 + SCROW nRow = 0, nLastRow;
2924 + while (nRow <= MAXROW)
2926 + if (pDoc->RowHidden(nRow, nTab, nLastRow))
2927 + // These rows are hidden. Unselect them.
2928 + aMarkData.SetMultiMarkArea(ScRange(0, nRow, nTab, MAXCOL, nLastRow, nTab), false);
2930 + nRow = nLastRow + 1;
2933 ScRangeList aNewRanges;
2934 aMarkData.FillRangeListWithMarks( &aNewRanges, FALSE );
2935 @@ -8882,8 +8889,9 @@ void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
2937 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
2939 - BOOL bVis = !(pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN);
2940 - ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
2941 + SCCOL nDummy;
2942 + bool bHidden = pDoc->ColHidden(nCol, nTab, nDummy);
2943 + ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
2945 else if ( pEntry->nWID == SC_WID_UNO_OWIDTH )
2947 @@ -8985,12 +8993,7 @@ void ScTableRowObj::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr
2948 // ScSizeMode eMode = bVis ? SC_SIZE_SHOW : SC_SIZE_DIRECT;
2949 // aFunc.SetWidthOrHeight( FALSE, 1, nRowArr, nTab, eMode, 0, TRUE, TRUE );
2950 // SC_SIZE_DIRECT mit Groesse 0 blendet aus
2951 - BYTE nFlags = pDoc->GetRowFlags(nRow, nTab);
2952 - if (bFil)
2953 - nFlags |= CR_FILTERED;
2954 - else
2955 - nFlags &= ~CR_FILTERED;
2956 - pDoc->SetRowFlags(nRow, nTab, nFlags);
2957 + pDoc->SetRowFiltered(nRow, nRow, nTab, bFil);
2959 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
2961 @@ -9042,12 +9045,13 @@ void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pEntr
2963 else if ( pEntry->nWID == SC_WID_UNO_CELLVIS )
2965 - BOOL bVis = !(pDoc->GetRowFlags( nRow, nTab ) & CR_HIDDEN);
2966 - ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
2967 + SCROW nDummy;
2968 + bool bHidden = pDoc->RowHidden(nRow, nTab, nDummy);
2969 + ScUnoHelpFunctions::SetBoolInAny( rAny, !bHidden );
2971 else if ( pEntry->nWID == SC_WID_UNO_CELLFILT )
2973 - BOOL bVis = ((pDoc->GetRowFlags( nRow, nTab ) & CR_FILTERED) != 0);
2974 + bool bVis = pDoc->RowFiltered(nRow, nTab);
2975 ScUnoHelpFunctions::SetBoolInAny( rAny, bVis );
2977 else if ( pEntry->nWID == SC_WID_UNO_OHEIGHT )
2978 diff --git sc/source/ui/unoobj/chart2uno.cxx sc/source/ui/unoobj/chart2uno.cxx
2979 index 7c1cfc6..174d213 100644
2980 --- sc/source/ui/unoobj/chart2uno.cxx
2981 +++ sc/source/ui/unoobj/chart2uno.cxx
2982 @@ -2840,14 +2840,17 @@ void ScChart2DataSequence::BuildDataCache()
2983 if (!ScRefTokenHelper::getRangeFromToken(aRange, *itr))
2984 continue;
2986 + SCCOL nLastCol = -1;
2987 + SCROW nLastRow = -1;
2988 for (SCTAB nTab = aRange.aStart.Tab(); nTab <= aRange.aEnd.Tab(); ++nTab)
2990 for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
2992 for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
2994 - bool bColHidden = (m_pDocument->GetColFlags(nCol, nTab) & CR_HIDDEN);
2995 - bool bRowHidden = (m_pDocument->GetRowFlags(nRow, nTab) & CR_HIDDEN);
2996 + bool bColHidden = m_pDocument->ColHidden(nCol, nTab, nLastCol);
2997 + bool bRowHidden = m_pDocument->RowHidden(nRow, nTab, nLastRow);
2999 if (bColHidden || bRowHidden)
3001 // hidden cell
3002 diff --git sc/source/ui/unoobj/docuno.cxx sc/source/ui/unoobj/docuno.cxx
3003 index 5c4113b..5b4a50b 100644
3004 --- sc/source/ui/unoobj/docuno.cxx
3005 +++ sc/source/ui/unoobj/docuno.cxx
3006 @@ -2613,7 +2613,8 @@ uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const rtl::OUString& aPro
3008 else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
3010 - BOOL bVis = !(pDoc->GetColFlags( nStartCol, nTab ) & CR_HIDDEN);
3011 + SCCOL nLastCol;
3012 + bool bVis = !pDoc->ColHidden(nStartCol, nTab, nLastCol);
3013 ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
3015 else if ( aNameString.EqualsAscii( SC_UNONAME_OWIDTH ) )
3016 @@ -2821,9 +2822,9 @@ void SAL_CALL ScTableRowsObj::setPropertyValue(
3018 //! undo etc.
3019 if (ScUnoHelpFunctions::GetBoolFromAny( aValue ))
3020 - pDoc->GetRowFlagsArrayModifiable( nTab).OrValue( nStartRow, nEndRow, CR_FILTERED);
3021 + pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, true);
3022 else
3023 - pDoc->GetRowFlagsArrayModifiable( nTab).AndValue( nStartRow, nEndRow, sal::static_int_cast<BYTE>(~CR_FILTERED) );
3024 + pDoc->SetRowFiltered(nStartRow, nEndRow, nTab, false);
3026 else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE) || aNameString.EqualsAscii( SC_UNONAME_MANPAGE) )
3028 @@ -2871,12 +2872,13 @@ uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const rtl::OUString& aProper
3030 else if ( aNameString.EqualsAscii( SC_UNONAME_CELLVIS ) )
3032 - BOOL bVis = !(pDoc->GetRowFlags( nStartRow, nTab ) & CR_HIDDEN);
3033 + SCROW nLastRow;
3034 + bool bVis = !pDoc->RowHidden(nStartRow, nTab, nLastRow);
3035 ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
3037 else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) )
3039 - BOOL bVis = ((pDoc->GetRowFlags( nStartRow, nTab ) & CR_FILTERED) != 0);
3040 + bool bVis = pDoc->RowFiltered(nStartRow, nTab);
3041 ScUnoHelpFunctions::SetBoolInAny( aAny, bVis );
3043 else if ( aNameString.EqualsAscii( SC_UNONAME_OHEIGHT ) )
3044 diff --git sc/source/ui/view/colrowba.cxx sc/source/ui/view/colrowba.cxx
3045 index ecd0a37..e7613c1 100644
3046 --- sc/source/ui/view/colrowba.cxx
3047 +++ sc/source/ui/view/colrowba.cxx
3048 @@ -101,7 +101,8 @@ USHORT ScColBar::GetEntrySize( SCCOLROW nEntryNo )
3050 ScDocument* pDoc = pViewData->GetDocument();
3051 SCTAB nTab = pViewData->GetTabNo();
3052 - if ( pDoc->GetColFlags( static_cast<SCCOL>(nEntryNo), nTab ) & CR_HIDDEN )
3053 + SCCOL nLastCol = -1;
3054 + if (pDoc->ColHidden(static_cast<SCCOL>(nEntryNo), nTab, nLastCol))
3055 return 0;
3056 else
3057 return (USHORT) ScViewData::ToPixel( pDoc->GetColWidth( static_cast<SCCOL>(nEntryNo), nTab ), pViewData->GetPPTX() );
3058 @@ -267,7 +268,8 @@ USHORT ScRowBar::GetEntrySize( SCCOLROW nEntryNo )
3060 ScDocument* pDoc = pViewData->GetDocument();
3061 SCTAB nTab = pViewData->GetTabNo();
3062 - if ( pDoc->GetRowFlags( nEntryNo, nTab ) & CR_HIDDEN )
3063 + SCROW nLastRow = -1;
3064 + if (pDoc->RowHidden(nEntryNo, nTab, nLastRow))
3065 return 0;
3066 else
3067 return (USHORT) ScViewData::ToPixel( pDoc->GetOriginalHeight( nEntryNo,
3068 diff --git sc/source/ui/view/drawutil.cxx sc/source/ui/view/drawutil.cxx
3069 index 48b03b5..ddb2f06 100644
3070 --- sc/source/ui/view/drawutil.cxx
3071 +++ sc/source/ui/view/drawutil.cxx
3072 @@ -69,14 +69,19 @@ void ScDrawUtil::CalcScale( ScDocument* pDoc, SCTAB nTab,
3073 nTwipsX += (long) nWidth;
3074 nPixelX += ScViewData::ToPixel( nWidth, nPPTX );
3076 - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
3077 - pDoc->GetRowFlagsArray( nTab), nStartRow, nEndRow-1, CR_HIDDEN, 0,
3078 - pDoc->GetRowHeightArray( nTab));
3079 - for ( ; aIter; ++aIter )
3081 + for (SCROW nRow = nStartRow; nRow <= nEndRow-1; ++nRow)
3083 - USHORT nHeight = *aIter;
3084 - nTwipsY += (long) nHeight;
3085 - nPixelY += ScViewData::ToPixel( nHeight, nPPTY );
3086 + SCROW nLastRow = nRow;
3087 + if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
3088 + {
3089 + nRow = nLastRow;
3090 + continue;
3093 + USHORT nHeight = pDoc->GetRowHeight(nRow, nTab);
3094 + nTwipsY += static_cast<long>(nHeight);
3095 + nPixelY += ScViewData::ToPixel(nHeight, nPPTY);
3098 MapMode aHMMMode( MAP_100TH_MM, Point(), rZoomX, rZoomY );
3099 diff --git sc/source/ui/view/gridwin.cxx sc/source/ui/view/gridwin.cxx
3100 index ac4d80f..e591f86 100644
3101 --- sc/source/ui/view/gridwin.cxx
3102 +++ sc/source/ui/view/gridwin.cxx
3103 @@ -4601,18 +4601,17 @@ void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, USHORT nEdges
3104 SCROW nTmp;
3106 ScDocument* pDoc = pDocSh->GetDocument();
3107 - while ( nCol1 > 0 && ( pDoc->GetColFlags( nCol1, nTab1 ) & CR_HIDDEN ) )
3108 + while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab1) )
3110 --nCol1;
3111 bHiddenEdge = TRUE;
3113 - while ( nCol2 < MAXCOL && ( pDoc->GetColFlags( nCol2, nTab1 ) & CR_HIDDEN ) )
3114 + while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab1) )
3116 ++nCol2;
3117 bHiddenEdge = TRUE;
3119 - nTmp = pDoc->GetRowFlagsArray( nTab1).GetLastForCondition( 0, nRow1,
3120 - CR_HIDDEN, 0);
3121 + nTmp = pDoc->FirstVisibleRow(0, nRow1, nTab1);
3122 if (!ValidRow(nTmp))
3123 nTmp = 0;
3124 if (nTmp < nRow1)
3125 @@ -4620,8 +4619,7 @@ void lcl_PaintOneRange( ScDocShell* pDocSh, const ScRange& rRange, USHORT nEdges
3126 nRow1 = nTmp;
3127 bHiddenEdge = TRUE;
3129 - nTmp = pDoc->GetRowFlagsArray( nTab1).GetFirstForCondition( nRow2, MAXROW,
3130 - CR_HIDDEN, 0);
3131 + nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab1);
3132 if (!ValidRow(nTmp))
3133 nTmp = MAXROW;
3134 if (nTmp > nRow2)
3135 diff --git sc/source/ui/view/gridwin4.cxx sc/source/ui/view/gridwin4.cxx
3136 index 4dfc08f..23edc22 100644
3137 --- sc/source/ui/view/gridwin4.cxx
3138 +++ sc/source/ui/view/gridwin4.cxx
3139 @@ -1378,7 +1378,7 @@ Rectangle ScGridWindow::GetListValButtonRect( const ScAddress& rButtonPos )
3140 const ScMergeAttr* pMerge = static_cast<const ScMergeAttr*>(pDoc->GetAttr( nCol,nRow,nTab, ATTR_MERGE ));
3141 if ( pMerge->GetColMerge() > 1 )
3142 nNextCol = nCol + pMerge->GetColMerge(); // next cell after the merged area
3143 - while ( nNextCol <= MAXCOL && (pDoc->GetColFlags( nNextCol, nTab ) & CR_HIDDEN) )
3144 + while ( nNextCol <= MAXCOL && pDoc->ColHidden(nNextCol, nTab) )
3145 ++nNextCol;
3146 BOOL bNextCell = ( nNextCol <= MAXCOL );
3147 if ( bNextCell )
3148 @@ -1581,7 +1581,7 @@ void ScGridWindow::InvertSimple( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
3149 if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) )
3151 while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 &&
3152 - ( (pDoc->GetRowFlags( nThisY-1, nTab ) & CR_HIDDEN) || bFirstRow ) )
3153 + (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) )
3155 --nThisY;
3156 pPattern = pDoc->GetPattern( nX, nThisY, nTab );
3157 @@ -1768,7 +1768,7 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
3158 if ( pMergeFlag->IsVerOverlapped() && ( bDoHidden || bFirstRow ) )
3160 while ( pMergeFlag->IsVerOverlapped() && nThisY > 0 &&
3161 - ( (pDoc->GetRowFlags( nThisY-1, nTab ) & CR_HIDDEN) || bFirstRow ) )
3162 + (pDoc->RowHidden(nThisY-1, nTab) || bFirstRow) )
3164 --nThisY;
3165 pPattern = pDoc->GetPattern( nX, nThisY, nTab );
3166 diff --git sc/source/ui/view/olinewin.cxx sc/source/ui/view/olinewin.cxx
3167 index fa00785..82d66d1 100644
3168 --- sc/source/ui/view/olinewin.cxx
3169 +++ sc/source/ui/view/olinewin.cxx
3170 @@ -186,16 +186,15 @@ const ScOutlineEntry* ScOutlineWindow::GetOutlineEntry( size_t nLevel, size_t nE
3172 bool ScOutlineWindow::IsHidden( SCCOLROW nColRowIndex ) const
3174 - sal_uInt8 nFlags = mbHoriz ?
3175 - GetDoc().GetColFlags( static_cast<SCCOL>(nColRowIndex), GetTab() ) :
3176 - GetDoc().GetRowFlags( static_cast<SCROW>(nColRowIndex), GetTab() );
3177 - return (nFlags & CR_HIDDEN) != 0;
3178 + return mbHoriz ?
3179 + GetDoc().ColHidden(static_cast<SCCOL>(nColRowIndex), GetTab()) :
3180 + GetDoc().RowHidden(static_cast<SCROW>(nColRowIndex), GetTab());
3183 bool ScOutlineWindow::IsFiltered( SCCOLROW nColRowIndex ) const
3185 // columns cannot be filtered
3186 - return !mbHoriz && GetDoc().IsFiltered( static_cast<SCROW>(nColRowIndex), GetTab() );
3187 + return !mbHoriz && GetDoc().RowFiltered( static_cast<SCROW>(nColRowIndex), GetTab() );
3190 bool ScOutlineWindow::IsFirstVisible( SCCOLROW nColRowIndex ) const
3191 diff --git sc/source/ui/view/output.cxx sc/source/ui/view/output.cxx
3192 index 9a27bb8..989ea07 100644
3193 --- sc/source/ui/view/output.cxx
3194 +++ sc/source/ui/view/output.cxx
3195 @@ -387,8 +387,9 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
3197 BYTE nDocFl = pDoc->GetColFlags( nCol, nTab );
3198 nBreak = pDoc->HasColBreak(nCol, nTab);
3199 + bool bHidden = pDoc->ColHidden(nCol, nTab);
3201 - if ( nBreak || !(nDocFl & CR_HIDDEN) )
3202 + if ( nBreak || !bHidden )
3203 break;
3204 ++nCol;
3206 @@ -507,7 +508,7 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
3207 for (SCROW i = nYplus1; i <= MAXROW; ++i)
3209 nBreak = pDoc->HasRowBreak(i, nTab);
3210 - bool bHidden = (pDoc->GetRowFlags(i, nTab) & CR_HIDDEN);
3211 + bool bHidden = pDoc->RowHidden(i, nTab);
3212 if (nBreak || !bHidden)
3213 break;
3215 @@ -654,7 +655,7 @@ void ScOutputData::FindRotated()
3216 const ScPatternAttr* pPattern = pInfo->pPatternAttr;
3217 const SfxItemSet* pCondSet = pInfo->pConditionSet;
3219 - if ( !pPattern && (pDoc->GetColFlags(nX,nTab) & CR_HIDDEN) == 0 )
3220 + if ( !pPattern && !pDoc->ColHidden(nX, nTab) )
3222 pPattern = pDoc->GetPattern( nX, nY, nTab );
3223 pCondSet = pDoc->GetCondResult( nX, nY, nTab );
3224 diff --git sc/source/ui/view/output2.cxx sc/source/ui/view/output2.cxx
3225 index dec757a..3867c17 100644
3226 --- sc/source/ui/view/output2.cxx
3227 +++ sc/source/ui/view/output2.cxx
3228 @@ -697,7 +697,7 @@ BOOL ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
3229 while (bHOver) // nY konstant
3231 --rOverX;
3232 - bHidden = ( (pDoc->GetColFlags(rOverX,nTab) & CR_HIDDEN) != 0 );
3233 + bHidden = pDoc->ColHidden(rOverX, nTab);
3234 if ( !bDoMerge && !bHidden )
3235 return FALSE;
3237 @@ -721,7 +721,7 @@ BOOL ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
3238 while (bVOver)
3240 --rOverY;
3241 - bHidden = ( (pDoc->GetRowFlags(rOverY,nTab) & CR_HIDDEN) != 0 );
3242 + bHidden = pDoc->RowHidden(rOverY, nTab);
3243 if ( !bDoMerge && !bHidden )
3244 return FALSE;
3246 @@ -729,8 +729,8 @@ BOOL ScOutputData::GetMergeOrigin( SCCOL nX, SCROW nY, SCSIZE nArrY,
3247 --nArrY; // lokale Kopie !
3249 if (rOverX >= nX1 && rOverY >= nY1 &&
3250 - (pDoc->GetColFlags(rOverX,nTab) & CR_HIDDEN) == 0 &&
3251 - (pDoc->GetRowFlags(rOverY,nTab) & CR_HIDDEN) == 0 &&
3252 + !pDoc->ColHidden(rOverX, nTab) &&
3253 + !pDoc->RowHidden(rOverY, nTab) &&
3254 pRowInfo[nArrY].nRowNo == rOverY)
3256 // rVirtPosY -= pRowInfo[nArrY].nHeight;
3257 @@ -2014,7 +2014,7 @@ void ScOutputData::DrawEdit(BOOL bPixelToLogic)
3258 if (bDoCell)
3260 if ( nCellY == nY && nCellX >= nX1 && nCellX <= nX2 &&
3261 - (pDoc->GetColFlags(nCellX,nTab) & CR_HIDDEN) == 0 )
3262 + !pDoc->ColHidden(nCellX, nTab) )
3264 CellInfo& rCellInfo = pThisRowInfo->pCellInfo[nCellX+1];
3265 pPattern = rCellInfo.pPatternAttr;
3266 diff --git sc/source/ui/view/prevloc.cxx sc/source/ui/view/prevloc.cxx
3267 index 54f7376..fb65955 100644
3268 --- sc/source/ui/view/prevloc.cxx
3269 +++ sc/source/ui/view/prevloc.cxx
3270 @@ -602,11 +602,11 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev
3271 ++nColCount;
3272 if ( bHasRepCols )
3273 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
3274 - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 )
3275 + if (!pDoc->ColHidden(nCol, nTab))
3276 ++nColCount;
3277 if ( bHasMainCols )
3278 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
3279 - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 )
3280 + if (!pDoc->ColHidden(nCol, nTab))
3281 ++nColCount;
3283 if ( nColCount > 0 )
3284 @@ -623,7 +623,7 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev
3286 long nPosX = 0;
3287 for ( nCol=nRepeatColStart; nCol<=nRepeatColEnd; nCol++ )
3288 - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 )
3289 + if (!pDoc->ColHidden(nCol, nTab))
3291 USHORT nDocW = pDoc->GetColWidth( nCol, nTab );
3292 long nNextX = nPosX + (long) (nDocW * nScaleX);
3293 @@ -642,7 +642,7 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev
3295 long nPosX = 0;
3296 for ( nCol=nMainColStart; nCol<=nMainColEnd; nCol++ )
3297 - if ( ( pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN ) == 0 )
3298 + if (!pDoc->ColHidden(nCol, nTab))
3300 USHORT nDocW = pDoc->GetColWidth( nCol, nTab );
3301 long nNextX = nPosX + (long) (nDocW * nScaleX);
3302 @@ -670,11 +670,9 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev
3303 if ( bHasHeaderRow )
3304 ++nRowCount;
3305 if ( bHasRepRows )
3306 - nRowCount += pDoc->GetRowFlagsArray( nTab).CountForCondition(
3307 - nRepeatRowStart, nRepeatRowEnd, CR_HIDDEN, 0);
3308 + nRowCount += pDoc->CountVisibleRows(nRepeatRowStart, nRepeatRowEnd, nTab);
3309 if ( bHasMainRows )
3310 - nRowCount += pDoc->GetRowFlagsArray( nTab).CountForCondition(
3311 - nMainRowStart, nMainRowEnd, CR_HIDDEN, 0);
3312 + nRowCount += pDoc->CountVisibleRows(nMainRowStart, nMainRowEnd, nTab);
3314 if ( nRowCount > 0 )
3316 @@ -689,58 +687,44 @@ void ScPreviewLocationData::GetTableInfo( const Rectangle& rVisiblePixel, ScPrev
3317 if ( bHasRepRows )
3319 long nPosY = 0;
3320 - ScCompressedArrayIterator< SCROW, BYTE> aIter(
3321 - pDoc->GetRowFlagsArray( nTab), nRepeatRowStart,
3322 - nRepeatRowEnd);
3323 - do
3324 + for (SCROW nRow = nRepeatRowStart; nRow <= nRepeatRowEnd; ++nRow)
3326 - if ((*aIter & CR_HIDDEN) == 0)
3328 - SCROW nRangeEnd = aIter.GetRangeEnd();
3329 - for (SCROW nRow=aIter.GetRangeStart(); nRow<=nRangeEnd; ++nRow)
3331 - USHORT nDocH = pDoc->FastGetOriginalRowHeight( nRow, nTab );
3332 - long nNextY = nPosY + (long) (nDocH * nScaleY);
3334 - long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
3335 - long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
3336 - pRowInfo[nRowPos].Set( FALSE, nRow,
3337 - aRepeatRect.Top() + nPixelStart,
3338 - aRepeatRect.Top() + nPixelEnd );
3340 - nPosY = nNextY;
3341 - ++nRowPos;
3344 - } while (aIter.NextRange());
3345 + if (pDoc->RowHidden(nRow, nTab))
3346 + continue;
3348 + USHORT nDocH = pDoc->FastGetOriginalRowHeight( nRow, nTab );
3349 + long nNextY = nPosY + (long) (nDocH * nScaleY);
3351 + long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
3352 + long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
3353 + pRowInfo[nRowPos].Set( FALSE, nRow,
3354 + aRepeatRect.Top() + nPixelStart,
3355 + aRepeatRect.Top() + nPixelEnd );
3357 + nPosY = nNextY;
3358 + ++nRowPos;
3361 if ( bHasMainRows )
3363 long nPosY = 0;
3364 - ScCompressedArrayIterator< SCROW, BYTE> aIter(
3365 - pDoc->GetRowFlagsArray( nTab), nMainRowStart,
3366 - nMainRowEnd);
3367 - do
3368 + for (SCROW nRow = nMainRowStart; nRow <= nMainRowEnd; ++nRow)
3370 - if ((*aIter & CR_HIDDEN) == 0)
3372 - SCROW nRangeEnd = aIter.GetRangeEnd();
3373 - for (SCROW nRow=aIter.GetRangeStart(); nRow<=nRangeEnd; ++nRow)
3375 - USHORT nDocH = pDoc->FastGetOriginalRowHeight( nRow, nTab );
3376 - long nNextY = nPosY + (long) (nDocH * nScaleY);
3378 - long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
3379 - long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
3380 - pRowInfo[nRowPos].Set( FALSE, nRow,
3381 - aMainRect.Top() + nPixelStart,
3382 - aMainRect.Top() + nPixelEnd );
3384 - nPosY = nNextY;
3385 - ++nRowPos;
3388 - } while (aIter.NextRange());
3389 + if (pDoc->RowHidden(nRow, nTab))
3390 + continue;
3392 + USHORT nDocH = pDoc->FastGetOriginalRowHeight( nRow, nTab );
3393 + long nNextY = nPosY + (long) (nDocH * nScaleY);
3395 + long nPixelStart = pWindow->LogicToPixel( Size( 0, nPosY ), aCellMapMode ).Height();
3396 + long nPixelEnd = pWindow->LogicToPixel( Size( 0, nNextY ), aCellMapMode ).Height() - 1;
3397 + pRowInfo[nRowPos].Set( FALSE, nRow,
3398 + aMainRect.Top() + nPixelStart,
3399 + aMainRect.Top() + nPixelEnd );
3401 + nPosY = nNextY;
3402 + ++nRowPos;
3405 rInfo.SetRowInfo( nRowCount, pRowInfo );
3407 diff --git sc/source/ui/view/printfun.cxx sc/source/ui/view/printfun.cxx
3408 index 7c9e431..982c02e 100644
3409 --- sc/source/ui/view/printfun.cxx
3410 +++ sc/source/ui/view/printfun.cxx
3411 @@ -3073,9 +3073,10 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom
3412 nTotalY = 0;
3414 BOOL bVisCol = FALSE;
3415 + SCCOL nLastCol = -1;
3416 for (SCCOL i=nStartCol; i<=nEndCol; i++)
3418 - BYTE nFlags = pDoc->GetColFlags(i,nPrintTab);
3419 + bool bHidden = pDoc->ColHidden(i, nPrintTab, nLastCol);
3420 bool bPageBreak = (pDoc->HasColBreak(i, nPrintTab) & BREAK_PAGE);
3421 if ( i>nStartCol && bVisCol && bPageBreak )
3423 @@ -3083,7 +3084,7 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom
3424 ++nPagesX;
3425 bVisCol = FALSE;
3427 - if (!(nFlags & CR_HIDDEN))
3428 + if (!bHidden)
3429 bVisCol = TRUE;
3431 if (bVisCol) // auch am Ende keine leeren Seiten
3432 @@ -3094,38 +3095,35 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom
3434 BOOL bVisRow = FALSE;
3435 SCROW nPageStartRow = nStartRow;
3436 - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray(
3437 - nPrintTab), nStartRow, nEndRow);
3438 - do
3440 - BYTE nFlags = *aIter;
3441 - SCROW nRangeEnd = aIter.GetRangeEnd();
3442 - for (SCROW j=aIter.GetRangeStart(); j<=nRangeEnd; ++j)
3444 - bool bPageBreak = (pDoc->HasRowBreak(j, nPrintTab) & BREAK_PAGE);
3445 - if ( j>nStartRow && bVisRow && bPageBreak )
3447 - pPageEndY[nTotalY] = j-1;
3448 - ++nTotalY;
3450 - if ( !aTableParam.bSkipEmpty ||
3451 - !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, j-1 ) )
3453 - pPageRows[nPagesY].SetStartRow( nPageStartRow );
3454 - pPageRows[nPagesY].SetEndRow( j-1 );
3455 - pPageRows[nPagesY].SetPagesX( nPagesX );
3456 - if (aTableParam.bSkipEmpty)
3457 - lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
3458 - ++nPagesY;
3461 - nPageStartRow = j;
3462 - bVisRow = FALSE;
3464 - if (!(nFlags & CR_HIDDEN))
3465 - bVisRow = TRUE;
3467 - } while (aIter.NextRange());
3468 + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
3470 + bool bPageBreak = (pDoc->HasRowBreak(nRow, nPrintTab) & BREAK_PAGE);
3471 + if (nRow > nStartRow && bVisRow && bPageBreak )
3473 + pPageEndY[nTotalY] = nRow-1;
3474 + ++nTotalY;
3476 + if ( !aTableParam.bSkipEmpty ||
3477 + !pDoc->IsPrintEmpty( nPrintTab, nStartCol, nPageStartRow, nEndCol, nRow-1 ) )
3479 + pPageRows[nPagesY].SetStartRow( nPageStartRow );
3480 + pPageRows[nPagesY].SetEndRow( nRow-1 );
3481 + pPageRows[nPagesY].SetPagesX( nPagesX );
3482 + if (aTableParam.bSkipEmpty)
3483 + lcl_SetHidden( pDoc, nPrintTab, pPageRows[nPagesY], nStartCol, pPageEndX );
3484 + ++nPagesY;
3487 + nPageStartRow = nRow;
3488 + bVisRow = FALSE;
3490 + SCROW nLastRow = -1;
3491 + if (!pDoc->RowHidden(nRow, nPrintTab, nLastRow))
3492 + bVisRow = TRUE;
3493 + else
3494 + // skip all hidden rows.
3495 + nRow = nLastRow;
3498 if (bVisRow)
3500 diff --git sc/source/ui/view/select.cxx sc/source/ui/view/select.cxx
3501 index 8ab9801..4ac0b68 100644
3502 --- sc/source/ui/view/select.cxx
3503 +++ sc/source/ui/view/select.cxx
3504 @@ -278,12 +278,12 @@ BOOL __EXPORT ScViewFunctionSet::SetCursorAtPoint( const Point& rPointPixel, BOO
3505 ScDocument* pDoc = pViewData->GetDocument();
3506 SCTAB nTab = pViewData->GetTabNo();
3507 if ( bLeft && !bRightScroll )
3508 - do --nPosX; while ( nPosX>=0 && ( pDoc->GetColFlags( nPosX, nTab ) & CR_HIDDEN ) );
3509 + do --nPosX; while ( nPosX>=0 && pDoc->ColHidden( nPosX, nTab ) );
3510 if ( bTop && !bBottomScroll )
3512 if (--nPosY >= 0)
3514 - pDoc->GetRowFlagsArray( nTab).GetLastForCondition( 0, nPosY, CR_HIDDEN, 0);
3515 + nPosY = pDoc->LastVisibleRow(0, nPosY, nTab);
3516 if (!ValidRow(nPosY))
3517 nPosY = -1;
3519 @@ -479,7 +479,7 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
3521 // #94321# in SetCursorAtPoint hidden columns are skipped.
3522 // They must be skipped here too, or the result will always be the first hidden column.
3523 - do ++nPosX; while ( nPosX<nStartX && ( pDoc->GetColFlags( nPosX, nTab ) & CR_HIDDEN ) );
3524 + do ++nPosX; while ( nPosX<nStartX && pDoc->ColHidden(nPosX, nTab) );
3525 for (SCCOL i=nPosX; i<nStartX; i++)
3526 nSizeX += pDoc->GetColWidth( i, nTab );
3528 @@ -494,8 +494,7 @@ BOOL ScViewFunctionSet::SetCursorAtCell( SCsCOL nPosX, SCsROW nPosY, BOOL bScrol
3529 // They must be skipped here too, or the result will always be the first hidden row.
3530 if (++nPosY < nStartY)
3532 - nPosY = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition(
3533 - nPosY, nStartY-1, CR_HIDDEN, 0);
3534 + nPosY = pDoc->FirstVisibleRow(nPosY, nStartY-1, nTab);
3535 if (!ValidRow(nPosY))
3536 nPosY = nStartY;
3538 diff --git sc/source/ui/view/tabview.cxx sc/source/ui/view/tabview.cxx
3539 index f39dd17..eb6908b 100644
3540 --- sc/source/ui/view/tabview.cxx
3541 +++ sc/source/ui/view/tabview.cxx
3542 @@ -1441,7 +1441,7 @@ void ScTabView::ScrollX( long nDeltaX, ScHSplitPos eWhich, BOOL bUpdBars )
3543 SCsCOL nDir = ( nDeltaX > 0 ) ? 1 : -1;
3544 ScDocument* pDoc = aViewData.GetDocument();
3545 SCTAB nTab = aViewData.GetTabNo();
3546 - while ( ( pDoc->GetColFlags( nNewX, nTab ) & CR_HIDDEN ) &&
3547 + while ( pDoc->ColHidden(nNewX, nTab) &&
3548 nNewX+nDir >= 0 && nNewX+nDir <= MAXCOL )
3549 nNewX = sal::static_int_cast<SCsCOL>( nNewX + nDir );
3551 @@ -1530,7 +1530,7 @@ void ScTabView::ScrollY( long nDeltaY, ScVSplitPos eWhich, BOOL bUpdBars )
3552 SCsROW nDir = ( nDeltaY > 0 ) ? 1 : -1;
3553 ScDocument* pDoc = aViewData.GetDocument();
3554 SCTAB nTab = aViewData.GetTabNo();
3555 - while ( ( pDoc->GetRowFlags( nNewY, nTab ) & CR_HIDDEN ) &&
3556 + while ( pDoc->RowHidden(nNewY, nTab) &&
3557 nNewY+nDir >= 0 && nNewY+nDir <= MAXROW )
3558 nNewY += nDir;
3560 diff --git sc/source/ui/view/tabview2.cxx sc/source/ui/view/tabview2.cxx
3561 index 687f936..02a2710 100644
3562 --- sc/source/ui/view/tabview2.cxx
3563 +++ sc/source/ui/view/tabview2.cxx
3564 @@ -928,13 +928,13 @@ BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom,
3567 long nBlockY = 0;
3568 - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
3569 - pDoc->GetRowFlagsArray( nTab), 0, nFixPosY-1, CR_HIDDEN, 0,
3570 - pDoc->GetRowHeightArray( nTab));
3571 - for ( ; aIter; ++aIter)
3572 + for (SCROW nRow = 0; nRow <= nFixPosY-1; ++nRow)
3574 + if (pDoc->RowHidden(nRow, nTab))
3575 + continue;
3577 // for frozen panes, add both parts
3578 - USHORT nRowTwips = *aIter;
3579 + USHORT nRowTwips = pDoc->GetRowHeight(nRow, nTab);
3580 if (nRowTwips)
3582 nBlockY += (long)(nRowTwips * fScaleY);
3583 @@ -942,10 +942,9 @@ BOOL lcl_FitsInWindow( double fScaleX, double fScaleY, USHORT nZoom,
3584 return FALSE;
3587 - aIter.NewLimits( nStartRow, nEndRow);
3588 - for ( ; aIter; ++aIter)
3589 + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
3591 - USHORT nRowTwips = *aIter;
3592 + USHORT nRowTwips = pDoc->GetRowHeight(nRow, nTab);
3593 if (nRowTwips)
3595 nBlockY += (long)(nRowTwips * fScaleY);
3596 diff --git sc/source/ui/view/tabview3.cxx sc/source/ui/view/tabview3.cxx
3597 index 5493de4..5317d0a 100644
3598 --- sc/source/ui/view/tabview3.cxx
3599 +++ sc/source/ui/view/tabview3.cxx
3600 @@ -993,8 +993,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
3601 BOOL bHFlip = FALSE;
3604 - BYTE nColFlags = pDoc->GetColFlags( nCurX, nTab );
3605 - bSkipCell = (nColFlags & CR_HIDDEN) || pDoc->IsHorOverlapped( nCurX, nCurY, nTab );
3606 + SCCOL nLastCol = -1;
3607 + bSkipCell = pDoc->ColHidden(nCurX, nTab, nLastCol) || pDoc->IsHorOverlapped( nCurX, nCurY, nTab );
3608 if (bSkipProtected && !bSkipCell)
3609 bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
3610 if (bSkipUnprotected && !bSkipCell)
3611 @@ -1035,8 +1035,8 @@ void ScTabView::MoveCursorRel( SCsCOL nMovX, SCsROW nMovY, ScFollowMode eMode,
3612 BOOL bVFlip = FALSE;
3615 - BYTE nRowFlags = pDoc->GetRowFlags( nCurY, nTab );
3616 - bSkipCell = (nRowFlags & CR_HIDDEN) || pDoc->IsVerOverlapped( nCurX, nCurY, nTab );
3617 + SCROW nLastRow = -1;
3618 + bSkipCell = pDoc->RowHidden(nCurY, nTab, nLastRow) || pDoc->IsVerOverlapped( nCurX, nCurY, nTab );
3619 if (bSkipProtected && !bSkipCell)
3620 bSkipCell = pDoc->HasAttrib(nCurX, nCurY, nTab, nCurX, nCurY, nTab, HASATTR_PROTECTED);
3621 if (bSkipUnprotected && !bSkipCell)
3622 @@ -2058,17 +2058,18 @@ void ScTabView::PaintRangeFinder( long nNumber )
3623 BOOL bHiddenEdge = FALSE;
3624 SCROW nTmp;
3625 ScDocument* pDoc = aViewData.GetDocument();
3626 - while ( nCol1 > 0 && ( pDoc->GetColFlags( nCol1, nTab ) & CR_HIDDEN ) )
3627 + SCCOL nLastCol = -1;
3628 + while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab, nLastCol) )
3630 --nCol1;
3631 bHiddenEdge = TRUE;
3633 - while ( nCol2 < MAXCOL && ( pDoc->GetColFlags( nCol2, nTab ) & CR_HIDDEN ) )
3634 + while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab, nLastCol) )
3636 ++nCol2;
3637 bHiddenEdge = TRUE;
3639 - nTmp = pDoc->GetRowFlagsArray( nTab).GetLastForCondition( 0, nRow1, CR_HIDDEN, 0);
3640 + nTmp = pDoc->LastVisibleRow(0, nRow1, nTab);
3641 if (!ValidRow(nTmp))
3642 nTmp = 0;
3643 if (nTmp < nRow1)
3644 @@ -2076,7 +2077,7 @@ void ScTabView::PaintRangeFinder( long nNumber )
3645 nRow1 = nTmp;
3646 bHiddenEdge = TRUE;
3648 - nTmp = pDoc->GetRowFlagsArray( nTab).GetFirstForCondition( nRow2, MAXROW, CR_HIDDEN, 0);
3649 + nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab);
3650 if (!ValidRow(nTmp))
3651 nTmp = MAXROW;
3652 if (nTmp > nRow2)
3653 diff --git sc/source/ui/view/viewdata.cxx sc/source/ui/view/viewdata.cxx
3654 index 344f5b6..2ca5d83 100644
3655 --- sc/source/ui/view/viewdata.cxx
3656 +++ sc/source/ui/view/viewdata.cxx
3657 @@ -1560,7 +1560,7 @@ Point ScViewData::GetScrPos( SCCOL nWhereX, SCROW nWhereY, ScSplitPos eWhich,
3658 else if ( nY < MAXROW )
3660 // skip multiple hidden rows (forward only for now)
3661 - SCROW nNext = pDoc->FastGetFirstNonHiddenRow( nY + 1, nTabNo );
3662 + SCROW nNext = pDoc->FirstVisibleRow(nY + 1, MAXROW, nTabNo);
3663 if ( nNext > MAXROW )
3664 nY = MAXROW;
3665 else
3666 @@ -1672,7 +1672,7 @@ SCROW ScViewData::CellsAtY( SCsROW nPosY, SCsROW nDir, ScVSplitPos eWhichY, USHO
3667 else if ( nDir == 1 && nRowNo < MAXROW )
3669 // skip multiple hidden rows (forward only for now)
3670 - SCROW nNext = pDoc->FastGetFirstNonHiddenRow( nRowNo + 1, nTabNo );
3671 + SCROW nNext = pDoc->FirstVisibleRow(nRowNo + 1, MAXROW, nTabNo);
3672 if ( nNext > MAXROW )
3674 // same behavior as without the optimization: set bOut with nY=MAXROW+1
3675 @@ -1735,11 +1735,19 @@ BOOL ScViewData::GetMergeSizePixel( SCCOL nX, SCROW nY, long& rSizeXPix, long& r
3676 for (SCCOL i=0; i<nCountX; i++)
3677 nOutWidth += ToPixel( pDoc->GetColWidth(nX+i,nTabNo), nPPTX );
3678 SCROW nCountY = pMerge->GetRowMerge();
3679 - ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
3680 - pDoc->GetRowFlagsArray( nTabNo), nY, nY+nCountY-1, CR_HIDDEN,
3681 - 0, pDoc->GetRowHeightArray( nTabNo));
3682 - for ( ; aIter; ++aIter )
3683 - nOutHeight += ToPixel( *aIter, nPPTY );
3685 + for (SCROW nRow = nY; nRow <= nY+nCountY-1; ++nRow)
3687 + SCROW nLastRow = nRow;
3688 + if (pDoc->RowHidden(nRow, nTabNo, NULL, &nLastRow))
3689 + {
3690 + nRow = nLastRow;
3691 + continue;
3694 + USHORT nHeight = pDoc->GetRowHeight(nRow, nTabNo);
3695 + nOutHeight += ToPixel(nHeight, nPPTY);
3698 rSizeXPix = nOutWidth;
3699 rSizeYPix = nOutHeight;
3700 diff --git sc/source/ui/view/viewfun3.cxx sc/source/ui/view/viewfun3.cxx
3701 index d0d565a..af68b6b 100644
3702 --- sc/source/ui/view/viewfun3.cxx
3703 +++ sc/source/ui/view/viewfun3.cxx
3704 @@ -1727,10 +1727,10 @@ BOOL ScViewFunc::MoveBlockTo( const ScRange& rSource, const ScAddress& rDestPos,
3705 BOOL bIncludeFiltered = bCut;
3706 if ( !bIncludeFiltered )
3708 - // manually find number of non-filtered rows
3709 - SCROW nPastedCount = pDocSh->GetDocument()->GetRowFlagsArray(
3710 - rSource.aStart.Tab()).CountForCondition(
3711 - rSource.aStart.Row(), rSource.aEnd.Row(), CR_FILTERED, 0);
3712 + // find number of non-filtered rows
3713 + SCROW nPastedCount = pDocSh->GetDocument()->CountNonFilteredRows(
3714 + rSource.aStart.Row(), rSource.aEnd.Row(), rSource.aStart.Tab());
3716 if ( nPastedCount == 0 )
3717 nPastedCount = 1;
3718 aDestEnd.SetRow( rDestPos.Row() + nPastedCount - 1 );
3719 diff --git sc/source/ui/view/viewfunc.cxx sc/source/ui/view/viewfunc.cxx
3720 index 61670e7..96132fc 100644
3721 --- sc/source/ui/view/viewfunc.cxx
3722 +++ sc/source/ui/view/viewfunc.cxx
3723 @@ -2215,28 +2215,19 @@ void ScViewFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
3725 // fuer alle eingeblendeten CR_MANUALSIZE loeschen,
3726 // dann SetOptimalHeight mit bShrink = FALSE
3727 - ScCompressedArrayIterator< SCROW, BYTE> aIter(
3728 - pDoc->GetRowFlagsArray( nTab), nStartNo,
3729 - nEndNo);
3730 - do
3731 + for (SCROW nRow = nStartNo; nRow <= nEndNo; ++nRow)
3733 - BYTE nOld = *aIter;
3734 - if ( (nOld & CR_HIDDEN) == 0 && ( nOld & CR_MANUALSIZE ) )
3735 + SCROW nLastRow = nRow;
3736 + if (pDoc->RowHidden(nRow, nTab, NULL, &nLastRow))
3738 - SCROW nRangeEnd = aIter.GetRangeEnd();
3739 - pDoc->SetRowFlags( aIter.GetRangeStart(),
3740 - nRangeEnd, nTab,
3741 - nOld & ~CR_MANUALSIZE);
3742 - aIter.Resync( nRangeEnd);
3743 - // Range may be extended due to merges and
3744 - // now aIter.GetRangeEnd() may point behind
3745 - // the previous row, but all flags of this
3746 - // range have the CR_MANUALSIZE bit
3747 - // removed, so it is safe to continue with
3748 - // the next range, not necessary to catch
3749 - // up with the remaining rows.
3750 + nRow = nLastRow;
3751 + continue;
3753 - } while (aIter.NextRange());
3755 + BYTE nOld = pDoc->GetRowFlags(nRow, nTab);
3756 + if (nOld & CR_MANUALSIZE)
3757 + pDoc->SetRowFlags(nRow, nTab, nOld & ~CR_MANUALSIZE);
3761 double nPPTX = GetViewData()->GetPPTX();
3762 @@ -2278,8 +2269,7 @@ void ScViewFunc::SetWidthOrHeight( BOOL bWidth, SCCOLROW nRangeCnt, SCCOLROW* pR
3764 for (SCCOL nCol=static_cast<SCCOL>(nStartNo); nCol<=static_cast<SCCOL>(nEndNo); nCol++)
3766 - if ( eMode != SC_SIZE_VISOPT ||
3767 - (pDoc->GetColFlags( nCol, nTab ) & CR_HIDDEN) == 0 )
3768 + if ( eMode != SC_SIZE_VISOPT || !pDoc->ColHidden(nCol, nTab) )
3770 USHORT nThisSize = nSizeTwips;
3772 diff --git sc/source/ui/view/viewutil.cxx sc/source/ui/view/viewutil.cxx
3773 index 964695c..4215562 100644
3774 --- sc/source/ui/view/viewutil.cxx
3775 +++ sc/source/ui/view/viewutil.cxx
3776 @@ -264,20 +264,19 @@ void ScViewUtil::UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc )
3777 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
3778 if ( rMark.GetTableSelect(nTab ) )
3780 - ScCompressedArrayIterator<SCROW, BYTE> aIter(pDoc->GetRowFlagsArray(nTab), nStartRow, nEndRow);
3781 - do
3782 + for (SCROW nRow = nStartRow; nRow <= nEndRow; ++nRow)
3784 - if (*aIter & CR_FILTERED)
3785 + SCROW nLastRow = nRow;
3786 + if (pDoc->RowFiltered(nRow, nTab, NULL, &nLastRow))
3788 // use nStartCol/nEndCol, so the multi mark area isn't extended to all columns
3789 // (visible in repaint for indentation)
3791 - rMark.SetMultiMarkArea( ScRange( nStartCol, aIter.GetRangeStart(), nTab,
3792 - nEndCol, aIter.GetRangeEnd(), nTab ), FALSE );
3793 + rMark.SetMultiMarkArea(
3794 + ScRange(nStartCol, nRow, nTab, nEndCol, nLastRow, nTab), false);
3795 bChanged = true;
3796 + nRow = nLastRow;
3799 - while (aIter.NextRange());
3802 if ( bChanged && !rMark.HasAnyMultiMarks() )
3803 @@ -288,13 +287,19 @@ void ScViewUtil::UnmarkFiltered( ScMarkData& rMark, ScDocument* pDoc )
3806 // static
3807 -bool ScViewUtil::FitToUnfilteredRows( ScRange & rRange, const ScDocument * pDoc, size_t nRows )
3808 +bool ScViewUtil::FitToUnfilteredRows( ScRange & rRange, ScDocument * pDoc, size_t nRows )
3810 SCTAB nTab = rRange.aStart.Tab();
3811 bool bOneTabOnly = (nTab == rRange.aEnd.Tab());
3812 // Always fit the range on its first sheet.
3813 DBG_ASSERT( bOneTabOnly, "ScViewUtil::ExtendToUnfilteredRows: works only on one sheet");
3814 SCROW nStartRow = rRange.aStart.Row();
3815 +#if 1
3816 + SCROW nLastRow = pDoc->LastNonFilteredRow(nStartRow, MAXROW, nTab);
3817 + if (ValidRow(nLastRow))
3818 + rRange.aEnd.SetRow(nLastRow);
3819 + SCROW nCount = pDoc->CountNonFilteredRows(nStartRow, MAXROW, nTab);
3820 +#else
3821 // FillArrayForCondition() usually is the fastest to determine such a set
3822 // in one pass, even if the array isn't used but the last element.
3823 SCROW* pArr = new SCROW[nRows];
3824 @@ -303,19 +308,19 @@ bool ScViewUtil::FitToUnfilteredRows( ScRange & rRange, const ScDocument * pDoc,
3825 if (nCount)
3826 rRange.aEnd.SetRow( pArr[nCount-1]);
3827 delete [] pArr;
3828 +#endif
3829 return nCount == nRows && bOneTabOnly;
3833 // static
3834 -bool ScViewUtil::HasFiltered( const ScRange& rRange, const ScDocument* pDoc )
3835 +bool ScViewUtil::HasFiltered( const ScRange& rRange, ScDocument* pDoc )
3837 SCROW nStartRow = rRange.aStart.Row();
3838 SCROW nEndRow = rRange.aEnd.Row();
3839 for (SCTAB nTab=rRange.aStart.Tab(); nTab<=rRange.aEnd.Tab(); nTab++)
3841 - if ( pDoc->GetRowFlagsArray( nTab).HasCondition( nStartRow, nEndRow,
3842 - CR_FILTERED, CR_FILTERED ) )
3843 + if (pDoc->HasFilteredRows(nStartRow, nEndRow, nTab))
3844 return true;