diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-11-03 21:55:22 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-11-04 00:27:22 +0100 |
commit | 947003702ecdf8d093f37a43f669a6b7aee95bbf (patch) | |
tree | 95e16075a02d29730f8599d5062d84d6e0d6b3da /sc | |
parent | dd584cb4eaad85d458ee2dc58480ec3ea7a2a311 (diff) |
add error and not error condition
Change-Id: Iaf087a470fa7353877ac726af907e6d4a31cba99
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/conditio.hxx | 8 | ||||
-rw-r--r-- | sc/source/core/data/conditio.cxx | 47 |
2 files changed, 48 insertions, 7 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx index f765639315c8..72f1fc8ed88c 100644 --- a/sc/inc/conditio.hxx +++ b/sc/inc/conditio.hxx @@ -76,6 +76,8 @@ enum ScConditionMode SC_COND_BOTTOM_PERCENT, SC_COND_ABOVE_AVERAGE, SC_COND_BELOW_AVERAGE, + SC_COND_ERROR, + SC_COND_NOERROR, SC_COND_NONE }; @@ -183,8 +185,8 @@ class SC_DLLPUBLIC ScConditionEntry : public ScFormatEntry bool bTextToReal ); void Interpret( const ScAddress& rPos ); - bool IsValid( double nArg ) const; - bool IsValidStr( const String& rArg ) const; + bool IsValid( double nArg, const ScAddress& rPos ) const; + bool IsValidStr( const String& rArg, const ScAddress& rPos ) const; public: ScConditionEntry( ScConditionMode eOper, @@ -262,6 +264,8 @@ private: bool IsAboveAverage( double nArg ) const; bool IsBelowAverage( double nArg ) const; + bool IsError( const ScAddress& rPos ) const; + void FillCache() const; struct ScConditionEntryCache diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 3557e06f3dea..f660b3bf7a06 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -969,7 +969,32 @@ bool ScConditionEntry::IsAboveAverage( double nArg ) const return (nArg > nSum/mpCache->nValueItems); } -bool ScConditionEntry::IsValid( double nArg ) const +bool ScConditionEntry::IsError( const ScAddress& rPos ) const +{ + ScBaseCell* pCell = mpDoc->GetCell(rPos); + if(!pCell) + return false; + + switch(pCell->GetCellType()) + { + case CELLTYPE_VALUE: + return false; + case CELLTYPE_FORMULA: + { + ScFormulaCell* pFormulaCell = static_cast<ScFormulaCell*>(pCell); + if(pFormulaCell->GetErrCode()) + return true; + } + case CELLTYPE_STRING: + case CELLTYPE_EDIT: + return false; + default: + break; + } + return false; +} + +bool ScConditionEntry::IsValid( double nArg, const ScAddress& rPos ) const { // Interpret muss schon gerufen sein @@ -1057,6 +1082,12 @@ bool ScConditionEntry::IsValid( double nArg ) const case SC_COND_BELOW_AVERAGE: bValid = IsBelowAverage( nArg ); break; + case SC_COND_ERROR: + case SC_COND_NOERROR: + bValid = IsError( rPos ); + if( eOp == SC_COND_NOERROR ) + bValid = !bValid; + break; default: OSL_FAIL("unbekannte Operation bei ScConditionEntry"); break; @@ -1064,7 +1095,7 @@ bool ScConditionEntry::IsValid( double nArg ) const return bValid; } -bool ScConditionEntry::IsValidStr( const String& rArg ) const +bool ScConditionEntry::IsValidStr( const String& rArg, const ScAddress& rPos ) const { bool bValid = false; // Interpret muss schon gerufen sein @@ -1085,7 +1116,7 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const // Wenn Bedingung Zahl enthaelt, immer FALSE, ausser bei "ungleich" - if ( !bIsStr1 ) + if ( !bIsStr1 && (eOp != SC_COND_ERROR && eOp != SC_COND_NOERROR) ) return ( eOp == SC_COND_NOTEQUAL ); if ( eOp == SC_COND_BETWEEN || eOp == SC_COND_NOTBETWEEN ) if ( !bIsStr2 ) @@ -1119,6 +1150,12 @@ bool ScConditionEntry::IsValidStr( const String& rArg ) const case SC_COND_ABOVE_AVERAGE: case SC_COND_BELOW_AVERAGE: return false; + case SC_COND_ERROR: + case SC_COND_NOERROR: + bValid = IsError( rPos ); + if(eOp == SC_COND_NOERROR) + bValid = !bValid; + break; default: { sal_Int32 nCompare = ScGlobal::GetCollator()->compareString( @@ -1165,9 +1202,9 @@ bool ScConditionEntry::IsCellValid( ScBaseCell* pCell, const ScAddress& rPos ) c rtl::OUString aArgStr; bool bVal = lcl_GetCellContent( pCell, bIsStr1, nArg, aArgStr ); if (bVal) - return IsValid( nArg ); + return IsValid( nArg, rPos ); else - return IsValidStr( aArgStr ); + return IsValidStr( aArgStr, rPos ); } String ScConditionEntry::GetExpression( const ScAddress& rCursor, sal_uInt16 nIndex, |