diff options
Diffstat (limited to 'sc/source/core/tool')
-rw-r--r-- | sc/source/core/tool/dbcolect.cxx | 11 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 58 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 15 | ||||
-rw-r--r-- | sc/source/core/tool/rangelst.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/rangenam.cxx | 3 |
6 files changed, 84 insertions, 27 deletions
diff --git a/sc/source/core/tool/dbcolect.cxx b/sc/source/core/tool/dbcolect.cxx index 4118f9dcd7f9..d5fe2701f459 100644 --- a/sc/source/core/tool/dbcolect.cxx +++ b/sc/source/core/tool/dbcolect.cxx @@ -827,7 +827,8 @@ ScDBData* ScDBCollection::GetDBAtArea(SCTAB nTab, SCCOL nCol1, SCROW nRow1, SCCO ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const { - ScDBData* pDataEmpty = NULL; + ScDBData* pAnonData = pDoc->GetAnonymousDBData(nTab); + if (pItems) { for (sal_uInt16 i = 0; i < nCount; i++) @@ -843,7 +844,13 @@ ScDBData* ScDBCollection::GetFilterDBAtTable(SCTAB nTab) const } } - return pDataEmpty; + if (pAnonData) + { + if ( pAnonData->HasAutoFilter() || pAnonData->HasQueryParam()) + return pAnonData; + } + + return NULL; } sal_Bool ScDBCollection::SearchName( const String& rName, sal_uInt16& rIndex ) const diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index c4a8cdd346cd..c72f35402f2c 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -1661,9 +1661,11 @@ void ScInterpreter::ScIsEmpty() nRes = 1; } break; + case svExternalSingleRef: + case svExternalDoubleRef: case svMatrix: { - ScMatrixRef pMat = PopMatrix(); + ScMatrixRef pMat = GetMatrix(); if ( !pMat ) ; // nothing else if ( !pJumpMatrix ) @@ -2509,26 +2511,44 @@ void ScInterpreter::ScIsOdd() PushInt( !IsEven() ); } - void ScInterpreter::ScN() { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScN" ); - sal_uInt16 nErr = nGlobalError; - nGlobalError = 0; - // Temporarily override the ConvertStringToValue() error for - // GetCellValue() / GetCellValueOrZero() - sal_uInt16 nSErr = mnStringNoValueError; - mnStringNoValueError = errCellNoValue; + switch (GetRawStackType()) + { + case svSingleRef: + case svDoubleRef: + case svMatrix: + case svExternalSingleRef: + case svExternalDoubleRef: + { + ScMatrixRef pMat = GetMatrix(); + SCSIZE nC, nR; + pMat->GetDimensions(nC, nR); + if (!nC || !nR) + PushDouble(0); + else + PushDouble(pMat->GetDouble(0, 0)); + return; + } + case svString: + PushDouble(0); + return; + default: + ; + } + + // Default action 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; - PushDouble( fVal ); + if (nGlobalError) + { + // Don't propagate the error. Push 0 instead. + nGlobalError = 0; + PushDouble(0); + return; + } + PushDouble(fVal); } - void ScInterpreter::ScTrim() { // Doesn't only trim but writes out twice! String aVal( GetString() ); @@ -5785,6 +5805,12 @@ void ScInterpreter::CalculateLookup(sal_Bool HLookup) return; } } + else if (eType == svSingleRef) + { + PopSingleRef(nCol1, nRow1, nTab1); + nCol2 = nCol1; + nRow2 = nRow1; + } else if (eType == svMatrix || eType == svExternalDoubleRef || eType == svExternalSingleRef) { pMat = GetMatrix(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index bfe5b6b632ac..8de2e386c77f 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3397,6 +3397,20 @@ sal_Bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos return bOk; } +namespace { + +class FindByPointer : ::std::unary_function<ScInterpreterTableOpParams, bool> +{ + const ScInterpreterTableOpParams* mpTableOp; +public: + FindByPointer(const ScInterpreterTableOpParams* p) : mpTableOp(p) {} + bool operator() (const ScInterpreterTableOpParams& val) const + { + return &val == mpTableOp; + } +}; + +} void ScInterpreter::ScTableOp() { @@ -3456,7 +3470,11 @@ void ScInterpreter::ScTableOp() PushString( aCellString ); } - pTableOp = pDok->aTableOpList.release( pDok->aTableOpList.end() ).release(); + boost::ptr_vector< ScInterpreterTableOpParams >::iterator itr = + ::std::find_if(pDok->aTableOpList.begin(), pDok->aTableOpList.end(), FindByPointer(pTableOp)); + if (itr != pDok->aTableOpList.end()) + pTableOp = pDok->aTableOpList.release(itr).release(); + // set dirty again once more to be able to recalculate original for ( ::std::vector< ScFormulaCell* >::const_iterator iBroadcast( pTableOp->aNotifiedFormulaCells.begin() ); diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index 3d764e44319b..e5e5c8a0968a 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -572,11 +572,16 @@ ScMatrixRef ScInterpreter::GetMatrix() pMat = new ScMatrix(1, 1); pMat->PutDouble(pToken->GetDouble(), 0, 0); } - else + else if (pToken->GetType() == svString) { pMat = new ScMatrix(1, 1); pMat->PutString(pToken->GetString(), 0, 0); } + else + { + pMat = new ScMatrix(1, 1); + pMat->PutEmpty(0, 0); + } } break; case svExternalDoubleRef: @@ -1978,14 +1983,10 @@ double lcl_TGetColumnSumProduct(ScMatrixRef pMatA, SCSIZE nRa, return fResult; } +// no mathematical signum, but used to switch between adding and subtracting double lcl_GetSign(double fValue) { - if (fValue < 0.0) - return -1.0; - else if (fValue > 0.0) - return 1.0; - else - return 0.0; + return (fValue >= 0.0 ? 1.0 : -1.0 ); } /* Calculates a QR decomposition with Householder reflection. diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx index 7395da73d33e..9b43b635823e 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -260,7 +260,9 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList ) } bool bJoinedInput = false; - for ( size_t i = 0, nRanges = maRanges.size(); i < nRanges && pOver; ++i ) + // We need to query the size of the container dynamically since its size + // may change during the loop. + for ( size_t i = 0; i < maRanges.size() && pOver; ++i ) { ScRange* p = maRanges[i]; if ( p == pOver ) diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx index df5f43617ae1..7d2972cadc5b 100644 --- a/sc/source/core/tool/rangenam.cxx +++ b/sc/source/core/tool/rangenam.cxx @@ -476,6 +476,9 @@ sal_Bool ScRangeData::IsNameValid( const String& rName, ScDocument* pDoc ) { /* XXX If changed, sc/source/filter/ftools/ftools.cxx * ScfTools::ConvertToScDefinedName needs to be changed too. */ + sal_Char a('.'); + if (rName.Search(a, 0) != STRING_NOTFOUND) + return false; xub_StrLen nPos = 0; xub_StrLen nLen = rName.Len(); if ( !nLen || !ScCompiler::IsCharFlagAllConventions( rName, nPos++, SC_COMPILER_C_CHAR_NAME ) ) |