diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-01-11 08:54:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-12 17:38:53 +0100 |
commit | d765ec2295d12ccde1fb25aa92c5d821de748add (patch) | |
tree | c2f806389478df23b78319c6043971f92995851c /sw | |
parent | a1d6701105456248f6ff39766a6699f26a8f3d60 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/inc/swmodeltestbase.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/layout/paintfrm.cxx | 6 | ||||
-rw-r--r-- | sw/source/core/text/inftxt.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 4 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxsdrexport.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8esh.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8graf.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par6.cxx | 2 | ||||
-rw-r--r-- | sw/source/filter/xml/xmlimpit.cxx | 4 |
9 files changed, 15 insertions, 15 deletions
diff --git a/sw/qa/inc/swmodeltestbase.hxx b/sw/qa/inc/swmodeltestbase.hxx index ceb2bbe125d0..83ba3245dafe 100644 --- a/sw/qa/inc/swmodeltestbase.hxx +++ b/sw/qa/inc/swmodeltestbase.hxx @@ -429,7 +429,7 @@ inline std::ostream& operator<<(std::ostream& rStrm, const Color& rColor) rStrm << "Color: R:" << static_cast<int>(rColor.GetRed()) << " G:" << static_cast<int>(rColor.GetGreen()) << " B:" << static_cast<int>(rColor.GetBlue()) - << " A:" << static_cast<int>(rColor.GetTransparency()); + << " A:" << static_cast<int>(255 - rColor.GetAlpha()); return rStrm; } diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 27bfd520e03c..c1205226ea86 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -1571,7 +1571,7 @@ static void lcl_implDrawGraphicBackgrd( const SvxBrushItem& _rBackgrdBrush, /// background color is transparent --> draw transparent. { bDrawTransparent = true; - nTransparencyPercent = (aColor.GetTransparency()*100 + 0x7F)/0xFF; + nTransparencyPercent = ((255 - aColor.GetAlpha())*100 + 0x7F)/0xFF; } else if ( (_rGraphicObj.GetAttr().IsTransparent()) && (_rBackgrdBrush.GetColor() == COL_TRANSPARENT) ) @@ -2107,7 +2107,7 @@ void DrawGraphic( // the transparency value is taken from the background graphic, // otherwise take the transparency value from the color. sal_Int8 nTransparencyPercent = static_cast<sal_Int8>( - (( bTransparentGrfWithNoFillBackgrd ? nGrfTransparency : aColor.GetTransparency() + (( bTransparentGrfWithNoFillBackgrd ? nGrfTransparency : (255 - aColor.GetAlpha()) )*100 + 0x7F)/0xFF); // draw poly-polygon transparent pOutDev->DrawTransparent( aDrawPoly, nTransparencyPercent ); @@ -7303,7 +7303,7 @@ bool SwFrame::GetBackgroundBrush( bNewDrawingLayerFillStyleIsUsedAndNotNoFill || // done when SvxBrushItem is used - !rBack.GetColor().GetTransparency() || rBack.GetGraphicPos() != GPOS_NONE || + rBack.GetColor().GetAlpha() == 255 || rBack.GetGraphicPos() != GPOS_NONE || // done when direct color is forced rxCol || diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx index 8ff2aac8d8da..b2d5bfa28728 100644 --- a/sw/source/core/text/inftxt.cxx +++ b/sw/source/core/text/inftxt.cxx @@ -602,7 +602,7 @@ SwTransparentTextGuard::~SwTransparentTextGuard() m_aContentMetafile.SetPrefSize(m_aPorRect.SSize()); m_rDrawInf.SetOut(*m_rPaintInf.GetOut()); Gradient aVCLGradient; - sal_uInt8 nTransPercentVcl = m_rPaintInf.GetFont()->GetColor().GetTransparency(); + sal_uInt8 nTransPercentVcl = 255 - m_rPaintInf.GetFont()->GetColor().GetAlpha(); const Color aTransColor(nTransPercentVcl, nTransPercentVcl, nTransPercentVcl); aVCLGradient.SetStyle(GradientStyle::Linear); aVCLGradient.SetStartColor(aTransColor); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index e5b068a11676..29da55150a6a 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7444,7 +7444,7 @@ void DocxAttributeOutput::CharColor( const SvxColorItem& rColor ) } AddToAttrList( m_pColorAttrList, FSNS( XML_w, XML_val ), aColorString.getStr() ); - m_nCharTransparence = aColor.GetTransparency(); + m_nCharTransparence = 255 - aColor.GetAlpha(); } void DocxAttributeOutput::CharContour( const SvxContourItem& rContour ) @@ -9038,7 +9038,7 @@ void DocxAttributeOutput::FormatAnchor( const SwFormatAnchor& ) static std::optional<sal_Int32> lcl_getDmlAlpha(const SvxBrushItem& rBrush) { std::optional<sal_Int32> oRet; - sal_Int32 nTransparency = rBrush.GetColor().GetTransparency(); + sal_Int32 nTransparency = 255 - rBrush.GetColor().GetAlpha(); if (nTransparency) { // Convert transparency to percent diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx index 1ed60de45e25..1af1dce13942 100644 --- a/sw/source/filter/ww8/docxsdrexport.cxx +++ b/sw/source/filter/ww8/docxsdrexport.cxx @@ -1083,7 +1083,7 @@ static OString lcl_TransparencyToDrawingMlAlpha(const Color& rColor) { if (rColor.IsTransparent()) { - sal_Int32 nAlphaPercent = 100 - float(rColor.GetTransparency()) / 2.55; + sal_Int32 nAlphaPercent = float(rColor.GetAlpha()) / 2.55; return OString::number(nAlphaPercent * oox::drawingml::PER_PERCENT); } diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx index 8b514baa59a4..48bf34fc9881 100644 --- a/sw/source/filter/ww8/wrtw8esh.cxx +++ b/sw/source/filter/ww8/wrtw8esh.cxx @@ -1869,7 +1869,7 @@ void SwBasicEscherEx::WriteBrushAttr(const SvxBrushItem &rBrush, rPropOpt.AddOpt( ESCHER_Prop_fillBackColor, nFillColor ^ 0xffffff ); rPropOpt.AddOpt( ESCHER_Prop_fNoFillHitTest, 0x100010 ); - nOpaque = rBrush.GetColor().GetTransparency(); + nOpaque = 255 - rBrush.GetColor().GetAlpha(); if (0 != nOpaque) bSetOpacity = true; } diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx index de8a1866ba36..c04770c53f3c 100644 --- a/sw/source/filter/ww8/ww8graf.cxx +++ b/sw/source/filter/ww8/ww8graf.cxx @@ -1838,7 +1838,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, sal_uInt16 nRes = WW8ITEMVALUE(rOldSet, XATTR_FILLTRANSPARENCE, XFillTransparenceItem); nTrans = sal_uInt8((nRes * 0xFE) / 100); - aBrushItem.GetColor().SetTransparency(nTrans); + aBrushItem.GetColor().SetAlpha(255 - nTrans); bBrushItemOk = true; } @@ -1855,7 +1855,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, // Writer graphics don't have it yet if (eShapeType != mso_sptPictureFrame) { - aBrushItem.GetColor().SetTransparency(0xFE); + aBrushItem.GetColor().SetAlpha(1); bBrushItemOk = true; } break; @@ -1867,7 +1867,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, aBrushItem.SetColor(aColor); if (bBrushItemOk) // has trans - aBrushItem.GetColor().SetTransparency(nTrans); + aBrushItem.GetColor().SetAlpha(255 - nTrans); bBrushItemOk = true; } diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 75289e386eb4..762ea0c81869 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -3605,7 +3605,7 @@ void SwWW8ImplReader::Read_TextForeColor(sal_uInt16, const sal_uInt8* pData, sho // At least when transparency is 0xff and the color is black, Word renders that as black. if (aColor.IsTransparent() && aColor != COL_AUTO) { - aColor.SetTransparency(0); + aColor.SetAlpha(255); } NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR)); diff --git a/sw/source/filter/xml/xmlimpit.cxx b/sw/source/filter/xml/xmlimpit.cxx index f41cec7cd206..2d0ea2bc046d 100644 --- a/sw/source/filter/xml/xmlimpit.cxx +++ b/sw/source/filter/xml/xmlimpit.cxx @@ -700,13 +700,13 @@ bool SvXMLImportItemMapper::PutXMLValue( case MID_BACK_COLOR: if( IsXMLToken( rValue, XML_TRANSPARENT ) ) { - rBrush.GetColor().SetTransparency(0xff); + rBrush.GetColor().SetAlpha(0); bOk = true; } else if (::sax::Converter::convertColor(nTempColor, rValue)) { Color aTempColor(nTempColor); - aTempColor.SetTransparency(0); + aTempColor.SetAlpha(255); rBrush.SetColor( aTempColor ); bOk = true; } |