sc/inc/dpcache.hxx | 6 +++--- sc/source/core/data/dpcache.cxx | 29 ++++++++++++----------------- 2 files changed, 15 insertions(+), 20 deletions(-)
New commits: commit 3a28389d6713bf29e1da2fea07b663fdd9cc3faa Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Fri Mar 9 15:56:30 2012 -0500 Use flat_segment_tree to store the empty row flags. diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx index 31d5103..2880c5a 100644 --- a/sc/inc/dpcache.hxx +++ b/sc/inc/dpcache.hxx @@ -41,6 +41,7 @@ #include <boost/noncopyable.hpp> #include <boost/scoped_ptr.hpp> #include <boost/ptr_container/ptr_vector.hpp> +#include <mdds/flat_segment_tree.hpp> #include <vector> @@ -119,7 +120,7 @@ private: GroupFieldsType maGroupFields; LabelsType maLabelNames; // Stores dimension names. - std::vector<bool> maEmptyRows; // Keeps track of empty rows. + mdds::flat_segment_tree<SCROW, bool> maEmptyRows; bool mbDisposing; @@ -150,7 +151,7 @@ public: SCROW GetRowCount() 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 IsRowEmpty(SCROW nRow) const; bool ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam) const; ScDocument* GetDoc() const; diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index 9ae41a4..73e1819 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -228,6 +228,7 @@ ScDPCache::Field::Field() {} ScDPCache::ScDPCache(ScDocument* pDoc) : mpDoc( pDoc ), mnColumnCount ( 0 ), + maEmptyRows(0, MAXROW, true), mbDisposing(false) { } @@ -341,6 +342,9 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange) maLabelNames.reserve(mnColumnCount+1); + // Set all rows non-empty first, then only tag empty ones in AddData(). + maEmptyRows.insert_front(nStartRow, nEndRow+1, false); + for (sal_uInt16 nCol = nStartCol; nCol <= nEndCol; ++nCol) { AddLabel(createLabelString(pDoc, nCol, nStartRow, nDocTab)); @@ -352,6 +356,7 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange) AddData(nCol - nStartCol, pData.release(), nNumFormat); } } + maEmptyRows.build_tree(); return true; } @@ -409,6 +414,7 @@ bool ScDPCache::InitFromDataBase (const Reference<sdbc::XRowSet>& xRowSet, const xRowSet->beforeFirst(); + maEmptyRows.build_tree(); return true; } catch (const Exception&) @@ -610,9 +616,11 @@ bool ScDPCache::ValidQuery( SCROW nRow, const ScQueryParam &rParam) const return bRet; } -bool ScDPCache::IsRowEmpty( SCROW nRow ) const +bool ScDPCache::IsRowEmpty(SCROW nRow) const { - return maEmptyRows[nRow]; + bool bEmpty = true; + maEmptyRows.search_tree(nRow, bEmpty); + return bEmpty; } bool ScDPCache::AddData(long nDim, ScDPItemData* pData, sal_uLong nNumFormat) @@ -639,14 +647,10 @@ bool ScDPCache::AddData(long nDim, ScDPItemData* pData, sal_uLong nNumFormat) else rField.maData.push_back(rField.maGlobalOrder[nIndex]); -//init empty row tag size_t nCurRow = maFields[nDim].maData.size() - 1; - while (maEmptyRows.size() <= nCurRow) - maEmptyRows.push_back(true); - - if (!pData->IsEmpty()) - maEmptyRows[nCurRow] = false; + if (pData->IsEmpty()) + maEmptyRows.insert_back(nCurRow, nCurRow+1, true); return true; } commit 2877147c477f064c213af53a8f250ce96ad1e5f2 Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Fri Mar 9 15:13:36 2012 -0500 IsValid() is superfluous. diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx index 661c5cd..31d5103 100644 --- a/sc/inc/dpcache.hxx +++ b/sc/inc/dpcache.hxx @@ -151,7 +151,6 @@ public: SCROW GetItemDataId( sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty ) const; rtl::OUString GetDimensionName(LabelsType::size_type nDim) const; bool IsRowEmpty( SCROW nRow ) const; - bool IsValid() const; bool ValidQuery(SCROW nRow, const ScQueryParam& rQueryParam) const; ScDocument* GetDoc() const; diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index 33a0a25..9ae41a4 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -252,11 +252,6 @@ ScDPCache::~ScDPCache() std::for_each(maRefObjects.begin(), maRefObjects.end(), ClearObjectSource()); } -bool ScDPCache::IsValid() const -{ - return !maFields.empty() && mnColumnCount > 0; -} - namespace { /** @@ -622,7 +617,6 @@ bool ScDPCache::IsRowEmpty( SCROW nRow ) const bool ScDPCache::AddData(long nDim, ScDPItemData* pData, sal_uLong nNumFormat) { - OSL_ENSURE( IsValid(), " IsValid() == false " ); OSL_ENSURE( nDim < mnColumnCount && nDim >=0 , "dimension out of bound" ); // Wrap this instance with scoped pointer to ensure proper deletion. @@ -713,7 +707,6 @@ void ScDPCache::Clear() void ScDPCache::AddLabel(const rtl::OUString& rLabel) { - OSL_ENSURE( IsValid(), " IsValid() == false " ); if ( maLabelNames.empty() ) maLabelNames.push_back(ScGlobal::GetRscString(STR_PIVOT_DATA)); @@ -741,7 +734,6 @@ void ScDPCache::AddLabel(const rtl::OUString& rLabel) SCROW ScDPCache::GetItemDataId(sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty) const { - OSL_ENSURE( IsValid(), " IsValid() == false " ); OSL_ENSURE(nDim < mnColumnCount, "ScDPTableDataCache::GetItemDataId "); const Field& rField = maFields[nDim]; @@ -1086,7 +1078,6 @@ void ScDPCache::ClearGroupFields() SCROW ScDPCache::GetOrder(long nDim, SCROW nIndex) const { - OSL_ENSURE( IsValid(), " IsValid() == false " ); OSL_ENSURE( nDim >=0 && nDim < mnColumnCount, "ScDPTableDataCache::GetOrder : out of bound" ); const Field& rField = maFields[nDim]; _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits