summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorNoel <noel.grandin@collabora.co.uk>2021-01-15 14:49:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-01-16 10:07:07 +0100
commit63a68064bb33f180b8a231f7524d99405d910226 (patch)
tree7ecf05b057c5ca4d80a48af045998a4b34484561 /chart2
parentd534a4c7b45ff254b339e806c6a11f13d9ff0043 (diff)
make the Color constructors explicitly specify transparency
to reduce the churn, we leave the existing constructor in place, and add a clang plugin to detect when the value passed to the existing constructor may contain transparency/alpha data. i.e. we leave expressions like Color(0xffffff) alone, but warn about any non-constant expression, and any expression like Color(0xff000000) Change-Id: Id2ce58e08882d9b7bd0b9f88eca97359dcdbcc8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109362 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/dialogs/DataBrowser.cxx8
-rw-r--r--chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx4
-rw-r--r--chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx2
-rw-r--r--chart2/source/controller/main/ChartController_Tools.cxx2
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.cxx2
-rw-r--r--chart2/source/view/main/VDataSeries.cxx8
6 files changed, 13 insertions, 13 deletions
diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx
index 2f29fd09b225..a5df0dcc03e4 100644
--- a/chart2/source/controller/dialogs/DataBrowser.cxx
+++ b/chart2/source/controller/dialogs/DataBrowser.cxx
@@ -646,11 +646,11 @@ void DataBrowser::RenewTable()
{
auto spHeader = std::make_shared<impl::SeriesHeader>( m_pColumnsWin, m_pColorsWin );
Reference< beans::XPropertySet > xSeriesProp( elemHeader.m_xDataSeries, uno::UNO_QUERY );
- sal_Int32 nColor = 0;
+ Color nColor;
// @todo: Set "DraftColor", i.e. interpolated colors for gradients, bitmaps, etc.
if( xSeriesProp.is() &&
( xSeriesProp->getPropertyValue( "Color" ) >>= nColor ))
- spHeader->SetColor( Color( nColor ));
+ spHeader->SetColor( nColor );
spHeader->SetChartType( elemHeader.m_xChartType, elemHeader.m_bSwapXAndYAxis );
spHeader->SetSeriesName(
DataSeriesHelper::getDataSeriesLabel(
@@ -1278,10 +1278,10 @@ void DataBrowser::RenewSeriesHeaders()
{
auto spHeader = std::make_shared<impl::SeriesHeader>( m_pColumnsWin, m_pColorsWin );
Reference< beans::XPropertySet > xSeriesProp(elemHeader.m_xDataSeries, uno::UNO_QUERY);
- sal_Int32 nColor = 0;
+ Color nColor;
if( xSeriesProp.is() &&
( xSeriesProp->getPropertyValue( "Color" ) >>= nColor ))
- spHeader->SetColor( Color( nColor ));
+ spHeader->SetColor( nColor );
spHeader->SetChartType( elemHeader.m_xChartType, elemHeader.m_bSwapXAndYAxis );
spHeader->SetSeriesName(
DataSeriesHelper::getDataSeriesLabel(
diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
index 07ce43a171b0..16fd2d2c9f56 100644
--- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
+++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx
@@ -153,7 +153,7 @@ namespace
Color lcl_getAmbientColor(
const uno::Reference< beans::XPropertySet > & xSceneProperties )
{
- sal_Int32 nResult = 0x000000;
+ Color nResult;
try
{
xSceneProperties->getPropertyValue("D3DSceneAmbientColor") >>= nResult;
@@ -162,7 +162,7 @@ namespace
{
DBG_UNHANDLED_EXCEPTION("chart2");
}
- return Color( nResult );
+ return nResult;
}
void lcl_setAmbientColor(
diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
index 7693c6ccfa37..2c27b6ae7dc1 100644
--- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx
@@ -216,7 +216,7 @@ DataPointItemConverter::DataPointItemConverter(
m_bDataSeries( bDataSeries ),
m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso),
m_bUseSpecialFillColor(bUseSpecialFillColor),
- m_nSpecialFillColor(nSpecialFillColor),
+ m_nSpecialFillColor(ColorTransparency, nSpecialFillColor),
m_nNumberFormat(nNumberFormat),
m_nPercentNumberFormat(nPercentNumberFormat),
m_aAvailableLabelPlacements(),
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index a5feac9eb7a6..55b4bed88ab6 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -1004,7 +1004,7 @@ void ChartController::executeDispatch_LineColor(sal_uInt32 nColor)
}
if( xPropSet.is() )
- xPropSet->setPropertyValue( "LineColor", css::uno::makeAny( Color(nColor) ) );
+ xPropSet->setPropertyValue( "LineColor", css::uno::makeAny( Color(ColorTransparency, nColor) ) );
}
}
catch( const uno::Exception& )
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index e1fdc3299e59..55a756c6edf3 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -504,7 +504,7 @@ void ChartAreaPanel::updateData()
{
sal_uInt32 nFillColor = 0;
xPropSet->getPropertyValue("FillColor") >>= nFillColor;
- XFillColorItem aFillColorItem("", Color(nFillColor));
+ XFillColorItem aFillColorItem("", Color(ColorTransparency, nFillColor));
updateFillColor(true, &aFillColorItem);
}
}
diff --git a/chart2/source/view/main/VDataSeries.cxx b/chart2/source/view/main/VDataSeries.cxx
index bb628a9419e3..d3c4dcd857e8 100644
--- a/chart2/source/view/main/VDataSeries.cxx
+++ b/chart2/source/view/main/VDataSeries.cxx
@@ -1125,13 +1125,13 @@ double VDataSeries::getValueByProperty( sal_Int32 nIndex, const OUString& rPropN
if(rPropName.endsWith("Color"))
{
//optimized interpolation for color values
- Color aColor(static_cast<sal_uInt32>(fValue));
- Color aOldColor(static_cast<sal_uInt32>(fOldValue));
+ Color aColor(ColorTransparency, static_cast<sal_uInt32>(fValue));
+ Color aOldColor(ColorTransparency, static_cast<sal_uInt32>(fOldValue));
sal_uInt8 r = aOldColor.GetRed() + (aColor.GetRed() - aOldColor.GetRed()) * mnPercent;
sal_uInt8 g = aOldColor.GetGreen() + (aColor.GetGreen() - aOldColor.GetGreen()) * mnPercent;
sal_uInt8 b = aOldColor.GetBlue() + (aColor.GetBlue() - aOldColor.GetBlue()) * mnPercent;
- sal_uInt8 t = 255 - (aOldColor.GetAlpha() + (aColor.GetAlpha() - aOldColor.GetAlpha()) * mnPercent);
- Color aRet(t, r, g, b);
+ sal_uInt8 a = aOldColor.GetAlpha() + (aColor.GetAlpha() - aOldColor.GetAlpha()) * mnPercent;
+ Color aRet(ColorAlpha, a, r, g, b);
return sal_uInt32(aRet);
}
return fOldValue + (fValue - fOldValue) * mnPercent;