summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTibor Nagy <nagy.tibor2@nisz.hu>2023-06-26 11:35:38 +0200
committerLászló Németh <nemeth@numbertext.org>2023-06-27 14:09:27 +0200
commit3e0537a6e746db6ea746af6b91f94aeb9d2b05d9 (patch)
treea7a3d973f310a110c1bc1103b24cf943696d895c
parentFix typo (diff)
downloadcore-3e0537a6e746db6ea746af6b91f94aeb9d2b05d9.tar.gz
core-3e0537a6e746db6ea746af6b91f94aeb9d2b05d9.zip
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 <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sc/qa/unit/data/xlsx/tdf156028.xlsxbin0 -> 8251 bytes
-rw-r--r--sc/qa/unit/subsequent_filters_test.cxx11
-rw-r--r--sc/source/core/data/colorscale.cxx2
3 files changed, 12 insertions, 1 deletions
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
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/tdf156028.xlsx
Binary files 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();