From d765ec2295d12ccde1fb25aa92c5d821de748add Mon Sep 17 00:00:00 2001 From: Noel Date: Mon, 11 Jan 2021 08:54:37 +0200 Subject: transparency->alpha in tools::Color this just changes the Get/Set methods, the constructor and internal representation of Color is not changed. Change-Id: Idb6e07cc08bbaa5bd55b6bd4b585e648aef507b6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109074 Tested-by: Jenkins Reviewed-by: Noel Grandin --- .../source/accessibility/AccessibleEditableTextPara.cxx | 2 +- editeng/source/accessibility/AccessibleImageBullet.cxx | 2 +- editeng/source/items/frmitems.cxx | 14 +++++++------- editeng/source/items/legacyitem.cxx | 2 +- editeng/source/items/textitem.cxx | 16 ++++++++-------- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'editeng') diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index 92d2afaf0bbb..6900e8cf8e1d 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -1146,7 +1146,7 @@ namespace accessibility Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor() ); // the background is transparent - aColor.SetTransparency( 0xFF); + aColor.SetAlpha(0); return static_cast( aColor ); } diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx index 0b319589f4d5..b75d3f32194d 100644 --- a/editeng/source/accessibility/AccessibleImageBullet.cxx +++ b/editeng/source/accessibility/AccessibleImageBullet.cxx @@ -340,7 +340,7 @@ namespace accessibility Color aColor( Application::GetSettings().GetStyleSettings().GetWindowColor() ); // the background is transparent - aColor.SetTransparency( 0xFF); + aColor.SetAlpha(0); return static_cast( aColor ); } diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index e3a6f8e5ac0c..e90f2f9586a3 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -1036,7 +1036,7 @@ bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const aShadow.IsTransparent = aShadowColor.IsTransparent(); aShadow.Color = sal_Int32(aShadowColor); - sal_Int8 nTransparence = rtl::math::round(float(aShadowColor.GetTransparency() * 100) / 255); + sal_Int8 nTransparence = rtl::math::round((float(255 - aShadowColor.GetAlpha()) * 100) / 255); switch ( nMemberId ) { @@ -1085,7 +1085,7 @@ bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if ((rVal >>= nTransparence) && !o3tl::checked_multiply(nTransparence, 255, nTransparence)) { Color aColor(aShadow.Color); - aColor.SetTransparency(rtl::math::round(float(nTransparence) / 100)); + aColor.SetAlpha(255 - rtl::math::round(float(nTransparence) / 100)); aShadow.Color = sal_Int32(aColor); } break; @@ -2915,14 +2915,14 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= aColor.GetRGBColor(); break; case MID_BACK_COLOR_TRANSPARENCY: - rVal <<= SvxBrushItem::TransparencyToPercent(aColor.GetTransparency()); + rVal <<= SvxBrushItem::TransparencyToPercent(255 - aColor.GetAlpha()); break; case MID_GRAPHIC_POSITION: rVal <<= static_cast(static_cast(eGraphicPos)); break; case MID_GRAPHIC_TRANSPARENT: - rVal <<= ( aColor.GetTransparency() == 0xff ); + rVal <<= ( aColor.GetAlpha() == 0 ); break; case MID_GRAPHIC_URL: @@ -2976,7 +2976,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) return false; if(MID_BACK_COLOR_R_G_B == nMemberId) { - aNewCol.SetTransparency(aColor.GetTransparency()); + aNewCol.SetAlpha(aColor.GetAlpha()); } aColor = aNewCol; } @@ -2986,7 +2986,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) sal_Int32 nTrans = 0; if ( !( rVal >>= nTrans ) || nTrans < 0 || nTrans > 100 ) return false; - aColor.SetTransparency(lcl_PercentToTransparency(nTrans)); + aColor.SetAlpha(255 - lcl_PercentToTransparency(nTrans)); } break; @@ -3005,7 +3005,7 @@ bool SvxBrushItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) break; case MID_GRAPHIC_TRANSPARENT: - aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 ); + aColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); break; case MID_GRAPHIC_URL: diff --git a/editeng/source/items/legacyitem.cxx b/editeng/source/items/legacyitem.cxx index 509c7a68b6aa..d630c4e5f0b3 100644 --- a/editeng/source/items/legacyitem.cxx +++ b/editeng/source/items/legacyitem.cxx @@ -802,7 +802,7 @@ namespace legacy aSerializer.readColor(aColor); aSerializer.readColor(aFillColor); rStrm.ReadSChar(nStyle); - aColor.SetTransparency(bTrans ? 0xff : 0); + aColor.SetAlpha(bTrans ? 0 : 255); rItem.SetLocation(static_cast(cLoc)); rItem.SetWidth(_nWidth); diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index 5b931336426e..e83d08b35504 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -963,7 +963,7 @@ bool SvxTextLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= mColor; break; case MID_TL_HASCOLOR: - rVal <<= !mColor.GetTransparency(); + rVal <<= mColor.GetAlpha() == 255; break; } return true; @@ -997,14 +997,14 @@ 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 nTrans = mColor.GetTransparency(); + sal_uInt8 nAlpha = mColor.GetAlpha(); mColor = Color( nCol ); - mColor.SetTransparency( nTrans ); + mColor.SetAlpha( nAlpha ); } } break; case MID_TL_HASCOLOR: - mColor.SetTransparency( Any2Bool( rVal ) ? 0 : 0xff ); + mColor.SetAlpha( Any2Bool( rVal ) ? 255 : 0 ); break; } return bRet; @@ -1339,7 +1339,7 @@ bool SvxBackgroundColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) c { case MID_GRAPHIC_TRANSPARENT: { - rVal <<= aColor.GetTransparency() == 0xff; + rVal <<= aColor.GetAlpha() == 0; break; } default: @@ -1361,7 +1361,7 @@ bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId { case MID_GRAPHIC_TRANSPARENT: { - aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 ); + aColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); SvxColorItem::SetValue( aColor ); break; } @@ -1407,7 +1407,7 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const { case MID_COLOR_ALPHA: { - auto fTransparency = static_cast(mColor.GetTransparency()) * 100 / 255; + auto fTransparency = static_cast(255 - mColor.GetAlpha()) * 100 / 255; rVal <<= static_cast(basegfx::fround(fTransparency)); break; } @@ -1432,7 +1432,7 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) if (bRet) { auto fTransparency = static_cast(nTransparency) * 255 / 100; - mColor.SetTransparency(static_cast(basegfx::fround(fTransparency))); + mColor.SetAlpha(255 - static_cast(basegfx::fround(fTransparency))); } return bRet; } -- cgit