diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-01-15 14:49:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-16 10:07:07 +0100 |
commit | 63a68064bb33f180b8a231f7524d99405d910226 (patch) | |
tree | 7ecf05b057c5ca4d80a48af045998a4b34484561 /filter/source | |
parent | d534a4c7b45ff254b339e806c6a11f13d9ff0043 (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 'filter/source')
-rw-r--r-- | filter/source/graphicfilter/ieps/ieps.cxx | 2 | ||||
-rw-r--r-- | filter/source/graphicfilter/itga/itga.cxx | 2 | ||||
-rw-r--r-- | filter/source/msfilter/escherex.cxx | 8 |
3 files changed, 6 insertions, 6 deletions
diff --git a/filter/source/graphicfilter/ieps/ieps.cxx b/filter/source/graphicfilter/ieps/ieps.cxx index e5753510bbd9..b70407027b7d 100644 --- a/filter/source/graphicfilter/ieps/ieps.cxx +++ b/filter/source/graphicfilter/ieps/ieps.cxx @@ -738,7 +738,7 @@ ipsGraphicImport( SvStream & rStream, Graphic & rGraphic, FilterConfigItem* ) if (!bIsValid) break; if ( nBitDepth == 1 ) - aBitmap.SetPixel( y, x, Color(static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1) ); + aBitmap.SetPixel( y, x, Color(ColorTransparency, static_cast<sal_uInt8>(nDat >> nBitsLeft) & 1) ); else { aBitmap.SetPixel( y, x, nDat ? COL_WHITE : COL_BLACK ); // nBitDepth == 8 diff --git a/filter/source/graphicfilter/itga/itga.cxx b/filter/source/graphicfilter/itga/itga.cxx index bbaee08117eb..023351c33b4e 100644 --- a/filter/source/graphicfilter/itga/itga.cxx +++ b/filter/source/graphicfilter/itga/itga.cxx @@ -638,7 +638,7 @@ bool TGAReader::ImplReadBody() return false; if ( nDummy >= mpFileHeader->nColorMapLength ) return false; - mpBitmap->SetPixel( nY, nX, Color(nDummy) ); + mpBitmap->SetPixel( nY, nX, Color(ColorTransparency, nDummy) ); } break; default: diff --git a/filter/source/msfilter/escherex.cxx b/filter/source/msfilter/escherex.cxx index 5df267f3f954..31d382796f43 100644 --- a/filter/source/msfilter/escherex.cxx +++ b/filter/source/msfilter/escherex.cxx @@ -376,12 +376,12 @@ sal_uInt32 EscherPropertyContainer::GetGradientColor( if ( nStartColor & 1 ) { nIntensity = pGradient->StartIntensity; - aColor = Color(pGradient->StartColor); + aColor = Color(ColorTransparency, pGradient->StartColor); } else { nIntensity = pGradient->EndIntensity; - aColor = Color(pGradient->EndColor); + aColor = Color(ColorTransparency, pGradient->EndColor); } } sal_uInt32 nRed = ( aColor.GetRed() * nIntensity ) / 100; @@ -1452,7 +1452,7 @@ Graphic lclDrawHatch( const drawing::Hatch& rHatch, const Color& rBackColor, boo pVDev->SetLineColor(); pVDev->SetFillColor(bFillBackground ? rBackColor : COL_TRANSPARENT); pVDev->DrawRect(rRect); - pVDev->DrawHatch(tools::PolyPolygon(rRect), Hatch(static_cast<HatchStyle>(rHatch.Style), Color(rHatch.Color), rHatch.Distance, + pVDev->DrawHatch(tools::PolyPolygon(rRect), Hatch(static_cast<HatchStyle>(rHatch.Style), Color(ColorTransparency, rHatch.Color), rHatch.Distance, Degree10(rHatch.Angle))); aMtf.Stop(); aMtf.WindStart(); @@ -1547,7 +1547,7 @@ bool EscherPropertyContainer::CreateGraphicProperties(const uno::Reference<beans Color aBackColor; if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "FillColor" ) ) { - aBackColor = Color(ImplGetColor( *o3tl::doAccess<sal_uInt32>(aAny), false )); + aBackColor = Color(ColorTransparency, ImplGetColor( *o3tl::doAccess<sal_uInt32>(aAny), false )); } bool bFillBackground = false; if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "FillBackground", true ) ) |