From f9f53c4a8c9e1cd2fa1a9f48576b09f1bfd023ae Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 16 Apr 2015 02:22:41 +0200 Subject: support tint for databar and colorscale colors, related tdf#90511 Change-Id: I59b00ab856583ed08f70c9c90469bbb44cb5782a --- sc/source/filter/inc/condformatbuffer.hxx | 4 ++-- sc/source/filter/oox/condformatbuffer.cxx | 40 ++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx index c3154ea6cdc4..31ae39ab0295 100644 --- a/sc/source/filter/inc/condformatbuffer.hxx +++ b/sc/source/filter/inc/condformatbuffer.hxx @@ -224,9 +224,9 @@ struct ExCfRuleModel bool mbGradient; OUString maAxisPosition; // AxisColor - sal_Int32 mnAxisColor; + sal_uInt32 mnAxisColor; // NegativeFillColor - sal_Int32 mnNegativeColor; + sal_uInt32 mnNegativeColor; // Cfvo bool mbIsLower; OUString maColorScaleType; diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 1992d3cc5131..7e0a0f5a1194 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -161,29 +161,42 @@ void ColorScaleRule::importCfvo( const AttributeList& rAttribs ) namespace { -::Color RgbToRgbComponents( sal_Int32& nRgb ) +::Color ARgbToARgbComponents( sal_uInt32& nRgb ) { + sal_Int32 ornA = 255 - ((nRgb >> 24) & 0xFF); sal_Int32 ornR = (nRgb >> 16) & 0xFF; sal_Int32 ornG = (nRgb >> 8) & 0xFF; sal_Int32 ornB = nRgb & 0xFF; - return ::Color(ornR, ornG, ornB); + return ::Color(ornA, ornR, ornG, ornB); } } void ColorScaleRule::importColor( const AttributeList& rAttribs ) { - sal_Int32 nColor = 0; + sal_uInt32 nColor = 0; if( rAttribs.hasAttribute( XML_rgb ) ) nColor = rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT ); else if( rAttribs.hasAttribute( XML_theme ) ) { sal_uInt32 nThemeIndex = rAttribs.getUnsigned( XML_theme, 0 ); nColor = getTheme().getColorByIndex( nThemeIndex ); + } - ::Color aColor = RgbToRgbComponents( nColor ); + ::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 ); if(mnCol >= maColorScaleRuleEntries.size()) maColorScaleRuleEntries.push_back(ColorScaleRuleModelEntry()); @@ -239,7 +252,7 @@ DataBarRule::DataBarRule( const CondFormat& rFormat ): void DataBarRule::importColor( const AttributeList& rAttribs ) { - sal_Int32 nColor = 0; + sal_uInt32 nColor = 0; if( rAttribs.hasAttribute( XML_rgb ) ) nColor = rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT ); else if( rAttribs.hasAttribute( XML_theme ) ) @@ -248,7 +261,18 @@ void DataBarRule::importColor( const AttributeList& rAttribs ) nColor = getTheme().getColorByIndex( nThemeIndex ); } - ::Color aColor = RgbToRgbComponents( nColor ); + ::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 ); mxFormat->maPositiveColor = aColor; } @@ -1119,13 +1143,13 @@ void ExtCfRule::finalizeImport() case AXISCOLOR: { ScDataBarFormatData* pDataBar = mpTarget; - pDataBar->maAxisColor = RgbToRgbComponents(maModel.mnAxisColor); + pDataBar->maAxisColor = ARgbToARgbComponents(maModel.mnAxisColor); break; } case NEGATIVEFILLCOLOR: { ScDataBarFormatData* pDataBar = mpTarget; - pDataBar->mpNegativeColor.reset( new ::Color( RgbToRgbComponents(maModel.mnNegativeColor) ) ); + pDataBar->mpNegativeColor.reset( new ::Color( ARgbToARgbComponents(maModel.mnNegativeColor) ) ); pDataBar->mbNeg = true; break; } -- cgit v1.2.3