summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-18 12:17:43 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-18 14:13:24 -0500
commit88c456a0dccb05b300267da1bfaa4e53f8051e19 (patch)
treeba920545f11714c4d948ab37fd658ccd8f7f36bd /sc
parentf3083a10f31f254058b7c847b27fd2adc4030b78 (diff)
Parse the query data first, then committing the query entries later.
This gives us the change to examine the query data and do some special-casing depending.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/queryentry.hxx14
-rw-r--r--sc/source/filter/excel/excimp8.cxx48
2 files changed, 32 insertions, 30 deletions
diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx
index 19adf3f640f0..835c84ad3ae4 100644
--- a/sc/inc/queryentry.hxx
+++ b/sc/inc/queryentry.hxx
@@ -42,7 +42,7 @@ namespace utl {
/**
* Each instance of this struct represents a single filtering criteria.
*/
-struct ScQueryEntry
+struct SC_DLLPUBLIC ScQueryEntry
{
enum QueryType { ByValue, ByString, ByDate, ByEmpty };
@@ -73,12 +73,12 @@ struct ScQueryEntry
QueryItemsType& GetQueryItems();
const QueryItemsType& GetQueryItems() const;
- SC_DLLPUBLIC void SetQueryByEmpty();
- SC_DLLPUBLIC bool IsQueryByEmpty() const;
- SC_DLLPUBLIC void SetQueryByNonEmpty();
- SC_DLLPUBLIC bool IsQueryByNonEmpty() const;
- SC_DLLPUBLIC const Item& GetQueryItem() const;
- SC_DLLPUBLIC Item& GetQueryItem();
+ void SetQueryByEmpty();
+ bool IsQueryByEmpty() const;
+ void SetQueryByNonEmpty();
+ bool IsQueryByNonEmpty() const;
+ const Item& GetQueryItem() const;
+ Item& GetQueryItem();
void Clear();
ScQueryEntry& operator=( const ScQueryEntry& r );
bool operator==( const ScQueryEntry& r ) const;
diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx
index 33747e716518..c3c4ee16c9a1 100644
--- a/sc/source/filter/excel/excimp8.cxx
+++ b/sc/source/filter/excel/excimp8.cxx
@@ -604,46 +604,45 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
return;
}
- sal_uInt8 nE, nType, nOper, nBoolErr, nVal;
+ sal_uInt8 nType, nOper, nBoolErr, nVal;
sal_Int32 nRK;
double fVal;
bool bIgnore;
- sal_uInt8 nStrLen[ 2 ] = { 0, 0 };
- ScQueryEntry *pQueryEntries[ 2 ] = { NULL, NULL };
+ sal_uInt8 nStrLen[2] = { 0, 0 };
+ ScQueryEntry aEntries[2];
- for( nE = 0; nE < 2; nE++ )
+ for (size_t nE = 0; nE < 2; ++nE)
{
if( nFirstEmpty < nCount )
{
- ScQueryEntry& aEntry = aParam.GetEntry( nFirstEmpty );
- ScQueryEntry::Item& rItem = aEntry.GetQueryItem();
- pQueryEntries[ nE ] = &aEntry;
+ ScQueryEntry& rEntry = aEntries[nE];
+ ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
bIgnore = false;
rStrm >> nType >> nOper;
switch( nOper )
{
case EXC_AFOPER_LESS:
- aEntry.eOp = SC_LESS;
+ rEntry.eOp = SC_LESS;
break;
case EXC_AFOPER_EQUAL:
- aEntry.eOp = SC_EQUAL;
+ rEntry.eOp = SC_EQUAL;
break;
case EXC_AFOPER_LESSEQUAL:
- aEntry.eOp = SC_LESS_EQUAL;
+ rEntry.eOp = SC_LESS_EQUAL;
break;
case EXC_AFOPER_GREATER:
- aEntry.eOp = SC_GREATER;
+ rEntry.eOp = SC_GREATER;
break;
case EXC_AFOPER_NOTEQUAL:
- aEntry.eOp = SC_NOT_EQUAL;
+ rEntry.eOp = SC_NOT_EQUAL;
break;
case EXC_AFOPER_GREATEREQUAL:
- aEntry.eOp = SC_GREATER_EQUAL;
+ rEntry.eOp = SC_GREATER_EQUAL;
break;
default:
- aEntry.eOp = SC_EQUAL;
+ rEntry.eOp = SC_EQUAL;
}
rtl::OUString aStr;
@@ -673,10 +672,10 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
bIgnore = (nBoolErr != 0);
break;
case EXC_AFTYPE_EMPTY:
- aEntry.SetQueryByEmpty();
+ rEntry.SetQueryByEmpty();
break;
case EXC_AFTYPE_NOTEMPTY:
- aEntry.SetQueryByNonEmpty();
+ rEntry.SetQueryByNonEmpty();
break;
default:
rStrm.Ignore( 8 );
@@ -693,10 +692,10 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
bHasConflict = true;
if( !bHasConflict && !bIgnore )
{
- aEntry.bDoQuery = true;
+ rEntry.bDoQuery = true;
rItem.meType = ScQueryEntry::ByString;
- aEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
- aEntry.eConnect = nE ? eConn : SC_AND;
+ rEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
+ rEntry.eConnect = nE ? eConn : SC_AND;
nFirstEmpty++;
}
}
@@ -704,12 +703,15 @@ void XclImpAutoFilterData::ReadAutoFilter( XclImpStream& rStrm )
rStrm.Ignore( 10 );
}
- for( nE = 0; nE < 2; nE++ )
- if( nStrLen[ nE ] && pQueryEntries[ nE ] )
+ for (size_t nE = 0; nE < 2; ++nE)
+ {
+ if (nStrLen[nE] && aEntries[nE].bDoQuery)
{
- pQueryEntries[nE]->GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
- ExcelQueryToOooQuery( *pQueryEntries[ nE ] );
+ aEntries[nE].GetQueryItem().maString = rStrm.ReadUniString(nStrLen[nE]);
+ ExcelQueryToOooQuery(aEntries[nE]);
+ aParam.AppendEntry() = aEntries[nE];
}
+ }
}
void XclImpAutoFilterData::SetAdvancedRange( const ScRange* pRange )