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 /svx/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 'svx/source')
-rw-r--r-- | svx/source/dialog/hexcolorcontrol.cxx | 2 | ||||
-rw-r--r-- | svx/source/fmcomp/fmgridif.cxx | 8 | ||||
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 2 | ||||
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 4 | ||||
-rw-r--r-- | svx/source/unodraw/XPropertyTable.cxx | 6 | ||||
-rw-r--r-- | svx/source/xoutdev/xattr.cxx | 34 | ||||
-rw-r--r-- | svx/source/xoutdev/xtabcolr.cxx | 2 |
7 files changed, 29 insertions, 29 deletions
diff --git a/svx/source/dialog/hexcolorcontrol.cxx b/svx/source/dialog/hexcolorcontrol.cxx index 3a559e889710..ff9b10ca8da8 100644 --- a/svx/source/dialog/hexcolorcontrol.cxx +++ b/svx/source/dialog/hexcolorcontrol.cxx @@ -84,7 +84,7 @@ Color HexColorControl::GetColor() const m_xEntry->set_message_type(nColor != -1 ? weld::EntryMessageType::Normal : weld::EntryMessageType::Error); - return Color(nColor); + return Color(ColorTransparency, nColor); } IMPL_STATIC_LINK(HexColorControl, ImplProcessInputHdl, OUString&, rTest, bool) diff --git a/svx/source/fmcomp/fmgridif.cxx b/svx/source/fmcomp/fmgridif.cxx index b74a31cec7d9..164aee16dc24 100644 --- a/svx/source/fmcomp/fmgridif.cxx +++ b/svx/source/fmcomp/fmgridif.cxx @@ -1785,7 +1785,7 @@ void FmXGridPeer::setProperty( const OUString& PropertyName, const Any& Value) if ( PropertyName == FM_PROP_TEXTLINECOLOR ) { - ::Color aTextLineColor( bVoid ? COL_TRANSPARENT : ::Color(::comphelper::getINT32( Value )) ); + ::Color aTextLineColor( bVoid ? COL_TRANSPARENT : ::Color(ColorTransparency, ::comphelper::getINT32( Value )) ); if (bVoid) { pGrid->SetTextLineColor(); @@ -1846,7 +1846,7 @@ void FmXGridPeer::setProperty( const OUString& PropertyName, const Any& Value) if (bVoid) pGrid->SetCursorColor(COL_TRANSPARENT); else - pGrid->SetCursorColor( ::Color(::comphelper::getINT32(Value))); + pGrid->SetCursorColor( ::Color(ColorTransparency, ::comphelper::getINT32(Value))); if (isDesignMode()) pGrid->Invalidate(); } @@ -1898,7 +1898,7 @@ void FmXGridPeer::setProperty( const OUString& PropertyName, const Any& Value) } else { - ::Color aColor( ::comphelper::getINT32(Value) ); + ::Color aColor( ColorTransparency, ::comphelper::getINT32(Value) ); pGrid->SetBackground( aColor ); pGrid->SetControlBackground( aColor ); } @@ -1911,7 +1911,7 @@ void FmXGridPeer::setProperty( const OUString& PropertyName, const Any& Value) } else { - ::Color aColor( ::comphelper::getINT32(Value) ); + ::Color aColor( ColorTransparency, ::comphelper::getINT32(Value) ); pGrid->SetTextColor( aColor ); pGrid->SetControlForeground( aColor ); } diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index a683704d41a1..43c332a68029 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -280,7 +280,7 @@ SdrItemPool::SdrItemPool( rPoolDefaults[ SDRATTR_3DSCENE_DISTANCE - SDRATTR_START ] = new SfxUInt32Item(SDRATTR_3DSCENE_DISTANCE, 100); rPoolDefaults[ SDRATTR_3DSCENE_FOCAL_LENGTH - SDRATTR_START ] = new SfxUInt32Item(SDRATTR_3DSCENE_FOCAL_LENGTH, 100); rPoolDefaults[ SDRATTR_3DSCENE_TWO_SIDED_LIGHTING - SDRATTR_START ] = new SfxBoolItem(SDRATTR_3DSCENE_TWO_SIDED_LIGHTING, false); - rPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_1 - SDRATTR_START ] = new SvxColorItem(Color(0xffcccccc), SDRATTR_3DSCENE_LIGHTCOLOR_1); + rPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_1 - SDRATTR_START ] = new SvxColorItem(Color(ColorTransparency, 0xffcccccc), SDRATTR_3DSCENE_LIGHTCOLOR_1); rPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_2 - SDRATTR_START ] = new SvxColorItem(Color(0x00000000), SDRATTR_3DSCENE_LIGHTCOLOR_2); rPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_3 - SDRATTR_START ] = new SvxColorItem(Color(0x00000000), SDRATTR_3DSCENE_LIGHTCOLOR_3); rPoolDefaults[ SDRATTR_3DSCENE_LIGHTCOLOR_4 - SDRATTR_START ] = new SvxColorItem(Color(0x00000000), SDRATTR_3DSCENE_LIGHTCOLOR_4); diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index f3630cc492aa..4084dffc993c 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -135,7 +135,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet) int nIx = 1; for (int i = 0; i < CustomColorList.getLength(); ++i) { - Color aColor(CustomColorList[i]); + Color aColor(ColorTransparency, CustomColorList[i]); rColorSet.InsertItem(nIx, aColor, CustomColorNameList[i]); ++nIx; } @@ -169,7 +169,7 @@ void PaletteManager::ReloadRecentColorSet(SvxColorValueSet& rColorSet) const bool bHasColorNames = Colorlist.getLength() == ColorNamelist.getLength(); for (int i = 0; i < Colorlist.getLength(); ++i) { - Color aColor(Colorlist[i]); + Color aColor(ColorTransparency, Colorlist[i]); OUString sColorName = bHasColorNames ? ColorNamelist[i] : ("#" + aColor.AsRGBHexString().toAsciiUpperCase()); maRecentColors.emplace_back(aColor, sColorName); rColorSet.InsertItem(nIx, aColor, sColorName); diff --git a/svx/source/unodraw/XPropertyTable.cxx b/svx/source/unodraw/XPropertyTable.cxx index acd7d6aac958..39d861327aa8 100644 --- a/svx/source/unodraw/XPropertyTable.cxx +++ b/svx/source/unodraw/XPropertyTable.cxx @@ -485,7 +485,7 @@ std::unique_ptr<XPropertyEntry> SvxUnoXHatchTable::createEntry(const OUString& r XHatch aXHatch; aXHatch.SetHatchStyle( aUnoHatch.Style ); - aXHatch.SetColor( Color(aUnoHatch.Color) ); + aXHatch.SetColor( Color(ColorTransparency, aUnoHatch.Color) ); aXHatch.SetDistance( aUnoHatch.Distance ); aXHatch.SetAngle( Degree10(aUnoHatch.Angle) ); @@ -564,8 +564,8 @@ std::unique_ptr<XPropertyEntry> SvxUnoXGradientTable::createEntry(const OUString XGradient aXGradient; aXGradient.SetGradientStyle( aGradient.Style ); - aXGradient.SetStartColor( Color(aGradient.StartColor) ); - aXGradient.SetEndColor( Color(aGradient.EndColor) ); + aXGradient.SetStartColor( Color(ColorTransparency, aGradient.StartColor) ); + aXGradient.SetEndColor( Color(ColorTransparency, aGradient.EndColor) ); aXGradient.SetAngle( Degree10(aGradient.Angle) ); aXGradient.SetBorder( aGradient.Border ); aXGradient.SetXOffset( aGradient.XOffset ); 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 ) ); } } |