summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-06-24 11:30:51 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-06-27 01:09:58 +0200
commitd3b96c7b7b691ae3853b72b99a1fcf5153ca5120 (patch)
treeb8064589c5de7a688d764b43a88def2622a07601 /sc/source
parent02baf894051b49b92fb2fd54ab4638c7d610f373 (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/source')
-rw-r--r--sc/source/filter/oox/pivottablebuffer.cxx12
1 files changed, 12 insertions, 0 deletions
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 );
}