summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/source/filter/oox/pivottablebuffer.cxx12
2 files changed, 13 insertions, 1 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7bd27c6b95fa..2ad14c05fc9b 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -2557,7 +2557,7 @@ public:
*/
void UnshareFormulaCells( SCTAB nTab, SCCOL nCol, std::vector<SCROW>& rRows );
void RegroupFormulaCells( SCTAB nTab, SCCOL nCol );
- void RegroupFormulaCells( const ScRange& range );
+ SC_DLLPUBLIC void RegroupFormulaCells( const ScRange& range );
formula::FormulaTokenRef ResolveStaticReference( const ScAddress& rPos );
formula::FormulaTokenRef ResolveStaticReference( const ScRange& rRange );
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx b/sc/source/filter/oox/pivottablebuffer.cxx
index 6d73e26928a9..71ecbb49f947 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -1459,6 +1459,18 @@ PivotTable& PivotTableBuffer::createPivotTable()
void PivotTableBuffer::finalizeImport()
{
+ if(maTables.empty())
+ return;
+
+ // Create formula groups. This needs to be done before pivot tables, because
+ // import may lead to calling ScDPObject::GetSource(), which calls ScDPObject::CreateObjects(),
+ // which will ensure all the cells are not dirty, causing recalculation even though
+ // ScDPObject::GetSource() doesn't need it. And the recalculation is slower without formula
+ // groups set up. Fixing that properly seems quite complex, given that do-everything approach
+ // of ScDPObject, so at least ensure the calculation is efficient.
+ ScDocument& rDoc = getDocImport().getDoc();
+ rDoc.RegroupFormulaCells( ScRange( 0, 0, 0, rDoc.MaxCol(), rDoc.MaxRow(), rDoc.GetMaxTableNumber()));
+
maTables.forEachMem( &PivotTable::finalizeImport );
}