[Libreoffice-commits] .: Branch 'feature/gsoc-calc-perf2' - 2 commits - sc/inc sc/source

Daniel Bankston dbank at kemper.freedesktop.org
Tue Aug 7 02:25:23 PDT 2012


 sc/inc/dapiuno.hxx                        |    2 -
 sc/inc/datauno.hxx                        |    2 -
 sc/inc/dpsave.hxx                         |    2 -
 sc/source/filter/inc/pivottablebuffer.hxx |    5 ++
 sc/source/filter/oox/pivottablebuffer.cxx |   52 +++++++++++++++++++++++-------
 sc/source/filter/oox/workbookhelper.cxx   |   20 +++++++++--
 6 files changed, 65 insertions(+), 18 deletions(-)

New commits:
commit 2892dab25d266ff81162ed91744b89f26299a004
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Tue Aug 7 04:21:54 2012 -0500

    Convert xlsx unnamed database range import to direct sc
    
    Will evaluate later if further conversion is useful here
    
    Change-Id: I6af5296b95075066335783e371d87be15f09f112

diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index afe59fd..75bd893 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -494,7 +494,7 @@ public:
 };
 
 
-class ScDatabaseRangeObj : public cppu::WeakImplHelper6<
+class SC_DLLPUBLIC ScDatabaseRangeObj : public cppu::WeakImplHelper6<
                                 com::sun::star::sheet::XDatabaseRange,
                                 com::sun::star::util::XRefreshable,
                                 com::sun::star::container::XNamed,
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 5aaf414..d61d9d5 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -76,6 +76,10 @@
 #include "rangenam.hxx"
 #include "tokenarray.hxx"
 #include "tokenuno.hxx"
+#include "convuno.hxx"
+#include "dbdata.hxx"
+#include "datauno.hxx"
+#include "globalnames.hxx"
 
 #include "formulabuffer.hxx"
 namespace oox {
@@ -464,12 +468,20 @@ Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( c
 
     // create database range and insert it into the Calc document
     Reference< XDatabaseRange > xDatabaseRange;
-    PropertySet aDocProps( mxDoc );
-    Reference< XUnnamedDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_UnnamedDatabaseRanges ), UNO_QUERY_THROW );
     if( bValidRange ) try
     {
-        xDatabaseRanges->setByTable( aDestRange );
-        xDatabaseRange.set( xDatabaseRanges->getByTable( aDestRange.Sheet ), UNO_QUERY );
+        ScDocument& rDoc =  getScDocument();
+        if( rDoc.GetTableCount() <= aDestRange.Sheet )
+            throw ::com::sun::star::lang::IndexOutOfBoundsException();
+        ScRange aScRange;
+        ScUnoConversion::FillScRange(aScRange, aDestRange);
+        ScDBData* pNewDBData = new ScDBData( STR_DB_LOCAL_NONAME, aScRange.aStart.Tab(),
+                                       aScRange.aStart.Col(), aScRange.aStart.Row(),
+                                       aScRange.aEnd.Col(), aScRange.aEnd.Row() );
+        rDoc.SetAnonymousDBData( aScRange.aStart.Tab() , pNewDBData );
+        ScDocShell* pDocSh = static_cast< ScDocShell* >(rDoc.GetDocumentShell());
+        ScDatabaseRangeObj* pDBRangeObj = new ScDatabaseRangeObj( pDocSh, aScRange.aStart.Tab() );
+        xDatabaseRange.set( pDBRangeObj );
     }
     catch( Exception& )
     {
commit 5373207539828d24d60bb55d3f408fd275b67e8d
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