sc/qa/unit/data/xlsx/cond_format_theme_color3.xlsx |binary sc/qa/unit/subsequent_filters-test.cxx | 56 +++++++++++++++++++++ sc/source/filter/oox/condformatbuffer.cxx | 31 +++-------- 3 files changed, 64 insertions(+), 23 deletions(-)
New commits: commit 6c9337ecce749ab2769ed1986d05dbb37e2e3fab Author: Markus Mohrhard <[email protected]> Date: Sat Apr 9 08:17:17 2016 +0200 add test case for tdf#98554 Change-Id: I7437a1ed8dd915411f6014bc01d4224fe5604f1d 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 0000000..2e97684 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 8106d21..720cdfe 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<const ScDataBarFormat*>(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<const ScColorScaleFormat*>(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); commit a86f37c5182d11d8f43a8b173d0d4dcea4be42c4 Author: Markus Mohrhard <[email protected]> Date: Sat Apr 9 08:16:01 2016 +0200 use the better color import method also for databars, tdf#98554 Ideally we would move some of the magic here into the ThemeBuffer class but this requires a lot more test cases. Change-Id: I29adadda6b40cd1863ad3d68554acf7f27c57900 diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 6e8239b..1c6b5ba 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -287,27 +287,9 @@ DataBarRule::DataBarRule( const CondFormat& rFormat ): void DataBarRule::importColor( const AttributeList& rAttribs ) { - sal_uInt32 nColor = 0; - if( rAttribs.hasAttribute( XML_rgb ) ) - nColor = rAttribs.getUnsignedHex( XML_rgb, UNSIGNED_RGB_TRANSPARENT ); - else if( rAttribs.hasAttribute( XML_theme ) ) - { - sal_uInt32 nThemeIndex = rAttribs.getUnsigned( XML_theme, 0 ); - nColor = getTheme().getColorByIndex( nThemeIndex ); - } - - ::Color aColor; - double nTint = rAttribs.getDouble(XML_tint, 0.0); - if (nTint != 0.0) - { - oox::drawingml::Color aDMColor; - aDMColor.setSrgbClr(nColor); - aDMColor.addExcelTintTransformation(nTint); - nColor = aDMColor.getColor(getBaseFilter().getGraphicHelper()); - aColor = ::Color(nColor); - } - else - aColor = ARgbToARgbComponents( nColor ); + ThemeBuffer& rThemeBuffer = getTheme(); + GraphicHelper& rGraphicHelper = getBaseFilter().getGraphicHelper(); + ::Color aColor = importOOXColor(rAttribs, rThemeBuffer, rGraphicHelper); mxFormat->maPositiveColor = aColor; } commit 5639909d59b158708305ce3b2e6afe3760032e84 Author: Markus Mohrhard <[email protected]> Date: Sat Apr 9 07:51:31 2016 +0200 work around Excel theme color bug, tdf#98554 Change-Id: Id0cd37b37394a0759ee6ffccafd8def719c14312 diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 1e61d32..6e8239b 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -194,14 +194,17 @@ namespace { { sal_uInt32 nThemeIndex = rAttribs.getUnsigned( XML_theme, 0 ); - // looks like an Excel bug + // Excel has a bug in the mapping of index 0, 1, 2 and 3. if (nThemeIndex == 0) nThemeIndex = 1; else if (nThemeIndex == 1) nThemeIndex = 0; + else if (nThemeIndex == 2) + nThemeIndex = 3; + else if (nThemeIndex == 3) + nThemeIndex = 2; nColor = rThemeBuffer.getColorByIndex( nThemeIndex ); - } ::Color aColor; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
