sc/inc/cell.hxx | 1 sc/inc/column.hxx | 1 sc/inc/document.hxx | 25 +++++- sc/inc/table.hxx | 1 sc/source/core/data/column3.cxx | 13 +++ sc/source/core/data/dociter.cxx | 4 - sc/source/core/data/document.cxx | 15 +++- sc/source/core/data/table2.cxx | 8 ++ sc/source/core/inc/interpre.hxx | 2 sc/source/core/tool/interpr1.cxx | 13 +-- sc/source/core/tool/interpr2.cxx | 25 +++--- sc/source/core/tool/interpr4.cxx | 141 ++++++++------------------------------- sc/source/core/tool/interpr5.cxx | 104 ++++++++++++++-------------- 13 files changed, 160 insertions(+), 193 deletions(-)
New commits: commit 15596e85a98805c32db4c9e5bbc9eb509c773733 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Thu Mar 28 12:37:56 2013 -0400 More on removing use of ScBaseCell in ScInterpreter. Change-Id: I4468e04e009da3f2ca5a975f2b1a4aed207922b3 diff --git a/sc/inc/cell.hxx b/sc/inc/cell.hxx index 166649d..7395713 100644 --- a/sc/inc/cell.hxx +++ b/sc/inc/cell.hxx @@ -145,6 +145,7 @@ public: inline void SetValue( double fValue ) { mfValue = fValue; } inline double GetValue() const { return mfValue; } + double* GetValuePtr() { return &mfValue; } private: double mfValue; diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index ba18278..b5d95a4 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -276,6 +276,7 @@ public: void GetString( SCROW nRow, rtl::OUString& rString ) const; const OUString* GetStringCell( SCROW nRow ) const; + double* GetValueCell( SCROW nRow ); void GetInputString( SCROW nRow, rtl::OUString& rString ) const; double GetValue( SCROW nRow ) const; const EditTextObject* GetEditText( SCROW nRow ) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 88fcd11..840c7d1 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -813,6 +813,17 @@ public: * it returns NULL even for a edit cell. */ const OUString* GetStringCell( const ScAddress& rPos ) const; + + /** + * Return a pointer to the double value stored in value cell. + * + * @param rPos cell position + * + * @return pointer to the double value stored in a numeric cell, or NULL + * if the cell at specified position is not a numeric cell. + */ + double* GetValueCell( const ScAddress& rPos ); + SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rString ); SC_DLLPUBLIC void GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, rtl::OUString& rString ); sal_uInt16 GetStringForFormula( const ScAddress& rPos, rtl::OUString& rString ); @@ -827,12 +838,14 @@ public: sal_uInt32 GetNumberFormat( const ScRange& rRange ) const; SC_DLLPUBLIC sal_uInt32 GetNumberFormat( const ScAddress& ) const; void SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberFormat ); - /** If no number format attribute is set and the cell - pointer passed is of type formula cell, the calculated - number format of the formula cell is returned. pCell - may be NULL. */ - SC_DLLPUBLIC void GetNumberFormatInfo( short& nType, sal_uLong& nIndex, - const ScAddress& rPos, const ScBaseCell* pCell ) const; + + /** + * If no number format attribute is set and a formula cell pointer is + * passed, the calculated number format of the formula cell is returned. + * pCell may be NULL. + */ + SC_DLLPUBLIC void GetNumberFormatInfo( short& nType, sal_uLong& nIndex, + const ScAddress& rPos, const ScFormulaCell* pCell ) const; void GetFormula( SCCOL nCol, SCROW nRow, SCTAB nTab, String& rFormula ) const; const ScTokenArray* GetFormulaTokens( const ScAddress& rPos ) const; SC_DLLPUBLIC const ScFormulaCell* GetFormulaCell( const ScAddress& rPos ) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 3ddcbfc..b5d692c 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -319,6 +319,7 @@ public: void GetString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const; const OUString* GetStringCell( SCCOL nCol, SCROW nRow ) const; + double* GetValueCell( SCCOL nCol, SCROW nRow ); void GetInputString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const; double GetValue( const ScAddress& rPos ) const { diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 5316ee0..9bd0ee9 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -1784,6 +1784,19 @@ const OUString* ScColumn::GetStringCell( SCROW nRow ) const return static_cast<const ScStringCell*>(pCell)->GetStringPtr(); } +double* ScColumn::GetValueCell( SCROW nRow ) +{ + SCSIZE nIndex; + if (!Search(nRow, nIndex)) + return NULL; + + ScBaseCell* pCell = maItems[nIndex].pCell; + if (pCell->GetCellType() != CELLTYPE_VALUE) + return NULL; + + return static_cast<ScValueCell*>(pCell)->GetValuePtr(); +} + void ScColumn::GetInputString( SCROW nRow, rtl::OUString& rString ) const { SCSIZE nIndex; diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index c318e04..1875518 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -611,8 +611,8 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) rValue.mfValue = ((ScFormulaCell*)pCell)->GetValue(); rValue.mbIsNumber = true; mpDoc->GetNumberFormatInfo( nNumFmtType, - nNumFmtIndex, ScAddress( nCol, nRow, nTab ), - pCell ); + nNumFmtIndex, ScAddress(nCol, nRow, nTab), + static_cast<ScFormulaCell*>(pCell)); rValue.mnError = ((ScFormulaCell*)pCell)->GetErrCode(); return true; // Found it! } diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 97e66a7..0d82eb6 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3061,6 +3061,14 @@ const OUString* ScDocument::GetStringCell( const ScAddress& rPos ) const return maTabs[rPos.Tab()]->GetStringCell(rPos.Col(), rPos.Row()); } +double* ScDocument::GetValueCell( const ScAddress& rPos ) +{ + if (!TableExists(rPos.Tab())) + return NULL; + + return maTabs[rPos.Tab()]->GetValueCell(rPos.Col(), rPos.Row()); +} + void ScDocument::GetInputString( SCCOL nCol, SCROW nRow, SCTAB nTab, OUString& rString ) { if ( ValidTab(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] ) @@ -3220,15 +3228,14 @@ void ScDocument::SetNumberFormat( const ScAddress& rPos, sal_uInt32 nNumberForma } void ScDocument::GetNumberFormatInfo( short& nType, sal_uLong& nIndex, - const ScAddress& rPos, const ScBaseCell* pCell ) const + const ScAddress& rPos, const ScFormulaCell* pCell ) const { SCTAB nTab = rPos.Tab(); if ( nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab] ) { nIndex = maTabs[nTab]->GetNumberFormat( rPos ); - if ( (nIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && pCell && - pCell->GetCellType() == CELLTYPE_FORMULA ) - static_cast<const ScFormulaCell*>(pCell)->GetFormatInfo( nType, nIndex ); + if ( (nIndex % SV_COUNTRY_LANGUAGE_OFFSET) == 0 && pCell) + pCell->GetFormatInfo(nType, nIndex); else nType = GetFormatTable()->GetType( nIndex ); } diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 253032b..9c95be5 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -1412,6 +1412,14 @@ const OUString* ScTable::GetStringCell( SCCOL nCol, SCROW nRow ) const return aCol[nCol].GetStringCell(nRow); } +double* ScTable::GetValueCell( SCCOL nCol, SCROW nRow ) +{ + if (!ValidColRow(nCol,nRow)) + return NULL; + + return aCol[nCol].GetValueCell(nRow); +} + void ScTable::GetInputString( SCCOL nCol, SCROW nRow, rtl::OUString& rString ) const { if (ValidColRow(nCol,nRow)) diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 4cac100..6fd8dc3 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -187,9 +187,7 @@ void ReplaceCell( SCCOL& rCol, SCROW& rRow, SCTAB& rTab ); // for TableOp bool IsTableOpInRange( const ScRange& ); sal_uLong GetCellNumberFormat( const ScAddress& rPos, ScRefCellValue& rCell ); double ConvertStringToValue( const String& ); -double GetCellValue( const ScAddress&, const ScBaseCell* ); double GetCellValue( const ScAddress&, ScRefCellValue& rCell ); -double GetCellValueOrZero( const ScAddress&, const ScBaseCell* ); double GetCellValueOrZero( const ScAddress&, ScRefCellValue& rCell ); double GetValueCellValue( const ScAddress&, double fOrig ); ScBaseCell* GetCell( const ScAddress& rPos ); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 53ebdf2..f0bfbe5 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -4121,21 +4121,22 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) ++nCount; break; } - ScBaseCell* pCell = GetCell( aAdr ); - if ( pCell ) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (!aCell.isEmpty()) { if( eFunc == ifCOUNT2 ) { - CellType eCellType = pCell->GetCellType(); + CellType eCellType = aCell.meType; if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) nCount++; if ( nGlobalError ) nGlobalError = 0; } - else if ( pCell->HasValueData() ) + else if (aCell.hasNumeric()) { nCount++; - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); CurFmtToFuncFmt(); switch( eFunc ) { @@ -4161,7 +4162,7 @@ double ScInterpreter::IterateParameters( ScIterFunc eFunc, bool bTextAsZero ) default: ; // nothing } } - else if ( bTextAsZero && pCell->HasStringData() ) + else if (bTextAsZero && aCell.hasString()) { nCount++; if ( eFunc == ifPRODUCT ) diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 449806f..c7496b5 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -1748,17 +1748,15 @@ void ScInterpreter::ScBackSolver() if (nGlobalError == 0) { - ScBaseCell* pVCell = GetCell( aValueAdr ); - // CELLTYPE_NOTE: kein Value aber von Formel referiert - ScBaseCell* pFCell = GetCell( aFormulaAdr ); + ScRefCellValue aFCell; + double* pVCell = pDok->GetValueCell(aValueAdr); + aFCell.assign(*pDok, aFormulaAdr); - if ( ((pVCell && pVCell->GetCellType() == CELLTYPE_VALUE)) - && pFCell && pFCell->GetCellType() == CELLTYPE_FORMULA ) + if (pVCell && aFCell.meType == CELLTYPE_FORMULA) { ScRange aVRange( aValueAdr, aValueAdr ); // fuer SetDirty - double fSaveVal; // Original value to be restored later if necessary - - fSaveVal = GetCellValue( aValueAdr, pVCell ); + // Original value to be restored later if necessary + double fSaveVal = *pVCell; const sal_uInt16 nMaxIter = 100; const double fEps = 1E-10; @@ -1768,8 +1766,7 @@ void ScInterpreter::ScBackSolver() double fBestF, fFPrev; fBestX = fXPrev = fSaveVal; - ScFormulaCell* pFormula = (ScFormulaCell*) pFCell; - ScValueCell* pValue = (ScValueCell*) pVCell; + ScFormulaCell* pFormula = aFCell.mpFormula; pFormula->Interpret(); bool bError = ( pFormula->GetErrCode() != 0 ); @@ -1791,7 +1788,7 @@ void ScInterpreter::ScBackSolver() // Nach der Regula Falsi Methode while ( !bDoneIteration && ( nIter++ < nMaxIter ) ) { - pValue->SetValue( fX ); + *pVCell = fX; pDok->SetDirty( aVRange ); pFormula->Interpret(); bError = ( pFormula->GetErrCode() != 0 ); @@ -1825,7 +1822,7 @@ void ScInterpreter::ScBackSolver() else fHorX = fX - fabs(fF)*fHorTangent; - pValue->SetValue( fHorX ); + *pVCell = fHorX; pDok->SetDirty( aVRange ); pFormula->Interpret(); bHorMoveError = ( pFormula->GetErrCode() != 0 ); @@ -1889,7 +1886,7 @@ void ScInterpreter::ScBackSolver() if ( bDoneIteration ) { - pValue->SetValue( nX ); + *pVCell = nX; pDok->SetDirty( aVRange ); pFormula->Interpret(); if ( fabs( pFormula->GetValue() - fTargetVal ) > fabs( fF ) ) @@ -1899,7 +1896,7 @@ void ScInterpreter::ScBackSolver() { nX = fBestX; } - pValue->SetValue( fSaveVal ); + *pVCell = fSaveVal; pDok->SetDirty( aVRange ); pFormula->Interpret(); if ( !bDoneIteration ) diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 8f9133a..4610a77 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -435,18 +435,6 @@ double ScInterpreter::ConvertStringToValue( const String& rStr ) #endif } - -double ScInterpreter::GetCellValue( const ScAddress& rPos, const ScBaseCell* pCell ) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetCellValue" ); - sal_uInt16 nErr = nGlobalError; - nGlobalError = 0; - double nVal = GetCellValueOrZero( rPos, pCell ); - if ( !nGlobalError || nGlobalError == errCellNoValue ) - nGlobalError = nErr; - return nVal; -} - double ScInterpreter::GetCellValue( const ScAddress& rPos, ScRefCellValue& rCell ) { sal_uInt16 nErr = nGlobalError; @@ -457,78 +445,6 @@ double ScInterpreter::GetCellValue( const ScAddress& rPos, ScRefCellValue& rCell return nVal; } -double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, const ScBaseCell* pCell ) -{ - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetCellValueOrZero" ); - double fValue = 0.0; - if (!pCell) - return fValue; - - CellType eType = pCell->GetCellType(); - switch (eType) - { - case CELLTYPE_FORMULA: - { - ScFormulaCell* pFCell = (ScFormulaCell*) pCell; - sal_uInt16 nErr = pFCell->GetErrCode(); - if( !nErr ) - { - if (pFCell->IsValue()) - { - fValue = pFCell->GetValue(); - pDok->GetNumberFormatInfo( nCurFmtType, nCurFmtIndex, - rPos, pFCell ); - } - else - { - String aStr = pFCell->GetString(); - fValue = ConvertStringToValue( aStr ); - } - } - else - { - fValue = 0.0; - SetError(nErr); - } - } - break; - case CELLTYPE_VALUE: - { - fValue = ((ScValueCell*)pCell)->GetValue(); - nCurFmtIndex = pDok->GetNumberFormat( rPos ); - nCurFmtType = pFormatter->GetType( nCurFmtIndex ); - if ( bCalcAsShown && fValue != 0.0 ) - fValue = pDok->RoundValueAsShown( fValue, nCurFmtIndex ); - } - break; - case CELLTYPE_STRING: - case CELLTYPE_EDIT: - { - // SUM(A1:A2) differs from A1+A2. No good. But people insist on - // it ... #i5658# - String aStr; - if ( eType == CELLTYPE_STRING ) - aStr = ((ScStringCell*)pCell)->GetString(); - else - aStr = ((ScEditCell*)pCell)->GetString(); - fValue = ConvertStringToValue( aStr ); - } - break; - case CELLTYPE_NONE: - case CELLTYPE_NOTE: - fValue = 0.0; // empty or broadcaster cell - break; -#if OSL_DEBUG_LEVEL > 0 - case CELLTYPE_DESTROYED: - SetError(errCellNoValue); - fValue = 0.0; - break; -#endif - } - - return fValue; -} - double ScInterpreter::GetCellValueOrZero( const ScAddress& rPos, ScRefCellValue& rCell ) { double fValue = 0.0; @@ -1115,17 +1031,20 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, { ScRefCellValue aCell; aCell.assign(*pDok, rAddress); - ScBaseCell* pCell = pDok->GetCell( rAddress); if (aCell.hasEmptyValue()) { - if (pRetTypeExpr && pRetIndexExpr) - pDok->GetNumberFormatInfo( *pRetTypeExpr, *pRetIndexExpr, rAddress, pCell); bool bInherited = (aCell.meType == CELLTYPE_FORMULA); + if (pRetTypeExpr && pRetIndexExpr) + pDok->GetNumberFormatInfo(*pRetTypeExpr, *pRetIndexExpr, rAddress, (bInherited ? aCell.mpFormula : NULL)); PushTempToken( new ScEmptyCellToken( bInherited, bDisplayEmptyAsString)); return; } - sal_uInt16 nErr; - if ((nErr = pCell->GetErrorCode()) != 0) + + sal_uInt16 nErr = 0; + if (aCell.meType == CELLTYPE_FORMULA) + nErr = aCell.mpFormula->GetErrCode(); + + if (nErr) { PushError( nErr); if (pRetTypeExpr) @@ -1133,10 +1052,10 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, if (pRetIndexExpr) *pRetIndexExpr = 0; } - else if (pCell->HasStringData()) + else if (aCell.hasString()) { - String aRes; - GetCellString( aRes, pCell); + OUString aRes; + GetCellString( aRes, aCell); PushString( aRes); if (pRetTypeExpr) *pRetTypeExpr = NUMBERFORMAT_TEXT; @@ -1145,7 +1064,7 @@ void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, } else { - double fVal = GetCellValue( rAddress, pCell); + double fVal = GetCellValue(rAddress, aCell); PushDouble( fVal); if (pRetTypeExpr) *pRetTypeExpr = nCurFmtType; @@ -2354,8 +2273,9 @@ double ScInterpreter::GetDouble() { ScAddress aAdr; PopSingleRef( aAdr ); - ScBaseCell* pCell = GetCell( aAdr ); - nVal = GetCellValue( aAdr, pCell ); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + nVal = GetCellValue(aAdr, aCell); } break; case svDoubleRef: @@ -2365,8 +2285,9 @@ double ScInterpreter::GetDouble() ScAddress aAdr; if ( !nGlobalError && DoubleRefToPosSingleRef( aRange, aAdr ) ) { - ScBaseCell* pCell = GetCell( aAdr ); - nVal = GetCellValue( aAdr, pCell ); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + nVal = GetCellValue(aAdr, aCell); } else nVal = 0.0; @@ -3012,15 +2933,16 @@ void ScInterpreter::ScExternal() ScAddress aAdr; if ( PopDoubleRefOrSingleRef( aAdr ) ) { - ScBaseCell* pCell = GetCell( aAdr ); - if ( pCell && pCell->HasStringData() ) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (aCell.hasString()) { - String aStr; - GetCellString( aStr, pCell ); - aElem <<= OUString( aStr ); + OUString aStr; + GetCellString(aStr, aCell); + aElem <<= aStr; } else - aElem <<= (double) GetCellValue( aAdr, pCell ); + aElem <<= GetCellValue(aAdr, aCell); } } uno::Sequence<uno::Any> aInner( &aElem, 1 ); @@ -3062,15 +2984,16 @@ void ScInterpreter::ScExternal() ScAddress aAdr; if ( PopDoubleRefOrSingleRef( aAdr ) ) { - ScBaseCell* pCell = GetCell( aAdr ); - if ( pCell && pCell->HasStringData() ) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (aCell.hasString()) { - String aStr; - GetCellString( aStr, pCell ); - aParam <<= OUString( aStr ); + OUString aStr; + GetCellString(aStr, aCell); + aParam <<= aStr; } else - aParam <<= (double) GetCellValue( aAdr, pCell ); + aParam <<= GetCellValue(aAdr, aCell); } } break; diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index 829a1e0..09196d9 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -3250,67 +3250,71 @@ void ScInterpreter::ScMatRef() Push( (FormulaToken&)*pCur ); ScAddress aAdr; PopSingleRef( aAdr ); - ScFormulaCell* pCell = (ScFormulaCell*) GetCell( aAdr ); - if( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) - { - const ScMatrix* pMat = pCell->GetMatrix(); - if( pMat ) - { - SCSIZE nCols, nRows; - pMat->GetDimensions( nCols, nRows ); - SCSIZE nC = static_cast<SCSIZE>(aPos.Col() - aAdr.Col()); - SCSIZE nR = static_cast<SCSIZE>(aPos.Row() - aAdr.Row()); - if ((nCols <= nC && nCols != 1) || (nRows <= nR && nRows != 1)) - PushNA(); - else - { - const ScMatrixValue nMatVal = pMat->Get( nC, nR); - ScMatValType nMatValType = nMatVal.nType; - if (ScMatrix::IsNonValueType( nMatValType)) - { - if (ScMatrix::IsEmptyPathType( nMatValType)) - { // result of empty false jump path - nFuncFmtType = NUMBERFORMAT_LOGICAL; - PushInt(0); - } - else if (ScMatrix::IsEmptyType( nMatValType)) - { - // Not inherited (really?) and display as empty string, not 0. - PushTempToken( new ScEmptyCellToken( false, true)); - } - else - PushString( nMatVal.GetString() ); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + + if (aCell.meType != CELLTYPE_FORMULA) + { + PushError( errNoRef ); + return; + } + + const ScMatrix* pMat = aCell.mpFormula->GetMatrix(); + if (pMat) + { + SCSIZE nCols, nRows; + pMat->GetDimensions( nCols, nRows ); + SCSIZE nC = static_cast<SCSIZE>(aPos.Col() - aAdr.Col()); + SCSIZE nR = static_cast<SCSIZE>(aPos.Row() - aAdr.Row()); + if ((nCols <= nC && nCols != 1) || (nRows <= nR && nRows != 1)) + PushNA(); + else + { + const ScMatrixValue nMatVal = pMat->Get( nC, nR); + ScMatValType nMatValType = nMatVal.nType; + + if (ScMatrix::IsNonValueType( nMatValType)) + { + if (ScMatrix::IsEmptyPathType( nMatValType)) + { // result of empty false jump path + nFuncFmtType = NUMBERFORMAT_LOGICAL; + PushInt(0); } - else + else if (ScMatrix::IsEmptyType( nMatValType)) { - PushDouble(nMatVal.fVal); // handles DoubleError - pDok->GetNumberFormatInfo( nCurFmtType, nCurFmtIndex, aAdr, pCell ); - nFuncFmtType = nCurFmtType; - nFuncFmtIndex = nCurFmtIndex; + // Not inherited (really?) and display as empty string, not 0. + PushTempToken( new ScEmptyCellToken( false, true)); } + else + PushString( nMatVal.GetString() ); } - } - else - { - // If not a result matrix, obtain the cell value. - sal_uInt16 nErr = pCell->GetErrCode(); - if (nErr) - PushError( nErr ); - else if( pCell->IsValue() ) - PushDouble( pCell->GetValue() ); else { - OUString aVal = pCell->GetString(); - PushString( aVal ); + PushDouble(nMatVal.fVal); // handles DoubleError + pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr, aCell.mpFormula); + nFuncFmtType = nCurFmtType; + nFuncFmtIndex = nCurFmtIndex; } - pDok->GetNumberFormatInfo( nCurFmtType, nCurFmtIndex, aAdr, pCell ); - nFuncFmtType = nCurFmtType; - nFuncFmtIndex = nCurFmtIndex; } } else - PushError( errNoRef ); + { + // If not a result matrix, obtain the cell value. + sal_uInt16 nErr = aCell.mpFormula->GetErrCode(); + if (nErr) + PushError( nErr ); + else if (aCell.mpFormula->IsValue()) + PushDouble(aCell.mpFormula->GetValue()); + else + { + OUString aVal = aCell.mpFormula->GetString(); + PushString( aVal ); + } + pDok->GetNumberFormatInfo(nCurFmtType, nCurFmtIndex, aAdr, aCell.mpFormula); + nFuncFmtType = nCurFmtType; + nFuncFmtIndex = nCurFmtIndex; + } } void ScInterpreter::ScInfo() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits