diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-22 21:35:44 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-22 21:49:26 -0400 |
commit | f9bf7f4d2c95a42671c4ba136a445e794538093c (patch) | |
tree | a3b5124ac77a7da97c22aca6405f3b15d8aec450 /sc/source | |
parent | a9a7f2501228e0f47085d937fc3727f1a452249f (diff) |
More ScCellIterator usage conversion. The rest are non-trivial...
Change-Id: I965e023d00306334f2b1aa7d3d92c90d44769b76
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/detfunc.cxx | 188 | ||||
-rw-r--r-- | sc/source/ui/app/transobj.cxx | 108 |
2 files changed, 145 insertions, 151 deletions
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 09881b4e6607..55bea538be2a 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -1029,87 +1029,85 @@ sal_uInt16 ScDetectiveFunc::InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiv sal_uInt16 ScDetectiveFunc::InsertSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, ScDetectiveData& rData, sal_uInt16 nLevel ) { - // ueber ganzes Dokument + // over the entire document. sal_uInt16 nResult = DET_INS_EMPTY; - ScCellIterator aCellIter( pDoc, 0,0,0, MAXCOL,MAXROW,MAXTAB ); // alle Tabellen - ScBaseCell* pCell = aCellIter.GetFirst(); - while (pCell) + ScCellIterator aCellIter(pDoc, ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB)); // all sheets + for (bool bHas = aCellIter.first(); bHas; bHas = aCellIter.next()) { - if (pCell->GetCellType() == CELLTYPE_FORMULA) - { - ScFormulaCell* pFCell = (ScFormulaCell*)pCell; - sal_Bool bRunning = pFCell->IsRunning(); + if (aCellIter.getType() != CELLTYPE_FORMULA) + continue; + + ScFormulaCell* pFCell = aCellIter.getFormulaCell(); + bool bRunning = pFCell->IsRunning(); - if (pFCell->GetDirty()) - pFCell->Interpret(); // nach SetRunning geht's nicht mehr! - pFCell->SetRunning(sal_True); + if (pFCell->GetDirty()) + pFCell->Interpret(); // nach SetRunning geht's nicht mehr! + pFCell->SetRunning(true); - ScDetectiveRefIter aIter( (ScFormulaCell*) pCell ); - ScRange aRef; - while ( aIter.GetNextRef( aRef) ) + ScDetectiveRefIter aIter(pFCell); + ScRange aRef; + while ( aIter.GetNextRef( aRef) ) + { + if (aRef.aStart.Tab() <= nTab && aRef.aEnd.Tab() >= nTab) { - if (aRef.aStart.Tab() <= nTab && aRef.aEnd.Tab() >= nTab) + if (Intersect( nCol1,nRow1,nCol2,nRow2, + aRef.aStart.Col(),aRef.aStart.Row(), + aRef.aEnd.Col(),aRef.aEnd.Row() )) { - if (Intersect( nCol1,nRow1,nCol2,nRow2, - aRef.aStart.Col(),aRef.aStart.Row(), - aRef.aEnd.Col(),aRef.aEnd.Row() )) + sal_Bool bAlien = ( aCellIter.GetPos().Tab() != nTab ); + sal_Bool bDrawRet; + if (bAlien) + bDrawRet = DrawAlienEntry( aRef, rData ); + else + bDrawRet = DrawEntry( aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), + aRef, rData ); + if (bDrawRet) { - sal_Bool bAlien = ( aCellIter.GetPos().Tab() != nTab ); - sal_Bool bDrawRet; - if (bAlien) - bDrawRet = DrawAlienEntry( aRef, rData ); - else - bDrawRet = DrawEntry( aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), - aRef, rData ); - if (bDrawRet) + nResult = DET_INS_INSERTED; // neuer Pfeil eingetragen + } + else + { + if (bRunning) { - nResult = DET_INS_INSERTED; // neuer Pfeil eingetragen + if (nResult == DET_INS_EMPTY) + nResult = DET_INS_CIRCULAR; } else { - if (bRunning) - { - if (nResult == DET_INS_EMPTY) - nResult = DET_INS_CIRCULAR; - } - else - { - // weiterverfolgen + // weiterverfolgen - if ( nLevel < rData.GetMaxLevel() ) + if ( nLevel < rData.GetMaxLevel() ) + { + sal_uInt16 nSubResult = InsertSuccLevel( + aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), + aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), + rData, nLevel+1 ); + switch (nSubResult) { - sal_uInt16 nSubResult = InsertSuccLevel( - aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), - aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), - rData, nLevel+1 ); - switch (nSubResult) - { - case DET_INS_INSERTED: - nResult = DET_INS_INSERTED; - break; - case DET_INS_CONTINUE: - if (nResult != DET_INS_INSERTED) - nResult = DET_INS_CONTINUE; - break; - case DET_INS_CIRCULAR: - if (nResult == DET_INS_EMPTY) - nResult = DET_INS_CIRCULAR; - break; - // DET_INS_EMPTY: unveraendert lassen - } + case DET_INS_INSERTED: + nResult = DET_INS_INSERTED; + break; + case DET_INS_CONTINUE: + if (nResult != DET_INS_INSERTED) + nResult = DET_INS_CONTINUE; + break; + case DET_INS_CIRCULAR: + if (nResult == DET_INS_EMPTY) + nResult = DET_INS_CIRCULAR; + break; + // DET_INS_EMPTY: unveraendert lassen } - else // nMaxLevel erreicht - if (nResult != DET_INS_INSERTED) - nResult = DET_INS_CONTINUE; } + else // nMaxLevel erreicht + if (nResult != DET_INS_INSERTED) + nResult = DET_INS_CONTINUE; } } } } - pFCell->SetRunning(bRunning); } - pCell = aCellIter.GetNext(); + pFCell->SetRunning(bRunning); } return nResult; @@ -1124,54 +1122,52 @@ sal_uInt16 ScDetectiveFunc::FindSuccLevel( SCCOL nCol1, SCROW nRow1, SCCOL nCol2 sal_Bool bDelete = ( nDeleteLevel && nLevel == nDeleteLevel-1 ); ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab ); - ScBaseCell* pCell = aCellIter.GetFirst(); - while (pCell) + for (bool bHas = aCellIter.first(); bHas; bHas = aCellIter.next()) { - if (pCell->GetCellType() == CELLTYPE_FORMULA) - { - ScFormulaCell* pFCell = (ScFormulaCell*)pCell; - sal_Bool bRunning = pFCell->IsRunning(); + if (aCellIter.getType() != CELLTYPE_FORMULA) + continue; + + ScFormulaCell* pFCell = aCellIter.getFormulaCell(); + bool bRunning = pFCell->IsRunning(); - if (pFCell->GetDirty()) - pFCell->Interpret(); // nach SetRunning geht's nicht mehr! - pFCell->SetRunning(sal_True); + if (pFCell->GetDirty()) + pFCell->Interpret(); // nach SetRunning geht's nicht mehr! + pFCell->SetRunning(true); - ScDetectiveRefIter aIter( (ScFormulaCell*) pCell ); - ScRange aRef; - while ( aIter.GetNextRef( aRef) ) + ScDetectiveRefIter aIter(pFCell); + ScRange aRef; + while ( aIter.GetNextRef( aRef) ) + { + if (aRef.aStart.Tab() <= nTab && aRef.aEnd.Tab() >= nTab) { - if (aRef.aStart.Tab() <= nTab && aRef.aEnd.Tab() >= nTab) + if (Intersect( nCol1,nRow1,nCol2,nRow2, + aRef.aStart.Col(),aRef.aStart.Row(), + aRef.aEnd.Col(),aRef.aEnd.Row() )) { - if (Intersect( nCol1,nRow1,nCol2,nRow2, - aRef.aStart.Col(),aRef.aStart.Row(), - aRef.aEnd.Col(),aRef.aEnd.Row() )) + if ( bDelete ) // Pfeile, die hier anfangen { - if ( bDelete ) // Pfeile, die hier anfangen - { - if (aRef.aStart != aRef.aEnd) - { - DeleteBox( aRef.aStart.Col(), aRef.aStart.Row(), - aRef.aEnd.Col(), aRef.aEnd.Row() ); - } - DeleteArrowsAt( aRef.aStart.Col(), aRef.aStart.Row(), false ); - } - else if ( !bRunning && - HasArrow( aRef.aStart, - aCellIter.GetPos().Col(),aCellIter.GetPos().Row(),aCellIter.GetPos().Tab() ) ) + if (aRef.aStart != aRef.aEnd) { - sal_uInt16 nTemp = FindSuccLevel( aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), - aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), - nLevel+1, nDeleteLevel ); - if (nTemp > nResult) - nResult = nTemp; + DeleteBox( aRef.aStart.Col(), aRef.aStart.Row(), + aRef.aEnd.Col(), aRef.aEnd.Row() ); } + DeleteArrowsAt( aRef.aStart.Col(), aRef.aStart.Row(), false ); + } + else if ( !bRunning && + HasArrow( aRef.aStart, + aCellIter.GetPos().Col(),aCellIter.GetPos().Row(),aCellIter.GetPos().Tab() ) ) + { + sal_uInt16 nTemp = FindSuccLevel( aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), + aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), + nLevel+1, nDeleteLevel ); + if (nTemp > nResult) + nResult = nTemp; } } } - - pFCell->SetRunning(bRunning); } - pCell = aCellIter.GetNext(); + + pFCell->SetRunning(bRunning); } return nResult; diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx index b98c05527b2a..c4c31449e69d 100644 --- a/sc/source/ui/app/transobj.cxx +++ b/sc/source/ui/app/transobj.cxx @@ -779,75 +779,73 @@ void ScTransferObj::StripRefs( ScDocument* pDoc, ScRange aRef; ScCellIterator aIter( pDoc, nStartX, nStartY, nSrcTab, nEndX, nEndY, nSrcTab ); - ScBaseCell* pCell = aIter.GetFirst(); - while (pCell) + for (bool bHas = aIter.first(); bHas; bHas = aIter.next()) { - if (pCell->GetCellType() == CELLTYPE_FORMULA) + if (aIter.getType() != CELLTYPE_FORMULA) + continue; + + ScFormulaCell* pFCell = aIter.getFormulaCell(); + bool bOut = false; + ScDetectiveRefIter aRefIter( pFCell ); + while ( !bOut && aRefIter.GetNextRef( aRef ) ) + { + if ( aRef.aStart.Tab() != nSrcTab || aRef.aEnd.Tab() != nSrcTab || + aRef.aStart.Col() < nStartX || aRef.aEnd.Col() > nEndX || + aRef.aStart.Row() < nStartY || aRef.aEnd.Row() > nEndY ) + bOut = true; + } + if (bOut) { - ScFormulaCell* pFCell = (ScFormulaCell*) pCell; - bool bOut = false; - ScDetectiveRefIter aRefIter( pFCell ); - while ( !bOut && aRefIter.GetNextRef( aRef ) ) + SCCOL nCol = aIter.GetPos().Col() - nSubX; + SCROW nRow = aIter.GetPos().Row() - nSubY; + + sal_uInt16 nErrCode = pFCell->GetErrCode(); + ScAddress aPos(nCol, nRow, nDestTab); + if (nErrCode) { - if ( aRef.aStart.Tab() != nSrcTab || aRef.aEnd.Tab() != nSrcTab || - aRef.aStart.Col() < nStartX || aRef.aEnd.Col() > nEndX || - aRef.aStart.Row() < nStartY || aRef.aEnd.Row() > nEndY ) - bOut = true; + if ( ((const SvxHorJustifyItem*) pDestDoc->GetAttr( + nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY))->GetValue() == + SVX_HOR_JUSTIFY_STANDARD ) + pDestDoc->ApplyAttr( nCol,nRow,nDestTab, + SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY) ); + + ScSetStringParam aParam; + aParam.setTextInput(); + pDestDoc->SetString(aPos, ScGlobal::GetErrorString(nErrCode)); } - if (bOut) + else if (pFCell->IsValue()) { - SCCOL nCol = aIter.GetPos().Col() - nSubX; - SCROW nRow = aIter.GetPos().Row() - nSubY; - - sal_uInt16 nErrCode = pFCell->GetErrCode(); - ScAddress aPos(nCol, nRow, nDestTab); - if (nErrCode) - { - if ( ((const SvxHorJustifyItem*) pDestDoc->GetAttr( - nCol,nRow,nDestTab, ATTR_HOR_JUSTIFY))->GetValue() == - SVX_HOR_JUSTIFY_STANDARD ) - pDestDoc->ApplyAttr( nCol,nRow,nDestTab, - SvxHorJustifyItem(SVX_HOR_JUSTIFY_RIGHT, ATTR_HOR_JUSTIFY) ); - - ScSetStringParam aParam; - aParam.setTextInput(); - pDestDoc->SetString(aPos, ScGlobal::GetErrorString(nErrCode)); - } - else if (pFCell->IsValue()) + pDestDoc->SetValue(aPos, pFCell->GetValue()); + } + else + { + String aStr = pFCell->GetString(); + if ( pFCell->IsMultilineResult() ) { - pDestDoc->SetValue(aPos, pFCell->GetValue()); + ScFieldEditEngine& rEngine = pDestDoc->GetEditEngine(); + rEngine.SetText(aStr); + pDestDoc->SetEditText(ScAddress(nCol,nRow,nDestTab), rEngine.CreateTextObject()); } else { - String aStr = pFCell->GetString(); - if ( pFCell->IsMultilineResult() ) - { - ScFieldEditEngine& rEngine = pDestDoc->GetEditEngine(); - rEngine.SetText(aStr); - pDestDoc->SetEditText(ScAddress(nCol,nRow,nDestTab), rEngine.CreateTextObject()); - } - else - { - ScSetStringParam aParam; - aParam.setTextInput(); - pDestDoc->SetString(aPos, aStr); - } + ScSetStringParam aParam; + aParam.setTextInput(); + pDestDoc->SetString(aPos, aStr); } + } - // number formats + // number formats - sal_uLong nOldFormat = ((const SfxUInt32Item*) - pDestDoc->GetAttr(nCol,nRow,nDestTab, ATTR_VALUE_FORMAT))->GetValue(); - if ( (nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) - { - sal_uLong nNewFormat = pFCell->GetStandardFormat( *pFormatter, - nOldFormat ); - pDestDoc->ApplyAttr( nCol,nRow,nDestTab, - SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat) ); - } + sal_uLong nOldFormat = ((const SfxUInt32Item*) + pDestDoc->GetAttr(nCol,nRow,nDestTab, ATTR_VALUE_FORMAT))->GetValue(); + if ( (nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 ) + { + sal_uLong nNewFormat = pFCell->GetStandardFormat( *pFormatter, + nOldFormat ); + pDestDoc->ApplyAttr( nCol,nRow,nDestTab, + SfxUInt32Item(ATTR_VALUE_FORMAT, nNewFormat) ); } } - pCell = aIter.GetNext(); } } |