[Libreoffice-commits] .: 10 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Mar 23 19:27:13 PDT 2012


 sc/inc/dpcache.hxx                     |   12 +++
 sc/inc/dpgroup.hxx                     |   12 +++
 sc/inc/dpitemdata.hxx                  |    5 -
 sc/inc/dpmacros.hxx                    |   36 ++++++++++
 sc/inc/dpnumgroupinfo.hxx              |    5 +
 sc/inc/dpobject.hxx                    |    6 +
 sc/inc/dptabdat.hxx                    |    8 ++
 sc/inc/dptabres.hxx                    |   14 ++--
 sc/source/core/data/dpcache.cxx        |  109 +++++++++++++++++++++++++++++++--
 sc/source/core/data/dpdimsave.cxx      |    6 -
 sc/source/core/data/dpgroup.cxx        |   60 +++++++++++++-----
 sc/source/core/data/dpitemdata.cxx     |    2 
 sc/source/core/data/dpnumgroupinfo.cxx |   18 +++++
 sc/source/core/data/dpobject.cxx       |   22 +++++-
 sc/source/core/data/dpsave.cxx         |    2 
 sc/source/core/data/dptabdat.cxx       |   10 ++-
 sc/source/core/data/dptabres.cxx       |   18 ++---
 sc/source/ui/docshell/dbdocfun.cxx     |    8 --
 sc/source/ui/inc/dbfunc.hxx            |    6 +
 sc/source/ui/view/dbfunc3.cxx          |   13 ++-
 20 files changed, 300 insertions(+), 72 deletions(-)

New commits:
commit d9cc468b307d1f1e18d9561c4dbaf0a744ababa9
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 22:15:39 2012 -0400

    Let's just centrally reload group data in DataPilotUpdate()...
    
    It's a no-op when there is no group dimensions anyways.

diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 7e392d5..5bc66c9 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -1327,6 +1327,7 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
                 if ( pNewObj == pOldObj && pDestObj->IsImportData() )
                     pDestObj->ClearTableData();
 
+                pDestObj->ReloadGroupTableData();
                 pDestObj->InvalidateData();             // before getting the new output area
 
                 //  make sure the table has a name (not set by dialog)
@@ -1474,9 +1475,6 @@ sal_uLong ScDBDocFunc::RefreshPivotTables(ScDPObject* pDPObj, bool bApi)
     for (; it != itEnd; ++it)
     {
         ScDPObject* pObj = *it;
-        if (bHasGroups)
-            // Re-build table data for each pivot table when the original contains group fields.
-            pObj->ReloadGroupTableData();
 
         // This action is intentionally not undoable since it modifies cache.
         DataPilotUpdate(pObj, pObj, false, bApi);
@@ -1515,7 +1513,6 @@ void ScDBDocFunc::RefreshPivotTableGroups(ScDPObject* pDPObj)
                 pSaveData->SetDimensionData(pDimData);
         }
 
-        pObj->ReloadGroupTableData();
         // This action is intentionally not undoable since it modifies cache.
         DataPilotUpdate(pObj, pObj, false, false);
     }
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 9a3faeb..e8bfb3f 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -665,7 +665,6 @@ bool ScDBFunc::MakePivotTable(
     bool bAllowMove = (pDPObj != NULL);   // allow re-positioning when editing existing table
 
     ScDBDocFunc aFunc( *pDocSh );
-    pDPObj->ReloadGroupTableData();
     bool bSuccess = aFunc.DataPilotUpdate(pDPObj, &aObj, true, false, bAllowMove);
 
     CursorPosChanged();     // shells may be switched
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index 694324f..bf3402c 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -599,7 +599,6 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu()
     }
     pDim->UpdateMemberVisibility(aResult);
 
-    pDPObj->ReloadGroupTableData();
     ScDBDocFunc aFunc(*pViewData->GetDocShell());
     aFunc.DataPilotUpdate(pDPObj, pDPObj, true, false);
 }
commit 16168d7d589d22b1efd2a666d08d96233783457f
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 22:05:03 2012 -0400

    We don't need date helper in FillGroupValues().

diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index b9271fd..eb46685 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -89,7 +89,7 @@ class ScDPGroupDimension
 {
     long                        nSourceDim;
     long                        nGroupDim;
-    String                      aGroupName;
+    rtl::OUString               aGroupName;
     ScDPDateGroupHelper*        pDateHelper;
     ScDPGroupItemVec            aItems;
    mutable  ::std::vector< SCROW >            maMemberEntries;
@@ -105,7 +105,7 @@ public:
 
     long        GetSourceDim() const    { return nSourceDim; }
     long        GetGroupDim() const     { return nGroupDim; }
-    const      String& GetName() const       { return aGroupName; }
+    const rtl::OUString& GetName() const { return aGroupName; }
 
     const std::vector< SCROW >&  GetColumnEntries( const ScDPCacheTable&  rCacheTable ) const;
     const ScDPGroupItem* GetGroupForData( const ScDPItemData& rData ) const;  // rData = entry in original dim.
@@ -119,6 +119,8 @@ public:
     void        DisposeData();
 
     size_t      GetItemCount() const { return aItems.size(); }
+
+    bool IsDateDimension() const;
 };
 
 typedef ::std::vector<ScDPGroupDimension> ScDPGroupDimensionVec;
@@ -146,6 +148,8 @@ public:
     void MakeDateHelper( const ScDPNumGroupInfo& rInfo, long nDim, sal_Int32 nPart );
 
     void        DisposeData();
+
+    bool IsDateDimension() const;
 };
 
 //
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index b2006a4..872ddfc 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -465,6 +465,11 @@ void ScDPGroupDimension::DisposeData()
     maMemberEntries.clear();
 }
 
+bool ScDPGroupDimension::IsDateDimension() const
+{
+    return pDateHelper != NULL;
+}
+
 // -----------------------------------------------------------------------
 
 ScDPNumGroupDimension::ScDPNumGroupDimension() :
@@ -500,6 +505,11 @@ void ScDPNumGroupDimension::DisposeData()
     maMemberEntries.clear();
 }
 
+bool ScDPNumGroupDimension::IsDateDimension() const
+{
+    return pDateHelper != NULL;
+}
+
 ScDPNumGroupDimension::~ScDPNumGroupDimension()
 {
     delete pDateHelper;
@@ -857,15 +867,15 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon
     for (size_t i = 0; it != itEnd; ++it, ++i)
     {
         long nColumn = *it;
-        const ScDPDateGroupHelper* pDateHelper = NULL;
+        bool bDateDim = false;
 
         long nSourceDim = nColumn;
         if ( nColumn >= nSourceCount && nColumn < nSourceCount + nGroupedColumns )
         {
             const ScDPGroupDimension& rGroupDim = aGroups[nColumn - nSourceCount];
             nSourceDim= rGroupDim.GetSourceDim();
-            pDateHelper = rGroupDim.GetDateHelper();
-            if (!pDateHelper)                         // date is handled below
+            bDateDim = rGroupDim.IsDateDimension();
+            if (!bDateDim)                         // date is handled below
             {
                 const ScDPItemData& rItem = *GetMemberById(nSourceDim, rItems[i]);
                 const ScDPGroupItem* pGroupItem = rGroupDim.GetGroupForData(rItem);
@@ -880,8 +890,8 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon
         }
         else if ( IsNumGroupDimension( nColumn ) )
         {
-            pDateHelper = pNumGroups[nColumn].GetDateHelper();
-            if (!pDateHelper)                         // date is handled below
+            bDateDim = pNumGroups[nColumn].IsDateDimension();
+            if (!bDateDim)                         // date is handled below
             {
                 const ScDPItemData* pData = pCache->GetItemDataById(nSourceDim, rItems[i]);
                 if (pData->GetType() == ScDPItemData::Value)
@@ -899,8 +909,9 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon
 
         const ScDPNumGroupInfo* pNumInfo = pCache->GetNumGroupInfo(nColumn);
 
-        if (pDateHelper && pNumInfo)
+        if (bDateDim && pNumInfo)
         {
+            // This is a date group dimension.
             sal_Int32 nDatePart = pCache->GetGroupType(nColumn);
             const ScDPItemData* pData = pCache->GetItemDataById(nSourceDim, rItems[i]);
             if (pData->GetType() == ScDPItemData::Value)
commit 83a7d544b2d2f6969bdca52b18d99f8a64ed5afa
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 21:56:06 2012 -0400

    Store the group type (aka date part) with the cache, and use that.
    
    With this, we can phase out the "DateHelper" class...

diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 3e23f47..68b1029 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -72,9 +72,10 @@ public:
     {
         ItemsType maItems;
         ScDPNumGroupInfo maInfo;
+        sal_Int32 mnGroupType;
 
         GroupItems();
-        GroupItems(const ScDPNumGroupInfo& rInfo);
+        GroupItems(const ScDPNumGroupInfo& rInfo, sal_Int32 nGroupType);
     };
 
     struct Field : boost::noncopyable
@@ -132,11 +133,12 @@ public:
     SCROW GetIdByItemData(long nDim, const ScDPItemData& rItem) const;
     rtl::OUString GetFormattedString(long nDim, const ScDPItemData& rItem) const;
     long AppendGroupField();
-    void ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo);
+    void ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nGroupType);
     SCROW SetGroupItem(long nDim, const ScDPItemData& rData);
     void GetGroupDimMemberIds(long nDim, std::vector<SCROW>& rIds) const;
     void ClearGroupFields();
     const ScDPNumGroupInfo* GetNumGroupInfo(long nDim) const;
+    sal_Int32 GetGroupType(long nDim) const;
 
     SCCOL GetDimensionIndex(const rtl::OUString& sName) const;
     sal_uLong GetNumberFormat( long nDim ) const;
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index f271ae3..6908163 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -62,10 +62,10 @@ using ::com::sun::star::uno::Reference;
 using ::com::sun::star::uno::UNO_QUERY;
 using ::com::sun::star::uno::UNO_QUERY_THROW;
 
-ScDPCache::GroupItems::GroupItems() {}
+ScDPCache::GroupItems::GroupItems() : mnGroupType(0) {}
 
-ScDPCache::GroupItems::GroupItems(const ScDPNumGroupInfo& rInfo) :
-    maInfo(rInfo) {}
+ScDPCache::GroupItems::GroupItems(const ScDPNumGroupInfo& rInfo, sal_Int32 nGroupType) :
+    maInfo(rInfo), mnGroupType(nGroupType) {}
 
 ScDPCache::Field::Field() : mnNumFormat(0) {}
 
@@ -1019,7 +1019,7 @@ long ScDPCache::AppendGroupField()
     return static_cast<long>(maFields.size() + maGroupFields.size() - 1);
 }
 
-void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo)
+void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo, sal_Int32 nGroupType)
 {
     if (nDim < 0)
         return;
@@ -1027,7 +1027,7 @@ void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo)
     long nSourceCount = static_cast<long>(maFields.size());
     if (nDim < nSourceCount)
     {
-        maFields.at(nDim).mpGroup.reset(new GroupItems(rNumInfo));
+        maFields.at(nDim).mpGroup.reset(new GroupItems(rNumInfo, nGroupType));
         return;
     }
 
@@ -1037,6 +1037,7 @@ void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo)
         GroupItems& rGI = maGroupFields[nDim];
         rGI.maItems.clear();
         rGI.maInfo = rNumInfo;
+        rGI.mnGroupType = nGroupType;
     }
 }
 
@@ -1132,6 +1133,27 @@ const ScDPNumGroupInfo* ScDPCache::GetNumGroupInfo(long nDim) const
     return NULL;
 }
 
+sal_Int32 ScDPCache::GetGroupType(long nDim) const
+{
+    if (nDim < 0)
+        return 0;
+
+    long nSourceCount = static_cast<long>(maFields.size());
+    if (nDim < nSourceCount)
+    {
+        if (!maFields.at(nDim).mpGroup)
+            return 0;
+
+        return maFields[nDim].mpGroup->mnGroupType;
+    }
+
+    nDim -= nSourceCount;
+    if (nDim < static_cast<long>(maGroupFields.size()))
+        return maGroupFields.at(nDim).mnGroupType;
+
+    return 0;
+}
+
 SCROW ScDPCache::GetOrder(long /*nDim*/, SCROW nIndex) const
 {
     return nIndex;
diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx
index f313990..30ddd74 100644
--- a/sc/source/core/data/dpdimsave.cxx
+++ b/sc/source/core/data/dpdimsave.cxx
@@ -357,7 +357,7 @@ void fillDateGroupDimension(
     }
 
     // Now, populate the group items in the cache.
-    rCache.ResetGroupItems(nGroupDim, rDateInfo);
+    rCache.ResetGroupItems(nGroupDim, rDateInfo, nDatePart);
 
     for (sal_Int32 nValue = nStart; nValue <= nEnd; ++nValue)
         rCache.SetGroupItem(nGroupDim, ScDPItemData(nDatePart, nValue));
@@ -408,7 +408,7 @@ void ScDPSaveGroupDimension::AddToCache(ScDPCache& rCache) const
         return;
     }
 
-    rCache.ResetGroupItems(nDim, aDateInfo);
+    rCache.ResetGroupItems(nDim, aDateInfo, 0);
     {
         ScDPSaveGroupItemVec::const_iterator it = aGroups.begin(), itEnd = aGroups.end();
         for (; it != itEnd; ++it)
@@ -541,7 +541,7 @@ void ScDPSaveNumGroupDimension::AddToCache(ScDPCache& rCache) const
         long nLoopCount = 0;
         double fLoop = aGroupInfo.mfStart;
 
-        rCache.ResetGroupItems(nDim, aGroupInfo);
+        rCache.ResetGroupItems(nDim, aGroupInfo, 0);
 
         // Use "less than" instead of "less or equal" for the loop - don't
         // create a group that consists only of the end value. Instead, the
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 3b9c7d6..b2006a4 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -901,16 +901,17 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon
 
         if (pDateHelper && pNumInfo)
         {
+            sal_Int32 nDatePart = pCache->GetGroupType(nColumn);
             const ScDPItemData* pData = pCache->GetItemDataById(nSourceDim, rItems[i]);
             if (pData->GetType() == ScDPItemData::Value)
             {
                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
                 sal_Int32 nPartValue = ScDPUtil::getDatePartValue(
-                    pData->GetValue(), *pNumInfo, pDateHelper->GetDatePart(), pFormatter);
+                    pData->GetValue(), *pNumInfo, nDatePart, pFormatter);
                 rtl::OUString aName = ScDPUtil::getDateGroupName(
-                    pDateHelper->GetDatePart(), nPartValue, pFormatter, pNumInfo->mfStart, pNumInfo->mfEnd);
+                    nDatePart, nPartValue, pFormatter, pNumInfo->mfStart, pNumInfo->mfEnd);
 
-                ScDPItemData aItem(pDateHelper->GetDatePart(), nPartValue);
+                ScDPItemData aItem(nDatePart, nPartValue);
                 rItems[i] = pCache->GetIdByItemData(nColumn, aItem);
             }
         }
commit 09bc4a1ed1f9b4a4661f16a8af5b2a58e30b9c8b
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 21:33:47 2012 -0400

    (Hopefully) fixed the table reload bug coming from the pivot layout dialog.

diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 94ce3a2..3e23f47 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -136,6 +136,7 @@ public:
     SCROW SetGroupItem(long nDim, const ScDPItemData& rData);
     void GetGroupDimMemberIds(long nDim, std::vector<SCROW>& rIds) const;
     void ClearGroupFields();
+    const ScDPNumGroupInfo* GetNumGroupInfo(long nDim) const;
 
     SCCOL GetDimensionIndex(const rtl::OUString& sName) const;
     sal_uLong GetNumberFormat( long nDim ) const;
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index c72b9a7..f271ae3 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -1111,6 +1111,27 @@ void ScDPCache::ClearGroupFields()
     std::for_each(maFields.begin(), maFields.end(), ClearGroupItems());
 }
 
+const ScDPNumGroupInfo* ScDPCache::GetNumGroupInfo(long nDim) const
+{
+    if (nDim < 0)
+        return NULL;
+
+    long nSourceCount = static_cast<long>(maFields.size());
+    if (nDim < nSourceCount)
+    {
+        if (!maFields.at(nDim).mpGroup)
+            return NULL;
+
+        return &maFields[nDim].mpGroup->maInfo;
+    }
+
+    nDim -= nSourceCount;
+    if (nDim < static_cast<long>(maGroupFields.size()))
+        return &maGroupFields.at(nDim).maInfo;
+
+    return NULL;
+}
+
 SCROW ScDPCache::GetOrder(long /*nDim*/, SCROW nIndex) const
 {
     return nIndex;
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 7617973..3b9c7d6 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -897,17 +897,18 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon
             }
         }
 
-        if ( pDateHelper )
+        const ScDPNumGroupInfo* pNumInfo = pCache->GetNumGroupInfo(nColumn);
+
+        if (pDateHelper && pNumInfo)
         {
             const ScDPItemData* pData = pCache->GetItemDataById(nSourceDim, rItems[i]);
             if (pData->GetType() == ScDPItemData::Value)
             {
                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
-                const ScDPNumGroupInfo& rNumInfo = pDateHelper->GetNumInfo();
                 sal_Int32 nPartValue = ScDPUtil::getDatePartValue(
-                    pData->GetValue(), rNumInfo, pDateHelper->GetDatePart(), pFormatter);
+                    pData->GetValue(), *pNumInfo, pDateHelper->GetDatePart(), pFormatter);
                 rtl::OUString aName = ScDPUtil::getDateGroupName(
-                    pDateHelper->GetDatePart(), nPartValue, pFormatter, rNumInfo.mfStart, rNumInfo.mfEnd);
+                    pDateHelper->GetDatePart(), nPartValue, pFormatter, pNumInfo->mfStart, pNumInfo->mfEnd);
 
                 ScDPItemData aItem(pDateHelper->GetDatePart(), nPartValue);
                 rItems[i] = pCache->GetIdByItemData(nColumn, aItem);
@@ -1077,8 +1078,7 @@ void ScDPGroupTableData::Dump() const
     {
         cout << "* dimension: " << i << endl;
         const ScDPNumGroupDimension& rGrp = pNumGroups[i];
-        const ScDPNumGroupInfo& rInfo = rGrp.GetInfo();
-        cout << "  num group enabled: " << rInfo.mbEnable << endl;
+        rGrp.GetInfo().Dump();
     }
     cout << "---" << endl;
 }
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 9218225..2a431da 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -560,8 +560,8 @@ void ScDPObject::ReloadGroupTableData()
         return;
 
     const ScDPDimensionSaveData* pDimData = pSaveData->GetExistingDimensionData();
-    if (!pDimData)
-        // No dimension data. Most likey it doesn't have any group dimensions.
+    if (!pDimData || !pDimData->HasGroupDimensions())
+        // No group dimensions exist.
         return;
 
     ScDPGroupTableData* pData = dynamic_cast<ScDPGroupTableData*>(mpTableData.get());
@@ -581,6 +581,7 @@ void ScDPObject::ReloadGroupTableData()
         pDimData->WriteToData(*pGroupData);
         mpTableData = pGroupData;
     }
+
     bSettingsChanged = true;
 }
 
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index e8bfb3f..9a3faeb 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -665,6 +665,7 @@ bool ScDBFunc::MakePivotTable(
     bool bAllowMove = (pDPObj != NULL);   // allow re-positioning when editing existing table
 
     ScDBDocFunc aFunc( *pDocSh );
+    pDPObj->ReloadGroupTableData();
     bool bSuccess = aFunc.DataPilotUpdate(pDPObj, &aObj, true, false, bAllowMove);
 
     CursorPosChanged();     // shells may be switched
commit 32d3e6b2ecd379e348d298777f8ae74cbc07a061
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 18:24:17 2012 -0400

    Added dump methods to various classes to make debugging easier.
    
    And a little code cleanup here and there...

diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index 987c806..b9271fd 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -214,6 +214,10 @@ public:
                                                const ScDPItemData& rBaseData, long nBaseIndex ) const;
     virtual sal_Bool                    HasCommonElement( const ScDPItemData& rFirstData, long nFirstIndex,
                                                       const ScDPItemData& rSecondData, long nSecondIndex ) const;
+
+#if DEBUG_PIVOT_TABLE
+    virtual void Dump() const;
+#endif
 };
 
 
diff --git a/sc/inc/dpnumgroupinfo.hxx b/sc/inc/dpnumgroupinfo.hxx
index 9d6f254..c4ae17b 100644
--- a/sc/inc/dpnumgroupinfo.hxx
+++ b/sc/inc/dpnumgroupinfo.hxx
@@ -30,6 +30,7 @@
 #define __SC_DPNUMGROUPINFO_HXX__
 
 #include "scdllapi.h"
+#include "dpmacros.hxx"
 
 struct ScDPNumGroupInfo
 {
@@ -44,6 +45,10 @@ struct ScDPNumGroupInfo
 
     SC_DLLPUBLIC ScDPNumGroupInfo();
     SC_DLLPUBLIC ScDPNumGroupInfo(const ScDPNumGroupInfo& r);
+
+#if DEBUG_PIVOT_TABLE
+    void Dump() const;
+#endif
 };
 
 #endif
diff --git a/sc/inc/dptabdat.hxx b/sc/inc/dptabdat.hxx
index 3951275..b11e892 100644
--- a/sc/inc/dptabdat.hxx
+++ b/sc/inc/dptabdat.hxx
@@ -33,7 +33,8 @@
 #include "dpoutput.hxx"
 #include "dpcachetable.hxx"
 #include "dpcache.hxx"
-#include <tools/string.hxx>
+#include "dpmacros.hxx"
+
 #include "svl/zforlist.hxx"
 
 #include <vector>
@@ -171,6 +172,11 @@ public:
     virtual SCROW                        GetIdOfItemData( long  nDim, const ScDPItemData& rData );
     virtual long                GetSourceDim( long nDim );
     virtual long                Compare( long nDim, long nDataId1, long nDataId2);
+
+#if DEBUG_PIVOT_TABLE
+    virtual void Dump() const;
+#endif
+
 protected:
     /** This structure stores vector arrays that hold intermediate data for
         each row during cache table iteration. */
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index aca81eb..7617973 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -899,8 +899,7 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon
 
         if ( pDateHelper )
         {
-            const ScDPItemData* pData  =
-                GetCacheTable().getCache()->GetItemDataById(nSourceDim, rItems[i]);
+            const ScDPItemData* pData = pCache->GetItemDataById(nSourceDim, rItems[i]);
             if (pData->GetType() == ScDPItemData::Value)
             {
                 SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
@@ -911,7 +910,7 @@ void ScDPGroupTableData::FillGroupValues(vector<SCROW>& rItems, const vector<lon
                     pDateHelper->GetDatePart(), nPartValue, pFormatter, rNumInfo.mfStart, rNumInfo.mfEnd);
 
                 ScDPItemData aItem(pDateHelper->GetDatePart(), nPartValue);
-                rItems[i] = GetCacheTable().getCache()->GetIdByItemData(nColumn, aItem);
+                rItems[i] = pCache->GetIdByItemData(nColumn, aItem);
             }
         }
     }
@@ -1058,12 +1057,31 @@ long ScDPGroupTableData::GetSourceDim( long nDim )
     }
     return nDim;
 }
- long ScDPGroupTableData::Compare( long nDim, long nDataId1, long nDataId2)
+
+long ScDPGroupTableData::Compare(long nDim, long nDataId1, long nDataId2)
 {
     if ( getIsDataLayoutDimension(nDim) )
         return 0;
     return ScDPItemData::Compare( *GetMemberById(nDim,  nDataId1),*GetMemberById(nDim,  nDataId2) );
 }
-// -----------------------------------------------------------------------
+
+#if DEBUG_PIVOT_TABLE
+#include <iostream>
+using std::cout;
+using std::endl;
+
+void ScDPGroupTableData::Dump() const
+{
+    cout << "--- ScDPGroupTableData" << endl;
+    for (long i = 0; i < nSourceCount; ++i)
+    {
+        cout << "* dimension: " << i << endl;
+        const ScDPNumGroupDimension& rGrp = pNumGroups[i];
+        const ScDPNumGroupInfo& rInfo = rGrp.GetInfo();
+        cout << "  num group enabled: " << rInfo.mbEnable << endl;
+    }
+    cout << "---" << endl;
+}
+#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpnumgroupinfo.cxx b/sc/source/core/data/dpnumgroupinfo.cxx
index 0b93bf4..2634933 100644
--- a/sc/source/core/data/dpnumgroupinfo.cxx
+++ b/sc/source/core/data/dpnumgroupinfo.cxx
@@ -45,4 +45,22 @@ ScDPNumGroupInfo::ScDPNumGroupInfo(const ScDPNumGroupInfo& r) :
     mfStart(r.mfStart),
     mfEnd(r.mfEnd), mfStep(r.mfStep) {}
 
+#if DEBUG_PIVOT_TABLE
+#include <iostream>
+using std::cout;
+using std::endl;
+
+void ScDPNumGroupInfo::Dump() const
+{
+    cout << "--- ScDPNumGroupInfo" << endl;
+    cout << "  enabled: " << mbEnable << endl;
+    cout << "  auto start: " << mbAutoStart << endl;
+    cout << "  auto end: " << mbAutoEnd << endl;
+    cout << "  start: " << mfStart << endl;
+    cout << "  end: " << mfEnd << endl;
+    cout << "  step: " << mfStep << endl;
+    cout << "---" << endl;
+}
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dptabdat.cxx b/sc/source/core/data/dptabdat.cxx
index 0fd0f1f..a2566be 100644
--- a/sc/source/core/data/dptabdat.cxx
+++ b/sc/source/core/data/dptabdat.cxx
@@ -236,7 +236,7 @@ void ScDPTableData::CalcResultsFromCacheTable(const ScDPCacheTable& rCacheTable,
 }
 
 void ScDPTableData::GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRow,
-                                const vector<long>& rDims, vector< SCROW/*ScDPItemData*/>& rItemData)
+                                const vector<long>& rDims, vector<SCROW>& rItemData)
 {
     sal_Int32 nDimSize = rDims.size();
     for (sal_Int32 i = 0; i < nDimSize; ++i)
@@ -255,7 +255,6 @@ void ScDPTableData::GetItemData(const ScDPCacheTable& rCacheTable, sal_Int32 nRo
 
         SCROW nId= rCacheTable.getCache()->GetItemDataId( static_cast<SCCOL>(nDim), static_cast<SCROW>(nRow), IsRepeatIfEmpty());
         rItemData.push_back( nId );
-
     }
 }
 
@@ -314,6 +313,11 @@ long ScDPTableData::Compare( long nDim, long nDataId1, long nDataId2)
     else
         return -1;
 }
-// -----------------------------------------------------------------------
+
+#if DEBUG_PIVOT_TABLE
+void ScDPTableData::Dump() const
+{
+}
+#endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 41fb722..3b59f51 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -3546,10 +3546,10 @@ void ScDPDataDimension::ProcessData( const vector< SCROW >& aDataMembers, const
         // always first member for data layout dim
         if ( bIsDataLayout || ( !aDataMembers.empty() && pMember->IsNamedItem(aDataMembers[0]) ) )
         {
-            vector</*ScDPItemData*/SCROW> aChildDataMembers;
+            vector<SCROW> aChildDataMembers;
             if (aDataMembers.size() > 1)
             {
-                vector</*ScDPItemData*/SCROW >::const_iterator itr = aDataMembers.begin();
+                vector<SCROW>::const_iterator itr = aDataMembers.begin();
                 aChildDataMembers.insert(aChildDataMembers.begin(), ++itr, aDataMembers.end());
             }
             pMember->ProcessData( aChildDataMembers, aValues, rSubState );
commit 7463dafd92a5153f4c67d1a6d91199d97a3aead1
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 16:26:33 2012 -0400

    A little clean up.

diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index 36ed4ac..3a64f6d 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -506,15 +506,15 @@ private:
     const ScDPResultData*   pResultData;
     MemberArray             maMemberArray;
     MemberHash              maMemberHash;
-    sal_Bool                    bInitialized;
-    String                  aDimensionName;     //! or ptr to IntDimension?
-    sal_Bool                    bIsDataLayout;      //! or ptr to IntDimension?
-    sal_Bool                    bSortByData;
-    sal_Bool                    bSortAscending;
+    rtl::OUString           aDimensionName;     //! or ptr to IntDimension?
     long                    nSortMeasure;
     ScMemberSortOrder       aMemberOrder;       // used when sorted by measure
-    sal_Bool                    bAutoShow;
-    sal_Bool                    bAutoTopItems;
+    bool                    bIsDataLayout:1;      //! or ptr to IntDimension?
+    bool                    bSortByData:1;
+    bool                    bSortAscending:1;
+    bool                    bAutoShow:1;
+    bool                    bAutoTopItems:1;
+    bool                    bInitialized:1;
     long                    nAutoMeasure;
     long                    nAutoCount;
 
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 314fc7e..41fb722 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -2719,13 +2719,13 @@ sal_Bool ScDPGroupCompare::TestIncluded( const ScDPMember& rMember )
 
 ScDPResultDimension::ScDPResultDimension( const ScDPResultData* pData ) :
     pResultData( pData ),
-    bInitialized( false ),
+    nSortMeasure( 0 ),
     bIsDataLayout( false ),
     bSortByData( false ),
     bSortAscending( false ),
-    nSortMeasure( 0 ),
     bAutoShow( false ),
     bAutoTopItems( false ),
+    bInitialized( false ),
     nAutoMeasure( 0 ),
     nAutoCount( 0 )
 {
@@ -2786,7 +2786,7 @@ void ScDPResultDimension::InitFrom( const vector<ScDPDimension*>& ppDim, const v
     const sheet::DataPilotFieldAutoShowInfo& rAutoInfo = pThisLevel->GetAutoShow();
     if ( rAutoInfo.IsEnabled )
     {
-        bAutoShow     = sal_True;
+        bAutoShow     = true;
         bAutoTopItems = ( rAutoInfo.ShowItemsMode == sheet::DataPilotFieldShowItemsMode::FROM_TOP );
         nAutoMeasure  = pThisLevel->GetAutoMeasure();
         nAutoCount    = rAutoInfo.ItemCount;
@@ -2796,7 +2796,7 @@ void ScDPResultDimension::InitFrom( const vector<ScDPDimension*>& ppDim, const v
     const sheet::DataPilotFieldSortInfo& rSortInfo = pThisLevel->GetSortInfo();
     if ( rSortInfo.Mode == sheet::DataPilotFieldSortMode::DATA )
     {
-        bSortByData = sal_True;
+        bSortByData = true;
         bSortAscending = rSortInfo.IsAscending;
         nSortMeasure = pThisLevel->GetSortMeasure();
     }
@@ -2820,12 +2820,12 @@ void ScDPResultDimension::InitFrom( const vector<ScDPDimension*>& ppDim, const v
             ScDPParentDimData aData( i, pThisDim, pThisLevel, pMember);
             ScDPResultMember* pNew = AddMember( aData );
 
-            rInitState.AddMember( nDimSource, /*aMemberData*/pNew->GetDataId() );
+            rInitState.AddMember(nDimSource, pNew->GetDataId());
             pNew->InitFrom( ppDim, ppLev, nPos+1, rInitState, bInitChild  );
             rInitState.RemoveMember();
         }
     }
-    bInitialized = sal_True;
+    bInitialized = true;
 }
 
 void ScDPResultDimension::LateInitFrom(
@@ -3976,7 +3976,7 @@ void ScDPResultDimension::InitWithMembers(
         if ( pResultMember )
         {
             rInitState.AddMember( nDimSource, pResultMember->GetDataId()  );
-            pResultMember->LateInitFrom( rParams /*ppDim, ppLev*/, pItemData, nPos+1 , rInitState );
+            pResultMember->LateInitFrom(rParams, pItemData, nPos+1, rInitState);
             rInitState.RemoveMember();
         }
     }
commit de8276412182eef061680360fab109f1acab0ab4
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 16:11:14 2012 -0400

    Bool-ness.

diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 5255b72..2bc011a 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -615,7 +615,7 @@ void ScDPSaveDimension::WriteToSource( const uno::Reference<uno::XInterface>& xD
         nHierCount = xHiers->getCount();
     }
 
-    sal_Bool bHasHiddenMember = false;
+    bool bHasHiddenMember = false;
 
     for (long nHier=0; nHier<nHierCount; nHier++)
     {
commit ec1b8060e3baf59ae561b3c847a243084e4646b3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 16:06:10 2012 -0400

    Dump item values too.

diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index 91a01a8..c72b9a7 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -1139,6 +1139,12 @@ std::ostream& operator<< (::std::ostream& os, const rtl::OUString& str)
     return os << ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr();
 }
 
+void dumpItems(const ScDPCache& rCache, long nDim, const ScDPCache::ItemsType& rItems, size_t nOffset)
+{
+    for (size_t i = 0; i < rItems.size(); ++i)
+        cout << "      " << (i+nOffset) << ": " << rCache.GetFormattedString(nDim, rItems[i]) << endl;
+}
+
 }
 
 void ScDPCache::Dump() const
@@ -1149,22 +1155,25 @@ void ScDPCache::Dump() const
         for (size_t i = 0; it != itEnd; ++it, ++i)
         {
             const Field& fld = *it;
-            cout << "* source field: " << GetDimensionName(i) << endl;
+            cout << "* source dimension: " << GetDimensionName(i) << " (ID = " << i << ")" << endl;
             cout << "    item count: " << fld.maItems.size() << endl;
+            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());
             }
         }
     }
 
     {
         GroupFieldsType::const_iterator it = maGroupFields.begin(), itEnd = maGroupFields.end();
-        for (; it != itEnd; ++it)
+        for (size_t i = maFields.size(); it != itEnd; ++it, ++i)
         {
             const GroupItems& gi = *it;
-            cout << "* group field: (unnamed)" << endl;
+            cout << "* group dimension: (unnamed) (ID = " << i << ")" << endl;
             cout << "    item count: " << gi.maItems.size() << endl;
+            dumpItems(*this, i, gi.maItems, 0);
         }
     }
 
commit 1097d2f3666a1841f87ac7c94b7011637599d5b3
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 14:35:08 2012 -0400

    Some misc changes & some dumping facility for pivot table for debugging.

diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 2591b3d..94ce3a2 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -31,6 +31,7 @@
 
 #include "global.hxx"
 #include "dpnumgroupinfo.hxx"
+#include "dpmacros.hxx"
 #include "tools/date.hxx"
 
 #include <boost/noncopyable.hpp>
@@ -160,6 +161,10 @@ public:
     ScDPCache(ScDocument* pDoc);
     ~ScDPCache();
 
+#if DEBUG_PIVOT_TABLE
+    void Dump() const;
+#endif
+
 private:
     void PostInit();
     void Clear();
diff --git a/sc/inc/dpitemdata.hxx b/sc/inc/dpitemdata.hxx
index b0f361b..1996d68 100644
--- a/sc/inc/dpitemdata.hxx
+++ b/sc/inc/dpitemdata.hxx
@@ -35,13 +35,12 @@
 #include "sal/types.h"
 #include "tools/solar.h"
 #include "rtl/ustring.hxx"
+#include "dpmacros.hxx"
 
 #include <vector>
 
 #include <boost/unordered_map.hpp>
 
-#define DEBUG_DP_ITEM_DATA 0
-
 class ScDocument;
 
 /**
@@ -119,7 +118,7 @@ public:
 
     sal_uInt8 GetCellType() const;
 
-#if DEBUG_DP_ITEM_DATA
+#if DEBUG_PIVOT_TABLE
     void Dump(const char* msg) const;
 #endif
 };
diff --git a/sc/inc/dpmacros.hxx b/sc/inc/dpmacros.hxx
new file mode 100644
index 0000000..906a0da
--- /dev/null
+++ b/sc/inc/dpmacros.hxx
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ *   Copyright (C) 2012 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef __SC_DPMACROS_HXX__
+#define __SC_DPMACROS_HXX__
+
+#define DEBUG_PIVOT_TABLE 0
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 8c1ed99..af50eb6 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -35,6 +35,8 @@
 #include "dpoutput.hxx"
 #include "dptypes.hxx"
 #include "pivot.hxx"
+#include "dpmacros.hxx"
+
 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
 
 #include <set>
@@ -259,6 +261,10 @@ public:
         std::vector<PivotField>* pRefPageFields = NULL );
 
     static bool         IsOrientationAllowed( sal_uInt16 nOrient, sal_Int32 nDimFlags );
+
+#if DEBUG_PIVOT_TABLE
+    void DumpCache() const;
+#endif
 };
 
 
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index f13a481..91a01a8 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -1126,4 +1126,51 @@ long ScDPCache::GetColumnCount() const
     return mnColumnCount;
 }
 
+#if DEBUG_PIVOT_TABLE
+
+#include <iostream>
+using std::cout;
+using std::endl;
+
+namespace {
+
+std::ostream& operator<< (::std::ostream& os, const rtl::OUString& str)
+{
+    return os << ::rtl::OUStringToOString(str, RTL_TEXTENCODING_UTF8).getStr();
+}
+
+}
+
+void ScDPCache::Dump() const
+{
+    cout << "--- pivot cache dump" << endl;
+    {
+        FieldsType::const_iterator it = maFields.begin(), itEnd = maFields.end();
+        for (size_t i = 0; it != itEnd; ++it, ++i)
+        {
+            const Field& fld = *it;
+            cout << "* source field: " << GetDimensionName(i) << endl;
+            cout << "    item count: " << fld.maItems.size() << endl;
+            if (fld.mpGroup)
+            {
+                cout << "    group item count: " << fld.mpGroup->maItems.size() << endl;
+            }
+        }
+    }
+
+    {
+        GroupFieldsType::const_iterator it = maGroupFields.begin(), itEnd = maGroupFields.end();
+        for (; it != itEnd; ++it)
+        {
+            const GroupItems& gi = *it;
+            cout << "* group field: (unnamed)" << endl;
+            cout << "    item count: " << gi.maItems.size() << endl;
+        }
+    }
+
+    cout << "---" << endl;
+}
+
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpitemdata.cxx b/sc/source/core/data/dpitemdata.cxx
index be4ef7e..c6fc2dd 100644
--- a/sc/source/core/data/dpitemdata.cxx
+++ b/sc/source/core/data/dpitemdata.cxx
@@ -294,7 +294,7 @@ sal_uInt8 ScDPItemData::GetCellType() const
     return SC_VALTYPE_STRING;
 }
 
-#if DEBUG_DP_ITEM_DATA
+#if DEBUG_PIVOT_TABLE
 void ScDPItemData::Dump(const char* msg) const
 {
     printf("--- (%s)\n", msg);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 2f0e510..9218225 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2524,6 +2524,20 @@ uno::Reference<sheet::XDimensionsSupplier> ScDPObject::CreateSource( const ScDPS
     return xRet;
 }
 
+#if DEBUG_PIVOT_TABLE
+void ScDPObject::DumpCache() const
+{
+    if (!mpTableData)
+        return;
+
+    const ScDPCache* pCache = mpTableData->GetCacheTable().getCache();
+    if (!pCache)
+        return;
+
+    pCache->Dump();
+}
+#endif
+
 ScDPCollection::SheetCaches::SheetCaches(ScDocument* pDoc) : mpDoc(pDoc) {}
 
 namespace {
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 6339e5f..7e392d5 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -1327,9 +1327,6 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
                 if ( pNewObj == pOldObj && pDestObj->IsImportData() )
                     pDestObj->ClearTableData();
 
-                if (pDestObj->HasGroups())
-                    pDestObj->ReloadGroupTableData();
-
                 pDestObj->InvalidateData();             // before getting the new output area
 
                 //  make sure the table has a name (not set by dialog)
@@ -1479,7 +1476,7 @@ sal_uLong ScDBDocFunc::RefreshPivotTables(ScDPObject* pDPObj, bool bApi)
         ScDPObject* pObj = *it;
         if (bHasGroups)
             // Re-build table data for each pivot table when the original contains group fields.
-            pObj->ClearTableData();
+            pObj->ReloadGroupTableData();
 
         // This action is intentionally not undoable since it modifies cache.
         DataPilotUpdate(pObj, pObj, false, bApi);
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 284ebf2..aef7207 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -85,8 +85,10 @@ public:
 
     void            Consolidate( const ScConsolidateParam& rParam, sal_Bool bRecord = sal_True );
 
-    bool            MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, sal_Bool bNewTable,
-                                    const ScDPObject& rSource, sal_Bool bApi = false );
+    bool MakePivotTable(
+        const ScDPSaveData& rData, const ScRange& rDest, bool bNewTable,
+        const ScDPObject& rSource, bool bApi = false );
+
     void            DeletePivotTable();
     void            RecalcPivotTable();
     bool HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts );
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 6742928..e8bfb3f 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -591,8 +591,9 @@ String lcl_MakePivotTabName( const String& rPrefix, SCTAB nNumber )
     return aName;
 }
 
-bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest, sal_Bool bNewTable,
-                                const ScDPObject& rSource, sal_Bool bApi )
+bool ScDBFunc::MakePivotTable(
+    const ScDPSaveData& rData, const ScRange& rDest, bool bNewTable,
+    const ScDPObject& rSource, bool bApi )
 {
     //  error message if no fields are set
     //  this must be removed when drag&drop of fields from a toolbox is available
@@ -605,7 +606,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
 
     ScDocShell* pDocSh  = GetViewData()->GetDocShell();
     ScDocument* pDoc    = GetViewData()->GetDocument();
-    sal_Bool bUndo(pDoc->IsUndoEnabled());
+    bool bUndo = pDoc->IsUndoEnabled();
 
     ScRange aDestRange = rDest;
     if ( bNewTable )
@@ -626,7 +627,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
         while ( !pDoc->InsertTab( nNewTab, lcl_MakePivotTabName( aName, i ) ) && i <= MAXTAB )
             i++;
 
-        sal_Bool bAppend = ( nNewTab+1 == pDoc->GetTableCount() );
+        bool bAppend = ( nNewTab+1 == pDoc->GetTableCount() );
         if (bUndo)
         {
             pDocSh->GetUndoManager()->AddUndoAction(
@@ -634,7 +635,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
         }
 
         GetViewData()->InsertTab( nNewTab );
-        SetTabNo( nNewTab, sal_True );
+        SetTabNo(nNewTab, true);
 
         aDestRange = ScRange( 0, 0, nNewTab );
     }
@@ -664,7 +665,7 @@ bool ScDBFunc::MakePivotTable( const ScDPSaveData& rData, const ScRange& rDest,
     bool bAllowMove = (pDPObj != NULL);   // allow re-positioning when editing existing table
 
     ScDBDocFunc aFunc( *pDocSh );
-    bool bSuccess = aFunc.DataPilotUpdate( pDPObj, &aObj, sal_True, false, bAllowMove );
+    bool bSuccess = aFunc.DataPilotUpdate(pDPObj, &aObj, true, false, bAllowMove);
 
     CursorPosChanged();     // shells may be switched
 
diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx
index bf3402c..694324f 100644
--- a/sc/source/ui/view/gridwin2.cxx
+++ b/sc/source/ui/view/gridwin2.cxx
@@ -599,6 +599,7 @@ void ScGridWindow::UpdateDPFromFieldPopupMenu()
     }
     pDim->UpdateMemberVisibility(aResult);
 
+    pDPObj->ReloadGroupTableData();
     ScDBDocFunc aFunc(*pViewData->GetDocShell());
     aFunc.DataPilotUpdate(pDPObj, pDPObj, true, false);
 }
commit 16cfcce0c07f51e6342081cdaafc72277cf6d79c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Fri Mar 23 12:30:37 2012 -0400

    No need to check for null table twice.

diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 9e7af6d..2f0e510 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -564,9 +564,6 @@ void ScDPObject::ReloadGroupTableData()
         // No dimension data. Most likey it doesn't have any group dimensions.
         return;
 
-    if (!mpTableData)
-        return;
-
     ScDPGroupTableData* pData = dynamic_cast<ScDPGroupTableData*>(mpTableData.get());
     if (pData)
     {


More information about the Libreoffice-commits mailing list