summaryrefslogtreecommitdiff
path: root/sc/source/core/data/dpcachetable.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data/dpcachetable.cxx')
-rw-r--r--sc/source/core/data/dpcachetable.cxx534
1 files changed, 157 insertions, 377 deletions
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 237d7ffd16db..ad5e921cb278 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -65,7 +65,6 @@ using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::sheet::DataPilotFieldFilter;
-const double D_TIMEFACTOR = 86400.0;
static BOOL lcl_HasQueryEntry( const ScQueryParam& rParam )
{
@@ -75,56 +74,35 @@ static BOOL lcl_HasQueryEntry( const ScQueryParam& rParam )
// ----------------------------------------------------------------------------
-static ScDPCacheCell EmptyCellContent = ScDPCacheCell();
-
-// ----------------------------------------------------------------------------
-
-ScDPCacheTable::Cell::Cell() :
- mnCategoryRef(0),
- mpContent(NULL)
-{
-}
-
-ScDPCacheTable::Cell::~Cell()
-{
-}
-
-// ----------------------------------------------------------------------------
-
ScDPCacheTable::FilterItem::FilterItem() :
- mnMatchStrId(ScSimpleSharedString::EMPTY),
mfValue(0.0),
mbHasValue(false)
{
}
-
+bool ScDPCacheTable::FilterItem::match( const ScDPItemData& rCellData ) const
+{
+ if (rCellData.GetString()!= maString &&
+ (!rCellData.IsValue()|| rCellData.GetValue()!= mfValue))
+ return false;
+ return true;
+}
// ----------------------------------------------------------------------------
-ScDPCacheTable::SingleFilter::SingleFilter(ScSimpleSharedString& rSharedString,
- sal_Int32 nMatchStrId, double fValue, bool bHasValue) :
- mrSharedString(rSharedString)
+ScDPCacheTable::SingleFilter::SingleFilter(String aString, double fValue, bool bHasValue)
{
- maItem.mnMatchStrId = nMatchStrId;
+ maItem.maString = aString;
maItem.mfValue = fValue;
maItem.mbHasValue = bHasValue;
}
-bool ScDPCacheTable::SingleFilter::match(const ScDPCacheCell& rCell) const
+bool ScDPCacheTable::SingleFilter::match( const ScDPItemData& rCellData ) const
{
- if (rCell.mnStrId != maItem.mnMatchStrId &&
- (!rCell.mbNumeric || rCell.mfValue != maItem.mfValue))
- return false;
-
- return true;
+ return maItem.match(rCellData);
}
const String ScDPCacheTable::SingleFilter::getMatchString()
{
- const String* pStr = mrSharedString.getString(maItem.mnMatchStrId);
- if (pStr)
- return *pStr;
-
- return String();
+ return maItem.maString;
}
double ScDPCacheTable::SingleFilter::getMatchValue() const
@@ -139,33 +117,26 @@ bool ScDPCacheTable::SingleFilter::hasValue() const
// ----------------------------------------------------------------------------
-ScDPCacheTable::GroupFilter::GroupFilter(ScSimpleSharedString& rSharedString) :
- mrSharedString(rSharedString)
+ScDPCacheTable::GroupFilter::GroupFilter()
{
}
-bool ScDPCacheTable::GroupFilter::match(const ScDPCacheCell& rCell) const
+bool ScDPCacheTable::GroupFilter::match( const ScDPItemData& rCellData ) const
{
vector<FilterItem>::const_iterator itrEnd = maItems.end();
- for (vector<FilterItem>::const_iterator itr = maItems.begin(); itr != itrEnd; ++itr)
- {
- bool bMatch = false;
- if (rCell.mbNumeric)
- bMatch = (itr->mfValue == rCell.mfValue);
- else
- bMatch = (itr->mnMatchStrId == rCell.mnStrId);
-
- if (bMatch)
- return true;
- }
- return false;
+ for (vector<FilterItem>::const_iterator itr = maItems.begin(); itr != itrEnd; ++itr)
+ {
+ bool bMatch = itr->match( rCellData);
+ if (bMatch)
+ return true;
+ }
+ return false;
}
void ScDPCacheTable::GroupFilter::addMatchItem(const String& rStr, double fVal, bool bHasValue)
{
- sal_Int32 nStrId = mrSharedString.getStringId(rStr);
FilterItem aItem;
- aItem.mnMatchStrId = nStrId;
+ aItem.maString = rStr;
aItem.mfValue = fVal;
aItem.mbHasValue = bHasValue;
maItems.push_back(aItem);
@@ -186,10 +157,16 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
-ScDPCacheTable::ScDPCacheTable(ScDPCollection* pCollection) :
- mrSharedString(pCollection->GetSharedString()),
- mpCollection(pCollection)
+ScDPCacheTable::ScDPCacheTable( ScDocument* pDoc,long nId ) :
+ mpCache( NULL ),
+ mpNoneCache( NULL )
{
+ if ( nId >= 0 )
+ mpCache = pDoc->GetDPObjectCache( nId );
+ else
+ { //create a temp cache object
+ InitNoneCache( NULL );
+ }
}
ScDPCacheTable::~ScDPCacheTable()
@@ -198,12 +175,12 @@ ScDPCacheTable::~ScDPCacheTable()
sal_Int32 ScDPCacheTable::getRowSize() const
{
- return maTable.size();
+ return GetCache()->GetRowCount();
}
sal_Int32 ScDPCacheTable::getColSize() const
{
- return maTable.empty() ? 0 : maTable[0].size();
+ return GetCache()->GetColumnCount();
}
namespace {
@@ -230,276 +207,114 @@ private:
}
-void ScDPCacheTable::fillTable(ScDocument* pDoc, const ScRange& rRange, const ScQueryParam& rQuery, BOOL* pSpecial,
- bool bIgnoreEmptyRows)
+void ScDPCacheTable::fillTable( const ScQueryParam& rQuery, BOOL* pSpecial,
+ bool bIgnoreEmptyRows, bool bRepeatIfEmpty )
{
// Make sure the formula cells within the data range are interpreted
// during this call, for this method may be called from the interpretation
// of GETPIVOTDATA, which disables nested formula interpretation without
// increasing the macro level.
- MacroInterpretIncrementer aMacroInc(pDoc);
-
- SCTAB nTab = rRange.aStart.Tab();
- SCCOL nStartCol = rRange.aStart.Col();
- SCROW nStartRow = rRange.aStart.Row();
- SCCOL nColCount = rRange.aEnd.Col() - rRange.aStart.Col() + 1;
- SCROW nRowCount = rRange.aEnd.Row() - rRange.aStart.Row() + 1;
-
- if (nRowCount <= 1 || nColCount <= 0)
+ MacroInterpretIncrementer aMacroInc(GetCache()->GetDoc());
+
+ if ( mpCache == NULL )
+ InitNoneCache( NULL );
+//check cache
+ const SCROW nRowCount = getRowSize();
+ const SCCOL nColCount = (SCCOL) getColSize();
+ if ( nRowCount <= 0 || nColCount <= 0)
return;
- maTable.clear();
- maTable.reserve(nRowCount);
- maHeader.clear();
- maHeader.reserve(nColCount);
maRowsVisible.clear();
maRowsVisible.reserve(nRowCount);
- // Header row
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- String aStr;
- pDoc->GetString(nCol + nStartCol, nStartRow, nTab, aStr);
- sal_Int32 nStrId = mrSharedString.insertString(aStr);
- maHeader.push_back(nStrId);
- }
// Initialize field entries container.
maFieldEntries.clear();
maFieldEntries.reserve(nColCount);
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- TypedScStrCollectionPtr p(new TypedScStrCollection);
- maFieldEntries.push_back(p);
- }
-
- vector<SCROW> aLastNonEmptyRows(nColCount, 0);
// Data rows
- for (SCROW nRow = 1; nRow < nRowCount; ++nRow)
+ for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
{
- if ( lcl_HasQueryEntry(rQuery) && !pDoc->ValidQuery(nRow + nStartRow, nTab, rQuery, pSpecial) )
- // filtered out by standard filter.
- continue;
-
- if ( bIgnoreEmptyRows &&
- pDoc->IsBlockEmpty(nTab, nStartCol, nRow + nStartRow,
- nStartCol + nColCount - 1, nRow + nStartRow) )
- // skip an empty row.
- continue;
-
- // Insert a new row into cache table.
- maRowsVisible.push_back(true);
- maTable.push_back( vector<Cell>() );
- maTable.back().reserve(nColCount);
-
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
+ SCROW nMemCount = GetCache()->GetDimMemberCount( nCol );
+ if ( nMemCount )
{
- maTable.back().push_back( ScDPCacheTable::Cell() );
- Cell& rCell = maTable.back().back();
- rCell.mnCategoryRef = maTable.size()-1;
+ std::vector< SCROW > pAdded( nMemCount, -1 );
- String aCellStr;
- bool bReadCell = nRow == 0 || pDoc->HasData(nStartCol + nCol, nStartRow + nRow, nTab);
- if (bReadCell)
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
{
- aLastNonEmptyRows[nCol] = maTable.size()-1;
- ScDPCacheCell aCell;
- pDoc->GetString(nStartCol + nCol, nStartRow + nRow, nTab, aCellStr);
- aCell.mnStrId = mrSharedString.insertString(aCellStr);
- aCell.mnType = SC_VALTYPE_STRING;
- aCell.mbNumeric = false;
- ScAddress aPos(nStartCol + nCol, nStartRow + nRow, nTab);
- getValueData(pDoc, aPos, aCell);
- rCell.mpContent = mpCollection->getCacheCellFromPool(aCell);
+ SCROW nIndex = GetCache()->GetItemDataId( nCol, nRow, bRepeatIfEmpty );
+ SCROW nOrder = GetCache()->GetOrder( nCol, nIndex );
+
+ if ( nCol == 0 )
+ maRowsVisible.push_back(false);
+
+ if ( lcl_HasQueryEntry(rQuery) &&
+ !GetCache()->ValidQuery( nRow , rQuery, pSpecial ) )
+ continue;
+ if ( bIgnoreEmptyRows && GetCache()->IsRowEmpty( nRow ) )
+ continue;
+ // Insert a new row into cache table.
+ if ( nCol == 0 )
+ maRowsVisible.back() = true;
+
+ pAdded[nOrder] = nIndex;
+ }
+ maFieldEntries.push_back( vector<SCROW>() );
+ for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
+ {
+ if ( pAdded[nRow] != -1 )
+ maFieldEntries.back().push_back( pAdded[nRow] );
}
- else
- rCell.mnCategoryRef = aLastNonEmptyRows[nCol];
-
- TypedStrData* pNew;
- if (rCell.mpContent && rCell.mpContent->mbNumeric)
- pNew = new TypedStrData(aCellStr, rCell.mpContent->mfValue, SC_STRTYPE_VALUE);
- else
- pNew = new TypedStrData(aCellStr);
-
- if (!maFieldEntries[nCol]->Insert(pNew))
- delete pNew;
}
}
}
-void lcl_GetCellValue(const Reference<sdbc::XRow>& xRow, sal_Int32 nType, long nCol,
- const Date& rNullDate, ScDPCacheCell& rCell, String& rStr,
- ScSimpleSharedString& rSharedString)
+void ScDPCacheTable::fillTable()
{
- short nNumType = NUMBERFORMAT_NUMBER;
- BOOL bEmptyFlag = FALSE;
- try
- {
- rStr = xRow->getString(nCol);
- rCell.mnStrId = rSharedString.getStringId(rStr);
- rCell.mnType = SC_VALTYPE_STRING;
-
- switch (nType)
- {
- case sdbc::DataType::BIT:
- case sdbc::DataType::BOOLEAN:
- {
- nNumType = NUMBERFORMAT_LOGICAL;
- rCell.mfValue = xRow->getBoolean(nCol) ? 1 : 0;
- bEmptyFlag = (rCell.mfValue == 0.0 && xRow->wasNull());
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
-
- case sdbc::DataType::TINYINT:
- case sdbc::DataType::SMALLINT:
- case sdbc::DataType::INTEGER:
- case sdbc::DataType::BIGINT:
- case sdbc::DataType::FLOAT:
- case sdbc::DataType::REAL:
- case sdbc::DataType::DOUBLE:
- case sdbc::DataType::NUMERIC:
- case sdbc::DataType::DECIMAL:
- {
- //! do the conversion here?
- rCell.mfValue = xRow->getDouble(nCol);
- bEmptyFlag = (rCell.mfValue == 0.0 && xRow->wasNull());
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
-
- case sdbc::DataType::CHAR:
- case sdbc::DataType::VARCHAR:
- case sdbc::DataType::LONGVARCHAR:
- bEmptyFlag = (rStr.Len() == 0 && xRow->wasNull());
- break;
+ if ( mpCache == NULL )
+ InitNoneCache( NULL );
+//check cache
+ const SCROW nRowCount = getRowSize();
+ const SCCOL nColCount = (SCCOL) getColSize();
+ if ( nRowCount <= 0 || nColCount <= 0)
+ return;
- case sdbc::DataType::DATE:
- {
- nNumType = NUMBERFORMAT_DATE;
+ maRowsVisible.clear();
+ maRowsVisible.reserve(nRowCount);
- util::Date aDate = xRow->getDate(nCol);
- rCell.mfValue = Date(aDate.Day, aDate.Month, aDate.Year) - rNullDate;
- bEmptyFlag = xRow->wasNull();
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
- case sdbc::DataType::TIME:
- {
- nNumType = NUMBERFORMAT_TIME;
-
- util::Time aTime = xRow->getTime(nCol);
- rCell.mfValue = ( aTime.Hours * 3600 + aTime.Minutes * 60 +
- aTime.Seconds + aTime.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
- bEmptyFlag = xRow->wasNull();
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
+ // Initialize field entries container.
+ maFieldEntries.clear();
+ maFieldEntries.reserve(nColCount);
- case sdbc::DataType::TIMESTAMP:
- {
- nNumType = NUMBERFORMAT_DATETIME;
-
- util::DateTime aStamp = xRow->getTimestamp(nCol);
- rCell.mfValue = ( Date( aStamp.Day, aStamp.Month, aStamp.Year ) - rNullDate ) +
- ( aStamp.Hours * 3600 + aStamp.Minutes * 60 +
- aStamp.Seconds + aStamp.HundredthSeconds / 100.0 ) / D_TIMEFACTOR;
- bEmptyFlag = xRow->wasNull();
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
- break;
-
- case sdbc::DataType::SQLNULL:
- case sdbc::DataType::BINARY:
- case sdbc::DataType::VARBINARY:
- case sdbc::DataType::LONGVARBINARY:
- default:
- break;
- }
- }
- catch (uno::Exception&)
+ // Data rows
+ for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
{
- }
-}
+ SCROW nMemCount = GetCache()->GetDimMemberCount( nCol );
+ if ( nMemCount )
+ {
+ std::vector< SCROW > pAdded( nMemCount, -1 );
-void ScDPCacheTable::fillTable(const Reference<sdbc::XRowSet>& xRowSet, const Date& rNullDate)
-{
- if (!xRowSet.is())
- // Dont' even waste time to go any further.
- return;
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow )
+ {
+ SCROW nIndex = GetCache()->GetItemDataId( nCol, nRow, false );
+ SCROW nOrder = GetCache()->GetOrder( nCol, nIndex );
- try
- {
- Reference<sdbc::XResultSetMetaDataSupplier> xMetaSupp(xRowSet, UNO_QUERY_THROW);
- Reference<sdbc::XResultSetMetaData> xMeta = xMetaSupp->getMetaData();
- if (!xMeta.is())
- return;
-
- sal_Int32 nColCount = xMeta->getColumnCount();
-
- // Get column titles and types.
- vector<sal_Int32> aColTypes(nColCount);
- maHeader.clear();
- maHeader.reserve(nColCount);
- for (sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
- {
- String aColTitle = xMeta->getColumnLabel(nCol+1);
- aColTypes[nCol] = xMeta->getColumnType(nCol+1);
- maHeader.push_back( mrSharedString.getStringId(aColTitle) );
- }
+ if ( nCol == 0 )
+ maRowsVisible.push_back(true);
- // Initialize field entries container.
- maFieldEntries.clear();
- maFieldEntries.reserve(nColCount);
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- TypedScStrCollectionPtr p(new TypedScStrCollection);
- maFieldEntries.push_back(p);
- }
- // Now get the data rows.
- Reference<sdbc::XRow> xRow(xRowSet, UNO_QUERY_THROW);
- xRowSet->first();
- maTable.clear();
- maRowsVisible.clear();
- do
- {
- maRowsVisible.push_back(true);
- maTable.push_back( vector<Cell>() );
- maTable.back().reserve(nColCount);
- for (sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
+ pAdded[nOrder] = nIndex;
+ }
+ maFieldEntries.push_back( vector<SCROW>() );
+ for ( SCROW nRow = 0; nRow < nMemCount; nRow++ )
{
- maTable.back().push_back( Cell() );
- Cell& rCell = maTable.back().back();
- ScDPCacheCell aCellContent;
- String aStr;
- lcl_GetCellValue(xRow, aColTypes[nCol], nCol+1, rNullDate, aCellContent, aStr, mrSharedString);
- rCell.mpContent = mpCollection->getCacheCellFromPool(aCellContent);
-
- TypedStrData* pNew;
- if (rCell.mpContent->mbNumeric)
- pNew = new TypedStrData(aStr, rCell.mpContent->mfValue, SC_STRTYPE_VALUE);
- else
- pNew = new TypedStrData(aStr);
-
- if (!maFieldEntries[nCol]->Insert(pNew))
- delete pNew;
+ if ( pAdded[nRow] != -1 )
+ maFieldEntries.back().push_back( pAdded[nRow] );
}
}
- while (xRowSet->next());
-
- xRowSet->beforeFirst();
- }
- catch (const Exception&)
- {
}
+ return;
}
bool ScDPCacheTable::isRowActive(sal_Int32 nRow) const
@@ -524,41 +339,43 @@ void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, c
maRowsVisible[nRow] = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
}
-const ScDPCacheCell* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
{
- if ( nRow >= static_cast<SCROW>(maTable.size()) )
- return NULL;
-
- const vector<Cell>& rRow = maTable[nRow];
- if ( nCol < 0 || static_cast<size_t>(nCol) >= rRow.size() )
- return NULL;
+ SCROW nId= GetCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
+ return GetCache()->GetItemDataById( nCol, nId );
+}
- const Cell& rCell = rRow[nCol];
- const ScDPCacheCell* pCell = rCell.mpContent;
- if (bRepeatIfEmpty && !pCell)
- pCell = getCell(nCol, rCell.mnCategoryRef, false);
+void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+{
+ const ScDPItemData* pData = getCell( nCol, nRow, bRepeatIfEmpty );
- return pCell ? pCell : &EmptyCellContent;
+ if (pData)
+ {
+ rVal.fValue = pData->IsValue() ? pData->GetValue() : 0.0;
+ rVal.nType = pData->GetType();
+ }
+ else
+ rVal.Set(0.0, SC_VALTYPE_EMPTY);
}
-
-const String* ScDPCacheTable::getFieldName(sal_Int32 nIndex) const
+String ScDPCacheTable::getFieldName(SCCOL nIndex) const
{
- if (nIndex >= static_cast<sal_Int32>(maHeader.size()))
- return NULL;
+ return (GetCache()->GetDimensionName( nIndex ));
+}
- return mrSharedString.getString(maHeader[nIndex]);
+sal_Int32 ScDPCacheTable::getFieldIndex(const String& rStr) const
+{
+ return GetCache()->GetDimensionIndex( rStr );
}
-const TypedScStrCollection& ScDPCacheTable::getFieldEntries(sal_Int32 nIndex) const
+const ::std::vector<SCROW>& ScDPCacheTable::getFieldEntries( sal_Int32 nColumn ) const
{
- if (nIndex < 0 || static_cast<size_t>(nIndex) >= maFieldEntries.size())
+ if (nColumn < 0 || static_cast<size_t>(nColumn) >= maFieldEntries.size())
{
// index out of bound. Hopefully this code will never be reached.
- static const TypedScStrCollection emptyCollection;
- return emptyCollection;
+ static const ::std::vector<SCROW> emptyEntries;
+ return emptyEntries;
}
-
- return *maFieldEntries[nIndex].get();
+ return maFieldEntries[nColumn];
}
void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< Sequence<Any> >& rTabData,
@@ -577,13 +394,10 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
// Header first.
Sequence<Any> headerRow(nColSize);
- for (sal_Int32 nCol = 0; nCol < nColSize; ++nCol)
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
{
OUString str;
- const String* pStr = mrSharedString.getString(maHeader[nCol]);
- if (pStr)
- str = *pStr;
-
+ str = getFieldName( nCol);
Any any;
any <<= str;
headerRow[nCol] = any;
@@ -607,26 +421,14 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
{
Any any;
bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(nCol) > 0;
- const ScDPCacheCell* pCell = getCell(nCol, nRow, bRepeatIfEmpty);
- if (!pCell)
- {
- // This should never happen, but in case this happens, just
- // stick in an empty string.
- OUString str;
- any <<= str;
- row[nCol] = any;
- continue;
- }
-
- if (pCell->mbNumeric)
- any <<= pCell->mfValue;
+ // Wang Xu Ming - DataPilot migration
+ const ScDPItemData* pData= getCell(nCol, nRow, bRepeatIfEmpty);
+ if ( pData->IsValue() )
+ any <<= pData->GetValue();
else
{
- OUString str;
- const String* pStr = mrSharedString.getString(pCell->mnStrId);
- if (pStr)
- str = *pStr;
- any <<= str;
+ OUString string (pData->GetString() );
+ any <<= string;
}
row[nCol] = any;
}
@@ -642,15 +444,19 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
void ScDPCacheTable::clear()
{
- maTable.clear();
- maHeader.clear();
maFieldEntries.clear();
maRowsVisible.clear();
}
+void ScDPCacheTable::swap(ScDPCacheTable& rOther)
+{
+ maFieldEntries.swap(rOther.maFieldEntries);
+ maRowsVisible.swap(rOther.maRowsVisible);
+}
+
bool ScDPCacheTable::empty() const
{
- return maTable.empty();
+ return ( mpCache == NULL&& mpNoneCache == NULL ) || maFieldEntries.size()==0;
}
bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
@@ -667,52 +473,26 @@ bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCr
// Check if the 'repeat if empty' flag is set for this field.
bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(itr->mnFieldIndex) > 0;
- const ScDPCacheCell* pCell = getCell(static_cast<SCCOL>(itr->mnFieldIndex), nRow, bRepeatIfEmpty);
- if (!pCell)
- // This should never happen, but just in case...
- return false;
-
- if (!itr->mpFilter->match(*pCell))
+ const ScDPItemData* pCellData = getCell(static_cast<SCCOL>(itr->mnFieldIndex), nRow, bRepeatIfEmpty);
+ if (!itr->mpFilter->match(*pCellData))
return false;
}
return true;
}
-void ScDPCacheTable::getValueData(ScDocument* pDoc, const ScAddress& rPos, ScDPCacheCell& rCell)
-{
- ScBaseCell* pCell = pDoc->GetCell(rPos);
- if (!pCell)
- {
- rCell.mnType = SC_VALTYPE_EMPTY;
- return;
- }
-
- CellType eType = pCell->GetCellType();
- if (eType == CELLTYPE_NOTE)
- {
- // note cell
- rCell.mnType = SC_VALTYPE_EMPTY;
- return;
- }
- if (eType == CELLTYPE_FORMULA && static_cast<ScFormulaCell*>(pCell)->GetErrCode())
- {
- // formula cell with error
- rCell.mnType = SC_VALTYPE_ERROR;
- return;
- }
-
- if ( pCell->HasValueData() )
- {
- if (eType == CELLTYPE_VALUE)
- // value cell
- rCell.mfValue = static_cast<ScValueCell*>(pCell)->GetValue();
- else if (eType == CELLTYPE_FORMULA)
- // formula cell
- rCell.mfValue = static_cast<ScFormulaCell*>(pCell)->GetValue();
-
- rCell.mbNumeric = true;
- rCell.mnType = SC_VALTYPE_VALUE;
- }
+void ScDPCacheTable::InitNoneCache( ScDocument* pDoc )
+{
+ mpCache = NULL;
+ if ( mpNoneCache )
+ delete mpNoneCache;
+ mpNoneCache = new ScDPTableDataCache( pDoc );
}
+ScDPTableDataCache* ScDPCacheTable::GetCache() const
+{
+ if ( mpCache )
+ return mpCache;
+ return mpNoneCache;
+}
+// End Comments