configure.ac                       |    2 -
 sc/inc/cellvalue.hxx               |    2 +
 sc/source/core/data/cellvalue.cxx  |   20 ++++++++++++++
 sc/source/core/data/column3.cxx    |   50 +++++++++++++++++++++++--------------
 sc/source/filter/excel/xestyle.cxx |    2 -
 5 files changed, 56 insertions(+), 20 deletions(-)

New commits:
commit 8bd0aae3af3478c38013a1d9403b6f9bb44abc28
Author:     Andras Timar <andras.ti...@collabora.com>
AuthorDate: Tue Nov 5 15:47:31 2024 +0100
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Nov 5 15:47:31 2024 +0100

    Bump version to 24.04.8.5
    
    Change-Id: I6447e6d77bcc8b0d7948d82679fc8250eb6712d4

diff --git a/configure.ac b/configure.ac
index cb869b768790..29f55de40efb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,7 +9,7 @@ dnl in order to create a configure script.
 # several non-alphanumeric characters, those are split off and used only for 
the
 # ABOUTBOXPRODUCTVERSIONSUFFIX in openoffice.lst. Why that is necessary, no 
idea.
 
-AC_INIT([Collabora Office],[24.04.8.4],[],[],[https://collaboraoffice.com/])
+AC_INIT([Collabora Office],[24.04.8.5],[],[],[https://collaboraoffice.com/])
 
 dnl libnumbertext needs autoconf 2.68, but that can pick up autoconf268 just 
fine if it is installed
 dnl whereas aclocal (as run by autogen.sh) insists on using autoconf and fails 
hard
commit 66db6b1fc314c81584236d43f7a6ef18742f2d7d
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Nov 4 14:24:26 2024 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Nov 5 15:38:33 2024 +0100

    tdf#163667 speed up spreadsheet with lots of cond formatting (II)
    
    Attempt to avoid the cost of GetCondResult when dealing with large runs
    of identical cells
    
    This restructures my caching code to increase the chance of hitting the
    cache.
    
    Change-Id: Ic83ff467be05fd645c80276708adb627c6b297d4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176007
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 1021846f3075..15c70f0bade3 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2725,8 +2725,10 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
 
     ScAddress aCell(GetCol(), 0, GetTab());
     ScDocument& rDoc = GetDoc();
+    // cache the output of GetCondResult
     const ScPatternAttr* pPrevPattern = nullptr;
     ScRefCellValue aPrevCellValue;
+    Color aPrevPatternColor;
     while (nRow1 <= nRow2)
     {
         aCell.SetRow(nRow1);
@@ -2738,27 +2740,26 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
 
         if (pPattern)
         {
-            // Speed up processing when dealing with runs of identical cells. 
We only
-            // care about collecting unique colors, so no need to process a 
cell if the result
-            // will be the same as the previous cell.
-            // Which we can only do if there is no conditional format to 
override the color on this cell.
-            if (!pCondFormat)
+            if 
(!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
             {
+                // Speed up processing when dealing with runs of identical 
cells. This avoids
+                // an expensive GetCondResult call.
                 ScRefCellValue aCellValue = GetCellValue(nRow1);
                 if (pPrevPattern == pPattern && aCellValue == aPrevCellValue)
                 {
-                    nRow1++;
-                    continue;
+                    aBackColor = aPrevPatternColor;
+                    bCondBackColor = true;
+                }
+                else
+                {
+                    const SfxItemSet* pCondSet = rDoc.GetCondResult(GetCol(), 
nRow1, GetTab());
+                    const SvxBrushItem* pBrush = 
&pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
+                    aBackColor = pBrush->GetColor();
+                    bCondBackColor = true;
+                    aPrevCellValue = aCellValue;
+                    pPrevPattern = pPattern;
+                    aPrevPatternColor = aBackColor;
                 }
-                aPrevCellValue = aCellValue;
-                pPrevPattern = pPattern;
-            }
-            if 
(!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
-            {
-                const SfxItemSet* pCondSet = rDoc.GetCondResult(GetCol(), 
nRow1, GetTab());
-                const SvxBrushItem* pBrush = 
&pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
-                aBackColor = pBrush->GetColor();
-                bCondBackColor = true;
             }
         }
 
@@ -2775,8 +2776,6 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
                     {
                         aBackColor = *oColor;
                         bCondBackColor = true;
-                        // we are overriding the color, so we need to clear 
the one-item cache.
-                        pPrevPattern = nullptr;
                     }
                 }
             }
commit bf4a16ce2fadb37019248fbff05d491dddd8deee
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Nov 1 11:39:58 2024 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Nov 5 15:38:33 2024 +0100

    tdf#163667 speed up spreadsheet with lots of cond formatting
    
    Attempt to avoid the cost of GetCondResult when dealing with large runs
    of identical cells
    
    Change-Id: If9192a9858e6785263ea1621e98d1b1d5de74c4c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175909
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx
index 6db9dee493cf..b40832d67521 100644
--- a/sc/inc/cellvalue.hxx
+++ b/sc/inc/cellvalue.hxx
@@ -128,6 +128,8 @@ public:
     ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos );
     ScRefCellValue( ScDocument& rDoc, const ScAddress& rPos, 
sc::ColumnBlockPosition& rBlockPos );
 
+    bool operator==(const ScRefCellValue&) const;
+
     void clear();
 
     CellType getType() const { return meType; }
diff --git a/sc/source/core/data/cellvalue.cxx 
b/sc/source/core/data/cellvalue.cxx
index 4330ea972992..b74b841a988f 100644
--- a/sc/source/core/data/cellvalue.cxx
+++ b/sc/source/core/data/cellvalue.cxx
@@ -685,4 +685,24 @@ bool ScRefCellValue::equalsWithoutFormat( const 
ScRefCellValue& r ) const
     return equalsWithoutFormatImpl(*this, r);
 }
 
+bool ScRefCellValue::operator==( const ScRefCellValue& r ) const
+{
+    if (meType != r.meType)
+        return false;
+
+    switch (meType)
+    {
+        case CELLTYPE_NONE:
+            return true;
+        case CELLTYPE_VALUE:
+            return mfValue == r.mfValue;
+        case CELLTYPE_STRING:
+            return mpString == r.mpString;
+        case CELLTYPE_FORMULA:
+            return equalsFormulaCells(getFormula(), r.getFormula());
+        default:
+            return false;
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 6fee9f85ff1c..1021846f3075 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2724,26 +2724,44 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
         return;
 
     ScAddress aCell(GetCol(), 0, GetTab());
+    ScDocument& rDoc = GetDoc();
+    const ScPatternAttr* pPrevPattern = nullptr;
+    ScRefCellValue aPrevCellValue;
     while (nRow1 <= nRow2)
     {
         aCell.SetRow(nRow1);
 
         Color aBackColor;
         bool bCondBackColor = false;
+        const ScPatternAttr* pPattern = rDoc.GetPattern(aCell.Col(), 
aCell.Row(), aCell.Tab());
+        ScConditionalFormat* pCondFormat = rDoc.GetCondFormat(aCell.Col(), 
aCell.Row(), aCell.Tab());
 
-        const ScPatternAttr* pPattern = GetDoc().GetPattern(aCell.Col(), 
aCell.Row(), aCell.Tab());
         if (pPattern)
         {
+            // Speed up processing when dealing with runs of identical cells. 
We only
+            // care about collecting unique colors, so no need to process a 
cell if the result
+            // will be the same as the previous cell.
+            // Which we can only do if there is no conditional format to 
override the color on this cell.
+            if (!pCondFormat)
+            {
+                ScRefCellValue aCellValue = GetCellValue(nRow1);
+                if (pPrevPattern == pPattern && aCellValue == aPrevCellValue)
+                {
+                    nRow1++;
+                    continue;
+                }
+                aPrevCellValue = aCellValue;
+                pPrevPattern = pPattern;
+            }
             if 
(!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
             {
-                const SfxItemSet* pCondSet = GetDoc().GetCondResult(GetCol(), 
nRow1, GetTab());
+                const SfxItemSet* pCondSet = rDoc.GetCondResult(GetCol(), 
nRow1, GetTab());
                 const SvxBrushItem* pBrush = 
&pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
                 aBackColor = pBrush->GetColor();
                 bCondBackColor = true;
             }
         }
 
-        ScConditionalFormat* pCondFormat = GetDoc().GetCondFormat(aCell.Col(), 
aCell.Row(), aCell.Tab());
         if (pCondFormat)
         {
             for (size_t nFormat = 0; nFormat < pCondFormat->size(); nFormat++)
@@ -2757,6 +2775,8 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
                     {
                         aBackColor = *oColor;
                         bCondBackColor = true;
+                        // we are overriding the color, so we need to clear 
the one-item cache.
+                        pPrevPattern = nullptr;
                     }
                 }
             }
@@ -2764,7 +2784,7 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
 
         if (!bCondBackColor)
         {
-            const SvxBrushItem* pBrush = GetDoc().GetAttr(aCell, 
ATTR_BACKGROUND);
+            const SvxBrushItem* pBrush = rDoc.GetAttr(aCell, ATTR_BACKGROUND);
             aBackColor = pBrush->GetColor();
         }
 
commit 89925893b72f8b37640c600e21d80ac4150d5540
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Fri Nov 1 10:14:23 2024 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Nov 5 15:38:33 2024 +0100

    fix GetBackColorFilterEntries missing colors
    
    Because the bCondBackColor var is outside the loop, once it is set to
    true, it stays true for the remainder of the loop, which means we might
    miss picking up a new background color.
    
    ever since
        commit 8b2369236dea7d6863c2df3d4ce5e356c9c8010c
        Author: Henry Castro <hcas...@collabora.com>
        Date:   Thu Nov 23 11:49:15 2023 -0400
        sc: fix back color filter entries
    
    Change-Id: I85625941fcd67fac7aabc24d43b2a56999e337db
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175896
    Tested-by: Jenkins
    Reviewed-by: Henry Castro <hcas...@collabora.com>
    (cherry picked from commit 6768924eebc3e6bc731c69e9a3a53781e0cb6f8f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175908
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index d7302133642a..6fee9f85ff1c 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2720,35 +2720,30 @@ void ScColumn::GetFilterEntries(
 
 void ScColumn::GetBackColorFilterEntries(SCROW nRow1, SCROW nRow2, 
ScFilterEntries& rFilterEntries)
 {
-    Color aBackColor;
-    bool bCondBackColor = false;
-    ScAddress aCell(GetCol(), 0, GetTab());
-    ScConditionalFormat* pCondFormat = nullptr;
-
-    const SfxItemSet* pCondSet = nullptr;
-    const SvxBrushItem* pBrush = nullptr;
-    const ScPatternAttr* pPattern = nullptr;
-    const ScColorScaleFormat* pColFormat = nullptr;
-
     if (!GetDoc().ValidRow(nRow1) || !GetDoc().ValidRow(nRow2))
         return;
 
+    ScAddress aCell(GetCol(), 0, GetTab());
     while (nRow1 <= nRow2)
     {
         aCell.SetRow(nRow1);
-        pPattern = GetDoc().GetPattern(aCell.Col(), aCell.Row(), aCell.Tab());
+
+        Color aBackColor;
+        bool bCondBackColor = false;
+
+        const ScPatternAttr* pPattern = GetDoc().GetPattern(aCell.Col(), 
aCell.Row(), aCell.Tab());
         if (pPattern)
         {
             if 
(!pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData().empty())
             {
-                pCondSet = GetDoc().GetCondResult(GetCol(), nRow1, GetTab());
-                pBrush = &pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
+                const SfxItemSet* pCondSet = GetDoc().GetCondResult(GetCol(), 
nRow1, GetTab());
+                const SvxBrushItem* pBrush = 
&pPattern->GetItem(ATTR_BACKGROUND, pCondSet);
                 aBackColor = pBrush->GetColor();
                 bCondBackColor = true;
             }
         }
 
-        pCondFormat = GetDoc().GetCondFormat(aCell.Col(), aCell.Row(), 
aCell.Tab());
+        ScConditionalFormat* pCondFormat = GetDoc().GetCondFormat(aCell.Col(), 
aCell.Row(), aCell.Tab());
         if (pCondFormat)
         {
             for (size_t nFormat = 0; nFormat < pCondFormat->size(); nFormat++)
@@ -2756,7 +2751,7 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
                 auto aEntry = pCondFormat->GetEntry(nFormat);
                 if (aEntry->GetType() == ScFormatEntry::Type::Colorscale)
                 {
-                    pColFormat = static_cast<const 
ScColorScaleFormat*>(aEntry);
+                    const ScColorScaleFormat* pColFormat = static_cast<const 
ScColorScaleFormat*>(aEntry);
                     std::optional<Color> oColor = pColFormat->GetColor(aCell);
                     if (oColor)
                     {
@@ -2769,7 +2764,7 @@ void ScColumn::GetBackColorFilterEntries(SCROW nRow1, 
SCROW nRow2, ScFilterEntri
 
         if (!bCondBackColor)
         {
-            pBrush = GetDoc().GetAttr(aCell, ATTR_BACKGROUND);
+            const SvxBrushItem* pBrush = GetDoc().GetAttr(aCell, 
ATTR_BACKGROUND);
             aBackColor = pBrush->GetColor();
         }
 
commit 99368afd9a526529a42d4581addee49d352e3f45
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Oct 29 13:00:27 2024 +0200
Commit:     Andras Timar <andras.ti...@collabora.com>
CommitDate: Tue Nov 5 15:38:33 2024 +0100

    fix bug in XclExpXF::Init (tdf#163667 related)
    
    looks like a copy/paste error from
       commit d0f8daa0980ba8e403b32006831657c5a0a4ea17
        Author: Eike Rathke <er...@redhat.com>
        Date:   Wed Aug 22 13:16:19 2018 +0200
    Resolves: tdf#73063 preserve and roundtrip LCID from/to Excel number
    formats
    
    Found while debugging the file in the associated bug.
    
    Change-Id: I6816290c90d6271f43416a7417cb2a0341da928c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175753
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sc/source/filter/excel/xestyle.cxx 
b/sc/source/filter/excel/xestyle.cxx
index 678327bd1a58..94ab1c1049cd 100644
--- a/sc/source/filter/excel/xestyle.cxx
+++ b/sc/source/filter/excel/xestyle.cxx
@@ -2144,7 +2144,7 @@ void XclExpXF::Init( const SfxItemSet& rItemSet, 
sal_Int16 nScript,
 
     // number format
     if (nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND)
-        mnXclNumFmt = nForceScNumFmt;
+        mnScNumFmt = nForceScNumFmt;
     else
     {
         // Built-in formats of dedicated languages may be attributed using the

Reply via email to