summaryrefslogtreecommitdiff
path: root/sc/inc
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2011-04-27 17:21:25 -0400
committerKohei Yoshida <kyoshida@novell.com>2011-04-28 15:35:54 -0400
commit60f355127fb93d574e30e590158fe867148762ea (patch)
tree16ab3e42b9789d8fd118458071fca42771c16372 /sc/inc
parentca844d3bfc4fc379608a4856a9750af84e620953 (diff)
Centrally manage cached grid data for data pilot tables.
This prevents cached data from getting re-generated everytime ScDPObject gets copied, which happens quite often. Without this, the performance of datapilot would really really suffer.
Diffstat (limited to 'sc/inc')
-rw-r--r--sc/inc/dpcachetable.hxx8
-rw-r--r--sc/inc/dpobject.hxx59
-rw-r--r--sc/inc/dpsdbtab.hxx7
-rw-r--r--sc/inc/dpshttab.hxx4
-rw-r--r--sc/inc/dptabdat.hxx3
-rw-r--r--sc/inc/dptablecache.hxx2
6 files changed, 65 insertions, 18 deletions
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 73b3d5e12727..9a5ff7979f57 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -121,7 +121,7 @@ public:
Criterion();
};
- ScDPCacheTable(ScDPCache* pCache);
+ ScDPCacheTable(const ScDPCache* pCache);
~ScDPCacheTable();
sal_Int32 getRowSize() const;
@@ -169,15 +169,13 @@ public:
SCROW getOrder(long nDim, SCROW nIndex) const;
void clear();
bool empty() const;
- void setCache(ScDPCache* p);
+ void setCache(const ScDPCache* p);
bool hasCache() const;
private:
ScDPCacheTable();
ScDPCacheTable(const ScDPCacheTable&);
- ScDPCache* getCache();
-
/**
* Check if a given row meets all specified criteria.
*
@@ -194,7 +192,7 @@ private:
has the index of 0. */
::std::vector<bool> maRowsVisible;
- ScDPCache* mpCache;
+ const ScDPCache* mpCache;
};
#endif
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 59230d833491..9972e0c1198f 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -39,6 +39,7 @@
#include <boost/ptr_container/ptr_list.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
#include <boost/shared_ptr.hpp>
namespace com { namespace sun { namespace star { namespace sheet {
@@ -117,7 +118,6 @@ private:
SC_DLLPRIVATE void CreateObjects();
SC_DLLPRIVATE void CreateOutput();
sal_Bool bRefresh;
- long mnCacheId;
public:
ScDPObject(ScDocument* pD);
@@ -257,13 +257,48 @@ public:
class ScDPCollection
{
-private:
- typedef ::boost::ptr_vector<ScDPObject> TablesType;
+public:
- ScDocument* pDoc;
- TablesType maTables;
+ /**
+ * Stores and manages all caches from internal sheets.
+ */
+ class SheetCaches
+ {
+ typedef ::boost::ptr_map<ScRange, ScDPCache> CachesType;
+ CachesType maCaches;
+ ScDocument* mpDoc;
+ public:
+ SheetCaches(ScDocument* pDoc);
+ const ScDPCache* getCache(const ScRange& rRange);
+ void removeCache(const ScRange& rRange);
+ };
+
+ /**
+ * Defines connection type to external data source. Used as a key to look
+ * up database cache.
+ */
+ struct DBType
+ {
+ sal_Int32 mnSdbType;
+ ::rtl::OUString maDBName;
+ ::rtl::OUString maCommand;
+ DBType(sal_Int32 nSdbType, const ::rtl::OUString& rDBName, const ::rtl::OUString& rCommand);
+ };
+
+ /**
+ * Data caches for external database sources.
+ */
+ class DBCaches
+ {
+ typedef ::boost::ptr_map<DBType, ScDPCache> CachesType;
+ CachesType maCaches;
+ ScDocument* mpDoc;
+ public:
+ DBCaches(ScDocument* pDoc);
+ const ScDPCache* getCache(sal_Int32 nSdbType, const ::rtl::OUString& rDBName, const ::rtl::OUString& rCommand);
+ void removeCache(sal_Int32 nSdbType, const ::rtl::OUString& rDBName, const ::rtl::OUString& rCommand);
+ };
-public:
ScDPCollection(ScDocument* pDocument);
ScDPCollection(const ScDPCollection& r);
~ScDPCollection();
@@ -296,8 +331,20 @@ public:
SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj);
bool HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
+
+ SheetCaches& GetSheetCaches();
+ DBCaches& GetDBCaches();
+
+private:
+ typedef ::boost::ptr_vector<ScDPObject> TablesType;
+
+ ScDocument* pDoc;
+ TablesType maTables;
+ SheetCaches maSheetCaches;
+ DBCaches maDBCaches;
};
+bool operator<(const ScDPCollection::DBType& left, const ScDPCollection::DBType& right);
#endif
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index b86d0869e404..87c3ccd1ec5c 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -41,8 +41,8 @@ class ScDocument;
struct ScImportSourceDesc
{
- String aDBName;
- String aObject;
+ ::rtl::OUString aDBName;
+ ::rtl::OUString aObject;
sal_uInt16 nType; // enum DataImportMode
bool bNative;
ScDocument* mpDoc;
@@ -56,7 +56,8 @@ struct ScImportSourceDesc
bNative == rOther.bNative &&
mpDoc == rOther.mpDoc; }
- ScDPCache* CreateCache() const;
+ sal_Int32 GetCommandType() const;
+ const ScDPCache* CreateCache() const;
};
/**
diff --git a/sc/inc/dpshttab.hxx b/sc/inc/dpshttab.hxx
index 9215ef107dfb..505a2758ae78 100644
--- a/sc/inc/dpshttab.hxx
+++ b/sc/inc/dpshttab.hxx
@@ -78,7 +78,7 @@ public:
const ScQueryParam& GetQueryParam() const;
bool operator== ( const ScSheetSourceDesc& rOther ) const;
- SC_DLLPUBLIC ScDPCache* CreateCache() const;
+ SC_DLLPUBLIC const ScDPCache* CreateCache() const;
/**
* Check the sanity of the data source range.
@@ -111,7 +111,7 @@ private:
ScDPCacheTable aCacheTable;
public:
- ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, ScDPCache* pCache);
+ ScSheetDPData(ScDocument* pD, const ScSheetSourceDesc& rDesc, const ScDPCache* pCache);
virtual ~ScSheetDPData();
virtual long GetColumnCount();
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 7b3dde760246..31d32fe25706 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -39,6 +39,7 @@
#include <set>
#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>
+#include <boost/noncopyable.hpp>
namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldFilter;
@@ -91,7 +92,7 @@ class ScDocument;
* Base class that abstracts different data source types of a datapilot
* table.
*/
-class SC_DLLPUBLIC ScDPTableData
+class SC_DLLPUBLIC ScDPTableData : public ::boost::noncopyable
{
// cached data for GetDatePart
long nLastDateVal;
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index c1ee4238193c..f5bfb6011210 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -93,7 +93,7 @@ public:
bool IsEmptyMember( SCROW nRow, sal_uInt16 nColumn ) const;
bool IsRowEmpty( SCROW nRow ) const;
bool IsValid() const;
- bool ValidQuery( SCROW nRow, const ScQueryParam& rQueryParam, bool* pSpecial );
+ bool ValidQuery( SCROW nRow, const ScQueryParam& rQueryParam, bool* pSpecial ) const;
ScDocument* GetDoc() const;//ms-cache-core
long GetColumnCount() const;