summaryrefslogtreecommitdiff
path: root/oox
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 /oox
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 'oox')
-rw-r--r--oox/source/drawingml/chart/objectformatter.cxx4
-rw-r--r--oox/source/drawingml/color.cxx8
-rw-r--r--oox/source/drawingml/shape.cxx4
-rw-r--r--oox/source/export/chartexport.cxx8
-rw-r--r--oox/source/export/drawingml.cxx22
-rw-r--r--oox/source/export/shapes.cxx2
-rw-r--r--oox/source/ole/olehelper.cxx2
7 files changed, 25 insertions, 25 deletions
diff --git a/oox/source/drawingml/chart/objectformatter.cxx b/oox/source/drawingml/chart/objectformatter.cxx
index d3b274e1fa3d..ecaa4c5121e4 100644
--- a/oox/source/drawingml/chart/objectformatter.cxx
+++ b/oox/source/drawingml/chart/objectformatter.cxx
@@ -727,7 +727,7 @@ struct ObjectFormatterData
DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const AutoFormatEntry* pAutoFormatEntry ) :
mrData( rData ),
- mnPhClr( 0xffffffff )
+ mnPhClr( ColorTransparency, 0xffffffff )
{
if( !pAutoFormatEntry )
return;
@@ -749,7 +749,7 @@ DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const Auto
DetailFormatterBase::DetailFormatterBase( ObjectFormatterData& rData, const AutoTextEntry* pAutoTextEntry ) :
mrData( rData ),
- mnPhClr( 0xffffffff )
+ mnPhClr( ColorTransparency, 0xffffffff )
{
if( pAutoTextEntry && (pAutoTextEntry->mnColorToken != XML_TOKEN_INVALID) )
mnPhClr = getSchemeColor( pAutoTextEntry->mnColorToken, XML_TOKEN_INVALID, 0 );
diff --git a/oox/source/drawingml/color.cxx b/oox/source/drawingml/color.cxx
index e87079945600..1cd5d2ebaed7 100644
--- a/oox/source/drawingml/color.cxx
+++ b/oox/source/drawingml/color.cxx
@@ -261,7 +261,7 @@ void Color::setSrgbClr( sal_Int32 nRgb )
{
OSL_ENSURE( (0 <= nRgb) && (nRgb <= 0xFFFFFF), "Color::setSrgbClr - invalid RGB value" );
meMode = COLOR_RGB;
- lclRgbToRgbComponents( mnC1, mnC2, mnC3, ::Color(nRgb) );
+ lclRgbToRgbComponents( mnC1, mnC2, mnC3, ::Color(ColorTransparency, nRgb) );
}
void Color::setScrgbClr( sal_Int32 nR, sal_Int32 nG, sal_Int32 nB )
@@ -495,10 +495,10 @@ void Color::clearTransparence()
case COLOR_SCHEME: setResolvedRgb( rGraphicHelper.getSchemeColor( mnC1 ) ); break;
case COLOR_PALETTE: setResolvedRgb( rGraphicHelper.getPaletteColor( mnC1 ) ); break;
- case COLOR_SYSTEM: setResolvedRgb( rGraphicHelper.getSystemColor( mnC1, ::Color(mnC2) ) ); break;
+ case COLOR_SYSTEM: setResolvedRgb( rGraphicHelper.getSystemColor( mnC1, ::Color(ColorTransparency, mnC2) ) ); break;
case COLOR_PH: setResolvedRgb( nPhClr ); break;
- case COLOR_FINAL: return ::Color(mnC1);
+ case COLOR_FINAL: return ::Color(ColorTransparency, mnC1);
}
// if color is UNUSED or turns to UNUSED in setResolvedRgb, do not perform transformations
@@ -647,7 +647,7 @@ void Color::clearTransparence()
}
if( meMode == COLOR_FINAL )
maTransforms.clear();
- return ::Color(nRet);
+ return ::Color(ColorTransparency, nRet);
}
bool Color::hasTransparency() const
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 98ef5de040b7..f5aa1c2cd9f2 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -967,8 +967,8 @@ Reference< XShape > const & Shape::createAndInsert(
const GraphicHelper& rGraphicHelper = rFilterBase.getGraphicHelper();
- ::Color nLinePhClr(0xffffffff);
- ::Color nFillPhClr(0xffffffff);
+ ::Color nLinePhClr(ColorTransparency, 0xffffffff);
+ ::Color nFillPhClr(ColorTransparency, 0xffffffff);
// TODO: use ph color when applying effect properties
//sal_Int32 nEffectPhClr = -1;
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 24fc7dc88aad..177660e42f85 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -481,7 +481,7 @@ static sal_Int32 lcl_generateRandomValue()
static sal_Int32 lcl_getAlphaFromTransparenceGradient(const awt::Gradient& rGradient, bool bStart)
{
// Our alpha is a gray color value.
- sal_uInt8 nRed = ::Color(bStart ? rGradient.StartColor : rGradient.EndColor).GetRed();
+ sal_uInt8 nRed = ::Color(ColorTransparency, bStart ? rGradient.StartColor : rGradient.EndColor).GetRed();
// drawingML alpha is a percentage on a 0..100000 scale.
return (255 - nRed) * oox::drawingml::MAX_PERCENT / 255;
}
@@ -1839,7 +1839,7 @@ void ChartExport::exportSolidFill(const Reference< XPropertySet >& xPropSet)
mpFS->endElementNS(XML_a, XML_gradFill);
}
else
- WriteSolidFill(::Color(nFillColor & 0xffffff), nAlpha);
+ WriteSolidFill(::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha);
}
void ChartExport::exportHatch( const Reference< XPropertySet >& xPropSet )
@@ -3880,7 +3880,7 @@ void ChartExport::exportDataPoints(
else
{
// property set only containing the color
- xPropSet.set( new ColorPropertySet( xColorScheme->getColorByIndex( nElement )));
+ xPropSet.set( new ColorPropertySet( ColorTransparency, xColorScheme->getColorByIndex( nElement )));
}
if( xPropSet.is() )
@@ -4245,7 +4245,7 @@ void ChartExport::exportMarker(const Reference< XPropertySet >& xPropSet)
pFS->singleElement(FSNS(XML_a, XML_noFill));
}
else
- WriteSolidFill(::Color(aColor));
+ WriteSolidFill(::Color(ColorTransparency, aColor));
pFS->endElement( FSNS( XML_c, XML_spPr ) );
}
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 897fb0ff42a8..54003cd32fc7 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -139,7 +139,7 @@ namespace
sal_Int32 GetAlphaFromTransparenceGradient(const awt::Gradient& rGradient, bool bStart)
{
// Our alpha is a gray color value.
- sal_uInt8 nRed = ::Color(bStart ? rGradient.StartColor : rGradient.EndColor).GetRed();
+ sal_uInt8 nRed = ::Color(ColorTransparency, bStart ? rGradient.StartColor : rGradient.EndColor).GetRed();
// drawingML alpha is a percentage on a 0..100000 scale.
return (255 - nRed) * oox::drawingml::MAX_PERCENT / 255;
}
@@ -481,7 +481,7 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
else if ( nFillColor != nOriginalColor )
{
// the user has set a different color for the shape
- WriteSolidFill( ::Color(nFillColor & 0xffffff), nAlpha );
+ WriteSolidFill( ::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha );
}
else if ( !sColorFillScheme.isEmpty() )
{
@@ -492,7 +492,7 @@ void DrawingML::WriteSolidFill( const Reference< XPropertySet >& rXPropSet )
{
// the shape had a custom color and the user didn't change it
// tdf#124013
- WriteSolidFill( ::Color(nFillColor & 0xffffff), nAlpha );
+ WriteSolidFill( ::Color(ColorTransparency, nFillColor & 0xffffff), nAlpha );
}
}
@@ -505,7 +505,7 @@ void DrawingML::WriteGradientStop(sal_uInt16 nStop, ::Color nColor, sal_Int32 nA
::Color DrawingML::ColorWithIntensity( sal_uInt32 nColor, sal_uInt32 nIntensity )
{
- return ::Color(( ( ( nColor & 0xff ) * nIntensity ) / 100 )
+ return ::Color(ColorTransparency, ( ( ( nColor & 0xff ) * nIntensity ) / 100 )
| ( ( ( ( ( nColor & 0xff00 ) >> 8 ) * nIntensity ) / 100 ) << 8 )
| ( ( ( ( ( nColor & 0xff0000 ) >> 8 ) * nIntensity ) / 100 ) << 8 ));
}
@@ -918,7 +918,7 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet, Referenc
default:
if (GetProperty(rXPropSet, "LineColor"))
{
- nColor = ::Color(mAny.get<sal_uInt32>() & 0xffffff);
+ nColor = ::Color(ColorTransparency, mAny.get<sal_uInt32>() & 0xffffff);
bColorSet = true;
}
if (GetProperty(rXPropSet, "LineTransparence"))
@@ -1578,7 +1578,7 @@ void DrawingML::WritePattFill(const Reference<XPropertySet>& rXPropSet, const cs
mpFS->startElementNS(XML_a, XML_pattFill, XML_prst, GetHatchPattern(rHatch));
mpFS->startElementNS(XML_a, XML_fgClr);
- WriteColor(::Color(rHatch.Color));
+ WriteColor(::Color(ColorTransparency, rHatch.Color));
mpFS->endElementNS( XML_a , XML_fgClr );
::Color nColor = COL_WHITE;
@@ -2023,7 +2023,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
&& eState == beans::PropertyState_DIRECT_VALUE)
|| GetProperty(rXPropSet, "CharColor"))
{
- ::Color color( *o3tl::doAccess<sal_uInt32>(mAny) );
+ ::Color color( ColorTransparency, *o3tl::doAccess<sal_uInt32>(mAny) );
SAL_INFO("oox.shape", "run color: " << sal_uInt32(color) << " auto: " << sal_uInt32(COL_AUTO));
// WriteSolidFill() handles MAX_PERCENT as "no transparency".
@@ -2053,7 +2053,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
{
if (GetProperty(rXPropSet, "CharBackColor"))
{
- ::Color color(*o3tl::doAccess<sal_uInt32>(mAny));
+ ::Color color(ColorTransparency, *o3tl::doAccess<sal_uInt32>(mAny));
if( color != COL_AUTO )
{
mpFS->startElementNS(XML_a, XML_highlight);
@@ -2069,7 +2069,7 @@ void DrawingML::WriteRunProperties( const Reference< XPropertySet >& rRun, bool
&& eState == beans::PropertyState_DIRECT_VALUE)
|| GetProperty(rXPropSet, "CharUnderlineColor")))
{
- ::Color color(*o3tl::doAccess<sal_uInt32>(mAny));
+ ::Color color(ColorTransparency, *o3tl::doAccess<sal_uInt32>(mAny));
// if color is automatic, then we shouldn't write information about color but to take color from character
if( color != COL_AUTO )
{
@@ -2426,7 +2426,7 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
}
else if(aPropName == "BulletColor")
{
- nBulletColor = ::Color(*o3tl::doAccess<sal_uInt32>(rPropValue.Value));
+ nBulletColor = ::Color(ColorTransparency, *o3tl::doAccess<sal_uInt32>(rPropValue.Value));
bHasBulletColor = true;
}
else if ( aPropName == "BulletChar" )
@@ -2514,7 +2514,7 @@ void DrawingML::WriteParagraphNumbering(const Reference< XPropertySet >& rXPropS
{
if (nBulletColor == COL_AUTO )
{
- nBulletColor = ::Color(mbIsBackgroundDark ? 0xffffff : 0x000000);
+ nBulletColor = ::Color(ColorTransparency, mbIsBackgroundDark ? 0xffffff : 0x000000);
}
mpFS->startElementNS(XML_a, XML_buClr);
WriteColor( nBulletColor );
diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 58246d08f231..9033e1d40d88 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -1805,7 +1805,7 @@ void ShapeExport::WriteBorderLine(const sal_Int32 XML_line, const BorderLine2& r
if ( rBorderLine.Color == sal_Int32( COL_AUTO ) )
mpFS->singleElementNS(XML_a, XML_noFill);
else
- DrawingML::WriteSolidFill( ::Color(rBorderLine.Color) );
+ DrawingML::WriteSolidFill( ::Color(ColorTransparency, rBorderLine.Color) );
mpFS->endElementNS( XML_a, XML_line );
}
}
diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx
index 1ffbbec89a30..0a50bc23327c 100644
--- a/oox/source/ole/olehelper.cxx
+++ b/oox/source/ole/olehelper.cxx
@@ -81,7 +81,7 @@ sal_uInt32 lclSwapRedBlue( sal_uInt32 nColor )
/** Returns the UNO RGB color from the passed encoded OLE BGR color. */
::Color lclDecodeBgrColor( sal_uInt32 nOleColor )
{
- return ::Color( lclSwapRedBlue( nOleColor ) & 0xFFFFFF );
+ return ::Color( ColorTransparency, lclSwapRedBlue( nOleColor ) & 0xFFFFFF );
}
const sal_uInt32 OLE_STDPIC_ID = 0x0000746C;