summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-10 14:58:26 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-10 18:45:43 -0500
commit3be56fc1b5453b87469d8d050ba54b3fc95d19a5 (patch)
tree4e3cf03e3f3e7f22f91ecab9ab7c008134d702cf
parenta0fd13c0651acf0e620a58eca248b3a12ea43632 (diff)
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)
-rw-r--r--sc/source/core/data/dpcache.cxx68
1 files 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 <memory>
+#if DEBUG_PIVOT_TABLE
+#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
+#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;
}