diff options
author | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-08-30 16:50:28 +0200 |
---|---|---|
committer | Daniel Rentz [dr] <daniel.rentz@oracle.com> | 2010-08-30 16:50:28 +0200 |
commit | be69a79f4b57a31b820fd0ff1e0abcc41d2a4e08 (patch) | |
tree | c0526c7a3ca9ca675de0699e5a01ac2794a05c8d /sc | |
parent | mib19: #163428# VBA symbol Worksheet.Visible supports xlSheetVeryHidden now (diff) | |
parent | CWS-TOOLING: integrate CWS calc58 (diff) | |
download | core-be69a79f4b57a31b820fd0ff1e0abcc41d2a4e08.tar.gz core-be69a79f4b57a31b820fd0ff1e0abcc41d2a4e08.zip |
mib19: rebase to OOO330m6
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/scmatrix.hxx | 11 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 27 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 13 | ||||
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 19 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 5 |
5 files changed, 46 insertions, 29 deletions
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx index 9857d675b7ab..b788672aa715 100644 --- a/sc/inc/scmatrix.hxx +++ b/sc/inc/scmatrix.hxx @@ -99,6 +99,7 @@ class SC_DLLPUBLIC ScMatrix mutable ULONG nRefCnt; // reference count SCSIZE nColCount; SCSIZE nRowCount; + bool mbCloneIfConst; // Whether the matrix is cloned with a CloneIfConst() call. void ResetIsString(); void DeleteIsString(); @@ -171,11 +172,19 @@ public: /** If nC*nR results in more than GetElementsMax() entries, a 1x1 matrix is created instead and a double error value (errStackOverflow) is set. Compare nC and nR with a GetDimensions() call to check. */ - ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0) { CreateMatrix( nC, nR); } + ScMatrix( SCSIZE nC, SCSIZE nR) : nRefCnt(0), mbCloneIfConst(true) { CreateMatrix( nC, nR); } /** Clone the matrix. */ ScMatrix* Clone() const; + /** Clone the matrix if mbCloneIfConst (immutable) is set, otherwise + return _this_ matrix, to be assigned to a ScMatrixRef. */ + ScMatrix* CloneIfConst(); + + /** Set the matrix to (im)mutable for CloneIfConst(), only the interpreter + should do this and know the consequences. */ + inline void SetImmutable( bool bVal ) { mbCloneIfConst = bVal; } + /** * Resize the matrix to specified new dimension. Note that this operation * clears all stored values. diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 35c63f52a92b..1e4c02967152 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2481,22 +2481,13 @@ void ScInterpreter::ScN() RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScN" ); USHORT nErr = nGlobalError; nGlobalError = 0; - double fVal; - if ( GetRawStackType() == svString ) - { - fVal = 0.0; - Pop(); - } - else - { - // Temporarily override the ConvertStringToValue() error for - // GetCellValue() / GetCellValueOrZero() - USHORT nSErr = mnStringNoValueError; - mnStringNoValueError = errCellNoValue; - fVal = GetDouble(); - mnStringNoValueError = nSErr; - } - if ( nGlobalError == NOTAVAILABLE || nGlobalError == errIllegalArgument ) + // Temporarily override the ConvertStringToValue() error for + // GetCellValue() / GetCellValueOrZero() + USHORT nSErr = mnStringNoValueError; + mnStringNoValueError = errCellNoValue; + double fVal = GetDouble(); + mnStringNoValueError = nSErr; + if ( nGlobalError == NOTAVAILABLE || nGlobalError == errCellNoValue ) nGlobalError = 0; // N(#NA) and N("text") are ok if ( !nGlobalError && nErr != NOTAVAILABLE ) nGlobalError = nErr; @@ -7108,10 +7099,6 @@ void ScInterpreter::ScText() case svDouble: fVal = PopDouble(); break; - case svString: - aStr = PopString(); - bString = true; - break; default: { FormulaTokenRef xTok( PopToken()); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 5c326001ff02..47cde7186067 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -231,6 +231,12 @@ double ScInterpreter::ConvertStringToValue( const String& rStr ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ConvertStringToValue" ); double fValue = 0.0; + if (mnStringNoValueError == errCellNoValue) + { + // Requested that all strings result in 0, error handled by caller. + SetError( mnStringNoValueError); + return fValue; + } ::rtl::OUString aStr( rStr); rtl_math_ConversionStatus eStatus; sal_Int32 nParseEnd; @@ -3964,5 +3970,10 @@ StackVar ScInterpreter::Interpret() while( maxsp-- ) (*p++)->DecRef(); - return xResult->GetType(); + StackVar eType = xResult->GetType(); + if (eType == svMatrix) + // Results are immutable in case they would be reused as input for new + // interpreters. + static_cast<ScToken*>(xResult.operator->())->GetMatrix()->SetImmutable( true); + return eType; } diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index ba4322a3281a..73794cf15b2d 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -310,6 +310,9 @@ ScMatrixRef ScInterpreter::GetNewMat(SCSIZE nC, SCSIZE nR) RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetNewMat" ); ScMatrix* pMat = new ScMatrix( nC, nR); pMat->SetErrorInterpreter( this); + // A temporary matrix is mutable and ScMatrix::CloneIfConst() returns the + // very matrix. + pMat->SetImmutable( false); SCSIZE nCols, nRows; pMat->GetDimensions( nCols, nRows); if ( nCols != nC || nRows != nR ) @@ -2069,23 +2072,25 @@ bool ScInterpreter::CheckMatrix(BOOL _bLOG,BOOL _bTrendGrowth,BYTE& nCase,SCSIZE { PushIllegalArgument(); return false; - } // if (!pMatY->IsValue(i)) - } // for ( SCSIZE i = 0; i < nCountY; i++ ) + } + } + if ( _bLOG ) { + ScMatrixRef pNewY = pMatY->CloneIfConst(); for (SCSIZE nElem = 0; nElem < nCountY; nElem++) { - const double fVal = pMatY->GetDouble(nElem); + const double fVal = pNewY->GetDouble(nElem); if (fVal <= 0.0) { PushIllegalArgument(); return false; } else - pMatY->PutDouble(log(fVal), nElem); - } // for (nElem = 0; nElem < nCountY; nElem++) - } // if ( _bRKP ) - + pNewY->PutDouble(log(fVal), nElem); + } + pMatY = pNewY; + } if (pMatX) { diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index fbb859b64ebf..2ecc20f53405 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -81,6 +81,11 @@ ScMatrix* ScMatrix::Clone() const return pScMat; } +ScMatrix* ScMatrix::CloneIfConst() +{ + return (mbCloneIfConst || IsEternalRef()) ? Clone() : this; +} + void ScMatrix::Resize( SCSIZE nC, SCSIZE nR) { Clear(); |