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

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Aug 2 19:42:19 PDT 2012


 sc/inc/dapiuno.hxx                        |    2 -
 sc/inc/dpsave.hxx                         |    2 -
 sc/source/filter/inc/pivottablebuffer.hxx |    5 ++
 sc/source/filter/oox/pivottablebuffer.cxx |   52 +++++++++++++++++++++++-------
 4 files changed, 48 insertions(+), 13 deletions(-)

New commits:
commit 1e3d97dfe9747fa70cdcf642a4a710c3d90cc95c
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Thu Aug 2 22:39:55 2012 -0400

    Use the internal API to set field item's properties.
    
    This is 1000 times faster.
    
    Change-Id: I09a75f70c8344898b2aea6bc5a8ca6b5fa9f1065

diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx
index e26906a..ac9079d 100644
--- a/sc/inc/dapiuno.hxx
+++ b/sc/inc/dapiuno.hxx
@@ -265,7 +265,7 @@ public:
                                 throw(::com::sun::star::uno::RuntimeException);
 
     static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId();
-    static ScDataPilotDescriptorBase* getImplementation( const com::sun::star::uno::Reference<
+    SC_DLLPUBLIC static ScDataPilotDescriptorBase* getImplementation( const com::sun::star::uno::Reference<
                                     com::sun::star::sheet::XDataPilotDescriptor> xObj );
 
                             // XTypeProvider (overloaded in ScDataPilotTableObj)
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 28bfafd..14a0032 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -298,7 +298,7 @@ public:
      *         manages its life cycle; hence the caller must
      *         <i>not</i> delete this object.
      */
-    ScDPSaveDimension* GetDimensionByName(const ::rtl::OUString& rName);
+    SC_DLLPUBLIC ScDPSaveDimension* GetDimensionByName(const ::rtl::OUString& rName);
     SC_DLLPUBLIC ScDPSaveDimension* GetDataLayoutDimension();
     SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const;
 
diff --git a/sc/source/filter/inc/pivottablebuffer.hxx b/sc/source/filter/inc/pivottablebuffer.hxx
index 82e1501..0ae79f9 100644
--- a/sc/source/filter/inc/pivottablebuffer.hxx
+++ b/sc/source/filter/inc/pivottablebuffer.hxx
@@ -38,6 +38,8 @@ namespace com { namespace sun { namespace star {
     namespace sheet { class XDataPilotField; }
 } } }
 
+class ScDPObject;
+
 namespace oox {
 namespace xls {
 
@@ -374,6 +376,8 @@ public:
     /** Returns the source column index of the pivot field with the passed index, or -1. */
     sal_Int32           getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const;
 
+    ScDPObject* getDPObject();
+
 private:
     typedef RefVector< PivotTableField >        PivotTableFieldVector;
     typedef RefVector< PivotTableFilter >       PivotTableFilterVector;
@@ -391,6 +395,7 @@ private:
     static void         importFields( IndexVector& orFields, SequenceInputStream& rStrm );
 
 private:
+    ScDPObject* mpDPObject;
     PivotTableFieldVector maFields;         /// All pivot table fields.
     PivotTableField     maDataField;        /// Data layout field.
     IndexVector         maRowFields;        /// Indexes to fields in row dimension.
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx
index 55fc315..cd25e34 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -54,6 +54,10 @@
 #include "addressconverter.hxx"
 #include "biffinputstream.hxx"
 
+#include "dapiuno.hxx"
+#include "dpobject.hxx"
+#include "dpsave.hxx"
+
 namespace oox {
 namespace xls {
 
@@ -63,6 +67,7 @@ using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::sheet;
 using namespace ::com::sun::star::table;
 using namespace ::com::sun::star::uno;
+using namespace com::sun::star;
 
 using ::rtl::OUString;
 
@@ -675,6 +680,9 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32
 
     if( xDPField.is() )
     {
+        // TODO: Use this to set properties directly, bypassing the slow uno layer.
+        ScDPObject* pDPObj = mrPivotTable.getDPObject();
+
         PropertySet aPropSet( xDPField );
         using namespace ::com::sun::star::sheet;
 
@@ -765,18 +773,27 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32
             aPropSet.setProperty( PROP_SortInfo, aSortInfo );
 
             // item settings
-            if( const PivotCacheField* pCacheField = mrPivotTable.getCacheField( mnFieldIndex ) ) try
+            if (const PivotCacheField* pCacheField = mrPivotTable.getCacheField(mnFieldIndex))
             {
-                Reference< XNameAccess > xDPItemsNA( xDPField->getItems(), UNO_QUERY_THROW );
-                for( ItemModelVector::iterator aIt = maItems.begin(), aEnd = maItems.end(); aIt != aEnd; ++aIt )
+                ScDPSaveData* pSaveData = pDPObj->GetSaveData();
+                ScDPSaveDimension* pDim = pSaveData->GetDimensionByName(pCacheField->getName());
+
+                try
                 {
-                    if( aIt->mnType == XML_data )
+                    for( ItemModelVector::iterator aIt = maItems.begin(), aEnd = maItems.end(); aIt != aEnd; ++aIt )
                     {
-                        if( const PivotCacheItem* pSharedItem = pCacheField->getCacheItem( aIt->mnCacheItem ) ) try
+                        if (aIt->mnType != XML_data)
+                            continue;
+
+                        const PivotCacheItem* pSharedItem = pCacheField->getCacheItem(aIt->mnCacheItem);
+                        if (!pSharedItem)
+                            continue;
+
+                        try
                         {
-                            PropertySet aItemProp( xDPItemsNA->getByName( pSharedItem->getName() ) );
-                            aItemProp.setProperty( PROP_ShowDetail, aIt->mbShowDetails );
-                            aItemProp.setProperty( PROP_IsHidden, aIt->mbHidden );
+                            ScDPSaveMember* pMem = pDim->GetMemberByName(pSharedItem->getName());
+                            pMem->SetShowDetails(aIt->mbShowDetails);
+                            pMem->SetIsVisible(!aIt->mbHidden);
                         }
                         catch( Exception& )
                         {
@@ -784,9 +801,7 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32
                         }
                     }
                 }
-            }
-            catch( Exception& )
-            {
+                catch (const Exception&) {}
             }
         }
     }
@@ -961,6 +976,7 @@ PTLocationModel::PTLocationModel() :
 
 PivotTable::PivotTable( const WorkbookHelper& rHelper ) :
     WorkbookHelper( rHelper ),
+    mpDPObject(NULL),
     maDataField( *this, OOX_PT_DATALAYOUTFIELD ),
     mpPivotCache( 0 )
 {
@@ -1215,6 +1231,15 @@ void PivotTable::finalizeImport()
                 mxDPDescriptor->setSourceRange( mpPivotCache->getSourceRange() );
                 mxDPDescriptor->setTag( maDefModel.maTag );
 
+                // TODO: This is a hack. Eventually we need to convert the whole thing to the internal API.
+                ScDataPilotDescriptorBase* pImpl = ScDataPilotDescriptorBase::getImplementation(mxDPDescriptor);
+                if (!pImpl)
+                    return;
+
+                mpDPObject = pImpl->GetDPObject();
+                if (!mpDPObject)
+                    return;
+
                 // global data pilot properties
                 PropertySet aDescProp( mxDPDescriptor );
                 aDescProp.setProperty( PROP_ColumnGrand, maDefModel.mbColGrandTotals );
@@ -1349,6 +1374,11 @@ sal_Int32 PivotTable::getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const
     return mpPivotCache ? mpPivotCache->getCacheDatabaseIndex( nFieldIdx ) : -1;
 }
 
+ScDPObject* PivotTable::getDPObject()
+{
+    return mpDPObject;
+}
+
 // private --------------------------------------------------------------------
 
 PivotTableField* PivotTable::getTableField( sal_Int32 nFieldIdx )


More information about the Libreoffice-commits mailing list