[Libreoffice-commits] .: 5 commits - sc/inc sc/Library_sc.mk sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Oct 31 19:13:51 PDT 2012
sc/Library_sc.mk | 2
sc/inc/dpcachetable.hxx | 192 ------------
sc/inc/dpfilteredcache.hxx | 185 ++++++++++++
sc/inc/dpgroup.hxx | 12
sc/inc/dpoutput.hxx | 2
sc/inc/dpsdbtab.hxx | 12
sc/inc/dpshttab.hxx | 10
sc/inc/dptabdat.hxx | 14
sc/inc/dptabres.hxx | 4
sc/inc/dptabsrc.hxx | 2
sc/source/core/data/dpcachetable.cxx | 474 --------------------------------
sc/source/core/data/dpfilteredcache.cxx | 463 +++++++++++++++++++++++++++++++
sc/source/core/data/dpgroup.cxx | 44 +-
sc/source/core/data/dpobject.cxx | 4
sc/source/core/data/dpoutput.cxx | 2
sc/source/core/data/dpsdbtab.cxx | 20 -
sc/source/core/data/dpshttab.cxx | 20 -
sc/source/core/data/dptabdat.cxx | 8
sc/source/core/data/dptabres.cxx | 10
sc/source/core/data/dptabsrc.cxx | 35 +-
sc/source/filter/excel/xepivot.cxx | 2
21 files changed, 742 insertions(+), 775 deletions(-)
New commits:
commit 507cf0c4ddfac44a43caf4405e220bdd00dca438
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Oct 31 22:12:07 2012 -0400
Rename the files to reflect the class name change.
Change-Id: I6223cd12ab539cd19555c0b23f2bce73f519a31f
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index f4cdafa..4ac291e 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -113,8 +113,8 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/data/documen8 \
sc/source/core/data/documen9 \
sc/source/core/data/document \
- sc/source/core/data/dpcachetable \
sc/source/core/data/dpdimsave \
+ sc/source/core/data/dpfilteredcache \
sc/source/core/data/dpgroup \
sc/source/core/data/dpitemdata \
sc/source/core/data/dpnumgroupinfo \
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
deleted file mode 100644
index f72bbdf..0000000
--- a/sc/inc/dpcachetable.hxx
+++ /dev/null
@@ -1,185 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef SC_DPCACHETABLE_HXX
-#define SC_DPCACHETABLE_HXX
-
-#include "sal/types.h"
-#include "osl/mutex.hxx"
-#include "global.hxx"
-#include "dpitemdata.hxx"
-#include "dpmacros.hxx"
-
-#include <vector>
-#include <boost/unordered_set.hpp>
-#include <boost/shared_ptr.hpp>
-
-#include <mdds/flat_segment_tree.hpp>
-
-class ScDPItemData;
-class ScDPCache;
-class ScDocument;
-class ScRange;
-struct ScDPValueData;
-struct ScQueryParam;
-
-/**
- * This class is only a wrapper to the actual cache, to provide filtering on
- * the raw data based on the query filter and/or page field filters.
- */
-class SC_DLLPUBLIC ScDPFilteredCache
-{
- typedef mdds::flat_segment_tree<SCROW, bool> RowFlagType;
-
-public:
- /** interface class used for filtering of rows. */
- class FilterBase
- {
- public:
- virtual ~FilterBase() {}
- /** returns true if the matching condition is met for a single cell
- value, or false otherwise. */
- virtual bool match( const ScDPItemData& rCellData ) const = 0;
- };
-
- /** ordinary single-item filter. */
- class SingleFilter : public FilterBase
- {
- public:
- explicit SingleFilter(const ScDPItemData &rItem);
- virtual ~SingleFilter() {}
-
- virtual bool match(const ScDPItemData& rCellData) const;
-
- const ScDPItemData& getMatchValue() const;
-
- private:
- explicit SingleFilter();
-
- ScDPItemData maItem;
- };
-
- /** multi-item (group) filter. */
- class GroupFilter : public FilterBase
- {
- public:
- GroupFilter();
- virtual ~GroupFilter() {}
- virtual bool match(const ScDPItemData& rCellData) const;
- void addMatchItem(const ScDPItemData& rItem);
- size_t getMatchItemCount() const;
-
- private:
- ::std::vector<ScDPItemData> maItems;
- };
-
- /** single filtering criterion. */
- struct Criterion
- {
- sal_Int32 mnFieldIndex;
- ::boost::shared_ptr<FilterBase> mpFilter;
-
- Criterion();
- };
-
- ScDPFilteredCache(const ScDPCache& rCache);
- ~ScDPFilteredCache();
-
- sal_Int32 getRowSize() const;
- sal_Int32 getColSize() const;
-
- const ScDPCache* getCache() const;
-
- void fillTable(const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty);
-
- void fillTable();
-
- /** Check whether a specified row is active or not. When a row is active,
- it is used in calculation of the results data. A row becomes inactive
- when it is filtered out by page field. */
- bool isRowActive(sal_Int32 nRow, sal_Int32* pLastRow = NULL) const;
-
- /** Set filter on/off flag to each row to control visibility. The caller
- must ensure that the table is filled before calling this function. */
- void filterByPageDimension(const ::std::vector<Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims);
-
- /** Get the cell instance at specified location within the data grid. Note
- that the data grid doesn't include the header row. Don't delete the
- returned object! */
- const ScDPItemData* getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
- void getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
- rtl::OUString getFieldName(SCCOL nIndex) const;
-
- /** Get the unique entries for a field specified by index. The caller must
- make sure that the table is filled before calling function, or it will
- get an empty collection. */
- const ::std::vector<SCROW>& getFieldEntries( sal_Int32 nColumn ) const;
-
- /** Filter the table based on the specified criteria, and copy the
- result to rTabData. This method is used, for example, to generate
- a drill-down data table. */
- void filterTable(const ::std::vector<Criterion>& rCriteria,
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rTabData,
- const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims);
-
- SCROW getOrder(long nDim, SCROW nIndex) const;
- void clear();
- bool empty() const;
-
-#if DEBUG_PIVOT_TABLE
- void dumpRowFlag(const RowFlagType& rFlag) const;
- void dump() const;
-#endif
-
-private:
- ScDPFilteredCache();
- ScDPFilteredCache(const ScDPFilteredCache&);
-
- /**
- * Check if a given row meets all specified criteria.
- *
- * @param nRow index of row to be tested.
- * @param rCriteria a list of criteria
- */
- bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const;
-
-private:
-
- /** unique field entires for each field (column). */
- ::std::vector< ::std::vector<SCROW> > maFieldEntries;
-
- /** Rows visible by standard filter query. */
- RowFlagType maShowByFilter;
- /** Rows visible by page dimension filtering. */
- RowFlagType maShowByPage;
-
- const ScDPCache& mrCache;
-};
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/dpfilteredcache.hxx b/sc/inc/dpfilteredcache.hxx
new file mode 100644
index 0000000..f72bbdf
--- /dev/null
+++ b/sc/inc/dpfilteredcache.hxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_DPCACHETABLE_HXX
+#define SC_DPCACHETABLE_HXX
+
+#include "sal/types.h"
+#include "osl/mutex.hxx"
+#include "global.hxx"
+#include "dpitemdata.hxx"
+#include "dpmacros.hxx"
+
+#include <vector>
+#include <boost/unordered_set.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <mdds/flat_segment_tree.hpp>
+
+class ScDPItemData;
+class ScDPCache;
+class ScDocument;
+class ScRange;
+struct ScDPValueData;
+struct ScQueryParam;
+
+/**
+ * This class is only a wrapper to the actual cache, to provide filtering on
+ * the raw data based on the query filter and/or page field filters.
+ */
+class SC_DLLPUBLIC ScDPFilteredCache
+{
+ typedef mdds::flat_segment_tree<SCROW, bool> RowFlagType;
+
+public:
+ /** interface class used for filtering of rows. */
+ class FilterBase
+ {
+ public:
+ virtual ~FilterBase() {}
+ /** returns true if the matching condition is met for a single cell
+ value, or false otherwise. */
+ virtual bool match( const ScDPItemData& rCellData ) const = 0;
+ };
+
+ /** ordinary single-item filter. */
+ class SingleFilter : public FilterBase
+ {
+ public:
+ explicit SingleFilter(const ScDPItemData &rItem);
+ virtual ~SingleFilter() {}
+
+ virtual bool match(const ScDPItemData& rCellData) const;
+
+ const ScDPItemData& getMatchValue() const;
+
+ private:
+ explicit SingleFilter();
+
+ ScDPItemData maItem;
+ };
+
+ /** multi-item (group) filter. */
+ class GroupFilter : public FilterBase
+ {
+ public:
+ GroupFilter();
+ virtual ~GroupFilter() {}
+ virtual bool match(const ScDPItemData& rCellData) const;
+ void addMatchItem(const ScDPItemData& rItem);
+ size_t getMatchItemCount() const;
+
+ private:
+ ::std::vector<ScDPItemData> maItems;
+ };
+
+ /** single filtering criterion. */
+ struct Criterion
+ {
+ sal_Int32 mnFieldIndex;
+ ::boost::shared_ptr<FilterBase> mpFilter;
+
+ Criterion();
+ };
+
+ ScDPFilteredCache(const ScDPCache& rCache);
+ ~ScDPFilteredCache();
+
+ sal_Int32 getRowSize() const;
+ sal_Int32 getColSize() const;
+
+ const ScDPCache* getCache() const;
+
+ void fillTable(const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty);
+
+ void fillTable();
+
+ /** Check whether a specified row is active or not. When a row is active,
+ it is used in calculation of the results data. A row becomes inactive
+ when it is filtered out by page field. */
+ bool isRowActive(sal_Int32 nRow, sal_Int32* pLastRow = NULL) const;
+
+ /** Set filter on/off flag to each row to control visibility. The caller
+ must ensure that the table is filled before calling this function. */
+ void filterByPageDimension(const ::std::vector<Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims);
+
+ /** Get the cell instance at specified location within the data grid. Note
+ that the data grid doesn't include the header row. Don't delete the
+ returned object! */
+ const ScDPItemData* getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
+ void getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const;
+ rtl::OUString getFieldName(SCCOL nIndex) const;
+
+ /** Get the unique entries for a field specified by index. The caller must
+ make sure that the table is filled before calling function, or it will
+ get an empty collection. */
+ const ::std::vector<SCROW>& getFieldEntries( sal_Int32 nColumn ) const;
+
+ /** Filter the table based on the specified criteria, and copy the
+ result to rTabData. This method is used, for example, to generate
+ a drill-down data table. */
+ void filterTable(const ::std::vector<Criterion>& rCriteria,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rTabData,
+ const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims);
+
+ SCROW getOrder(long nDim, SCROW nIndex) const;
+ void clear();
+ bool empty() const;
+
+#if DEBUG_PIVOT_TABLE
+ void dumpRowFlag(const RowFlagType& rFlag) const;
+ void dump() const;
+#endif
+
+private:
+ ScDPFilteredCache();
+ ScDPFilteredCache(const ScDPFilteredCache&);
+
+ /**
+ * Check if a given row meets all specified criteria.
+ *
+ * @param nRow index of row to be tested.
+ * @param rCriteria a list of criteria
+ */
+ bool isRowQualified(sal_Int32 nRow, const ::std::vector<Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const;
+
+private:
+
+ /** unique field entires for each field (column). */
+ ::std::vector< ::std::vector<SCROW> > maFieldEntries;
+
+ /** Rows visible by standard filter query. */
+ RowFlagType maShowByFilter;
+ /** Rows visible by page dimension filtering. */
+ RowFlagType maShowByPage;
+
+ const ScDPCache& mrCache;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index 22f18a6..1716d4a 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -38,7 +38,7 @@
#include "global.hxx"
#include "address.hxx"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include "dptypes.hxx"
#include <vector>
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 26ada0e..629a0e5 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -31,7 +31,7 @@
#include "address.hxx"
#include "dpoutput.hxx"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include "dpcache.hxx"
#include "dpmacros.hxx"
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index e5a939a..6a5a1df 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -30,7 +30,7 @@
#define SC_DPTABRES_HXX
#include "global.hxx"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include <tools/string.hxx>
#include <com/sun/star/sheet/MemberResult.hpp>
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
deleted file mode 100644
index 1da99f6..0000000
--- a/sc/source/core/data/dpcachetable.cxx
+++ /dev/null
@@ -1,463 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#include "dpcachetable.hxx"
-#include "document.hxx"
-#include "address.hxx"
-#include "cell.hxx"
-#include "dptabdat.hxx"
-#include "dptabsrc.hxx"
-#include "dpobject.hxx"
-#include "queryparam.hxx"
-#include "queryentry.hxx"
-#include "dpitemdata.hxx"
-
-#include <com/sun/star/i18n/LocaleDataItem.hpp>
-#include <com/sun/star/sdbc/DataType.hpp>
-#include <com/sun/star/sdbc/XRow.hpp>
-#include <com/sun/star/sdbc/XRowSet.hpp>
-#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
-#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
-#include <com/sun/star/util/Date.hpp>
-#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
-#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
-
-#include <memory>
-
-using namespace ::com::sun::star;
-
-using ::rtl::OUString;
-using ::std::vector;
-using ::std::pair;
-using ::std::auto_ptr;
-using ::com::sun::star::i18n::LocaleDataItem;
-using ::com::sun::star::uno::Exception;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::UNO_QUERY;
-using ::com::sun::star::uno::UNO_QUERY_THROW;
-using ::com::sun::star::sheet::DataPilotFieldFilter;
-
-ScDPFilteredCache::SingleFilter::SingleFilter(const ScDPItemData& rItem) :
- maItem(rItem) {}
-
-bool ScDPFilteredCache::SingleFilter::match(const ScDPItemData& rCellData) const
-{
- return maItem == rCellData;
-}
-
-const ScDPItemData& ScDPFilteredCache::SingleFilter::getMatchValue() const
-{
- return maItem;
-}
-
-ScDPFilteredCache::GroupFilter::GroupFilter()
-{
-}
-
-bool ScDPFilteredCache::GroupFilter::match(const ScDPItemData& rCellData) const
-{
- vector<ScDPItemData>::const_iterator it = maItems.begin(), itEnd = maItems.end();
- for (; it != itEnd; ++it)
- {
- bool bMatch = *it == rCellData;
- if (bMatch)
- return true;
- }
- return false;
-}
-
-void ScDPFilteredCache::GroupFilter::addMatchItem(const ScDPItemData& rItem)
-{
- maItems.push_back(rItem);
-}
-
-size_t ScDPFilteredCache::GroupFilter::getMatchItemCount() const
-{
- return maItems.size();
-}
-
-// ----------------------------------------------------------------------------
-
-ScDPFilteredCache::Criterion::Criterion() :
- mnFieldIndex(-1),
- mpFilter(static_cast<FilterBase*>(NULL))
-{
-}
-
-// ----------------------------------------------------------------------------
-
-ScDPFilteredCache::ScDPFilteredCache(const ScDPCache& rCache) :
- maShowByFilter(0, MAXROW+1, false), maShowByPage(0, MAXROW+1, true), mrCache(rCache)
-{
-}
-
-ScDPFilteredCache::~ScDPFilteredCache()
-{
-}
-
-sal_Int32 ScDPFilteredCache::getRowSize() const
-{
- return mrCache.GetRowCount();
-}
-
-sal_Int32 ScDPFilteredCache::getColSize() const
-{
- return mrCache.GetColumnCount();
-}
-
-void ScDPFilteredCache::fillTable(
- const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
-{
- SCROW nRowCount = getRowSize();
- SCROW nDataSize = mrCache.GetDataSize();
- SCCOL nColCount = getColSize();
- if (nRowCount <= 0 || nColCount <= 0)
- return;
-
- maShowByFilter.clear();
- maShowByPage.clear();
- maShowByPage.build_tree();
-
- // Process the non-empty data rows.
- for (SCROW nRow = 0; nRow < nDataSize; ++nRow)
- {
- if (!getCache()->ValidQuery(nRow, rQuery))
- continue;
-
- if (bIgnoreEmptyRows && getCache()->IsRowEmpty(nRow))
- continue;
-
- maShowByFilter.insert_back(nRow, nRow+1, true);
- }
-
- // Process the trailing empty rows.
- if (!bIgnoreEmptyRows)
- maShowByFilter.insert_back(nDataSize, nRowCount, true);
-
- maShowByFilter.build_tree();
-
- // Initialize field entries container.
- maFieldEntries.clear();
- maFieldEntries.reserve(nColCount);
-
- // Build unique field entries.
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- maFieldEntries.push_back( vector<SCROW>() );
- SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
- if (!nMemCount)
- continue;
-
- std::vector<SCROW> aAdded(nMemCount, -1);
- bool bShow = false;
- SCROW nEndSegment = -1;
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
- {
- if (nRow > nEndSegment)
- {
- if (!maShowByFilter.search_tree(nRow, bShow, NULL, &nEndSegment))
- {
- OSL_FAIL("Tree search failed!");
- continue;
- }
- --nEndSegment; // End position is not inclusive. Move back one.
- }
-
- if (!bShow)
- {
- nRow = nEndSegment;
- continue;
- }
-
- SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
- SCROW nOrder = getOrder(nCol, nIndex);
- aAdded[nOrder] = nIndex;
- }
- for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
- {
- if (aAdded[nRow] != -1)
- maFieldEntries.back().push_back(aAdded[nRow]);
- }
- }
-}
-
-void ScDPFilteredCache::fillTable()
-{
- SCROW nRowCount = getRowSize();
- SCCOL nColCount = getColSize();
- if (nRowCount <= 0 || nColCount <= 0)
- return;
-
- maShowByPage.clear();
- maShowByPage.build_tree();
-
- maShowByFilter.clear();
- maShowByFilter.insert_front(0, nRowCount, true);
- maShowByFilter.build_tree();
-
- // Initialize field entries container.
- maFieldEntries.clear();
- maFieldEntries.reserve(nColCount);
-
- // Data rows
- for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
- {
- maFieldEntries.push_back( vector<SCROW>() );
- SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
- if (!nMemCount)
- continue;
-
- std::vector<SCROW> aAdded(nMemCount, -1);
-
- for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
- {
- SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, false);
- SCROW nOrder = getOrder(nCol, nIndex);
- aAdded[nOrder] = nIndex;
- }
- for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
- {
- if (aAdded[nRow] != -1)
- maFieldEntries.back().push_back(aAdded[nRow]);
- }
- }
-}
-
-bool ScDPFilteredCache::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
-{
- bool bFilter = false, bPage = true;
- SCROW nLastRowFilter = MAXROW, nLastRowPage = MAXROW;
- maShowByFilter.search_tree(nRow, bFilter, NULL, &nLastRowFilter);
- maShowByPage.search_tree(nRow, bPage, NULL, &nLastRowPage);
- if (pLastRow)
- {
- // Return the last row of current segment.
- *pLastRow = nLastRowFilter < nLastRowPage ? nLastRowFilter : nLastRowPage;
- *pLastRow -= 1; // End position is not inclusive. Move back one.
- }
-
- return bFilter && bPage;
-}
-
-void ScDPFilteredCache::filterByPageDimension(const vector<Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
-{
- SCROW nRowSize = getRowSize();
-
- maShowByPage.clear();
- for (SCROW nRow = 0; nRow < nRowSize; ++nRow)
- {
- bool bShow = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
- maShowByPage.insert_back(nRow, nRow+1, bShow);
- }
-
- maShowByPage.build_tree();
-}
-
-const ScDPItemData* ScDPFilteredCache::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
-{
- SCROW nId= mrCache.GetItemDataId(nCol, nRow, bRepeatIfEmpty);
- return mrCache.GetItemDataById( nCol, nId );
-}
-
-void ScDPFilteredCache::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
-{
- const ScDPItemData* pData = getCell( nCol, nRow, bRepeatIfEmpty );
-
- if (pData)
- {
- rVal.fValue = pData->IsValue() ? pData->GetValue() : 0.0;
- rVal.nType = pData->GetCellType();
- }
- else
- rVal.Set(0.0, SC_VALTYPE_EMPTY);
-}
-
-rtl::OUString ScDPFilteredCache::getFieldName(SCCOL nIndex) const
-{
- return mrCache.GetDimensionName(nIndex);
-}
-
-const ::std::vector<SCROW>& ScDPFilteredCache::getFieldEntries( sal_Int32 nColumn ) const
-{
- if (nColumn < 0 || static_cast<size_t>(nColumn) >= maFieldEntries.size())
- {
- // index out of bound. Hopefully this code will never be reached.
- static const ::std::vector<SCROW> emptyEntries;
- return emptyEntries;
- }
- return maFieldEntries[nColumn];
-}
-
-void ScDPFilteredCache::filterTable(const vector<Criterion>& rCriteria, Sequence< Sequence<Any> >& rTabData,
- const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
-{
- sal_Int32 nRowSize = getRowSize();
- sal_Int32 nColSize = getColSize();
-
- if (!nRowSize)
- // no data to filter.
- return;
-
- // Row first, then column.
- vector< Sequence<Any> > tableData;
- tableData.reserve(nRowSize+1);
-
- // Header first.
- Sequence<Any> headerRow(nColSize);
- for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
- {
- OUString str;
- str = getFieldName( nCol);
- Any any;
- any <<= str;
- headerRow[nCol] = any;
- }
- tableData.push_back(headerRow);
-
- for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
- {
- sal_Int32 nLastRow;
- if (!isRowActive(nRow, &nLastRow))
- {
- // This row is filtered out.
- nRow = nLastRow;
- continue;
- }
-
- if (!isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims))
- continue;
-
- // Insert this row into table.
-
- Sequence<Any> row(nColSize);
- for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
- {
- Any any;
- bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(nCol) > 0;
- const ScDPItemData* pData= getCell(nCol, nRow, bRepeatIfEmpty);
- if ( pData->IsValue() )
- any <<= pData->GetValue();
- else
- {
- OUString string (pData->GetString() );
- any <<= string;
- }
- row[nCol] = any;
- }
- tableData.push_back(row);
- }
-
- // convert vector to Seqeunce
- sal_Int32 nTabSize = static_cast<sal_Int32>(tableData.size());
- rTabData.realloc(nTabSize);
- for (sal_Int32 i = 0; i < nTabSize; ++i)
- rTabData[i] = tableData[i];
-}
-
-SCROW ScDPFilteredCache::getOrder(long nDim, SCROW nIndex) const
-{
- return mrCache.GetOrder(nDim, nIndex);
-}
-
-void ScDPFilteredCache::clear()
-{
- maFieldEntries.clear();
- maShowByFilter.clear();
- maShowByPage.clear();
-}
-
-bool ScDPFilteredCache::empty() const
-{
- return maFieldEntries.empty();
-}
-
-bool ScDPFilteredCache::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
- const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const
-{
- sal_Int32 nColSize = getColSize();
- vector<Criterion>::const_iterator itrEnd = rCriteria.end();
- for (vector<Criterion>::const_iterator itr = rCriteria.begin(); itr != itrEnd; ++itr)
- {
- if (itr->mnFieldIndex >= nColSize)
- // specified field is outside the source data columns. Don't
- // use this criterion.
- continue;
-
- // Check if the 'repeat if empty' flag is set for this field.
- bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(itr->mnFieldIndex) > 0;
- const ScDPItemData* pCellData = getCell(static_cast<SCCOL>(itr->mnFieldIndex), nRow, bRepeatIfEmpty);
- if (!itr->mpFilter->match(*pCellData))
- return false;
- }
- return true;
-}
-
-const ScDPCache* ScDPFilteredCache::getCache() const
-{
- return &mrCache;
-}
-
-#if DEBUG_PIVOT_TABLE
-#include <iostream>
-using std::cout;
-using std::endl;
-
-void ScDPFilteredCache::dumpRowFlag(const RowFlagType& rFlag) const
-{
- RowFlagType::const_iterator it = rFlag.begin(), itEnd = rFlag.end();
- bool bShow = it->second;
- SCROW nRow1 = it->first;
- for (++it; it != itEnd; ++it)
- {
- SCROW nRow2 = it->first;
- cout << " * range " << nRow1 << "-" << nRow2 << ": " << (bShow ? "on" : "off") << endl;
- bShow = it->second;
- nRow1 = nRow2;
- }
-}
-
-void ScDPFilteredCache::dump() const
-{
- cout << "--- pivot cache filter dump" << endl;
-
- cout << endl;
- cout << "* show by filter" << endl;
- dumpRowFlag(maShowByFilter);
-
- cout << endl;
- cout << "* show by page dimensions" << endl;
- dumpRowFlag(maShowByPage);
-
- cout << "---" << endl;
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx
new file mode 100644
index 0000000..5f4f2bd
--- /dev/null
+++ b/sc/source/core/data/dpfilteredcache.cxx
@@ -0,0 +1,463 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "dpfilteredcache.hxx"
+#include "document.hxx"
+#include "address.hxx"
+#include "cell.hxx"
+#include "dptabdat.hxx"
+#include "dptabsrc.hxx"
+#include "dpobject.hxx"
+#include "queryparam.hxx"
+#include "queryentry.hxx"
+#include "dpitemdata.hxx"
+
+#include <com/sun/star/i18n/LocaleDataItem.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+
+#include <memory>
+
+using namespace ::com::sun::star;
+
+using ::rtl::OUString;
+using ::std::vector;
+using ::std::pair;
+using ::std::auto_ptr;
+using ::com::sun::star::i18n::LocaleDataItem;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::sheet::DataPilotFieldFilter;
+
+ScDPFilteredCache::SingleFilter::SingleFilter(const ScDPItemData& rItem) :
+ maItem(rItem) {}
+
+bool ScDPFilteredCache::SingleFilter::match(const ScDPItemData& rCellData) const
+{
+ return maItem == rCellData;
+}
+
+const ScDPItemData& ScDPFilteredCache::SingleFilter::getMatchValue() const
+{
+ return maItem;
+}
+
+ScDPFilteredCache::GroupFilter::GroupFilter()
+{
+}
+
+bool ScDPFilteredCache::GroupFilter::match(const ScDPItemData& rCellData) const
+{
+ vector<ScDPItemData>::const_iterator it = maItems.begin(), itEnd = maItems.end();
+ for (; it != itEnd; ++it)
+ {
+ bool bMatch = *it == rCellData;
+ if (bMatch)
+ return true;
+ }
+ return false;
+}
+
+void ScDPFilteredCache::GroupFilter::addMatchItem(const ScDPItemData& rItem)
+{
+ maItems.push_back(rItem);
+}
+
+size_t ScDPFilteredCache::GroupFilter::getMatchItemCount() const
+{
+ return maItems.size();
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPFilteredCache::Criterion::Criterion() :
+ mnFieldIndex(-1),
+ mpFilter(static_cast<FilterBase*>(NULL))
+{
+}
+
+// ----------------------------------------------------------------------------
+
+ScDPFilteredCache::ScDPFilteredCache(const ScDPCache& rCache) :
+ maShowByFilter(0, MAXROW+1, false), maShowByPage(0, MAXROW+1, true), mrCache(rCache)
+{
+}
+
+ScDPFilteredCache::~ScDPFilteredCache()
+{
+}
+
+sal_Int32 ScDPFilteredCache::getRowSize() const
+{
+ return mrCache.GetRowCount();
+}
+
+sal_Int32 ScDPFilteredCache::getColSize() const
+{
+ return mrCache.GetColumnCount();
+}
+
+void ScDPFilteredCache::fillTable(
+ const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
+{
+ SCROW nRowCount = getRowSize();
+ SCROW nDataSize = mrCache.GetDataSize();
+ SCCOL nColCount = getColSize();
+ if (nRowCount <= 0 || nColCount <= 0)
+ return;
+
+ maShowByFilter.clear();
+ maShowByPage.clear();
+ maShowByPage.build_tree();
+
+ // Process the non-empty data rows.
+ for (SCROW nRow = 0; nRow < nDataSize; ++nRow)
+ {
+ if (!getCache()->ValidQuery(nRow, rQuery))
+ continue;
+
+ if (bIgnoreEmptyRows && getCache()->IsRowEmpty(nRow))
+ continue;
+
+ maShowByFilter.insert_back(nRow, nRow+1, true);
+ }
+
+ // Process the trailing empty rows.
+ if (!bIgnoreEmptyRows)
+ maShowByFilter.insert_back(nDataSize, nRowCount, true);
+
+ maShowByFilter.build_tree();
+
+ // Initialize field entries container.
+ maFieldEntries.clear();
+ maFieldEntries.reserve(nColCount);
+
+ // Build unique field entries.
+ for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
+ {
+ maFieldEntries.push_back( vector<SCROW>() );
+ SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
+ if (!nMemCount)
+ continue;
+
+ std::vector<SCROW> aAdded(nMemCount, -1);
+ bool bShow = false;
+ SCROW nEndSegment = -1;
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
+ {
+ if (nRow > nEndSegment)
+ {
+ if (!maShowByFilter.search_tree(nRow, bShow, NULL, &nEndSegment))
+ {
+ OSL_FAIL("Tree search failed!");
+ continue;
+ }
+ --nEndSegment; // End position is not inclusive. Move back one.
+ }
+
+ if (!bShow)
+ {
+ nRow = nEndSegment;
+ continue;
+ }
+
+ SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
+ SCROW nOrder = getOrder(nCol, nIndex);
+ aAdded[nOrder] = nIndex;
+ }
+ for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
+ {
+ if (aAdded[nRow] != -1)
+ maFieldEntries.back().push_back(aAdded[nRow]);
+ }
+ }
+}
+
+void ScDPFilteredCache::fillTable()
+{
+ SCROW nRowCount = getRowSize();
+ SCCOL nColCount = getColSize();
+ if (nRowCount <= 0 || nColCount <= 0)
+ return;
+
+ maShowByPage.clear();
+ maShowByPage.build_tree();
+
+ maShowByFilter.clear();
+ maShowByFilter.insert_front(0, nRowCount, true);
+ maShowByFilter.build_tree();
+
+ // Initialize field entries container.
+ maFieldEntries.clear();
+ maFieldEntries.reserve(nColCount);
+
+ // Data rows
+ for (SCCOL nCol = 0; nCol < nColCount; ++nCol)
+ {
+ maFieldEntries.push_back( vector<SCROW>() );
+ SCROW nMemCount = getCache()->GetDimMemberCount( nCol );
+ if (!nMemCount)
+ continue;
+
+ std::vector<SCROW> aAdded(nMemCount, -1);
+
+ for (SCROW nRow = 0; nRow < nRowCount; ++nRow)
+ {
+ SCROW nIndex = getCache()->GetItemDataId(nCol, nRow, false);
+ SCROW nOrder = getOrder(nCol, nIndex);
+ aAdded[nOrder] = nIndex;
+ }
+ for (SCROW nRow = 0; nRow < nMemCount; ++nRow)
+ {
+ if (aAdded[nRow] != -1)
+ maFieldEntries.back().push_back(aAdded[nRow]);
+ }
+ }
+}
+
+bool ScDPFilteredCache::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
+{
+ bool bFilter = false, bPage = true;
+ SCROW nLastRowFilter = MAXROW, nLastRowPage = MAXROW;
+ maShowByFilter.search_tree(nRow, bFilter, NULL, &nLastRowFilter);
+ maShowByPage.search_tree(nRow, bPage, NULL, &nLastRowPage);
+ if (pLastRow)
+ {
+ // Return the last row of current segment.
+ *pLastRow = nLastRowFilter < nLastRowPage ? nLastRowFilter : nLastRowPage;
+ *pLastRow -= 1; // End position is not inclusive. Move back one.
+ }
+
+ return bFilter && bPage;
+}
+
+void ScDPFilteredCache::filterByPageDimension(const vector<Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
+{
+ SCROW nRowSize = getRowSize();
+
+ maShowByPage.clear();
+ for (SCROW nRow = 0; nRow < nRowSize; ++nRow)
+ {
+ bool bShow = isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims);
+ maShowByPage.insert_back(nRow, nRow+1, bShow);
+ }
+
+ maShowByPage.build_tree();
+}
+
+const ScDPItemData* ScDPFilteredCache::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+{
+ SCROW nId= mrCache.GetItemDataId(nCol, nRow, bRepeatIfEmpty);
+ return mrCache.GetItemDataById( nCol, nId );
+}
+
+void ScDPFilteredCache::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+{
+ const ScDPItemData* pData = getCell( nCol, nRow, bRepeatIfEmpty );
+
+ if (pData)
+ {
+ rVal.fValue = pData->IsValue() ? pData->GetValue() : 0.0;
+ rVal.nType = pData->GetCellType();
+ }
+ else
+ rVal.Set(0.0, SC_VALTYPE_EMPTY);
+}
+
+rtl::OUString ScDPFilteredCache::getFieldName(SCCOL nIndex) const
+{
+ return mrCache.GetDimensionName(nIndex);
+}
+
+const ::std::vector<SCROW>& ScDPFilteredCache::getFieldEntries( sal_Int32 nColumn ) const
+{
+ if (nColumn < 0 || static_cast<size_t>(nColumn) >= maFieldEntries.size())
+ {
+ // index out of bound. Hopefully this code will never be reached.
+ static const ::std::vector<SCROW> emptyEntries;
+ return emptyEntries;
+ }
+ return maFieldEntries[nColumn];
+}
+
+void ScDPFilteredCache::filterTable(const vector<Criterion>& rCriteria, Sequence< Sequence<Any> >& rTabData,
+ const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
+{
+ sal_Int32 nRowSize = getRowSize();
+ sal_Int32 nColSize = getColSize();
+
+ if (!nRowSize)
+ // no data to filter.
+ return;
+
+ // Row first, then column.
+ vector< Sequence<Any> > tableData;
+ tableData.reserve(nRowSize+1);
+
+ // Header first.
+ Sequence<Any> headerRow(nColSize);
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
+ {
+ OUString str;
+ str = getFieldName( nCol);
+ Any any;
+ any <<= str;
+ headerRow[nCol] = any;
+ }
+ tableData.push_back(headerRow);
+
+ for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
+ {
+ sal_Int32 nLastRow;
+ if (!isRowActive(nRow, &nLastRow))
+ {
+ // This row is filtered out.
+ nRow = nLastRow;
+ continue;
+ }
+
+ if (!isRowQualified(nRow, rCriteria, rRepeatIfEmptyDims))
+ continue;
+
+ // Insert this row into table.
+
+ Sequence<Any> row(nColSize);
+ for (SCCOL nCol = 0; nCol < nColSize; ++nCol)
+ {
+ Any any;
+ bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(nCol) > 0;
+ const ScDPItemData* pData= getCell(nCol, nRow, bRepeatIfEmpty);
+ if ( pData->IsValue() )
+ any <<= pData->GetValue();
+ else
+ {
+ OUString string (pData->GetString() );
+ any <<= string;
+ }
+ row[nCol] = any;
+ }
+ tableData.push_back(row);
+ }
+
+ // convert vector to Seqeunce
+ sal_Int32 nTabSize = static_cast<sal_Int32>(tableData.size());
+ rTabData.realloc(nTabSize);
+ for (sal_Int32 i = 0; i < nTabSize; ++i)
+ rTabData[i] = tableData[i];
+}
+
+SCROW ScDPFilteredCache::getOrder(long nDim, SCROW nIndex) const
+{
+ return mrCache.GetOrder(nDim, nIndex);
+}
+
+void ScDPFilteredCache::clear()
+{
+ maFieldEntries.clear();
+ maShowByFilter.clear();
+ maShowByPage.clear();
+}
+
+bool ScDPFilteredCache::empty() const
+{
+ return maFieldEntries.empty();
+}
+
+bool ScDPFilteredCache::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
+ const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const
+{
+ sal_Int32 nColSize = getColSize();
+ vector<Criterion>::const_iterator itrEnd = rCriteria.end();
+ for (vector<Criterion>::const_iterator itr = rCriteria.begin(); itr != itrEnd; ++itr)
+ {
+ if (itr->mnFieldIndex >= nColSize)
+ // specified field is outside the source data columns. Don't
+ // use this criterion.
+ continue;
+
+ // Check if the 'repeat if empty' flag is set for this field.
+ bool bRepeatIfEmpty = rRepeatIfEmptyDims.count(itr->mnFieldIndex) > 0;
+ const ScDPItemData* pCellData = getCell(static_cast<SCCOL>(itr->mnFieldIndex), nRow, bRepeatIfEmpty);
+ if (!itr->mpFilter->match(*pCellData))
+ return false;
+ }
+ return true;
+}
+
+const ScDPCache* ScDPFilteredCache::getCache() const
+{
+ return &mrCache;
+}
+
+#if DEBUG_PIVOT_TABLE
+#include <iostream>
+using std::cout;
+using std::endl;
+
+void ScDPFilteredCache::dumpRowFlag(const RowFlagType& rFlag) const
+{
+ RowFlagType::const_iterator it = rFlag.begin(), itEnd = rFlag.end();
+ bool bShow = it->second;
+ SCROW nRow1 = it->first;
+ for (++it; it != itEnd; ++it)
+ {
+ SCROW nRow2 = it->first;
+ cout << " * range " << nRow1 << "-" << nRow2 << ": " << (bShow ? "on" : "off") << endl;
+ bShow = it->second;
+ nRow1 = nRow2;
+ }
+}
+
+void ScDPFilteredCache::dump() const
+{
+ cout << "--- pivot cache filter dump" << endl;
+
+ cout << endl;
+ cout << "* show by filter" << endl;
+ dumpRowFlag(maShowByFilter);
+
+ cout << endl;
+ cout << "* show by page dimensions" << endl;
+ dumpRowFlag(maShowByPage);
+
+ cout << "---" << endl;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 0eb4622..7ef663a 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -30,7 +30,7 @@
#include "global.hxx"
#include "document.hxx"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include "dptabsrc.hxx"
#include "dptabres.hxx"
#include "dpobject.hxx"
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 2abe79f..0e4f112 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -36,7 +36,7 @@
#include "dpoutput.hxx"
#include "dptabsrc.hxx"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include "document.hxx"
#include "patattr.hxx"
#include "docpool.hxx"
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index 9b877ee..a75e394 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -29,7 +29,7 @@
#include "dpsdbtab.hxx"
#include "global.hxx"
#include "globstr.hrc"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include "dptabres.hxx"
#include "document.hxx"
#include "dpobject.hxx"
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 6b6569c..ef46b2c 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -32,7 +32,7 @@
#include "dptabres.hxx"
#include "document.hxx"
#include "cell.hxx"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include "dpobject.hxx"
#include "globstr.hrc"
#include "rangenam.hxx"
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index 79030b8..3bf76db 100644
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -29,7 +29,7 @@
#include "dptabdat.hxx"
#include "global.hxx"
-#include "dpcachetable.hxx"
+#include "dpfilteredcache.hxx"
#include "dptabres.hxx"
#include "document.hxx"
#include "dpobject.hxx"
commit 2a2a2c42814a2b3d00c85f7ba48fcc0f9f04a111
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Oct 31 21:56:19 2012 -0400
Rename ScDPCacheTable to ScDPFilteredCache.
I always wanted to do this. The new name reflects what it really does
better than the old one.
Change-Id: I3c90cce06d482f1453936ff3916eef9663bb417b
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 7fb6c64..f72bbdf 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -49,12 +49,10 @@ struct ScDPValueData;
struct ScQueryParam;
/**
- * Despite the name, this class is only a wrapper to the actual cache, to
- * provide filtering on the raw data based on the query filter and/or page
- * field filters. I will rename this class to a more appropriate name in the
- * future.
+ * This class is only a wrapper to the actual cache, to provide filtering on
+ * the raw data based on the query filter and/or page field filters.
*/
-class SC_DLLPUBLIC ScDPCacheTable
+class SC_DLLPUBLIC ScDPFilteredCache
{
typedef mdds::flat_segment_tree<SCROW, bool> RowFlagType;
@@ -109,8 +107,8 @@ public:
Criterion();
};
- ScDPCacheTable(const ScDPCache& rCache);
- ~ScDPCacheTable();
+ ScDPFilteredCache(const ScDPCache& rCache);
+ ~ScDPFilteredCache();
sal_Int32 getRowSize() const;
sal_Int32 getColSize() const;
@@ -159,8 +157,8 @@ public:
#endif
private:
- ScDPCacheTable();
- ScDPCacheTable(const ScDPCacheTable&);
+ ScDPFilteredCache();
+ ScDPFilteredCache(const ScDPFilteredCache&);
/**
* Check if a given row meets all specified criteria.
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index afa3933..1fb4aec 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -57,7 +57,7 @@ public:
bool HasElement( const ScDPItemData& rData ) const;
bool HasCommonElement( const ScDPGroupItem& rOther ) const;
- void FillGroupFilter( ScDPCacheTable::GroupFilter& rFilter ) const;
+ void FillGroupFilter( ScDPFilteredCache::GroupFilter& rFilter ) const;
};
typedef ::std::vector<ScDPGroupItem> ScDPGroupItemVec;
@@ -84,7 +84,7 @@ public:
long GetGroupDim() const { return nGroupDim; }
const rtl::OUString& GetName() const { return aGroupName; }
- const std::vector< SCROW >& GetColumnEntries( const ScDPCacheTable& rCacheTable ) const;
+ const std::vector< SCROW >& GetColumnEntries( const ScDPFilteredCache& rCacheTable ) const;
const ScDPGroupItem* GetGroupForData( const ScDPItemData& rData ) const; // rData = entry in original dim.
const ScDPGroupItem* GetGroupForName( const ScDPItemData& rName ) const; // rName = entry in group dim.
const ScDPGroupItem* GetGroupByIndex( size_t nIndex ) const;
@@ -145,7 +145,7 @@ class ScDPGroupTableData : public ScDPTableData
bool IsNumGroupDimension( long nDimension ) const;
void GetNumGroupInfo(long nDimension, ScDPNumGroupInfo& rInfo);
- void ModifyFilterCriteria(::std::vector<ScDPCacheTable::Criterion>& rCriteria);
+ void ModifyFilterCriteria(::std::vector<ScDPFilteredCache::Criterion>& rCriteria);
public:
// takes ownership of pSource
@@ -176,12 +176,12 @@ public:
virtual bool IsRepeatIfEmpty();
virtual void CreateCacheTable();
- virtual void FilterCacheTable(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims);
- virtual void GetDrillDownData(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria,
+ virtual void FilterCacheTable(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims);
+ virtual void GetDrillDownData(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria,
const ::boost::unordered_set<sal_Int32>& rCatDims,
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rData);
virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow);
- virtual const ScDPCacheTable& GetCacheTable() const;
+ virtual const ScDPFilteredCache& GetCacheTable() const;
virtual void ReloadCacheTable();
virtual sal_Bool IsBaseForGroup(long nDim) const;
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index 87e6df6..c1a0fc9 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -36,7 +36,7 @@
#include <vector>
#include <boost/unordered_set.hpp>
-class ScDPCacheTable;
+class ScDPFilteredCache;
class ScDocument;
class ScDPCache;
class ScDPDimensionSaveData;
@@ -68,7 +68,7 @@ struct ScImportSourceDesc
class ScDatabaseDPData : public ScDPTableData
{
private:
- ScDPCacheTable aCacheTable;
+ ScDPFilteredCache aCacheTable;
public:
ScDatabaseDPData(ScDocument* pDoc, const ScDPCache& rCache);
virtual ~ScDatabaseDPData();
@@ -81,12 +81,12 @@ public:
virtual void SetEmptyFlags( sal_Bool bIgnoreEmptyRows, sal_Bool bRepeatIfEmpty );
virtual void CreateCacheTable();
- virtual void FilterCacheTable(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims);
- virtual void GetDrillDownData(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria,
+ virtual void FilterCacheTable(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims);
+ virtual void GetDrillDownData(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria,
const ::boost::unordered_set<sal_Int32>& rCatDims,
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rData);
virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow);
- virtual const ScDPCacheTable& GetCacheTable() const;
+ virtual const ScDPFilteredCache& GetCacheTable() const;
virtual void ReloadCacheTable();
};
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 633207a..9e1e0d4 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -104,7 +104,7 @@ private:
bool bIgnoreEmptyRows;
bool bRepeatIfEmpty;
- ScDPCacheTable aCacheTable;
+ ScDPFilteredCache aCacheTable;
public:
ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache& rCache);
@@ -121,12 +121,12 @@ public:
virtual bool IsRepeatIfEmpty();
virtual void CreateCacheTable();
- virtual void FilterCacheTable(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rCatDims);
- virtual void GetDrillDownData(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria,
+ virtual void FilterCacheTable(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rCatDims);
+ virtual void GetDrillDownData(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria,
const ::boost::unordered_set<sal_Int32>& rCatDims,
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rData);
virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow);
- virtual const ScDPCacheTable& GetCacheTable() const;
+ virtual const ScDPFilteredCache& GetCacheTable() const;
virtual void ReloadCacheTable();
};
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 16b8ef3..26ada0e 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -148,12 +148,12 @@ public:
virtual bool IsRepeatIfEmpty();
virtual void CreateCacheTable() = 0;
- virtual void FilterCacheTable(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims) = 0;
- virtual void GetDrillDownData(const ::std::vector<ScDPCacheTable::Criterion>& rCriteria,
+ virtual void FilterCacheTable(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria, const ::boost::unordered_set<sal_Int32>& rDataDims) = 0;
+ virtual void GetDrillDownData(const ::std::vector<ScDPFilteredCache::Criterion>& rCriteria,
const ::boost::unordered_set<sal_Int32>& rCatDims,
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > >& rData) = 0;
virtual void CalcResults(CalcInfo& rInfo, bool bAutoShow) = 0;
- virtual const ScDPCacheTable& GetCacheTable() const = 0;
+ virtual const ScDPFilteredCache& GetCacheTable() const = 0;
virtual void ReloadCacheTable() = 0;
// overloaded in ScDPGroupTableData:
@@ -187,12 +187,12 @@ protected:
::std::vector<ScDPValueData> aValues;
};
- void FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTable& rCacheTable, const CalcInfo& rInfo, CalcRowData& rData);
+ void FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPFilteredCache& rCacheTable, const CalcInfo& rInfo, CalcRowData& rData);
void ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAutoShow);
- void CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable, CalcInfo& rInfo, bool bAutoShow);
+ void CalcResultsFromCacheTable(const ScDPFilteredCache& rCacheTable, CalcInfo& rInfo, bool bAutoShow);
private:
- void GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
+ void GetItemData(const ScDPFilteredCache& rCacheTable, sal_Int32 nRow,
const ::std::vector<long>& rDims, ::std::vector< SCROW >& rItemData);
};
#endif
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index 48a62b7..e5a939a 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -656,7 +656,7 @@ public:
~ScDPResultVisibilityData();
void addVisibleMember(const String& rDimName, const ScDPItemData& rMemberItem);
- void fillFieldFilters(::std::vector<ScDPCacheTable::Criterion>& rFilters) const;
+ void fillFieldFilters(::std::vector<ScDPFilteredCache::Criterion>& rFilters) const;
private:
struct MemberHash
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index 9fced30..c3ec63e 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -152,7 +152,7 @@ private:
* Set visibilities of individual rows in the cache table based on the
* page field data.
*/
- void FilterCacheTableByPageDimensions();
+ void FilterCacheByPageDimensions();
void SetDupCount( long nNew );
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 6a648a9..1da99f6 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -64,24 +64,24 @@ using ::com::sun::star::uno::UNO_QUERY;
using ::com::sun::star::uno::UNO_QUERY_THROW;
using ::com::sun::star::sheet::DataPilotFieldFilter;
-ScDPCacheTable::SingleFilter::SingleFilter(const ScDPItemData& rItem) :
+ScDPFilteredCache::SingleFilter::SingleFilter(const ScDPItemData& rItem) :
maItem(rItem) {}
-bool ScDPCacheTable::SingleFilter::match(const ScDPItemData& rCellData) const
+bool ScDPFilteredCache::SingleFilter::match(const ScDPItemData& rCellData) const
{
return maItem == rCellData;
}
-const ScDPItemData& ScDPCacheTable::SingleFilter::getMatchValue() const
+const ScDPItemData& ScDPFilteredCache::SingleFilter::getMatchValue() const
{
return maItem;
}
-ScDPCacheTable::GroupFilter::GroupFilter()
+ScDPFilteredCache::GroupFilter::GroupFilter()
{
}
-bool ScDPCacheTable::GroupFilter::match(const ScDPItemData& rCellData) const
+bool ScDPFilteredCache::GroupFilter::match(const ScDPItemData& rCellData) const
{
vector<ScDPItemData>::const_iterator it = maItems.begin(), itEnd = maItems.end();
for (; it != itEnd; ++it)
@@ -93,19 +93,19 @@ bool ScDPCacheTable::GroupFilter::match(const ScDPItemData& rCellData) const
return false;
}
-void ScDPCacheTable::GroupFilter::addMatchItem(const ScDPItemData& rItem)
+void ScDPFilteredCache::GroupFilter::addMatchItem(const ScDPItemData& rItem)
{
maItems.push_back(rItem);
}
-size_t ScDPCacheTable::GroupFilter::getMatchItemCount() const
+size_t ScDPFilteredCache::GroupFilter::getMatchItemCount() const
{
return maItems.size();
}
// ----------------------------------------------------------------------------
-ScDPCacheTable::Criterion::Criterion() :
+ScDPFilteredCache::Criterion::Criterion() :
mnFieldIndex(-1),
mpFilter(static_cast<FilterBase*>(NULL))
{
@@ -113,26 +113,26 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
-ScDPCacheTable::ScDPCacheTable(const ScDPCache& rCache) :
+ScDPFilteredCache::ScDPFilteredCache(const ScDPCache& rCache) :
maShowByFilter(0, MAXROW+1, false), maShowByPage(0, MAXROW+1, true), mrCache(rCache)
{
}
-ScDPCacheTable::~ScDPCacheTable()
+ScDPFilteredCache::~ScDPFilteredCache()
{
}
-sal_Int32 ScDPCacheTable::getRowSize() const
+sal_Int32 ScDPFilteredCache::getRowSize() const
{
return mrCache.GetRowCount();
}
-sal_Int32 ScDPCacheTable::getColSize() const
+sal_Int32 ScDPFilteredCache::getColSize() const
{
return mrCache.GetColumnCount();
}
-void ScDPCacheTable::fillTable(
+void ScDPFilteredCache::fillTable(
const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
{
SCROW nRowCount = getRowSize();
@@ -208,7 +208,7 @@ void ScDPCacheTable::fillTable(
}
}
-void ScDPCacheTable::fillTable()
+void ScDPFilteredCache::fillTable()
{
SCROW nRowCount = getRowSize();
SCCOL nColCount = getColSize();
@@ -250,7 +250,7 @@ void ScDPCacheTable::fillTable()
}
}
-bool ScDPCacheTable::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
+bool ScDPFilteredCache::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
{
bool bFilter = false, bPage = true;
SCROW nLastRowFilter = MAXROW, nLastRowPage = MAXROW;
@@ -266,7 +266,7 @@ bool ScDPCacheTable::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
return bFilter && bPage;
}
-void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
+void ScDPFilteredCache::filterByPageDimension(const vector<Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
{
SCROW nRowSize = getRowSize();
@@ -280,13 +280,13 @@ void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, c
maShowByPage.build_tree();
}
-const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+const ScDPItemData* ScDPFilteredCache::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
{
SCROW nId= mrCache.GetItemDataId(nCol, nRow, bRepeatIfEmpty);
return mrCache.GetItemDataById( nCol, nId );
}
-void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
+void ScDPFilteredCache::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
{
const ScDPItemData* pData = getCell( nCol, nRow, bRepeatIfEmpty );
@@ -299,12 +299,12 @@ void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, boo
rVal.Set(0.0, SC_VALTYPE_EMPTY);
}
-rtl::OUString ScDPCacheTable::getFieldName(SCCOL nIndex) const
+rtl::OUString ScDPFilteredCache::getFieldName(SCCOL nIndex) const
{
return mrCache.GetDimensionName(nIndex);
}
-const ::std::vector<SCROW>& ScDPCacheTable::getFieldEntries( sal_Int32 nColumn ) const
+const ::std::vector<SCROW>& ScDPFilteredCache::getFieldEntries( sal_Int32 nColumn ) const
{
if (nColumn < 0 || static_cast<size_t>(nColumn) >= maFieldEntries.size())
{
@@ -315,7 +315,7 @@ const ::std::vector<SCROW>& ScDPCacheTable::getFieldEntries( sal_Int32 nColumn
return maFieldEntries[nColumn];
}
-void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< Sequence<Any> >& rTabData,
+void ScDPFilteredCache::filterTable(const vector<Criterion>& rCriteria, Sequence< Sequence<Any> >& rTabData,
const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims)
{
sal_Int32 nRowSize = getRowSize();
@@ -381,24 +381,24 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
rTabData[i] = tableData[i];
}
-SCROW ScDPCacheTable::getOrder(long nDim, SCROW nIndex) const
+SCROW ScDPFilteredCache::getOrder(long nDim, SCROW nIndex) const
{
return mrCache.GetOrder(nDim, nIndex);
}
-void ScDPCacheTable::clear()
+void ScDPFilteredCache::clear()
{
maFieldEntries.clear();
maShowByFilter.clear();
maShowByPage.clear();
}
-bool ScDPCacheTable::empty() const
+bool ScDPFilteredCache::empty() const
{
return maFieldEntries.empty();
}
-bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
+bool ScDPFilteredCache::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const
{
sal_Int32 nColSize = getColSize();
@@ -419,7 +419,7 @@ bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCr
return true;
}
-const ScDPCache* ScDPCacheTable::getCache() const
+const ScDPCache* ScDPFilteredCache::getCache() const
{
return &mrCache;
}
@@ -429,7 +429,7 @@ const ScDPCache* ScDPCacheTable::getCache() const
using std::cout;
using std::endl;
-void ScDPCacheTable::dumpRowFlag(const RowFlagType& rFlag) const
+void ScDPFilteredCache::dumpRowFlag(const RowFlagType& rFlag) const
{
RowFlagType::const_iterator it = rFlag.begin(), itEnd = rFlag.end();
bool bShow = it->second;
@@ -443,7 +443,7 @@ void ScDPCacheTable::dumpRowFlag(const RowFlagType& rFlag) const
}
}
-void ScDPCacheTable::dump() const
+void ScDPFilteredCache::dump() const
{
cout << "--- pivot cache filter dump" << endl;
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index aba2785..0eb4622 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -63,7 +63,7 @@ using ::boost::shared_ptr;
const sal_uInt16 SC_DP_LEAPYEAR = 1648; // arbitrary leap year for date calculations
-class ScDPGroupNumFilter : public ScDPCacheTable::FilterBase
+class ScDPGroupNumFilter : public ScDPFilteredCache::FilterBase
{
public:
ScDPGroupNumFilter(const ScDPItemData& rValue, const ScDPNumGroupInfo& rInfo);
@@ -103,7 +103,7 @@ bool ScDPGroupNumFilter::match(const ScDPItemData& rCellData) const
return low <= rCellData.GetValue() && rCellData.GetValue() < high;
}
-class ScDPGroupDateFilter : public ScDPCacheTable::FilterBase
+class ScDPGroupDateFilter : public ScDPFilteredCache::FilterBase
{
public:
virtual ~ScDPGroupDateFilter() {}
@@ -309,7 +309,7 @@ bool ScDPGroupItem::HasCommonElement( const ScDPGroupItem& rOther ) const
return false;
}
-void ScDPGroupItem::FillGroupFilter( ScDPCacheTable::GroupFilter& rFilter ) const
+void ScDPGroupItem::FillGroupFilter( ScDPFilteredCache::GroupFilter& rFilter ) const
{
ScDPItemDataVec::const_iterator itrEnd = aElements.end();
for (ScDPItemDataVec::const_iterator itr = aElements.begin(); itr != itrEnd; ++itr)
@@ -361,7 +361,7 @@ void ScDPGroupDimension::SetGroupDim( long nDim )
}
const std::vector<SCROW>& ScDPGroupDimension::GetColumnEntries(
- const ScDPCacheTable& rCacheTable) const
+ const ScDPFilteredCache& rCacheTable) const
{
if (!maMemberEntries.empty())
return maMemberEntries;
@@ -628,7 +628,7 @@ void ScDPGroupTableData::CreateCacheTable()
pSourceData->CreateCacheTable();
}
-void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>& rCriteria)
+void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPFilteredCache::Criterion>& rCriteria)
{
typedef boost::unordered_map<long, const ScDPGroupDimension*> GroupFieldMapType;
GroupFieldMapType aGroupFieldIds;
@@ -638,17 +638,17 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
aGroupFieldIds.insert( boost::unordered_map<long, const ScDPGroupDimension*>::value_type(itr->GetGroupDim(), &(*itr)) );
}
- vector<ScDPCacheTable::Criterion> aNewCriteria;
+ vector<ScDPFilteredCache::Criterion> aNewCriteria;
aNewCriteria.reserve(rCriteria.size() + aGroups.size());
// Go through all the filtered field names and process them appropriately.
const ScDPCache* pCache = GetCacheTable().getCache();
- vector<ScDPCacheTable::Criterion>::const_iterator itrEnd = rCriteria.end();
+ vector<ScDPFilteredCache::Criterion>::const_iterator itrEnd = rCriteria.end();
GroupFieldMapType::const_iterator itrGrpEnd = aGroupFieldIds.end();
- for (vector<ScDPCacheTable::Criterion>::const_iterator itr = rCriteria.begin(); itr != itrEnd; ++itr)
+ for (vector<ScDPFilteredCache::Criterion>::const_iterator itr = rCriteria.begin(); itr != itrEnd; ++itr)
{
- ScDPCacheTable::SingleFilter* pFilter = dynamic_cast<ScDPCacheTable::SingleFilter*>(itr->mpFilter.get());
+ ScDPFilteredCache::SingleFilter* pFilter = dynamic_cast<ScDPFilteredCache::SingleFilter*>(itr->mpFilter.get());
if (!pFilter)
// We expect this to be a single filter.
continue;
@@ -659,7 +659,7 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
if (IsNumGroupDimension(itr->mnFieldIndex))
{
// internal number group field
- ScDPCacheTable::Criterion aCri;
+ ScDPFilteredCache::Criterion aCri;
aCri.mnFieldIndex = itr->mnFieldIndex;
const ScDPNumGroupDimension& rNumGrpDim = pNumGroups[itr->mnFieldIndex];
const ScDPNumGroupInfo* pNumInfo = pCache->GetNumGroupInfo(itr->mnFieldIndex);
@@ -701,7 +701,7 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
if (pGrpDim->IsDateDimension() && pNumInfo)
{
// external number group
- ScDPCacheTable::Criterion aCri;
+ ScDPFilteredCache::Criterion aCri;
aCri.mnFieldIndex = nSrcDim; // use the source dimension, not the group dimension.
aCri.mpFilter.reset(
new ScDPGroupDateFilter(
@@ -723,11 +723,11 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
if (!pGrpItem || !pGrpItem->GetName().IsCaseInsEqual(aName))
continue;
- ScDPCacheTable::Criterion aCri;
+ ScDPFilteredCache::Criterion aCri;
aCri.mnFieldIndex = nSrcDim;
- aCri.mpFilter.reset(new ScDPCacheTable::GroupFilter());
- ScDPCacheTable::GroupFilter* pGrpFilter =
- static_cast<ScDPCacheTable::GroupFilter*>(aCri.mpFilter.get());
+ aCri.mpFilter.reset(new ScDPFilteredCache::GroupFilter());
+ ScDPFilteredCache::GroupFilter* pGrpFilter =
+ static_cast<ScDPFilteredCache::GroupFilter*>(aCri.mpFilter.get());
pGrpItem->FillGroupFilter(*pGrpFilter);
aNewCriteria.push_back(aCri);
@@ -738,16 +738,16 @@ void ScDPGroupTableData::ModifyFilterCriteria(vector<ScDPCacheTable::Criterion>&
rCriteria.swap(aNewCriteria);
}
-void ScDPGroupTableData::FilterCacheTable(const vector<ScDPCacheTable::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
+void ScDPGroupTableData::FilterCacheTable(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
{
- vector<ScDPCacheTable::Criterion> aNewCriteria(rCriteria);
+ vector<ScDPFilteredCache::Criterion> aNewCriteria(rCriteria);
ModifyFilterCriteria(aNewCriteria);
pSourceData->FilterCacheTable(aNewCriteria, rCatDims);
}
-void ScDPGroupTableData::GetDrillDownData(const vector<ScDPCacheTable::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
+void ScDPGroupTableData::GetDrillDownData(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
{
- vector<ScDPCacheTable::Criterion> aNewCriteria(rCriteria);
+ vector<ScDPFilteredCache::Criterion> aNewCriteria(rCriteria);
ModifyFilterCriteria(aNewCriteria);
pSourceData->GetDrillDownData(aNewCriteria, rCatDims, rData);
}
@@ -758,7 +758,7 @@ void ScDPGroupTableData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
// getIsDataLayoutDimension and GetSourceDim are used, so it has to be called
// with original rInfo, containing dimension indexes of the grouped data.
- const ScDPCacheTable& rCacheTable = pSourceData->GetCacheTable();
+ const ScDPFilteredCache& rCacheTable = pSourceData->GetCacheTable();
sal_Int32 nRowSize = rCacheTable.getRowSize();
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
{
@@ -783,7 +783,7 @@ void ScDPGroupTableData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
}
}
-const ScDPCacheTable& ScDPGroupTableData::GetCacheTable() const
+const ScDPFilteredCache& ScDPGroupTableData::GetCacheTable() const
{
return pSourceData->GetCacheTable();
}
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index 696f74d..9b877ee 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -134,14 +134,14 @@ void ScDatabaseDPData::CreateCacheTable()
aCacheTable.fillTable();
}
-void ScDatabaseDPData::FilterCacheTable(const vector<ScDPCacheTable::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
+void ScDatabaseDPData::FilterCacheTable(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
{
CreateCacheTable();
aCacheTable.filterByPageDimension(
rCriteria, (IsRepeatIfEmpty() ? rCatDims : boost::unordered_set<sal_Int32>()));
}
-void ScDatabaseDPData::GetDrillDownData(const vector<ScDPCacheTable::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
+void ScDatabaseDPData::GetDrillDownData(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
{
CreateCacheTable();
sal_Int32 nRowSize = aCacheTable.getRowSize();
@@ -158,7 +158,7 @@ void ScDatabaseDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
CalcResultsFromCacheTable( aCacheTable, rInfo, bAutoShow);
}
-const ScDPCacheTable& ScDatabaseDPData::GetCacheTable() const
+const ScDPFilteredCache& ScDatabaseDPData::GetCacheTable() const
{
return aCacheTable;
}
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 15ea27c..6b6569c 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -185,14 +185,14 @@ void ScSheetDPData::CreateCacheTable()
aCacheTable.fillTable(aQuery, bIgnoreEmptyRows, bRepeatIfEmpty);
}
-void ScSheetDPData::FilterCacheTable(const vector<ScDPCacheTable::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
+void ScSheetDPData::FilterCacheTable(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims)
{
CreateCacheTable();
aCacheTable.filterByPageDimension(
rCriteria, (IsRepeatIfEmpty() ? rCatDims : boost::unordered_set<sal_Int32>()));
}
-void ScSheetDPData::GetDrillDownData(const vector<ScDPCacheTable::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
+void ScSheetDPData::GetDrillDownData(const vector<ScDPFilteredCache::Criterion>& rCriteria, const boost::unordered_set<sal_Int32>& rCatDims, Sequence< Sequence<Any> >& rData)
{
CreateCacheTable();
sal_Int32 nRowSize = aCacheTable.getRowSize();
@@ -209,7 +209,7 @@ void ScSheetDPData::CalcResults(CalcInfo& rInfo, bool bAutoShow)
CalcResultsFromCacheTable(aCacheTable, rInfo, bAutoShow);
}
-const ScDPCacheTable& ScSheetDPData::GetCacheTable() const
+const ScDPFilteredCache& ScSheetDPData::GetCacheTable() const
{
return aCacheTable;
}
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index f150d8d..79030b8 100644
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -157,7 +157,7 @@ sal_Bool ScDPTableData::HasCommonElement( const ScDPItemData&, long,
OSL_FAIL("HasCommonElement shouldn't be called for non-group data");
return false;
}
-void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPCacheTable& rCacheTable,
+void ScDPTableData::FillRowDataFromCacheTable(sal_Int32 nRow, const ScDPFilteredCache& rCacheTable,
const CalcInfo& rInfo, CalcRowData& rData)
{
// column dimensions
@@ -216,7 +216,7 @@ void ScDPTableData::ProcessRowData(CalcInfo& rInfo, CalcRowData& rData, bool bAu
}
}
-void ScDPTableData::CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable, CalcInfo& rInfo, bool bAutoShow)
+void ScDPTableData::CalcResultsFromCacheTable(const ScDPFilteredCache& rCacheTable, CalcInfo& rInfo, bool bAutoShow)
{
sal_Int32 nRowSize = rCacheTable.getRowSize();
for (sal_Int32 nRow = 0; nRow < nRowSize; ++nRow)
@@ -234,7 +234,7 @@ void ScDPTableData::CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable,
}
}
-void ScDPTableData::GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
+void ScDPTableData::GetItemData(const ScDPFilteredCache& rCacheTable, sal_Int32 nRow,
const vector<long>& rDims, vector<SCROW>& rItemData)
{
sal_Int32 nDimSize = rDims.size();
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 3b34126..b4dfa96 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -3849,7 +3849,7 @@ void ScDPResultVisibilityData::addVisibleMember(const String& rDimName, const Sc
rMem.insert(rMemberItem);
}
-void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPCacheTable::Criterion>& rFilters) const
+void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPFilteredCache::Criterion>& rFilters) const
{
typedef boost::unordered_map<String, long, ScStringHashCode> FieldNameMapType;
FieldNameMapType aFieldNames;
@@ -3866,7 +3866,7 @@ void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPCacheTable::Criterion
itr != itrEnd; ++itr)
{
const String& rDimName = itr->first;
- ScDPCacheTable::Criterion aCri;
+ ScDPFilteredCache::Criterion aCri;
FieldNameMapType::const_iterator itrField = aFieldNames.find(rDimName);
if (itrField == aFieldNames.end())
// This should never happen!
@@ -3874,10 +3874,10 @@ void ScDPResultVisibilityData::fillFieldFilters(vector<ScDPCacheTable::Criterion
long nDimIndex = itrField->second;
aCri.mnFieldIndex = static_cast<sal_Int32>(nDimIndex);
- aCri.mpFilter.reset(new ScDPCacheTable::GroupFilter(/*mrSharedString*/));
+ aCri.mpFilter.reset(new ScDPFilteredCache::GroupFilter(/*mrSharedString*/));
- ScDPCacheTable::GroupFilter* pGrpFilter =
- static_cast<ScDPCacheTable::GroupFilter*>(aCri.mpFilter.get());
+ ScDPFilteredCache::GroupFilter* pGrpFilter =
+ static_cast<ScDPFilteredCache::GroupFilter*>(aCri.mpFilter.get());
const VisibleMemberType& rMem = itr->second;
for (VisibleMemberType::const_iterator itrMem = rMem.begin(), itrMemEnd = rMem.end();
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index c3c1214..ba904cb 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -431,7 +431,7 @@ Sequence< Sequence<Any> > SAL_CALL ScDPSource::getDrillDownData(const Sequence<s
{
long nColumnCount = GetData()->GetColumnCount();
- vector<ScDPCacheTable::Criterion> aFilterCriteria;
+ vector<ScDPFilteredCache::Criterion> aFilterCriteria;
sal_Int32 nFilterCount = aFilters.getLength();
for (sal_Int32 i = 0; i < nFilterCount; ++i)
{
@@ -449,10 +449,10 @@ Sequence< Sequence<Any> > SAL_CALL ScDPSource::getDrillDownData(const Sequence<s
{
ScDPItemData aItem;
pMembers->getByIndex(nIndex)->FillItemData( aItem );
- aFilterCriteria.push_back( ScDPCacheTable::Criterion() );
+ aFilterCriteria.push_back( ScDPFilteredCache::Criterion() );
aFilterCriteria.back().mnFieldIndex = nCol;
aFilterCriteria.back().mpFilter.reset(
- new ScDPCacheTable::SingleFilter(aItem));
+ new ScDPFilteredCache::SingleFilter(aItem));
}
}
}
@@ -678,12 +678,13 @@ void ScDPSource::GetCategoryDimensionIndices(boost::unordered_set<sal_Int32>& rC
rCatDims.swap(aCatDims);
}
-void ScDPSource::FilterCacheTableByPageDimensions()
+void ScDPSource::FilterCacheByPageDimensions()
{
- // #i117661# Repeated calls to ScDPCacheTable::filterByPageDimension are invalid because
- // rows are only hidden, never shown again. If FilterCacheTableByPageDimensions is called
- // again, the cache table must be re-initialized. Currently, CreateRes_Impl always uses
- // a fresh cache because ScDBDocFunc::DataPilotUpdate calls InvalidateData.
+ // #i117661# Repeated calls to ScDPFilteredCache::filterByPageDimension
+ // are invalid because rows are only hidden, never shown again. If
+ // FilterCacheByPageDimensions is called again, the cache table must
+ // be re-initialized. Currently, CreateRes_Impl always uses a fresh cache
+ // because ScDBDocFunc::DataPilotUpdate calls InvalidateData.
if (bPageFiltered)
{
@@ -695,7 +696,7 @@ void ScDPSource::FilterCacheTableByPageDimensions()
}
// filter table by page dimensions.
- vector<ScDPCacheTable::Criterion> aCriteria;
+ vector<ScDPFilteredCache::Criterion> aCriteria;
for (long i = 0; i < nPageDimCount; ++i)
{
ScDPDimension* pDim = GetDimensionsObject()->getByIndex(nPageDims[i]);
@@ -705,11 +706,11 @@ void ScDPSource::FilterCacheTableByPageDimensions()
GetLevelsObject()->getByIndex(0)->GetMembersObject();
long nMemCount = pMems->getCount();
- ScDPCacheTable::Criterion aFilter;
+ ScDPFilteredCache::Criterion aFilter;
aFilter.mnFieldIndex = static_cast<sal_Int32>(nField);
- aFilter.mpFilter.reset(new ScDPCacheTable::GroupFilter(/*rSharedString*/));
- ScDPCacheTable::GroupFilter* pGrpFilter =
- static_cast<ScDPCacheTable::GroupFilter*>(aFilter.mpFilter.get());
+ aFilter.mpFilter.reset(new ScDPFilteredCache::GroupFilter(/*rSharedString*/));
+ ScDPFilteredCache::GroupFilter* pGrpFilter =
+ static_cast<ScDPFilteredCache::GroupFilter*>(aFilter.mpFilter.get());
for (long j = 0; j < nMemCount; ++j)
{
ScDPMember* pMem = pMems->getByIndex(j);
@@ -728,10 +729,10 @@ void ScDPSource::FilterCacheTableByPageDimensions()
continue;
const ScDPItemData& rData = pDim->GetSelectedData();
- aCriteria.push_back(ScDPCacheTable::Criterion());
- ScDPCacheTable::Criterion& r = aCriteria.back();
+ aCriteria.push_back(ScDPFilteredCache::Criterion());
+ ScDPFilteredCache::Criterion& r = aCriteria.back();
r.mnFieldIndex = static_cast<sal_Int32>(nField);
- r.mpFilter.reset(new ScDPCacheTable::SingleFilter(rData));
+ r.mpFilter.reset(new ScDPFilteredCache::SingleFilter(rData));
}
if (!aCriteria.empty())
{
@@ -913,7 +914,7 @@ void ScDPSource::CreateRes_Impl()
return;
}
- FilterCacheTableByPageDimensions();
+ FilterCacheByPageDimensions();
aInfo.aPageDims.reserve(nPageDimCount);
for (i = 0; i < nPageDimCount; ++i)
commit 6a06befd20b01290a61e8157bd72c20eddcd15a0
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Oct 31 21:46:46 2012 -0400
Since the cache there is never NULL, let's take a reference instead.
Change-Id: Idd3ca250ea51c9e17b4566febf13d9c8ca9c6a8f
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 0358e58..7fb6c64 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -109,7 +109,7 @@ public:
Criterion();
};
- ScDPCacheTable(const ScDPCache* pCache);
+ ScDPCacheTable(const ScDPCache& rCache);
~ScDPCacheTable();
sal_Int32 getRowSize() const;
@@ -180,7 +180,7 @@ private:
/** Rows visible by page dimension filtering. */
RowFlagType maShowByPage;
- const ScDPCache* mpCache;
+ const ScDPCache& mrCache;
};
#endif
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index 943bf8d..87e6df6 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -70,7 +70,7 @@ class ScDatabaseDPData : public ScDPTableData
private:
ScDPCacheTable aCacheTable;
public:
- ScDatabaseDPData(ScDocument* pDoc, const ScDPCache* pCache);
+ ScDatabaseDPData(ScDocument* pDoc, const ScDPCache& rCache);
virtual ~ScDatabaseDPData();
virtual long GetColumnCount();
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 0374123..633207a 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -107,7 +107,7 @@ private:
ScDPCacheTable aCacheTable;
public:
- ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache* pCache);
+ ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache& rCache);
virtual ~ScSheetDPData();
virtual long GetColumnCount();
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 9d7e3cb..6a648a9 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -113,8 +113,8 @@ ScDPCacheTable::Criterion::Criterion() :
// ----------------------------------------------------------------------------
-ScDPCacheTable::ScDPCacheTable(const ScDPCache* pCache) :
- maShowByFilter(0, MAXROW+1, false), maShowByPage(0, MAXROW+1, true), mpCache(pCache)
+ScDPCacheTable::ScDPCacheTable(const ScDPCache& rCache) :
+ maShowByFilter(0, MAXROW+1, false), maShowByPage(0, MAXROW+1, true), mrCache(rCache)
{
}
@@ -124,19 +124,19 @@ ScDPCacheTable::~ScDPCacheTable()
sal_Int32 ScDPCacheTable::getRowSize() const
{
- return mpCache ? getCache()->GetRowCount() : 0;
+ return mrCache.GetRowCount();
}
sal_Int32 ScDPCacheTable::getColSize() const
{
- return mpCache ? getCache()->GetColumnCount() : 0;
+ return mrCache.GetColumnCount();
}
void ScDPCacheTable::fillTable(
const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty)
{
SCROW nRowCount = getRowSize();
- SCROW nDataSize = mpCache->GetDataSize();
+ SCROW nDataSize = mrCache.GetDataSize();
SCCOL nColCount = getColSize();
if (nRowCount <= 0 || nColCount <= 0)
return;
@@ -282,11 +282,8 @@ void ScDPCacheTable::filterByPageDimension(const vector<Criterion>& rCriteria, c
const ScDPItemData* ScDPCacheTable::getCell(SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
{
- if (!mpCache)
- return NULL;
-
- SCROW nId= getCache()->GetItemDataId(nCol, nRow, bRepeatIfEmpty);
- return getCache()->GetItemDataById( nCol, nId );
+ SCROW nId= mrCache.GetItemDataId(nCol, nRow, bRepeatIfEmpty);
+ return mrCache.GetItemDataById( nCol, nId );
}
void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, bool bRepeatIfEmpty) const
@@ -304,10 +301,7 @@ void ScDPCacheTable::getValue( ScDPValueData& rVal, SCCOL nCol, SCROW nRow, boo
rtl::OUString ScDPCacheTable::getFieldName(SCCOL nIndex) const
{
- if (!mpCache)
- return rtl::OUString();
-
- return getCache()->GetDimensionName( nIndex );
+ return mrCache.GetDimensionName(nIndex);
}
const ::std::vector<SCROW>& ScDPCacheTable::getFieldEntries( sal_Int32 nColumn ) const
@@ -389,7 +383,7 @@ void ScDPCacheTable::filterTable(const vector<Criterion>& rCriteria, Sequence< S
SCROW ScDPCacheTable::getOrder(long nDim, SCROW nIndex) const
{
- return mpCache->GetOrder(nDim, nIndex);
+ return mrCache.GetOrder(nDim, nIndex);
}
void ScDPCacheTable::clear()
@@ -427,7 +421,7 @@ bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCr
const ScDPCache* ScDPCacheTable::getCache() const
{
- return mpCache;
+ return &mrCache;
}
#if DEBUG_PIVOT_TABLE
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 81888fd..cfd89aa 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -595,7 +595,7 @@ ScDPTableData* ScDPObject::GetTableData()
if (pCache)
{
pCache->AddReference(this);
- pData.reset(new ScDatabaseDPData(pDoc, pCache));
+ pData.reset(new ScDatabaseDPData(pDoc, *pCache));
}
}
else
@@ -616,7 +616,7 @@ ScDPTableData* ScDPObject::GetTableData()
if (pCache)
{
pCache->AddReference(this);
- pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, pCache));
+ pData.reset(new ScSheetDPData(pDoc, *pSheetDesc, *pCache));
}
}
}
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index da9da05..696f74d 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -72,9 +72,9 @@ const ScDPCache* ScImportSourceDesc::CreateCache(const ScDPDimensionSaveData* pD
}
ScDatabaseDPData::ScDatabaseDPData(
- ScDocument* pDoc, const ScDPCache* pCache) :
+ ScDocument* pDoc, const ScDPCache& rCache) :
ScDPTableData(pDoc),
- aCacheTable(pCache)
+ aCacheTable(rCache)
{
}
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 78f7025..15ea27c 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -51,12 +51,12 @@ using ::std::vector;
// -----------------------------------------------------------------------
-ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache* pCache) :
+ScSheetDPData::ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache& rCache) :
ScDPTableData(pD),
aQuery ( rDesc.GetQueryParam() ),
bIgnoreEmptyRows( false ),
bRepeatIfEmpty(false),
- aCacheTable(pCache)
+ aCacheTable(rCache)
{
SCSIZE nEntryCount( aQuery.GetEntryCount());
for (SCSIZE j = 0; j < nEntryCount; ++j)
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index ac0bef9..85e36e5 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -547,7 +547,7 @@ void XclExpPCField::InsertNumDateGroupItems( const ScDPObject& rDPObj, const ScD
if (!pCache)
return;
- ScSheetDPData aDPData(GetDocPtr(), *pSrcDesc, pCache);
+ ScSheetDPData aDPData(GetDocPtr(), *pSrcDesc, *pCache);
long nDim = GetFieldIndex();
const std::vector< SCROW > aOrignial = aDPData.GetColumnEntries(nDim);
// get the string collection with generated grouping elements
commit 8617c5a251ce725aa7c6743be28abd3db116255f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Oct 31 21:34:59 2012 -0400
The cache inside ScDPCacheTable (I should rename this) is never NULL.
There is no point of having hasCache() method which always returns true.
Change-Id: I309d3c33899cdab2049af5199ae8d41f7cbd5f99
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 6f4d151..0358e58 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -152,7 +152,6 @@ public:
SCROW getOrder(long nDim, SCROW nIndex) const;
void clear();
bool empty() const;
- bool hasCache() const;
#if DEBUG_PIVOT_TABLE
void dumpRowFlag(const RowFlagType& rFlag) const;
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index a71a8f2..9d7e3cb 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -404,11 +404,6 @@ bool ScDPCacheTable::empty() const
return maFieldEntries.empty();
}
-bool ScDPCacheTable::hasCache() const
-{
- return mpCache != NULL;
-}
-
bool ScDPCacheTable::isRowQualified(sal_Int32 nRow, const vector<Criterion>& rCriteria,
const boost::unordered_set<sal_Int32>& rRepeatIfEmptyDims) const
{
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index 4cd86ca..da9da05 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -131,14 +131,6 @@ void ScDatabaseDPData::CreateCacheTable()
// cache table already created.
return;
- if (!aCacheTable.hasCache())
- {
- OSL_FAIL("Cache table should be created with a live data cache instance at all times.");
- // This better not happen!! Cache table should be created with a live
- // data cache instance at all times.
- return;
- }
-
aCacheTable.fillTable();
}
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index e2f6801..78f7025 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -182,14 +182,6 @@ void ScSheetDPData::CreateCacheTable()
// already cached.
return;
- if (!aCacheTable.hasCache())
- {
- OSL_FAIL("Cache table should be created with a live data cache instance at all times.");
- // This better not happen!! The cache table should be created with a
- // live data cache at all times.
- return;
- }
-
aCacheTable.fillTable(aQuery, bIgnoreEmptyRows, bRepeatIfEmpty);
}
commit 6c2c355375950e84fd9b8cd0a2d4717ef21ea2e6
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Wed Oct 31 21:26:29 2012 -0400
These comments are no longer correct.
They were correct up until IBM re-worked a whole bunch of stuff during
the OOo 3.2 (?) development cycle.
Change-Id: Ia9a9e30287f6c8451a6cfa98f3515d703e3c67cc
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 84edf6a..6f4d151 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -117,12 +117,8 @@ public:
const ScDPCache* getCache() const;
- /** Fill the internal table from the cell range provided. This function
- assumes that the first row is the column header. */
void fillTable(const ScQueryParam& rQuery, bool bIgnoreEmptyRows, bool bRepeatIfEmpty);
- /** Fill the internal table from database connection object. This function
- assumes that the first row is the column header. */
void fillTable();
/** Check whether a specified row is active or not. When a row is active,
More information about the Libreoffice-commits
mailing list