filter/source/msfilter/util.cxx             |    5 ++---
 include/filter/msfilter/util.hxx            |    2 +-
 sw/source/filter/ww8/wrtww8gr.cxx           |    4 ++--
 sw/source/filter/ww8/ww8atr.cxx             |    2 +-
 sw/source/filter/ww8/ww8par6.cxx            |   14 +++++++-------
 sw/source/filter/ww8/ww8struc.hxx           |    2 +-
 writerfilter/source/rtftok/rtfsdrimport.cxx |   14 ++++++--------
 7 files changed, 20 insertions(+), 23 deletions(-)

New commits:
commit 5bbaca6d3ccef10223b8618c25f41b91dd467ffc
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Jan 16 19:20:07 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Jan 17 08:51:14 2021 +0100

    return Color from BGRToRGB
    
    instead of converting at all the call-sites
    
    Change-Id: I4732082fcd4731f6fd46aef197a15564586f0c90
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109450
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index c72a2802c7be..63d12f514c24 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -42,15 +42,14 @@ rtl_TextEncoding getBestTextEncodingFromLocale(const 
css::lang::Locale &rLocale)
     return RTL_TEXTENCODING_MS_1252;
 }
 
-sal_uInt32 BGRToRGB(sal_uInt32 nColor)
+::Color BGRToRGB(sal_uInt32 nColor)
 {
     sal_uInt8
         r(static_cast<sal_uInt8>(nColor&0xFF)),
         g(static_cast<sal_uInt8>((nColor>>8)&0xFF)),
         b(static_cast<sal_uInt8>((nColor>>16)&0xFF)),
         t(static_cast<sal_uInt8>((nColor>>24)&0xFF));
-    nColor = (t<<24) + (r<<16) + (g<<8) + b;
-    return nColor;
+    return ::Color(ColorTransparency, (t<<24) + (r<<16) + (g<<8) + b);
 }
 
 DateTime DTTM2DateTime( tools::Long lDTTM )
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index cb70198ebedd..7e25e701420d 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -34,7 +34,7 @@ namespace msfilter::util {
 MSFILTER_DLLPUBLIC rtl_TextEncoding getBestTextEncodingFromLocale(const 
css::lang::Locale &rLocale);
 
 /// Convert a color in BGR format to RGB.
-MSFILTER_DLLPUBLIC sal_uInt32 BGRToRGB(sal_uInt32 nColour);
+MSFILTER_DLLPUBLIC ::Color BGRToRGB(sal_uInt32 nColour);
 
 /** Convert from DTTM to Writer's DateTime
   */
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx 
b/sw/source/filter/ww8/wrtww8gr.cxx
index aedca139434b..b79641c5372a 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -524,8 +524,8 @@ void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const 
ww8::Frame &rFly,
                 {
                     WW8_BRCVer9 aBrc90 = WW8Export::TranslateBorderLine( *pLn,
                         pBox->GetDistance( i ), bShadow );
-                    sal_uInt8 ico = 
msfilter::util::TransColToIco(Color(ColorTransparency, msfilter::util::BGRToRGB(
-                        aBrc90.cv())));
+                    sal_uInt8 ico = 
msfilter::util::TransColToIco(msfilter::util::BGRToRGB(
+                        aBrc90.cv()));
                     aBrc = WW8_BRC(aBrc90.dptLineWidth(), aBrc90.brcType(), 
ico,
                         aBrc90.dptSpace(), aBrc90.fShadow(), aBrc90.fFrame());
                 }
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 2d5ae8d3a31a..e6501dc34ca3 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4408,7 +4408,7 @@ void WW8Export::Out_BorderLine(ww::bytes& rO, const 
SvxBorderLine* pLine,
     if( pLine && pLine->GetBorderLineStyle() != SvxBorderLineStyle::NONE )
     {
         aBrcVer9 = TranslateBorderLine( *pLine, nDist, bShadow );
-        sal_uInt8 ico = msfilter::util::TransColToIco( 
Color(ColorTransparency, msfilter::util::BGRToRGB(aBrcVer9.cv())) );
+        sal_uInt8 ico = msfilter::util::TransColToIco( 
msfilter::util::BGRToRGB(aBrcVer9.cv()) );
         aBrcVer8 = WW8_BRC( aBrcVer9.dptLineWidth(), aBrcVer9.brcType(), ico,
             aBrcVer9.dptSpace(), aBrcVer9.fShadow(), aBrcVer9.fFrame() );
     }
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index e717e797a2a9..815c3ef97bef 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -1458,7 +1458,7 @@ static void GetLineIndex(SvxBoxItem &rBox, short 
nLineThickness, short nSpace,
     aLine.SetWidth(fConverted);
 
     //No AUTO for borders as yet, so if AUTO, use BLACK
-    Color col = (cv==0xff000000) ? COL_BLACK : Color(ColorTransparency, 
msfilter::util::BGRToRGB(cv));
+    Color col = (cv==0xff000000) ? COL_BLACK : msfilter::util::BGRToRGB(cv);
 
     aLine.SetColor(col);
 
@@ -3600,7 +3600,7 @@ void SwWW8ImplReader::Read_TextForeColor(sal_uInt16, 
const sal_uInt8* pData, sho
         m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), RES_CHRATR_COLOR );
     else
     {
-        Color aColor(ColorTransparency, 
msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)));
+        Color aColor = msfilter::util::BGRToRGB(SVBT32ToUInt32(pData));
 
         // At least when transparency is 0xff and the color is black, Word 
renders that as black.
         if (aColor.IsTransparent() && aColor != COL_AUTO)
@@ -3634,7 +3634,7 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, 
const sal_uInt8* pData, sh
                 {
                     const SwAttrSet& aSet = m_pCurrentColl->GetAttrSet();
                     std::unique_ptr<SvxUnderlineItem> 
pUnderline(aSet.Get(RES_CHRATR_UNDERLINE, false).Clone());
-                    pUnderline->SetColor( Color(ColorTransparency, 
msfilter::util::BGRToRGB(SVBT32ToUInt32(pData))) );
+                    pUnderline->SetColor( 
msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) );
                     m_pCurrentColl->SetFormatAttr( *pUnderline );
                 }
             }
@@ -3646,7 +3646,7 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, 
const sal_uInt8* pData, sh
                 if (nLen >= 4)
                 {
                     std::unique_ptr<SvxUnderlineItem> 
pUnderline(m_xCurrentItemSet->Get(RES_CHRATR_UNDERLINE, false).Clone());
-                    pUnderline->SetColor( 
Color(ColorTransparency,msfilter::util::BGRToRGB(SVBT32ToUInt32(pData))) );
+                    pUnderline->SetColor( 
msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) );
                     m_xCurrentItemSet->Put( std::move(pUnderline) );
                 }
             }
@@ -3655,7 +3655,7 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, 
const sal_uInt8* pData, sh
         {
             SvxUnderlineItem* pUnderlineAttr = 
const_cast<SvxUnderlineItem*>(static_cast<const 
SvxUnderlineItem*>(m_xCtrlStck->GetOpenStackAttr( *m_pPaM->GetPoint(), 
RES_CHRATR_UNDERLINE )));
             if (pUnderlineAttr && nLen >= 4)
-                pUnderlineAttr->SetColor( Color(ColorTransparency, 
msfilter::util::BGRToRGB(SVBT32ToUInt32( pData ) )));
+                pUnderlineAttr->SetColor( 
msfilter::util::BGRToRGB(SVBT32ToUInt32( pData ) ));
         }
     }
 }
@@ -4945,9 +4945,9 @@ void SwWW8ImplReader::Read_ParaBackColor(sal_uInt16, 
const sal_uInt8* pData, sho
 Color SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67)
 {
     OSL_ENSURE(!bVer67, "Impossible");
-    Color nFore(ColorTransparency, 
msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData)));
+    Color nFore = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
     rpData+=4;
-    Color nBack(ColorTransparency, 
msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData)));
+    Color nBack = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
     rpData+=4;
     sal_uInt16 nIndex = SVBT16ToUInt16(rpData);
     rpData+=2;
diff --git a/sw/source/filter/ww8/ww8struc.hxx 
b/sw/source/filter/ww8/ww8struc.hxx
index c4b1eabc84c4..825947a19033 100644
--- a/sw/source/filter/ww8/ww8struc.hxx
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -1088,7 +1088,7 @@ namespace wwUtility
     inline sal_uInt32 RGBToBGR(::Color nColour)
     {
         // we can use this because the translation is symmetric
-        return msfilter::util::BGRToRGB(sal_uInt32(nColour));
+        return sal_uInt32(msfilter::util::BGRToRGB(sal_uInt32(nColour)));
     }
 }
 
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx 
b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 074252fd768b..56b586c9e7c5 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -448,10 +448,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, 
ShapeOrPict const shap
         }
         else if (rProperty.first == "fillBackColor")
             // fillType will decide, possible it'll be the end color of a 
gradient.
-            aFillModel.moColor2.set(
-                "#"
-                + OUString::fromUtf8(msfilter::util::ConvertColor(Color(
-                      ColorTransparency, 
msfilter::util::BGRToRGB(rProperty.second.toInt32())))));
+            aFillModel.moColor2.set("#"
+                                    + 
OUString::fromUtf8(msfilter::util::ConvertColor(
+                                          
msfilter::util::BGRToRGB(rProperty.second.toInt32()))));
         else if (rProperty.first == "lineColor")
             aLineColor <<= 
msfilter::util::BGRToRGB(rProperty.second.toInt32());
         else if (rProperty.first == "lineBackColor")
@@ -672,10 +671,9 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, 
ShapeOrPict const shap
                 aShadowModel.mbHasShadow = true;
         }
         else if (rProperty.first == "shadowColor")
-            aShadowModel.moColor.set(
-                "#"
-                + OUString::fromUtf8(msfilter::util::ConvertColor(Color(
-                      ColorTransparency, 
msfilter::util::BGRToRGB(rProperty.second.toInt32())))));
+            aShadowModel.moColor.set("#"
+                                     + 
OUString::fromUtf8(msfilter::util::ConvertColor(
+                                           
msfilter::util::BGRToRGB(rProperty.second.toInt32()))));
         else if (rProperty.first == "shadowOffsetX")
             // EMUs to points
             
aShadowModel.moOffset.set(OUString::number(rProperty.second.toDouble() / 12700) 
+ "pt");
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to