Update ooo320-m1
[ooovba.git] / applied_patches / 0188-calc-perf-page-and-manual-breaks.diff
blobc22680b5cbf9a6546721260ed4a7333d3c7ebd47
1 diff --git sc/inc/document.hxx sc/inc/document.hxx
2 index 986bde8..c3e15ea 100644
3 --- sc/inc/document.hxx
4 +++ sc/inc/document.hxx
5 @@ -47,6 +47,7 @@
7 #include <memory>
8 #include <map>
9 +#include <set>
11 class KeyEvent;
12 class OutputDevice;
13 @@ -156,6 +157,9 @@ namespace com { namespace sun { namespace star {
14 namespace embed {
15 class XEmbeddedObject;
17 + namespace sheet {
18 + struct TablePageBreakData;
19 + }
20 } } }
22 namespace com { namespace sun { namespace star { namespace document {
23 @@ -1296,6 +1300,24 @@ public:
24 SC_DLLPUBLIC const ScBitMaskCompressedArray< SCROW, BYTE> & GetRowFlagsArray( SCTAB nTab ) const;
25 SC_DLLPUBLIC ScBitMaskCompressedArray< SCROW, BYTE> & GetRowFlagsArrayModifiable( SCTAB nTab );
27 + SC_DLLPUBLIC void GetAllRowBreaks(::std::set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
28 + SC_DLLPUBLIC void GetAllColBreaks(::std::set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const;
29 + SC_DLLPUBLIC ScBreakType HasRowBreak(SCROW nRow, SCTAB nTab) const;
30 + SC_DLLPUBLIC ScBreakType HasColBreak(SCCOL nCol, SCTAB nTab) const;
31 + SC_DLLPUBLIC void SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
32 + SC_DLLPUBLIC void SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
33 + void RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual);
34 + void RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual);
35 + ::com::sun::star::uno::Sequence<
36 + ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData(SCTAB nTab) const;
38 + /**
39 + * Write all column row flags to table's flag data, because not all column
40 + * row attributes are stored in the flag data members. This is necessary
41 + * for ods export.
42 + */
43 + void SyncColRowFlags();
45 /// @return the index of the last row with any set flags (auto-pagebreak is ignored).
46 SC_DLLPUBLIC SCROW GetLastFlaggedRow( SCTAB nTab ) const;
48 @@ -1335,6 +1357,7 @@ public:
49 Size GetPageSize( SCTAB nTab ) const;
50 void SetPageSize( SCTAB nTab, const Size& rSize );
51 void SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCROW nEndRow );
52 + void InvalidatePageBreaks(SCTAB nTab);
53 void UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea = NULL );
54 void RemoveManualBreaks( SCTAB nTab );
55 BOOL HasManualBreaks( SCTAB nTab ) const;
56 diff --git sc/inc/global.hxx sc/inc/global.hxx
57 index b2d6e50..61d748d 100644
58 --- sc/inc/global.hxx
59 +++ sc/inc/global.hxx
60 @@ -213,13 +213,16 @@ const SCSIZE PIVOT_MAXPAGEFIELD = 10;
61 // FILTERED und MANUALSIZE nur fuer Zeilen moeglich
62 const BYTE CR_HIDDEN = 1;
63 //const BYTE CR_MARKED = 2;
64 -const BYTE CR_PAGEBREAK = 4;
65 +//const BYTE CR_PAGEBREAK = 4;
66 const BYTE CR_MANUALBREAK = 8;
67 const BYTE CR_FILTERED = 16;
68 const BYTE CR_MANUALSIZE = 32;
69 +const BYTE CR_ALL = (CR_HIDDEN | CR_MANUALBREAK | CR_FILTERED | CR_MANUALSIZE);
71 -// was davon kommt in die Datei:
72 -#define CR_SAVEMASK ( ~CR_PAGEBREAK )
73 +typedef BYTE ScBreakType;
74 +const ScBreakType BREAK_NONE = 0;
75 +const ScBreakType BREAK_PAGE = 1;
76 +const ScBreakType BREAK_MANUAL = 2;
78 // Insert-/Delete-Flags
79 const USHORT IDF_NONE = 0x0000;
80 diff --git sc/inc/table.hxx sc/inc/table.hxx
81 index ea24628..bfc4bf2 100644
82 --- sc/inc/table.hxx
83 +++ sc/inc/table.hxx
84 @@ -40,12 +40,19 @@
85 #include "compressedarray.hxx"
87 #include <memory>
88 +#include <set>
90 namespace utl {
91 class SearchParam;
92 class TextSearch;
95 +namespace com { namespace sun { namespace star {
96 + namespace sheet {
97 + struct TablePageBreakData;
98 + }
99 +} } }
101 class SfxItemSet;
102 class SfxStyleSheetBase;
103 class SvxBoxInfoItem;
104 @@ -115,6 +122,11 @@ private:
105 BYTE* pColFlags;
106 ScBitMaskCompressedArray< SCROW, BYTE>* pRowFlags;
108 + ::std::set<SCROW> maRowPageBreaks;
109 + ::std::set<SCROW> maRowManualBreaks;
110 + ::std::set<SCCOL> maColPageBreaks;
111 + ::std::set<SCCOL> maColManualBreaks;
113 ScOutlineTable* pOutlineTable;
115 SCCOL nTableAreaX;
116 @@ -150,6 +162,7 @@ private:
117 Color aScenarioColor;
118 USHORT nScenarioFlags;
119 BOOL bActiveScenario;
120 + bool mbPageBreaksValid;
122 friend class ScDocument; // fuer FillInfo
123 friend class ScDocumentIterator;
124 @@ -337,7 +350,8 @@ public:
126 void CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const;
128 - void InvalidateTableArea() { bTableAreaValid = FALSE; }
129 + void InvalidateTableArea();
130 + void InvalidatePageBreaks();
132 BOOL GetCellArea( SCCOL& rEndCol, SCROW& rEndRow ) const; // FALSE = leer
133 BOOL GetTableArea( SCCOL& rEndCol, SCROW& rEndRow ) const;
134 @@ -598,6 +612,21 @@ public:
135 void RemoveManualBreaks();
136 BOOL HasManualBreaks() const;
138 + void GetAllRowBreaks(::std::set<SCROW>& rBreaks, bool bPage, bool bManual) const;
139 + void GetAllColBreaks(::std::set<SCCOL>& rBreaks, bool bPage, bool bManual) const;
140 + bool HasRowPageBreak(SCROW nRow) const;
141 + bool HasColPageBreak(SCCOL nCol) const;
142 + bool HasRowManualBreak(SCROW nRow) const;
143 + bool HasColManualBreak(SCCOL nCol) const;
144 + void RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow);
145 + void RemoveRowBreak(SCROW nRow, bool bPage, bool bManual);
146 + void RemoveColBreak(SCCOL nCol, bool bPage, bool bManual);
147 + void SetRowBreak(SCROW nRow, bool bPage, bool bManual);
148 + void SetColBreak(SCCOL nCol, bool bPage, bool bManual);
149 + ::com::sun::star::uno::Sequence<
150 + ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const;
151 + void SyncColRowFlags();
153 void StripHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
154 void ExtendHidden( SCCOL& rX1, SCROW& rY1, SCCOL& rX2, SCROW& rY2 );
156 diff --git sc/source/core/data/document.cxx sc/source/core/data/document.cxx
157 index 13c9e66..98001ef 100644
158 --- sc/source/core/data/document.cxx
159 +++ sc/source/core/data/document.cxx
160 @@ -54,6 +54,7 @@
161 #include <tools/tenccvt.hxx>
163 #include <com/sun/star/text/WritingMode2.hpp>
164 +#include <com/sun/star/sheet/TablePageBreakData.hpp>
166 #include "document.hxx"
167 #include "table.hxx"
168 @@ -103,6 +104,9 @@
169 using namespace ::com::sun::star;
171 namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
172 +using ::com::sun::star::uno::Sequence;
173 +using ::com::sun::star::sheet::TablePageBreakData;
174 +using ::std::set;
176 struct ScDefaultAttr
178 @@ -3189,6 +3193,102 @@ const ScBitMaskCompressedArray< SCROW, BYTE> & ScDocument::GetRowFlagsArray(
179 return *pFlags;
182 +void ScDocument::GetAllRowBreaks(set<SCROW>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const
184 + if (!ValidTab(nTab) || !pTab[nTab])
185 + return;
187 + pTab[nTab]->GetAllRowBreaks(rBreaks, bPage, bManual);
190 +void ScDocument::GetAllColBreaks(set<SCCOL>& rBreaks, SCTAB nTab, bool bPage, bool bManual) const
192 + if (!ValidTab(nTab) || !pTab[nTab])
193 + return;
195 + pTab[nTab]->GetAllColBreaks(rBreaks, bPage, bManual);
198 +ScBreakType ScDocument::HasRowBreak(SCROW nRow, SCTAB nTab) const
200 + ScBreakType nType = BREAK_NONE;
201 + if (!ValidTab(nTab) || !pTab[nTab] || !ValidRow(nRow))
202 + return nType;
204 + if (pTab[nTab]->HasRowPageBreak(nRow))
205 + nType |= BREAK_PAGE;
207 + if (pTab[nTab]->HasRowManualBreak(nRow))
208 + nType |= BREAK_MANUAL;
210 + return nType;
213 +ScBreakType ScDocument::HasColBreak(SCCOL nCol, SCTAB nTab) const
215 + ScBreakType nType = BREAK_NONE;
216 + if (!ValidTab(nTab) || !pTab[nTab] || !ValidCol(nCol))
217 + return nType;
219 + if (pTab[nTab]->HasColPageBreak(nCol))
220 + nType |= BREAK_PAGE;
222 + if (pTab[nTab]->HasColManualBreak(nCol))
223 + nType |= BREAK_MANUAL;
225 + return nType;
228 +void ScDocument::SetRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual)
230 + if (!ValidTab(nTab) || !pTab[nTab] || !ValidRow(nRow))
231 + return;
233 + pTab[nTab]->SetRowBreak(nRow, bPage, bManual);
236 +void ScDocument::SetColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual)
238 + if (!ValidTab(nTab) || !pTab[nTab] || !ValidCol(nCol))
239 + return;
241 + pTab[nTab]->SetColBreak(nCol, bPage, bManual);
244 +void ScDocument::RemoveRowBreak(SCROW nRow, SCTAB nTab, bool bPage, bool bManual)
246 + if (!ValidTab(nTab) || !pTab[nTab] || !ValidRow(nRow))
247 + return;
249 + pTab[nTab]->RemoveRowBreak(nRow, bPage, bManual);
252 +void ScDocument::RemoveColBreak(SCCOL nCol, SCTAB nTab, bool bPage, bool bManual)
254 + if (!ValidTab(nTab) || !pTab[nTab] || !ValidCol(nCol))
255 + return;
257 + pTab[nTab]->RemoveColBreak(nCol, bPage, bManual);
260 +Sequence<TablePageBreakData> ScDocument::GetRowBreakData(SCTAB nTab) const
262 + if (!ValidTab(nTab) || !pTab[nTab])
263 + return Sequence<TablePageBreakData>();
265 + return pTab[nTab]->GetRowBreakData();
268 +void ScDocument::SyncColRowFlags()
270 + for (SCTAB i = 0; i <= nMaxTableNumber; ++i)
272 + if (!ValidTab(i) || !pTab[i])
273 + continue;
275 + pTab[i]->SyncColRowFlags();
279 SCROW ScDocument::GetLastFlaggedRow( SCTAB nTab ) const
281 @@ -4569,6 +4669,11 @@ void ScDocument::SetRepeatArea( SCTAB nTab, SCCOL nStartCol, SCCOL nEndCol, SCRO
282 pTab[nTab]->SetRepeatArea( nStartCol, nEndCol, nStartRow, nEndRow );
285 +void ScDocument::InvalidatePageBreaks(SCTAB nTab)
287 + if (ValidTab(nTab) && pTab[nTab])
288 + pTab[nTab]->InvalidatePageBreaks();
291 void ScDocument::UpdatePageBreaks( SCTAB nTab, const ScRange* pUserArea )
293 diff --git sc/source/core/data/table1.cxx sc/source/core/data/table1.cxx
294 index ddd1bbb..51c3e5e 100644
295 --- sc/source/core/data/table1.cxx
296 +++ sc/source/core/data/table1.cxx
297 @@ -155,7 +155,8 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const String& rNewName,
298 pScenarioRanges( NULL ),
299 aScenarioColor( COL_LIGHTGRAY ),
300 nScenarioFlags( 0 ),
301 - bActiveScenario( FALSE )
302 + bActiveScenario( FALSE ),
303 + mbPageBreaksValid(false)
306 if (bColInfo)
307 --- sc/source/core/data/table2.cxx
308 +++ sc/source/core/data/table2.cxx
309 @@ -137,6 +137,8 @@ void ScTable::InsertRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
310 aCol[j].InsertRow( nStartRow, nSize );
311 if( !--nRecalcLvl )
312 SetDrawPageSize();
314 + InvalidatePageBreaks();
318 @@ -164,6 +166,8 @@ void ScTable::DeleteRow( SCCOL nStartCol, SCCOL nEndCol, SCROW nStartRow, SCSIZE
320 if( !--nRecalcLvl )
321 SetDrawPageSize();
323 + InvalidatePageBreaks();
327 @@ -230,6 +234,8 @@ void ScTable::InsertCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
329 if( !--nRecalcLvl )
330 SetDrawPageSize();
332 + InvalidatePageBreaks();
336 @@ -272,6 +278,8 @@ void ScTable::DeleteCol( SCCOL nStartCol, SCROW nStartRow, SCROW nEndRow, SCSIZE
338 if( !--nRecalcLvl )
339 SetDrawPageSize();
341 + InvalidatePageBreaks();
345 @@ -638,29 +646,39 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
346 if (bWidth)
347 for (SCCOL i=nCol1; i<=nCol2; i++)
349 - BOOL bChange = pCharts &&
350 - ( pDestTab->pColFlags[i] & CR_HIDDEN ) != ( pColFlags[i] & CR_HIDDEN );
351 + bool bHiddenChange = ( pDestTab->pColFlags[i] & CR_HIDDEN ) != ( pColFlags[i] & CR_HIDDEN );
352 + bool bChange = bHiddenChange || (pDestTab->pColWidth[i] != pColWidth[i]);
353 pDestTab->pColWidth[i] = pColWidth[i];
354 pDestTab->pColFlags[i] = pColFlags[i];
355 //! Aenderungen zusammenfassen?
356 - if (bChange)
357 + if (bHiddenChange && pCharts)
358 pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab ));
360 + if (bChange)
361 + pDestTab->InvalidatePageBreaks();
364 if (bHeight)
366 + bool bChange = pDestTab->pRowHeight->SumValues(nRow1, nRow2) != pRowHeight->SumValues(nRow1, nRow2);
368 + if (bChange)
369 + pDestTab->InvalidatePageBreaks();
371 pDestTab->pRowHeight->CopyFrom( *pRowHeight, nRow1, nRow2);
372 for (SCROW i=nRow1; i<=nRow2; i++)
374 // TODO: might need some performance improvement, block
375 // operations instead of single GetValue()/SetValue() calls.
376 BYTE nThisRowFlags = pRowFlags->GetValue(i);
377 - BOOL bChange = pCharts &&
378 - ( pDestTab->pRowFlags->GetValue(i) & CR_HIDDEN ) != ( nThisRowFlags & CR_HIDDEN );
379 + bool bHiddenChange = ( pDestTab->pRowFlags->GetValue(i) & CR_HIDDEN ) != ( nThisRowFlags & CR_HIDDEN );
380 pDestTab->pRowFlags->SetValue( i, nThisRowFlags );
381 //! Aenderungen zusammenfassen?
382 - if (bChange)
383 + if (bHiddenChange && pCharts)
384 pCharts->SetRangeDirty(ScRange( 0, i, nTab, MAXCOL, i, nTab ));
386 + if (bHiddenChange)
387 + pDestTab->InvalidatePageBreaks();
390 pDestTab->DecRecalcLevel();
391 @@ -711,6 +729,16 @@ void ScTable::CopyUpdated( const ScTable* pPosTab, ScTable* pDestTab ) const
392 aCol[i].CopyUpdated( pPosTab->aCol[i], pDestTab->aCol[i] );
395 +void ScTable::InvalidateTableArea()
397 + bTableAreaValid = FALSE;
400 +void ScTable::InvalidatePageBreaks()
402 + mbPageBreaksValid = false;
405 void ScTable::CopyScenarioTo( ScTable* pDestTab ) const
407 DBG_ASSERT( bScenario, "bScenario == FALSE" );
408 @@ -1931,6 +1959,8 @@ void ScTable::SetColWidth( SCCOL nCol, USHORT nNewWidth )
409 pColWidth[nCol] = nNewWidth;
410 if( !--nRecalcLvl )
411 SetDrawPageSize();
413 + InvalidatePageBreaks();
416 else
417 @@ -1960,6 +1990,8 @@ void ScTable::SetRowHeight( SCROW nRow, USHORT nNewHeight )
418 pRowHeight->SetValue( nRow, nNewHeight);
419 if( !--nRecalcLvl )
420 SetDrawPageSize();
422 + InvalidatePageBreaks();
425 else
426 @@ -2041,6 +2073,9 @@ BOOL ScTable::SetRowHeightRange( SCROW nStartRow, SCROW nEndRow, USHORT nNewHeig
428 if( !--nRecalcLvl )
429 SetDrawPageSize();
431 + if (bChanged)
432 + InvalidatePageBreaks();
434 else
436 @@ -2280,6 +2315,8 @@ void ScTable::ShowRow(SCROW nRow, BOOL bShow)
437 ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
438 if ( pCharts )
439 pCharts->SetRangeDirty(ScRange( 0, nRow, nTab, MAXCOL, nRow, nTab ));
441 + InvalidatePageBreaks();
444 else
445 @@ -2324,6 +2361,8 @@ void ScTable::DBShowRow(SCROW nRow, BOOL bShow)
447 if (pOutlineTable)
448 UpdateOutlineRow( nRow, nRow, bShow );
450 + InvalidatePageBreaks();
453 else
454 @@ -2421,6 +2460,8 @@ void ScTable::ShowRows(SCROW nRow1, SCROW nRow2, BOOL bShow)
455 ScChartListenerCollection* pCharts = pDocument->GetChartListenerCollection();
456 if ( pCharts )
457 pCharts->SetRangeDirty(ScRange( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab ));
459 + InvalidatePageBreaks();
462 nStartRow = nEndRow + 1;
463 @@ -2496,7 +2537,7 @@ SCROW ScTable::GetLastFlaggedRow() const
464 if ( !pRowFlags )
465 return 0;
467 - SCROW nLastFound = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) );
468 + SCROW nLastFound = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<BYTE>(CR_ALL) );
469 return ValidRow(nLastFound) ? nLastFound : 0;
472 @@ -2508,7 +2549,7 @@ SCCOL ScTable::GetLastChangedCol() const
474 SCCOL nLastFound = 0;
475 for (SCCOL nCol = 1; nCol <= MAXCOL; nCol++)
476 - if ((pColFlags[nCol] & ~CR_PAGEBREAK) || (pColWidth[nCol] != STD_COL_WIDTH))
477 + if ((pColFlags[nCol] & CR_ALL) || (pColWidth[nCol] != STD_COL_WIDTH))
478 nLastFound = nCol;
480 return nLastFound;
481 @@ -2520,7 +2561,7 @@ SCROW ScTable::GetLastChangedRow() const
482 if ( !pRowFlags )
483 return 0;
485 - SCROW nLastFlags = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) );
486 + SCROW nLastFlags = pRowFlags->GetLastAnyBitAccess( 0, sal::static_int_cast<BYTE>(CR_ALL) );
487 if (!ValidRow(nLastFlags))
488 nLastFlags = 0;
490 diff --git sc/source/core/data/table3.cxx sc/source/core/data/table3.cxx
491 index 5fca4bc..95f68fc 100644
492 --- sc/source/core/data/table3.cxx
493 +++ sc/source/core/data/table3.cxx
494 @@ -771,7 +771,7 @@ void ScTable::RemoveSubTotals( ScSubTotalParam& rParam )
495 if ( pCell->GetCellType() == CELLTYPE_FORMULA )
496 if (((ScFormulaCell*)pCell)->IsSubTotal())
498 - SetRowFlags(nRow+1,GetRowFlags(nRow+1)&(~CR_MANUALBREAK));
499 + RemoveRowBreak(nRow+1, false, true);
500 pDocument->DeleteRow( 0,nTab, MAXCOL,nTab, nRow, 1 );
501 --nEndRow;
502 aIter = ScColumnIterator( &aCol[nCol],nRow,nEndRow );
503 @@ -939,9 +939,7 @@ BOOL ScTable::DoSubTotals( ScSubTotalParam& rParam )
504 bBlockVis = FALSE;
505 if ( rParam.bPagebreak && nRow < MAXROW &&
506 aRowEntry.nSubStartRow != nStartRow && nLevel == 0)
507 - SetRowFlags( aRowEntry.nSubStartRow,
508 - GetRowFlags(aRowEntry.nSubStartRow) |
509 - CR_MANUALBREAK);
510 + SetRowBreak(aRowEntry.nSubStartRow, false, true);
512 if (bSpaceLeft)
514 diff --git sc/source/core/data/table5.cxx sc/source/core/data/table5.cxx
515 index 3bb433c..618fe75 100644
516 --- sc/source/core/data/table5.cxx
517 +++ sc/source/core/data/table5.cxx
518 @@ -53,8 +53,13 @@
519 #include "brdcst.hxx"
520 #include "tabprotection.hxx"
521 #include "globstr.hrc"
522 +#include <com/sun/star/sheet/TablePageBreakData.hpp>
524 +#include <algorithm>
526 using ::com::sun::star::uno::Sequence;
527 +using ::com::sun::star::sheet::TablePageBreakData;
528 +using ::std::set;
530 // STATIC DATA -----------------------------------------------------------
532 @@ -68,6 +73,9 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
533 if ( !pUserArea && !bPageSizeValid )
534 return;
536 + if (mbPageBreaksValid)
537 + return;
539 SfxStyleSheetBase* pStyle = pDocument->GetStyleSheetPool()->
540 Find( aPageStyle, SFX_STYLE_FAMILY_PAGE );
541 if ( !pStyle )
542 @@ -79,7 +87,6 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
543 const SfxPoolItem* pItem;
545 SCCOL nX;
546 - SCROW nY;
547 SCCOL nStartCol = 0;
548 SCROW nStartRow = 0;
549 SCCOL nEndCol = MAXCOL;
550 @@ -99,8 +106,9 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
551 // bei mehreren Bereichen nichts anzeigen:
553 for (nX=0; nX<MAXCOL; nX++)
554 - pColFlags[nX] &= ~CR_PAGEBREAK;
555 - pRowFlags->AndValue( 0, MAXROW-1, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) );
556 + RemoveColBreak(nX, true, false);
558 + RemoveRowPageBreaks(0, MAXROW-1);
560 return;
562 @@ -144,13 +152,13 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
563 // Anfang: Breaks loeschen
565 for (nX=0; nX<nStartCol; nX++)
566 - pColFlags[nX] &= ~CR_PAGEBREAK;
567 - pRowFlags->AndValue( 0, nStartRow-1, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) );
568 + RemoveColBreak(nX, true, false);
569 + RemoveRowPageBreaks(0, nStartRow-1);
571 if (nStartCol > 0)
572 - pColFlags[nStartCol] |= CR_PAGEBREAK; //! AREABREAK
573 + SetColBreak(nStartCol, true, false); // AREABREAK
574 if (nStartRow > 0)
575 - pRowFlags->OrValue( nStartRow, CR_PAGEBREAK); //! AREABREAK
576 + SetRowBreak(nStartRow, true, false); // AREABREAK
578 // Mittelteil: Breaks verteilen
580 @@ -161,14 +169,15 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
582 BOOL bStartOfPage = FALSE;
583 long nThisX = ( pColFlags[nX] & CR_HIDDEN ) ? 0 : pColWidth[nX];
584 - if ( (nSizeX+nThisX > nPageSizeX) || ((pColFlags[nX] & CR_MANUALBREAK) && !bSkipBreaks) )
585 + bool bManualBreak = HasColManualBreak(nX);
586 + if ( (nSizeX+nThisX > nPageSizeX) || (bManualBreak && !bSkipBreaks) )
588 - pColFlags[nX] |= CR_PAGEBREAK;
589 + SetColBreak(nX, true, false);
590 nSizeX = 0;
591 bStartOfPage = TRUE;
593 else if (nX != nStartCol)
594 - pColFlags[nX] &= ~CR_PAGEBREAK;
595 + RemoveColBreak(nX, true, false);
596 else
597 bStartOfPage = TRUE;
599 @@ -178,7 +187,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
600 for (SCCOL i=nRepeatStartX; i<=nRepeatEndX; i++)
601 nPageSizeX -= ( pColFlags[i] & CR_HIDDEN ) ? 0 : pColWidth[i];
602 while (nX<=nRepeatEndX)
603 - pColFlags[++nX] &= ~CR_PAGEBREAK;
604 + RemoveColBreak(++nX, true, false);
605 bColFound = TRUE;
608 @@ -186,23 +195,21 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
611 // Remove all page breaks in range.
612 - pRowFlags->AndValue( nStartRow+1, nEndRow, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) );
613 + RemoveRowPageBreaks(nStartRow+1, nEndRow);
615 // And set new page breaks.
616 BOOL bRepeatRow = ( nRepeatStartY != SCROW_REPEAT_NONE );
617 BOOL bRowFound = FALSE;
618 long nSizeY = 0;
619 - ScCompressedArrayIterator< SCROW, BYTE> aFlagsIter( *pRowFlags, nStartRow, nEndRow);
620 - ScCompressedArrayIterator< SCROW, USHORT> aHeightIter( *pRowHeight, nStartRow, nEndRow);
621 - for ( ; aFlagsIter; ++aFlagsIter, ++aHeightIter)
623 - nY = aFlagsIter.GetPos();
624 + for (SCROW nY = nStartRow; nY <= nEndRow; ++nY)
626 BOOL bStartOfPage = FALSE;
627 - BYTE nFlags = *aFlagsIter;
628 - long nThisY = (nFlags & CR_HIDDEN) ? 0 : *aHeightIter;
629 - if ( (nSizeY+nThisY > nPageSizeY) || ((nFlags & CR_MANUALBREAK) && !bSkipBreaks) )
630 + BYTE nFlags = pRowFlags->GetValue(nY);
631 + long nThisY = (nFlags & CR_HIDDEN) ? 0 : pRowHeight->GetValue(nY);
632 + bool bManualBreak = HasRowManualBreak(nY);
633 + if ( (nSizeY+nThisY > nPageSizeY) || (bManualBreak && !bSkipBreaks) )
635 - pRowFlags->SetValue( nY, nFlags | CR_PAGEBREAK);
636 - aFlagsIter.Resync( nY);
637 + SetRowBreak(nY, true, false);
638 nSizeY = 0;
639 bStartOfPage = TRUE;
641 @@ -222,12 +229,7 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
642 #endif
643 nPageSizeY -= nHeights;
644 if (nY <= nRepeatEndY)
646 - pRowFlags->AndValue( nY, nRepeatEndY, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) );
647 - nY = nRepeatEndY + 1;
648 - aFlagsIter.Resync( nY);
649 - aHeightIter.Resync( nY);
651 + RemoveRowPageBreaks(nY, nRepeatEndY);
652 bRowFound = TRUE;
655 @@ -238,46 +240,214 @@ void ScTable::UpdatePageBreaks( const ScRange* pUserArea )
657 if (nEndCol < MAXCOL)
659 - pColFlags[nEndCol+1] |= CR_PAGEBREAK; //! AREABREAK
660 + SetColBreak(nEndCol+1, true, false); // AREABREAK
661 for (nX=nEndCol+2; nX<=MAXCOL; nX++)
662 - pColFlags[nX] &= ~CR_PAGEBREAK;
663 + RemoveColBreak(nX, true, false);
665 if (nEndRow < MAXROW)
667 - pRowFlags->OrValue( nEndRow+1, CR_PAGEBREAK); //! AREABREAK
668 + SetRowBreak(nEndRow+1, true, false); // AREABREAK
669 if (nEndRow+2 <= MAXROW)
670 - pRowFlags->AndValue( nEndRow+2, MAXROW, sal::static_int_cast<BYTE>(~CR_PAGEBREAK) );
671 + RemoveRowPageBreaks(nEndRow+2, MAXROW);
673 + mbPageBreaksValid = true;
676 void ScTable::RemoveManualBreaks()
678 - if (pColFlags)
679 - for (SCCOL nCol = 0; nCol <= MAXCOL; nCol++)
680 - pColFlags[nCol] &= ~CR_MANUALBREAK;
682 - if (pRowFlags)
683 - pRowFlags->AndValue( 0, MAXROW, sal::static_int_cast<BYTE>(~CR_MANUALBREAK) );
684 + maRowManualBreaks.clear();
685 + maColManualBreaks.clear();
686 + InvalidatePageBreaks();
689 BOOL ScTable::HasManualBreaks() const
691 - if (pColFlags)
692 - for (SCCOL nCol = 0; nCol <= MAXCOL; nCol++)
693 - if ( pColFlags[nCol] & CR_MANUALBREAK )
694 - return TRUE;
695 + return !maRowManualBreaks.empty() || !maColManualBreaks.empty();
698 +void ScTable::GetAllRowBreaks(set<SCROW>& rBreaks, bool bPage, bool bManual) const
700 + if (bPage)
701 + rBreaks = maRowPageBreaks;
703 + if (bManual)
705 + using namespace std;
706 + copy(maRowManualBreaks.begin(), maRowManualBreaks.end(), inserter(rBreaks, rBreaks.begin()));
710 +void ScTable::GetAllColBreaks(set<SCCOL>& rBreaks, bool bPage, bool bManual) const
712 + if (bPage)
713 + rBreaks = maColPageBreaks;
715 + if (bManual)
717 + using namespace std;
718 + copy(maColManualBreaks.begin(), maColManualBreaks.end(), inserter(rBreaks, rBreaks.begin()));
722 +bool ScTable::HasRowPageBreak(SCROW nRow) const
724 + if (!ValidRow(nRow))
725 + return false;
727 + return maRowPageBreaks.count(nRow) > 0;
730 - if (pRowFlags)
731 - if (ValidRow( pRowFlags->GetLastAnyBitAccess( 0, CR_MANUALBREAK)))
732 - return TRUE;
733 +bool ScTable::HasColPageBreak(SCCOL nCol) const
735 + if (!ValidCol(nCol))
736 + return false;
738 - return FALSE;
739 + return maColPageBreaks.count(nCol) > 0;
742 +bool ScTable::HasRowManualBreak(SCROW nRow) const
744 + if (!ValidRow(nRow))
745 + return false;
747 + return maRowManualBreaks.count(nRow) > 0;
750 +bool ScTable::HasColManualBreak(SCCOL nCol) const
752 + if (!ValidCol(nCol))
753 + return false;
755 + return (maColManualBreaks.count(nCol) > 0);
758 +void ScTable::RemoveRowPageBreaks(SCROW nStartRow, SCROW nEndRow)
760 + using namespace std;
762 + if (!ValidRow(nStartRow) || !ValidRow(nEndRow))
763 + return;
765 + set<SCROW>::iterator low = maRowPageBreaks.lower_bound(nStartRow);
766 + set<SCROW>::iterator high = maRowPageBreaks.upper_bound(nEndRow);
767 + maRowPageBreaks.erase(low, high);
770 +void ScTable::RemoveRowBreak(SCROW nRow, bool bPage, bool bManual)
772 + if (!ValidRow(nRow))
773 + return;
775 + if (bPage)
776 + maRowPageBreaks.erase(nRow);
778 + if (bManual)
779 + {
780 + maRowManualBreaks.erase(nRow);
781 + InvalidatePageBreaks();
785 +void ScTable::RemoveColBreak(SCCOL nCol, bool bPage, bool bManual)
787 + if (!ValidCol(nCol))
788 + return;
790 + if (bPage)
791 + maColPageBreaks.erase(nCol);
793 + if (bManual)
794 + {
795 + maColManualBreaks.erase(nCol);
796 + InvalidatePageBreaks();
800 +void ScTable::SetRowBreak(SCROW nRow, bool bPage, bool bManual)
802 + if (!ValidRow(nRow))
803 + return;
805 + if (bPage)
806 + maRowPageBreaks.insert(nRow);
808 + if (bManual)
809 + {
810 + maRowManualBreaks.insert(nRow);
811 + InvalidatePageBreaks();
815 +void ScTable::SetColBreak(SCCOL nCol, bool bPage, bool bManual)
817 + if (!ValidCol(nCol))
818 + return;
820 + if (bPage)
821 + maColPageBreaks.insert(nCol);
823 + if (bManual)
824 + {
825 + maColManualBreaks.insert(nCol);
826 + InvalidatePageBreaks();
830 +Sequence<TablePageBreakData> ScTable::GetRowBreakData() const
832 + using ::std::copy;
833 + using ::std::inserter;
835 + set<SCROW> aRowBreaks = maRowPageBreaks;
836 + copy(maRowManualBreaks.begin(), maRowManualBreaks.end(), inserter(aRowBreaks, aRowBreaks.begin()));
838 + set<SCROW>::const_iterator itr = aRowBreaks.begin(), itrEnd = aRowBreaks.end();
839 + Sequence<TablePageBreakData> aSeq(aRowBreaks.size());
841 + for (sal_Int32 i = 0; itr != itrEnd; ++itr, ++i)
843 + SCROW nRow = *itr;
844 + TablePageBreakData aData;
845 + aData.Position = nRow;
846 + aData.ManualBreak = HasRowManualBreak(nRow);
847 + aSeq[i] = aData;
850 + return aSeq;
853 +void ScTable::SyncColRowFlags()
855 + using ::sal::static_int_cast;
857 + // For now, we only need to sync the manual breaks.
859 + pRowFlags->AndValue(0, MAXROW, static_int_cast<BYTE>(~CR_MANUALBREAK));
860 + for (SCCOL i = 0; i <= MAXCOL; ++i)
861 + pColFlags[i] &= static_int_cast<BYTE>(~CR_MANUALBREAK);
863 + if (!maRowManualBreaks.empty())
865 + for (set<SCROW>::const_iterator itr = maRowManualBreaks.begin(), itrEnd = maRowManualBreaks.end();
866 + itr != itrEnd; ++itr)
867 + pRowFlags->OrValue(*itr, static_int_cast<BYTE>(CR_MANUALBREAK));
870 + if (!maColManualBreaks.empty())
872 + for (set<SCCOL>::const_iterator itr = maColManualBreaks.begin(), itrEnd = maColManualBreaks.end();
873 + itr != itrEnd; ++itr)
874 + pColFlags[*itr] |= CR_MANUALBREAK;
878 void ScTable::SetPageSize( const Size& rSize )
880 if ( rSize.Width() != 0 && rSize.Height() != 0 )
882 + if (aPageSizeTwips != rSize)
883 + InvalidatePageBreaks();
885 bPageSizeValid = TRUE;
886 aPageSizeTwips = rSize;
888 diff --git sc/source/filter/excel/xepage.cxx sc/source/filter/excel/xepage.cxx
889 index 52aa775..f99b732 100644
890 --- sc/source/filter/excel/xepage.cxx
891 +++ sc/source/filter/excel/xepage.cxx
892 @@ -48,9 +48,14 @@
893 #include "xehelper.hxx"
894 #include "xeescher.hxx"
896 +#include <set>
897 +#include <limits>
899 #include <oox/core/tokens.hxx>
901 using ::rtl::OString;
902 +using ::std::set;
903 +using ::std::numeric_limits;
905 // Page settings records ======================================================
907 @@ -302,17 +307,23 @@ XclExpPageSettings::XclExpPageSettings( const XclExpRoot& rRoot ) :
909 // *** page breaks ***
911 - ScCompressedArrayIterator< SCROW, BYTE> aIter( rDoc.GetRowFlagsArray( nScTab), 1, GetMaxPos().Row());
912 - do
913 + set<SCROW> aRowBreaks;
914 + rDoc.GetAllRowBreaks(aRowBreaks, nScTab, false, true);
916 + SCROW nMaxRow = numeric_limits<sal_uInt16>::max();
917 + for (set<SCROW>::const_iterator itr = aRowBreaks.begin(), itrEnd = aRowBreaks.end(); itr != itrEnd; ++itr)
919 - if (*aIter & CR_MANUALBREAK)
920 - for (SCROW j=aIter.GetRangeStart(); j<=aIter.GetRangeEnd(); ++j)
921 - maData.maHorPageBreaks.push_back( static_cast< sal_uInt16 >( j ) );
922 - } while (aIter.NextRange());
924 - for( SCCOL nScCol = 1, nScMaxCol = GetMaxPos().Col(); nScCol <= nScMaxCol; ++nScCol )
925 - if( rDoc.GetColFlags( nScCol, nScTab ) & CR_MANUALBREAK )
926 - maData.maVerPageBreaks.push_back( static_cast< sal_uInt16 >( nScCol ) );
927 + SCROW nRow = *itr;
928 + if (nRow > nMaxRow)
929 + break;
931 + maData.maHorPageBreaks.push_back(nRow);
934 + set<SCCOL> aColBreaks;
935 + rDoc.GetAllColBreaks(aColBreaks, nScTab, false, true);
936 + for (set<SCCOL>::const_iterator itr = aColBreaks.begin(), itrEnd = aColBreaks.end(); itr != itrEnd; ++itr)
937 + maData.maVerPageBreaks.push_back(*itr);
940 static void lcl_WriteHeaderFooter( XclExpXmlStream& rStrm )
941 diff --git sc/source/filter/excel/xipage.cxx sc/source/filter/excel/xipage.cxx
942 index 2a52521..cb1aba2 100644
943 --- sc/source/filter/excel/xipage.cxx
944 +++ sc/source/filter/excel/xipage.cxx
945 @@ -378,14 +378,14 @@ void XclImpPageSettings::Finalize()
947 SCROW nScRow = static_cast< SCROW >( *aIt );
948 if( nScRow <= MAXROW )
949 - rDoc.SetRowFlags( nScRow, nScTab, rDoc.GetRowFlags( nScRow, nScTab ) | CR_MANUALBREAK );
950 + rDoc.SetRowBreak(nScRow, nScTab, false, true);
953 for( aIt = maData.maVerPageBreaks.begin(), aEnd = maData.maVerPageBreaks.end(); aIt != aEnd; ++aIt )
955 SCCOL nScCol = static_cast< SCCOL >( *aIt );
956 if( nScCol <= MAXCOL )
957 - rDoc.SetColFlags( nScCol, nScTab, rDoc.GetColFlags( nScCol, nScTab ) | CR_MANUALBREAK );
958 + rDoc.SetColBreak(nScCol, nScTab, false, true);
962 diff --git sc/source/filter/starcalc/scflt.cxx sc/source/filter/starcalc/scflt.cxx
963 index 444ed23..371ef48 100644
964 --- sc/source/filter/starcalc/scflt.cxx
965 +++ sc/source/filter/starcalc/scflt.cxx
966 @@ -1552,13 +1552,15 @@ void Sc10Import::LoadTables()
967 if (DataValue != 0)
969 BYTE nFlags = 0;
970 - if ((DataValue & crfSoftBreak) == crfSoftBreak)
971 - nFlags |= CR_PAGEBREAK;
972 - if ((DataValue & crfHardBreak) == crfHardBreak)
973 - nFlags |= CR_MANUALBREAK;
974 + bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
975 + bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
976 if ((DataValue & crfHidden) == crfHidden)
977 nFlags |= CR_HIDDEN;
978 - for (SCCOL k = static_cast<SCCOL>(DataStart); k <= static_cast<SCCOL>(DataEnd); k++) pDoc->SetColFlags(k, static_cast<SCTAB> (TabNo), nFlags);
979 + for (SCCOL k = static_cast<SCCOL>(DataStart); k <= static_cast<SCCOL>(DataEnd); k++)
980 + {
981 + pDoc->SetColFlags(k, static_cast<SCTAB> (TabNo), nFlags);
982 + pDoc->SetColBreak(k, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
985 DataStart = DataEnd + 1;
987 @@ -1602,13 +1604,15 @@ void Sc10Import::LoadTables()
988 if (DataValue != 0)
990 BYTE nFlags = 0;
991 - if ((DataValue & crfSoftBreak) == crfSoftBreak)
992 - nFlags |= CR_PAGEBREAK;
993 - if ((DataValue & crfHardBreak) == crfHardBreak)
994 - nFlags |= CR_MANUALBREAK;
995 + bool bPageBreak = ((DataValue & crfSoftBreak) == crfSoftBreak);
996 + bool bManualBreak = ((DataValue & crfHardBreak) == crfHardBreak);
997 if ((DataValue & crfHidden) == crfHidden)
998 nFlags |= CR_HIDDEN;
999 - for (SCROW l = static_cast<SCROW>(DataStart); l <= static_cast<SCROW>(DataEnd); l++) pDoc->SetRowFlags(l, static_cast<SCTAB> (TabNo), nFlags);
1000 + for (SCROW l = static_cast<SCROW>(DataStart); l <= static_cast<SCROW>(DataEnd); l++)
1001 + {
1002 + pDoc->SetRowFlags(l, static_cast<SCTAB> (TabNo), nFlags);
1003 + pDoc->SetRowBreak(l, static_cast<SCTAB> (TabNo), bPageBreak, bManualBreak);
1006 DataStart = DataEnd + 1;
1008 diff --git sc/source/filter/xml/xmlexprt.cxx sc/source/filter/xml/xmlexprt.cxx
1009 index 089f12d..4dd19a1 100644
1010 --- sc/source/filter/xml/xmlexprt.cxx
1011 +++ sc/source/filter/xml/xmlexprt.cxx
1012 @@ -1947,6 +1947,7 @@ void ScXMLExport::_ExportAutoStyles()
1014 if (pDoc)
1016 + pDoc->SyncColRowFlags();
1017 uno::Reference<table::XTableColumns> xTableColumns(xColumnRowRange->getColumns());
1018 if (xTableColumns.is())
1020 diff --git sc/source/ui/docshell/dbdocfun.cxx sc/source/ui/docshell/dbdocfun.cxx
1021 index 9e2a647..0e670d8 100644
1022 --- sc/source/ui/docshell/dbdocfun.cxx
1023 +++ sc/source/ui/docshell/dbdocfun.cxx
1024 @@ -938,7 +938,10 @@ BOOL ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
1027 if (!bCopy)
1029 + pDoc->InvalidatePageBreaks(nTab);
1030 pDoc->UpdatePageBreaks( nTab );
1033 // #i23299# because of Subtotal functions, the whole rows must be set dirty
1034 ScRange aDirtyRange( 0 , aLocalParam.nRow1, nDestTab,
1035 diff --git sc/source/ui/docshell/docfunc.cxx sc/source/ui/docshell/docfunc.cxx
1036 index 0d98486..1477025 100644
1037 --- sc/source/ui/docshell/docfunc.cxx
1038 +++ sc/source/ui/docshell/docfunc.cxx
1039 @@ -3033,20 +3033,22 @@ BOOL ScDocFunc::InsertPageBreak( BOOL bColumn, const ScAddress& rPos,
1040 if (nPos == 0)
1041 return FALSE; // erste Spalte / Zeile
1043 - BYTE nFlags = bColumn ? pDoc->GetColFlags( static_cast<SCCOL>(nPos), nTab )
1044 - : pDoc->GetRowFlags( static_cast<SCROW>(nPos), nTab );
1045 - if (nFlags & CR_MANUALBREAK)
1046 - return TRUE; // Umbruch schon gesetzt
1047 + ScBreakType nBreak = bColumn ?
1048 + pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab) :
1049 + pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab);
1050 + if (nBreak & BREAK_MANUAL)
1051 + return true;
1053 if (bRecord)
1054 rDocShell.GetUndoManager()->AddUndoAction(
1055 new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, TRUE ) );
1057 - nFlags |= CR_MANUALBREAK;
1058 - if (bColumn)
1059 - pDoc->SetColFlags( static_cast<SCCOL>(nPos), nTab, nFlags );
1060 - else
1061 - pDoc->SetRowFlags( static_cast<SCROW>(nPos), nTab, nFlags );
1062 + if (bColumn)
1063 + pDoc->SetColBreak(static_cast<SCCOL>(nPos), nTab, false, true);
1064 + else
1065 + pDoc->SetRowBreak(static_cast<SCROW>(nPos), nTab, false, true);
1067 + pDoc->InvalidatePageBreaks(nTab);
1068 pDoc->UpdatePageBreaks( nTab );
1070 if (bColumn)
1071 @@ -3089,20 +3091,25 @@ BOOL ScDocFunc::RemovePageBreak( BOOL bColumn, const ScAddress& rPos,
1073 SCCOLROW nPos = bColumn ? static_cast<SCCOLROW>(rPos.Col()) :
1074 static_cast<SCCOLROW>(rPos.Row());
1075 - BYTE nFlags = bColumn ? pDoc->GetColFlags( static_cast<SCCOL>(nPos), nTab )
1076 - : pDoc->GetRowFlags( static_cast<SCROW>(nPos), nTab );
1077 - if ((nFlags & CR_MANUALBREAK)==0)
1078 - return FALSE; // kein Umbruch gesetzt
1080 + ScBreakType nBreak;
1081 + if (bColumn)
1082 + nBreak = pDoc->HasColBreak(static_cast<SCCOL>(nPos), nTab);
1083 + else
1084 + nBreak = pDoc->HasRowBreak(static_cast<SCROW>(nPos), nTab);
1085 + if ((nBreak & BREAK_MANUAL) == 0)
1086 + // There is no manual break.
1087 + return false;
1089 if (bRecord)
1090 rDocShell.GetUndoManager()->AddUndoAction(
1091 new ScUndoPageBreak( &rDocShell, rPos.Col(), rPos.Row(), nTab, bColumn, FALSE ) );
1093 - nFlags &= ~CR_MANUALBREAK;
1094 - if (bColumn)
1095 - pDoc->SetColFlags( static_cast<SCCOL>(nPos), nTab, nFlags );
1096 - else
1097 - pDoc->SetRowFlags( static_cast<SCROW>(nPos), nTab, nFlags );
1098 + if (bColumn)
1099 + pDoc->RemoveColBreak(static_cast<SCCOL>(nPos), nTab, false, true);
1100 + else
1101 + pDoc->RemoveRowBreak(static_cast<SCROW>(nPos), nTab, false, true);
1103 pDoc->UpdatePageBreaks( nTab );
1105 if (bColumn)
1106 diff --git sc/source/ui/docshell/olinefun.cxx sc/source/ui/docshell/olinefun.cxx
1107 index ed5fb52..37023e2 100644
1108 --- sc/source/ui/docshell/olinefun.cxx
1109 +++ sc/source/ui/docshell/olinefun.cxx
1110 @@ -692,6 +692,7 @@ BOOL ScOutlineDocFunc::ShowOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, US
1112 pArray->SetVisibleBelow( nLevel, nEntry, TRUE, TRUE );
1114 + pDoc->InvalidatePageBreaks(nTab);
1115 pDoc->UpdatePageBreaks( nTab );
1117 if (bPaint)
1118 @@ -757,6 +758,7 @@ BOOL ScOutlineDocFunc::HideOutline( SCTAB nTab, BOOL bColumns, USHORT nLevel, US
1120 pArray->SetVisibleBelow( nLevel, nEntry, FALSE );
1122 + pDoc->InvalidatePageBreaks(nTab);
1123 pDoc->UpdatePageBreaks( nTab );
1125 if (bPaint)
1126 diff --git sc/source/ui/undo/undocell.cxx sc/source/ui/undo/undocell.cxx
1127 index 52c8bc0..9237578 100644
1128 --- sc/source/ui/undo/undocell.cxx
1129 +++ sc/source/ui/undo/undocell.cxx
1130 @@ -587,6 +587,8 @@ void ScUndoPageBreak::DoChange( BOOL bInsertP ) const
1131 pViewShell->InsertPageBreak(bColumn, FALSE);
1132 else
1133 pViewShell->DeletePageBreak(bColumn, FALSE);
1135 + pDocShell->GetDocument()->InvalidatePageBreaks(nTab);
1139 diff --git sc/source/ui/undo/undodat.cxx sc/source/ui/undo/undodat.cxx
1140 index 36bb424..7420660 100644
1141 --- sc/source/ui/undo/undodat.cxx
1142 +++ sc/source/ui/undo/undodat.cxx
1143 @@ -1032,7 +1032,10 @@ void __EXPORT ScUndoQuery::Undo()
1144 pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), TRUE );
1146 if (!bCopy)
1148 + pDoc->InvalidatePageBreaks(nTab);
1149 pDoc->UpdatePageBreaks( nTab );
1152 ScRange aDirtyRange( 0 , aQueryParam.nRow1, nTab,
1153 MAXCOL, aQueryParam.nRow2, nTab );
1154 --- sc/source/ui/unoobj/cellsuno.cxx
1155 +++ sc/source/ui/unoobj/cellsuno.cxx
1156 @@ -7150,7 +7150,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPage
1157 SCCOL nCount = 0;
1158 SCCOL nCol;
1159 for (nCol=0; nCol<=MAXCOL; nCol++)
1160 - if (pDoc->GetColFlags( nCol, nTab ) & ( CR_PAGEBREAK | CR_MANUALBREAK ))
1161 + if (pDoc->HasColBreak(nCol, nTab))
1162 ++nCount;
1164 sheet::TablePageBreakData aData;
1165 @@ -7159,11 +7159,11 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getColumnPage
1166 USHORT nPos = 0;
1167 for (nCol=0; nCol<=MAXCOL; nCol++)
1169 - BYTE nFlags = pDoc->GetColFlags( nCol, nTab );
1170 - if (nFlags & ( CR_PAGEBREAK | CR_MANUALBREAK ))
1171 + ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
1172 + if (nBreak)
1174 aData.Position = nCol;
1175 - aData.ManualBreak = ( nFlags & CR_MANUALBREAK ) != 0;
1176 + aData.ManualBreak = (nBreak & BREAK_MANUAL);
1177 pAry[nPos] = aData;
1178 ++nPos;
1180 @@ -7192,33 +7192,7 @@ uno::Sequence<sheet::TablePageBreakData> SAL_CALL ScTableSheetObj::getRowPageBre
1181 ScPrintFunc aPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab );
1182 aPrintFunc.UpdatePages();
1185 - SCROW nCount = pDoc->GetRowFlagsArray( nTab).CountForAnyBitCondition(
1186 - 0, MAXROW, (CR_PAGEBREAK | CR_MANUALBREAK));
1188 - uno::Sequence<sheet::TablePageBreakData> aSeq(nCount);
1189 - if (nCount)
1191 - sheet::TablePageBreakData aData;
1192 - sheet::TablePageBreakData* pAry = aSeq.getArray();
1193 - size_t nPos = 0;
1194 - ScCompressedArrayIterator< SCROW, BYTE> aIter( pDoc->GetRowFlagsArray( nTab), 0, MAXROW);
1195 - do
1197 - BYTE nFlags = *aIter;
1198 - if (nFlags & ( CR_PAGEBREAK | CR_MANUALBREAK ))
1200 - for (SCROW nRow = aIter.GetRangeStart(); nRow <= aIter.GetRangeEnd(); ++nRow)
1202 - aData.Position = nRow;
1203 - aData.ManualBreak = ( nFlags & CR_MANUALBREAK ) != 0;
1204 - pAry[nPos] = aData;
1205 - ++nPos;
1208 - } while (aIter.NextRange());
1210 - return aSeq;
1211 + return pDoc->GetRowBreakData(nTab);
1213 return uno::Sequence<sheet::TablePageBreakData>(0);
1215 @@ -8987,13 +8961,13 @@ void ScTableColumnObj::GetOnePropertyValue( const SfxItemPropertyMap* pMap,
1217 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
1219 - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nCol, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) );
1220 - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak );
1221 + ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
1222 + ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
1224 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
1226 - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nCol, nTab ) & (CR_MANUALBREAK)) );
1227 - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak );
1228 + ScBreakType nBreak = pDoc->HasColBreak(nCol, nTab);
1229 + ScUnoHelpFunctions::SetBoolInAny(rAny, (nBreak & BREAK_MANUAL));
1231 else
1232 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
1233 @@ -9151,13 +9125,13 @@ void ScTableRowObj::GetOnePropertyValue( const SfxItemPropertyMap* pMap,
1235 else if ( pEntry->nWID == SC_WID_UNO_NEWPAGE )
1237 - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nRow, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) );
1238 - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak );
1239 + ScBreakType nBreak = pDoc->HasRowBreak(nRow, nTab);
1240 + ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
1242 else if ( pEntry->nWID == SC_WID_UNO_MANPAGE )
1244 - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nRow, nTab ) & (CR_MANUALBREAK)) );
1245 - ScUnoHelpFunctions::SetBoolInAny( rAny, bBreak );
1246 + ScBreakType nBreak = (pDoc->HasRowBreak(nRow, nTab) & BREAK_MANUAL);
1247 + ScUnoHelpFunctions::SetBoolInAny( rAny, nBreak );
1249 else
1250 ScCellRangeObj::GetOnePropertyValue(pEntry, rAny);
1251 diff --git sc/source/ui/unoobj/docuno.cxx sc/source/ui/unoobj/docuno.cxx
1252 index f14ab4a..f2f1eb5 100644
1253 --- sc/source/ui/unoobj/docuno.cxx
1254 +++ sc/source/ui/unoobj/docuno.cxx
1255 @@ -2685,13 +2685,13 @@ uno::Any SAL_CALL ScTableColumnsObj::getPropertyValue( const rtl::OUString& aPro
1257 else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) )
1259 - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nStartCol, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) );
1260 - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak );
1261 + ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab);
1262 + ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
1264 else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
1266 - BOOL bBreak = ( 0 != (pDoc->GetColFlags( nStartCol, nTab ) & (CR_MANUALBREAK)) );
1267 - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak );
1268 + ScBreakType nBreak = pDoc->HasColBreak(nStartCol, nTab);
1269 + ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) );
1272 return aAny;
1273 @@ -2939,13 +2939,13 @@ uno::Any SAL_CALL ScTableRowsObj::getPropertyValue( const rtl::OUString& aProper
1275 else if ( aNameString.EqualsAscii( SC_UNONAME_NEWPAGE ) )
1277 - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nStartRow, nTab ) & (CR_PAGEBREAK|CR_MANUALBREAK)) );
1278 - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak );
1279 + ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab);
1280 + ScUnoHelpFunctions::SetBoolInAny( aAny, nBreak );
1282 else if ( aNameString.EqualsAscii( SC_UNONAME_MANPAGE ) )
1284 - BOOL bBreak = ( 0 != (pDoc->GetRowFlags( nStartRow, nTab ) & (CR_MANUALBREAK)) );
1285 - ScUnoHelpFunctions::SetBoolInAny( aAny, bBreak );
1286 + ScBreakType nBreak = pDoc->HasRowBreak(nStartRow, nTab);
1287 + ScUnoHelpFunctions::SetBoolInAny( aAny, (nBreak & BREAK_MANUAL) );
1289 else if ( aNameString.EqualsAscii( SC_UNONAME_CELLBACK ) || aNameString.EqualsAscii( SC_UNONAME_CELLTRAN ) )
1291 diff --git sc/source/ui/vba/vbarange.cxx sc/source/ui/vba/vbarange.cxx
1292 index 634443a..986c376 100644
1293 --- sc/source/ui/vba/vbarange.cxx
1294 +++ sc/source/ui/vba/vbarange.cxx
1295 @@ -3719,16 +3719,16 @@ ScVbaRange::getPageBreak() throw (uno::RuntimeException)
1297 ScDocument* pDoc = getDocumentFromRange( mxRange );
1299 - BYTE nFlag = 0;
1300 + ScBreakType nBreak = BREAK_NONE;
1301 if ( !bColumn )
1302 - nFlag = pDoc -> GetRowFlags(thisAddress.StartRow, thisAddress.Sheet);
1303 + nBreak = pDoc->HasRowBreak(thisAddress.StartRow, thisAddress.Sheet);
1304 else
1305 - nFlag = pDoc -> GetColFlags(static_cast<SCCOL>(thisAddress.StartColumn), thisAddress.Sheet);
1306 + nBreak = pDoc->HasColBreak(thisAddress.StartColumn, thisAddress.Sheet);
1308 - if ( nFlag & CR_PAGEBREAK)
1309 + if (nBreak & BREAK_PAGE)
1310 nPageBreak = excel::XlPageBreak::xlPageBreakAutomatic;
1312 - if ( nFlag & CR_MANUALBREAK)
1313 + if (nBreak & BREAK_MANUAL)
1314 nPageBreak = excel::XlPageBreak::xlPageBreakManual;
1317 diff --git sc/source/ui/view/cellsh.cxx sc/source/ui/view/cellsh.cxx
1318 index 3c047da..f228c30 100644
1319 --- sc/source/ui/view/cellsh.cxx
1320 +++ sc/source/ui/view/cellsh.cxx
1321 @@ -717,22 +717,22 @@ void ScCellShell::GetState(SfxItemSet &rSet)
1322 break;
1324 case FID_INS_ROWBRK:
1325 - if ( nPosY==0 || (pDoc->GetRowFlags(nPosY,nTab) & CR_MANUALBREAK) )
1326 + if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) )
1327 rSet.DisableItem( nWhich );
1328 break;
1330 case FID_INS_COLBRK:
1331 - if ( nPosX==0 || (pDoc->GetColFlags(nPosX,nTab) & CR_MANUALBREAK) )
1332 + if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) )
1333 rSet.DisableItem( nWhich );
1334 break;
1336 case FID_DEL_ROWBRK:
1337 - if ( nPosY==0 || (pDoc->GetRowFlags(nPosY,nTab) & CR_MANUALBREAK)==0 )
1338 + if ( nPosY==0 || (pDoc->HasRowBreak(nPosY, nTab) & BREAK_MANUAL) == 0 )
1339 rSet.DisableItem( nWhich );
1340 break;
1342 case FID_DEL_COLBRK:
1343 - if ( nPosX==0 || (pDoc->GetColFlags(nPosX,nTab) & CR_MANUALBREAK)==0 )
1344 + if ( nPosX==0 || (pDoc->HasColBreak(nPosX, nTab) & BREAK_MANUAL) == 0 )
1345 rSet.DisableItem( nWhich );
1346 break;
1348 diff --git sc/source/ui/view/gridwin2.cxx sc/source/ui/view/gridwin2.cxx
1349 index 72a6606..4434440 100644
1350 --- sc/source/ui/view/gridwin2.cxx
1351 +++ sc/source/ui/view/gridwin2.cxx
1352 @@ -1278,7 +1278,7 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp )
1353 BOOL bGrow = !bHide && nNew > nPagebreakBreak;
1354 if ( bColumn )
1356 - if ( pDoc->GetColFlags( static_cast<SCCOL>(nPagebreakBreak), nTab ) & CR_MANUALBREAK )
1357 + if (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakBreak), nTab) & BREAK_MANUAL)
1359 ScAddress aOldAddr( static_cast<SCCOL>(nPagebreakBreak), nPosY, nTab );
1360 pViewFunc->DeletePageBreak( TRUE, TRUE, &aOldAddr, FALSE );
1361 @@ -1291,8 +1291,8 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp )
1362 if ( bGrow )
1364 // vorigen Break auf hart, und Skalierung aendern
1365 - if ( static_cast<SCCOL>(nPagebreakPrev) > aPagebreakSource.aStart.Col() &&
1366 - !(pDoc->GetColFlags( static_cast<SCCOL>(nPagebreakPrev), nTab ) & CR_MANUALBREAK) )
1367 + bool bManualBreak = (pDoc->HasColBreak(static_cast<SCCOL>(nPagebreakPrev), nTab) & BREAK_MANUAL);
1368 + if ( static_cast<SCCOL>(nPagebreakPrev) > aPagebreakSource.aStart.Col() && !bManualBreak )
1370 ScAddress aPrev( static_cast<SCCOL>(nPagebreakPrev), nPosY, nTab );
1371 pViewFunc->InsertPageBreak( TRUE, TRUE, &aPrev, FALSE );
1372 @@ -1305,7 +1305,7 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp )
1374 else
1376 - if ( pDoc->GetRowFlags( nPagebreakBreak, nTab ) & CR_MANUALBREAK )
1377 + if (pDoc->HasRowBreak(nPagebreakBreak, nTab) & BREAK_MANUAL)
1379 ScAddress aOldAddr( nPosX, nPagebreakBreak, nTab );
1380 pViewFunc->DeletePageBreak( FALSE, TRUE, &aOldAddr, FALSE );
1381 @@ -1318,8 +1318,8 @@ void ScGridWindow::PagebreakMove( const MouseEvent& rMEvt, BOOL bUp )
1382 if ( bGrow )
1384 // vorigen Break auf hart, und Skalierung aendern
1385 - if ( nPagebreakPrev > aPagebreakSource.aStart.Row() &&
1386 - !(pDoc->GetRowFlags( nPagebreakPrev, nTab ) & CR_MANUALBREAK) )
1387 + bool bManualBreak = (pDoc->HasRowBreak(nPagebreakPrev, nTab) & BREAK_MANUAL);
1388 + if ( nPagebreakPrev > aPagebreakSource.aStart.Row() && !bManualBreak )
1390 ScAddress aPrev( nPosX, nPagebreakPrev, nTab );
1391 pViewFunc->InsertPageBreak( FALSE, TRUE, &aPrev, FALSE );
1392 diff --git sc/source/ui/view/gridwin4.cxx sc/source/ui/view/gridwin4.cxx
1393 index 0e0742a..2e88791 100644
1394 --- sc/source/ui/view/gridwin4.cxx
1395 +++ sc/source/ui/view/gridwin4.cxx
1396 @@ -1090,7 +1090,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
1397 if ( nBreak >= nX1 && nBreak <= nX2+1 )
1399 //! hidden suchen
1400 - if ( pDoc->GetColFlags( nBreak, nTab ) & CR_MANUALBREAK )
1401 + if (pDoc->HasColBreak(nBreak, nTab) & BREAK_MANUAL)
1402 pContentDev->SetFillColor( aManual );
1403 else
1404 pContentDev->SetFillColor( aAutomatic );
1405 @@ -1109,7 +1109,7 @@ void ScGridWindow::DrawPagePreview( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2,
1406 if ( nBreak >= nY1 && nBreak <= nY2+1 )
1408 //! hidden suchen
1409 - if ( pDoc->GetRowFlags( nBreak, nTab ) & CR_MANUALBREAK )
1410 + if (pDoc->HasRowBreak(nBreak, nTab) & BREAK_MANUAL)
1411 pContentDev->SetFillColor( aManual );
1412 else
1413 pContentDev->SetFillColor( aAutomatic );
1414 diff --git sc/source/ui/view/output.cxx sc/source/ui/view/output.cxx
1415 index f320558..1585791 100644
1416 --- sc/source/ui/view/output.cxx
1417 +++ sc/source/ui/view/output.cxx
1418 @@ -325,8 +325,9 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
1419 long nPosX;
1420 long nPosY;
1421 SCSIZE nArrY;
1422 - BYTE nOldFlags = 0;
1423 - BYTE nFlags;
1424 + ScBreakType nBreak = BREAK_NONE;
1425 + ScBreakType nBreakOld = BREAK_NONE;
1427 BOOL bSingle;
1428 Color aPageColor;
1429 Color aManualColor;
1430 @@ -381,27 +382,27 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
1431 if ( bPage )
1433 // Seitenumbrueche auch in ausgeblendeten suchen
1434 - nFlags = 0;
1435 SCCOL nCol = nXplus1;
1436 while (nCol <= MAXCOL)
1438 BYTE nDocFl = pDoc->GetColFlags( nCol, nTab );
1439 - nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK );
1440 - if ( nFlags || !(nDocFl & CR_HIDDEN) )
1441 + nBreak = pDoc->HasColBreak(nCol, nTab);
1443 + if ( nBreak || !(nDocFl & CR_HIDDEN) )
1444 break;
1445 ++nCol;
1448 - if (nFlags != nOldFlags)
1449 + if (nBreak != nBreakOld)
1451 aGrid.Flush();
1452 - pDev->SetLineColor( (nFlags & CR_MANUALBREAK) ? aManualColor :
1453 - (nFlags) ? aPageColor : aGridColor );
1454 - nOldFlags = nFlags;
1455 + pDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
1456 + nBreak ? aPageColor : aGridColor );
1457 + nBreakOld = nBreak;
1461 - BOOL bDraw = bGrid || nOldFlags; // einfaches Gitter nur wenn eingestellt
1462 + BOOL bDraw = bGrid || nBreakOld; // einfaches Gitter nur wenn eingestellt
1464 //! Mit dieser Abfrage wird zuviel weggelassen, wenn ein automatischer
1465 //! Umbruch mitten in den Wiederholungsspalten liegt.
1466 @@ -412,7 +413,7 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
1468 if ( nX == MAXCOL )
1469 bDraw = FALSE;
1470 - else if (pDoc->GetColFlags(nXplus1,nTab) & ( CR_PAGEBREAK | CR_MANUALBREAK ))
1471 + else if (pDoc->HasColBreak(nXplus1, nTab))
1472 bDraw = FALSE;
1474 #endif
1475 @@ -503,28 +504,24 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
1477 if ( bPage )
1479 - // Seitenumbrueche auch in ausgeblendeten suchen
1480 - nFlags = 0;
1481 - ScCompressedArrayIterator< SCROW, BYTE > aIter(
1482 - pDoc->GetRowFlagsArray( nTab), nYplus1, MAXROW);
1483 - do
1484 + for (SCROW i = nYplus1; i <= MAXROW; ++i)
1486 - BYTE nDocFl = *aIter;
1487 - nFlags = nDocFl & ( CR_PAGEBREAK | CR_MANUALBREAK );
1488 - if ( nFlags || !(nDocFl & CR_HIDDEN) )
1489 - break;
1490 - } while (aIter.NextRange());
1491 + nBreak = pDoc->HasRowBreak(i, nTab);
1492 + bool bHidden = (pDoc->GetRowFlags(i, nTab) & CR_HIDDEN);
1493 + if (nBreak || !bHidden)
1494 + break;
1497 - if (nFlags != nOldFlags)
1498 + if (nBreakOld != nBreak)
1500 aGrid.Flush();
1501 - pDev->SetLineColor( (nFlags & CR_MANUALBREAK) ? aManualColor :
1502 - (nFlags) ? aPageColor : aGridColor );
1503 - nOldFlags = nFlags;
1504 + pDev->SetLineColor( (nBreak & BREAK_MANUAL) ? aManualColor :
1505 + (nBreak) ? aPageColor : aGridColor );
1506 + nBreakOld = nBreak;
1510 - BOOL bDraw = bGrid || nOldFlags; // einfaches Gitter nur wenn eingestellt
1511 + BOOL bDraw = bGrid || nBreakOld; // einfaches Gitter nur wenn eingestellt
1513 //! Mit dieser Abfrage wird zuviel weggelassen, wenn ein automatischer
1514 //! Umbruch mitten in den Wiederholungszeilen liegt.
1515 @@ -535,7 +532,7 @@ void ScOutputData::DrawGrid( BOOL bGrid, BOOL bPage )
1517 if ( nY == MAXROW )
1518 bDraw = FALSE;
1519 - else if (pDoc->GetRowFlags(nYplus1,nTab) & ( CR_PAGEBREAK | CR_MANUALBREAK ))
1520 + else if (pDoc->HasRowBreak(nYplus1, nTab))
1521 bDraw = FALSE;
1523 #endif
1524 diff --git sc/source/ui/view/printfun.cxx sc/source/ui/view/printfun.cxx
1525 index 020821d..2ddaa99 100644
1526 --- sc/source/ui/view/printfun.cxx
1527 +++ sc/source/ui/view/printfun.cxx
1528 @@ -2874,30 +2874,84 @@ void ScPrintFunc::CalcZoom( USHORT nRangeNo ) // Zoom berechnen
1529 if (aTableParam.bScalePageNum)
1531 nZoom = 100;
1532 - BOOL bFound = FALSE;
1533 USHORT nPagesToFit = aTableParam.nScalePageNum;
1534 - while (!bFound)
1536 - CalcPages();
1537 - if ( nPagesX * nPagesY <= nPagesToFit || nZoom <= ZOOM_MIN )
1538 - bFound = TRUE;
1539 - else
1540 - --nZoom;
1543 + sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
1544 + while (true)
1546 + if (nZoom <= ZOOM_MIN)
1547 + break;
1549 + CalcPages();
1550 + bool bFitsPage = (nPagesX * nPagesY <= nPagesToFit);
1552 + if (bFitsPage)
1554 + if (nZoom == 100)
1555 + // If it fits at 100 %, it's good enough for me.
1556 + break;
1558 + nLastFitZoom = nZoom;
1559 + nZoom = (nLastNonFitZoom + nZoom) / 2;
1561 + if (nLastFitZoom == nZoom)
1562 + // It converged. Use this zoom level.
1563 + break;
1565 + else
1567 + if (nZoom - nLastFitZoom <= 1)
1569 + nZoom = nLastFitZoom;
1570 + CalcPages();
1571 + break;
1574 + nLastNonFitZoom = nZoom;
1575 + nZoom = (nLastFitZoom + nZoom) / 2;
1579 else if (aTableParam.bScaleTo)
1581 nZoom = 100;
1582 - BOOL bFound = FALSE;
1583 USHORT nW = aTableParam.nScaleWidth;
1584 USHORT nH = aTableParam.nScaleHeight;
1585 - while (!bFound)
1587 + sal_uInt16 nLastFitZoom = 0, nLastNonFitZoom = 0;
1588 + while (true)
1590 + if (nZoom <= ZOOM_MIN)
1591 + break;
1593 CalcPages();
1594 - if ( ((!nW || (nPagesX <= nW)) && (!nH || (nPagesY <= nH))) || (nZoom <= ZOOM_MIN) )
1595 - bFound = TRUE;
1596 + bool bFitsPage = ((!nW || (nPagesX <= nW)) && (!nH || (nPagesY <= nH)));
1598 + if (bFitsPage)
1600 + if (nZoom == 100)
1601 + // If it fits at 100 %, it's good enough for me.
1602 + break;
1604 + nLastFitZoom = nZoom;
1605 + nZoom = (nLastNonFitZoom + nZoom) / 2;
1607 + if (nLastFitZoom == nZoom)
1608 + // It converged. Use this zoom level.
1609 + break;
1611 else
1612 - --nZoom;
1614 + if (nZoom - nLastFitZoom <= 1)
1616 + nZoom = nLastFitZoom;
1617 + CalcPages();
1618 + break;
1621 + nLastNonFitZoom = nZoom;
1622 + nZoom = (nLastFitZoom + nZoom) / 2;
1626 else if (aTableParam.bScaleAll)
1627 @@ -3021,7 +3075,8 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom
1628 for (SCCOL i=nStartCol; i<=nEndCol; i++)
1630 BYTE nFlags = pDoc->GetColFlags(i,nPrintTab);
1631 - if ( i>nStartCol && bVisCol && (nFlags & CR_PAGEBREAK) )
1632 + bool bPageBreak = (pDoc->HasColBreak(i, nPrintTab) & BREAK_PAGE);
1633 + if ( i>nStartCol && bVisCol && bPageBreak )
1635 pPageEndX[nPagesX] = i-1;
1636 ++nPagesX;
1637 @@ -3046,7 +3101,8 @@ void ScPrintFunc::CalcPages() // berechnet aPageRect und Seiten aus nZoom
1638 SCROW nRangeEnd = aIter.GetRangeEnd();
1639 for (SCROW j=aIter.GetRangeStart(); j<=nRangeEnd; ++j)
1641 - if ( j>nStartRow && bVisRow && (nFlags & CR_PAGEBREAK) )
1642 + bool bPageBreak = (pDoc->HasRowBreak(j, nPrintTab) & BREAK_PAGE);
1643 + if ( j>nStartRow && bVisRow && bPageBreak )
1645 pPageEndY[nTotalY] = j-1;
1646 ++nTotalY;