diff options
Diffstat (limited to 'oox/source/ole/olehelper.cxx')
-rw-r--r-- | oox/source/ole/olehelper.cxx | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/oox/source/ole/olehelper.cxx b/oox/source/ole/olehelper.cxx index 0a0796e15a7e..8dfe02283cb0 100644 --- a/oox/source/ole/olehelper.cxx +++ b/oox/source/ole/olehelper.cxx @@ -26,19 +26,22 @@ ************************************************************************/ #include "oox/ole/olehelper.hxx" + #include <rtl/ustrbuf.hxx> -#include "tokens.hxx" #include "oox/helper/binaryinputstream.hxx" #include "oox/helper/graphichelper.hxx" - -using ::rtl::OUString; -using ::rtl::OUStringBuffer; +#include "oox/token/tokens.hxx" namespace oox { namespace ole { // ============================================================================ +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +// ============================================================================ + namespace { const sal_uInt32 OLE_COLORTYPE_MASK = 0xFF000000; @@ -51,10 +54,16 @@ const sal_uInt32 OLE_PALETTECOLOR_MASK = 0x0000FFFF; const sal_uInt32 OLE_BGRCOLOR_MASK = 0x00FFFFFF; const sal_uInt32 OLE_SYSTEMCOLOR_MASK = 0x0000FFFF; +/** Swaps the red and blue component of the passed color. */ +inline sal_uInt32 lclSwapRedBlue( sal_uInt32 nColor ) +{ + return static_cast< sal_uInt32 >( (nColor & 0xFF00FF00) | ((nColor & 0x0000FF) << 16) | ((nColor & 0xFF0000) >> 16) ); +} + /** Returns the UNO RGB color from the passed encoded OLE BGR color. */ inline sal_Int32 lclDecodeBgrColor( sal_uInt32 nOleColor ) { - return static_cast< sal_Int32 >( ((nOleColor & 0x0000FF) << 16) | (nOleColor & 0x00FF00) | ((nOleColor & 0xFF0000) >> 16) ); + return static_cast< sal_Int32 >( lclSwapRedBlue( nOleColor ) & 0xFFFFFF ); } // ---------------------------------------------------------------------------- @@ -161,6 +170,11 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, return API_RGB_BLACK; } +/*static*/ sal_uInt32 OleHelper::encodeOleColor( sal_Int32 nRgbColor ) +{ + return OLE_COLORTYPE_BGR | lclSwapRedBlue( static_cast< sal_uInt32 >( nRgbColor & 0xFFFFFF ) ); +} + /*static*/ OUString OleHelper::importGuid( BinaryInputStream& rInStrm ) { OUStringBuffer aBuffer; @@ -297,4 +311,3 @@ StdFontInfo::StdFontInfo( const ::rtl::OUString& rName, sal_uInt32 nHeight, } // namespace ole } // namespace oox - |