Kaydet (Commit) 1e3d97df authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Use the internal API to set field item's properties.

This is 1000 times faster.

Change-Id: I09a75f70c8344898b2aea6bc5a8ca6b5fa9f1065
üst 621145a7
...@@ -265,7 +265,7 @@ public: ...@@ -265,7 +265,7 @@ public:
throw(::com::sun::star::uno::RuntimeException); throw(::com::sun::star::uno::RuntimeException);
static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); 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 ); com::sun::star::sheet::XDataPilotDescriptor> xObj );
// XTypeProvider (overloaded in ScDataPilotTableObj) // XTypeProvider (overloaded in ScDataPilotTableObj)
......
...@@ -298,7 +298,7 @@ public: ...@@ -298,7 +298,7 @@ public:
* manages its life cycle; hence the caller must * manages its life cycle; hence the caller must
* <i>not</i> delete this object. * <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* GetDataLayoutDimension();
SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const; SC_DLLPUBLIC ScDPSaveDimension* GetExistingDataLayoutDimension() const;
......
...@@ -38,6 +38,8 @@ namespace com { namespace sun { namespace star { ...@@ -38,6 +38,8 @@ namespace com { namespace sun { namespace star {
namespace sheet { class XDataPilotField; } namespace sheet { class XDataPilotField; }
} } } } } }
class ScDPObject;
namespace oox { namespace oox {
namespace xls { namespace xls {
...@@ -374,6 +376,8 @@ public: ...@@ -374,6 +376,8 @@ public:
/** Returns the source column index of the pivot field with the passed index, or -1. */ /** Returns the source column index of the pivot field with the passed index, or -1. */
sal_Int32 getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const; sal_Int32 getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const;
ScDPObject* getDPObject();
private: private:
typedef RefVector< PivotTableField > PivotTableFieldVector; typedef RefVector< PivotTableField > PivotTableFieldVector;
typedef RefVector< PivotTableFilter > PivotTableFilterVector; typedef RefVector< PivotTableFilter > PivotTableFilterVector;
...@@ -391,6 +395,7 @@ private: ...@@ -391,6 +395,7 @@ private:
static void importFields( IndexVector& orFields, SequenceInputStream& rStrm ); static void importFields( IndexVector& orFields, SequenceInputStream& rStrm );
private: private:
ScDPObject* mpDPObject;
PivotTableFieldVector maFields; /// All pivot table fields. PivotTableFieldVector maFields; /// All pivot table fields.
PivotTableField maDataField; /// Data layout field. PivotTableField maDataField; /// Data layout field.
IndexVector maRowFields; /// Indexes to fields in row dimension. IndexVector maRowFields; /// Indexes to fields in row dimension.
......
...@@ -54,6 +54,10 @@ ...@@ -54,6 +54,10 @@
#include "addressconverter.hxx" #include "addressconverter.hxx"
#include "biffinputstream.hxx" #include "biffinputstream.hxx"
#include "dapiuno.hxx"
#include "dpobject.hxx"
#include "dpsave.hxx"
namespace oox { namespace oox {
namespace xls { namespace xls {
...@@ -63,6 +67,7 @@ using namespace ::com::sun::star::container; ...@@ -63,6 +67,7 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::sheet; using namespace ::com::sun::star::sheet;
using namespace ::com::sun::star::table; using namespace ::com::sun::star::table;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace com::sun::star;
using ::rtl::OUString; using ::rtl::OUString;
...@@ -675,6 +680,9 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32 ...@@ -675,6 +680,9 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32
if( xDPField.is() ) if( xDPField.is() )
{ {
// TODO: Use this to set properties directly, bypassing the slow uno layer.
ScDPObject* pDPObj = mrPivotTable.getDPObject();
PropertySet aPropSet( xDPField ); PropertySet aPropSet( xDPField );
using namespace ::com::sun::star::sheet; using namespace ::com::sun::star::sheet;
...@@ -765,18 +773,27 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32 ...@@ -765,18 +773,27 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32
aPropSet.setProperty( PROP_SortInfo, aSortInfo ); aPropSet.setProperty( PROP_SortInfo, aSortInfo );
// item settings // 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 ); ScDPSaveData* pSaveData = pDPObj->GetSaveData();
for( ItemModelVector::iterator aIt = maItems.begin(), aEnd = maItems.end(); aIt != aEnd; ++aIt ) 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() ) ); ScDPSaveMember* pMem = pDim->GetMemberByName(pSharedItem->getName());
aItemProp.setProperty( PROP_ShowDetail, aIt->mbShowDetails ); pMem->SetShowDetails(aIt->mbShowDetails);
aItemProp.setProperty( PROP_IsHidden, aIt->mbHidden ); pMem->SetIsVisible(!aIt->mbHidden);
} }
catch( Exception& ) catch( Exception& )
{ {
...@@ -784,9 +801,7 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32 ...@@ -784,9 +801,7 @@ Reference< XDataPilotField > PivotTableField::convertRowColPageField( sal_Int32
} }
} }
} }
} catch (const Exception&) {}
catch( Exception& )
{
} }
} }
} }
...@@ -961,6 +976,7 @@ PTLocationModel::PTLocationModel() : ...@@ -961,6 +976,7 @@ PTLocationModel::PTLocationModel() :
PivotTable::PivotTable( const WorkbookHelper& rHelper ) : PivotTable::PivotTable( const WorkbookHelper& rHelper ) :
WorkbookHelper( rHelper ), WorkbookHelper( rHelper ),
mpDPObject(NULL),
maDataField( *this, OOX_PT_DATALAYOUTFIELD ), maDataField( *this, OOX_PT_DATALAYOUTFIELD ),
mpPivotCache( 0 ) mpPivotCache( 0 )
{ {
...@@ -1215,6 +1231,15 @@ void PivotTable::finalizeImport() ...@@ -1215,6 +1231,15 @@ void PivotTable::finalizeImport()
mxDPDescriptor->setSourceRange( mpPivotCache->getSourceRange() ); mxDPDescriptor->setSourceRange( mpPivotCache->getSourceRange() );
mxDPDescriptor->setTag( maDefModel.maTag ); 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 // global data pilot properties
PropertySet aDescProp( mxDPDescriptor ); PropertySet aDescProp( mxDPDescriptor );
aDescProp.setProperty( PROP_ColumnGrand, maDefModel.mbColGrandTotals ); aDescProp.setProperty( PROP_ColumnGrand, maDefModel.mbColGrandTotals );
...@@ -1349,6 +1374,11 @@ sal_Int32 PivotTable::getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const ...@@ -1349,6 +1374,11 @@ sal_Int32 PivotTable::getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const
return mpPivotCache ? mpPivotCache->getCacheDatabaseIndex( nFieldIdx ) : -1; return mpPivotCache ? mpPivotCache->getCacheDatabaseIndex( nFieldIdx ) : -1;
} }
ScDPObject* PivotTable::getDPObject()
{
return mpDPObject;
}
// private -------------------------------------------------------------------- // private --------------------------------------------------------------------
PivotTableField* PivotTable::getTableField( sal_Int32 nFieldIdx ) PivotTableField* PivotTable::getTableField( sal_Int32 nFieldIdx )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment