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 { ...@@ -41,6 +41,8 @@ namespace util {
/// what the encoding is, but you know or can guess the language /// what the encoding is, but you know or can guess the language
MSFILTER_DLLPUBLIC rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale); 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 ...@@ -51,6 +51,17 @@ rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Loc
return RTL_TEXTENCODING_MS_1252; 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 ...@@ -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) void SwWW8ImplReader::Read_TxtForeColor(sal_uInt16, const sal_uInt8* pData, short nLen)
{ {
if( nLen < 0 ) if( nLen < 0 )
pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR ); pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_COLOR );
else else
{ {
Color aColor(wwUtility::BGRToRGB(SVBT32ToUInt32(pData))); Color aColor(msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)));
NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR)); NewAttr(SvxColorItem(aColor, RES_CHRATR_COLOR));
if (pAktColl && pStyles) if (pAktColl && pStyles)
pStyles->bTxtColChanged = true; pStyles->bTxtColChanged = true;
...@@ -4663,9 +4652,9 @@ sal_uInt32 SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67) ...@@ -4663,9 +4652,9 @@ sal_uInt32 SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67)
{ {
(void) bVer67; // unused in non-debug (void) bVer67; // unused in non-debug
OSL_ENSURE(bVer67 == false, "Impossible"); OSL_ENSURE(bVer67 == false, "Impossible");
sal_uInt32 nFore = wwUtility::BGRToRGB(SVBT32ToUInt32(rpData)); sal_uInt32 nFore = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
rpData+=4; rpData+=4;
sal_uInt32 nBack = wwUtility::BGRToRGB(SVBT32ToUInt32(rpData)); sal_uInt32 nBack = msfilter::util::BGRToRGB(SVBT32ToUInt32(rpData));
rpData+=4; rpData+=4;
sal_uInt16 nIndex = SVBT16ToShort(rpData); sal_uInt16 nIndex = SVBT16ToShort(rpData);
rpData+=2; rpData+=2;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <sal/config.h> #include <sal/config.h>
#include <editeng/borderline.hxx> #include <editeng/borderline.hxx>
#include <filter/msfilter/util.hxx>
#if defined OSL_BIGENDIAN || SAL_TYPES_ALIGNMENT4 > 2 || defined UNX #if defined OSL_BIGENDIAN || SAL_TYPES_ALIGNMENT4 > 2 || defined UNX
# define __WW8_NEEDS_COPY # define __WW8_NEEDS_COPY
...@@ -978,8 +979,7 @@ struct SEPr ...@@ -978,8 +979,7 @@ struct SEPr
namespace wwUtility namespace wwUtility
{ {
sal_uInt32 BGRToRGB(sal_uInt32 nColour); inline sal_uInt32 RGBToBGR(sal_uInt32 nColour) { return msfilter::util::BGRToRGB(nColour); }
inline sal_uInt32 RGBToBGR(sal_uInt32 nColour) { return BGRToRGB(nColour); }
} }
#endif #endif
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <ooxml/resourceids.hxx> // NS_ooxml namespace #include <ooxml/resourceids.hxx> // NS_ooxml namespace
#include <filter/msfilter/escherex.hxx> #include <filter/msfilter/escherex.hxx>
#include <filter/msfilter/util.hxx>
#include <rtfsdrimport.hxx> #include <rtfsdrimport.hxx>
...@@ -44,18 +45,6 @@ using rtl::OUString; ...@@ -44,18 +45,6 @@ using rtl::OUString;
using rtl::OUStringBuffer; using rtl::OUStringBuffer;
using rtl::OUStringToOString; 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 writerfilter {
namespace rtftok { namespace rtftok {
...@@ -132,14 +121,14 @@ void RTFSdrImport::resolve(RTFShape& rShape) ...@@ -132,14 +121,14 @@ void RTFSdrImport::resolve(RTFShape& rShape)
} }
else if (i->first == "fillColor" && xPropertySet.is()) else if (i->first == "fillColor" && xPropertySet.is())
{ {
aAny <<= lcl_BGRToRGB(i->second.toInt32()); aAny <<= msfilter::util::BGRToRGB(i->second.toInt32());
xPropertySet->setPropertyValue("FillColor", aAny); xPropertySet->setPropertyValue("FillColor", aAny);
} }
else if ( i->first == "fillBackColor" ) else if ( i->first == "fillBackColor" )
; // Ignore: complementer of fillColor ; // Ignore: complementer of fillColor
else if (i->first == "lineColor" && xPropertySet.is()) else if (i->first == "lineColor" && xPropertySet.is())
{ {
aAny <<= lcl_BGRToRGB(i->second.toInt32()); aAny <<= msfilter::util::BGRToRGB(i->second.toInt32());
xPropertySet->setPropertyValue("LineColor", aAny); xPropertySet->setPropertyValue("LineColor", aAny);
} }
else if ( i->first == "lineBackColor" ) 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