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 /editeng/source/items | |
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 'editeng/source/items')
-rw-r--r-- | editeng/source/items/frmitems.cxx | 8 | ||||
-rw-r--r-- | editeng/source/items/textitem.cxx | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 589bde044152..184bf21cd994 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -1084,7 +1084,7 @@ bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int32 nTransparence = 0; if ((rVal >>= nTransparence) && !o3tl::checked_multiply<sal_Int32>(nTransparence, 255, nTransparence)) { - Color aColor(aShadow.Color); + Color aColor(ColorTransparency, aShadow.Color); aColor.SetAlpha(255 - rtl::math::round(float(nTransparence) / 100)); aShadow.Color = sal_Int32(aColor); } @@ -1106,7 +1106,7 @@ bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) } nWidth = bConvert ? convertMm100ToTwip(aShadow.ShadowWidth) : aShadow.ShadowWidth; - Color aSet(aShadow.Color); + Color aSet(ColorTransparency, aShadow.Color); aShadowColor = aSet; } @@ -1439,7 +1439,7 @@ namespace bool lcl_lineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine, bool bConvert, bool bGuessWidth) { - rSvxLine.SetColor( Color(rLine.Color)); + rSvxLine.SetColor( Color(ColorTransparency, rLine.Color)); if ( bGuessWidth ) { rSvxLine.GuessLinesWidths( rSvxLine.GetBorderLineStyle(), @@ -2735,7 +2735,7 @@ bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId ) switch ( nMemId ) { - case MID_FG_COLOR: pLine->SetColor( Color(nVal) ); break; + case MID_FG_COLOR: pLine->SetColor( Color(ColorTransparency, nVal) ); break; case MID_LINE_STYLE: pLine->SetBorderLineStyle(static_cast<SvxBorderLineStyle>(nVal)); break; diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index e83d08b35504..e63b9c786e1d 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -990,7 +990,7 @@ bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) break; case MID_TL_COLOR: { - sal_Int32 nCol = 0; + Color nCol; if( !( rVal >>= nCol ) ) bRet = false; else @@ -998,7 +998,7 @@ bool SvxTextLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) // Keep transparence, because it contains the information // whether the font color or the stored color should be used sal_uInt8 nAlpha = mColor.GetAlpha(); - mColor = Color( nCol ); + mColor = nCol; mColor.SetAlpha( nAlpha ); } } @@ -1354,7 +1354,7 @@ bool SvxBackgroundColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) c bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) { nMemberId &= ~CONVERT_TWIPS; - sal_Int32 nColor = 0; + Color nColor; Color aColor = SvxColorItem::GetValue(); switch( nMemberId ) @@ -1369,7 +1369,7 @@ bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId { if(!(rVal >>= nColor)) return false; - SvxColorItem::SetValue( Color(nColor) ); + SvxColorItem::SetValue( nColor ); break; } } |