[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - 273 commits - basctl/source basegfx/source basegfx/test basic/CppunitTest_basic_coverage.mk basic/qa basic/source bridges/Library_cpp_uno.mk bridges/Module_bridges.mk bridges/source chart2/source comphelper/inc comphelper/source config_host/config_global.h.in config_host/config_graphite.h.in config_host/config_mingw.h.in config_host/config_telepathy.h.in config_host/config_vclplug.h.in config_host.mk.in config_host/README configure.ac connectivity/Library_tdeab1.mk connectivity/source cppcanvas/source cppuhelper/inc cppuhelper/source cppuhelper/ZipPackage_cppuhelper_odk_headers.mk cui/source dbaccess/inc dbaccess/source desktop/source distro-configs/LibreOfficeAndroid.conf distro-configs/LibreOfficeAndroidX86.conf editeng/inc editeng/source expat/StaticLibrary_expat.mk extensions/source filter/Library_placeware.mk filter/source forms/source fpicker/source framework/source graphite/graphite2.patch idlc/source idl/source ios/CustomTarget_Viewer_app.mk ios/Executable_Viewer.mk ios/experimental jvmfwk/source l10ntools/inc l10ntools/source l10ntools/StaticLibrary_transex.mk libmariadb/configs libmariadb/my_config.h libmariadb/mysql_version.h libmariadb/UnpackedTarball_mariadb.mk liborcus/ExternalProject_liborcus.mk Library_merged.mk libxml2/libxml2-android.patch linguistic/inc linguistic/source odk/CustomTarget_doxygen.mk odk/pack offapi/com offapi/type_reference offapi/UnoApi_offapi.mk officecfg/registry oox/inc oox/Library_oox.mk oox/source openssl/ExternalProject_openssl.mk python3/ExternalPackage_python3.mk python3/ExternalProject_python3.mk python3/python-3.3.0-msvc-x64.patch.1 RepositoryExternal.mk Repository.mk rsc/source sal/inc sal/osl sal/qa sc/CppunitTest_sc_tablesheetobj.mk sc/CppunitTest_sc_tablesheetsobj.mk sc/inc sc/Library_sc.mk sc/qa sc/source sd/CppunitTest_sd_uimpress.mk sdext/CppunitTest_pdfimport.mk sdext/Executable_pdf2xml.mk sdext/Executable_pdfunzip.mk sdext/Library_pdf import.mk sdext/source sd/inc sd/Library_sdfilt.mk sd/Library_sdui.mk sd/sdi sd/source sd/uiconfig sd/UI_simpress.mk setup_native/source sfx2/inc sfx2/source shell/inc slideshow/source solenv/bin solenv/gbuild solenv/inc stoc/source svl/qa svtools/bmpmaker svtools/Executable_bmp.mk svtools/Executable_bmpsum.mk svtools/Executable_g2g.mk svtools/inc svtools/Module_svtools.mk svtools/source svx/inc svx/source sw/inc sw/JunitTest_sw_complex.mk sw/qa sw/source testtools/source toolkit/source tools/inc tools/source ucb/source ucpp/Executable_ucpp.mk unotools/inc unotools/source unoxml/source uui/source vcl/aqua vcl/coretext vcl/generic vcl/headless vcl/inc vcl/ios vcl/Library_vcl.mk vcl/qa vcl/quartz vcl/source vcl/unx vcl/win writerfilter/source xmlhelp/source xmloff/inc xmloff/Package_inc.mk xmloff/source xmlreader/inc xmlscript/source
Kohei Yoshida
kohei.yoshida at gmail.com
Fri Mar 22 18:56:20 PDT 2013
Rebased ref, commits from common ancestor:
commit f9bf7f4d2c95a42671c4ba136a445e794538093c
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();
}
}
commit a9a7f2501228e0f47085d937fc3727f1a452249f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 20:54:13 2013 -0400
More on ScCellIterator usage conversion... Still not done.
Change-Id: I5023a57f3a089f1af7cd7fe53f57f82c60eb2b65
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 8e3b28b..1a6d3e7 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -244,7 +244,7 @@ public:
const ScAddress& GetPos() const { return maCurPos; }
CellType getType() const;
- const OUString& getString() const;
+ OUString getString();
const EditTextObject* getEditText() const;
ScFormulaCell* getFormulaCell();
bool hasString() const;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 6517f5b..a280555 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1138,9 +1138,22 @@ CellType ScCellIterator::getType() const
return meCurType;
}
-const OUString& ScCellIterator::getString() const
+OUString ScCellIterator::getString()
{
- return maCurString;
+ switch (meCurType)
+ {
+ case CELLTYPE_STRING:
+ return maCurString;
+ case CELLTYPE_EDIT:
+ if (mpCurEditText)
+ return ScEditUtil::GetString(*mpCurEditText);
+ break;
+ case CELLTYPE_FORMULA:
+ return mpCurFormula->GetString();
+ default:
+ ;
+ }
+ return EMPTY_OUSTRING;
}
const EditTextObject* ScCellIterator::getEditText() const
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index f2fc819..3196b2e 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -742,13 +742,13 @@ bool ScDocument::DoSubTotals( SCTAB nTab, ScSubTotalParam& rParam )
bool ScDocument::HasSubTotalCells( const ScRange& rRange )
{
ScCellIterator aIter( this, rRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->IsSubTotal() )
- return true;
+ if (aIter.getType() != CELLTYPE_FORMULA)
+ continue;
- pCell = aIter.GetNext();
+ if (aIter.getFormulaCell()->IsSubTotal())
+ return true;
}
return false; // none found
}
@@ -1576,19 +1576,23 @@ bool ScDocument::GetFormulaEntries( ScTypedCaseStrSet& rStrings )
for (sal_uInt16 nListNo=0; nListNo<2; nListNo++)
{
ScRangePairList* pList = pLists[ nListNo ];
- if (pList)
- for ( size_t i = 0, nPairs = pList->size(); i < nPairs; ++i )
+ if (!pList)
+ continue;
+
+ for ( size_t i = 0, nPairs = pList->size(); i < nPairs; ++i )
+ {
+ ScRangePair* pPair = (*pList)[i];
+ ScRange aRange = pPair->GetRange(0);
+ ScCellIterator aIter( this, aRange );
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- ScRangePair* pPair = (*pList)[i];
- ScRange aRange = pPair->GetRange(0);
- ScCellIterator aIter( this, aRange );
- for ( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
- if ( pCell->HasStringData() )
- {
- OUString aStr = pCell->GetStringData();
- rStrings.insert(ScTypedStrData(aStr, 0.0, ScTypedStrData::Header));
- }
+ if (!aIter.hasString())
+ continue;
+
+ OUString aStr = aIter.getString();
+ rStrings.insert(ScTypedStrData(aStr, 0.0, ScTypedStrData::Header));
}
+ }
}
return true;
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index a0ec234..6ebbf39 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -3418,15 +3418,14 @@ void ScDocument::InterpretDirtyCells( const ScRangeList& rRanges )
for (size_t nPos=0, nRangeCount = rRanges.size(); nPos < nRangeCount; nPos++)
{
ScCellIterator aIter( this, *rRanges[ nPos ] );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
- {
- if ( static_cast<ScFormulaCell*>(pCell)->GetDirty() && GetAutoCalc() )
- static_cast<ScFormulaCell*>(pCell)->Interpret();
- }
- pCell = aIter.GetNext();
+ if (aIter.getType() != CELLTYPE_FORMULA)
+ continue;
+
+ ScFormulaCell* p = aIter.getFormulaCell();
+ if (p->GetDirty() && GetAutoCalc())
+ p->Interpret();
}
}
}
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index ee5f820..09881b4 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -1400,18 +1400,18 @@ sal_Bool ScDetectiveFunc::MarkInvalid(sal_Bool& rOverflow)
void ScDetectiveFunc::GetAllPreds(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
vector<ScTokenRef>& rRefTokens)
{
- ScCellIterator aCellIter(pDoc, nCol1, nRow1, nTab, nCol2, nRow2, nTab);
- for (ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext())
+ ScCellIterator aIter(pDoc, nCol1, nRow1, nTab, nCol2, nRow2, nTab);
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if (pCell->GetCellType() != CELLTYPE_FORMULA)
+ if (aIter.getType() != CELLTYPE_FORMULA)
continue;
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ ScFormulaCell* pFCell = aIter.getFormulaCell();
ScDetectiveRefIter aRefIter(pFCell);
for (ScToken* p = aRefIter.GetNextRefToken(); p; p = aRefIter.GetNextRefToken())
{
ScTokenRef pRef(static_cast<ScToken*>(p->Clone()));
- pRef->CalcAbsIfRel(aCellIter.GetPos());
+ pRef->CalcAbsIfRel(aIter.GetPos());
ScRefTokenHelper::join(rRefTokens, pRef);
}
}
@@ -1424,17 +1424,17 @@ void ScDetectiveFunc::GetAllSuccs(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW n
aSrcRange.push_back(
ScRefTokenHelper::createRefToken(ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab)));
- ScCellIterator aCellIter(pDoc, 0, 0, nTab, MAXCOL, MAXROW, nTab);
- for (ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext())
+ ScCellIterator aIter(pDoc, ScRange(0, 0, nTab, MAXCOL, MAXROW, nTab));
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if (pCell->GetCellType() != CELLTYPE_FORMULA)
+ if (aIter.getType() != CELLTYPE_FORMULA)
continue;
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ ScFormulaCell* pFCell = aIter.getFormulaCell();
ScDetectiveRefIter aRefIter(pFCell);
for (ScToken* p = aRefIter.GetNextRefToken(); p; p = aRefIter.GetNextRefToken())
{
- ScAddress aPos = aCellIter.GetPos();
+ const ScAddress& aPos = aIter.GetPos();
ScTokenRef pRef(static_cast<ScToken*>(p->Clone()));
pRef->CalcAbsIfRel(aPos);
if (ScRefTokenHelper::intersects(aSrcRange, pRef))
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index 9e793c0..a51f28a 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -4155,16 +4155,12 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero )
{
ScBaseCell* pCell;
ScCellIterator aIter( pDok, aRange, glSubTotal );
- if ( (pCell = aIter.GetFirst()) != NULL )
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- do
- {
- CellType eType = pCell->GetCellType();
- if( eType != CELLTYPE_NONE && eType != CELLTYPE_NOTE )
- nCount++;
- }
- while ( (pCell = aIter.GetNext()) != NULL );
+ if (!aIter.isEmpty())
+ ++nCount;
}
+
if ( nGlobalError )
nGlobalError = 0;
}
@@ -5373,16 +5369,12 @@ void ScInterpreter::ScCountEmptyCells()
static_cast<sal_uLong>(aRange.aEnd.Row() - aRange.aStart.Row() + 1) *
static_cast<sal_uLong>(aRange.aEnd.Col() - aRange.aStart.Col() + 1) *
static_cast<sal_uLong>(aRange.aEnd.Tab() - aRange.aStart.Tab() + 1);
- ScBaseCell* pCell;
- ScCellIterator aDocIter( pDok, aRange, glSubTotal);
- if ( (pCell = aDocIter.GetFirst()) != NULL )
+
+ ScCellIterator aIter( pDok, aRange, glSubTotal);
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- do
- {
- if ((eCellType = pCell->GetCellType()) != CELLTYPE_NONE
- && eCellType != CELLTYPE_NOTE)
- nCount++;
- } while ( (pCell = aDocIter.GetNext()) != NULL );
+ if (!aIter.isEmpty())
+ ++nCount;
}
}
}
diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx
index b5df5e9..114354c 100644
--- a/sc/source/core/tool/rangeseq.cxx
+++ b/sc/source/core/tool/rangeseq.cxx
@@ -37,12 +37,14 @@ static bool lcl_HasErrors( ScDocument* pDoc, const ScRange& rRange )
{
// no need to look at empty cells - just use ScCellIterator
ScCellIterator aIter( pDoc, rRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if ( pCell->GetCellType() == CELLTYPE_FORMULA && static_cast<ScFormulaCell*>(pCell)->GetErrCode() != 0 )
+ if (aIter.getType() != CELLTYPE_FORMULA)
+ continue;
+
+ ScFormulaCell* pCell = aIter.getFormulaCell();
+ if (pCell->GetErrCode() != 0)
return true;
- pCell = aIter.GetNext();
}
return false; // no error found
}
diff --git a/sc/source/ui/docshell/tablink.cxx b/sc/source/ui/docshell/tablink.cxx
index 9105ee2..628a15f 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -302,27 +302,24 @@ sal_Bool ScTableLink::Refresh(const String& rNewFile, const String& rNewFilter,
ScRangeList aErrorCells; // cells on the linked sheets that need error values
- ScCellIterator aCellIter( pDoc, 0,0,0, MAXCOL,MAXROW,MAXTAB ); // all sheets
- ScBaseCell* pCell = aCellIter.GetFirst();
- while (pCell)
+ ScCellIterator aIter(pDoc, ScRange(0,0,0,MAXCOL,MAXROW,MAXTAB)); // all sheets
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
- {
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ if (aIter.getType() != CELLTYPE_FORMULA)
+ continue;
- ScDetectiveRefIter aRefIter( pFCell );
- ScRange aRefRange;
- while ( aRefIter.GetNextRef( aRefRange ) )
+ ScFormulaCell* pCell = aIter.getFormulaCell();
+ ScDetectiveRefIter aRefIter(pCell);
+ ScRange aRefRange;
+ while ( aRefIter.GetNextRef( aRefRange ) )
+ {
+ if ( aRefRange.aStart.Tab() <= nTab && aRefRange.aEnd.Tab() >= nTab )
{
- if ( aRefRange.aStart.Tab() <= nTab && aRefRange.aEnd.Tab() >= nTab )
- {
- // use first cell of range references (don't fill potentially large ranges)
+ // use first cell of range references (don't fill potentially large ranges)
- aErrorCells.Join( ScRange( aRefRange.aStart ) );
- }
+ aErrorCells.Join( ScRange( aRefRange.aStart ) );
}
}
- pCell = aCellIter.GetNext();
}
size_t nRanges = aErrorCells.size();
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index 776f946..40fa41c 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -175,27 +175,25 @@ static sal_Bool lcl_CopyData( ScDocument* pSrcDoc, const ScRange& rSrcRange,
// If the range contains formula cells with default number format,
// apply a number format for the formula result
ScCellIterator aIter( pClipDoc, rSrcRange );
- 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;
+
+ ScAddress aCellPos = aIter.GetPos();
+ sal_uInt32 nFormat = pClipDoc->GetNumberFormat(aCellPos);
+ if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
{
- ScAddress aCellPos = aIter.GetPos();
- sal_uInt32 nFormat = pClipDoc->GetNumberFormat(aCellPos);
- if ( (nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0 )
+ ScFormulaCell* pFCell = aIter.getFormulaCell();
+ sal_uInt16 nErrCode = pFCell->GetErrCode();
+ if ( nErrCode == 0 && pFCell->IsValue() )
{
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
- sal_uInt16 nErrCode = pFCell->GetErrCode();
- if ( nErrCode == 0 && pFCell->IsValue() )
- {
- sal_uInt32 nNewFormat = pFCell->GetStandardFormat( *pClipDoc->GetFormatTable(), nFormat );
- if ( nNewFormat != nFormat )
- pClipDoc->ApplyAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(),
- SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
- }
+ sal_uInt32 nNewFormat = pFCell->GetStandardFormat( *pClipDoc->GetFormatTable(), nFormat );
+ if ( nNewFormat != nFormat )
+ pClipDoc->ApplyAttr( aCellPos.Col(), aCellPos.Row(), aCellPos.Tab(),
+ SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ) );
}
}
- pCell = aIter.GetNext();
}
ScMarkData aDestMark;
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index 8d8de0f..900e03d 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -506,14 +506,15 @@ void ScTabView::InterpretVisible()
if (nX2 > MAXCOL) nX2 = MAXCOL;
if (nY2 > MAXROW) nY2 = MAXROW;
- ScCellIterator aIter( pDoc, nX1, nY1, nTab, nX2, nY2, nTab );
- ScBaseCell* pCell = aIter.GetFirst();
- while ( pCell )
+ ScCellIterator aIter(pDoc, ScRange(nX1, nY1, nTab, nX2, nY2, nTab));
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetDirty() )
- ((ScFormulaCell*)pCell)->Interpret();
+ if (aIter.getType() != CELLTYPE_FORMULA)
+ continue;
- pCell = aIter.GetNext();
+ ScFormulaCell* p = aIter.getFormulaCell();
+ if (p->GetDirty())
+ p->Interpret();
}
}
}
commit 0872a719ab85a497ea1d71920e298fd9f1d66766
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 20:10:36 2013 -0400
More on reducing direct use of ScBaseCell.
Change-Id: Ic59376eea086802f173e590faf2693b646db3feb
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 742bfc9..70c5620 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1228,8 +1228,8 @@ public:
SC_DLLPUBLIC const ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XBreakIterator >& GetBreakIterator();
bool HasStringWeakCharacters( const rtl::OUString& rString );
SC_DLLPUBLIC sal_uInt8 GetStringScriptType( const rtl::OUString& rString );
- SC_DLLPUBLIC sal_uInt8 GetCellScriptType( const ScAddress& rPos, ScBaseCell* pCell, sal_uLong nNumberFormat );
- SC_DLLPUBLIC sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell );
+ SC_DLLPUBLIC sal_uInt8 GetCellScriptType( const ScAddress& rPos, sal_uLong nNumberFormat );
+ SC_DLLPUBLIC sal_uInt8 GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab );
bool HasDetectiveOperations() const;
void AddDetectiveOperation( const ScDetOpData& rData );
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 13287de..5607211 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -2371,7 +2371,7 @@ bool ScColumn::HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst) const
ScBaseCell* pCell = maItems[nIndex].pCell;
CellType eCellType = pCell->GetCellType();
if ( eCellType == CELLTYPE_EDIT ||
- IsAmbiguousScriptNonZero( pDocument->GetScriptType(nCol, nRow, nTab, pCell) ) ||
+ IsAmbiguousScriptNonZero( pDocument->GetScriptType(nCol, nRow, nTab) ) ||
((eCellType == CELLTYPE_FORMULA) && ((ScFormulaCell*)pCell)->IsMultilineResult()) )
{
rFirst = nRow;
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index e2792de..4108cdc 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -214,7 +214,7 @@ long ScColumn::GetNeededSize(
nIndent = ((const SfxUInt16Item&)pPattern->GetItem(ATTR_INDENT)).GetValue();
}
- sal_uInt8 nScript = pDocument->GetScriptType( nCol, nRow, nTab, pCell );
+ sal_uInt8 nScript = pDocument->GetScriptType(nCol, nRow, nTab);
if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
// also call SetFont for edit cells, because bGetFont may be set only once
@@ -603,7 +603,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth(
{
SCROW nRow = maItems[nIndex].nRow;
- sal_uInt8 nScript = pDocument->GetScriptType( nCol, nRow, nTab, maItems[nIndex].pCell );
+ sal_uInt8 nScript = pDocument->GetScriptType(nCol, nRow, nTab);
if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType();
const ScPatternAttr* pPattern = GetPattern( nRow );
@@ -772,7 +772,7 @@ void ScColumn::GetOptimalHeight(
Search(nStart,nIndex);
while ( nIndex < maItems.size() && (nRow=maItems[nIndex].nRow) <= nEnd )
{
- sal_uInt8 nScript = pDocument->GetScriptType( nCol, nRow, nTab, maItems[nIndex].pCell );
+ sal_uInt8 nScript = pDocument->GetScriptType(nCol, nRow, nTab);
if ( nScript != nDefScript )
{
if ( nScript == SCRIPTTYPE_ASIAN )
diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx
index 507f7f9..055598c 100644
--- a/sc/source/core/data/documen6.cxx
+++ b/sc/source/core/data/documen6.cxx
@@ -114,18 +114,14 @@ sal_uInt8 ScDocument::GetStringScriptType( const rtl::OUString& rString )
return nRet;
}
-sal_uInt8 ScDocument::GetCellScriptType( const ScAddress& rPos, ScBaseCell* pCell, sal_uLong nNumberFormat )
+sal_uInt8 ScDocument::GetCellScriptType( const ScAddress& rPos, sal_uLong nNumberFormat )
{
- if ( !pCell )
- return 0; // empty
-
sal_uInt8 nStored = GetScriptType(rPos);
if ( nStored != SC_SCRIPTTYPE_UNKNOWN ) // stored value valid?
return nStored; // use stored value
- rtl::OUString aStr;
Color* pColor;
- ScCellFormat::GetString( pCell, nNumberFormat, aStr, &pColor, *xPoolHelper->GetFormTable() );
+ OUString aStr = ScCellFormat::GetString(*this, rPos, nNumberFormat, &pColor, *xPoolHelper->GetFormTable());
sal_uInt8 nRet = GetStringScriptType( aStr );
@@ -134,7 +130,7 @@ sal_uInt8 ScDocument::GetCellScriptType( const ScAddress& rPos, ScBaseCell* pCel
return nRet;
}
-sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseCell* pCell )
+sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab )
{
// if script type is set, don't have to get number formats
@@ -153,7 +149,7 @@ sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseC
sal_uLong nFormat = pPattern->GetNumberFormat( xPoolHelper->GetFormTable(), pCondSet );
- return GetCellScriptType(aPos, pCell, nFormat);
+ return GetCellScriptType(aPos, nFormat);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index 06c48c8..4dafed6 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -883,7 +883,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
if ( pCell )
{
bValueData = pCell->HasValueData();
- nScriptType = pDoc->GetScriptType( nCol, nRow, nTab, pCell );
+ nScriptType = pDoc->GetScriptType(nCol, nRow, nTab);
}
else
{
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 2f53d18..449f9de 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -1598,7 +1598,7 @@ void ScOutputData::DrawStrings( sal_Bool bPixelToLogic )
}
sal_uInt8 nScript = mpDoc->GetCellScriptType(
- ScAddress(nCellX, nCellY, nTab), pCell,
+ ScAddress(nCellX, nCellY, nTab),
pPattern->GetNumberFormat(mpDoc->GetFormatTable(), pCondSet));
if (nScript == 0)
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 1283ddd..e7ff91d 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -817,7 +817,7 @@ sal_uInt8 ScViewFunc::GetSelectionScriptType()
// no selection -> cursor
nScript = pDoc->GetScriptType( GetViewData()->GetCurX(),
- GetViewData()->GetCurY(), GetViewData()->GetTabNo(), NULL );
+ GetViewData()->GetCurY(), GetViewData()->GetTabNo());
}
else
{
@@ -828,12 +828,10 @@ sal_uInt8 ScViewFunc::GetSelectionScriptType()
{
ScRange aRange = *aRanges[i];
ScCellIterator aIter( pDoc, aRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while ( pCell )
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
nScript |= pDoc->GetScriptType(
- aIter.GetPos().Col(), aIter.GetPos().Row(), aIter.GetPos().Tab(), pCell);
- pCell = aIter.GetNext();
+ aIter.GetPos().Col(), aIter.GetPos().Row(), aIter.GetPos().Tab());
}
}
}
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index 9aa5068..d055ced 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -72,7 +72,7 @@ sal_uInt16 ScViewUtil::GetEffLanguage( ScDocument* pDoc, const ScAddress& rPos )
{
// used for thesaurus
- sal_uInt8 nScript = pDoc->GetScriptType( rPos.Col(), rPos.Row(), rPos.Tab(), NULL );
+ sal_uInt8 nScript = pDoc->GetScriptType(rPos.Col(), rPos.Row(), rPos.Tab());
sal_uInt16 nWhich = ( nScript == SCRIPTTYPE_ASIAN ) ? ATTR_CJK_FONT_LANGUAGE :
( ( nScript == SCRIPTTYPE_COMPLEX ) ? ATTR_CTL_FONT_LANGUAGE : ATTR_FONT_LANGUAGE );
const SfxPoolItem* pItem = pDoc->GetAttr( rPos.Col(), rPos.Row(), rPos.Tab(), nWhich);
commit 2f6b33da43a06ff43bda739c41245761ffdf97fa
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 19:49:41 2013 -0400
Re-did ScCellIterator to avoid copying every single iterated cell.
ScCellValue copies the cell value. Let's not use it in ScCellIterator.
Change-Id: Id478b607c702077751878f557b8779c98b68db28
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 80f3738..8e3b28b 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -24,7 +24,6 @@
#include <tools/solar.h>
#include "global.hxx"
#include "scdllapi.h"
-#include "cellvalue.hxx"
#include <memory>
@@ -45,6 +44,7 @@ struct ScDBQueryParamBase;
struct ScQueryParam;
struct ScDBQueryParamInternal;
struct ScDBQueryParamMatrix;
+class ScFormulaCell;
class ScDocumentIterator // walk through all non-empty cells
{
@@ -218,10 +218,17 @@ private:
ScAddress maStartPos;
ScAddress maEndPos;
ScAddress maCurPos;
- ScCellValue maCurCell;
SCSIZE nColRow;
bool bSubTotal;
+ CellType meCurType;
+ OUString maCurString;
+ union {
+ double mfCurValue;
+ const EditTextObject* mpCurEditText; // points to the original.
+ ScFormulaCell* mpCurFormula; // points to the original.
+ };
+
ScBaseCell* GetThis();
void init();
bool getCurrent();
@@ -236,10 +243,17 @@ public:
ScBaseCell* GetNext();
const ScAddress& GetPos() const { return maCurPos; }
+ CellType getType() const;
+ const OUString& getString() const;
+ const EditTextObject* getEditText() const;
+ ScFormulaCell* getFormulaCell();
+ bool hasString() const;
+ bool hasNumeric() const;
+ bool isEmpty() const;
+ bool equalsWithoutFormat( const ScAddress& rPos ) const;
+
bool first();
bool next();
-
- const ScCellValue& get() const;
};
class ScQueryCellIterator // walk through all non-empty cells in an area
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index 3bdbb32..556e749 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -59,6 +59,8 @@ public:
/// Retrieves string with paragraphs delimited by new lines ('\n').
static String GetMultilineString( const EditEngine& rEngine );
+ static OUString GetString( const EditTextObject& rEditText );
+
public:
ScEditUtil( ScDocument* pDocument, SCCOL nX, SCROW nY, SCTAB nZ,
const Point& rScrPosPixel,
diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx
index 2bbc4b2..6629c51 100644
--- a/sc/source/core/data/autonamecache.cxx
+++ b/sc/source/core/data/autonamecache.cxx
@@ -57,23 +57,26 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rN
{
// don't check code length here, always use the stored result
// (AutoCalc is disabled during CompileXML)
- const ScCellValue& rVal = aIter.get();
- if (rVal.hasString())
+ if (aIter.hasString())
{
OUString aStr;
- switch (rVal.meType)
+ switch (aIter.getType())
{
case CELLTYPE_STRING:
- aStr = *rVal.mpString;
+ aStr = aIter.getString();
break;
case CELLTYPE_FORMULA:
- aStr = rVal.mpFormula->GetString();
+ aStr = aIter.getFormulaCell()->GetString();
break;
case CELLTYPE_EDIT:
{
- ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
- rEngine.SetText(*rVal.mpEditText);
- aStr = ScEditUtil::GetMultilineString(rEngine); // string with line separators between paragraphs
+ const EditTextObject* p = aIter.getEditText();
+ if (p)
+ {
+ ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
+ rEngine.SetText(*p);
+ aStr = ScEditUtil::GetMultilineString(rEngine); // string with line separators between paragraphs
+ }
}
break;
case CELLTYPE_NONE:
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 5446bbc..6517f5b 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -35,6 +35,8 @@
#include "queryparam.hxx"
#include "queryentry.hxx"
#include "globstr.hrc"
+#include "editutil.hxx"
+
#include "tools/fract.hxx"
#include "editeng/editobj.hxx"
@@ -943,7 +945,9 @@ ScCellIterator::ScCellIterator( ScDocument* pDocument,
maStartPos(nSCol, nSRow, nSTab),
maEndPos(nECol, nERow, nETab),
nColRow(0),
- bSubTotal(bSTotal)
+ bSubTotal(bSTotal),
+ meCurType(CELLTYPE_NONE),
+ mfCurValue(0.0)
{
init();
}
@@ -953,7 +957,9 @@ ScCellIterator::ScCellIterator( ScDocument* pDocument, const ScRange& rRange, bo
maStartPos(rRange.aStart),
maEndPos(rRange.aEnd),
nColRow(0),
- bSubTotal(bSTotal)
+ bSubTotal(bSTotal),
+ meCurType(CELLTYPE_NONE),
+ mfCurValue(0.0)
{
init();
}
@@ -1068,7 +1074,7 @@ bool ScCellIterator::getCurrent()
maCurPos.IncTab();
if (maCurPos.Tab() > maEndPos.Tab())
{
- maCurCell.clear();
+ meCurType = CELLTYPE_NONE;
return false; // Over and out
}
}
@@ -1093,33 +1099,26 @@ bool ScCellIterator::getCurrent()
else
{
// Found it!
- maCurCell.clear();
- maCurCell.meType = pCell->GetCellType();
- switch (maCurCell.meType)
+ meCurType = pCell->GetCellType();
+ switch (meCurType)
{
case CELLTYPE_VALUE:
- maCurCell.mfValue = static_cast<const ScValueCell*>(pCell)->GetValue();
+ mfCurValue = static_cast<const ScValueCell*>(pCell)->GetValue();
break;
case CELLTYPE_STRING:
- {
- const OUString& rStr = static_cast<const ScStringCell*>(pCell)->GetString();
- maCurCell.mpString = new OUString(rStr);
- }
+ maCurString = static_cast<const ScStringCell*>(pCell)->GetString();
break;
case CELLTYPE_EDIT:
- {
- const EditTextObject* pData = static_cast<const ScEditCell*>(pCell)->GetData();
- maCurCell.mpEditText = pData->Clone();
- }
+ mpCurEditText = static_cast<const ScEditCell*>(pCell)->GetData();
break;
case CELLTYPE_FORMULA:
- maCurCell.mpFormula = static_cast<const ScFormulaCell*>(pCell)->Clone();
+ mpCurFormula = static_cast<ScFormulaCell*>(pCell);
break;
default:
- maCurCell.meType = CELLTYPE_NONE;
+ meCurType = CELLTYPE_NONE;
}
- if (maCurCell.meType != CELLTYPE_NONE)
+ if (meCurType != CELLTYPE_NONE)
return true;
maCurPos.IncRow();
@@ -1134,6 +1133,145 @@ bool ScCellIterator::getCurrent()
return false;
}
+CellType ScCellIterator::getType() const
+{
+ return meCurType;
+}
+
+const OUString& ScCellIterator::getString() const
+{
+ return maCurString;
+}
+
+const EditTextObject* ScCellIterator::getEditText() const
+{
+ return mpCurEditText;
+}
+
+ScFormulaCell* ScCellIterator::getFormulaCell()
+{
+ return mpCurFormula;
+}
+
+bool ScCellIterator::hasString() const
+{
+ switch (meCurType)
+ {
+ case CELLTYPE_STRING:
+ case CELLTYPE_EDIT:
+ return true;
+ case CELLTYPE_FORMULA:
+ return !mpCurFormula->IsValue();
+ default:
+ ;
+ }
+
+ return false;
+}
+
+bool ScCellIterator::hasNumeric() const
+{
+ switch (meCurType)
+ {
+ case CELLTYPE_VALUE:
+ return true;
+ case CELLTYPE_FORMULA:
+ return mpCurFormula->IsValue();
+ default:
+ ;
+ }
+
+ return false;
+}
+
+bool ScCellIterator::isEmpty() const
+{
+ return meCurType == CELLTYPE_NOTE || meCurType == CELLTYPE_NONE;
+}
+
+namespace {
+
+CellType adjustCellType( CellType eOrig )
+{
+ switch (eOrig)
+ {
+ case CELLTYPE_NOTE:
+ return CELLTYPE_NONE;
+ case CELLTYPE_EDIT:
+ return CELLTYPE_STRING;
+ default:
+ ;
+ }
+ return eOrig;
+}
+
+}
+
+bool ScCellIterator::equalsWithoutFormat( const ScAddress& rPos ) const
+{
+ // Fetch the other cell first.
+ if (!pDoc->TableExists(rPos.Tab()))
+ return false;
+
+ ScTable& rTab = *pDoc->maTabs[rPos.Tab()];
+ if (!ValidColRow(rPos.Col(), rPos.Row()))
+ return false;
+
+ ScColumn& rCol = rTab.aCol[rPos.Col()];
+ SCSIZE nIndex;
+ if (!rCol.Search(rPos.Row(), nIndex))
+ return false;
+
+ ScBaseCell* pCell2 = rCol.maItems[nIndex].pCell;
+
+ CellType eType1 = adjustCellType(meCurType);
+ CellType eType2 = adjustCellType(pCell2->GetCellType());
+ if (eType1 != eType2)
+ return false;
+
+ switch (eType1)
+ {
+ case CELLTYPE_NONE:
+ // Both are empty.
+ return true;
+ case CELLTYPE_VALUE:
+ return mfCurValue == static_cast<ScValueCell*>(pCell2)->GetValue();
+ case CELLTYPE_STRING:
+ {
+ OUString aStr1;
+ if (meCurType == CELLTYPE_STRING)
+ aStr1 = maCurString;
+ else if (meCurType == CELLTYPE_EDIT)
+ aStr1 = ScEditUtil::GetString(*mpCurEditText);
+
+ OUString aStr2 = pCell2->GetStringData();
+ return aStr1 == aStr2;
+ }
+ case CELLTYPE_FORMULA:
+ {
+ ScTokenArray* pCode1 = mpCurFormula->GetCode();
+ ScTokenArray* pCode2 = static_cast<ScFormulaCell*>(pCell2)->GetCode();
+
+ if (pCode1->GetLen() != pCode2->GetLen())
+ return false;
+
+ sal_uInt16 n = pCode1->GetLen();
+ formula::FormulaToken** ppToken1 = pCode1->GetArray();
+ formula::FormulaToken** ppToken2 = pCode2->GetArray();
+ for (sal_uInt16 i = 0; i < n; ++i)
+ {
+ if (!ppToken1[i]->TextEqual(*(ppToken2[i])))
+ return false;
+ }
+
+ return true;
+ }
+ default:
+ ;
+ }
+ return false;
+}
+
bool ScCellIterator::first()
{
if (!ValidTab(maCurPos.Tab()))
@@ -1151,11 +1289,6 @@ bool ScCellIterator::next()
return getCurrent();
}
-const ScCellValue& ScCellIterator::get() const
-{
- return maCurCell;
-}
-
//-------------------------------------------------------------------------------
ScQueryCellIterator::ScQueryCellIterator(ScDocument* pDocument, SCTAB nTable,
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 280658e..ee5f820 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -302,11 +302,10 @@ sal_Bool ScDetectiveFunc::HasError( const ScRange& rRange, ScAddress& rErrPos )
ScCellIterator aIter( pDoc, rRange);
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- const ScCellValue& rVal = aIter.get();
- if (rVal.meType != CELLTYPE_FORMULA)
+ if (aIter.getType() != CELLTYPE_FORMULA)
continue;
- nError = rVal.mpFormula->GetErrCode();
+ nError = aIter.getFormulaCell()->GetErrCode();
if (nError)
rErrPos = aIter.GetPos();
}
@@ -794,7 +793,7 @@ sal_uInt16 ScDetectiveFunc::InsertPredLevelArea( const ScRange& rRef,
ScCellIterator aIter( pDoc, rRef);
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if (aIter.get().meType != CELLTYPE_FORMULA)
+ if (aIter.getType() != CELLTYPE_FORMULA)
continue;
const ScAddress& rPos = aIter.GetPos();
@@ -896,7 +895,7 @@ sal_uInt16 ScDetectiveFunc::FindPredLevelArea( const ScRange& rRef,
ScCellIterator aCellIter( pDoc, rRef);
for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
{
- if (aCellIter.get().meType != CELLTYPE_FORMULA)
+ if (aCellIter.getType() != CELLTYPE_FORMULA)
continue;
sal_uInt16 nTemp = FindPredLevel(aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), nLevel, nDeleteLevel);
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 66ba2fc..67ff543 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -29,6 +29,7 @@
#include <editeng/flditem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/justifyitem.hxx>
+#include "editeng/editobj.hxx"
#include <vcl/svapp.hxx>
#include <vcl/outdev.hxx>
#include <svl/inethist.hxx>
@@ -90,6 +91,19 @@ String ScEditUtil::GetMultilineString( const EditEngine& rEngine )
return lcl_GetDelimitedString(rEngine, '\n');
}
+OUString ScEditUtil::GetString( const EditTextObject& rEditText )
+{
+ OUStringBuffer aRet;
+ size_t n = rEditText.GetParagraphCount();
+ for (size_t i = 0; i < n; ++i)
+ {
+ if (i > 0)
+ aRet.append('\n');
+ aRet.append(rEditText.GetText(i));
+ }
+ return aRet.makeStringAndClear();
+}
+
//------------------------------------------------------------------------
Rectangle ScEditUtil::GetEditArea( const ScPatternAttr* pPattern, sal_Bool bForceToTop )
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index dd727ae..11ba412 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2062,12 +2062,14 @@ void ScXMLExport::_ExportAutoStyles()
if (pDoc->IsStreamValid(nTab))
{
ScCellIterator aIter( pDoc, 0,0,nTab, MAXCOL,MAXROW,nTab );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
- static_cast<ScFormulaCell*>(pCell)->IsValue(); // interpret if dirty
- pCell = aIter.GetNext();
+ if (aIter.getType() != CELLTYPE_FORMULA)
+ continue;
+
+ ScFormulaCell* pFC = aIter.getFormulaCell();
+ if (pFC)
+ pFC->IsValue(); // interpret if dirty
}
}
diff --git a/sc/source/ui/Accessibility/AccessibleCell.cxx b/sc/source/ui/Accessibility/AccessibleCell.cxx
index 33a99a1..7eb84d5 100644
--- a/sc/source/ui/Accessibility/AccessibleCell.cxx
+++ b/sc/source/ui/Accessibility/AccessibleCell.cxx
@@ -367,11 +367,10 @@ void ScAccessibleCell::FillDependends(utl::AccessibleRelationSetHelper* pRelatio
for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
{
- const ScCellValue& rVal = aCellIter.get();
- if (rVal.meType == CELLTYPE_FORMULA)
+ if (aCellIter.getType() == CELLTYPE_FORMULA)
{
bool bFound = false;
- ScDetectiveRefIter aIter(rVal.mpFormula);
+ ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
ScRange aRef;
while ( !bFound && aIter.GetNextRef( aRef ) )
{
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 6e91815..6e4ca2b 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -1180,7 +1180,7 @@ bool lcl_EmptyExcept( ScDocument* pDoc, const ScRange& rRange, const ScRange& rE
ScCellIterator aIter( pDoc, rRange );
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if (!aIter.get().isEmpty()) // real content?
+ if (!aIter.isEmpty()) // real content?
{
if (!rExcept.In(aIter.GetPos()))
return false; // cell found
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 7bff6dd..2ff086f 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3561,7 +3561,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCel
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
// Notizen zaehlen als nicht-leer
- if (!aIter.get().isEmpty())
+ if (!aIter.isEmpty())
aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
}
}
@@ -3597,8 +3597,7 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
bool bAdd = false;
- const ScCellValue& rVal = aIter.get();
- switch (rVal.meType)
+ switch (aIter.getType())
{
case CELLTYPE_STRING:
if ( nContentFlags & sheet::CellFlags::STRING )
@@ -3677,9 +3676,9 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaC
ScCellIterator aIter( pDoc, aRange );
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if (aIter.get().meType == CELLTYPE_FORMULA)
+ if (aIter.getType() == CELLTYPE_FORMULA)
{
- ScFormulaCell* pFCell = aIter.get().mpFormula;
+ ScFormulaCell* pFCell = aIter.getFormulaCell();
bool bAdd = false;
if (pFCell->GetErrCode())
{
@@ -3737,7 +3736,7 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
ScCellIterator aCmpIter( pDoc, aCmpRange );
for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
{
- if (aCmpIter.get().meType != CELLTYPE_NOTE)
+ if (aCmpIter.getType() != CELLTYPE_NOTE)
{
SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
if (bColumnDiff)
@@ -3778,17 +3777,13 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
ScCellIterator aIter( pDoc, aRange );
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- const ScCellValue& rCell = aIter.get();
-
if (bColumnDiff)
aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
else
aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
- ScCellValue aOtherCell;
- aOtherCell.assign(*pDoc, aCmpAddr);
ScRange aOneRange(aIter.GetPos());
- if (!rCell.equalsWithoutFormat(aOtherCell))
+ if (!aIter.equalsWithoutFormat(aCmpAddr))
aMarkData.SetMultiMarkArea( aOneRange );
else
aMarkData.SetMultiMarkArea( aOneRange, false ); // deselect
@@ -3868,11 +3863,10 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPreceden
ScCellIterator aIter( pDoc, aRange );
for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- const ScCellValue& rVal = aIter.get();
- if (rVal.meType != CELLTYPE_FORMULA)
+ if (aIter.getType() != CELLTYPE_FORMULA)
continue;
- ScDetectiveRefIter aRefIter(rVal.mpFormula);
+ ScDetectiveRefIter aRefIter(aIter.getFormulaCell());
ScRange aRefRange;
while ( aRefIter.GetNextRef( aRefRange) )
{
@@ -3917,12 +3911,11 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependen
ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab );
for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
{
- const ScCellValue& rVal = aCellIter.get();
- if (rVal.meType != CELLTYPE_FORMULA)
+ if (aCellIter.getType() != CELLTYPE_FORMULA)
continue;
bool bMark = false;
- ScDetectiveRefIter aIter(rVal.mpFormula);
+ ScDetectiveRefIter aIter(aCellIter.getFormulaCell());
ScRange aRefRange;
while ( aIter.GetNextRef( aRefRange) )
{
commit 71362fb191d87e918fbf066ce639b0df213bd2a7
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 16:44:10 2013 -0400
More on ScCellIterator conversion... More to come.
Change-Id: I7b80e8418e8f5ea4ea64f4f05c3709aaf8606bad
diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx
index 57981ec..280658e 100644
--- a/sc/source/core/tool/detfunc.cxx
+++ b/sc/source/core/tool/detfunc.cxx
@@ -299,17 +299,16 @@ sal_Bool ScDetectiveFunc::HasError( const ScRange& rRange, ScAddress& rErrPos )
rErrPos = rRange.aStart;
sal_uInt16 nError = 0;
- ScCellIterator aCellIter( pDoc, rRange);
- ScBaseCell* pCell = aCellIter.GetFirst();
- while (pCell)
+ ScCellIterator aIter( pDoc, rRange);
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
- {
- nError = ((ScFormulaCell*)pCell)->GetErrCode();
- if (nError)
- rErrPos = aCellIter.GetPos();
- }
- pCell = aCellIter.GetNext();
+ const ScCellValue& rVal = aIter.get();
+ if (rVal.meType != CELLTYPE_FORMULA)
+ continue;
+
+ nError = rVal.mpFormula->GetErrCode();
+ if (nError)
+ rErrPos = aIter.GetPos();
}
return (nError != 0);
@@ -792,27 +791,29 @@ sal_uInt16 ScDetectiveFunc::InsertPredLevelArea( const ScRange& rRef,
{
sal_uInt16 nResult = DET_INS_EMPTY;
- ScCellIterator aCellIter( pDoc, rRef);
- ScBaseCell* pCell = aCellIter.GetFirst();
- while (pCell)
+ ScCellIterator aIter( pDoc, rRef);
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
- switch( InsertPredLevel( aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), rData, nLevel ) )
- {
- 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;
- }
+ if (aIter.get().meType != CELLTYPE_FORMULA)
+ continue;
- pCell = aCellIter.GetNext();
+ const ScAddress& rPos = aIter.GetPos();
+ switch (InsertPredLevel(rPos.Col(), rPos.Row(), rData, nLevel))
+ {
+ 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;
+ default:
+ ;
+ }
}
return nResult;
@@ -893,16 +894,14 @@ sal_uInt16 ScDetectiveFunc::FindPredLevelArea( const ScRange& rRef,
sal_uInt16 nResult = nLevel;
ScCellIterator aCellIter( pDoc, rRef);
- ScBaseCell* pCell = aCellIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
- {
- sal_uInt16 nTemp = FindPredLevel( aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), nLevel, nDeleteLevel );
- if (nTemp > nResult)
- nResult = nTemp;
- }
- pCell = aCellIter.GetNext();
+ if (aCellIter.get().meType != CELLTYPE_FORMULA)
+ continue;
+
+ sal_uInt16 nTemp = FindPredLevel(aCellIter.GetPos().Col(), aCellIter.GetPos().Row(), nLevel, nDeleteLevel);
+ if (nTemp > nResult)
+ nResult = nTemp;
}
return nResult;
commit ea8ed4dac5390935021b0ca579f33393ac50bd30
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 15:47:37 2013 -0400
ScDBDocFunc is now ScBaseCell-free.
Change-Id: I666886c737b118b30faff6c3763d40c1c4b7fca7
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index a73b238..6e91815 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -39,7 +39,6 @@
#include "dpobject.hxx"
#include "dpsave.hxx"
#include "dociter.hxx" // for lcl_EmptyExcept
-#include "cell.hxx" // for lcl_EmptyExcept
#include "editable.hxx"
#include "attrib.hxx"
#include "drwlayer.hxx"
@@ -1179,15 +1178,13 @@ namespace {
bool lcl_EmptyExcept( ScDocument* pDoc, const ScRange& rRange, const ScRange& rExcept )
{
ScCellIterator aIter( pDoc, rRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if ( !pCell->IsBlank() ) // real content?
+ if (!aIter.get().isEmpty()) // real content?
{
if (!rExcept.In(aIter.GetPos()))
return false; // cell found
}
- pCell = aIter.GetNext();
}
return true; // nothing found - empty
commit 7d6eb60583e05dfa36402c92dc4315f2056f8592
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 15:36:57 2013 -0400
Start switching ScCellIterator caller to alternative iteration method.
Change-Id: I8b39adaaff3874e26709579530fb74b2bf0543be
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index ac96274..16af46f 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -49,6 +49,14 @@ struct ScCellValue
* Set cell value at specified position in specified document.
*/
void commit( ScDocument& rDoc, const ScAddress& rPos );
+
+ bool hasString() const;
+
+ bool hasNumeric() const;
+
+ bool isEmpty() const;
+
+ bool equalsWithoutFormat( const ScCellValue& r ) const;
};
// TODO: temporary workaround. To be removed later.
diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx
index 8a79864..2bbc4b2 100644
--- a/sc/source/core/data/autonamecache.cxx
+++ b/sc/source/core/data/autonamecache.cxx
@@ -21,10 +21,11 @@
#include "autonamecache.hxx"
#include "dociter.hxx"
-#include "cell.hxx"
#include "queryparam.hxx"
-
-// -----------------------------------------------------------------------
+#include "cell.hxx"
+#include "cellvalue.hxx"
+#include "editutil.hxx"
+#include "document.hxx"
ScAutoNameCache::ScAutoNameCache( ScDocument* pD ) :
pDoc( pD ),
@@ -52,25 +53,28 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rN
ScAutoNameAddresses& rAddresses = aNames[rName];
ScCellIterator aIter( pDoc, ScRange( 0, 0, nCurrentTab, MAXCOL, MAXROW, nCurrentTab ) );
- for ( ScBaseCell* pCell = aIter.GetFirst(); pCell; pCell = aIter.GetNext() )
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
// don't check code length here, always use the stored result
// (AutoCalc is disabled during CompileXML)
-
- if ( pCell->HasStringData() )
+ const ScCellValue& rVal = aIter.get();
+ if (rVal.hasString())
{
- String aStr;
- CellType eType = pCell->GetCellType();
- switch ( eType )
+ OUString aStr;
+ switch (rVal.meType)
{
case CELLTYPE_STRING:
- aStr = ((ScStringCell*)pCell)->GetString();
+ aStr = *rVal.mpString;
break;
case CELLTYPE_FORMULA:
- aStr = ((ScFormulaCell*)pCell)->GetString();
+ aStr = rVal.mpFormula->GetString();
break;
case CELLTYPE_EDIT:
- aStr = ((ScEditCell*)pCell)->GetString();
+ {
+ ScFieldEditEngine& rEngine = pDoc->GetEditEngine();
+ rEngine.SetText(*rVal.mpEditText);
+ aStr = ScEditUtil::GetMultilineString(rEngine); // string with line separators between paragraphs
+ }
break;
case CELLTYPE_NONE:
case CELLTYPE_VALUE:
diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx
index 6a51c68..3706278 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -12,6 +12,7 @@
#include "cell.hxx"
#include "editeng/editobj.hxx"
#include "stringutil.hxx"
+#include "formula/token.hxx"
ScCellValue::ScCellValue() : meType(CELLTYPE_NONE), mfValue(0.0) {}
ScCellValue::ScCellValue( double fValue ) : meType(CELLTYPE_VALUE), mfValue(fValue) {}
@@ -113,6 +114,121 @@ void ScCellValue::commit( ScDocument& rDoc, const ScAddress& rPos )
}
}
+bool ScCellValue::hasString() const
+{
+ switch (meType)
+ {
+ case CELLTYPE_STRING:
+ case CELLTYPE_EDIT:
+ return true;
+ case CELLTYPE_FORMULA:
+ return !mpFormula->IsValue();
+ default:
+ return false;
+ }
+}
+
+bool ScCellValue::hasNumeric() const
+{
+ switch (meType)
+ {
+ case CELLTYPE_VALUE:
+ return true;
+ case CELLTYPE_FORMULA:
+ return mpFormula->IsValue();
+ default:
+ return false;
+ }
+}
+
+bool ScCellValue::isEmpty() const
+{
+ return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE;
+}
+
+namespace {
+
+CellType adjustCellType( CellType eOrig )
+{
+ switch (eOrig)
+ {
+ case CELLTYPE_NOTE:
+ return CELLTYPE_NONE;
+ case CELLTYPE_EDIT:
+ return CELLTYPE_STRING;
+ default:
+ ;
+ }
+ return eOrig;
+}
+
+OUString getString( const ScCellValue& rVal )
+{
+ if (rVal.meType == CELLTYPE_STRING)
+ return *rVal.mpString;
+
+ if (rVal.meType == CELLTYPE_EDIT)
+ {
+ OUStringBuffer aRet;
+ size_t n = rVal.mpEditText->GetParagraphCount();
+ for (size_t i = 0; i < n; ++i)
+ {
+ if (i > 0)
+ aRet.append('\n');
+ aRet.append(rVal.mpEditText->GetText(i));
+ }
+ return aRet.makeStringAndClear();
+ }
+
+ return EMPTY_OUSTRING;
+}
+
+}
+
+bool ScCellValue::equalsWithoutFormat( const ScCellValue& r ) const
+{
+ CellType eType1 = adjustCellType(meType);
+ CellType eType2 = adjustCellType(r.meType);
+ if (eType1 != eType2)
+ return false;
+
+ switch (meType)
+ {
+ case CELLTYPE_NONE:
+ return true;
+ case CELLTYPE_VALUE:
+ return mfValue == r.mfValue;
+ case CELLTYPE_STRING:
+ {
+ OUString aStr1 = getString(*this);
+ OUString aStr2 = getString(r);
+ return aStr1 == aStr2;
+ }
+ case CELLTYPE_FORMULA:
+ {
+ ScTokenArray* pCode1 = mpFormula->GetCode();
+ ScTokenArray* pCode2 = r.mpFormula->GetCode();
+
+ if (pCode1->GetLen() != pCode2->GetLen())
+ return false;
+
+ sal_uInt16 n = pCode1->GetLen();
+ formula::FormulaToken** ppToken1 = pCode1->GetArray();
+ formula::FormulaToken** ppToken2 = pCode2->GetArray();
+ for (sal_uInt16 i = 0; i < n; ++i)
+ {
+ if (!ppToken1[i]->TextEqual(*(ppToken2[i])))
+ return false;
+ }
+
+ return true;
+ }
+ default:
+ ;
+ }
+ return false;
+}
+
ScBaseCell* getHackedBaseCell( ScDocument* pDoc, const ScCellValue& rVal )
{
switch (rVal.meType)
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index a64feb1..7bff6dd 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -3558,14 +3558,11 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryEmptyCel
ScRange aRange = *aRanges[ i ];
ScCellIterator aIter( pDoc, aRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
// Notizen zaehlen als nicht-leer
- if ( !pCell->IsBlank() )
+ if (!aIter.get().isEmpty())
aMarkData.SetMultiMarkArea(aIter.GetPos(), false);
-
- pCell = aIter.GetNext();
}
}
@@ -3597,28 +3594,28 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC
ScRange aRange = *aRanges[ i ];
ScCellIterator aIter( pDoc, aRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- sal_Bool bAdd = false;
- switch ( pCell->GetCellType() )
+ bool bAdd = false;
+ const ScCellValue& rVal = aIter.get();
+ switch (rVal.meType)
{
case CELLTYPE_STRING:
if ( nContentFlags & sheet::CellFlags::STRING )
- bAdd = sal_True;
+ bAdd = true;
break;
case CELLTYPE_EDIT:
if ( (nContentFlags & sheet::CellFlags::STRING) || (nContentFlags & sheet::CellFlags::FORMATTED) )
- bAdd = sal_True;
+ bAdd = true;
break;
case CELLTYPE_FORMULA:
if ( nContentFlags & sheet::CellFlags::FORMULA )
- bAdd = sal_True;
+ bAdd = true;
break;
case CELLTYPE_VALUE:
if ( (nContentFlags & (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME))
== (sheet::CellFlags::VALUE|sheet::CellFlags::DATETIME) )
- bAdd = sal_True;
+ bAdd = true;
else
{
// Date/Time Erkennung
@@ -3630,12 +3627,12 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC
(nTyp == NUMBERFORMAT_DATETIME))
{
if ( nContentFlags & sheet::CellFlags::DATETIME )
- bAdd = sal_True;
+ bAdd = true;
}
else
{
if ( nContentFlags & sheet::CellFlags::VALUE )
- bAdd = sal_True;
+ bAdd = true;
}
}
break;
@@ -3647,8 +3644,6 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryContentC
if (bAdd)
aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
-
- pCell = aIter.GetNext();
}
}
@@ -3680,34 +3675,31 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryFormulaC
ScRange aRange = *aRanges[ i ];
ScCellIterator aIter( pDoc, aRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ if (aIter.get().meType == CELLTYPE_FORMULA)
{
- ScFormulaCell* pFCell = (ScFormulaCell*)pCell;
- sal_Bool bAdd = false;
+ ScFormulaCell* pFCell = aIter.get().mpFormula;
+ bool bAdd = false;
if (pFCell->GetErrCode())
{
if ( nResultFlags & sheet::FormulaResult::ERROR )
- bAdd = sal_True;
+ bAdd = true;
}
else if (pFCell->IsValue())
{
if ( nResultFlags & sheet::FormulaResult::VALUE )
- bAdd = sal_True;
+ bAdd = true;
}
else // String
{
if ( nResultFlags & sheet::FormulaResult::STRING )
- bAdd = sal_True;
+ bAdd = true;
}
if (bAdd)
aMarkData.SetMultiMarkArea(aIter.GetPos(), true);
}
-
- pCell = aIter.GetNext();
}
}
@@ -3743,10 +3735,9 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
else
aCmpRange = ScRange( static_cast<SCCOL>(nCmpPos),0,nTab, static_cast<SCCOL>(nCmpPos),MAXROW,nTab );
ScCellIterator aCmpIter( pDoc, aCmpRange );
- ScBaseCell* pCmpCell = aCmpIter.GetFirst();
- while (pCmpCell)
+ for (bool bHasCell = aCmpIter.first(); bHasCell; bHasCell = aCmpIter.next())
{
- if (pCmpCell->GetCellType() != CELLTYPE_NOTE)
+ if (aCmpIter.get().meType != CELLTYPE_NOTE)
{
SCCOLROW nCellPos = bColumnDiff ? static_cast<SCCOLROW>(aCmpIter.GetPos().Col()) : static_cast<SCCOLROW>(aCmpIter.GetPos().Row());
if (bColumnDiff)
@@ -3774,7 +3765,6 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
}
}
}
- pCmpCell = aCmpIter.GetNext();
}
// alle nichtleeren Zellen mit der Vergleichsspalte vergleichen und entsprechend
@@ -3786,22 +3776,22 @@ uno::Reference<sheet::XSheetCellRanges> ScCellRangesBase::QueryDifferences_Impl(
ScRange aRange( *aRanges[ i ] );
ScCellIterator aIter( pDoc, aRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
+ const ScCellValue& rCell = aIter.get();
+
if (bColumnDiff)
aCmpAddr = ScAddress( aIter.GetPos().Col(), nCmpPos, aIter.GetPos().Tab() );
else
aCmpAddr = ScAddress( static_cast<SCCOL>(nCmpPos), aIter.GetPos().Row(), aIter.GetPos().Tab() );
- const ScBaseCell* pOtherCell = pDoc->GetCell( aCmpAddr );
+ ScCellValue aOtherCell;
+ aOtherCell.assign(*pDoc, aCmpAddr);
ScRange aOneRange(aIter.GetPos());
- if ( !ScBaseCell::CellEqual( pCell, pOtherCell ) )
+ if (!rCell.equalsWithoutFormat(aOtherCell))
aMarkData.SetMultiMarkArea( aOneRange );
else
aMarkData.SetMultiMarkArea( aOneRange, false ); // deselect
-
- pCell = aIter.GetNext();
}
}
@@ -3876,23 +3866,20 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryPreceden
{
ScRange aRange( *aNewRanges[ nR] );
ScCellIterator aIter( pDoc, aRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aIter.first(); bHasCell; bHasCell = aIter.next())
{
- if ( pCell->GetCellType() == CELLTYPE_FORMULA )
- {
- ScFormulaCell* pFCell = (ScFormulaCell*) pCell;
+ const ScCellValue& rVal = aIter.get();
+ if (rVal.meType != CELLTYPE_FORMULA)
+ continue;
- ScDetectiveRefIter aRefIter( pFCell );
- ScRange aRefRange;
- while ( aRefIter.GetNextRef( aRefRange) )
- {
- if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
- bFound = sal_True;
- aMarkData.SetMultiMarkArea( aRefRange, sal_True );
- }
+ ScDetectiveRefIter aRefIter(rVal.mpFormula);
+ ScRange aRefRange;
+ while ( aRefIter.GetNextRef( aRefRange) )
+ {
+ if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aRefRange ) )
+ bFound = true;
+ aMarkData.SetMultiMarkArea(aRefRange, true);
}
- pCell = aIter.GetNext();
}
}
@@ -3928,33 +3915,32 @@ uno::Reference<sheet::XSheetCellRanges> SAL_CALL ScCellRangesBase::queryDependen
SCTAB nTab = lcl_FirstTab(aNewRanges); //! alle Tabellen
ScCellIterator aCellIter( pDoc, 0,0, nTab, MAXCOL,MAXROW, nTab );
- ScBaseCell* pCell = aCellIter.GetFirst();
- while (pCell)
+ for (bool bHasCell = aCellIter.first(); bHasCell; bHasCell = aCellIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ const ScCellValue& rVal = aCellIter.get();
+ if (rVal.meType != CELLTYPE_FORMULA)
+ continue;
+
+ bool bMark = false;
+ ScDetectiveRefIter aIter(rVal.mpFormula);
+ ScRange aRefRange;
+ while ( aIter.GetNextRef( aRefRange) )
{
- sal_Bool bMark = false;
- ScDetectiveRefIter aIter( (ScFormulaCell*) pCell );
- ScRange aRefRange;
- while ( aIter.GetNextRef( aRefRange) )
- {
- size_t nRangesCount = aNewRanges.size();
- for (size_t nR = 0; nR < nRangesCount; ++nR)
- {
- ScRange aRange( *aNewRanges[ nR ] );
- if (aRange.Intersects(aRefRange))
- bMark = sal_True; // von Teil des Ranges abhaengig
- }
- }
- if (bMark)
+ size_t nRangesCount = aNewRanges.size();
+ for (size_t nR = 0; nR < nRangesCount; ++nR)
{
- ScRange aCellRange(aCellIter.GetPos());
- if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
- bFound = sal_True;
- aMarkData.SetMultiMarkArea( aCellRange, sal_True );
+ ScRange aRange( *aNewRanges[ nR ] );
+ if (aRange.Intersects(aRefRange))
+ bMark = sal_True; // von Teil des Ranges abhaengig
}
}
- pCell = aCellIter.GetNext();
+ if (bMark)
+ {
+ ScRange aCellRange(aCellIter.GetPos());
+ if ( bRecursive && !bFound && !aMarkData.IsAllMarked( aCellRange ) )
+ bFound = true;
+ aMarkData.SetMultiMarkArea(aCellRange, true);
+ }
}
aMarkData.FillRangeListWithMarks( &aNewRanges, sal_True );
commit 9b5561558cdaa2c331b6d965f273c8994b4a1d12
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 14:27:35 2013 -0400
Nobody uses CELLTYPE_SYMBOLS anymore. Chuck it away.
Change-Id: I7b9b221c3536c94fbf56c9b5230e62927efe6e1f
diff --git a/sc/inc/global.hxx b/sc/inc/global.hxx
index b1dd688..26d8539 100644
--- a/sc/inc/global.hxx
+++ b/sc/inc/global.hxx
@@ -271,7 +271,6 @@ enum CellType
CELLTYPE_FORMULA,
CELLTYPE_NOTE,
CELLTYPE_EDIT,
- CELLTYPE_SYMBOLS // for load/save
#if OSL_DEBUG_LEVEL > 0
,CELLTYPE_DESTROYED
#endif
diff --git a/sc/source/core/data/autonamecache.cxx b/sc/source/core/data/autonamecache.cxx
index f0e98dc..8a79864 100644
--- a/sc/source/core/data/autonamecache.cxx
+++ b/sc/source/core/data/autonamecache.cxx
@@ -75,7 +75,6 @@ const ScAutoNameAddresses& ScAutoNameCache::GetNameOccurrences( const String& rN
case CELLTYPE_NONE:
case CELLTYPE_VALUE:
case CELLTYPE_NOTE:
- case CELLTYPE_SYMBOLS:
#if OSL_DEBUG_LEVEL > 0
case CELLTYPE_DESTROYED:
#endif
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a9857e2..2aad01a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -3055,7 +3055,6 @@ bool ScCompiler::IsColRowName( const String& rName )
case CELLTYPE_NONE:
case CELLTYPE_VALUE:
case CELLTYPE_NOTE:
- case CELLTYPE_SYMBOLS:
#if OSL_DEBUG_LEVEL > 0
case CELLTYPE_DESTROYED:
#endif
@@ -3184,7 +3183,6 @@ bool ScCompiler::IsColRowName( const String& rName )
case CELLTYPE_NONE:
case CELLTYPE_VALUE:
case CELLTYPE_NOTE:
- case CELLTYPE_SYMBOLS:
#if OSL_DEBUG_LEVEL > 0
case CELLTYPE_DESTROYED:
#endif
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index d78efe6..752c595 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -531,7 +531,6 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCel
case CELLTYPE_NOTE:
fValue = 0.0; // empty or broadcaster cell
break;
- case CELLTYPE_SYMBOLS:
#if OSL_DEBUG_LEVEL > 0
case CELLTYPE_DESTROYED:
#endif
diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx
index fcb7121..8eed3b7 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2626,7 +2626,6 @@ void ScChart2DataSequence::BuildDataCache()
case CELLTYPE_NONE:
case CELLTYPE_NOTE:
case CELLTYPE_STRING:
- case CELLTYPE_SYMBOLS:
default:
; // do nothing
}
commit 98c408356cffbf48fad596168399143e17321555
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Fri Mar 22 14:21:25 2013 -0400
Use ScCellValue instead of ScBaseCell in ScCellIterator.
But of course such migration has to be done in gradual steps. For now,
ScCellIterator supports both methods.
Change-Id: I40cd8969b05598fe20916e43a5537217e824d418
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 1935b7a..2ee7004 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -143,7 +143,8 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/drawpage \
sc/source/core/data/drwlayer \
sc/source/core/data/fillinfo \
- sc/source/core/data/funcdesc \
+ sc/source/core/data/formulaiter \
+ sc/source/core/data/funcdesc \
sc/source/core/data/global \
sc/source/core/data/global2 \
sc/source/core/data/globalx \
diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx
index 4230272..0d34698 100644
--- a/sc/inc/cell.hxx
+++ b/sc/inc/cell.hxx
@@ -602,18 +602,6 @@ public:
bool InterpretFormulaGroup();
};
-// Iterator for references in a formula cell
-class ScDetectiveRefIter
-{
-private:
- ScTokenArray* pCode;
- ScAddress aPos;
-public:
- ScDetectiveRefIter( ScFormulaCell* pCell );
- bool GetNextRef( ScRange& rRange );
- ScToken* GetNextRefToken();
-};
-
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index c104a33..80f3738 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -24,6 +24,7 @@
#include <tools/solar.h>
#include "global.hxx"
#include "scdllapi.h"
+#include "cellvalue.hxx"
#include <memory>
@@ -217,11 +218,13 @@ private:
ScAddress maStartPos;
ScAddress maEndPos;
ScAddress maCurPos;
+ ScCellValue maCurCell;
SCSIZE nColRow;
bool bSubTotal;
ScBaseCell* GetThis();
void init();
+ bool getCurrent();
public:
ScCellIterator(ScDocument* pDocument,
SCCOL nSCol, SCROW nSRow, SCTAB nSTab,
@@ -232,6 +235,11 @@ public:
ScBaseCell* GetFirst();
ScBaseCell* GetNext();
const ScAddress& GetPos() const { return maCurPos; }
+
+ bool first();
+ bool next();
+
+ const ScCellValue& get() const;
};
class ScQueryCellIterator // walk through all non-empty cells in an area
diff --git a/sc/inc/formulaiter.hxx b/sc/inc/formulaiter.hxx
new file mode 100644
index 0000000..dbde7e1
--- /dev/null
+++ b/sc/inc/formulaiter.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef SC_FORMULAITER_HXX
+#define SC_FORMULAITER_HXX
+
+#include "address.hxx"
+
+class ScTokenArray;
+class ScFormulaCell;
+class ScToken;
+
+/**
+ * Iterator for references in a formula cell.
+ */
+class ScDetectiveRefIter
+{
+private:
+ ScTokenArray* pCode;
+ ScAddress aPos;
+public:
+ ScDetectiveRefIter( ScFormulaCell* pCell );
+ bool GetNextRef( ScRange& rRange );
+ ScToken* GetNextRefToken();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 4aac6b5..aa777e5 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1980,61 +1980,4 @@ EditTextObject* ScFormulaCell::CreateURLObject()
return CreateURLObjectFromURL( *pDocument, aURL, aCellText );
}
-// ============================================================================
-
-ScDetectiveRefIter::ScDetectiveRefIter( ScFormulaCell* pCell )
-{
- pCode = pCell->GetCode();
- pCode->Reset();
- aPos = pCell->aPos;
-}
-
-static bool lcl_ScDetectiveRefIter_SkipRef( ScToken* p )
-{
- ScSingleRefData& rRef1 = p->GetSingleRef();
- if ( rRef1.IsColDeleted() || rRef1.IsRowDeleted() || rRef1.IsTabDeleted()
- || !rRef1.Valid() )
- return true;
- if ( p->GetType() == svDoubleRef || p->GetType() == svExternalDoubleRef )
- {
- ScSingleRefData& rRef2 = p->GetDoubleRef().Ref2;
- if ( rRef2.IsColDeleted() || rRef2.IsRowDeleted() || rRef2.IsTabDeleted()
- || !rRef2.Valid() )
- return true;
- }
- return false;
-}
-
-bool ScDetectiveRefIter::GetNextRef( ScRange& rRange )
-{
- bool bRet = false;
- ScToken* p = GetNextRefToken();
- if( p )
- {
- SingleDoubleRefProvider aProv( *p );
- rRange.aStart.Set( aProv.Ref1.nCol, aProv.Ref1.nRow, aProv.Ref1.nTab );
- rRange.aEnd.Set( aProv.Ref2.nCol, aProv.Ref2.nRow, aProv.Ref2.nTab );
- bRet = true;
- }
-
- return bRet;
-}
-
-ScToken* ScDetectiveRefIter::GetNextRefToken()
-{
- ScToken* p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
- if (p)
- p->CalcAbsIfRel( aPos );
-
- while ( p && lcl_ScDetectiveRefIter_SkipRef( p ) )
- {
- p = static_cast<ScToken*>(pCode->GetNextReferenceRPN());
- if (p)
- p->CalcAbsIfRel( aPos );
- }
- return p;
-}
-
-// ============================================================================
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index d5417d5..5446bbc 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -36,12 +36,12 @@
#include "queryentry.hxx"
#include "globstr.hrc"
#include "tools/fract.hxx"
+#include "editeng/editobj.hxx"
#include <vector>
using ::rtl::math::approxEqual;
using ::std::vector;
-using ::rtl::OUString;
using ::std::set;
// STATIC DATA -----------------------------------------------------------
@@ -1051,6 +1051,111 @@ ScBaseCell* ScCellIterator::GetNext()
return GetThis();
}
+bool ScCellIterator::getCurrent()
+{
+ ScColumn* pCol = &(pDoc->maTabs[maCurPos.Tab()])->aCol[maCurPos.Col()];
+ while (true)
+ {
+ if (maCurPos.Row() > maEndPos.Row())
+ {
+ maCurPos.SetRow(maStartPos.Row());
+ do
+ {
+ maCurPos.IncCol();
+ if (maCurPos.Col() > maEndPos.Col())
+ {
+ maCurPos.SetCol(maStartPos.Col());
+ maCurPos.IncTab();
+ if (maCurPos.Tab() > maEndPos.Tab())
+ {
+ maCurCell.clear();
+ return false; // Over and out
+ }
+ }
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list