diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-04-10 18:17:00 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-04-10 18:48:25 +0200 |
commit | 55131d409d903496b9d6ec5dee39e33983bf1043 (patch) | |
tree | a315de69dc224f14b3221935ae2ddb908d78eac9 /filter | |
parent | 24ee3df385cf2aa95cd888581c84fdf90cc682dc (diff) |
add msfilter::util::ConvertColor to avoid copy&paste
Change-Id: Ia5507f8d1ec18a45d3128c809d03f8f41849f93c
Diffstat (limited to 'filter')
-rw-r--r-- | filter/inc/filter/msfilter/util.hxx | 4 | ||||
-rw-r--r-- | filter/source/msfilter/rtfutil.cxx | 1 | ||||
-rw-r--r-- | filter/source/msfilter/util.cxx | 19 |
3 files changed, 23 insertions, 1 deletions
diff --git a/filter/inc/filter/msfilter/util.hxx b/filter/inc/filter/msfilter/util.hxx index 110429551bba..c3b56883e5ba 100644 --- a/filter/inc/filter/msfilter/util.hxx +++ b/filter/inc/filter/msfilter/util.hxx @@ -31,6 +31,7 @@ #include <rtl/textenc.h> #include <tools/datetime.hxx> +#include <tools/color.hxx> #include <com/sun/star/lang/Locale.hpp> #include "filter/msfilter/msfilterdllapi.h" @@ -88,6 +89,9 @@ enum TextCategory */ MSFILTER_DLLPUBLIC TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47LanguageTag); +/// Converts tools Color to HTML color (without leading hashmark). +MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor ); + } } diff --git a/filter/source/msfilter/rtfutil.cxx b/filter/source/msfilter/rtfutil.cxx index 3e2dfb0fbf85..050a2f206ccf 100644 --- a/filter/source/msfilter/rtfutil.cxx +++ b/filter/source/msfilter/rtfutil.cxx @@ -181,7 +181,6 @@ OString OutStringUpr(const sal_Char *pToken, const String &rStr, rtl_TextEncodin aRet.append("}}}"); return aRet.makeStringAndClear(); } - } } diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx index ca111203543e..3fec6daafd95 100644 --- a/filter/source/msfilter/util.cxx +++ b/filter/source/msfilter/util.cxx @@ -306,6 +306,25 @@ TextCategory categorizeCodePoint(sal_uInt32 codePoint, const OUString &rBcp47Lan return eRet; } +OString ConvertColor( const Color &rColor ) +{ + OString color( "auto" ); + if ( rColor.GetColor() != COL_AUTO ) + { + const char pHexDigits[] = "0123456789ABCDEF"; + char pBuffer[] = "000000"; + + pBuffer[0] = pHexDigits[ ( rColor.GetRed() >> 4 ) & 0x0F ]; + pBuffer[1] = pHexDigits[ rColor.GetRed() & 0x0F ]; + pBuffer[2] = pHexDigits[ ( rColor.GetGreen() >> 4 ) & 0x0F ]; + pBuffer[3] = pHexDigits[ rColor.GetGreen() & 0x0F ]; + pBuffer[4] = pHexDigits[ ( rColor.GetBlue() >> 4 ) & 0x0F ]; + pBuffer[5] = pHexDigits[ rColor.GetBlue() & 0x0F ]; + + color = OString( pBuffer ); + } + return color; +} } } |