Kaydet (Commit) c450ea69 authored tarafından Miklos Vajna's avatar Miklos Vajna

introduce msfilter::util::BGRToRGB to avoid copy&paste

Change-Id: Ic3fa8865bf3862407867b5e4a438e3d9bc723e86
üst 71bf95db
......@@ -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);
}
}
......
......@@ -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;
}
}
}
......
......@@ -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;
......
......@@ -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
......
......@@ -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" )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment