From 9487b7130609c85ccd9c6ece331bb31e3be68a51 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 10 Jul 2013 09:41:23 +0200 Subject: [PATCH] SvxBrushItem::TransparencyToPercent: add this to avoid copypaste Change-Id: I9b77c0a48b7de39eadae118c24c70ac415898293 --- editeng/source/items/frmitems.cxx | 4 ++-- include/editeng/brushitem.hxx | 1 + sw/source/filter/ww8/docxattributeoutput.cxx | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 8dedafd3a2a8..987c888be328 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -3567,7 +3567,7 @@ static inline sal_Int8 lcl_PercentToTransparency(long nPercent) //0xff must not be returned! return sal_Int8(nPercent ? (50 + 0xfe * nPercent) / 100 : 0); } -static inline sal_Int8 lcl_TransparencyToPercent(sal_Int32 nTrans) +sal_Int8 SvxBrushItem::TransparencyToPercent(sal_Int32 nTrans) { return (sal_Int8)((nTrans * 100 + 127) / 254); } @@ -3584,7 +3584,7 @@ bool SvxBrushItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= (sal_Int32)( aColor.GetRGBColor() ); break; case MID_BACK_COLOR_TRANSPARENCY: - rVal <<= lcl_TransparencyToPercent(aColor.GetTransparency()); + rVal <<= SvxBrushItem::TransparencyToPercent(aColor.GetTransparency()); break; case MID_GRAPHIC_POSITION: rVal <<= (style::GraphicLocation)(sal_Int16)eGraphicPos; diff --git a/include/editeng/brushitem.hxx b/include/editeng/brushitem.hxx index d18882ad3cba..d05ee3bf56a8 100644 --- a/include/editeng/brushitem.hxx +++ b/include/editeng/brushitem.hxx @@ -122,6 +122,7 @@ public: static SvxGraphicPosition WallpaperStyle2GraphicPos( WallpaperStyle eStyle ); static WallpaperStyle GraphicPos2WallpaperStyle( SvxGraphicPosition ePos ); + static sal_Int8 TransparencyToPercent(sal_Int32 nTrans); }; #endif // #ifndef _SVX_BRSHITEM_HXX diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5a0f8a09686d..69c3888a2baf 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4864,8 +4864,7 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) if (nTransparency) { // Convert transparency to percent - // Consider editeng/source/items/frmitems.cxx : lcl_TransparencyToPercent() function. - sal_Int8 nTransparencyPercent = (sal_Int8)((nTransparency * 100 + 127) / 254); + sal_Int8 nTransparencyPercent = SvxBrushItem::TransparencyToPercent(nTransparency); // Calculate alpha value // Consider oox/source/drawingml/color.cxx : getTransparency() function.