sc/source/core/data/column3.cxx |   23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 6e2993e1a7a61d69717b3fcf93ffa52fa0f26ba9
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Thu Apr 27 13:58:26 2023 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Thu Jun 1 13:05:13 2023 +0200

    tdf#153972 Fix color filter when cells have no content
    
    Change-Id: I9742fc0627c2311bfe4c067961e0feea476f1899
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151096
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index 5e1e66be1eca..eb478fd2a462 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -2566,7 +2566,7 @@ class FilterEntriesHandler
     bool mbFiltering;
     bool mbFilteredRow;
 
-    void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& 
rCell)
+    void processCell(const ScColumn& rColumn, SCROW nRow, ScRefCellValue& 
rCell, bool bIsEmptyCell=false)
     {
         SvNumberFormatter* pFormatter = mrColumn.GetDoc().GetFormatTable();
         sal_uLong nFormat = 
mrColumn.GetNumberFormat(mrColumn.GetDoc().GetNonThreadedContext(), nRow);
@@ -2580,6 +2580,16 @@ class FilterEntriesHandler
             
mrFilterEntries.addBackgroundColor(pTable->GetCellBackgroundColor(aPos));
         }
 
+        if (bIsEmptyCell)
+        {
+            if (!mrFilterEntries.mbHasEmpties)
+            {
+                mrFilterEntries.push_back(ScTypedStrData(OUString()));
+                mrFilterEntries.mbHasEmpties = true;
+            }
+            return;
+        }
+
         if (rCell.hasString())
         {
             mrFilterEntries.push_back(ScTypedStrData(std::move(aStr), 0.0, 
0.0, ScTypedStrData::Standard, false, mbFilteredRow));
@@ -2675,17 +2685,8 @@ public:
 
     void operator() (const int nElemType, size_t nRow, size_t /* nDataSize */)
     {
-        if ( nElemType == sc::element_type_empty )
-        {
-            if (!mrFilterEntries.mbHasEmpties)
-            {
-                mrFilterEntries.push_back(ScTypedStrData(OUString()));
-                mrFilterEntries.mbHasEmpties = true;
-            }
-            return;
-        }
         ScRefCellValue aCell = mrColumn.GetCellValue(nRow);
-        processCell(mrColumn, nRow, aCell);
+        processCell(mrColumn, nRow, aCell, nElemType == 
sc::element_type_empty);
     }
 };
 

Reply via email to