sc/inc/document.hxx | 2 +- sc/source/filter/oox/pivottablebuffer.cxx | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
New commits: commit 5a9c4fc41ec42161ff89c946248f03f16fae7d24 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Fri Jun 24 11:30:51 2022 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Sun Jun 26 20:26:13 2022 +0200 more efficient recalculations from xlsx import of pivot tables The import of pivot tables in xlsx triggers recalculations, even though it's not necessary. Fixing that properly seems complex given how ScDPObject is designed, so at least ensure the calculation is efficient (formula grouping is otherwise done only after pivot table import). This can especially noticeable for formulas where groups make a big difference (e.g. COUNTIFS uses ScSortedRangeCache only for formula groups). Change-Id: I8dbdf854880707a9707cdc9dc3d73fc1d6b6b000 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136362 Tested-by: Luboš Luňák <l.lu...@collabora.com> Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index cf9be32b9332..959960e15e03 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 ); }