summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-12-08 23:02:26 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-12-08 23:02:26 -0500
commit49b6cbe96b6655cd35366283f239af516cc2644d (patch)
treefdf66567ad54cc7644e1e21cb6e2fc00d0c4ca6b /sc
parentd598c76cb9f34aad83802450cc4d607b71792eb8 (diff)
bnc#656073: Allow filtering by error value.
The old way was that an error cell was evaulated as having a value of 0. The error cell also showed up as blank in the popup. Using the error string is much more intuitive (and some users apparently want this behavior).
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/column3.cxx46
-rw-r--r--sc/source/core/data/table3.cxx7
2 files changed, 36 insertions, 17 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 898edfda51b5..fbeb9519cfa3 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -1575,9 +1575,9 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollec
while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEndRow) : false )
{
- ScBaseCell* pCell = pItems[nIndex].pCell;
- TypedStrData* pData;
- sal_uLong nFormat = GetNumberFormat( nRow );
+ ScBaseCell* pCell = pItems[nIndex].pCell;
+ TypedStrData* pData = NULL;
+ sal_uLong nFormat = GetNumberFormat( nRow );
ScCellFormat::GetInputString( pCell, nFormat, aString, *pFormatter );
@@ -1585,7 +1585,7 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollec
pData = new TypedStrData( aString );
else
{
- double nValue;
+ double nValue = 0.0;
switch ( pCell->GetCellType() )
{
@@ -1594,26 +1594,40 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollec
break;
case CELLTYPE_FORMULA:
- nValue = ((ScFormulaCell*)pCell)->GetValue();
- break;
+ {
+ ScFormulaCell* pFC = static_cast<ScFormulaCell*>(pCell);
+ sal_uInt16 nErr = pFC->GetErrCode();
+ if (nErr)
+ {
+ // Error cell is evaluated as string (for now).
+ String aErr = ScGlobal::GetErrorString(nErr);
+ if (aErr.Len())
+ pData = new TypedStrData(aErr);
+ }
+ else
+ nValue = pFC->GetValue();
+ }
+ break;
default:
- nValue = 0.0;
+ ;
}
- if (pFormatter)
+ if (!pData)
{
- short nType = pFormatter->GetType(nFormat);
- if ((nType & NUMBERFORMAT_DATE) && !(nType & NUMBERFORMAT_TIME))
+ if (pFormatter)
{
- // special case for date values. Disregard the time
- // element if the number format is of date type.
- nValue = ::rtl::math::approxFloor(nValue);
- bHasDates = true;
+ short nType = pFormatter->GetType(nFormat);
+ if ((nType & NUMBERFORMAT_DATE) && !(nType & NUMBERFORMAT_TIME))
+ {
+ // special case for date values. Disregard the time
+ // element if the number format is of date type.
+ nValue = ::rtl::math::approxFloor(nValue);
+ bHasDates = true;
+ }
}
+ pData = new TypedStrData( aString, nValue, SC_STRTYPE_VALUE );
}
-
- pData = new TypedStrData( aString, nValue, SC_STRTYPE_VALUE );
}
if ( !rStrings.Insert( pData ) )
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 1be106ffec1f..ffd5d6f390d8 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1277,7 +1277,12 @@ public:
if ( pCell )
{
- if (pCell->GetCellType() != CELLTYPE_NOTE)
+ if (pCell->GetCellType() == CELLTYPE_FORMULA && pCell->GetErrorCode())
+ {
+ // Error cell is evaluated as string (for now).
+ aCellStr = ScGlobal::GetErrorString(pCell->GetErrorCode());
+ }
+ else if (pCell->GetCellType() != CELLTYPE_NOTE)
{
sal_uLong nFormat = mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow );
ScCellFormat::GetInputString(pCell, nFormat, aCellStr, *mrDoc.GetFormatTable());