sc/inc/document.hxx                       |    2 +-
 sc/source/core/data/queryevaluator.cxx    |    3 +--
 sc/source/filter/oox/pivottablebuffer.cxx |   12 ++++++++++++
 3 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit bbb44bba687d742392a208a81bd1181929caea9f
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Fri Jun 24 14:59:19 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Mon Jun 27 01:10:16 2022 +0200

    rEntry.bDoQuery is always true for processed entries
    
    As can be seen at the beginning of ScQueryEvaluator::ValidQuery()
    in the for loop condition. Comes from 4fd1333ba4bb4f2311e909829,
    and I'm not quite sure if the passed value is really supposed
    to be always true or if it's a mistake.
    
    Change-Id: I44bde5d50ac70332d6e48ee583ffed13e664cd61
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136396
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>
    (cherry picked from commit 10b638e361fd0971e68c24ff3be8ef91ecfad903)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136433

diff --git a/sc/source/core/data/queryevaluator.cxx 
b/sc/source/core/data/queryevaluator.cxx
index 93b2960a489f..d7fdf79237ae 100644
--- a/sc/source/core/data/queryevaluator.cxx
+++ b/sc/source/core/data/queryevaluator.cxx
@@ -330,8 +330,7 @@ OUString ScQueryEvaluator::getCellString(const 
ScRefCellValue& rCell, SCROW nRow
                   : mrTab.GetNumberFormat(static_cast<SCCOL>(rEntry.nField), 
nRow);
         SvNumberFormatter* pFormatter
             = mpContext ? mpContext->GetFormatTable() : mrDoc.GetFormatTable();
-        return ScCellFormat::GetInputString(rCell, nFormat, *pFormatter, 
mrDoc, sharedString,
-                                            rEntry.bDoQuery);
+        return ScCellFormat::GetInputString(rCell, nFormat, *pFormatter, 
mrDoc, sharedString, true);
     }
 }
 
commit d3b96c7b7b691ae3853b72b99a1fcf5153ca5120
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: Mon Jun 27 01:09:58 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>
    (cherry picked from commit 39f893df5076db615ee8a3d4dca7bd3ec23d8bf5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136432
    Tested-by: Jenkins

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 );
 }
 

Reply via email to