From 63a68064bb33f180b8a231f7524d99405d910226 Mon Sep 17 00:00:00 2001 From: Noel Date: Fri, 15 Jan 2021 14:49:12 +0200 Subject: 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 --- filter/qa/cppunit/msfilter-test.cxx | 2 +- filter/source/graphicfilter/ieps/ieps.cxx | 2 +- filter/source/graphicfilter/itga/itga.cxx | 2 +- filter/source/msfilter/escherex.cxx | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'filter') diff --git a/filter/qa/cppunit/msfilter-test.cxx b/filter/qa/cppunit/msfilter-test.cxx index ce7b4b7c4cbd..439aad88b674 100644 --- a/filter/qa/cppunit/msfilter-test.cxx +++ b/filter/qa/cppunit/msfilter-test.cxx @@ -56,7 +56,7 @@ void MSFilterTest::testTransColToIco() { const OString sMessage = "Index of unmatched color: " + OString::number(i); CPPUNIT_ASSERT_EQUAL_MESSAGE(sMessage.getStr(), aExpected[i], - static_cast(msfilter::util::TransColToIco( Color(aStdCol[i]) ))); + static_cast(msfilter::util::TransColToIco( Color(ColorTransparency, aStdCol[i]) ))); } // tdf#92471 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(nDat >> nBitsLeft) & 1) ); + aBitmap.SetPixel( y, x, Color(ColorTransparency, static_cast(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(rHatch.Style), Color(rHatch.Color), rHatch.Distance, + pVDev->DrawHatch(tools::PolyPolygon(rRect), Hatch(static_cast(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(aAny), false )); + aBackColor = Color(ColorTransparency, ImplGetColor( *o3tl::doAccess(aAny), false )); } bool bFillBackground = false; if ( EscherPropertyValueHelper::GetPropertyValue( aAny, rXPropSet, "FillBackground", true ) ) -- cgit