summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2016-10-09 07:46:06 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2016-10-09 20:20:58 +0200
commitdb481dd30521f9ce498873cdc945cf9544bf983c (patch)
tree2099be10fdbfca8e2275a9e8a9affbaf6a3aa501 /sc/source
parent89bde37004c7777910d92b73e0ba7223c3bfe575 (diff)
Pivot table XLSX import: PivotCache is not handled as a const object.
Change-Id: I226902205e977deb1a4a73db33e3bf7671067bc8
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/filter/inc/pivotcachebuffer.hxx1
-rw-r--r--sc/source/filter/inc/pivottablebuffer.hxx5
-rw-r--r--sc/source/filter/oox/pivotcachebuffer.cxx5
-rw-r--r--sc/source/filter/oox/pivottablebuffer.cxx11
4 files changed, 17 insertions, 5 deletions
diff --git a/sc/source/filter/inc/pivotcachebuffer.hxx b/sc/source/filter/inc/pivotcachebuffer.hxx
index 3bf5406c62f3..6b35a11ffa07 100644
--- a/sc/source/filter/inc/pivotcachebuffer.hxx
+++ b/sc/source/filter/inc/pivotcachebuffer.hxx
@@ -405,6 +405,7 @@ public:
/** Returns the number of pivot cache fields. */
sal_Int32 getCacheFieldCount() const;
/** Returns the cache field with the specified index. */
+ PivotCacheField* getCacheField( sal_Int32 nFieldIdx );
const PivotCacheField* getCacheField( sal_Int32 nFieldIdx ) const;
/** Returns the source column index of the field with the passed index. */
sal_Int32 getCacheDatabaseIndex( sal_Int32 nFieldIdx ) const;
diff --git a/sc/source/filter/inc/pivottablebuffer.hxx b/sc/source/filter/inc/pivottablebuffer.hxx
index 37ee04edf586..dfe52206ad6f 100644
--- a/sc/source/filter/inc/pivottablebuffer.hxx
+++ b/sc/source/filter/inc/pivottablebuffer.hxx
@@ -175,7 +175,7 @@ private:
PivotTable& mrPivotTable; /// The parent pivot table object.
ItemModelVector maItems; /// All items of this field.
PTFieldModel maModel; /// Pivot field settings.
- OUString maDPFieldName; /// Name of the field in DataPilot field collection.
+ OUString maDPFieldName; /// Name of the field in DataPilot field collection.
sal_Int32 mnFieldIndex; /// Zero-based index of this field.
};
@@ -338,6 +338,7 @@ public:
getDataLayoutField() const;
/** Returns the cache field with the specified index. */
+ PivotCacheField* getCacheField( sal_Int32 nFieldIdx );
const PivotCacheField* getCacheField( sal_Int32 nFieldIdx ) const;
/** Returns the base cache field of the data field item with the specified index. */
const PivotCacheField* getCacheFieldOfDataField( sal_Int32 nDataItemIdx ) const;
@@ -373,7 +374,7 @@ private:
PivotTableFilterVector maFilters; /// All field filters.
PTDefinitionModel maDefModel; /// Global pivot table settings.
PTLocationModel maLocationModel; /// Location settings of the pivot table.
- const PivotCache* mpPivotCache; /// The pivot cache this table is based on.
+ PivotCache* mpPivotCache; /// The pivot cache this table is based on.
css::uno::Reference< css::sheet::XDataPilotDescriptor >
mxDPDescriptor; /// Descriptor of the DataPilot object.
};
diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx
index a9e59cefcd83..56632e7cbe31 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -1250,6 +1250,11 @@ sal_Int32 PivotCache::getCacheFieldCount() const
return static_cast< sal_Int32 >( maFields.size() );
}
+PivotCacheField* PivotCache::getCacheField( sal_Int32 nFieldIdx )
+{
+ return maFields.get( nFieldIdx ).get();
+}
+
const PivotCacheField* PivotCache::getCacheField( sal_Int32 nFieldIdx ) const
{
return maFields.get( nFieldIdx ).get();
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx
index bc3c05ce8c82..99b80b97231c 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -439,7 +439,7 @@ void PivotTableField::finalizeParentGroupingImport( const Reference< XDataPilotF
{
if( maDPFieldName.isEmpty() ) // prevent endless loops if file format is broken
{
- if( const PivotCacheField* pCacheField = mrPivotTable.getCacheField( mnFieldIndex ) )
+ if( PivotCacheField* pCacheField = mrPivotTable.getCacheField( mnFieldIndex ) )
{
// data field can have user defined groupname captions, apply them
// if they do
@@ -449,9 +449,9 @@ void PivotTableField::finalizeParentGroupingImport( const Reference< XDataPilotF
if ( aIt->mnType == XML_data && aIt->msCaption.getLength() )
captionList.push_back( IdCaptionPair( aIt->mnCacheItem, aIt->msCaption ) );
}
- // #FIXME find another way out of this const nightmare prison
if ( !captionList.empty() )
- const_cast<PivotCacheField*>( pCacheField )->applyItemCaptions( captionList );
+ pCacheField->applyItemCaptions( captionList );
+
maDPFieldName = pCacheField->createParentGroupField( rxBaseDPField, rBaseCacheField, orItemNames );
// on success, try to create nested group fields
Reference< XDataPilotField > xDPField = mrPivotTable.getDataPilotField( maDPFieldName );
@@ -1300,6 +1300,11 @@ Reference< XDataPilotField > PivotTable::getDataLayoutField() const
return xDPField;
}
+PivotCacheField* PivotTable::getCacheField( sal_Int32 nFieldIdx )
+{
+ return mpPivotCache ? mpPivotCache->getCacheField( nFieldIdx ) : nullptr;
+}
+
const PivotCacheField* PivotTable::getCacheField( sal_Int32 nFieldIdx ) const
{
return mpPivotCache ? mpPivotCache->getCacheField( nFieldIdx ) : nullptr;