diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-02 22:39:55 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-08-02 22:41:39 -0400 |
commit | 1e3d97dfe9747fa70cdcf642a4a710c3d90cc95c (patch) | |
tree | 5771fabbdedcf4f5d4e549d63d139814fa3932d0 | |
parent | 621145a777ec6ac918bd822bfc4ece1f75900bb1 (diff) |
Use the internal API to set field item's properties.
This is 1000 times faster.
Change-Id: I09a75f70c8344898b2aea6bc5a8ca6b5fa9f1065
-rw-r--r-- | sc/inc/dapiuno.hxx | 2 | ||||
-rw-r--r-- | sc/inc/dpsave.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/inc/pivottablebuffer.hxx | 5 | ||||
-rw-r--r-- | sc/source/filter/oox/pivottablebuffer.cxx | 52 |
4 files changed, 48 insertions, 13 deletions
diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx index e26906af2d4a..ac9079d8174f 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 28bfafdbe1f4..14a0032150bd 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 82e1501db3bc..0ae79f96bed5 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 55fc31587d6f..cd25e34c9d52 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 ) |