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

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Jan 12 22:45:52 PST 2011


 sc/inc/document.hxx                         |    7 
 sc/inc/dpobject.hxx                         |   43 +++-
 sc/source/core/data/documen3.cxx            |  100 -----------
 sc/source/core/data/dpcachetable.cxx        |    2 
 sc/source/core/data/dpobject.cxx            |  247 ++++++++++++++++++++--------
 sc/source/core/data/dpsdbtab.cxx            |   17 -
 sc/source/core/data/dpshttab.cxx            |    6 
 sc/source/filter/excel/xepivot.cxx          |    2 
 sc/source/filter/xml/XMLExportDataPilot.cxx |    4 
 sc/source/ui/docshell/docsh.cxx             |    4 
 sc/source/ui/unoobj/dapiuno.cxx             |   24 +-
 sc/source/ui/view/dbfunc3.cxx               |    4 
 12 files changed, 243 insertions(+), 217 deletions(-)

New commits:
commit 317b1e6fae941d14d04fedb9ed52944dead66d31
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Jan 13 01:44:03 2011 -0500

    ScDPCollection is no longer derived from ScCollection.
    
    ScCollection is another redundant data structure that could easily
    be replaced with boost::ptr_vector or any of its siblings.

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 1858689..6ea4fd2 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
 
 #include <boost/ptr_container/ptr_list.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
 #include <boost/shared_ptr.hpp>
 
 //------------------------------------------------------------------
@@ -259,36 +260,48 @@ public:
 
 // ============================================================================
 
-class ScDPCollection : public ScCollection
+class ScDPCollection
 {
 private:
     ScDocument*	pDoc;
 
     typedef ::boost::ptr_list<ScDPTableDataCache> DataCachesType;
-    DataCachesType maDPDataCaches;
+    typedef ::boost::ptr_vector<ScDPObject> TablesType;
+    TablesType      maTables;
+    DataCachesType  maDPDataCaches;
 public:
                 ScDPCollection(ScDocument* pDocument);
                 ScDPCollection(const ScDPCollection& r);
-    virtual		~ScDPCollection();
+                ~ScDPCollection();
 
-    virtual	ScDataObject*	Clone() const;
+    SC_DLLPUBLIC size_t GetCount() const;
+    SC_DLLPUBLIC ScDPObject* operator[](size_t nIndex);
+    SC_DLLPUBLIC const ScDPObject* operator[](size_t nIndex) const;
 
-    ScDPObject*	operator[](USHORT nIndex) const {return (ScDPObject*)At(nIndex);}
-    ScDPObject*	GetByName(const String& rName) const;
+    const ScDPObject* GetByName(const String& rName) const;
 
     void        DeleteOnTab( SCTAB nTab );
     void		UpdateReference( UpdateRefMode eUpdateRefMode,
                                  const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz );
 
-    BOOL		RefsEqual( const ScDPCollection& r ) const;
+    bool        RefsEqual( const ScDPCollection& r ) const;
     void		WriteRefsTo( ScDPCollection& r ) const;
 
-    String 		CreateNewName( USHORT nMin = 1 ) const;
+    /**
+     * Create a new name that's not yet used by any existing data pilot
+     * objects.  All data pilot names are 'DataPilot' + <num>, and the nMin
+     * specifies the minimum number allowed.
+     *
+     * @param nMin minimum number allowed.
+     *
+     * @return new name for data pilot object.
+     */
+    String CreateNewName( USHORT nMin = 1 ) const;
 
     void FreeTable(ScDPObject* pDPObj);
     SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj);
 
-    bool        HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
+    bool HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
 
     ScDPTableDataCache* GetDPObjectCache( long nID );
     ScDPTableDataCache* GetUsedDPObjectCache ( const ScRange& rRange );
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 603e4c3..2f1d65e 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2418,7 +2418,6 @@ ScDPCollection::ScDPCollection(ScDocument* pDocument) :
 }
 
 ScDPCollection::ScDPCollection(const ScDPCollection& r) :
-    ScCollection(r),
     pDoc(r.pDoc),
     maDPDataCaches(r.maDPDataCaches)
 {
@@ -2428,114 +2427,136 @@ ScDPCollection::~ScDPCollection()
 {
 }
 
-ScDataObject* ScDPCollection::Clone() const
-{
-    return new ScDPCollection(*this);
-}
-
 void ScDPCollection::DeleteOnTab( SCTAB nTab )
 {
-    USHORT nPos = 0;
-    while ( nPos < nCount )
+    TablesType::iterator itr = maTables.begin(), itrEnd = maTables.end();
+    while (itr != itrEnd)
     {
-        // look for output positions on the deleted sheet
-        if ( static_cast<const ScDPObject*>(At(nPos))->GetOutRange().aStart.Tab() == nTab )
-            AtFree(nPos);
+        const ScDPObject& rObj = *itr;
+        if (rObj.GetOutRange().aStart.Tab() == nTab)
+            // returns the next position after the erased element.
+            itr = maTables.erase(itr);
         else
-            ++nPos;
+            ++itr;
     }
 }
 
 void ScDPCollection::UpdateReference( UpdateRefMode eUpdateRefMode,
                                          const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz )
 {
-    for (USHORT i=0; i<nCount; i++)
-        ((ScDPObject*)At(i))->UpdateReference( eUpdateRefMode, r, nDx, nDy, nDz );
+    TablesType::iterator itr = maTables.begin(), itrEnd = maTables.end();
+    for (; itr != itrEnd; ++itr)
+        itr->UpdateReference(eUpdateRefMode, r, nDx, nDy, nDz);
 }
 
-BOOL ScDPCollection::RefsEqual( const ScDPCollection& r ) const
+bool ScDPCollection::RefsEqual( const ScDPCollection& r ) const
 {
-    if ( nCount != r.nCount )
-        return FALSE;
+    if (maTables.size() != r.maTables.size())
+        return false;
 
-    for (USHORT i=0; i<nCount; i++)
-        if ( ! ((const ScDPObject*)At(i))->RefsEqual( *((const ScDPObject*)r.At(i)) ) )
-            return FALSE;
+    TablesType::const_iterator itr = maTables.begin(), itr2 = r.maTables.begin(), itrEnd = maTables.end();
+    for (; itr != itrEnd; ++itr, ++itr2)
+        if (!itr->RefsEqual(*itr2))
+            return false;
 
-    return TRUE;	// all equal
+    return true;
 }
 
 void ScDPCollection::WriteRefsTo( ScDPCollection& r ) const
 {
-    if ( nCount == r.nCount )
+    if ( maTables.size() == r.maTables.size() )
     {
         //!	assert equal names?
-        for (USHORT i=0; i<nCount; i++)
-            ((const ScDPObject*)At(i))->WriteRefsTo( *((ScDPObject*)r.At(i)) );
+        TablesType::const_iterator itr = maTables.begin(), itrEnd = maTables.end();
+        TablesType::iterator itr2 = r.maTables.begin();
+        for (; itr != itrEnd; ++itr, ++itr2)
+            itr->WriteRefsTo(*itr2);
     }
     else
     {
         // #i8180# If data pilot tables were deleted with their sheet,
         // this collection contains extra entries that must be restored.
         // Matching objects are found by their names.
-
-        DBG_ASSERT( nCount >= r.nCount, "WriteRefsTo: missing entries in document" );
-        for (USHORT nSourcePos=0; nSourcePos<nCount; nSourcePos++)
+        size_t nSrcSize = maTables.size();
+        size_t nDestSize = r.maTables.size();
+        DBG_ASSERT( nSrcSize >= nDestSize, "WriteRefsTo: missing entries in document" );
+        for (size_t nSrcPos = 0; nSrcPos < nSrcSize; ++nSrcPos)
         {
-            const ScDPObject* pSourceObj = static_cast<const ScDPObject*>(At(nSourcePos));
-            String aName = pSourceObj->GetName();
+            const ScDPObject& rSrcObj = maTables[nSrcPos];
+            String aName = rSrcObj.GetName();
             bool bFound = false;
-            for (USHORT nDestPos=0; nDestPos<r.nCount && !bFound; nDestPos++)
+            for (size_t nDestPos = 0; nDestPos < nDestSize && !bFound; ++nDestPos)
             {
-                ScDPObject* pDestObj = static_cast<ScDPObject*>(r.At(nDestPos));
-                if ( pDestObj->GetName() == aName )
+                ScDPObject& rDestObj = r.maTables[nDestPos];
+                if (rDestObj.GetName() == aName)
                 {
-                    pSourceObj->WriteRefsTo( *pDestObj );     // found object, copy refs
+                    rSrcObj.WriteRefsTo(rDestObj);     // found object, copy refs
                     bFound = true;
                 }
             }
-            if ( !bFound )
+
+            if (!bFound)
             {
                 // none found, re-insert deleted object (see ScUndoDataPilot::Undo)
 
-                ScDPObject* pDestObj = new ScDPObject( *pSourceObj );
-                pDestObj->SetAlive(TRUE);
-                if ( !r.InsertNewTable(pDestObj) )
-                {
-                    DBG_ERROR("cannot insert DPObject");
-                    DELETEZ( pDestObj );
-                }
+                ScDPObject* pDestObj = new ScDPObject(rSrcObj);
+                pDestObj->SetAlive(true);
+                r.InsertNewTable(pDestObj);
             }
         }
-        DBG_ASSERT( nCount == r.nCount, "WriteRefsTo: couldn't restore all entries" );
+        DBG_ASSERT( maTables.size() == r.maTables.size(), "WriteRefsTo: couldn't restore all entries" );
     }
 }
 
-ScDPObject* ScDPCollection::GetByName(const String& rName) const
+size_t ScDPCollection::GetCount() const
+{
+    return maTables.size();
+}
+
+ScDPObject* ScDPCollection::operator [](size_t nIndex)
+{
+    return &maTables[nIndex];
+}
+
+const ScDPObject* ScDPCollection::operator [](size_t nIndex) const
+{
+    return &maTables[nIndex];
+}
+
+const ScDPObject* ScDPCollection::GetByName(const String& rName) const
 {
-    for (USHORT i=0; i<nCount; i++)
-        if (static_cast<const ScDPObject*>(pItems[i])->GetName() == rName)
-            return static_cast<ScDPObject*>(pItems[i]);
+    TablesType::const_iterator itr = maTables.begin(), itrEnd = maTables.end();
+    for (; itr != itrEnd; ++itr)
+        if (itr->GetName() == rName)
+            return &(*itr);
+
     return NULL;
 }
 
 String ScDPCollection::CreateNewName( USHORT nMin ) const
 {
     String aBase = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DataPilot"));
-    //!	from Resource?
+    //! from Resource?
 
-    for (USHORT nAdd=0; nAdd<=nCount; nAdd++)	//	nCount+1 tries
+    size_t n = maTables.size();
+    for (size_t nAdd = 0; nAdd <= n; ++nAdd)   //  nCount+1 tries
     {
         String aNewName = aBase;
         aNewName += String::CreateFromInt32( nMin + nAdd );
-        BOOL bFound = FALSE;
-        for (USHORT i=0; i<nCount && !bFound; i++)
-            if (((const ScDPObject*)pItems[i])->GetName() == aNewName)
-                bFound = TRUE;
+        bool bFound = false;
+        TablesType::const_iterator itr = maTables.begin(), itrEnd = maTables.end();
+        for (; itr != itrEnd; ++itr)
+        {
+            if (itr->GetName() == aNewName)
+            {
+                bFound = true;
+                break;
+            }
+        }
         if (!bFound)
-            return aNewName;			// found unused Name
+            return aNewName;            // found unused Name
     }
-    return String();					// should not happen
+    return String();                    // should not happen
 }
 
 long ScDPObject::GetCacheId() const
@@ -2581,8 +2602,8 @@ ULONG ScDPObject::RefreshCache()
         nNewId = pCache->GetId();
 
         bRefresh = TRUE;
-        USHORT nCount = pDPCollection->GetCount();
-        for (USHORT i=0; i<nCount; i++)
+        size_t nCount = pDPCollection->GetCount();
+        for (size_t i=0; i<nCount; ++i)
         { //set new cache id
             if ( (*pDPCollection)[i]->GetCacheId() == nOldId  )
             {
@@ -2595,6 +2616,7 @@ ULONG ScDPObject::RefreshCache()
     }
     return nErrId;
 }
+
 void ScDPObject::SetCacheId( long nCacheId )
 {
     if ( GetCacheId() != nCacheId )
@@ -2613,20 +2635,27 @@ void ScDPCollection::FreeTable(ScDPObject* pDPObj)
     const ScAddress& s = rOutRange.aStart;
     const ScAddress& e = rOutRange.aEnd;
     pDoc->RemoveFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), SC_MF_DP_TABLE);
-    Free(pDPObj);
+    TablesType::iterator itr = maTables.begin(), itrEnd = maTables.end();
+    for (; itr != itrEnd; ++itr)
+    {
+        ScDPObject* p = &(*itr);
+        if (p == pDPObj)
+        {
+            maTables.erase(itr);
+            break;
+        }
+    }
 }
 
 bool ScDPCollection::InsertNewTable(ScDPObject* pDPObj)
 {
-    bool bSuccess = Insert(pDPObj);
-    if (bSuccess)
-    {
-        const ScRange& rOutRange = pDPObj->GetOutRange();
-        const ScAddress& s = rOutRange.aStart;
-        const ScAddress& e = rOutRange.aEnd;
-        pDoc->ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), SC_MF_DP_TABLE);
-    }
-    return bSuccess;
+    const ScRange& rOutRange = pDPObj->GetOutRange();
+    const ScAddress& s = rOutRange.aStart;
+    const ScAddress& e = rOutRange.aEnd;
+    pDoc->ApplyFlagsTab(s.Col(), s.Row(), e.Col(), e.Row(), s.Tab(), SC_MF_DP_TABLE);
+
+    maTables.push_back(pDPObj);
+    return true;
 }
 
 bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
@@ -2654,13 +2683,13 @@ ScDPTableDataCache* ScDPCollection::GetDPObjectCache( long nID )
 ScDPTableDataCache* ScDPCollection::GetUsedDPObjectCache ( const ScRange& rRange )
 {
     ScDPTableDataCache* pCache = NULL;
-    for ( short i=nCount-1; i>=0 ; i--)
+    for (size_t i=maTables.size(); i > 0 ; --i)
     {
-        if ( const ScSheetSourceDesc* pUsedSheetDesc = (*this)[i]->GetSheetDesc() )
+        if ( const ScSheetSourceDesc* pUsedSheetDesc = maTables[i-1].GetSheetDesc() )
             if ( rRange == pUsedSheetDesc->aSourceRange )
             {
-                long nID = (*this)[i]->GetCacheId();
-                if ( nID >= 0  )
+                long nID = maTables[i-1].GetCacheId();
+                if ( nID >= 0 )
                     pCache= GetDPObjectCache( nID );
                 if ( pCache )
                     return pCache;
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index ba0b50c..3a99f97 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -81,15 +81,14 @@ using ::com::sun::star::uno::UNO_QUERY;
 {
     ScDPTableDataCache* pCache = NULL;
     ScDPCollection* pDPCollection= pDoc->GetDPCollection();
-    USHORT nCount = pDPCollection->GetCount();
-    
-    for ( short i=nCount-1; i>=0 ; i--)
+    size_t nCount = pDPCollection->GetCount();
+    for (size_t i = nCount; i > 0; --i)
     {
-        if ( const ScImportSourceDesc* pUsedDesc = (*pDPCollection)[i]->GetImportSourceDesc() )
+        if ( const ScImportSourceDesc* pUsedDesc = (*pDPCollection)[i-1]->GetImportSourceDesc() )
             if ( *this == *pUsedDesc )
             {
-                long nID = (*pDPCollection)[i]->GetCacheId();
-                if ( nID >= 0  )
+                long nID = (*pDPCollection)[i-1]->GetCacheId();
+                if ( nID >= 0 )
                     pCache= pDPCollection->GetDPObjectCache( nID );
                 if ( pCache )
                     return pCache;
diff --git a/sc/source/filter/excel/xepivot.cxx b/sc/source/filter/excel/xepivot.cxx
index 232b699..6b7f741 100644
--- a/sc/source/filter/excel/xepivot.cxx
+++ b/sc/source/filter/excel/xepivot.cxx
@@ -1849,7 +1849,7 @@ XclExpPivotTableManager::XclExpPivotTableManager( const XclExpRoot& rRoot ) :
 void XclExpPivotTableManager::CreatePivotTables()
 {
     if( ScDPCollection* pDPColl = GetDoc().GetDPCollection() )
-        for( USHORT nDPObj = 0, nCount = pDPColl->GetCount(); nDPObj < nCount; ++nDPObj )
+        for( size_t nDPObj = 0, nCount = pDPColl->GetCount(); nDPObj < nCount; ++nDPObj )
             if( ScDPObject* pDPObj = (*pDPColl)[ nDPObj ] )
                 if( const XclExpPivotCache* pPCache = CreatePivotCache( *pDPObj ) )
                     maPTableList.AppendNewRecord( new XclExpPivotTable( GetRoot(), *pDPObj, *pPCache ) );
diff --git a/sc/source/filter/xml/XMLExportDataPilot.cxx b/sc/source/filter/xml/XMLExportDataPilot.cxx
index f6d3d05..1bcfa37 100644
--- a/sc/source/filter/xml/XMLExportDataPilot.cxx
+++ b/sc/source/filter/xml/XMLExportDataPilot.cxx
@@ -755,12 +755,12 @@ void ScXMLExportDataPilot::WriteDataPilots(const uno::Reference <sheet::XSpreads
         ScDPCollection* pDPs = pDoc->GetDPCollection();
         if (pDPs)
         {
-            sal_Int16 nDPCount = pDPs->GetCount();
+            size_t nDPCount = pDPs->GetCount();
             if (nDPCount > 0)
             {
                 SvXMLElementExport aElemDPs(rExport, XML_NAMESPACE_TABLE, XML_DATA_PILOT_TABLES, sal_True, sal_True);
                 rExport.CheckAttrList();
-                for (sal_Int16 i = 0; i < nDPCount; ++i)
+                for (size_t i = 0; i < nDPCount; ++i)
                 {
                     ScDPSaveData* pDPSave = (*pDPs)[i]->GetSaveData();
                     if (pDPSave)
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index c34b407..0789d89 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -378,8 +378,8 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
             ScDPCollection* pDPCollection = aDocument.GetDPCollection();
             if ( pDPCollection )
             {
-                USHORT nDPCount = pDPCollection->GetCount();
-                for (USHORT nDP=0; nDP<nDPCount; nDP++)
+                size_t nDPCount = pDPCollection->GetCount();
+                for (size_t nDP=0; nDP<nDPCount; ++nDP)
                 {
                     ScDPObject* pDPObj = (*pDPCollection)[nDP];
                     if ( !pDPObj->GetName().Len() )
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 4d24c0d..3f7ef28 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -265,8 +265,8 @@ ScDPObject* lcl_GetDPObject( ScDocShell* pDocShell, SCTAB nTab, const String& rN
         ScDPCollection* pColl = pDoc->GetDPCollection();
         if ( pColl )
         {
-            USHORT nCount = pColl->GetCount();
-            for (USHORT i=0; i<nCount; i++)
+            size_t nCount = pColl->GetCount();
+            for (size_t i=0; i<nCount; ++i)
             {
                 ScDPObject* pDPObj = (*pColl)[i];
                 if ( pDPObj->GetOutRange().aStart.Tab() == nTab &&
@@ -347,8 +347,8 @@ ScDataPilotTableObj* ScDataPilotTablesObj::GetObjectByIndex_Impl( sal_Int32 nInd
             //	api only handles sheet data at this time
             //!	allow all data sources!!!
             sal_Int32 nFound = 0;
-            USHORT nCount = pColl->GetCount();
-            for (USHORT i=0; i<nCount; i++)
+            size_t nCount = pColl->GetCount();
+            for (size_t i=0; i<nCount; ++i)
             {
                 ScDPObject* pDPObj = (*pColl)[i];
                 if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
@@ -499,8 +499,8 @@ sal_Int32 SAL_CALL ScDataPilotTablesObj::getCount() throw(RuntimeException)
             //!	allow all data sources!!!
 
             USHORT nFound = 0;
-            USHORT nCount = pColl->GetCount();
-            for (USHORT i=0; i<nCount; i++)
+            size_t nCount = pColl->GetCount();
+            for (size_t i=0; i<nCount; ++i)
             {
                 ScDPObject* pDPObj = (*pColl)[i];
                 if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
@@ -562,9 +562,9 @@ Sequence<OUString> SAL_CALL ScDataPilotTablesObj::getElementNames()
             //!	allow all data sources!!!
 
             USHORT nFound = 0;
-            USHORT nCount = pColl->GetCount();
-            USHORT i;
-            for (i=0; i<nCount; i++)
+            size_t nCount = pColl->GetCount();
+            size_t i;
+            for (i=0; i<nCount; ++i)
             {
                 ScDPObject* pDPObj = (*pColl)[i];
                 if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
@@ -574,7 +574,7 @@ Sequence<OUString> SAL_CALL ScDataPilotTablesObj::getElementNames()
             USHORT nPos = 0;
             Sequence<OUString> aSeq(nFound);
             OUString* pAry = aSeq.getArray();
-            for (i=0; i<nCount; i++)
+            for (i=0; i<nCount; ++i)
             {
                 ScDPObject* pDPObj = (*pColl)[i];
                 if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
@@ -598,8 +598,8 @@ sal_Bool SAL_CALL ScDataPilotTablesObj::hasByName( const OUString& aName )
         if ( pColl )
         {
             String aNamStr(aName);
-            USHORT nCount = pColl->GetCount();
-            for (USHORT i=0; i<nCount; i++)
+            size_t nCount = pColl->GetCount();
+            for (size_t i=0; i<nCount; ++i)
             {
                 //	api only handles sheet data at this time
                 //!	allow all data sources!!!
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 50200b9..60bf4b8 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -708,8 +708,8 @@ ULONG RefreshDPObject( ScDPObject *pDPObj, ScDocument *pDoc, ScDocShell *pDocSh,
     {
         //Refresh all dpobjects
         ScDPCollection* pDPCollection = pDoc->GetDPCollection();
-        USHORT nCount = pDPCollection->GetCount();
-        for (USHORT i=0; i<nCount; i++)
+        size_t nCount = pDPCollection->GetCount();
+        for (size_t i=0; i<nCount; ++i)
         {
             if ( (*pDPCollection)[i]->GetCacheId() == pDPObj->GetCacheId()  )
             {
commit 8b4ea69d2ad3abf07957ae1eb5c8cf7943cbc973
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Jan 13 00:25:56 2011 -0500

    Use boost::ptr_list to store data cache instances to fix memory leak.

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index b55138e..1858689 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -37,6 +37,7 @@
 #include "pivot.hxx"
 #include <com/sun/star/sheet/XDimensionsSupplier.hpp>
 
+#include <boost/ptr_container/ptr_list.hpp>
 #include <boost/shared_ptr.hpp>
 
 //------------------------------------------------------------------
@@ -262,7 +263,9 @@ class ScDPCollection : public ScCollection
 {
 private:
     ScDocument*	pDoc;
-    ::std::list<ScDPTableDataCache*> maDPDataCaches;
+
+    typedef ::boost::ptr_list<ScDPTableDataCache> DataCachesType;
+    DataCachesType maDPDataCaches;
 public:
                 ScDPCollection(ScDocument* pDocument);
                 ScDPCollection(const ScDPCollection& r);
@@ -288,9 +291,13 @@ public:
     bool        HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
 
     ScDPTableDataCache* GetDPObjectCache( long nID );
-    ScDPTableDataCache* GetUsedDPObjectCache ( ScRange rRange );
+    ScDPTableDataCache* GetUsedDPObjectCache ( const ScRange& rRange );
     long AddDPObjectCache( ScDPTableDataCache* pData );
     void RemoveDPObjectCache( long nID );
+
+    /**
+     * Get an available, unique ID value for datapilot data cache.
+     */
     long GetNewDPObjectCacheId ();
 };
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index c355147..603e4c3 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2419,7 +2419,8 @@ ScDPCollection::ScDPCollection(ScDocument* pDocument) :
 
 ScDPCollection::ScDPCollection(const ScDPCollection& r) :
     ScCollection(r),
-    pDoc(r.pDoc)
+    pDoc(r.pDoc),
+    maDPDataCaches(r.maDPDataCaches)
 {
 }
 
@@ -2641,15 +2642,16 @@ bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
 
 ScDPTableDataCache* ScDPCollection::GetDPObjectCache( long nID )
 {
-    for ( std::list<ScDPTableDataCache*>::iterator iter = maDPDataCaches.begin(); iter!=maDPDataCaches.end(); ++iter )
-    { //
-        if ( nID == (*iter)->GetId() )
-            return *iter;
+    DataCachesType::iterator itr = maDPDataCaches.begin(), itrEnd = maDPDataCaches.end();
+    for (; itr != itrEnd; ++itr)
+    {
+        if ( nID == itr->GetId() )
+            return &(*itr);
     }
     return NULL;
 }
 
-ScDPTableDataCache* ScDPCollection::GetUsedDPObjectCache ( ScRange rRange )
+ScDPTableDataCache* ScDPCollection::GetUsedDPObjectCache ( const ScRange& rRange )
 {
     ScDPTableDataCache* pCache = NULL;
     for ( short i=nCount-1; i>=0 ; i--)
@@ -2679,17 +2681,15 @@ long ScDPCollection::AddDPObjectCache( ScDPTableDataCache* pData )
 
 void ScDPCollection::RemoveDPObjectCache( long nID )
 {
-    for ( std::list<ScDPTableDataCache*>::iterator iter = maDPDataCaches.begin(); iter!=maDPDataCaches.end(); ++iter )
+    DataCachesType::iterator itr = maDPDataCaches.begin(), itrEnd = maDPDataCaches.end();
+    for (; itr != itrEnd; ++itr)
     {
-        if ( nID == (*iter)->GetId() )
+        if ( nID == itr->GetId() )
         {
-            ScDPTableDataCache* pCache = *iter;
-            maDPDataCaches.erase( iter );
-            delete pCache;
+            maDPDataCaches.erase(itr);
             break;
         }
     }
-
 }
 
 long ScDPCollection::GetNewDPObjectCacheId()
@@ -2697,20 +2697,22 @@ long ScDPCollection::GetNewDPObjectCacheId()
     long nID = 0;
 
     bool bFound = false;
-    std::list<ScDPTableDataCache*>::iterator iter;
-    do {
-        for ( iter = maDPDataCaches.begin(); iter!=maDPDataCaches.end(); ++iter )
-        { //Get a new Id
-            if ( nID == (*iter)->GetId() )
+    DataCachesType::const_iterator itr, itrEnd = maDPDataCaches.end();
+    do
+    {
+        for ( itr = maDPDataCaches.begin(); itr != itrEnd; ++itr )
+        {
+            if ( nID == itr->GetId() )
             {
                 nID++;
                 bFound = true;
                 break;
             }
         }
-        if ( iter == maDPDataCaches.end() )
+        if ( itr == itrEnd )
             bFound = false;
-    } while ( bFound );
+    }
+    while ( bFound );
 
     return nID;
 }
commit a9d0e8bf5ebe913710463f2b1e755bf3c1827fa0
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Jan 13 00:03:54 2011 -0500

    Renamed data member.

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index cf57639..b55138e 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -262,7 +262,7 @@ class ScDPCollection : public ScCollection
 {
 private:
     ScDocument*	pDoc;
-    std::list<ScDPTableDataCache*>   m_listDPObjectsCaches;
+    ::std::list<ScDPTableDataCache*> maDPDataCaches;
 public:
                 ScDPCollection(ScDocument* pDocument);
                 ScDPCollection(const ScDPCollection& r);
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 35b0715..c355147 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2641,7 +2641,7 @@ bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
 
 ScDPTableDataCache* ScDPCollection::GetDPObjectCache( long nID )
 {
-    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
+    for ( std::list<ScDPTableDataCache*>::iterator iter = maDPDataCaches.begin(); iter!=maDPDataCaches.end(); ++iter )
     { //
         if ( nID == (*iter)->GetId() )
             return *iter;
@@ -2673,18 +2673,18 @@ long ScDPCollection::AddDPObjectCache( ScDPTableDataCache* pData )
     { //create a id for it
         pData->SetId( GetNewDPObjectCacheId() );
     }
-    m_listDPObjectsCaches.push_back( pData );
+    maDPDataCaches.push_back( pData );
     return pData->GetId();
 }
 
 void ScDPCollection::RemoveDPObjectCache( long nID )
 {
-    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
+    for ( std::list<ScDPTableDataCache*>::iterator iter = maDPDataCaches.begin(); iter!=maDPDataCaches.end(); ++iter )
     {
         if ( nID == (*iter)->GetId() )
         {
             ScDPTableDataCache* pCache = *iter;
-            m_listDPObjectsCaches.erase( iter );
+            maDPDataCaches.erase( iter );
             delete pCache;
             break;
         }
@@ -2699,7 +2699,7 @@ long ScDPCollection::GetNewDPObjectCacheId()
     bool bFound = false;
     std::list<ScDPTableDataCache*>::iterator iter;
     do {
-        for ( iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
+        for ( iter = maDPDataCaches.begin(); iter!=maDPDataCaches.end(); ++iter )
         { //Get a new Id
             if ( nID == (*iter)->GetId() )
             {
@@ -2708,7 +2708,7 @@ long ScDPCollection::GetNewDPObjectCacheId()
                 break;
             }
         }
-        if ( iter == m_listDPObjectsCaches.end() )
+        if ( iter == maDPDataCaches.end() )
             bFound = false;
     } while ( bFound );
 
commit 5b9ce57d4bf56ba25fcad0c9462d3df5b57aa2e2
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Jan 12 23:51:13 2011 -0500

    Removed unused method.

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 9f72a06..cf57639 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -291,7 +291,6 @@ public:
     ScDPTableDataCache* GetUsedDPObjectCache ( ScRange rRange );
     long AddDPObjectCache( ScDPTableDataCache* pData );
     void RemoveDPObjectCache( long nID );
-    void RemoveUnusedDPObjectCaches();
     long GetNewDPObjectCacheId ();
 };
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 51f329c..35b0715 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2692,27 +2692,6 @@ void ScDPCollection::RemoveDPObjectCache( long nID )
 
 }
 
-void ScDPCollection::RemoveUnusedDPObjectCaches()
-{
-    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
-    {
-        long  nID = (*iter)->GetId();
-        USHORT i ;
-        for ( i=0; i<nCount; i++)
-        {
-            if ( nID ==  (*this)[i]->GetCacheId() )
-                break;
-        }
-        if ( i == nCount )
-        {
-            ScDPTableDataCache* pCache = *iter;
-            m_listDPObjectsCaches.erase( iter );
-            delete pCache;
-            continue;
-        }
-    }
-}
-
 long ScDPCollection::GetNewDPObjectCacheId()
 {
     long nID = 0;
commit c5fcbdc68164c6480345561b0a1483bdeac3c183
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Jan 12 23:46:09 2011 -0500

    Moved the dp cache handling code from ScDocument to ScDPCollection.
    
    Let's not bloat ScDocument any more than it currently is.  We need
    to be making ScDocument smaller by moving stuff out, not adding
    stuff in.  Plus, dp caches are relevant only when the document has
    data pilot tables, so it makes more sense to move it to
    ScDPCollection.

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 19309eb..a11d2bd 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -246,7 +246,6 @@ private:
     ScRangeName*		pRangeName;
     ScDBCollection*		pDBCollection;
     ScDPCollection*		pDPCollection;
-    std::list<ScDPTableDataCache*>   m_listDPObjectsCaches;
     ScChartCollection*	pChartCollection;
     std::auto_ptr< ScTemporaryChartLock > apTemporaryChartLock;
     ScPatternAttr*		pSelectionAttr;					// Attributes of a block
@@ -488,12 +487,6 @@ public:
     SC_DLLPUBLIC ScDPCollection*		GetDPCollection();
     ScDPObject*			GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
     ScDPObject*         GetDPAtBlock( const ScRange& rBlock ) const;
-    SC_DLLPUBLIC ScDPTableDataCache*    GetDPObjectCache( long nID );
-    SC_DLLPUBLIC ScDPTableDataCache*    GetUsedDPObjectCache ( ScRange rRange );
-    SC_DLLPUBLIC long                                 AddDPObjectCache( ScDPTableDataCache* pData );
-    SC_DLLPUBLIC void                                 RemoveDPObjectCache( long nID );
-    SC_DLLPUBLIC void                                 RemoveUnusedDPObjectCaches();
-    SC_DLLPUBLIC long                                 GetNewDPObjectCacheId ();
 
     SC_DLLPUBLIC ScChartCollection*	GetChartCollection() const;
 
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 5cd7a8e..9f72a06 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -262,6 +262,7 @@ class ScDPCollection : public ScCollection
 {
 private:
     ScDocument*	pDoc;
+    std::list<ScDPTableDataCache*>   m_listDPObjectsCaches;
 public:
                 ScDPCollection(ScDocument* pDocument);
                 ScDPCollection(const ScDPCollection& r);
@@ -285,6 +286,13 @@ public:
     SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj);
 
     bool        HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const;
+
+    ScDPTableDataCache* GetDPObjectCache( long nID );
+    ScDPTableDataCache* GetUsedDPObjectCache ( ScRange rRange );
+    long AddDPObjectCache( ScDPTableDataCache* pData );
+    void RemoveDPObjectCache( long nID );
+    void RemoveUnusedDPObjectCaches();
+    long GetNewDPObjectCacheId ();
 };
 
 
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index b69ab56..1078257 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -2031,104 +2031,4 @@ void ScDocument::DecSizeRecalcLevel( SCTAB nTab, bool bUpdateNoteCaptionPos )
         pTab[nTab]->DecRecalcLevel( bUpdateNoteCaptionPos );
 }
 
-ScDPTableDataCache* ScDocument::GetDPObjectCache( long nID )
-{
-    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
-    { //
-        if ( nID == (*iter)->GetId() )
-            return *iter;
-    }
-    return NULL;
-}
-
-ScDPTableDataCache* ScDocument::GetUsedDPObjectCache ( ScRange rRange )
-{
-    ScDPTableDataCache* pCache = NULL;
-    USHORT nCount = GetDPCollection()->GetCount();
-    for ( short i=nCount-1; i>=0 ; i--)
-    {
-        if ( const ScSheetSourceDesc* pUsedSheetDesc = (*pDPCollection)[i]->GetSheetDesc() )
-            if ( rRange == pUsedSheetDesc->aSourceRange )
-            {
-                long nID = (*pDPCollection)[i]->GetCacheId();
-                if ( nID >= 0  )
-                    pCache= GetDPObjectCache( nID );
-                if ( pCache )
-                    return pCache;
-            }
-    }
-    return pCache;
-}
-
-long ScDocument::AddDPObjectCache( ScDPTableDataCache* pData )
-{
-    if ( pData->GetId() < 0 )
-    { //create a id for it
-        pData->SetId( GetNewDPObjectCacheId() );
-    }
-    m_listDPObjectsCaches.push_back( pData );
-    return pData->GetId();
-}
-
-long ScDocument::GetNewDPObjectCacheId()
-{
-    long nID = 0;
-
-    bool bFound = false;
-    std::list<ScDPTableDataCache*>::iterator iter;
-    do {
-        for ( iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
-        { //Get a new Id
-            if ( nID == (*iter)->GetId() )
-            {
-                nID++;
-                bFound = true;
-                break;
-            }
-        }
-        if ( iter == m_listDPObjectsCaches.end() )
-            bFound = false;
-    } while ( bFound );
-
-    return nID;
-}
-
-void ScDocument::RemoveDPObjectCache( long nID )
-{
-    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
-    {
-        if ( nID == (*iter)->GetId() )
-        {
-            ScDPTableDataCache* pCache = *iter;
-            m_listDPObjectsCaches.erase( iter );
-            delete pCache;
-            break;
-        }
-    }
-
-}
-
-void ScDocument::RemoveUnusedDPObjectCaches()
-{
-    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
-    {
-        long  nID = (*iter)->GetId();
-        USHORT nCount = GetDPCollection()->GetCount();
-        USHORT i ;
-        for ( i=0; i<nCount; i++)
-        {
-            if ( nID ==  (*pDPCollection)[i]->GetCacheId() )
-                break;
-        }
-        if ( i == nCount )
-        {
-            ScDPTableDataCache* pCache = *iter;
-            m_listDPObjectsCaches.erase( iter );
-            delete pCache;
-            continue;
-        }
-    }
-}
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpcachetable.cxx b/sc/source/core/data/dpcachetable.cxx
index 1a1d68d..fb29e6c 100644
--- a/sc/source/core/data/dpcachetable.cxx
+++ b/sc/source/core/data/dpcachetable.cxx
@@ -165,7 +165,7 @@ ScDPCacheTable::ScDPCacheTable( ScDocument* pDoc, long nId ) :
     mpNoneCache( NULL )
 {
     if ( nId >= 0 )
-        mpCache = pDoc->GetDPObjectCache( nId );
+        mpCache = pDoc->GetDPCollection()->GetDPObjectCache( nId );
     else
     { //create a temp cache object
         initNoneCache( NULL );
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index cd65675..51f329c 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -2558,10 +2558,11 @@ ULONG ScDPObject::RefreshCache()
         nErrId =  pSheetDesc->CheckValidate( pDoc );
     if ( nErrId == 0 )
     {
+        ScDPCollection* pDPCollection = pDoc->GetDPCollection();
         long nOldId = GetCacheId();
-        long nNewId = pDoc->GetNewDPObjectCacheId();
+        long nNewId = pDPCollection->GetNewDPObjectCacheId();
         if ( nOldId >= 0 )
-            pDoc->RemoveDPObjectCache( nOldId );
+            pDPCollection->RemoveDPObjectCache( nOldId );
 
         ScDPTableDataCache* pCache  = NULL;
         if ( pSheetDesc )
@@ -2579,7 +2580,6 @@ ULONG ScDPObject::RefreshCache()
         nNewId = pCache->GetId();
 
         bRefresh = TRUE;
-        ScDPCollection* pDPCollection = pDoc->GetDPCollection();
         USHORT nCount = pDPCollection->GetCount();
         for (USHORT i=0; i<nCount; i++)
         { //set new cache id
@@ -2639,4 +2639,101 @@ bool ScDPCollection::HasDPTable(SCCOL nCol, SCROW nRow, SCTAB nTab) const
     return pMergeAttr->HasDPTable();
 }
 
+ScDPTableDataCache* ScDPCollection::GetDPObjectCache( long nID )
+{
+    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
+    { //
+        if ( nID == (*iter)->GetId() )
+            return *iter;
+    }
+    return NULL;
+}
+
+ScDPTableDataCache* ScDPCollection::GetUsedDPObjectCache ( ScRange rRange )
+{
+    ScDPTableDataCache* pCache = NULL;
+    for ( short i=nCount-1; i>=0 ; i--)
+    {
+        if ( const ScSheetSourceDesc* pUsedSheetDesc = (*this)[i]->GetSheetDesc() )
+            if ( rRange == pUsedSheetDesc->aSourceRange )
+            {
+                long nID = (*this)[i]->GetCacheId();
+                if ( nID >= 0  )
+                    pCache= GetDPObjectCache( nID );
+                if ( pCache )
+                    return pCache;
+            }
+    }
+    return pCache;
+}
+
+long ScDPCollection::AddDPObjectCache( ScDPTableDataCache* pData )
+{
+    if ( pData->GetId() < 0 )
+    { //create a id for it
+        pData->SetId( GetNewDPObjectCacheId() );
+    }
+    m_listDPObjectsCaches.push_back( pData );
+    return pData->GetId();
+}
+
+void ScDPCollection::RemoveDPObjectCache( long nID )
+{
+    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
+    {
+        if ( nID == (*iter)->GetId() )
+        {
+            ScDPTableDataCache* pCache = *iter;
+            m_listDPObjectsCaches.erase( iter );
+            delete pCache;
+            break;
+        }
+    }
+
+}
+
+void ScDPCollection::RemoveUnusedDPObjectCaches()
+{
+    for ( std::list<ScDPTableDataCache*>::iterator iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
+    {
+        long  nID = (*iter)->GetId();
+        USHORT i ;
+        for ( i=0; i<nCount; i++)
+        {
+            if ( nID ==  (*this)[i]->GetCacheId() )
+                break;
+        }
+        if ( i == nCount )
+        {
+            ScDPTableDataCache* pCache = *iter;
+            m_listDPObjectsCaches.erase( iter );
+            delete pCache;
+            continue;
+        }
+    }
+}
+
+long ScDPCollection::GetNewDPObjectCacheId()
+{
+    long nID = 0;
+
+    bool bFound = false;
+    std::list<ScDPTableDataCache*>::iterator iter;
+    do {
+        for ( iter = m_listDPObjectsCaches.begin(); iter!=m_listDPObjectsCaches.end(); ++iter )
+        { //Get a new Id
+            if ( nID == (*iter)->GetId() )
+            {
+                nID++;
+                bFound = true;
+                break;
+            }
+        }
+        if ( iter == m_listDPObjectsCaches.end() )
+            bFound = false;
+    } while ( bFound );
+
+    return nID;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index c31d53d..ba0b50c 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -90,7 +90,7 @@ using ::com::sun::star::uno::UNO_QUERY;
             {
                 long nID = (*pDPCollection)[i]->GetCacheId();
                 if ( nID >= 0  )
-                    pCache= pDoc->GetDPObjectCache( nID );
+                    pCache= pDPCollection->GetDPObjectCache( nID );
                 if ( pCache )
                     return pCache;
             }
@@ -164,7 +164,7 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache( ScDocument* pDoc , long nID
             SvNumberFormatter aFormat( pDoc->GetServiceManager(), ScGlobal::eLnge);
             pCache->InitFromDataBase( xRowSet, *aFormat.GetNullDate() );
             pCache->SetId( nID );
-            pDoc->AddDPObjectCache( pCache );
+            pDoc->GetDPCollection()->AddDPObjectCache( pCache );
             DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
         }
     }
@@ -190,7 +190,7 @@ ScDPTableDataCache* ScImportSourceDesc::CreateCache( ScDocument* pDoc , long nID
 
 ScDPTableDataCache* ScImportSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
 {
-    ScDPTableDataCache* pCache = pDoc->GetDPObjectCache( nID );
+    ScDPTableDataCache* pCache = pDoc->GetDPCollection()->GetDPObjectCache( nID );
     if ( NULL == pCache && pDoc )
         pCache = GetExistDPObjectCache( pDoc);
     if ( NULL == pCache )
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 902bef0..20e4346 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -248,7 +248,7 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID
 
             pCache->InitFromDoc( pDoc, aSourceRange );
             pCache->SetId( nID );
-            pDoc->AddDPObjectCache( pCache );
+            pDoc->GetDPCollection()->AddDPObjectCache( pCache );
 
             DBG_TRACE1("Create a cache id = %d \n", pCache->GetId() );
         }
@@ -261,11 +261,11 @@ ScDPTableDataCache* ScSheetSourceDesc::CreateCache( ScDocument* pDoc , long nID
 
 ScDPTableDataCache* ScSheetSourceDesc::GetExistDPObjectCache ( ScDocument* pDoc  ) const
 {
-    return pDoc->GetUsedDPObjectCache( aSourceRange );
+    return pDoc->GetDPCollection()->GetUsedDPObjectCache( aSourceRange );
 }
 ScDPTableDataCache* ScSheetSourceDesc::GetCache( ScDocument* pDoc, long nID ) const
 {
-    ScDPTableDataCache* pCache = pDoc->GetDPObjectCache( nID );
+    ScDPTableDataCache* pCache = pDoc->GetDPCollection()->GetDPObjectCache( nID );
     if ( NULL == pCache && pDoc )
         pCache = GetExistDPObjectCache( pDoc );
     if ( NULL == pCache )


More information about the Libreoffice-commits mailing list