summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/dpcache.hxx6
-rw-r--r--sc/source/core/data/dpcache.cxx20
-rw-r--r--sc/source/core/data/dpcachetable.cxx1
3 files changed, 25 insertions, 2 deletions
diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 7f996e077b91..b69e3c2cb43f 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -130,6 +130,7 @@ private:
LabelsType maLabelNames; // Stores dimension names.
mdds::flat_segment_tree<SCROW, bool> maEmptyRows;
+ SCROW mnDataSize;
bool mbDisposing;
@@ -159,8 +160,9 @@ public:
bool InitFromDoc(ScDocument* pDoc, const ScRange& rRange);
bool InitFromDataBase(DBConnector& rDB);
- SCROW GetRowCount() const;
- SCROW GetItemDataId( sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty ) const;
+ SCROW GetRowCount() const;
+ SCROW GetDataSize() const;
+ SCROW GetItemDataId( sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty ) const;
rtl::OUString GetDimensionName(LabelsType::size_type nDim) const;
bool IsRowEmpty(SCROW nRow) const;
bool ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam) const;
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index c94b5423a473..75234afd8f8e 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -65,6 +65,7 @@ ScDPCache::ScDPCache(ScDocument* pDoc) :
mpDoc( pDoc ),
mnColumnCount ( 0 ),
maEmptyRows(0, MAXROW, true),
+ mnDataSize(-1),
mbDisposing(false)
{
}
@@ -654,7 +655,21 @@ public:
void ScDPCache::PostInit()
{
+ OSL_ENSURE(!maFields.empty(), "Cache not initialized!");
+
maEmptyRows.build_tree();
+ typedef mdds::flat_segment_tree<SCROW, bool>::const_reverse_iterator itr_type;
+ itr_type it = maEmptyRows.rbegin(), itEnd = maEmptyRows.rend();
+ OSL_ENSURE(it != itEnd, "corrupt flat_segment_tree instance!");
+ mnDataSize = maFields[0].maItems.size();
+ ++it; // Skip the first position.
+ OSL_ENSURE(it != itEnd, "buggy version of flat_segment_tree is used.");
+ if (it->second)
+ {
+ SCROW nLastNonEmpty = it->first - 1;
+ if (nLastNonEmpty < mnDataSize)
+ mnDataSize = nLastNonEmpty;
+ }
}
void ScDPCache::Clear()
@@ -753,6 +768,11 @@ SCROW ScDPCache::GetRowCount() const
return maFields[0].maData.size();
}
+SCROW ScDPCache::GetDataSize() const
+{
+ return mnDataSize >= 0 ? mnDataSize : 0;
+}
+
const ScDPCache::ItemsType& ScDPCache::GetDimMemberValues(SCCOL nDim) const
{
OSL_ENSURE( nDim>=0 && nDim < mnColumnCount ," nDim < mnColumnCount ");
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 6afb9c5ca08c..f1a6417c9f93 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -147,6 +147,7 @@ void ScDPCacheTable::fillTable(
const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
{
const SCROW nRowCount = getRowSize();
+ SCROW nDataSize = mpCache->GetDataSize();
const SCCOL nColCount = (SCCOL) getColSize();
if ( nRowCount <= 0 || nColCount <= 0)
return;