summaryrefslogtreecommitdiff
path: root/editeng
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 /editeng
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 'editeng')
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx8
-rw-r--r--editeng/source/items/frmitems.cxx8
-rw-r--r--editeng/source/items/textitem.cxx8
-rw-r--r--editeng/source/uno/unonrule.cxx6
4 files changed, 15 insertions, 15 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
index 6900e8cf8e1d..ac4bbe1ada4d 100644
--- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx
+++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx
@@ -1471,7 +1471,7 @@ namespace accessibility
if (rRes.Name == "CharColor")
{
uno::Any &anyChar = rRes.Value;
- Color crChar = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved));
+ Color crChar(ColorTransparency, static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>(anyChar.pReserved)));
if (COL_AUTO == crChar )
{
uno::Reference< css::accessibility::XAccessibleComponent > xComponent(mxParent,uno::UNO_QUERY);
@@ -1485,7 +1485,7 @@ namespace accessibility
}
else
{
- Color cr(xComponent->getBackground());
+ Color cr(ColorTransparency, xComponent->getBackground());
crChar = cr.IsDark() ? COL_WHITE : COL_BLACK;
anyChar <<= crChar;
}
@@ -1502,7 +1502,7 @@ namespace accessibility
if (rRes.Name == "CharUnderlineColor")
{
uno::Any &anyCharUnderLine = rRes.Value;
- Color crCharUnderLine = static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>( anyCharUnderLine.pReserved));
+ Color crCharUnderLine(ColorTransparency, static_cast<sal_uInt32>( reinterpret_cast<sal_uIntPtr>( anyCharUnderLine.pReserved)));
if (COL_AUTO == crCharUnderLine )
{
uno::Reference< css::accessibility::XAccessibleComponent > xComponent(mxParent,uno::UNO_QUERY);
@@ -1516,7 +1516,7 @@ namespace accessibility
}
else
{
- Color cr(xComponent->getBackground());
+ Color cr(ColorTransparency, xComponent->getBackground());
crCharUnderLine = cr.IsDark() ? COL_WHITE : COL_BLACK;
anyCharUnderLine <<= crCharUnderLine;
}
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;
}
}
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx
index 761fa305e3f4..4e81037a36ae 100644
--- a/editeng/source/uno/unonrule.cxx
+++ b/editeng/source/uno/unonrule.cxx
@@ -427,10 +427,10 @@ void SvxUnoNumberingRules::setNumberingRuleByIndex(const Sequence<beans::Propert
}
else if ( rPropName == UNO_NAME_NRULE_BULLET_COLOR )
{
- sal_Int32 nColor = 0;
- if( aVal >>= nColor )
+ Color aColor;
+ if( aVal >>= aColor )
{
- aFmt.SetBulletColor( static_cast<Color>(nColor) );
+ aFmt.SetBulletColor( aColor );
continue;
}
}