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:
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)
......
......@@ -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;
......
......@@ -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.
......
......@@ -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 )
......
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