summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-10 11:59:50 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-10 18:45:22 -0500
commita3880da7f1d799c7c7735528efdf6fee8c5a4f4e (patch)
treeb390a506424d55ebb4bbebb5dcc08fc8de6e2e38
parent8fb8a39eb2c27bb5bc38601469969230f7f90c13 (diff)
Allow dumping of internal states of pivot table objects for debugging.
Change-Id: I5021ef61d9238da352e13bdd81a2f3607d0fb4aa (cherry picked from commit 8f6e3118f57276a458b82482b0d277dee327413e)
-rw-r--r--sc/inc/dpobject.hxx4
-rw-r--r--sc/inc/dpsave.hxx13
-rw-r--r--sc/source/core/data/dpobject.cxx28
-rw-r--r--sc/source/core/data/dpsave.cxx83
4 files changed, 128 insertions, 0 deletions
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 9bdb12346b13..309fab687957 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -406,6 +406,10 @@ public:
bool IntersectsTableByRows( SCCOL nCol, SCROW nRow1, SCROW nRow2, SCTAB nTab ) const;
bool HasTable( const ScRange& rRange ) const;
+#if DEBUG_PIVOT_TABLE
+ void DumpTables() const;
+#endif
+
private:
/** Only to be called from ScDPCache::RemoveReference(). */
void RemoveCache(const ScDPCache* pCache);
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 905bfc86e5f9..7ced43a0e30f 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -33,6 +33,7 @@
#include <sal/types.h>
#include "scdllapi.h"
+#include "calcmacros.hxx"
namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldReference;
@@ -85,6 +86,10 @@ public:
void WriteToSource( const com::sun::star::uno::Reference<com::sun::star::uno::XInterface>& xMember,
sal_Int32 nPosition );
+
+#if DEBUG_PIVOT_TABLE
+ void Dump(int nIndent = 0) const;
+#endif
};
@@ -222,6 +227,10 @@ public:
bool HasInvisibleMember() const;
void RemoveObsoleteMembers(const MemberSetType& rMembers);
+
+#if DEBUG_PIVOT_TABLE
+ void Dump(int nIndent = 0) const;
+#endif
};
@@ -357,6 +366,10 @@ public:
*/
SC_DLLPUBLIC bool HasInvisibleMember(const OUString& rDimName) const;
+#if DEBUG_PIVOT_TABLE
+ void Dump() const;
+#endif
+
private:
void CheckDuplicateName(ScDPSaveDimension& rDim);
void RemoveDuplicateNameCount(const OUString& rName);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index e8b384c4184f..5162d3b0eede 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -3640,6 +3640,34 @@ bool ScDPCollection::HasTable( const ScRange& rRange ) const
maTables.begin(), maTables.end(), FindIntersectingTable(rRange)) != maTables.end();
}
+#if DEBUG_PIVOT_TABLE
+
+namespace {
+
+struct DumpTable : std::unary_function<ScDPObject, void>
+{
+ void operator() (const ScDPObject& rObj) const
+ {
+ cout << "-- '" << rObj.GetName() << "'" << endl;
+ ScDPSaveData* pSaveData = rObj.GetSaveData();
+ if (!pSaveData)
+ return;
+
+ pSaveData->Dump();
+
+ cout << endl; // blank line
+ }
+};
+
+}
+
+void ScDPCollection::DumpTables() const
+{
+ std::for_each(maTables.begin(), maTables.end(), DumpTable());
+}
+
+#endif
+
void ScDPCollection::RemoveCache(const ScDPCache* pCache)
{
if (maSheetCaches.remove(pCache))
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 457262296641..c0328ce1fe42 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -164,6 +164,30 @@ void ScDPSaveMember::WriteToSource( const uno::Reference<uno::XInterface>& xMemb
}
}
+#if DEBUG_PIVOT_TABLE
+
+void ScDPSaveMember::Dump(int nIndent) const
+{
+ std::string aIndent(nIndent*4, ' ');
+ cout << aIndent << "* member name: '" << aName << "'" << endl;
+
+ cout << aIndent << " + layout name: ";
+ if (mpLayoutName)
+ cout << "'" << *mpLayoutName << "'";
+ else
+ cout << "(none)";
+ cout << endl;
+
+ cout << aIndent << " + visibility: ";
+ if (nVisibleMode == SC_DPSAVEMODE_DONTKNOW)
+ cout << "(unknown)";
+ else
+ cout << (nVisibleMode ? "visible" : "hidden");
+ cout << endl;
+}
+
+#endif
+
ScDPSaveDimension::ScDPSaveDimension(const OUString& rName, bool bDataLayout) :
aName( rName ),
mpLayoutName(NULL),
@@ -702,6 +726,51 @@ void ScDPSaveDimension::RemoveObsoleteMembers(const MemberSetType& rMembers)
maMemberList.swap(aNew);
}
+#if DEBUG_PIVOT_TABLE
+
+void ScDPSaveDimension::Dump(int nIndent) const
+{
+ static const char* pOrientNames[] = { "hidden", "column", "row", "page", "data" };
+ std::string aIndent(nIndent*4, ' ');
+
+ cout << aIndent << "* dimension name: '" << aName << "'" << endl;
+
+ cout << aIndent << " + orientation: ";
+ if (nOrientation <= 4)
+ cout << pOrientNames[nOrientation];
+ else
+ cout << "(invalid)";
+ cout << endl;
+
+ cout << aIndent << " + layout name: ";
+ if (mpLayoutName)
+ cout << "'" << *mpLayoutName << "'";
+ else
+ cout << "(none)";
+ cout << endl;
+
+ cout << aIndent << " + subtotal name: ";
+ if (mpSubtotalName)
+ cout << "'" << *mpSubtotalName << "'";
+ else
+ cout << "(none)";
+ cout << endl;
+
+ cout << aIndent << " + is data layout: " << (bIsDataLayout ? "yes" : "no") << endl;
+ cout << aIndent << " + is duplicate: " << (bDupFlag ? "yes" : "no") << endl;
+
+ MemberList::const_iterator itMem = maMemberList.begin(), itMemEnd = maMemberList.end();
+ for (; itMem != itMemEnd; ++itMem)
+ {
+ ScDPSaveMember* pMem = *itMem;
+ pMem->Dump(nIndent+1);
+ }
+
+ cout << endl; // blank line
+}
+
+#endif
+
ScDPSaveData::ScDPSaveData() :
pDimensionData( NULL ),
nColumnGrandMode( SC_DPSAVEMODE_DONTKNOW ),
@@ -1354,6 +1423,20 @@ bool ScDPSaveData::HasInvisibleMember(const OUString& rDimName) const
return pDim->HasInvisibleMember();
}
+#if DEBUG_PIVOT_TABLE
+
+void ScDPSaveData::Dump() const
+{
+ DimsType::const_iterator itDim = aDimList.begin(), itDimEnd = aDimList.end();
+ for (; itDim != itDimEnd; ++itDim)
+ {
+ const ScDPSaveDimension& rDim = *itDim;
+ rDim.Dump();
+ }
+}
+
+#endif
+
void ScDPSaveData::CheckDuplicateName(ScDPSaveDimension& rDim)
{
const OUString aName = ScDPUtil::getSourceDimensionName(rDim.GetName());