writerfilter/source/rtftok/rtfdispatchvalue.cxx |    6 ++---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx  |    7 ------
 writerfilter/source/rtftok/rtfdocumentimpl.hxx  |   27 ++++++++++++++++++++----
 3 files changed, 27 insertions(+), 13 deletions(-)

New commits:
commit faa499cf6c9ccc0503fdc889727e1affcca8e930
Author: Mike Kaganski <mike.kagan...@collabora.com>
Date:   Sun Jan 28 13:17:50 2018 +0100

    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/48781
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx 
b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index 726cb90acb37..1529e3805448 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -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:
         {
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 0474991024e4..0bc42bb73eee 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -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;
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 386f1950080f..9d162490a8d1 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -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.
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to