From 3e0537a6e746db6ea746af6b91f94aeb9d2b05d9 Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Mon, 26 Jun 2023 11:35:38 +0200 Subject: tdf#156028 sc: use color of the highest value if only one value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (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 Tested-by: László Németh --- sc/qa/unit/data/xlsx/tdf156028.xlsx | Bin 0 -> 8251 bytes sc/qa/unit/subsequent_filters_test.cxx | 11 +++++++++++ sc/source/core/data/colorscale.cxx | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 sc/qa/unit/data/xlsx/tdf156028.xlsx 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 ScColorScaleFormat::GetColor( const ScAddress& rAddr ) cons calcMinMax(nMin, nMax); // this check is for safety - if(nMin >= nMax) + if(nMin > nMax) return std::optional(); ScColorScaleEntries::const_iterator itr = begin(); -- cgit