diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-28 09:43:57 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-28 17:03:53 -0400 |
commit | 663b7062855a21e6c9a24830ffb5ac7ae2669466 (patch) | |
tree | 93c58fbabb9932f56b8848ddc29b23b7ef7fa318 /sc | |
parent | c63e6c38c9b0be2a5141b356bdcb4fe9b361effc (diff) |
Removing use of ScBaseCell in ScInterpreter.
Change-Id: I1edfbc08a0fe705e3d0ad07b8cc0d48ffddaad9f
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 15 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 262 | ||||
-rw-r--r-- | sc/source/core/tool/interpr2.cxx | 16 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 84 |
4 files changed, 200 insertions, 177 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 4350d7ecea13..18d635235b3f 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -150,7 +150,7 @@ private: const formula::FormulaToken* pCur; // current token - String aTempStr; // for GetString() + OUString aTempStr; // for GetString() ScTokenStack* pStackObj; // contains the stacks formula::FormulaToken** pStack; // the current stack sal_uInt16 nGlobalError; // global (local to this formula expression) error @@ -185,7 +185,7 @@ void PushNA(); void ReplaceCell( ScAddress& ); // for TableOp void ReplaceCell( SCCOL& rCol, SCROW& rRow, SCTAB& rTab ); // for TableOp bool IsTableOpInRange( const ScRange& ); -sal_uLong GetCellNumberFormat( const ScAddress&, const ScBaseCell* ); +sal_uLong GetCellNumberFormat( const ScAddress& rPos, ScRefCellValue& rCell ); double ConvertStringToValue( const String& ); double GetCellValue( const ScAddress&, const ScBaseCell* ); double GetCellValue( const ScAddress&, ScRefCellValue& rCell ); @@ -195,8 +195,7 @@ 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 ); +sal_uInt16 GetCellErrCode( const ScRefCellValue& rCell ); bool HasCellEmptyData( const ScBaseCell* pCell ); bool HasCellValueData( const ScBaseCell* pCell ); bool HasCellStringData( const ScBaseCell* pCell ); @@ -265,7 +264,7 @@ formula::FormulaTokenRef PopToken(); void Pop(); void PopError(); double PopDouble(); -const String& PopString(); +const OUString& PopString(); void ValidateRef( const ScSingleRefData & rRef ); void ValidateRef( const ScComplexRefData & rRef ); void ValidateRef( const ScRefList & rRefList ); @@ -339,10 +338,10 @@ double GetDouble(); double GetDoubleWithDefault(double nDefault); bool IsMissing(); bool GetBool() { return GetDouble() != 0.0; } -const String& GetString(); -const String& GetStringFromMatrix(const ScMatrixRef& pMat); +const OUString& GetString(); +const OUString& GetStringFromMatrix(const ScMatrixRef& pMat); // pop matrix and obtain one element, upper left or according to jump matrix -ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, String& rString ); +ScMatValType GetDoubleOrStringFromMatrix( double& rDouble, OUString& rString ); ScMatrixRef CreateMatrixFromDoubleRef( const formula::FormulaToken* pToken, SCCOL nCol1, SCROW nRow1, SCTAB nTab1, SCCOL nCol2, SCROW nRow2, SCTAB nTab2 ); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 574612c0b95a..3e480e13eea5 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -301,8 +301,10 @@ void ScInterpreter::ScIfError( bool bNAonly ) bError = true; else { - ScBaseCell* pCell = GetCell( aAdr); - nGlobalError = GetCellErrCode( pCell); + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + nGlobalError = GetCellErrCode(aCell); if (nGlobalError) bError = true; } @@ -310,16 +312,16 @@ void ScInterpreter::ScIfError( bool bNAonly ) break; case svExternalSingleRef: case svExternalDoubleRef: - { - double fVal; - String aStr; - // Handles also existing jump matrix case and sets error on - // elements. - GetDoubleOrStringFromMatrix( fVal, aStr); - if (nGlobalError) - bError = true; - } - break; + { + double fVal; + OUString aStr; + // Handles also existing jump matrix case and sets error on + // elements. + GetDoubleOrStringFromMatrix( fVal, aStr); + if (nGlobalError) + bError = true; + } + break; case svMatrix: { const ScMatrixRef pMat = PopMatrix(); @@ -2114,9 +2116,9 @@ void ScInterpreter::ScIsEmpty() // NOTE: this could test also on inherited emptiness, but then the // cell tested wouldn't be empty. Must correspond with // ScCountEmptyCells(). - // if (HasCellEmptyData( GetCell( aAdr))) - CellType eCellType = GetCellType( GetCell( aAdr ) ); - if((eCellType == CELLTYPE_NONE) || (eCellType == CELLTYPE_NOTE)) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if ((aCell.meType == CELLTYPE_NONE) || (aCell.meType == CELLTYPE_NOTE)) nRes = 1; } break; @@ -2165,18 +2167,19 @@ short ScInterpreter::IsString() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - ScBaseCell* pCell = GetCell( aAdr ); - if (GetCellErrCode( pCell ) == 0) + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (GetCellErrCode(aCell) == 0) { - switch ( GetCellType( pCell ) ) + switch (aCell.meType) { case CELLTYPE_STRING : case CELLTYPE_EDIT : nRes = 1; break; case CELLTYPE_FORMULA : - nRes = !((ScFormulaCell*)pCell)->IsValue() && - !((ScFormulaCell*)pCell)->IsEmpty(); + nRes = (!aCell.mpFormula->IsValue() && !aCell.mpFormula->IsEmpty()); break; default: ; // nothing @@ -2235,14 +2238,15 @@ void ScInterpreter::ScIsLogical() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - ScBaseCell* pCell = GetCell( aAdr ); - if (GetCellErrCode( pCell ) == 0) + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (GetCellErrCode(aCell) == 0) { - if (HasCellValueData(pCell)) + if (aCell.hasNumeric()) { - sal_uLong nFormat = GetCellNumberFormat( aAdr, pCell ); - nRes = ( pFormatter->GetType(nFormat) - == NUMBERFORMAT_LOGICAL); + sal_uLong nFormat = GetCellNumberFormat(aAdr, aCell); + nRes = (pFormatter->GetType(nFormat) == NUMBERFORMAT_LOGICAL); } } } @@ -2274,10 +2278,12 @@ void ScInterpreter::ScType() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - ScBaseCell* pCell = GetCell( aAdr ); - if (GetCellErrCode( pCell ) == 0) + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (GetCellErrCode(aCell) == 0) { - switch ( GetCellType( pCell ) ) + switch (aCell.meType) { // NOTE: this is Xcl nonsense! case CELLTYPE_NOTE : @@ -2288,15 +2294,14 @@ void ScInterpreter::ScType() nType = 2; break; case CELLTYPE_VALUE : - { - sal_uLong nFormat = GetCellNumberFormat( aAdr, pCell ); - if (pFormatter->GetType(nFormat) - == NUMBERFORMAT_LOGICAL) - nType = 4; - else - nType = 1; - } - break; + { + sal_uLong nFormat = GetCellNumberFormat(aAdr, aCell); + if (pFormatter->GetType(nFormat) == NUMBERFORMAT_LOGICAL) + nType = 4; + else + nType = 1; + } + break; case CELLTYPE_FORMULA : nType = 8; break; @@ -2791,17 +2796,18 @@ void ScInterpreter::ScIsValue() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - ScBaseCell* pCell = GetCell( aAdr ); - if (GetCellErrCode( pCell ) == 0) + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (GetCellErrCode(aCell) == 0) { - switch ( GetCellType( pCell ) ) + switch (aCell.meType) { case CELLTYPE_VALUE : nRes = 1; break; case CELLTYPE_FORMULA : - nRes = ((ScFormulaCell*)pCell)->IsValue() && - !((ScFormulaCell*)pCell)->IsEmpty(); + nRes = (aCell.mpFormula->IsValue() && !aCell.mpFormula->IsEmpty()); break; default: ; // nothing @@ -2851,7 +2857,8 @@ void ScInterpreter::ScIsFormula() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - nRes = (GetCellType( GetCell( aAdr ) ) == CELLTYPE_FORMULA); + + nRes = (pDok->GetCellType(aAdr) == CELLTYPE_FORMULA); } break; default: @@ -2874,11 +2881,13 @@ void ScInterpreter::ScFormula() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - ScBaseCell* pCell = GetCell( aAdr ); - switch ( GetCellType( pCell ) ) + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + switch (aCell.meType) { case CELLTYPE_FORMULA : - ((ScFormulaCell*)pCell)->GetFormula( aFormula ); + aCell.mpFormula->GetFormula(aFormula); break; default: SetError( NOTAVAILABLE ); @@ -2910,8 +2919,9 @@ void ScInterpreter::ScIsNV() nRes = 1; else { - ScBaseCell* pCell = GetCell( aAdr ); - sal_uInt16 nErr = GetCellErrCode( pCell ); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + sal_uInt16 nErr = GetCellErrCode(aCell); nRes = (nErr == NOTAVAILABLE); } } @@ -2959,8 +2969,9 @@ void ScInterpreter::ScIsErr() nRes = 1; else { - ScBaseCell* pCell = GetCell( aAdr ); - sal_uInt16 nErr = GetCellErrCode( pCell ); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + sal_uInt16 nErr = GetCellErrCode(aCell); nRes = (nErr && nErr != NOTAVAILABLE); } } @@ -3018,8 +3029,9 @@ void ScInterpreter::ScIsError() nRes = 1; else { - ScBaseCell* pCell = GetCell( aAdr ); - nRes = (GetCellErrCode( pCell ) != 0); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + nRes = (GetCellErrCode(aCell) != 0); } } break; @@ -3064,22 +3076,24 @@ short ScInterpreter::IsEven() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - ScBaseCell* pCell = GetCell( aAdr ); - sal_uInt16 nErr = GetCellErrCode( pCell ); + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + sal_uInt16 nErr = GetCellErrCode(aCell); if (nErr != 0) SetError(nErr); else { - switch ( GetCellType( pCell ) ) + switch (aCell.meType) { case CELLTYPE_VALUE : - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); nRes = 1; break; case CELLTYPE_FORMULA : - if( ((ScFormulaCell*)pCell)->IsValue() ) + if (aCell.mpFormula->IsValue()) { - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); nRes = 1; } break; @@ -3252,27 +3266,28 @@ void ScInterpreter::ScT() return ; } bool bValue = false; - ScBaseCell* pCell = GetCell( aAdr ); - if ( GetCellErrCode( pCell ) == 0 ) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (GetCellErrCode(aCell) == 0) { - switch ( GetCellType( pCell ) ) + switch (aCell.meType) { case CELLTYPE_VALUE : bValue = true; break; case CELLTYPE_FORMULA : - bValue = ((ScFormulaCell*)pCell)->IsValue(); + bValue = aCell.mpFormula->IsValue(); break; default: ; // nothing } } if ( bValue ) - PushString( EMPTY_STRING ); + PushString(EMPTY_OUSTRING); else { // like GetString() - GetCellString( aTempStr, pCell ); + GetCellString(aTempStr, aCell); PushString( aTempStr ); } } @@ -3282,7 +3297,7 @@ void ScInterpreter::ScT() case svExternalDoubleRef: { double fVal; - String aStr; + OUString aStr; ScMatValType nMatValType = GetDoubleOrStringFromMatrix( fVal, aStr); if (ScMatrix::IsValueType( nMatValType)) PushString( EMPTY_STRING); @@ -3308,7 +3323,7 @@ void ScInterpreter::ScT() void ScInterpreter::ScValue() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScValue" ); - String aInputString; + OUString aInputString; double fVal; switch ( GetRawStackType() ) @@ -3324,28 +3339,29 @@ void ScInterpreter::ScValue() case svSingleRef: case svDoubleRef: + { + ScAddress aAdr; + if ( !PopDoubleRefOrSingleRef( aAdr ) ) { - ScAddress aAdr; - if ( !PopDoubleRefOrSingleRef( aAdr ) ) - { - PushInt(0); - return; - } - ScBaseCell* pCell = GetCell( aAdr ); - if ( pCell && pCell->HasStringData() ) - GetCellString( aInputString, pCell ); - else if ( pCell && pCell->HasValueData() ) - { - PushDouble( GetCellValue(aAdr, pCell) ); - return; - } - else - { - PushDouble(0.0); - return; - } + PushInt(0); + return; } - break; + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (aCell.hasString()) + GetCellString(aInputString, aCell); + else if (aCell.hasNumeric()) + { + PushDouble( GetCellValue(aAdr, aCell) ); + return; + } + else + { + PushDouble(0.0); + return; + } + } + break; case svMatrix: { ScMatValType nType = GetDoubleOrStringFromMatrix( fVal, @@ -5164,7 +5180,7 @@ void ScInterpreter::ScMatch() break; case svMatrix : { - String aStr; + OUString aStr; ScMatValType nType = GetDoubleOrStringFromMatrix( rItem.mfVal, aStr); rItem.maString = aStr; @@ -5350,7 +5366,7 @@ void ScInterpreter::ScCountEmptyCells() nMaxCount = 1; ScAddress aAdr; PopSingleRef( aAdr ); - eCellType = GetCellType( GetCell( aAdr ) ); + eCellType = pDok->GetCellType(aAdr); if (eCellType != CELLTYPE_NONE && eCellType != CELLTYPE_NOTE) nCount = 1; } @@ -5450,7 +5466,7 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) } } - String aString; + OUString aString; double fVal = 0.0; bool bIsString = true; switch ( GetStackType() ) @@ -5462,25 +5478,26 @@ double ScInterpreter::IterateParametersIf( ScIterFuncIf eFunc ) if ( !PopDoubleRefOrSingleRef( aAdr ) ) return 0; - ScBaseCell* pCell = GetCell( aAdr ); - switch ( GetCellType( pCell ) ) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + switch (aCell.meType) { case CELLTYPE_VALUE : - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); bIsString = false; break; case CELLTYPE_FORMULA : - if( ((ScFormulaCell*)pCell)->IsValue() ) + if (aCell.mpFormula->IsValue()) { - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); bIsString = false; } else - GetCellString(aString, pCell); + GetCellString(aString, aCell); break; case CELLTYPE_STRING : case CELLTYPE_EDIT : - GetCellString(aString, pCell); + GetCellString(aString, aCell); break; default: fVal = 0.0; @@ -5813,7 +5830,7 @@ void ScInterpreter::ScCountIf() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScCountIf" ); if ( MustHaveParamCount( GetByte(), 2 ) ) { - String aString; + OUString aString; double fVal = 0.0; bool bIsString = true; switch ( GetStackType() ) @@ -5827,25 +5844,26 @@ void ScInterpreter::ScCountIf() PushInt(0); return ; } - ScBaseCell* pCell = GetCell( aAdr ); - switch ( GetCellType( pCell ) ) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + switch (aCell.meType) { case CELLTYPE_VALUE : - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); bIsString = false; break; case CELLTYPE_FORMULA : - if( ((ScFormulaCell*)pCell)->IsValue() ) + if (aCell.mpFormula->IsValue()) { - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); bIsString = false; } else - GetCellString(aString, pCell); + GetCellString(aString, aCell); break; case CELLTYPE_STRING : case CELLTYPE_EDIT : - GetCellString(aString, pCell); + GetCellString(aString, aCell); break; default: fVal = 0.0; @@ -6035,7 +6053,7 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) while (nParamCount > 1 && !nGlobalError) { // take criteria - String aString; + OUString aString; fVal = 0.0; bool bIsString = true; switch ( GetStackType() ) @@ -6047,25 +6065,26 @@ double ScInterpreter::IterateParametersIfs( ScIterFuncIfs eFunc ) if ( !PopDoubleRefOrSingleRef( aAdr ) ) return 0; - ScBaseCell* pCell = GetCell( aAdr ); - switch ( GetCellType( pCell ) ) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + switch (aCell.meType) { case CELLTYPE_VALUE : - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); bIsString = false; break; case CELLTYPE_FORMULA : - if( ((ScFormulaCell*)pCell)->IsValue() ) + if (aCell.mpFormula->IsValue()) { - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); bIsString = false; } else - GetCellString(aString, pCell); + GetCellString(aString, aCell); break; case CELLTYPE_STRING : case CELLTYPE_EDIT : - GetCellString(aString, pCell); + GetCellString(aString, aCell); break; default: fVal = 0.0; @@ -7250,32 +7269,33 @@ bool ScInterpreter::FillEntry(ScQueryEntry& rEntry) PushInt(0); return false; } - ScBaseCell* pCell = GetCell( aAdr ); - if (HasCellValueData(pCell)) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (aCell.hasNumeric()) { rItem.meType = ScQueryEntry::ByValue; - rItem.mfVal = GetCellValue(aAdr, pCell); + rItem.mfVal = GetCellValue(aAdr, aCell); } else { - if ( GetCellType( pCell ) == CELLTYPE_NOTE ) + if (aCell.meType == CELLTYPE_NOTE) { rItem.meType = ScQueryEntry::ByValue; rItem.mfVal = 0.0; } else { - String sStr; - GetCellString(sStr, pCell); + OUString aStr; + GetCellString(aStr, aCell); rItem.meType = ScQueryEntry::ByString; - rItem.maString = sStr; + rItem.maString = aStr; } } } break; case svMatrix : { - String aStr; + OUString aStr; const ScMatValType nType = GetDoubleOrStringFromMatrix(rItem.mfVal, aStr); rItem.maString = aStr; rItem.meType = ScMatrix::IsNonValueType(nType) ? diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 39e780faba42..a2b6041562c0 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -2705,7 +2705,7 @@ void ScInterpreter::ScHyperLink() if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { double fVal = 0.0; - String aStr; + OUString aStr; ScMatValType nResultType = SC_MATVAL_STRING; if ( nParamCount == 2 ) @@ -2725,21 +2725,23 @@ void ScInterpreter::ScHyperLink() ScAddress aAdr; if ( !PopDoubleRefOrSingleRef( aAdr ) ) break; - ScBaseCell* pCell = GetCell( aAdr ); - if (HasCellEmptyData( pCell)) + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (aCell.hasEmptyValue()) nResultType = SC_MATVAL_EMPTY; else { - sal_uInt16 nErr = GetCellErrCode( pCell ); + sal_uInt16 nErr = GetCellErrCode(aCell); if (nErr) SetError( nErr); - else if (HasCellValueData( pCell)) + else if (aCell.hasNumeric()) { - fVal = GetCellValue( aAdr, pCell ); + fVal = GetCellValue(aAdr, aCell); nResultType = SC_MATVAL_VALUE; } else - GetCellString( aStr, pCell ); + GetCellString(aStr, aCell); } } break; diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index a54748fab99a..cc4d190ebb82 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -151,28 +151,27 @@ bool ScInterpreter::IsTableOpInRange( const ScRange& rRange ) } -sal_uLong ScInterpreter::GetCellNumberFormat( const ScAddress& rPos, const ScBaseCell* pCell) +sal_uLong ScInterpreter::GetCellNumberFormat( const ScAddress& rPos, ScRefCellValue& rCell ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetCellNumberFormat" ); sal_uLong nFormat; sal_uInt16 nErr; - if ( pCell ) + if (rCell.isEmpty()) { - if ( pCell->GetCellType() == CELLTYPE_FORMULA ) - nErr = ((ScFormulaCell*)pCell)->GetErrCode(); - else - nErr = 0; nFormat = pDok->GetNumberFormat( rPos ); - if ( pCell->GetCellType() == CELLTYPE_FORMULA - && ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0) ) - nFormat = ((ScFormulaCell*)pCell)->GetStandardFormat( *pFormatter, - nFormat ); + nErr = 0; } else { + if (rCell.meType == CELLTYPE_FORMULA) + nErr = rCell.mpFormula->GetErrCode(); + else + nErr = 0; nFormat = pDok->GetNumberFormat( rPos ); - nErr = 0; + if (rCell.meType == CELLTYPE_FORMULA && ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0)) + nFormat = rCell.mpFormula->GetStandardFormat(*pFormatter, nFormat); } + SetError(nErr); return nFormat; } @@ -191,14 +190,9 @@ double ScInterpreter::GetValueCellValue( const ScAddress& rPos, const ScValueCel return fVal; } -sal_uInt16 ScInterpreter::GetCellErrCode( const ScBaseCell* pCell ) +sal_uInt16 ScInterpreter::GetCellErrCode( const ScRefCellValue& rCell ) { - return pCell ? pCell->GetErrorCode() : 0; -} - -CellType ScInterpreter::GetCellType( const ScBaseCell* pCell ) -{ - return pCell ? pCell->GetCellType() : CELLTYPE_NONE; + return rCell.meType == CELLTYPE_FORMULA ? rCell.mpFormula->GetErrorCode() : 0; } bool ScInterpreter::HasCellEmptyData( const ScBaseCell* pCell ) @@ -1136,13 +1130,14 @@ void ScInterpreter::PushTempToken( const FormulaToken& r ) void ScInterpreter::PushCellResultToken( bool bDisplayEmptyAsString, const ScAddress & rAddress, short * pRetTypeExpr, sal_uLong * pRetIndexExpr ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::PushCellResultToken" ); + ScRefCellValue aCell; + aCell.assign(*pDok, rAddress); ScBaseCell* pCell = pDok->GetCell( rAddress); - if (!pCell || pCell->HasEmptyData()) + if (aCell.hasEmptyValue()) { if (pRetTypeExpr && pRetIndexExpr) pDok->GetNumberFormatInfo( *pRetTypeExpr, *pRetIndexExpr, rAddress, pCell); - bool bInherited = (GetCellType( pCell) == CELLTYPE_FORMULA); + bool bInherited = (aCell.meType == CELLTYPE_FORMULA); PushTempToken( new ScEmptyCellToken( bInherited, bDisplayEmptyAsString)); return; } @@ -1251,7 +1246,7 @@ double ScInterpreter::PopDouble() } -const String& ScInterpreter::PopString() +const OUString& ScInterpreter::PopString() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::PopString" ); nCurFmtType = NUMBERFORMAT_TEXT; @@ -1266,17 +1261,18 @@ const String& ScInterpreter::PopString() nGlobalError = p->GetError(); break; case svString: - return p->GetString(); + aTempStr = p->GetString(); + return aTempStr; case svEmptyCell: case svMissing: - return EMPTY_STRING; + return EMPTY_OUSTRING; default: SetError( errIllegalArgument); } } else SetError( errUnknownStackVariable); - return EMPTY_STRING; + return EMPTY_OUSTRING; } @@ -2448,18 +2444,18 @@ double ScInterpreter::GetDoubleWithDefault(double nDefault) } -const String& ScInterpreter::GetString() +const OUString& ScInterpreter::GetString() { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetString" ); switch (GetRawStackType()) { case svError: PopError(); - return EMPTY_STRING; + return EMPTY_OUSTRING; case svMissing: case svEmptyCell: Pop(); - return EMPTY_STRING; + return EMPTY_OUSTRING; case svDouble: { double fVal = PopDouble(); @@ -2477,12 +2473,13 @@ const String& ScInterpreter::GetString() PopSingleRef( aAdr ); if (nGlobalError == 0) { - ScBaseCell* pCell = GetCell( aAdr ); - GetCellString( aTempStr, pCell ); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + GetCellString(aTempStr, aCell); return aTempStr; } else - return EMPTY_STRING; + return EMPTY_OUSTRING; } case svDoubleRef: { // generate position dependent SingleRef @@ -2491,18 +2488,23 @@ const String& ScInterpreter::GetString() ScAddress aAdr; if ( !nGlobalError && DoubleRefToPosSingleRef( aRange, aAdr ) ) { - ScBaseCell* pCell = GetCell( aAdr ); - GetCellString( aTempStr, pCell ); + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + GetCellString(aTempStr, aCell); return aTempStr; } else - return EMPTY_STRING; + return EMPTY_OUSTRING; } case svExternalSingleRef: { ScExternalRefCache::TokenRef pToken; PopExternalSingleRef(pToken); - return nGlobalError ? EMPTY_STRING : pToken->GetString(); + if (nGlobalError) + return EMPTY_OUSTRING; + + aTempStr = pToken->GetString(); + return aTempStr; } case svExternalDoubleRef: { @@ -2520,10 +2522,10 @@ const String& ScInterpreter::GetString() PopError(); SetError( errIllegalArgument); } - return EMPTY_STRING; + return EMPTY_OUSTRING; } -const String& ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat) +const OUString& ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat) { if ( !pMat ) ; // nothing @@ -2545,16 +2547,16 @@ const String& ScInterpreter::GetStringFromMatrix(const ScMatrixRef& pMat) else SetError( errNoValue); } - return EMPTY_STRING; + return EMPTY_OUSTRING; } -ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( double& rDouble, - String& rString ) +ScMatValType ScInterpreter::GetDoubleOrStringFromMatrix( + double& rDouble, OUString& rString ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetDoubleOrStringFromMatrix" ); rDouble = 0.0; - rString.Erase(); + rString = EMPTY_OUSTRING; ScMatValType nMatValType = SC_MATVAL_EMPTY; ScMatrixRef pMat; |