[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Mar 22 18:36:12 PDT 2013
sc/source/core/tool/detfunc.cxx | 188 +++++++++++++++++++---------------------
sc/source/ui/app/transobj.cxx | 108 +++++++++++-----------
2 files changed, 145 insertions(+), 151 deletions(-)
New commits:
commit eed4ca11c508f8bf46d43e18955ed307439765d3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 21:35:44 2013 -0400
More ScCellIterator usage conversion. The rest are non-trivial...
Change-Id: I965e023d00306334f2b1aa7d3d92c90d44769b76
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 09881b4..55bea53 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 b98c055..c4c3144 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();
}
}
More information about the Libreoffice-commits
mailing list