diff options
author | Eike Rathke <erack@redhat.com> | 2011-11-28 12:41:50 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2011-11-28 15:25:34 +0100 |
commit | 42e80ec68bc1f4d2dfd62b82116790687321d231 (patch) | |
tree | cf626212f7c1d11a10e5dc667c99b947cdc72f24 /sc | |
parent | 62e8e2a31a9344ee40a5ebde6fe7559290efb300 (diff) |
dr80: #i116460# performance of Excel file with many outlines
# HG changeset patch
# User Niklas Nebel <nn@openoffice.org>
# Date 1300438660 -3600
# Node ID aa7d08a12d7ee60c71eb4f2dc1241197e009c443
# Parent 49c53fbe0cd4d663f419b659c82618bd106282ef
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/unonames.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/drwlayer.cxx | 23 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 10 | ||||
-rw-r--r-- | sc/source/filter/excel/colrowst.cxx | 5 | ||||
-rw-r--r-- | sc/source/ui/docshell/olinefun.cxx | 69 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 6 |
6 files changed, 87 insertions, 28 deletions
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx index 72070af32f30..a4417ec06824 100644 --- a/sc/inc/unonames.hxx +++ b/sc/inc/unonames.hxx @@ -179,6 +179,8 @@ #define SC_UNONAME_AUTOPRINT "AutomaticPrintArea" #define SC_UNONAME_TABCOLOR "TabColor" +#define SC_UNONAME_VISFLAG "VisibleFlag" + // LinkTarget #define SC_UNO_LINKDISPBIT "LinkDisplayBitmap" #define SC_UNO_LINKDISPNAME "LinkDisplayName" diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index 997e5160e40f..58b591cec3e1 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -959,6 +959,15 @@ void ScDrawLayer::MoveArea( SCTAB nTab, SCCOL nCol1,SCROW nRow1, SCCOL nCol2,SCR if (!bAdjustEnabled) return; + SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab)); + OSL_ENSURE(pPage,"Page not found"); + if (!pPage) + return; + + // for an empty page, there's no need to calculate the row heights + if (!pPage->GetObjCount()) + return; + sal_Bool bNegativePage = pDoc->IsNegativePage( nTab ); Rectangle aRect = pDoc->GetMMRect( nCol1, nRow1, nCol2, nRow2, nTab ); @@ -1003,6 +1012,15 @@ sal_Bool ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndR if ( !pDoc ) return false; + SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab)); + OSL_ENSURE(pPage,"Page not found"); + if (!pPage) + return sal_False; + + // for an empty page, there's no need to calculate the row heights + if (!pPage->GetObjCount()) + return sal_False; + Rectangle aTestRect; aTestRect.Top() += pDoc->GetRowHeight( 0, nStartRow-1, nTab); @@ -1025,11 +1043,6 @@ sal_Bool ScDrawLayer::HasObjectsInRows( SCTAB nTab, SCROW nStartRow, SCROW nEndR if ( bNegativePage ) MirrorRectRTL( aTestRect ); - SdrPage* pPage = GetPage(static_cast<sal_uInt16>(nTab)); - OSL_ENSURE(pPage,"Page nicht gefunden"); - if (!pPage) - return false; - sal_Bool bFound = false; Rectangle aObjRect; diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 52b83b10a9fa..e03c285a72ed 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -161,10 +161,12 @@ struct SetRowHeightRangeFunc : public OptimalHeightsFuncObjBase } }; -bool SetOptimalHeightsToRows(OptimalHeightsFuncObjBase& rFuncObj, +bool SetOptimalHeightsToRows( OptimalHeightsFuncObjBase& rFuncObj, ScTable* pTab, ScBitMaskCompressedArray<SCROW, sal_uInt8>* pRowFlags, SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtra, const vector<sal_uInt16>& aHeights, bool bForce) { + pTab->IncRecalcLevel(); // #i116460# avoid problems with Excel files + SCSIZE nCount = static_cast<SCSIZE>(nEndRow-nStartRow+1); bool bChanged = false; SCROW nRngStart = 0; @@ -221,6 +223,8 @@ bool SetOptimalHeightsToRows(OptimalHeightsFuncObjBase& rFuncObj, if (nLast) bChanged |= rFuncObj(nRngStart, nRngEnd, nLast); + pTab->DecRecalcLevel(); // #i116460# avoid problems with Excel files + return bChanged; } @@ -478,7 +482,7 @@ bool ScTable::SetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16 nExtr SetRowHeightRangeFunc aFunc(this, nPPTX, nPPTY); bool bChanged = SetOptimalHeightsToRows( - aFunc, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce); + aFunc, this, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce); if ( pProgress != pOuterProgress ) delete pProgress; @@ -509,7 +513,7 @@ void ScTable::SetOptimalHeightOnly( SCROW nStartRow, SCROW nEndRow, sal_uInt16 n SetRowHeightOnlyFunc aFunc(this); SetOptimalHeightsToRows( - aFunc, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce); + aFunc, this, pRowFlags, nStartRow, nEndRow, nExtra, aHeights, bForce); if ( pProgress != pOuterProgress ) delete pProgress; diff --git a/sc/source/filter/excel/colrowst.cxx b/sc/source/filter/excel/colrowst.cxx index bc6ca42e42af..8da41c98d2d1 100644 --- a/sc/source/filter/excel/colrowst.cxx +++ b/sc/source/filter/excel/colrowst.cxx @@ -297,6 +297,7 @@ void XclImpColRowSettings::Convert( SCTAB nScTab ) void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab ) { ScDocument& rDoc = GetDoc(); + rDoc.IncSizeRecalcLevel( nScTab ); // #i116460# performance with many hidden rows // hide the columns for( SCCOL nScCol = 0; nScCol <= MAXCOL; ++nScCol ) @@ -340,7 +341,7 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab ) { if (bPrevHidden) { - rDoc.ShowRows(nPrevRow, nRow-1, nScTab, false); + rDoc.SetRowHidden(nPrevRow, nRow-1, nScTab, true); // #i116460# SetRowHidden instead of ShowRow // #i38093# rows hidden by filter need extra flag if (nFirstFilterScRow <= nPrevRow && nPrevRow <= nLastFilterScRow) { @@ -357,6 +358,8 @@ void XclImpColRowSettings::ConvertHiddenFlags( SCTAB nScTab ) // #i47438# if default row format is hidden, hide remaining rows if( ::get_flag( mnDefRowFlags, EXC_DEFROW_HIDDEN ) && (mnLastScRow < MAXROW) ) rDoc.ShowRows( mnLastScRow + 1, MAXROW, nScTab, false ); + + rDoc.DecSizeRecalcLevel( nScTab ); // #i116460# performance with many hidden rows } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/olinefun.cxx b/sc/source/ui/docshell/olinefun.cxx index 3f0a3a1bedf5..92dc97f84ee6 100644 --- a/sc/source/ui/docshell/olinefun.cxx +++ b/sc/source/ui/docshell/olinefun.cxx @@ -391,6 +391,8 @@ sal_Bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, sal_Bool bColumns, sal_uInt1 bColumns, nLevel ) ); } + pDoc->IncSizeRecalcLevel( nTab ); + pDoc->InitializeNoteCaptions(nTab); ScSubOutlineIterator aIter( pArray ); // alle Eintraege ScOutlineEntry* pEntry; @@ -420,11 +422,19 @@ sal_Bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, sal_Bool bColumns, sal_uInt1 if ( bColumns ) pDoc->ShowCol( static_cast<SCCOL>(i), nTab, bShow ); else - if ( !bShow || !pDoc->RowFiltered( i,nTab ) ) - pDoc->ShowRow( i, nTab, bShow ); + { + // show several rows together, don't show filtered rows + SCROW nFilterEnd = i; + bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd ); + nFilterEnd = std::min( nThisEnd, nFilterEnd ); + if ( !bShow || !bFiltered ) + pDoc->ShowRows( i, nFilterEnd, nTab, bShow ); + i = nFilterEnd; + } } } + pDoc->DecSizeRecalcLevel( nTab ); pDoc->SetDrawPageSize(nTab); pDoc->UpdatePageBreaks( nTab ); @@ -479,6 +489,8 @@ sal_Bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, sal_Bool b pUndoDoc, pUndoTab, sal_True ) ); } + pDoc->IncSizeRecalcLevel( nTab ); + // Spalten nMin=MAXCOL; @@ -520,9 +532,17 @@ sal_Bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, sal_Bool b } } for ( i=nMin; i<=nMax; i++ ) - if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden - pDoc->ShowRow( i, nTab, sal_True ); + { + // show several rows together, don't show filtered rows + SCROW nFilterEnd = i; + bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd ); + nFilterEnd = std::min( nMax, nFilterEnd ); + if ( !bFiltered ) + pDoc->ShowRows( i, nFilterEnd, nTab, sal_True ); + i = nFilterEnd; + } + pDoc->DecSizeRecalcLevel( nTab ); pDoc->SetDrawPageSize(nTab); pDoc->UpdatePageBreaks( nTab ); @@ -592,6 +612,8 @@ sal_Bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, sal_Bool b pUndoDoc, pUndoTab, false ) ); } + pDoc->IncSizeRecalcLevel( nTab ); + // Spalten nCount = pColArray->GetCount(nColLevel); @@ -618,6 +640,7 @@ sal_Bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, sal_Bool b HideOutline( nTab, false, nRowLevel, i, false, false, bApi ); } + pDoc->DecSizeRecalcLevel( nTab ); pDoc->UpdatePageBreaks( nTab ); rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP ); @@ -673,6 +696,8 @@ sal_Bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, sal_Bool bColumns, sal_uInt1 //! HideCursor(); + pDoc->IncSizeRecalcLevel( nTab ); + pDoc->InitializeNoteCaptions(nTab); pEntry->SetHidden(false); SCCOLROW i; @@ -681,8 +706,15 @@ sal_Bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, sal_Bool bColumns, sal_uInt1 if ( bColumns ) pDoc->ShowCol( static_cast<SCCOL>(i), nTab, sal_True ); else - if ( !pDoc->RowFiltered( i,nTab ) ) // weggefilterte nicht einblenden - pDoc->ShowRow( i, nTab, sal_True ); + { + // show several rows together, don't show filtered rows + SCROW nFilterEnd = i; + bool bFiltered = pDoc->RowFiltered( i, nTab, NULL, &nFilterEnd ); + nFilterEnd = std::min( nEnd, nFilterEnd ); + if ( !bFiltered ) + pDoc->ShowRows( i, nFilterEnd, nTab, sal_True ); + i = nFilterEnd; + } } ScSubOutlineIterator aIter( pArray, nLevel, nEntry ); @@ -692,13 +724,11 @@ sal_Bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, sal_Bool bColumns, sal_uInt1 { SCCOLROW nSubStart = pEntry->GetStart(); SCCOLROW nSubEnd = pEntry->GetEnd(); - for ( i = nSubStart; i <= nSubEnd; i++ ) - { - if ( bColumns ) + if ( bColumns ) + for ( i = nSubStart; i <= nSubEnd; i++ ) pDoc->ShowCol( static_cast<SCCOL>(i), nTab, false ); - else - pDoc->ShowRow( i, nTab, false ); - } + else + pDoc->ShowRows( nSubStart, nSubEnd, nTab, sal_False ); } } @@ -759,19 +789,20 @@ sal_Bool ScOutlineDocFunc::HideOutline( SCTAB nTab, sal_Bool bColumns, sal_uInt1 //! HideCursor(); + pDoc->IncSizeRecalcLevel( nTab ); + pDoc->InitializeNoteCaptions(nTab); pEntry->SetHidden(true); SCCOLROW i; - for ( i = nStart; i <= nEnd; i++ ) - { - if ( bColumns ) - pDoc->ShowCol( static_cast<SCCOL>(i), nTab, false ); - else - pDoc->ShowRow( i, nTab, false ); - } + if ( bColumns ) + for ( i = nStart; i <= nEnd; i++ ) + pDoc->ShowCol( static_cast<SCCOL>(i), nTab, sal_False ); + else + pDoc->ShowRows( nStart, nEnd, nTab, sal_False ); pArray->SetVisibleBelow( nLevel, nEntry, false ); + pDoc->DecSizeRecalcLevel( nTab ); pDoc->SetDrawPageSize(nTab); pDoc->InvalidatePageBreaks(nTab); pDoc->UpdatePageBreaks( nTab ); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 31bb2e3deff8..affcb56e228f 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -3267,6 +3267,12 @@ void SAL_CALL ScTableRowsObj::setPropertyValue( aFunc.SetWidthOrHeight( false, 1, nRowArr, nTab, eMode, 0, sal_True, sal_True ); // SC_SIZE_DIRECT with size 0: hide } + else if ( aNameString.EqualsAscii( SC_UNONAME_VISFLAG ) ) + { + // #i116460# Shortcut to only set the flag, without drawing layer update etc. + // Should only be used from import filters. + pDoc->SetRowHidden(nStartRow, nEndRow, nTab, !ScUnoHelpFunctions::GetBoolFromAny( aValue )); + } else if ( aNameString.EqualsAscii( SC_UNONAME_CELLFILT ) ) { //! undo etc. |