Kaydet (Commit) 1e50a93d authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Determine data size in cache that doesn't include trailing empty rows.

Change-Id: I47632b7ae93f4e68c4512fc30f4e4fe18e1c5f4d
üst 123206d0
......@@ -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;
......
......@@ -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 ");
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment