diff options
author | Justin Luth <justin.luth@collabora.com> | 2018-08-18 19:35:01 +0300 |
---|---|---|
committer | Justin Luth <justin_luth@sil.org> | 2018-08-21 06:36:05 +0200 |
commit | 7d01ce4021bafde8184355f46d1cbe2c370767e1 (patch) | |
tree | dab9f15441c7185230dabe9e0893be74f08f7414 /writerfilter | |
parent | 5732db01795df90df95944cffc8566ea11e6c389 (diff) |
tdf#57589 writerfilter: support hash-encoded colors
Previously, a hash-encoded value would simply fail to zero
and thus the color would be dark black.
The unit test covers two conditions. Paragraph 1 has a valid
encoding, and pararaph 2 has an invalid coding (which is
ignored and fails to COL_AUTO).
Change-Id: I68940f5c4b0975a87feb6cab8fb3572b7546a077
Reviewed-on: https://gerrit.libreoffice.org/59295
Tested-by: Jenkins
Reviewed-by: Justin Luth <justin_luth@sil.org>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/ooxml/OOXMLPropertySet.cxx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.cxx b/writerfilter/source/ooxml/OOXMLPropertySet.cxx index f35379e529a6..79b53849c054 100644 --- a/writerfilter/source/ooxml/OOXMLPropertySet.cxx +++ b/writerfilter/source/ooxml/OOXMLPropertySet.cxx @@ -23,6 +23,7 @@ #include <ooxml/QNameToString.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <oox/token/tokens.hxx> +#include <sax/tools/converter.hxx> #include <tools/color.hxx> namespace writerfilter { @@ -592,6 +593,20 @@ OOXMLHexColorValue::OOXMLHexColorValue(const char * pValue) if (strcmp(pValue, "auto")) { mnValue = rtl_str_toUInt32(pValue, 16); + + // Convert hash-encoded values (like #FF0080) + const sal_Int32 nLen = strlen(pValue); + if ( !mnValue && nLen > 1 && pValue[0] == '#' ) + { + sal_Int32 nColor(COL_AUTO); + // Word appears to require strict 6 digit length, else it ignores it + if ( nLen == 7 ) + { + const OUString sHashColor(pValue, nLen, RTL_TEXTENCODING_ASCII_US); + sax::Converter::convertColor( nColor, sHashColor ); + } + mnValue = nColor; + } } } |