summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Deller <luke@deller.id.au>2018-03-08 01:11:40 +1100
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-03-20 10:05:57 +0100
commit3967aebca94be9ceea3e36b43f7f53589473ad4e (patch)
treee03e38f49ee109bd7102dd055133800798a93c61
parent029ba7ac94d517143af5166df4e2dcb58b350443 (diff)
tdf#116179 Support reading "auto" colour from docx
In docx a colour value is represented as a 6-digit hex RGB value, or alternatively the word "auto" to represent automatic colour. - Add support for reading the value "auto" as COL_AUTO. Previously this would be read as if it were a hex value, stopping at the letter 'u' which is not a valid hex digit, resulting in the colour 0x00000A - a very dark blue, which looks close enough to black that it went unnoticed for a long time :-) - Remove code which tried to handle this wrong 0x00000A value, including the constant OOXML_COLOR_AUTO, as it is no longer needed and will cause surprises for anyone who really wanted this exact shade of dark blue - Fix unit tests that were checking for 0x00000A Change-Id: I6000070341931147ff9341ad6281cd3b53c02b46 Reviewed-on: https://gerrit.libreoffice.org/50995 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> Reviewed-on: https://gerrit.libreoffice.org/51461 Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--filter/source/msfilter/util.cxx7
-rw-r--r--include/filter/msfilter/util.hxx5
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx14
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport5.cxx16
-rw-r--r--sw/source/core/text/xmldump.cxx3
-rw-r--r--writerfilter/source/dmapper/BorderHandler.cxx2
-rw-r--r--writerfilter/source/dmapper/CellColorHandler.cxx10
-rw-r--r--writerfilter/source/dmapper/DomainMapper.cxx2
-rw-r--r--writerfilter/source/dmapper/TDefTableHandler.cxx2
-rw-r--r--writerfilter/source/ooxml/OOXMLFactory.cxx9
-rw-r--r--writerfilter/source/ooxml/OOXMLFactory.hxx1
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySet.cxx16
-rw-r--r--writerfilter/source/ooxml/OOXMLPropertySet.hxx8
-rw-r--r--writerfilter/source/ooxml/factoryimpl.py5
-rw-r--r--writerfilter/source/ooxml/model.xml2
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx6
17 files changed, 65 insertions, 45 deletions
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index 9cf01a0929a3..c563b0a54095 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -126,14 +126,11 @@ sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cChar,
}
-OString ConvertColor( const Color &rColor, bool bAutoColor )
+OString ConvertColor( const Color &rColor )
{
OString color( "auto" );
- if (bAutoColor && rColor.GetColor() == OOXML_COLOR_AUTO)
- return color;
-
- if ( rColor.GetColor() != COL_AUTO )
+ if ( rColor != COL_AUTO )
{
const char pHexDigits[] = "0123456789ABCDEF";
char pBuffer[] = "000000";
diff --git a/include/filter/msfilter/util.hxx b/include/filter/msfilter/util.hxx
index 8895a4181bec..623f1cfe84db 100644
--- a/include/filter/msfilter/util.hxx
+++ b/include/filter/msfilter/util.hxx
@@ -59,15 +59,12 @@ MSFILTER_DLLPUBLIC sal_Unicode bestFitOpenSymbolToMSFont(sal_Unicode cBullet,
rtl_TextEncoding& r_ioChrSet, OUString& r_ioFontName);
-#define OOXML_COLOR_AUTO 0x0a
-
/**
* Converts tools Color to HTML color (without leading hashmark).
*
* @param rColor color to convert
- * @param bAutoColor if OOXML_COLOR_AUTO should be recognized as an auto color
*/
-MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor, bool bAutoColor = false );
+MSFILTER_DLLPUBLIC OString ConvertColor( const Color &rColor );
/** Paper size in 1/100 millimeters. */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 536eea8c6d07..ce981644f5e1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -699,7 +699,7 @@ DECLARE_OOXMLEXPORT_TEST(testNumOverrideLvltext, "num-override-lvltext.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int16(2), comphelper::SequenceAsHashMap(xRules->getByIndex(1))["ParentNumbering"].get<sal_Int16>());
// The paragraph marker's red font color was inherited by the number portion, this was ff0000.
- CPPUNIT_ASSERT_EQUAL(OUString("00000a"), parseDump("//Special[@nType='POR_NUMBER']/SwFont", "color"));
+ CPPUNIT_ASSERT_EQUAL(OUString("ffffffff"), parseDump("//Special[@nType='POR_NUMBER']/SwFont", "color"));
}
DECLARE_OOXMLEXPORT_TEST(testNumOverrideStart, "num-override-start.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 52128c0a740d..079e3513a4a1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -192,21 +192,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107035, "tdf107035.docx")
// Check that the page number field colour is set to "automatic".
sal_Int32 nPgNumColour = getProperty<sal_Int32>(xPgNumRun, "CharColor");
-#if 0
- // TODO Enable this once tdf#116179 is fixed
CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_AUTO), nPgNumColour);
-
-#else
- // Meanwhile just check that the page number field colour is different
- // from the green text before it:
-
- // Select the first run containing the green text
- auto xTextRun = getRun(getParagraph(1), 1);
-
- // Check that the page number field colour is different from the green text
- CPPUNIT_ASSERT(getProperty<sal_Int32>(xTextRun, "CharColor") != nPgNumColour);
-#endif
-
}
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index fc98eb98243d..1fa183ca174a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -650,43 +650,43 @@ DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx")
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:color = 'auto']", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:color = 'auto']", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:color = 'auto']", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:color = 'auto']", 1);
//Table Cell Borders
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:color = 'auto']", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:color = 'auto']", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:color = 'auto']", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:val = 'single']",1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:sz = 4]", 1);
assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:space = 0]", 1);
- assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:color = '00000A']", 1);
+ assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:color = 'auto']", 1);
}
DECLARE_OOXMLEXPORT_TEST(testFdo77129, "fdo77129.docx")
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index 02b47ff1ebc7..a8116eab6f86 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -452,7 +452,8 @@ void SwFont::dumpAsXml(xmlTextWriterPtr writer) const
{
xmlTextWriterStartElement(writer, BAD_CAST("SwFont"));
xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("ptr"), "%p", this);
- xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("color"), "%s", GetColor().AsRGBHexString().toUtf8().getStr());
+ // do not use Color::AsRGBHexString() as that omits the transparency
+ xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("color"), "%08x", GetColor().GetColor());
xmlTextWriterEndElement(writer);
}
diff --git a/writerfilter/source/dmapper/BorderHandler.cxx b/writerfilter/source/dmapper/BorderHandler.cxx
index e2528c28d50e..0a07c9753393 100644
--- a/writerfilter/source/dmapper/BorderHandler.cxx
+++ b/writerfilter/source/dmapper/BorderHandler.cxx
@@ -67,7 +67,7 @@ void BorderHandler::lcl_attribute(Id rName, Value & rVal)
break;
case NS_ooxml::LN_CT_Border_color:
m_nLineColor = nIntValue;
- appendGrabBag("color", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true)));
+ appendGrabBag("color", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue)));
break;
case NS_ooxml::LN_CT_Border_space: // border distance in points
m_nLineDistance = ConversionHelper::convertTwipToMM100( nIntValue * 20 );
diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx
index cb8fccac1f71..968c1b1f553f 100644
--- a/writerfilter/source/dmapper/CellColorHandler.cxx
+++ b/writerfilter/source/dmapper/CellColorHandler.cxx
@@ -109,8 +109,8 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal)
}
break;
case NS_ooxml::LN_CT_Shd_fill:
- createGrabBag("fill", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true))));
- if( nIntValue == OOXML_COLOR_AUTO )
+ createGrabBag("fill", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue))));
+ if( nIntValue == sal_Int32(COL_AUTO) )
nIntValue = 0xffffff; //fill color auto means white
else
m_bAutoFillColor = false;
@@ -118,8 +118,8 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal)
m_nFillColor = nIntValue;
break;
case NS_ooxml::LN_CT_Shd_color:
- createGrabBag("color", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true))));
- if( nIntValue == OOXML_COLOR_AUTO )
+ createGrabBag("color", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue))));
+ if( nIntValue == sal_Int32(COL_AUTO) )
nIntValue = 0; //shading color auto means black
//color of the shading
m_nColor = nIntValue;
@@ -283,7 +283,7 @@ TablePropertyMapPtr CellColorHandler::getProperties()
pPropertyMap->Insert( m_OutputFormat == Form ? PROP_BACK_COLOR
: PROP_CHAR_BACK_COLOR, uno::makeAny( nApplyColor ));
- createGrabBag("originalColor", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nApplyColor, true))));
+ createGrabBag("originalColor", uno::makeAny(OUString::fromUtf8(msfilter::util::ConvertColor(nApplyColor))));
return pPropertyMap;
}
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 5569f91a23de..40134d148ac9 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -302,7 +302,7 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
case NS_ooxml::LN_CT_Color_val:
if (m_pImpl->GetTopContext())
m_pImpl->GetTopContext()->Insert(PROP_CHAR_COLOR, uno::makeAny( nIntValue ) );
- m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true)));
+ m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, "val", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue)));
break;
case NS_ooxml::LN_CT_Underline_color:
if (m_pImpl->GetTopContext())
diff --git a/writerfilter/source/dmapper/TDefTableHandler.cxx b/writerfilter/source/dmapper/TDefTableHandler.cxx
index bd594fc510cb..b86f37ed8bf3 100644
--- a/writerfilter/source/dmapper/TDefTableHandler.cxx
+++ b/writerfilter/source/dmapper/TDefTableHandler.cxx
@@ -287,7 +287,7 @@ void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
appendGrabBag("val", TDefTableHandler::getBorderTypeString(nIntValue));
break;
case NS_ooxml::LN_CT_Border_color:
- appendGrabBag("color", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue, /*bAutoColor=*/true)));
+ appendGrabBag("color", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue)));
m_nLineColor = nIntValue;
break;
case NS_ooxml::LN_CT_Border_space:
diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx b/writerfilter/source/ooxml/OOXMLFactory.cxx
index c164ff949757..91eb7b0e4c96 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.cxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.cxx
@@ -96,6 +96,15 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * pHandler,
pFactory->attributeAction(pHandler, nToken, xValue);
}
break;
+ case ResourceType::HexColor:
+ {
+ const char *pValue = "";
+ pAttribs->getAsChar(nToken, pValue);
+ OOXMLValue::Pointer_t xValue(new OOXMLHexColorValue(pValue));
+ pHandler->newProperty(nId, xValue);
+ pFactory->attributeAction(pHandler, nToken, xValue);
+ }
+ break;
case ResourceType::TwipsMeasure:
{
const char *pValue = "";
diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx b/writerfilter/source/ooxml/OOXMLFactory.hxx
index dce03696185c..fcf89155ae7c 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.hxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.hxx
@@ -40,6 +40,7 @@ enum class ResourceType {
Integer,
Properties,
Hex,
+ HexColor,
String,
Shape,
Boolean,
diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.cxx b/writerfilter/source/ooxml/OOXMLPropertySet.cxx
index 286da4fb040e..916c1b9a4902 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 <tools/color.hxx>
namespace writerfilter {
namespace ooxml
@@ -577,6 +578,21 @@ string OOXMLHexValue::toString() const
}
#endif
+/*
+ class OOXMLHexColorValue
+*/
+OOXMLHexColorValue::OOXMLHexColorValue(const char * pValue)
+{
+ if (!strcmp(pValue, "auto"))
+ {
+ mnValue = sal_uInt32(COL_AUTO);
+ }
+ else
+ {
+ mnValue = rtl_str_toUInt32(pValue, 16);
+ }
+}
+
// OOXMLUniversalMeasureValue
// ECMA-376 5th ed. Part 1 , 22.9.2.15
OOXMLUniversalMeasureValue::OOXMLUniversalMeasureValue(const char * pValue, sal_uInt32 npPt)
diff --git a/writerfilter/source/ooxml/OOXMLPropertySet.hxx b/writerfilter/source/ooxml/OOXMLPropertySet.hxx
index c6b664f59b90..f6aaa3ac4686 100644
--- a/writerfilter/source/ooxml/OOXMLPropertySet.hxx
+++ b/writerfilter/source/ooxml/OOXMLPropertySet.hxx
@@ -211,7 +211,9 @@ public:
class OOXMLHexValue : public OOXMLValue
{
+protected:
sal_uInt32 mnValue;
+ OOXMLHexValue() {}
public:
explicit OOXMLHexValue(sal_uInt32 nValue);
explicit OOXMLHexValue(const char * pValue);
@@ -224,6 +226,12 @@ public:
virtual OOXMLValue * clone() const override;
};
+class OOXMLHexColorValue : public OOXMLHexValue
+{
+public:
+ explicit OOXMLHexColorValue(const char * pValue);
+};
+
class OOXMLUniversalMeasureValue : public OOXMLValue
{
private:
diff --git a/writerfilter/source/ooxml/factoryimpl.py b/writerfilter/source/ooxml/factoryimpl.py
index 3605892fe71f..acbaf4234261 100644
--- a/writerfilter/source/ooxml/factoryimpl.py
+++ b/writerfilter/source/ooxml/factoryimpl.py
@@ -37,7 +37,10 @@ def createFastChildContextFromFactory(model):
switch (nResource)
{""")
- resources = ["List", "Integer", "Hex", "String", "TwipsMeasure", "HpsMeasure", "Boolean", "MeasurementOrPercent"]
+ resources = [
+ "List", "Integer", "Hex", "HexColor", "String", "TwipsMeasure",
+ "HpsMeasure", "Boolean", "MeasurementOrPercent",
+ ]
for resource in [r.getAttribute("resource") for r in model.getElementsByTagName("resource")]:
if resource not in resources:
resources.append(resource)
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index a9ffbdfa6c65..25f8a267bb8a 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -16710,7 +16710,7 @@
<value tokenid="ooxml:Value_ST_HexColorAuto_auto">auto</value>
</resource>
<resource name="ST_HexColorRGB" resource="Hex"/>
- <resource name="ST_HexColor" resource="Hex"/>
+ <resource name="ST_HexColor" resource="HexColor"/>
<resource name="CT_Color" resource="Properties">
<attribute name="val" tokenid="ooxml:CT_Color_val"/>
<attribute name="themeColor" tokenid="ooxml:CT_Color_themeColor"/>
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 9c4c714baeb3..0a5d3993ff43 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -97,8 +97,10 @@ void putNestedAttribute(RTFSprms& rSprms, Id nParent, Id nId, const RTFValue::Po
if (nParent == NS_ooxml::LN_CT_TcPrBase_shd)
{
// RTF default is 'auto', see writerfilter::dmapper::CellColorHandler
- aAttributes.set(NS_ooxml::LN_CT_Shd_color, std::make_shared<RTFValue>(0x0a));
- aAttributes.set(NS_ooxml::LN_CT_Shd_fill, std::make_shared<RTFValue>(0x0a));
+ aAttributes.set(NS_ooxml::LN_CT_Shd_color,
+ std::make_shared<RTFValue>(sal_uInt32(COL_AUTO)));
+ aAttributes.set(NS_ooxml::LN_CT_Shd_fill,
+ std::make_shared<RTFValue>(sal_uInt32(COL_AUTO)));
}
auto pParentValue = std::make_shared<RTFValue>(aAttributes);
rSprms.set(nParent, pParentValue, eOverwrite);