incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject svn commit: r1381965 - in /incubator/ooo/trunk/main/sc/source/filter: excel/read.cxx excel/xipivot.cxx inc/xipivot.hxx
Date Fri, 07 Sep 2012 09:47:01 GMT
Author: leiw
Date: Fri Sep  7 09:47:01 2012
New Revision: 1381965

URL: http://svn.apache.org/viewvc?rev=1381965&view=rev
Log:
#i120839 [From Symphony]It costs too much memory to open a large spreadsheet file containing
pivot tables

          Patch by: Clarence GUO
          Review by: Wang Lei

Modified:
    incubator/ooo/trunk/main/sc/source/filter/excel/read.cxx
    incubator/ooo/trunk/main/sc/source/filter/excel/xipivot.cxx
    incubator/ooo/trunk/main/sc/source/filter/inc/xipivot.hxx

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/read.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/read.cxx?rev=1381965&r1=1381964&r2=1381965&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/read.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/read.cxx Fri Sep  7 09:47:01 2012
@@ -19,13 +19,9 @@
  * 
  *************************************************************/
 
-
-
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sc.hxx"
 
-
-
 //------------------------------------------------------------------------
 
 #include <stdlib.h>
@@ -1017,7 +1013,7 @@ FltError ImportExcel8::Read( void )
                         {
                             rNumFmtBfr.CreateScFormats();
                             rXFBfr.CreateUserStyles();
-                            rPTableMgr.ReadPivotCaches( maStrm );
+                            //rPTableMgr.ReadPivotCaches( maStrm );
                             eAkt = EXC_STATE_BEFORE_SHEET;
                         }
                     break;
@@ -1203,8 +1199,15 @@ FltError ImportExcel8::Read( void )
         // #i45843# Convert pivot tables before calculation, so they are available
         // for the GETPIVOTDATA function.
         if( GetBiff() == EXC_BIFF8 )
-            GetPivotTableManager().ConvertPivotTables();
+//            GetPivotTableManager().ConvertPivotTables();
+        {
+            SCTAB nTabCount = GetDoc().GetTableCount();
+
+            GetPivotTableManager().ConvertPivotTables( maStrm );
 
+            for( SCTAB nDummyTab = GetDoc().GetTableCount() - 1; nDummyTab >= nTabCount;
nDummyTab-- )
+                GetDoc().DeleteTab( nDummyTab );
+        }
         pProgress.reset();
 
         if (pD->IsAdjustHeightEnabled())
@@ -1226,8 +1229,9 @@ FltError ImportExcel8::Read( void )
         else if( rAddrConv.IsColTruncated() )
             eLastErr = SCWARN_IMPORT_COLUMN_OVERFLOW;
 
-        if( GetBiff() == EXC_BIFF8 )                         
-            GetPivotTableManager().MaybeRefreshPivotTables();
+// Refreshing pivot tables moves to the end of converting every table
+//        if( GetBiff() == EXC_BIFF8 )                         
+//            GetPivotTableManager().MaybeRefreshPivotTables();
     }
 
 	return eLastErr;

Modified: incubator/ooo/trunk/main/sc/source/filter/excel/xipivot.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/excel/xipivot.cxx?rev=1381965&r1=1381964&r2=1381965&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/excel/xipivot.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/excel/xipivot.cxx Fri Sep  7 09:47:01 2012
@@ -19,8 +19,6 @@
  * 
  *************************************************************/
 
-
-
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sc.hxx"
 
@@ -1420,6 +1418,8 @@ void XclImpPivotTable::Convert()
     mpDPObj = pDPObj;
 
     ApplyMergeFlags(aOutRange, aSaveData);
+    MaybeRefresh();	// refresh after convert immediately
+    mxPCache = XclImpPivotCacheRef();	// release memory
 }
 
 void XclImpPivotTable::MaybeRefresh()
@@ -1612,23 +1612,48 @@ void XclImpPivotTableManager::ReadSxView
 
 // ----------------------------------------------------------------------------
 
-void XclImpPivotTableManager::ReadPivotCaches( XclImpStream& rStrm )
+// Reading all used pivot caches at one time and then converting all pivot tables together
will consume too much memory, forbid this action
+// ConvertPivotTables will change to read cache one by one and convert it then release the
memory
+/*void XclImpPivotTableManager::ReadPivotCaches( XclImpStream& rStrm )
 {
     for( XclImpPivotCacheVec::iterator aIt = maPCaches.begin(), aEnd = maPCaches.end(); aIt
!= aEnd; ++aIt )
         (*aIt)->ReadPivotCacheStream( rStrm );
-}
+}*/
 
-void XclImpPivotTableManager::ConvertPivotTables()
+void XclImpPivotTableManager::ConvertPivotTables( XclImpStream & rStm/* guoyanp: for
DP memory */ )
 {
+//    for( XclImpPivotTableVec::iterator aIt = maPTables.begin(), aEnd = maPTables.end();
aIt != aEnd; ++aIt )
+//        (*aIt)->Convert();
+
+    std::map< sal_uInt16, std::list< XclImpPivotTableRef > > aMap;
+
     for( XclImpPivotTableVec::iterator aIt = maPTables.begin(), aEnd = maPTables.end(); aIt
!= aEnd; ++aIt )
-        (*aIt)->Convert();
+        aMap[(*aIt)->GetCacheId()].push_back( *aIt );
+
+    size_t iCache = 0;
+
+    for( std::map< sal_uInt16, std::list< XclImpPivotTableRef > >::iterator i
= aMap.begin(); i != aMap.end(); i++, iCache++ )
+    {
+        if( i->first >= maPCaches.size() ) continue;
+
+        maPCaches[iCache]->ReadPivotCacheStream( rStm );
+
+        for( std::list< XclImpPivotTableRef >::iterator j = i->second.begin(); j
!= i->second.end(); j++ )
+            (*j)->Convert();
+
+        maPCaches[iCache] = XclImpPivotCacheRef();
+    }
 }
 
-void XclImpPivotTableManager::MaybeRefreshPivotTables()
+// Reading all used pivot caches at one time and then converting all pivot tables together
will consume too much memory, forbid that action
+// ConvertPivotTables will change to read cache one by one and convert it then release the
memory
+// So refreshing all pivot tables at one time is forbidden too because the cache already
released
+// Need to refresh one by one after convert every pivot table
+/*void XclImpPivotTableManager::MaybeRefreshPivotTables()
 {
     for( XclImpPivotTableVec::iterator aIt = maPTables.begin(), aEnd = maPTables.end(); aIt
!= aEnd; ++aIt )
         (*aIt)->MaybeRefresh();
-}
+}*/
 
 // ============================================================================
 

Modified: incubator/ooo/trunk/main/sc/source/filter/inc/xipivot.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/filter/inc/xipivot.hxx?rev=1381965&r1=1381964&r2=1381965&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/filter/inc/xipivot.hxx (original)
+++ incubator/ooo/trunk/main/sc/source/filter/inc/xipivot.hxx Fri Sep  7 09:47:01 2012
@@ -19,8 +19,6 @@
  * 
  *************************************************************/
 
-
-
 #ifndef SC_XIPIVOT_HXX
 #define SC_XIPIVOT_HXX
 
@@ -358,6 +356,8 @@ public:
 
     void                ApplyMergeFlags(const ScRange& rOutRange, const ScDPSaveData&
rSaveData);
 
+    sal_uInt16          GetCacheId() const { return maPTInfo.mnCacheIdx; };
+
     // ------------------------------------------------------------------------
 private:
     typedef ::std::vector< XclImpPTFieldRef > XclImpPTFieldVec;
@@ -433,11 +433,11 @@ public:
     // ------------------------------------------------------------------------
 
     /** Reads all used pivot caches and creates additional sheets for external data sources.
*/
-    void                ReadPivotCaches( XclImpStream& rStrm );
+//    void                ReadPivotCaches( XclImpStream& rStrm );
     /** Inserts all pivot tables into the Calc document. */
-    void                ConvertPivotTables();
-
-    void                MaybeRefreshPivotTables();
+//    void                ConvertPivotTables();
+    void                ConvertPivotTables( XclImpStream & );
+//    void                MaybeRefreshPivotTables();
 
 private:
     typedef ::std::vector< XclImpPivotCacheRef >    XclImpPivotCacheVec;



Mime
View raw message