[Libreoffice-commits] core.git: sw/qa writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Aug 21 04:36:28 UTC 2018
sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 8 ++++++++
writerfilter/source/ooxml/OOXMLPropertySet.cxx | 15 +++++++++++++++
3 files changed, 23 insertions(+)
New commits:
commit 7d01ce4021bafde8184355f46d1cbe2c370767e1
Author: Justin Luth <justin.luth at collabora.com>
AuthorDate: Sat Aug 18 19:35:01 2018 +0300
Commit: Justin Luth <justin_luth at sil.org>
CommitDate: Tue Aug 21 06:36:05 2018 +0200
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 at sil.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx b/sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx
new file mode 100644
index 000000000000..d12b85b2da9c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf57589_hashColor.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 6974cb776550..263959520851 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -45,6 +45,14 @@ protected:
}
};
+DECLARE_OOXMLEXPORT_TEST(testTdf57589_hashColor, "tdf57589_hashColor.docx")
+{
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
+ CPPUNIT_ASSERT_EQUAL(COL_LIGHTMAGENTA, Color(getProperty<sal_uInt32>(getParagraph(1), "ParaBackColor")));
+ CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getParagraph(2), "FillStyle"));
+ CPPUNIT_ASSERT_EQUAL(COL_AUTO, Color(getProperty<sal_uInt32>(getParagraph(2), "ParaBackColor")));
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf92524_autoColor, "tdf92524_autoColor.doc")
{
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
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;
+ }
}
}
More information about the Libreoffice-commits
mailing list