summaryrefslogtreecommitdiff
path: root/svx/source/xoutdev
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 /svx/source/xoutdev
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 'svx/source/xoutdev')
-rw-r--r--svx/source/xoutdev/xattr.cxx34
-rw-r--r--svx/source/xoutdev/xtabcolr.cxx2
2 files changed, 18 insertions, 18 deletions
diff --git a/svx/source/xoutdev/xattr.cxx b/svx/source/xoutdev/xattr.cxx
index 79ee53600f63..8efd50c25418 100644
--- a/svx/source/xoutdev/xattr.cxx
+++ b/svx/source/xoutdev/xattr.cxx
@@ -307,9 +307,9 @@ bool XColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) const
bool XColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
{
- sal_Int32 nValue = 0;
+ Color nValue;
rVal >>= nValue;
- SetColorValue( Color(nValue) );
+ SetColorValue( nValue );
return true;
}
@@ -978,7 +978,7 @@ bool XLineColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*
if(!(rVal >>= nValue))
return false;
- SetColorValue( Color(nValue) );
+ SetColorValue( Color(ColorTransparency, nValue) );
return true;
}
@@ -1901,11 +1901,11 @@ bool XFillColorItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/) c
bool XFillColorItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/)
{
- sal_Int32 nValue = 0;
+ Color nValue;
if(!(rVal >>= nValue ))
return false;
- SetColorValue( Color(nValue) );
+ SetColorValue( nValue );
return true;
}
@@ -2021,8 +2021,8 @@ namespace
{
XGradient aGradient;
- aGradient.SetStartColor(rMap["startcolor"].toInt32(16));
- aGradient.SetEndColor(rMap["endcolor"].toInt32(16));
+ aGradient.SetStartColor(Color(ColorTransparency, rMap["startcolor"].toInt32(16)));
+ aGradient.SetEndColor(Color(ColorTransparency, rMap["endcolor"].toInt32(16)));
aGradient.SetGradientStyle(lcl_getStyleFromString(rMap["style"]));
aGradient.SetAngle(Degree10(rMap["angle"].toInt32()));
@@ -2284,8 +2284,8 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId
XGradient aXGradient;
aXGradient.SetGradientStyle( aGradient2.Style );
- aXGradient.SetStartColor( Color(aGradient2.StartColor) );
- aXGradient.SetEndColor( Color(aGradient2.EndColor) );
+ aXGradient.SetStartColor( Color(ColorTransparency, aGradient2.StartColor) );
+ aXGradient.SetEndColor( Color(ColorTransparency, aGradient2.EndColor) );
aXGradient.SetAngle( Degree10(aGradient2.Angle) );
aXGradient.SetBorder( aGradient2.Border );
aXGradient.SetXOffset( aGradient2.XOffset );
@@ -2321,8 +2321,8 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId
XGradient aXGradient;
aXGradient.SetGradientStyle( aGradient2.Style );
- aXGradient.SetStartColor( Color(aGradient2.StartColor) );
- aXGradient.SetEndColor( Color(aGradient2.EndColor) );
+ aXGradient.SetStartColor( Color(ColorTransparency, aGradient2.StartColor) );
+ aXGradient.SetEndColor( Color(ColorTransparency, aGradient2.EndColor) );
aXGradient.SetAngle( Degree10(aGradient2.Angle) );
aXGradient.SetBorder( aGradient2.Border );
aXGradient.SetXOffset( aGradient2.XOffset );
@@ -2338,16 +2338,16 @@ bool XFillGradientItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId
case MID_GRADIENT_STARTCOLOR:
case MID_GRADIENT_ENDCOLOR:
{
- sal_Int32 nVal = 0;
+ Color nVal;
if(!(rVal >>= nVal ))
return false;
XGradient aXGradient = GetGradientValue();
if ( nMemberId == MID_GRADIENT_STARTCOLOR )
- aXGradient.SetStartColor( Color(nVal) );
+ aXGradient.SetStartColor( nVal );
else
- aXGradient.SetEndColor( Color(nVal) );
+ aXGradient.SetEndColor( nVal );
SetGradientValue( aXGradient );
break;
}
@@ -2708,7 +2708,7 @@ bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
if ( bHatch )
{
aHatch.SetHatchStyle( aUnoHatch.Style );
- aHatch.SetColor( Color(aUnoHatch.Color) );
+ aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
aHatch.SetDistance( aUnoHatch.Distance );
aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
}
@@ -2726,7 +2726,7 @@ bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
return false;
aHatch.SetHatchStyle( aUnoHatch.Style );
- aHatch.SetColor( Color(aUnoHatch.Color) );
+ aHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) );
aHatch.SetDistance( aUnoHatch.Distance );
aHatch.SetAngle( Degree10(aUnoHatch.Angle) );
break;
@@ -2759,7 +2759,7 @@ bool XFillHatchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
return false;
if ( nMemberId == MID_HATCH_COLOR )
- aHatch.SetColor( Color(nVal) );
+ aHatch.SetColor( Color(ColorTransparency, nVal) );
else if ( nMemberId == MID_HATCH_DISTANCE )
aHatch.SetDistance( nVal );
else
diff --git a/svx/source/xoutdev/xtabcolr.cxx b/svx/source/xoutdev/xtabcolr.cxx
index 3fe4947f2b03..67e963ce92a6 100644
--- a/svx/source/xoutdev/xtabcolr.cxx
+++ b/svx/source/xoutdev/xtabcolr.cxx
@@ -118,7 +118,7 @@ bool XColorList::Create()
for(b = 0; b < nNumColorsInGroup; b++)
{
- Insert( std::make_unique<XColorEntry>( Color(aStdCol[nOffset + b]), aStrCol[b] + aSuffix ) );
+ Insert( std::make_unique<XColorEntry>( Color(ColorTransparency, aStdCol[nOffset + b]), aStrCol[b] + aSuffix ) );
}
}