sc/inc/cellform.hxx | 2 sc/inc/document.hxx | 5 -- sc/source/core/data/cell.cxx | 13 ++--- sc/source/core/data/cell2.cxx | 31 +++++--------- sc/source/core/data/colorscale.cxx | 8 +-- sc/source/core/data/column.cxx | 2 sc/source/core/data/documen7.cxx | 12 ----- sc/source/core/data/table4.cxx | 5 -- sc/source/core/data/table5.cxx | 6 +- sc/source/core/inc/interpre.hxx | 6 +- sc/source/core/tool/cellform.cxx | 4 - sc/source/core/tool/chartarr.cxx | 4 - sc/source/core/tool/compiler.cxx | 6 +- sc/source/core/tool/detfunc.cxx | 37 +++++++--------- sc/source/core/tool/interpr4.cxx | 81 ++++++++++++++++++++++++++++--------- sc/source/core/tool/interpr5.cxx | 3 - sc/source/filter/xml/xmlcelli.cxx | 3 - sc/source/ui/docshell/docsh.cxx | 6 +- sc/source/ui/docshell/impex.cxx | 10 ++-- sc/source/ui/unoobj/cellsuno.cxx | 2 sc/source/ui/unoobj/chart2uno.cxx | 2 sc/source/ui/view/output2.cxx | 6 ++ 22 files changed, 138 insertions(+), 116 deletions(-)
New commits: commit 4e9ff08285b3be412dcb3e1dd314ace004aa65b4 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Mar 28 01:07:36 2013 -0400 A bit more. Change-Id: I7617bfa094ba8e6fb2c19944362bd604f5299732 diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index 0dff21a..cee5df3 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -723,17 +723,16 @@ void ScFormulaCell::GetFormula( rtl::OUStringBuffer& rBuffer, * pCell only if (!this->IsInChangeTrack()), * GetEnglishFormula() omitted that test. * Can we live without in all cases? */ - ScBaseCell* pCell; + ScFormulaCell* pCell = NULL; ScSingleRefData& rRef = p->GetSingleRef(); rRef.CalcAbsIfRel( aPos ); if ( rRef.Valid() ) - pCell = pDocument->GetCell( ScAddress( rRef.nCol, - rRef.nRow, rRef.nTab ) ); - else - pCell = NULL; - if (pCell && pCell->GetCellType() == CELLTYPE_FORMULA) + pCell = pDocument->GetFormulaCell( + ScAddress(rRef.nCol, rRef.nRow, rRef.nTab)); + + if (pCell) { - ((ScFormulaCell*)pCell)->GetFormula( rBuffer, eGrammar); + pCell->GetFormula( rBuffer, eGrammar); return; } else diff --git a/sc/source/core/tool/detfunc.cxx b/sc/source/core/tool/detfunc.cxx index 958162f..cd75cdd 100644 --- a/sc/source/core/tool/detfunc.cxx +++ b/sc/source/core/tool/detfunc.cxx @@ -67,6 +67,7 @@ #include "rangelst.hxx" #include "reftokenhelper.hxx" #include "formulaiter.hxx" +#include "cellvalue.hxx" #include <vector> @@ -821,14 +822,12 @@ sal_uInt16 ScDetectiveFunc::InsertPredLevelArea( const ScRange& rRef, sal_uInt16 ScDetectiveFunc::InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ) { - ScBaseCell* pCell; - pDoc->GetCell( nCol, nRow, nTab, pCell ); - if (!pCell) - return DET_INS_EMPTY; - if (pCell->GetCellType() != CELLTYPE_FORMULA) + ScRefCellValue aCell; + aCell.assign(*pDoc, ScAddress(nCol, nRow, nTab)); + if (aCell.meType != CELLTYPE_FORMULA) return DET_INS_EMPTY; - ScFormulaCell* pFCell = (ScFormulaCell*)pCell; + ScFormulaCell* pFCell = aCell.mpFormula; if (pFCell->IsRunning()) return DET_INS_CIRCULAR; @@ -838,7 +837,7 @@ sal_uInt16 ScDetectiveFunc::InsertPredLevel( SCCOL nCol, SCROW nRow, ScDetective sal_uInt16 nResult = DET_INS_EMPTY; - ScDetectiveRefIter aIter( (ScFormulaCell*) pCell ); + ScDetectiveRefIter aIter(pFCell); ScRange aRef; while ( aIter.GetNextRef( aRef ) ) { @@ -912,14 +911,12 @@ sal_uInt16 ScDetectiveFunc::FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nL { OSL_ENSURE( nLevel<1000, "Level" ); - ScBaseCell* pCell; - pDoc->GetCell( nCol, nRow, nTab, pCell ); - if (!pCell) - return nLevel; - if (pCell->GetCellType() != CELLTYPE_FORMULA) + ScRefCellValue aCell; + aCell.assign(*pDoc, ScAddress(nCol, nRow, nTab)); + if (aCell.meType != CELLTYPE_FORMULA) return nLevel; - ScFormulaCell* pFCell = (ScFormulaCell*)pCell; + ScFormulaCell* pFCell = aCell.mpFormula; if (pFCell->IsRunning()) return nLevel; @@ -935,7 +932,7 @@ sal_uInt16 ScDetectiveFunc::FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nL DeleteArrowsAt( nCol, nRow, sal_True ); // Pfeile, die hierher zeigen } - ScDetectiveRefIter aIter( (ScFormulaCell*) pCell ); + ScDetectiveRefIter aIter(pFCell); ScRange aRef; while ( aIter.GetNextRef( aRef) ) { @@ -974,14 +971,12 @@ sal_uInt16 ScDetectiveFunc::FindPredLevel( SCCOL nCol, SCROW nRow, sal_uInt16 nL sal_uInt16 ScDetectiveFunc::InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiveData& rData, sal_uInt16 nLevel ) { - ScBaseCell* pCell; - pDoc->GetCell( nCol, nRow, nTab, pCell ); - if (!pCell) - return DET_INS_EMPTY; - if (pCell->GetCellType() != CELLTYPE_FORMULA) + ScRefCellValue aCell; + aCell.assign(*pDoc, ScAddress(nCol, nRow, nTab)); + if (aCell.meType != CELLTYPE_FORMULA) return DET_INS_EMPTY; - ScFormulaCell* pFCell = (ScFormulaCell*)pCell; + ScFormulaCell* pFCell = aCell.mpFormula; if (pFCell->IsRunning()) return DET_INS_CIRCULAR; @@ -991,7 +986,7 @@ sal_uInt16 ScDetectiveFunc::InsertErrorLevel( SCCOL nCol, SCROW nRow, ScDetectiv sal_uInt16 nResult = DET_INS_EMPTY; - ScDetectiveRefIter aIter( (ScFormulaCell*) pCell ); + ScDetectiveRefIter aIter(pFCell); ScRange aRef; ScAddress aErrorPos; sal_Bool bHasError = false; commit ba2e263b76dfca0f513a05dba295a5b0e8d35c47 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Mar 28 00:54:35 2013 -0400 Reduce calls to ScDocument::GetCell(). Change-Id: I39196eced68d25b6b2ae1378f712564badfc4572 diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx index 373d6e6..08561f8 100644 --- a/sc/inc/cellform.hxx +++ b/sc/inc/cellform.hxx @@ -48,7 +48,7 @@ public: bool bUseStarFormat = false ); static OUString GetString( - const ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat, + ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat, Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true, bool bFormula = false, ScForceTextFmt eForceTextFmt = ftDontForce, bool bUseStarFormat = false ); diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index ec944f6..88fcd11 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1706,15 +1706,12 @@ public: void EndListeningArea( const ScRange& rRange, SvtListener* pListener ); /** Broadcast wrapper, calls - SC_DLLPUBLIC rHint.GetCell()->Broadcast() and AreaBroadcast() + rHint.GetCell()->Broadcast() and AreaBroadcast() and TrackFormulas() and conditional format list SourceChanged(). Preferred. */ void Broadcast( const ScHint& rHint ); - /// deprecated - void Broadcast( sal_uLong nHint, const ScAddress& rAddr, - ScBaseCell* pCell ); /// only area, no cell broadcast void AreaBroadcast( const ScHint& rHint ); /// only areas in range, no cell broadcasts diff --git a/sc/source/core/data/cell2.cxx b/sc/source/core/data/cell2.cxx index 7603b05..b443d65 100644 --- a/sc/source/core/data/cell2.cxx +++ b/sc/source/core/data/cell2.cxx @@ -593,7 +593,7 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) rOrgPos = aOrg; ScFormulaCell* pFCell; if ( cMatrixFlag == MM_REFERENCE ) - pFCell = (ScFormulaCell*) pDocument->GetCell( aOrg ); + pFCell = pDocument->GetFormulaCell(aOrg); else pFCell = this; // this MM_FORMULA // There's only one this, don't compare pFCell==this. @@ -607,17 +607,15 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) nC = 1; nR = 1; ScAddress aTmpOrg; - ScBaseCell* pCell; + ScFormulaCell* pCell; ScAddress aAdr( aOrg ); aAdr.IncCol(); bool bCont = true; do { - pCell = pDocument->GetCell( aAdr ); - if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA - && ((ScFormulaCell*)pCell)->cMatrixFlag == MM_REFERENCE - && ((ScFormulaCell*)pCell)->GetMatrixOrigin( aTmpOrg ) - && aTmpOrg == aOrg ) + pCell = pDocument->GetFormulaCell(aAdr); + if (pCell && pCell->cMatrixFlag == MM_REFERENCE && + pCell->GetMatrixOrigin(aTmpOrg) && aTmpOrg == aOrg) { nC++; aAdr.IncCol(); @@ -630,11 +628,9 @@ sal_uInt16 ScFormulaCell::GetMatrixEdge( ScAddress& rOrgPos ) bCont = true; do { - pCell = pDocument->GetCell( aAdr ); - if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA - && ((ScFormulaCell*)pCell)->cMatrixFlag == MM_REFERENCE - && ((ScFormulaCell*)pCell)->GetMatrixOrigin( aTmpOrg ) - && aTmpOrg == aOrg ) + pCell = pDocument->GetFormulaCell(aAdr); + if (pCell && pCell->cMatrixFlag == MM_REFERENCE && + pCell->GetMatrixOrigin(aTmpOrg) && aTmpOrg == aOrg) { nR++; aAdr.IncRow(); @@ -1766,13 +1762,10 @@ bool ScFormulaCell::InterpretFormulaGroup() InterpretTail( SCITP_NORMAL ); for ( sal_Int32 i = 0; i < xGroup->mnLength; i++ ) { - ScBaseCell *pBaseCell = NULL; - pDocument->GetCell( aPos.Col(), - xGroup->mnStart + i, - aPos.Tab(), pBaseCell ); - assert( pBaseCell != NULL ); - assert( pBaseCell->GetCellType() == CELLTYPE_FORMULA ); - ScFormulaCell *pCell = static_cast<ScFormulaCell *>( pBaseCell ); + ScAddress aTmpPos = aPos; + aTmpPos.SetRow(xGroup->mnStart + i); + ScFormulaCell* pCell = pDocument->GetFormulaCell(aTmpPos); + assert( pCell != NULL ); // FIXME: this set of horrors is unclear to me ... certainly // the above GetCell is profoundly nasty & slow ... diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 754cbdc..f7d3493 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -282,7 +282,7 @@ std::vector<double>& ScColorFormat::getValues() const } else if(eType == CELLTYPE_FORMULA) { - if(static_cast<ScFormulaCell*>(mpDoc->GetCell(aAddr))->IsValue()) + if (mpDoc->GetFormulaCell(aAddr)->IsValue()) { double aVal = mpDoc->GetValue(nCol, nRow, nTab); rValues.push_back(aVal); @@ -406,7 +406,7 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const if (eCellType == CELLTYPE_FORMULA) { - if(!static_cast<ScFormulaCell*>(mpDoc->GetCell(rAddr))->IsValue()) + if (!mpDoc->GetFormulaCell(rAddr)->IsValue()) return NULL; } @@ -663,7 +663,7 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const if (eCellType == CELLTYPE_FORMULA) { - if(!static_cast<ScFormulaCell*>(mpDoc->GetCell(rAddr))->IsValue()) + if (!mpDoc->GetFormulaCell(rAddr)->IsValue()) return NULL; } @@ -801,7 +801,7 @@ ScIconSetInfo* ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const if (eCellType == CELLTYPE_FORMULA) { - if(!static_cast<ScFormulaCell*>(mpDoc->GetCell(rAddr))->IsValue()) + if (!mpDoc->GetFormulaCell(rAddr)->IsValue()) return NULL; } diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 150b5ad..1712fbe 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -221,7 +221,7 @@ bool ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const ScFormulaCell* pFCell; if ( ((ScFormulaCell*)pCell)->GetMatrixFlag() == MM_REFERENCE ) - pFCell = (ScFormulaCell*) pDocument->GetCell( aOrg ); + pFCell = pDocument->GetFormulaCell(aOrg); else pFCell = (ScFormulaCell*)pCell; SCCOL nC; diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index f813464..96ebc36 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -62,18 +62,6 @@ void ScDocument::EndListeningArea( const ScRange& rRange, pBASM->EndListeningArea( rRange, pListener ); } - -void ScDocument::Broadcast( sal_uLong nHint, const ScAddress& rAddr, - ScBaseCell* pCell - ) -{ - if ( !pBASM ) - return ; // Clipboard or Undo - ScHint aHint(nHint, rAddr, pCell ? pCell->GetBroadcaster() : NULL); - Broadcast( aHint ); -} - - void ScDocument::Broadcast( const ScHint& rHint ) { if ( !pBASM ) diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 6970b54..b467745 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -440,9 +440,8 @@ void ScTable::FillFormula(sal_uLong& /* nFormulaCounter */, bool /* bFirst */, S { if ( nDestCol >= aOrg.Col() && nDestRow >= aOrg.Row() ) { - ScBaseCell* pOrgCell = pDocument->GetCell( aOrg ); - if ( pOrgCell && pOrgCell->GetCellType() == CELLTYPE_FORMULA - && ((ScFormulaCell*)pOrgCell)->GetMatrixFlag() == MM_FORMULA ) + ScFormulaCell* pOrgCell = pDocument->GetFormulaCell(aOrg); + if (pOrgCell && pOrgCell->GetMatrixFlag() == MM_FORMULA) { ((ScFormulaCell*)pOrgCell)->SetMatColsRows( nDestCol - aOrg.Col() + 1, diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx index 644b1a6..86e6b4f 100644 --- a/sc/source/core/data/table5.cxx +++ b/sc/source/core/data/table5.cxx @@ -1166,7 +1166,7 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p switch ( pCell->GetCellType() ) { case CELLTYPE_VALUE : - pDocument->Broadcast(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), pCell); + pDocument->Broadcast(ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster())); break; case CELLTYPE_FORMULA : ((ScFormulaCell*)pCell)->SetDirty(); @@ -1208,8 +1208,8 @@ void ScTable::InvalidateTextWidth( const ScAddress* pAdrFrom, const ScAddress* p switch ( pCell->GetCellType() ) { case CELLTYPE_VALUE : - pDocument->Broadcast( SC_HINT_DATACHANGED, - ScAddress( nCol, nRow, nTab ), pCell ); + pDocument->Broadcast( + ScHint(SC_HINT_DATACHANGED, ScAddress(nCol, nRow, nTab), pCell->GetBroadcaster())); break; case CELLTYPE_FORMULA : ((ScFormulaCell*)pCell)->SetDirty(); diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 760a0c7..0fdc89c 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -52,6 +52,7 @@ struct ScComplexRefData; class ScToken; class ScJumpMatrix; class ScCellIterator; +class ScRefCellValue; #define MAXSTACK (4096 / sizeof(formula::FormulaToken*)) @@ -187,12 +188,13 @@ bool IsTableOpInRange( const ScRange& ); sal_uLong GetCellNumberFormat( const ScAddress&, const ScBaseCell* ); double ConvertStringToValue( const String& ); double GetCellValue( const ScAddress&, const ScBaseCell* ); -double GetCellValue( ScCellIterator& rIter ); +double GetCellValue( const ScAddress&, ScRefCellValue& rCell ); double GetCellValueOrZero( const ScAddress&, const ScBaseCell* ); -double GetCellValueOrZero( ScCellIterator& rIter ); +double GetCellValueOrZero( const ScAddress&, ScRefCellValue& rCell ); double GetValueCellValue( const ScAddress&, const ScValueCell* ); ScBaseCell* GetCell( const ScAddress& rPos ); void GetCellString( String& rStr, const ScBaseCell* pCell ); +void GetCellString( OUString& rStr, ScRefCellValue& rCell ); sal_uInt16 GetCellErrCode( const ScBaseCell* pCell ); CellType GetCellType( const ScBaseCell* pCell ); bool HasCellEmptyData( const ScBaseCell* pCell ); diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index d60627b..1ddfaaa 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -136,7 +136,7 @@ void ScCellFormat::GetString( ScRefCellValue& rCell, sal_uLong nFormat, OUString } OUString ScCellFormat::GetString( - const ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat, Color** ppColor, + ScDocument& rDoc, const ScAddress& rPos, sal_uLong nFormat, Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals, bool bFormula, ScForceTextFmt eForceTextFmt, bool bUseStarFormat ) { @@ -180,7 +180,7 @@ OUString ScCellFormat::GetString( break; case CELLTYPE_FORMULA: { - ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(rDoc.GetCell(rPos)); + ScFormulaCell* pFCell = rDoc.GetFormulaCell(rPos); if (bFormula) { pFCell->GetFormula(aString); diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index e88c6c1..34f4605 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -116,7 +116,7 @@ ScMemChart* ScChartArray::CreateMemChart() namespace { -double getCellValue( const ScDocument& rDoc, const ScAddress& rPos, double fDefault, bool bCalcAsShown ) +double getCellValue( ScDocument& rDoc, const ScAddress& rPos, double fDefault, bool bCalcAsShown ) { double fRet = fDefault; @@ -135,7 +135,7 @@ double getCellValue( const ScDocument& rDoc, const ScAddress& rPos, double fDefa break; case CELLTYPE_FORMULA: { - ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(rDoc.GetCell(rPos)); + ScFormulaCell* pFCell = rDoc.GetFormulaCell(rPos); if (!pFCell->GetErrCode() && pFCell->IsValue()) fRet = pFCell->GetValue(); } diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx index 80428a4..b8bf5dd 100644 --- a/sc/source/core/tool/compiler.cxx +++ b/sc/source/core/tool/compiler.cxx @@ -5277,8 +5277,10 @@ bool ScCompiler::HandleSingleRef() } if ( !bInList && pDoc->GetDocOptions().IsLookUpColRowNames() ) { // automagically or created by copying and NamePos isn't in list - bool bString = pDoc->HasStringData( nCol, nRow, nTab ); - if ( !bString && !pDoc->GetCell( aLook ) ) + ScRefCellValue aCell; + aCell.assign(*pDoc, aLook); + bool bString = aCell.hasString(); + if (!bString && aCell.isEmpty()) bString = true; // empty cell is ok if ( bString ) { //! coresponds with ScInterpreter::ScColRowNameAuto() diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index bfd9494..475ae3e 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -470,11 +470,11 @@ double ScInterpreter::GetCellValue( const ScAddress& rPos, const ScBaseCell* pCe return nVal; } -double ScInterpreter::GetCellValue( ScCellIterator& rIter ) +double ScInterpreter::GetCellValue( const ScAddress& rPos, ScRefCellValue& rCell ) { sal_uInt16 nErr = nGlobalError; nGlobalError = 0; - double nVal = GetCellValueOrZero(rIter); + double nVal = GetCellValueOrZero(rPos, rCell); if ( !nGlobalError || nGlobalError == errCellNoValue ) nGlobalError = nErr; return nVal; @@ -552,18 +552,16 @@ double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCel return fValue; } -double ScInterpreter::GetCellValueOrZero( ScCellIterator& rIter ) +double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& rCell ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetCellValueOrZero" ); double fValue = 0.0; - CellType eType = rIter.getType(); - const ScAddress& rPos = rIter.GetPos(); + CellType eType = rCell.meType; switch (eType) { case CELLTYPE_FORMULA: { - ScFormulaCell* pFCell = rIter.getFormulaCell(); + ScFormulaCell* pFCell = rCell.mpFormula; sal_uInt16 nErr = pFCell->GetErrCode(); if( !nErr ) { @@ -588,7 +586,7 @@ double ScInterpreter::GetCellValueOrZero( ScCellIterator& rIter ) break; case CELLTYPE_VALUE: { - fValue = rIter.getValue(); + fValue = rCell.mfValue; nCurFmtIndex = pDok->GetNumberFormat( rPos ); nCurFmtType = pFormatter->GetType( nCurFmtIndex ); if ( bCalcAsShown && fValue != 0.0 ) @@ -600,7 +598,7 @@ double ScInterpreter::GetCellValueOrZero( ScCellIterator& rIter ) { // SUM(A1:A2) differs from A1+A2. No good. But people insist on // it ... #i5658# - OUString aStr = rIter.getString(); + OUString aStr = rCell.getString(); fValue = ConvertStringToValue( aStr ); } break; @@ -673,6 +671,48 @@ void ScInterpreter::GetCellString( String& rStr, const ScBaseCell* pCell ) SetError(nErr); } +void ScInterpreter::GetCellString( OUString& rStr, ScRefCellValue& rCell ) +{ + sal_uInt16 nErr = 0; + + switch (rCell.meType) + { + case CELLTYPE_STRING: + case CELLTYPE_EDIT: + rStr = rCell.getString(); + break; + case CELLTYPE_FORMULA: + { + ScFormulaCell* pFCell = rCell.mpFormula; + nErr = pFCell->GetErrCode(); + if (pFCell->IsValue()) + { + double fVal = pFCell->GetValue(); + sal_uLong nIndex = pFormatter->GetStandardFormat( + NUMBERFORMAT_NUMBER, + ScGlobal::eLnge); + pFormatter->GetInputLineString(fVal, nIndex, rStr); + } + else + rStr = pFCell->GetString(); + } + break; + case CELLTYPE_VALUE: + { + double fVal = rCell.mfValue; + sal_uLong nIndex = pFormatter->GetStandardFormat( + NUMBERFORMAT_NUMBER, + ScGlobal::eLnge); + pFormatter->GetInputLineString(fVal, nIndex, rStr); + } + break; + default: + rStr = ScGlobal::GetEmptyString(); + break; + } + + SetError(nErr); +} bool ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2, sal_uInt8* pCellArr) @@ -3651,15 +3691,18 @@ void ScInterpreter::ScTableOp() } pTableOp->bCollectNotifications = false; - ScBaseCell* pFCell = pDok->GetCell( pTableOp->aFormulaPos ); - if ( pFCell && pFCell->GetCellType() == CELLTYPE_FORMULA ) - ((ScFormulaCell*)pFCell)->SetDirtyVar(); - if ( HasCellValueData( pFCell ) ) - PushDouble( GetCellValue( pTableOp->aFormulaPos, pFCell )); + ScRefCellValue aCell; + aCell.assign(*pDok, pTableOp->aFormulaPos); + if (aCell.meType == CELLTYPE_FORMULA) + aCell.mpFormula->SetDirtyVar(); + if (aCell.hasNumeric()) + { + PushDouble(GetCellValue(pTableOp->aFormulaPos, aCell)); + } else { - String aCellString; - GetCellString( aCellString, pFCell ); + OUString aCellString; + GetCellString(aCellString, aCell); PushString( aCellString ); } @@ -3681,10 +3724,10 @@ void ScInterpreter::ScTableOp() if ( !bReuseLastParams ) pDok->aLastTableOpParams = *pTableOp; - if ( pFCell && pFCell->GetCellType() == CELLTYPE_FORMULA ) + if (aCell.meType == CELLTYPE_FORMULA) { - ((ScFormulaCell*)pFCell)->SetDirtyVar(); - ((ScFormulaCell*)pFCell)->GetErrCode(); // recalculate original + aCell.mpFormula->SetDirtyVar(); + aCell.mpFormula->GetErrCode(); // recalculate original } // Reset all dirty flags so next incarnation does really collect all cell diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index a9a432c..f574c4a 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -437,7 +437,8 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken if (aCellIter.hasNumeric()) { ScAddress aAdr(nCol, nThisRow, nTab1); - double fVal = GetCellValue(aCellIter); + ScRefCellValue aCell = aCellIter.getRefCellValue(); + double fVal = GetCellValue(aCellIter.GetPos(), aCell); if ( nGlobalError ) { diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index d51e1b5..c57a951 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -1367,8 +1367,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) // cached result. For import, we only need to set the correct // matrix geometry and the value type of the top-left element. - ScFormulaCell* pFCell = - static_cast<ScFormulaCell*>( rXMLImport.GetDocument()->GetCell(rCellPos) ); + ScFormulaCell* pFCell = rXMLImport.GetDocument()->GetFormulaCell(rCellPos); ScMatrixRef pMat(new ScMatrix(nMatrixCols, nMatrixRows)); if (bFormulaTextResult && maStringValue) diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index b9e7517..3fc1bfa 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -475,7 +475,7 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un else { // still need to recalc volatile formula cells. - aDocument.Broadcast( SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL ); + aDocument.Broadcast( ScHint(SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL) ); } aDocument.SetXMLFromWrapper( false ); @@ -2736,7 +2736,7 @@ void ScDocShell::SetDocumentModified( sal_Bool bIsModified /* = sal_True */ ) { // #i115009# broadcast BCA_BRDCST_ALWAYS, so a component can read recalculated results // of RecalcModeAlways formulas (like OFFSET) after modifying cells - aDocument.Broadcast( SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL ); + aDocument.Broadcast( ScHint(SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL) ); aDocument.InvalidateTableArea(); // #i105279# needed here aDocument.BroadcastUno( SfxSimpleHint( SFX_HINT_DATACHANGED ) ); @@ -2756,7 +2756,7 @@ void ScDocShell::SetDocumentModified( sal_Bool bIsModified /* = sal_True */ ) aDocument.InvalidateStyleSheetUsage(); aDocument.InvalidateTableArea(); aDocument.InvalidateLastTableOpParams(); - aDocument.Broadcast( SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL ); + aDocument.Broadcast( ScHint(SC_HINT_DATACHANGED, BCA_BRDCST_ALWAYS, NULL) ); if ( aDocument.IsForcedFormulaPending() && aDocument.GetAutoCalc() ) aDocument.CalcFormulaTree( sal_True ); PostDataChanged(); diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index e35551a..5c525dc 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -48,6 +48,7 @@ #include "patattr.hxx" #include "docpool.hxx" #include "stringutil.hxx" +#include "cellvalue.hxx" #include "globstr.hrc" #include <vcl/svapp.hxx> @@ -1968,9 +1969,9 @@ bool ScImportExport::Doc2Sylk( SvStream& rStrm ) bool bForm = false; SCROW r = nRow - nStartRow + 1; SCCOL c = nCol - nStartCol + 1; - ScBaseCell* pCell; - pDoc->GetCell( nCol, nRow, aRange.aStart.Tab(), pCell ); - CellType eType = (pCell ? pCell->GetCellType() : CELLTYPE_NONE); + ScRefCellValue aCell; + aCell.assign(*pDoc, ScAddress(nCol, nRow, aRange.aStart.Tab())); + CellType eType = aCell.meType; switch( eType ) { case CELLTYPE_FORMULA: @@ -2014,8 +2015,7 @@ bool ScImportExport::Doc2Sylk( SvStream& rStrm ) checkformula: if( bForm ) { - const ScFormulaCell* pFCell = - static_cast<const ScFormulaCell*>(pCell); + const ScFormulaCell* pFCell = aCell.mpFormula; switch ( pFCell->GetMatrixFlag() ) { case MM_REFERENCE : diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 20bd346..502a1ea 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -6605,7 +6605,7 @@ void SAL_CALL ScCellObj::setFormulaResult( double nValue ) throw(uno::RuntimeExc ScDocShell* pDocSh = GetDocShell(); if ( pDocSh && pDocSh->GetDocument()->GetCellType( aCellPos ) == CELLTYPE_FORMULA ) { - ScFormulaCell* pCell = (ScFormulaCell *)pDocSh->GetDocument()->GetCell( aCellPos ); + ScFormulaCell* pCell = pDocSh->GetDocument()->GetFormulaCell(aCellPos); pCell->SetHybridDouble( nValue ); pCell->ResetDirty(); pCell->ResetChanged(); diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 60e65dc..dc02354 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -2608,7 +2608,7 @@ void ScChart2DataSequence::BuildDataCache() break; case CELLTYPE_FORMULA: { - ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(m_pDocument->GetCell(aAdr)); + ScFormulaCell* pFCell = m_pDocument->GetFormulaCell(aAdr); sal_uInt16 nErr = pFCell->GetErrCode(); if (nErr) break; diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index afa0dab..4ecb1fc 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -1080,7 +1080,11 @@ bool ScOutputData::IsEmptyCellText( RowInfo* pThisRowInfo, SCCOL nX, SCROW nY ) if ( pThisRowInfo && nX <= nX2 ) bEmpty = pThisRowInfo->pCellInfo[nX+1].bEmptyCellText; else - bEmpty = ( mpDoc->GetCell( ScAddress( nX, nY, nTab ) ) == NULL ); + { + ScRefCellValue aCell; + aCell.assign(*mpDoc, ScAddress(nX, nY, nTab)); + bEmpty = aCell.isEmpty(); + } if ( !bEmpty && ( nX < nX1 || nX > nX2 || !pThisRowInfo ) ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits