sc/source/core/data/documen8.cxx | 205 +++++++++++++++++++-------------------- 1 file changed, 100 insertions(+), 105 deletions(-)
New commits: commit 763d8dad024d8b4307fb21e81b87d46f78346f06 Author: Kohei Yoshida <[email protected]> Date: Wed Mar 13 15:48:08 2013 -0400 Reduce scope level. Change-Id: I28db9130864ac3408398834bfbbdeb904ca4948e diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 9ac10a7..6b50d12 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -549,131 +549,133 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers ScStyleSheet* pStyle = (ScStyleSheet*)aScope.getStylePool()->Find(pTable->aPageStyle, SFX_STYLE_FAMILY_PAGE); OSL_ENSURE( pStyle, "Missing StyleSheet :-/" ); - if (pStyle && 0 == getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES)) + if (!pStyle || getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES) == 0) { - sal_uInt16 nRestart = 0; - sal_uInt16 nCount = 0; - ScBaseCell* pCell = NULL; + // Move to the next sheet as the current one has scale-to-pages set, + // and bail out. + aScope.incTab(); + return false; + } - sal_uInt16 nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); - Fraction aZoomFract( nZoom, 100 ); + sal_uInt16 nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); + Fraction aZoomFract(nZoom, 100); - // Start at specified cell position (nCol, nRow, nTab). - ScColumn* pColumn = &pTable->aCol[aScope.Col()]; - boost::scoped_ptr<ScColumnIterator> pColIter( - new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); + // Start at specified cell position (nCol, nRow, nTab). + ScColumn* pColumn = &pTable->aCol[aScope.Col()]; + boost::scoped_ptr<ScColumnIterator> pColIter( + new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); - OutputDevice* pDev = NULL; - while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) ) + OutputDevice* pDev = NULL; + sal_uInt16 nRestart = 0; + sal_uInt16 nCount = 0; + while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) ) + { + SCROW nRow; + ScBaseCell* pCell = NULL; + if ( pColIter->Next(nRow, pCell) ) { - SCROW nRow; - if ( pColIter->Next(nRow, pCell) ) - { - // More cell in this column. - aScope.setRow(nRow); + // More cell in this column. + aScope.setRow(nRow); - if ( TEXTWIDTH_DIRTY == pCell->GetTextWidth() ) + if ( TEXTWIDTH_DIRTY == pCell->GetTextWidth() ) + { + // Calculate text width for this cell. + double nPPTX = 0.0; + double nPPTY = 0.0; + if ( !pDev ) { - // Calculate text width for this cell. - double nPPTX = 0.0; - double nPPTY = 0.0; - if ( !pDev ) - { - pDev = GetPrinter(); - aScope.setOldMapMode(pDev->GetMapMode()); - pDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize + pDev = GetPrinter(); + aScope.setOldMapMode(pDev->GetMapMode()); + pDev->SetMapMode( MAP_PIXEL ); // wichtig fuer GetNeededSize - Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); - nPPTX = aPix1000.X() / 1000.0; - nPPTY = aPix1000.Y() / 1000.0; - } + Point aPix1000 = pDev->LogicToPixel( Point(1000,1000), MAP_TWIP ); + nPPTX = aPix1000.X() / 1000.0; + nPPTY = aPix1000.Y() / 1000.0; + } - if (!aScope.hasProgressBar() && pCell->GetCellType() == CELLTYPE_FORMULA - && ((ScFormulaCell*)pCell)->GetDirty()) - { - aScope.createProgressBar(); - } + if (!aScope.hasProgressBar() && pCell->GetCellType() == CELLTYPE_FORMULA + && ((ScFormulaCell*)pCell)->GetDirty()) + { + aScope.createProgressBar(); + } - sal_uInt16 nNewWidth = (sal_uInt16)GetNeededSize( - aScope.Col(), aScope.Row(), aScope.Tab(), - pDev, nPPTX, nPPTY, aZoomFract,aZoomFract, true, true); // bTotalSize + sal_uInt16 nNewWidth = (sal_uInt16)GetNeededSize( + aScope.Col(), aScope.Row(), aScope.Tab(), + pDev, nPPTX, nPPTY, aZoomFract,aZoomFract, true, true); // bTotalSize - pCell->SetTextWidth( nNewWidth ); - aScope.setNeedMore(true); - } + pCell->SetTextWidth( nNewWidth ); + aScope.setNeedMore(true); } - else - { - // No more cell in this column. Move to the left column and start at row 0. + } + else + { + // No more cell in this column. Move to the left column and start at row 0. - bool bNewTab = false; + bool bNewTab = false; - aScope.setRow(0); - aScope.incCol(-1); + aScope.setRow(0); + aScope.incCol(-1); - if (aScope.Col() < 0) - { - // No more column to the left. Move to the right-most column of the next sheet. - aScope.setCol(MAXCOL); - aScope.incTab(); - bNewTab = true; - } + if (aScope.Col() < 0) + { + // No more column to the left. Move to the right-most column of the next sheet. + aScope.setCol(MAXCOL); + aScope.incTab(); + bNewTab = true; + } - if (!ValidTab(aScope.Tab()) || aScope.Tab() >= static_cast<SCTAB>(maTabs.size()) || !maTabs[aScope.Tab()] ) - { - // Sheet doesn't exist at specified sheet position. Restart at sheet 0. - aScope.setTab(0); - nRestart++; - bNewTab = true; - } + if (!ValidTab(aScope.Tab()) || aScope.Tab() >= static_cast<SCTAB>(maTabs.size()) || !maTabs[aScope.Tab()] ) + { + // Sheet doesn't exist at specified sheet position. Restart at sheet 0. + aScope.setTab(0); + nRestart++; + bNewTab = true; + } - if ( nRestart < 2 ) + if ( nRestart < 2 ) + { + if ( bNewTab ) { - if ( bNewTab ) - { - pTable = maTabs[aScope.Tab()]; - pStyle = (ScStyleSheet*)aScope.getStylePool()->Find( - pTable->aPageStyle, SFX_STYLE_FAMILY_PAGE); + pTable = maTabs[aScope.Tab()]; + pStyle = (ScStyleSheet*)aScope.getStylePool()->Find( + pTable->aPageStyle, SFX_STYLE_FAMILY_PAGE); - if ( pStyle ) + if ( pStyle ) + { + // Check if the scale-to-pages setting is set. If + // set, we exit the loop. If not, get the page + // scale factor of the new sheet. + if (getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES) == 0) { - // Check if the scale-to-pages setting is set. If - // set, we exit the loop. If not, get the page - // scale factor of the new sheet. - if (getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES) == 0) - { - nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); - aZoomFract = Fraction(nZoom, 100); - } - else - nZoom = 0; + nZoom = getScaleValue(*pStyle, ATTR_PAGE_SCALE); + aZoomFract = Fraction(nZoom, 100); } else - { - OSL_FAIL( "Missing StyleSheet :-/" ); - } + nZoom = 0; } - - if ( nZoom > 0 ) + else { - pColumn = &pTable->aCol[aScope.Col()]; - pColIter.reset(new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); + OSL_FAIL( "Missing StyleSheet :-/" ); } - else - aScope.incTab(); // Move to the next sheet as the current one has scale-to-pages set. } + + if ( nZoom > 0 ) + { + pColumn = &pTable->aCol[aScope.Col()]; + pColIter.reset(new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); + } + else + aScope.incTab(); // Move to the next sheet as the current one has scale-to-pages set. } + } - nCount++; + nCount++; - // Quit if either 1) its duration exceeds 50 ms, or 2) there is - // any pending event after processing 32 cells. - if ((50L < Time::GetSystemTicks() - aScope.getStartTime()) || (nCount > 31 && Application::AnyInput(ABORT_EVENTS))) - nCount = CALCMAX; - } + // Quit if either 1) its duration exceeds 50 ms, or 2) there is any + // pending event after processing 32 cells. + if ((50L < Time::GetSystemTicks() - aScope.getStartTime()) || (nCount > 31 && Application::AnyInput(ABORT_EVENTS))) + nCount = CALCMAX; } - else - aScope.incTab(); // Move to the next sheet as the current one has scale-to-pages set. return aScope.getNeedMore(); } commit a16c153b096f46e035b41f5127b516f14d4d54de Author: Kohei Yoshida <[email protected]> Date: Wed Mar 13 15:33:41 2013 -0400 A bit more re-organization. Change-Id: Ie722a910303ff8852c164ccc9ae256d52f4695f0 diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index 541e709..9ac10a7 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -87,6 +87,7 @@ #include "scresid.hxx" #include <memory> +#include <boost/scoped_ptr.hpp> // states for online spelling in the visible range (0 is set initially) #define VSPL_START 0 @@ -529,11 +530,6 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers IdleCalcTextWidthScope aScope(*this, aCurTextWidthCalcPos); - OutputDevice* pDev = NULL; - ScStyleSheet* pStyle = NULL; - ScColumnIterator* pColIter = NULL; - ScTable* pTable = NULL; - if (!ValidRow(aScope.Row())) { aScope.setRow(0); @@ -549,9 +545,8 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers if (!ValidTab(aScope.Tab()) || aScope.Tab() >= static_cast<SCTAB>(maTabs.size()) || !maTabs[aScope.Tab()]) aScope.setTab(0); - pTable = maTabs[aScope.Tab()]; - pStyle = (ScStyleSheet*)aScope.getStylePool()->Find(pTable->aPageStyle, SFX_STYLE_FAMILY_PAGE); - + ScTable* pTable = maTabs[aScope.Tab()]; + ScStyleSheet* pStyle = (ScStyleSheet*)aScope.getStylePool()->Find(pTable->aPageStyle, SFX_STYLE_FAMILY_PAGE); OSL_ENSURE( pStyle, "Missing StyleSheet :-/" ); if (pStyle && 0 == getScaleValue(*pStyle, ATTR_PAGE_SCALETOPAGES)) @@ -565,8 +560,10 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers // Start at specified cell position (nCol, nRow, nTab). ScColumn* pColumn = &pTable->aCol[aScope.Col()]; - pColIter = new ScColumnIterator(pColumn, aScope.Row(), MAXROW); + boost::scoped_ptr<ScColumnIterator> pColIter( + new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); + OutputDevice* pDev = NULL; while ( (nZoom > 0) && (nCount < CALCMAX) && (nRestart < 2) ) { SCROW nRow; @@ -659,10 +656,8 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers if ( nZoom > 0 ) { - delete pColIter; - pColumn = &pTable->aCol[aScope.Col()]; - pColIter = new ScColumnIterator( pColumn, aScope.Row(), MAXROW ); + pColIter.reset(new ScColumnIterator(pColumn, aScope.Row(), MAXROW)); } else aScope.incTab(); // Move to the next sheet as the current one has scale-to-pages set. @@ -680,8 +675,6 @@ bool ScDocument::IdleCalcTextWidth() // true = demnaechst wieder vers else aScope.incTab(); // Move to the next sheet as the current one has scale-to-pages set. - delete pColIter; - return aScope.getNeedMore(); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
