diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2020-12-24 11:32:51 +1100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-12-26 19:25:17 +0100 |
commit | b75c9642f0cae522c5cc0f059e801819662b2ddf (patch) | |
tree | 2afc38645359cc5dfd007b94b63117c8c1898239 | |
parent | 43978d8f25a41c20c72d93cc3cb972c93c52674a (diff) |
vcl: use Color:IsTransparent() where appropriate
Change-Id: I37bbab5f22f91faad65be8ef79734ce1ee6355d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108249
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | drawinglayer/source/tools/emfphelperdata.cxx | 4 | ||||
-rw-r--r-- | editeng/source/items/frmitems.cxx | 2 | ||||
-rw-r--r-- | editeng/source/items/legacyitem.cxx | 6 | ||||
-rw-r--r-- | include/tools/color.hxx | 3 | ||||
-rw-r--r-- | sc/source/ui/app/inputhdl.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/view/output2.cxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 2 | ||||
-rw-r--r-- | svx/source/dialog/fntctrl.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdotextdecomposition.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/access/accframe.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/layout/atrfrm.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 14 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 2 | ||||
-rw-r--r-- | vcl/skia/salbmp.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 2 | ||||
-rw-r--r-- | xmloff/source/style/shadwhdl.cxx | 2 |
17 files changed, 31 insertions, 32 deletions
diff --git a/drawinglayer/source/tools/emfphelperdata.cxx b/drawinglayer/source/tools/emfphelperdata.cxx index f486d59375fd..fcd5697161a0 100644 --- a/drawinglayer/source/tools/emfphelperdata.cxx +++ b/drawinglayer/source/tools/emfphelperdata.cxx @@ -1666,7 +1666,7 @@ namespace emfplushelper color.getBColor()); } drawinglayer::primitive2d::Primitive2DReference aPrimitiveText(pBaseText); - if (color.GetTransparency() != 0) + if (color.IsTransparent()) { aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText }, @@ -2151,7 +2151,7 @@ namespace emfplushelper color.getBColor()); } drawinglayer::primitive2d::Primitive2DReference aPrimitiveText(pBaseText); - if (color.GetTransparency() != 0) + if (color.IsTransparent()) { aPrimitiveText = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( drawinglayer::primitive2d::Primitive2DContainer { aPrimitiveText }, diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 283fc2fb6eab..cb3c4a14a136 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -1032,7 +1032,7 @@ bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const } aShadow.Location = eSet; aShadow.ShadowWidth = bConvert ? convertTwipToMm100(nWidth) : nWidth; - aShadow.IsTransparent = aShadowColor.GetTransparency() > 0; + aShadow.IsTransparent = aShadowColor.IsTransparent(); aShadow.Color = sal_Int32(aShadowColor); sal_Int8 nTransparence = rtl::math::round(float(aShadowColor.GetTransparency() * 100) / 255); diff --git a/editeng/source/items/legacyitem.cxx b/editeng/source/items/legacyitem.cxx index af41980b2d2c..bb9a7cf03b47 100644 --- a/editeng/source/items/legacyitem.cxx +++ b/editeng/source/items/legacyitem.cxx @@ -595,7 +595,7 @@ namespace legacy tools::GenericTypeSerializer aSerializer(rStrm); aSerializer.writeColor(rItem.GetColor()); aSerializer.writeColor(rItem.GetColor()); - rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID + rStrm.WriteSChar( rItem.GetColor().IsTransparent() ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID sal_uInt16 nDoLoad = 0; const GraphicObject* pGraphicObject(rItem.GetGraphicObject()); @@ -811,11 +811,11 @@ namespace legacy { rStrm.WriteSChar( static_cast<sal_uInt8>(rItem.GetLocation()) ) .WriteUInt16( rItem.GetWidth() ) - .WriteBool( rItem.GetColor().GetTransparency() > 0 ); + .WriteBool( rItem.GetColor().IsTransparent() ); tools::GenericTypeSerializer aSerializer(rStrm); aSerializer.writeColor(rItem.GetColor()); aSerializer.writeColor(rItem.GetColor()); - rStrm.WriteSChar( rItem.GetColor().GetTransparency() > 0 ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID + rStrm.WriteSChar( rItem.GetColor().IsTransparent() ? 0 : 1 ); //BRUSH_NULL : BRUSH_SOLID return rStrm; } } diff --git a/include/tools/color.hxx b/include/tools/color.hxx index 964e8ca8d157..27b63b178715 100644 --- a/include/tools/color.hxx +++ b/include/tools/color.hxx @@ -143,11 +143,10 @@ public: } /** Is the color transparent? - * @returns true or false */ bool IsTransparent() const { - return (GetTransparency() != 0); + return GetTransparency() != 0; } /** Sets the red value. diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx index 5d802fd9d5f7..612a97cb2209 100644 --- a/sc/source/ui/app/inputhdl.cxx +++ b/sc/source/ui/app/inputhdl.cxx @@ -2425,7 +2425,7 @@ bool ScInputHandler::StartTable( sal_Unicode cTyped, bool bFromCommand, bool bIn Color aBackCol = pPattern->GetItem( ATTR_BACKGROUND ).GetColor(); ScModule* pScMod = SC_MOD(); - if ( aBackCol.GetTransparency() > 0 || + if ( aBackCol.IsTransparent() || Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) aBackCol = pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; mpEditEngine->SetBackgroundColor( aBackCol ); diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index b0d5f2075c73..a790cb8c4a17 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -2444,7 +2444,7 @@ void ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor) } Color aBackCol = mpPattern->GetItem( ATTR_BACKGROUND, mpCondSet ).GetColor(); - if ( bUseStyleColor && ( aBackCol.GetTransparency() > 0 || bCellContrast ) ) + if ( bUseStyleColor && ( aBackCol.IsTransparent() || bCellContrast ) ) aBackCol = nConfBackColor; mpEngine->SetBackgroundColor( aBackCol ); } @@ -4604,7 +4604,7 @@ void ScOutputData::DrawRotated(bool bPixelToLogic) Color aBackCol = pPattern->GetItem( ATTR_BACKGROUND, pCondSet ).GetColor(); - if ( mbUseStyleColor && ( aBackCol.GetTransparency() > 0 || bCellContrast ) ) + if ( mbUseStyleColor && ( aBackCol.IsTransparent() || bCellContrast ) ) aBackCol = nConfBackColor; pEngine->SetBackgroundColor( aBackCol ); } diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 2d30a3504f75..a18b8f15e52b 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1748,7 +1748,7 @@ void ScViewData::SetEditEngine( ScSplitPos eWhich, Color aBackCol = pPattern->GetItem(ATTR_BACKGROUND).GetColor(); ScModule* pScMod = SC_MOD(); - if ( aBackCol.GetTransparency() > 0 ) + if ( aBackCol.IsTransparent() ) { aBackCol = pScMod->GetColorConfig().GetColorValue(svtools::DOCCOLOR).nColor; } diff --git a/svx/source/dialog/fntctrl.cxx b/svx/source/dialog/fntctrl.cxx index 1b2eb421aad3..12afafcb0939 100644 --- a/svx/source/dialog/fntctrl.cxx +++ b/svx/source/dialog/fntctrl.cxx @@ -996,7 +996,7 @@ void SvxFontPrevWindow::SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBack { const SvxBrushItem& rBrush = static_cast<const SvxBrushItem&>( rSet.Get( nWhich ) ); const Color& rColor = rBrush.GetColor(); - bTransparent = rColor.GetTransparency() > 0; + bTransparent = rColor.IsTransparent(); rFont.SetFillColor( rColor ); rCJKFont.SetFillColor( rColor ); rCTLFont.SetFillColor( rColor ); diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index f95a59f44c80..2661c98b72e5 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -358,7 +358,7 @@ namespace aTextFillColor); } - if (aFontColor.GetTransparency() != 0) + if (aFontColor.IsTransparent()) { // Handle semi-transparent text for both the decorated and simple case here. pNewPrimitive = new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D( diff --git a/sw/source/core/access/accframe.cxx b/sw/source/core/access/accframe.cxx index a3ece547a8a9..2e47aefcdcf4 100644 --- a/sw/source/core/access/accframe.cxx +++ b/sw/source/core/access/accframe.cxx @@ -381,8 +381,8 @@ bool SwAccessibleFrame::IsOpaque( SwViewShell const *pVSh ) const // If a fly frame has a transparent background color, we have to consider the background. // But a background color "no fill"/"auto fill" should *not* be considered. if( pFrame->IsFlyFrame() && - (rBack.GetColor().GetTransparency() != 0) && - (rBack.GetColor() != COL_TRANSPARENT) + rBack.GetColor().IsTransparent() && + rBack.GetColor() != COL_TRANSPARENT ) return true; diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx index 5d9ffa3e3254..73078517cc03 100644 --- a/sw/source/core/layout/atrfrm.cxx +++ b/sw/source/core/layout/atrfrm.cxx @@ -3205,8 +3205,8 @@ bool SwFlyFrameFormat::IsBackgroundTransparent() const // from its anchor. std::unique_ptr<SvxBrushItem> aBackground(makeBackgroundBrushItem()); if ( aBackground && - (aBackground->GetColor().GetTransparency() != 0) && - (aBackground->GetColor() != COL_TRANSPARENT) + aBackground->GetColor().IsTransparent() && + aBackground->GetColor() != COL_TRANSPARENT ) { return true; @@ -3215,7 +3215,7 @@ bool SwFlyFrameFormat::IsBackgroundTransparent() const { const GraphicObject *pTmpGrf = aBackground->GetGraphicObject(); if ( pTmpGrf && - (pTmpGrf->GetAttr().GetTransparency() != 0) + pTmpGrf->GetAttr().IsTransparent() ) { return true; diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 9609a6567af2..27bfd520e03c 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1567,13 +1567,13 @@ static void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, /// and calculate transparency percent value sal_Int8 nTransparencyPercent = 0; bool bDrawTransparent = false; - if ( aColor.GetTransparency() != 0 ) + if ( aColor.IsTransparent() ) /// background color is transparent --> draw transparent. { bDrawTransparent = true; nTransparencyPercent = (aColor.GetTransparency()*100 + 0x7F)/0xFF; } - else if ( (_rGraphicObj.GetAttr().GetTransparency() != 0) && + else if ( (_rGraphicObj.GetAttr().IsTransparent()) && (_rBackgrdBrush.GetColor() == COL_TRANSPARENT) ) /// graphic is drawn transparent and background color is /// "no fill"/"auto fill" --> draw transparent @@ -2003,7 +2003,7 @@ void DrawGraphic( if ( bConsiderBackgroundTransparency ) { GraphicAttr aGrfAttr = pGrf->GetAttr(); - if ( (aGrfAttr.GetTransparency() != 0) && + if ( (aGrfAttr.IsTransparent()) && (pBrush->GetColor() == COL_TRANSPARENT) ) { @@ -2040,7 +2040,7 @@ void DrawGraphic( } eDrawStyle = Default; if (bConsiderBackgroundTransparency && - ( ( aColor.GetTransparency() != 0) || + ( ( aColor.IsTransparent()) || bTransparentGrfWithNoFillBackgrd ) ) { eDrawStyle = Transparent; @@ -3765,7 +3765,7 @@ bool SwFlyFrame::IsBackgroundTransparent() const if ( GetBackgroundBrush( aFillAttributes, pBackgrdBrush, xSectionTOXColor, aDummyRect, false, /*bConsiderTextBox=*/false) ) { if ( xSectionTOXColor && - (xSectionTOXColor->GetTransparency() != 0) && + (xSectionTOXColor->IsTransparent()) && (xSectionTOXColor != COL_TRANSPARENT) ) { bBackgroundTransparent = true; @@ -3776,7 +3776,7 @@ bool SwFlyFrame::IsBackgroundTransparent() const } else if ( pBackgrdBrush ) { - if ( (pBackgrdBrush->GetColor().GetTransparency() != 0) && + if ( (pBackgrdBrush->GetColor().IsTransparent()) && (pBackgrdBrush->GetColor() != COL_TRANSPARENT) ) { bBackgroundTransparent = true; @@ -3786,7 +3786,7 @@ bool SwFlyFrame::IsBackgroundTransparent() const const GraphicObject *pTmpGrf = pBackgrdBrush->GetGraphicObject(); if ( pTmpGrf && - (pTmpGrf->GetAttr().GetTransparency() != 0) + (pTmpGrf->GetAttr().IsTransparent()) ) { bBackgroundTransparent = true; diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 8d6026886b35..54852e600c1b 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -714,7 +714,7 @@ void SwTextPaintInfo::DrawText_( const OUString &rText, const SwLinePortion &rPo // Handle semi-transparent text if necessary. std::unique_ptr<SwTransparentTextGuard, o3tl::default_delete<SwTransparentTextGuard>> pTransparentText; - if (m_pFnt->GetColor() != COL_AUTO && m_pFnt->GetColor().GetTransparency() != 0) + if (m_pFnt->GetColor() != COL_AUTO && m_pFnt->GetColor().IsTransparent()) { pTransparentText.reset(new SwTransparentTextGuard(rPor, *this, aDrawInf)); } diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 570451503029..54ae41500552 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -1082,7 +1082,7 @@ void DocxSdrExport::writeDMLAndVMLDrawing(const SdrObject* sdrObj, // Converts ARGB transparency (0..255) to drawingml alpha (opposite, and 0..100000) static OString lcl_ConvertTransparency(const Color& rColor) { - if (rColor.GetTransparency() > 0) + if (rColor.IsTransparent()) { sal_Int32 nTransparencyPercent = 100 - float(rColor.GetTransparency()) / 2.55; return OString::number(nTransparencyPercent * oox::drawingml::PER_PERCENT); diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 63062aa22a08..c98d5e1aa480 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -674,7 +674,7 @@ const sk_sp<SkImage>& SkiaSalBitmap::GetSkImage() const { SkiaZone zone; sk_sp<SkSurface> surface = SkiaHelper::createSkSurface( - mSize, mEraseColor.GetTransparency() != 0 ? kPremul_SkAlphaType : kOpaque_SkAlphaType); + mSize, mEraseColor.IsTransparent() ? kPremul_SkAlphaType : kOpaque_SkAlphaType); assert(surface); surface->getCanvas()->clear(toSkColor(mEraseColor)); SkiaSalBitmap* thisPtr = const_cast<SkiaSalBitmap*>(this); @@ -921,7 +921,7 @@ bool SkiaSalBitmap::IsFullyOpaqueAsAlpha() const SkAlphaType SkiaSalBitmap::alphaType() const { if (mEraseColorSet) - return mEraseColor.GetTransparency() != 0 ? kPremul_SkAlphaType : kOpaque_SkAlphaType; + return mEraseColor.IsTransparent() ? kPremul_SkAlphaType : kOpaque_SkAlphaType; #if SKIA_USE_BITMAP32 // The bitmap's alpha matters only if SKIA_USE_BITMAP32 is set, otherwise // the alpha is in a separate bitmap. diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 9b70300e5cc7..968af851ae86 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -7162,7 +7162,7 @@ void PDFWriterImpl::drawTextLine( const Point& rPos, tools::Long nWidth, FontStr m_aPages.back().appendMatrix3(aMat, aLine); aLine.append( " cm\n" ); - if ( aUnderlineColor.GetTransparency() != 0 ) + if ( aUnderlineColor.IsTransparent() ) aUnderlineColor = aStrikeoutColor; if ( (eUnderline == LINESTYLE_SMALLWAVE) || diff --git a/xmloff/source/style/shadwhdl.cxx b/xmloff/source/style/shadwhdl.cxx index b0c9e49a5c14..b80db3a8d055 100644 --- a/xmloff/source/style/shadwhdl.cxx +++ b/xmloff/source/style/shadwhdl.cxx @@ -107,7 +107,7 @@ bool XMLShadowPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue if( bRet && ( bColorFound || bOffsetFound ) ) { - aShadow.IsTransparent = aColor.GetTransparency() > 0; + aShadow.IsTransparent = aColor.IsTransparent(); aShadow.Color = sal_Int32(aColor); bRet = true; } |