[Libreoffice-commits] core.git: 4 commits - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Tue Dec 10 15:43:04 PST 2013


 sc/inc/dpobject.hxx               |   14 ++++--
 sc/inc/dpsave.hxx                 |   13 +++++
 sc/source/core/data/dpcache.cxx   |   68 +++++++++++++++++++++++-------
 sc/source/core/data/dpobject.cxx  |   85 +++++++++++++++++++++++++++++---------
 sc/source/core/data/dpsave.cxx    |   83 +++++++++++++++++++++++++++++++++++++
 sc/source/filter/xml/xmldpimp.cxx |   33 ++++++++++++++
 sc/source/filter/xml/xmldpimp.hxx |    7 +++
 7 files changed, 262 insertions(+), 41 deletions(-)

New commits:
commit b3977983e9f662392426f581516d86d7034ad0fd
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Dec 10 15:56:06 2013 -0500

    fdo#66969: Reset group dimension data from all referencing pivot objects.
    
    The previous code was doing it only with the first referencing pivot table,
    which would break the rest of them sharing the same cache if
    the first one doesn't contain all group dimensions used in all of the
    referencing pivot tables.
    
    Change-Id: I35d6907ef8db7ed69db42583cac92b2b74406e2c

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 309fab6..803a05e 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -290,7 +290,7 @@ public:
     private:
         ScDPCache* getExistingCache(const ScRange& rRange);
 
-        void updateCache(const ScRange& rRange, const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs);
+        void updateCache(const ScRange& rRange, std::set<ScDPObject*>& rRefs);
         bool remove(const ScDPCache* p);
     };
 
@@ -313,8 +313,7 @@ public:
         ScDPCache* getExistingCache(const OUString& rName);
 
         void updateCache(
-            const OUString& rName, const ScRange& rRange,
-            const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs);
+            const OUString& rName, const ScRange& rRange, std::set<ScDPObject*>& rRefs);
         bool remove(const ScDPCache* p);
     };
 
@@ -358,8 +357,9 @@ public:
         com::sun::star::uno::Reference<com::sun::star::sdbc::XRowSet> createRowSet(
             sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand);
 
-        void updateCache(sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand,
-                         const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs);
+        void updateCache(
+            sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand,
+            std::set<ScDPObject*>& rRefs);
         bool remove(const ScDPCache* p);
     };
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 4aec8a8..677bd5e 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2809,6 +2809,25 @@ struct FindInvalidRange : public std::unary_function<ScRange, bool>
     }
 };
 
+void setGroupItemsToCache( ScDPCache& rCache, const std::set<ScDPObject*>& rRefs )
+{
+    // Go through all referencing pivot tables, and re-fill the group dimension info.
+    std::set<ScDPObject*>::const_iterator itRef = rRefs.begin(), itRefEnd = rRefs.end();
+    for (; itRef != itRefEnd; ++itRef)
+    {
+        const ScDPObject* pObj = *itRef;
+        const ScDPSaveData* pSave = pObj->GetSaveData();
+        if (!pSave)
+            continue;
+
+        const ScDPDimensionSaveData* pGroupDims = pSave->GetExistingDimensionData();
+        if (!pGroupDims)
+            continue;
+
+        pGroupDims->WriteToCache(rCache);
+    }
+}
+
 }
 
 bool ScDPCollection::SheetCaches::hasCache(const ScRange& rRange) const
@@ -2926,8 +2945,7 @@ void ScDPCollection::SheetCaches::updateReference(
     }
 }
 
-void ScDPCollection::SheetCaches::updateCache(
-    const ScRange& rRange, const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs)
+void ScDPCollection::SheetCaches::updateCache(const ScRange& rRange, std::set<ScDPObject*>& rRefs)
 {
     RangeIndexType::iterator it = std::find(maRanges.begin(), maRanges.end(), rRange);
     if (it == maRanges.end())
@@ -2947,12 +2965,15 @@ void ScDPCollection::SheetCaches::updateCache(
     }
 
     ScDPCache& rCache = *itCache->second;
+
+    // Update the cache with new cell values. This will clear all group dimension info.
     rCache.InitFromDoc(mpDoc, rRange);
-    if (pDimData)
-        pDimData->WriteToCache(rCache);
 
     std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
     rRefs.swap(aRefs);
+
+    // Make sure to re-populate the group dimension info.
+    setGroupItemsToCache(rCache, rRefs);
 }
 
 bool ScDPCollection::SheetCaches::remove(const ScDPCache* p)
@@ -3010,8 +3031,7 @@ size_t ScDPCollection::NameCaches::size() const
 }
 
 void ScDPCollection::NameCaches::updateCache(
-    const OUString& rName, const ScRange& rRange, const ScDPDimensionSaveData* pDimData,
-    std::set<ScDPObject*>& rRefs)
+    const OUString& rName, const ScRange& rRange, std::set<ScDPObject*>& rRefs)
 {
     CachesType::iterator itr = maCaches.find(rName);
     if (itr == maCaches.end())
@@ -3021,12 +3041,14 @@ void ScDPCollection::NameCaches::updateCache(
     }
 
     ScDPCache& rCache = *itr->second;
+    // Update the cache with new cell values. This will clear all group dimension info.
     rCache.InitFromDoc(mpDoc, rRange);
-    if (pDimData)
-        pDimData->WriteToCache(rCache);
 
     std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
     rRefs.swap(aRefs);
+
+    // Make sure to re-populate the group dimension info.
+    setGroupItemsToCache(rCache, rRefs);
 }
 
 bool ScDPCollection::NameCaches::remove(const ScDPCache* p)
@@ -3171,7 +3193,7 @@ uno::Reference<sdbc::XRowSet> ScDPCollection::DBCaches::createRowSet(
 
 void ScDPCollection::DBCaches::updateCache(
     sal_Int32 nSdbType, const OUString& rDBName, const OUString& rCommand,
-    const ScDPDimensionSaveData* pDimData, std::set<ScDPObject*>& rRefs)
+    std::set<ScDPObject*>& rRefs)
 {
     DBType aType(nSdbType, rDBName, rCommand);
     CachesType::iterator it = maCaches.find(aType);
@@ -3204,12 +3226,12 @@ void ScDPCollection::DBCaches::updateCache(
         return;
     }
 
-    if (pDimData)
-        pDimData->WriteToCache(rCache);
-
     comphelper::disposeComponent(xRowSet);
     std::set<ScDPObject*> aRefs(rCache.GetAllReferences());
     aRefs.swap(rRefs);
+
+    // Make sure to re-populate the group dimension info.
+    setGroupItemsToCache(rCache, rRefs);
 }
 
 bool ScDPCollection::DBCaches::remove(const ScDPCache* p)
@@ -3271,11 +3293,6 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
     if (!pDPObj)
         return STR_ERR_DATAPILOTSOURCE;
 
-    const ScDPSaveData* pSaveData = pDPObj->GetSaveData();
-    const ScDPDimensionSaveData* pDimData = NULL;
-    if (pSaveData)
-        pDimData = pSaveData->GetExistingDimensionData();
-
     if (pDPObj->IsSheetData())
     {
         // data source is internal sheet.
@@ -3292,7 +3309,7 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
             // cache by named range
             ScDPCollection::NameCaches& rCaches = GetNameCaches();
             if (rCaches.hasCache(pDesc->GetRangeName()))
-                rCaches.updateCache(pDesc->GetRangeName(), pDesc->GetSourceRange(), pDimData, rRefs);
+                rCaches.updateCache(pDesc->GetRangeName(), pDesc->GetSourceRange(), rRefs);
             else
             {
                 // Not cached yet.  Collect all tables that use this named
@@ -3305,7 +3322,7 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
             // cache by cell range
             ScDPCollection::SheetCaches& rCaches = GetSheetCaches();
             if (rCaches.hasCache(pDesc->GetSourceRange()))
-                rCaches.updateCache(pDesc->GetSourceRange(), pDimData, rRefs);
+                rCaches.updateCache(pDesc->GetSourceRange(), rRefs);
             else
             {
                 // Not cached yet.  Collect all tables that use this range as
@@ -3324,7 +3341,7 @@ sal_uLong ScDPCollection::ReloadCache(ScDPObject* pDPObj, std::set<ScDPObject*>&
         ScDPCollection::DBCaches& rCaches = GetDBCaches();
         if (rCaches.hasCache(pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject))
             rCaches.updateCache(
-                pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject, pDimData, rRefs);
+                pDesc->GetCommandType(), pDesc->aDBName, pDesc->aObject, rRefs);
         else
         {
             // Not cached yet.  Collect all tables that use this range as
commit bcea38729938300ce574d9f8570dd49869f01890
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Dec 10 14:58:26 2013 -0500

    Dump group types from pivot cache for debugging.
    
    Also add some flags to change the dumping behavior a little.
    
    Change-Id: I291cdd7d055614b9e7074bdc47292ecd41a474ac

diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index ab7643d..49e5d8f 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;
 }
 
commit 2e1b90a4272defb917b23e2e360e171114d6fa4d
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Dec 10 12:50:48 2013 -0500

    fdo#66969: Set selected page name after building all dimension members.
    
    Because the new implementation relies on the visiblity flag of the
    dimension members, they need to exist before setting currently selected
    page, which is still used in documents generated by the older version of
    LibreOffice.
    
    Change-Id: I6cec5fd3d2165f714fc01b596d3761890d87a4ff

diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 2718733..88750dd 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -412,6 +412,11 @@ void ScXMLDataPilotTableContext::SetButtons()
         pDPObject->RefreshAfterLoad();
 }
 
+void ScXMLDataPilotTableContext::SetSelectedPage( const OUString& rDimName, const OUString& rSelected )
+{
+    maSelectedPages.insert(SelectedPagesType::value_type(rDimName, rSelected));
+}
+
 void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim)
 {
     if (pDPSave)
@@ -548,10 +553,36 @@ void ScXMLDataPilotTableContext::EndElement()
     if ( pDPCollection->GetByName(pDPObject->GetName()) )
         pDPObject->SetName( OUString() );     // ignore the invalid name, create a new name in AfterXMLLoading
 
+    ProcessSelectedPages();
+
     pDPCollection->InsertNewTable(pDPObject);
     SetButtons();
 }
 
+void ScXMLDataPilotTableContext::ProcessSelectedPages()
+{
+    // Set selected pages after building all dimension members.
+    if (!pDPObject)
+        return;
+
+    pDPObject->BuildAllDimensionMembers();
+    ScDPSaveData* pSaveData = pDPObject->GetSaveData();
+    if (!pSaveData)
+        return;
+
+    SelectedPagesType::const_iterator it = maSelectedPages.begin(), itEnd = maSelectedPages.end();
+    for (; it != itEnd; ++it)
+    {
+        const OUString& rDimName = it->first;
+        const OUString& rSelected = it->second;
+        ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(rDimName);
+        if (!pDim)
+            continue;
+
+        pDim->SetCurrentPage(&rSelected);
+    }
+}
+
 void ScXMLDataPilotTableContext::SetGrandTotal(
     XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName)
 {
@@ -1111,7 +1142,7 @@ void ScXMLDataPilotFieldContext::EndElement()
         pDim->SetOrientation(nOrientation);
         if (bSelectedPage)
         {
-            pDim->SetCurrentPage(&sSelectedPage);
+            pDataPilotTable->SetSelectedPage(pDim->GetName(), sSelectedPage);
         }
         pDataPilotTable->AddDimension(pDim);
         if (bIsGroupField)
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
index 1aa851d..32f878d 100644
--- a/sc/source/filter/xml/xmldpimp.hxx
+++ b/sc/source/filter/xml/xmldpimp.hxx
@@ -71,6 +71,8 @@ public:
 
 class ScXMLDataPilotTableContext : public SvXMLImportContext
 {
+    typedef boost::unordered_map<OUString, OUString, OUStringHash> SelectedPagesType;
+
     struct GrandTotalItem
     {
         OUString maDisplayName;
@@ -114,9 +116,13 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext
     bool            bDrillDown:1;
     bool            bHeaderGridLayout:1;
 
+    SelectedPagesType maSelectedPages;
+
     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
 
+    void ProcessSelectedPages();
+
 public:
 
     ScXMLDataPilotTableContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
@@ -151,6 +157,7 @@ public:
     void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim);
     void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim);
     void SetButtons();
+    void SetSelectedPage( const OUString& rDimName, const OUString& rSelected );
 };
 
 class ScXMLDPSourceSQLContext : public SvXMLImportContext
commit 8f6e3118f57276a458b82482b0d277dee327413e
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Dec 10 11:59:50 2013 -0500

    Allow dumping of internal states of pivot table objects for debugging.
    
    Change-Id: I5021ef61d9238da352e13bdd81a2f3607d0fb4aa

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 9bdb123..309fab6 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 905bfc8..7ced43a 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 43d97fc..4aec8a8 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 4572622..c0328ce 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());


More information about the Libreoffice-commits mailing list