Kaydet (Commit) faa499cf authored tarafından Mike Kaganski's avatar Mike Kaganski

tdf#115278: an empty entry in color table is auto color

A unit test will come in a separate commit

Change-Id: I89dd9cae6e099509d21398e29ccf6412791accc2
Reviewed-on: https://gerrit.libreoffice.org/48781Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 85538dd3
......@@ -371,13 +371,13 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_RED:
m_aStates.top().aCurrentColor.nRed = nParam;
m_aStates.top().aCurrentColor.SetRed(nParam);
break;
case RTF_GREEN:
m_aStates.top().aCurrentColor.nGreen = nParam;
m_aStates.top().aCurrentColor.SetGreen(nParam);
break;
case RTF_BLUE:
m_aStates.top().aCurrentColor.nBlue = nParam;
m_aStates.top().aCurrentColor.SetBlue(nParam);
break;
case RTF_FCHARSET:
{
......
......@@ -1210,10 +1210,7 @@ RTFError RTFDocumentImpl::resolveChars(char ch)
if (m_aStates.top().eDestination == Destination::COLORTABLE)
{
// we hit a ';' at the end of each color entry
sal_uInt32 color = (m_aStates.top().aCurrentColor.nRed << 16)
| (m_aStates.top().aCurrentColor.nGreen << 8)
| m_aStates.top().aCurrentColor.nBlue;
m_aColorTable.push_back(color);
m_aColorTable.push_back(m_aStates.top().aCurrentColor.GetColor());
// set components back to zero
m_aStates.top().aCurrentColor = RTFColorTableEntry();
}
......@@ -3425,8 +3422,6 @@ RTFParserState::RTFParserState(RTFDocumentImpl* pDocumentImpl)
void RTFDocumentImpl::resetFrame() { m_aStates.top().aFrame = RTFFrame(&m_aStates.top()); }
RTFColorTableEntry::RTFColorTableEntry() = default;
RTFPicture::RTFPicture() = default;
RTFShape::RTFShape() = default;
......
......@@ -22,6 +22,7 @@
#include <oox/mathml/importutils.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/colordata.hxx>
#include <rtftok/RTFDocument.hxx>
#include "rtfreferencetable.hxx"
......@@ -127,10 +128,28 @@ struct TableRowBuffer
class RTFColorTableEntry
{
public:
RTFColorTableEntry();
sal_uInt8 nRed = 0;
sal_uInt8 nGreen = 0;
sal_uInt8 nBlue = 0;
void SetRed(sal_uInt8 nRed)
{
m_bAuto = false;
m_nR = nRed;
}
void SetGreen(sal_uInt8 nGreen)
{
m_bAuto = false;
m_nG = nGreen;
}
void SetBlue(sal_uInt8 nBlue)
{
m_bAuto = false;
m_nB = nBlue;
}
ColorData GetColor() const { return m_bAuto ? COL_AUTO : RGB_COLORDATA(m_nR, m_nG, m_nB); }
private:
bool m_bAuto = true;
sal_uInt8 m_nR = 0;
sal_uInt8 m_nG = 0;
sal_uInt8 m_nB = 0;
};
/// Stores the properties of a shape.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment