sc/qa/unit/data/xlsx/tdf156028.xlsx    |binary
 sc/qa/unit/subsequent_filters_test.cxx |   11 +++++++++++
 sc/source/core/data/colorscale.cxx     |    2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 3e0537a6e746db6ea746af6b91f94aeb9d2b05d9
Author:     Tibor Nagy <nagy.tib...@nisz.hu>
AuthorDate: Mon Jun 26 11:35:38 2023 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Jun 27 14:09:27 2023 +0200

    tdf#156028 sc: use color of the highest value if only one value
    
    (in a single cell or the same value repeating in all cells of the
    data set) on percentile color scale, like other spreadsheets do.
    
    This is a follow up to commit 6a059f8d1b0a7a5b64bd272e1e7b8291979bcd56
    (tdf#155321 sc: fix color of the highest value on percentile color scale
    if the highest value occurs multiple times in the data set.)
    
    Change-Id: I630df332e403705e8338e3441af093c2de95c280
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153577
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: László Németh <nem...@numbertext.org>

diff --git a/sc/qa/unit/data/xlsx/tdf156028.xlsx 
b/sc/qa/unit/data/xlsx/tdf156028.xlsx
new file mode 100644
index 000000000000..6fc2fc814fe3
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf156028.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters_test.cxx 
b/sc/qa/unit/subsequent_filters_test.cxx
index f633073c85f9..d02ebc075e3e 100644
--- a/sc/qa/unit/subsequent_filters_test.cxx
+++ b/sc/qa/unit/subsequent_filters_test.cxx
@@ -134,6 +134,17 @@ CPPUNIT_TEST_FIXTURE(ScFiltersTest, 
testTdf155321_CondFormatColor_XLSX)
     CPPUNIT_ASSERT_EQUAL(Color(99, 190, 123), aColor);
 }
 
+CPPUNIT_TEST_FIXTURE(ScFiltersTest, testTdf156028_ColorScale_XLSX)
+{
+    createScDoc("xlsx/tdf156028.xlsx");
+
+    ScDocument* pDoc = getScDoc();
+    ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(0, 0, 0);
+    ScRefCellValue aCellA1(*pDoc, ScAddress(0, 0, 0));
+    Color aColor = pCondFormat->GetData(aCellA1, ScAddress(0, 0, 
0)).mxColorScale.value();
+    CPPUNIT_ASSERT_EQUAL(Color(99, 190, 123), aColor);
+}
+
 CPPUNIT_TEST_FIXTURE(ScFiltersTest, testTdf138601_CondFormatXLSX)
 {
     createScDoc("xlsx/tdf138601.xlsx");
diff --git a/sc/source/core/data/colorscale.cxx 
b/sc/source/core/data/colorscale.cxx
index 4e61dbdbc228..20ea2b5186f6 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -647,7 +647,7 @@ std::optional<Color> ScColorScaleFormat::GetColor( const 
ScAddress& rAddr ) cons
     calcMinMax(nMin, nMax);
 
     // this check is for safety
-    if(nMin >= nMax)
+    if(nMin > nMax)
         return std::optional<Color>();
 
     ScColorScaleEntries::const_iterator itr = begin();

Reply via email to