merge the formfield patch from ooo-build
[ooovba.git] / applied_patches / 0193-calc-perf-copy-table-flags.diff
blob40b728c7c14d1648017b6a2bcafd7aa1eb3d452d
1 diff --git sc/source/core/data/table2.cxx sc/source/core/data/table2.cxx
2 index 889510f..0857312 100644
3 --- sc/source/core/data/table2.cxx
4 +++ sc/source/core/data/table2.cxx
5 @@ -663,6 +663,8 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
6 // Charts muessen beim Ein-/Ausblenden angepasst werden
7 ScChartListenerCollection* pCharts = pDestTab->pDocument->GetChartListenerCollection();
9 + bool bFlagChange = false;
11 BOOL bWidth = (nRow1==0 && nRow2==MAXROW && pColWidth && pDestTab->pColWidth);
12 BOOL bHeight = (nCol1==0 && nCol2==MAXCOL && pRowHeight && pDestTab->pRowHeight);
14 @@ -673,18 +675,18 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
15 if (bWidth)
16 for (SCCOL i=nCol1; i<=nCol2; i++)
18 - bool bThisHidden = ColHidden(i);
19 - bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden);
20 + bool bThisHidden = ColHidden(i);
21 + bool bHiddenChange = (pDestTab->ColHidden(i) != bThisHidden);
22 bool bChange = bHiddenChange || (pDestTab->pColWidth[i] != pColWidth[i]);
23 pDestTab->pColWidth[i] = pColWidth[i];
24 pDestTab->pColFlags[i] = pColFlags[i];
25 - pDestTab->SetColHidden(i, i, bThisHidden);
26 + pDestTab->SetColHidden(i, i, bThisHidden);
27 //! Aenderungen zusammenfassen?
28 if (bHiddenChange && pCharts)
29 pCharts->SetRangeDirty(ScRange( i, 0, nTab, i, MAXROW, nTab ));
31 if (bChange)
32 - pDestTab->InvalidatePageBreaks();
33 + bFlagChange = true;
36 if (bHeight)
37 @@ -692,28 +694,45 @@ void ScTable::CopyToTable(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
38 bool bChange = pDestTab->pRowHeight->SumValues(nRow1, nRow2) != pRowHeight->SumValues(nRow1, nRow2);
40 if (bChange)
41 - pDestTab->InvalidatePageBreaks();
42 + bFlagChange = true;
44 pDestTab->pRowHeight->CopyFrom( *pRowHeight, nRow1, nRow2);
45 - for (SCROW i=nRow1; i<=nRow2; i++)
46 - {
47 - // TODO: might need some performance improvement, block
48 - // operations instead of single GetValue()/SetValue() calls.
49 - BYTE nThisRowFlags = pRowFlags->GetValue(i);
50 - bool bThisHidden = RowHidden(i);
51 - bool bHiddenChange = (pDestTab->RowHidden(i) != bThisHidden);
52 - pDestTab->pRowFlags->SetValue( i, nThisRowFlags );
53 - pDestTab->SetRowHidden(i, i, bThisHidden);
54 - //! Aenderungen zusammenfassen?
55 - if (bHiddenChange && pCharts)
56 - pCharts->SetRangeDirty(ScRange( 0, i, nTab, MAXCOL, i, nTab ));
57 + pDestTab->pRowFlags->CopyFrom(*pRowFlags, nRow1, nRow2);
59 - if (bHiddenChange)
60 - pDestTab->InvalidatePageBreaks();
61 + for (SCROW i = nRow1; i <= nRow2; ++i)
62 + {
63 + SCROW nThisLastRow, nDestLastRow;
64 + bool bThisHidden = RowHidden(i, nThisLastRow);
65 + bool bDestHidden = pDestTab->RowHidden(i, nDestLastRow);
67 + // If the segment sizes differ, we take the shorter segment of the two.
68 + SCROW nLastRow = ::std::min(nThisLastRow, nDestLastRow);
69 + if (nLastRow >= nRow2)
70 + // the last row shouldn't exceed the upper bound the caller specified.
71 + nLastRow = nRow2;
73 + pDestTab->SetRowHidden(i, nLastRow, bThisHidden);
75 + bool bThisHiddenChange = (bThisHidden != bDestHidden);
76 + if (bThisHiddenChange && pCharts)
77 + {
78 + // Hidden flags differ.
79 + pCharts->SetRangeDirty(ScRange(0, i, nTab, MAXCOL, nLastRow, nTab));
80 + }
82 + if (bThisHiddenChange)
83 + bFlagChange = true;
85 + // Jump to the last row of the identical flag segment.
86 + i = nLastRow;
89 pDestTab->DecRecalcLevel();
92 + if (bFlagChange)
93 + pDestTab->InvalidatePageBreaks();
95 pDestTab->SetOutlineTable( pOutlineTable ); // auch nur wenn bColRowFlags