From 6c9337ecce749ab2769ed1986d05dbb37e2e3fab Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Sat, 9 Apr 2016 08:17:17 +0200 Subject: add test case for tdf#98554 Change-Id: I7437a1ed8dd915411f6014bc01d4224fe5604f1d --- sc/qa/unit/data/xlsx/cond_format_theme_color3.xlsx | Bin 0 -> 8530 bytes sc/qa/unit/subsequent_filters-test.cxx | 56 +++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 sc/qa/unit/data/xlsx/cond_format_theme_color3.xlsx (limited to 'sc') diff --git a/sc/qa/unit/data/xlsx/cond_format_theme_color3.xlsx b/sc/qa/unit/data/xlsx/cond_format_theme_color3.xlsx new file mode 100644 index 000000000000..2e97684d7880 Binary files /dev/null and b/sc/qa/unit/data/xlsx/cond_format_theme_color3.xlsx differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 8106d2166b75..720cdfefb82c 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -141,6 +141,7 @@ public: void testNewCondFormatXLSX(); void testCondFormatThemeColorXLSX(); void testCondFormatThemeColor2XLSX(); // negative bar color and axis color + void testCondFormatThemeColor3XLSX(); // theme index 2 and 3 are switched void testComplexIconSetsXLSX(); void testCondFormatParentXLSX(); void testColorScaleNumWithRefXLSX(); @@ -259,6 +260,7 @@ public: CPPUNIT_TEST(testNewCondFormatXLSX); CPPUNIT_TEST(testCondFormatThemeColorXLSX); CPPUNIT_TEST(testCondFormatThemeColor2XLSX); + CPPUNIT_TEST(testCondFormatThemeColor3XLSX); CPPUNIT_TEST(testComplexIconSetsXLSX); CPPUNIT_TEST(testCondFormatParentXLSX); CPPUNIT_TEST(testColorScaleNumWithRefXLSX); @@ -2472,6 +2474,60 @@ void ScFiltersTest::testCondFormatThemeColor2XLSX() namespace { +void checkDatabarPositiveColor(ScConditionalFormat* pFormat, const Color& rColor) +{ + CPPUNIT_ASSERT(pFormat); + const ScFormatEntry* pEntry = pFormat->GetEntry(0); + CPPUNIT_ASSERT(pEntry); + CPPUNIT_ASSERT_EQUAL(pEntry->GetType(), condformat::DATABAR); + const ScDataBarFormat* pDataBar = static_cast(pEntry); + const ScDataBarFormatData* pDataBarFormatData = pDataBar->GetDataBarData(); + + CPPUNIT_ASSERT_EQUAL(rColor, pDataBarFormatData->maPositiveColor); +} + +} + +void ScFiltersTest::testCondFormatThemeColor3XLSX() +{ + ScDocShellRef xDocSh = ScBootstrapFixture::loadDoc("cond_format_theme_color3.", FORMAT_XLSX); + + CPPUNIT_ASSERT_MESSAGE("Failed to load document", xDocSh.Is()); + + ScDocument& rDoc = xDocSh->GetDocument(); + ScConditionalFormat* pFormat = rDoc.GetCondFormat(1, 3, 0); + CPPUNIT_ASSERT(pFormat); + const ScFormatEntry* pEntry = pFormat->GetEntry(0); + CPPUNIT_ASSERT(pEntry); + CPPUNIT_ASSERT_EQUAL(pEntry->GetType(), condformat::COLORSCALE); + const ScColorScaleFormat* pColorScale = static_cast(pEntry); + + CPPUNIT_ASSERT_EQUAL(size_t(2), pColorScale->size()); + const ScColorScaleEntry* pColorScaleEntry = pColorScale->GetEntry(0); + CPPUNIT_ASSERT(pColorScaleEntry); + CPPUNIT_ASSERT_EQUAL(Color(175, 171, 171), pColorScaleEntry->GetColor()); + + pColorScaleEntry = pColorScale->GetEntry(1); + CPPUNIT_ASSERT(pColorScaleEntry); + CPPUNIT_ASSERT_EQUAL(Color(51, 63, 80), pColorScaleEntry->GetColor()); + + pFormat = rDoc.GetCondFormat(3, 3, 0); + checkDatabarPositiveColor(pFormat, Color(59, 56, 56)); + + pFormat = rDoc.GetCondFormat(5, 3, 0); + checkDatabarPositiveColor(pFormat, Color(173, 185, 202)); + + pFormat = rDoc.GetCondFormat(7, 3, 0); + checkDatabarPositiveColor(pFormat, Color(89, 89, 89)); + + pFormat = rDoc.GetCondFormat(9, 3, 0); + checkDatabarPositiveColor(pFormat, Color(217, 217, 217)); + + xDocSh->DoClose(); +} + +namespace { + void testComplexIconSetsXLSX_Impl(ScDocument& rDoc, SCCOL nCol, ScIconSetType eType) { ScConditionalFormat* pFormat = rDoc.GetCondFormat(nCol, 1, 0); -- cgit v1.2.3