From 3be56fc1b5453b87469d8d050ba54b3fc95d19a5 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 10 Dec 2013 14:58:26 -0500 Subject: Dump group types from pivot cache for debugging. Also add some flags to change the dumping behavior a little. Change-Id: I291cdd7d055614b9e7074bdc47292ecd41a474ac (cherry picked from commit bcea38729938300ce574d9f8570dd49869f01890) --- sc/source/core/data/dpcache.cxx | 68 ++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index ab7643d62e07..49e5d8f164e0 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -37,6 +37,10 @@ #include +#if DEBUG_PIVOT_TABLE +#include +#endif + using namespace ::com::sun::star; using ::com::sun::star::uno::Exception; @@ -1174,10 +1178,36 @@ void dumpSourceData(const ScDPCache& rCache, long nDim, const ScDPCache::ItemsTy cout << " '" << rCache.GetFormattedString(nDim, rItems[*it]) << "'" << endl; } +const char* getGroupTypeName(sal_Int32 nType) +{ + static const char* pNames[] = { + "", "years", "quarters", "months", "days", "hours", "minutes", "seconds" + }; + + switch (nType) + { + case sheet::DataPilotFieldGroupBy::YEARS: return pNames[1]; + case sheet::DataPilotFieldGroupBy::QUARTERS: return pNames[2]; + case sheet::DataPilotFieldGroupBy::MONTHS: return pNames[3]; + case sheet::DataPilotFieldGroupBy::DAYS: return pNames[4]; + case sheet::DataPilotFieldGroupBy::HOURS: return pNames[5]; + case sheet::DataPilotFieldGroupBy::MINUTES: return pNames[6]; + case sheet::DataPilotFieldGroupBy::SECONDS: return pNames[7]; + default: + ; + } + + return pNames[0]; +} + } void ScDPCache::Dump() const { + // Change these flags to fit your debugging needs. + bool bDumpItems = false; + bool bDumpSourceData = false; + cout << "--- pivot cache dump" << endl; { FieldsType::const_iterator it = maFields.begin(), itEnd = maFields.end(); @@ -1186,15 +1216,34 @@ void ScDPCache::Dump() const const Field& fld = *it; cout << "* source dimension: " << GetDimensionName(i) << " (ID = " << i << ")" << endl; cout << " item count: " << fld.maItems.size() << endl; - dumpItems(*this, i, fld.maItems, 0); + if (bDumpItems) + dumpItems(*this, i, fld.maItems, 0); if (fld.mpGroup) { cout << " group item count: " << fld.mpGroup->maItems.size() << endl; - dumpItems(*this, i, fld.mpGroup->maItems, fld.maItems.size()); + cout << " group type: " << getGroupTypeName(fld.mpGroup->mnGroupType) << endl; + if (bDumpItems) + dumpItems(*this, i, fld.mpGroup->maItems, fld.maItems.size()); } - cout << " source data (re-constructed):" << endl; - dumpSourceData(*this, i, fld.maItems, fld.maData); + if (bDumpSourceData) + { + cout << " source data (re-constructed):" << endl; + dumpSourceData(*this, i, fld.maItems, fld.maData); + } + } + } + + { + GroupFieldsType::const_iterator it = maGroupFields.begin(), itEnd = maGroupFields.end(); + for (size_t i = maFields.size(); it != itEnd; ++it, ++i) + { + const GroupItems& gi = *it; + cout << "* group dimension: (unnamed) (ID = " << i << ")" << endl; + cout << " item count: " << gi.maItems.size() << endl; + cout << " group type: " << getGroupTypeName(gi.mnGroupType) << endl; + if (bDumpItems) + dumpItems(*this, i, gi.maItems, 0); } } @@ -1218,17 +1267,6 @@ void ScDPCache::Dump() const } } - { - GroupFieldsType::const_iterator it = maGroupFields.begin(), itEnd = maGroupFields.end(); - for (size_t i = maFields.size(); it != itEnd; ++it, ++i) - { - const GroupItems& gi = *it; - cout << "* group dimension: (unnamed) (ID = " << i << ")" << endl; - cout << " item count: " << gi.maItems.size() << endl; - dumpItems(*this, i, gi.maItems, 0); - } - } - cout << "---" << endl; } -- cgit v1.2.3