summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-05-07 09:32:48 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-05-07 09:32:48 +0200
commitc450ea69921001621a1114369b3508bfa69bd088 (patch)
tree4989f9274bb926816546e2b0b2c5f20566c7ebd4
parent71bf95db0bf87424678ce62d526e14848cdafec7 (diff)
introduce msfilter::util::BGRToRGB to avoid copy&paste
Change-Id: Ic3fa8865bf3862407867b5e4a438e3d9bc723e86
-rw-r--r--filter/inc/filter/msfilter/util.hxx2
-rw-r--r--filter/source/msfilter/util.cxx11
-rw-r--r--sw/source/filter/ww8/ww8par6.cxx17
-rw-r--r--sw/source/filter/ww8/ww8struc.hxx4
-rw-r--r--writerfilter/source/rtftok/rtfsdrimport.cxx17
5 files changed, 21 insertions, 30 deletions
diff --git a/filter/inc/filter/msfilter/util.hxx b/filter/inc/filter/msfilter/util.hxx
index 01ff3738b64a..2dc5fa7f3966 100644
--- a/filter/inc/filter/msfilter/util.hxx
+++ b/filter/inc/filter/msfilter/util.hxx
@@ -41,6 +41,8 @@ namespace util {
/// what the encoding is, but you know or can guess the language
MSFILTER_DLLPUBLIC rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale);
+/// Convert a color in BGR format to RGB.
+MSFILTER_DLLPUBLIC sal_uInt32 BGRToRGB(sal_uInt32 nColour);
}
}
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 76fe07c7aea8..03df8afb583a 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -51,6 +51,17 @@ rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Loc
return RTL_TEXTENCODING_MS_1252;
}
+sal_uInt32 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;
+}
+
}
}
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 8a719998bc62..d0a94a1c8c6f 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3363,24 +3363,13 @@ void SwWW8ImplReader::Read_TxtColor( sal_uInt16, const sal_uInt8* pData, short n
}
}
-sal_uInt32 wwUtility::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;
-}
-
void SwWW8ImplReader::Read_TxtForeColor(sal_uInt16, const sal_uInt8* pData, short nLen)
{
if( nLen < 0 )
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
else
{
- Color aColor(wwUtility::BGRToRGB(SVBT32ToUInt32(pData)));
+ Color aColor(msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)));
NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR));
if (pAktColl && pStyles)
pStyles->bTxtColChanged = true;
@@ -4663,9 +4652,9 @@ sal_uInt32 SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67)
{
(void) bVer67; // unused in non-debug
OSL_ENSURE(bVer67 == false, "Impossible");
- sal_uInt32 nFore = wwUtility::BGRToRGB(SVBT32ToUInt32(rpData));
+ sal_uInt32 nFore = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
rpData+=4;
- sal_uInt32 nBack = wwUtility::BGRToRGB(SVBT32ToUInt32(rpData));
+ sal_uInt32 nBack = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
rpData+=4;
sal_uInt16 nIndex = SVBT16ToShort(rpData);
rpData+=2;
diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx
index 3790ebf3b546..98dff63a9d8a 100644
--- a/sw/source/filter/ww8/ww8struc.hxx
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -34,6 +34,7 @@
#include <sal/config.h>
#include <editeng/borderline.hxx>
+#include <filter/msfilter/util.hxx>
#if defined OSL_BIGENDIAN || SAL_TYPES_ALIGNMENT4 > 2 || defined UNX
# define __WW8_NEEDS_COPY
@@ -978,8 +979,7 @@ struct SEPr
namespace wwUtility
{
- sal_uInt32 BGRToRGB(sal_uInt32 nColour);
- inline sal_uInt32 RGBToBGR(sal_uInt32 nColour) { return BGRToRGB(nColour); }
+ inline sal_uInt32 RGBToBGR(sal_uInt32 nColour) { return msfilter::util::BGRToRGB(nColour); }
}
#endif
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 01b1d00d96b1..4fc04532cebf 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -35,6 +35,7 @@
#include <ooxml/resourceids.hxx> // NS_ooxml namespace
#include <filter/msfilter/escherex.hxx>
+#include <filter/msfilter/util.hxx>
#include <rtfsdrimport.hxx>
@@ -44,18 +45,6 @@ using rtl::OUString;
using rtl::OUStringBuffer;
using rtl::OUStringToOString;
-// NEEDSWORK: wwUtility::BGRToRGB does the same.
-static sal_uInt32 lcl_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;
-}
-
namespace writerfilter {
namespace rtftok {
@@ -132,14 +121,14 @@ void RTFSdrImport::resolve(RTFShape& rShape)
}
else if (i->first == "fillColor" && xPropertySet.is())
{
- aAny <<= lcl_BGRToRGB(i->second.toInt32());
+ aAny <<= msfilter::util::BGRToRGB(i->second.toInt32());
xPropertySet->setPropertyValue("FillColor", aAny);
}
else if ( i->first == "fillBackColor" )
; // Ignore: complementer of fillColor
else if (i->first == "lineColor" && xPropertySet.is())
{
- aAny <<= lcl_BGRToRGB(i->second.toInt32());
+ aAny <<= msfilter::util::BGRToRGB(i->second.toInt32());
xPropertySet->setPropertyValue("LineColor", aAny);
}
else if ( i->first == "lineBackColor" )