diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-06-24 11:30:51 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-06-27 01:09:58 +0200 |
commit | d3b96c7b7b691ae3853b72b99a1fcf5153ca5120 (patch) | |
tree | b8064589c5de7a688d764b43a88def2622a07601 /sc | |
parent | 02baf894051b49b92fb2fd54ab4638c7d610f373 (diff) |
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.lunak@collabora.com>
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit 39f893df5076db615ee8a3d4dca7bd3ec23d8bf5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136432
Tested-by: Jenkins
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/pivottablebuffer.cxx | 12 |
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 ); } |