[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    koffice/filters/kspread/excel
From:       Marijn Kruisselbrink <m.kruisselbrink () student ! tue ! nl>
Date:       2010-08-13 6:32:19
Message-ID: 20100813063219.055D0AC857 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1162941 by mkruisselbrink:

remove custom Color class and replace it with QColor

 M  +3 -3      import/excelimport.cc  
 M  +9 -9      sidewinder/format.cpp  
 M  +8 -68     sidewinder/format.h  
 M  +18 -18    sidewinder/globalssubstreamhandler.cpp  
 M  +2 -2      sidewinder/globalssubstreamhandler.h  


--- trunk/koffice/filters/kspread/excel/import/excelimport.cc #1162940:1162941
@@ -1629,10 +1629,10 @@
     return styleName;
 }
 
-QString convertColor(const Color& color)
+QString convertColor(const QColor& color)
 {
     char buf[8];
-    sprintf(buf, "#%02x%02x%02x", color.red, color.green, color.blue);
+    sprintf(buf, "#%02x%02x%02x", color.red(), color.green(), color.blue());
     return QString(buf);
 }
 
@@ -1771,7 +1771,7 @@
     if (!back.isNull() && back.pattern() != FormatBackground::EmptyPattern) {
         KoGenStyle fillStyle = KoGenStyle(KoGenStyle::GraphicAutoStyle, "graphic");
 
-        Color backColor = back.backgroundColor();
+        QColor backColor = back.backgroundColor();
         if (back.pattern() == FormatBackground::SolidPattern)
             backColor = back.foregroundColor();
         const QString bgColor = convertColor(backColor);
--- trunk/koffice/filters/kspread/excel/sidewinder/format.cpp #1162940:1162941
@@ -34,7 +34,7 @@
     bool superscript : 1;
     QString fontFamily;
     double fontSize;
-    Color color;
+    QColor color;
 };
 
 FormatFont::FormatFont()
@@ -111,12 +111,12 @@
     d->null = false;
 }
 
-Color FormatFont::color() const
+QColor FormatFont::color() const
 {
     return d->color;
 }
 
-void FormatFont::setColor(const Color& c)
+void FormatFont::setColor(const QColor& c)
 {
     d->color = c;
     d->null = false;
@@ -389,8 +389,8 @@
 public:
     bool null;
     unsigned pattern;
-    Color background;
-    Color foreground;
+    QColor background;
+    QColor foreground;
 };
 
 // constructor
@@ -446,23 +446,23 @@
     d->null = false;
 }
 
-Color FormatBackground::backgroundColor() const
+QColor FormatBackground::backgroundColor() const
 {
     return d->background;
 }
 
-void FormatBackground::setBackgroundColor(const Color& color)
+void FormatBackground::setBackgroundColor(const QColor& color)
 {
     d->background = color;
     d->null = false;
 }
 
-Color FormatBackground::foregroundColor() const
+QColor FormatBackground::foregroundColor() const
 {
     return d->foreground;
 }
 
-void FormatBackground::setForegroundColor(const Color& color)
+void FormatBackground::setForegroundColor(const QColor& color)
 {
     d->foreground = color;
     d->null = false;
--- trunk/koffice/filters/kspread/excel/sidewinder/format.h #1162940:1162941
@@ -23,77 +23,17 @@
 
 #include <cstdio> // for sscanf
 #include <QString>
+#include <QColor>
 
 namespace Swinder
 {
 
-/**
- * @short Provides color based on RGB values.
- *
- * Class Color provides color based on  terms of RGB (red, green and blue)
- * components.
- *
- */
-class Color
-{
-public:
-
-    unsigned red, green, blue;
-
-    /**
-     * Constructs a default color with the RGB value (0, 0, 0), i.e black.
-     */
-    Color() {
-        red = green = blue = 0;
-    }
-
-    /**
-     * Creates a copy of another color.
-     */
-    Color(const Color& c) {
-        red = c.red; green = c.green; blue = c.blue;
-    }
-
-    /**
-     * Creates a color based on given red, green and blue values.
-     */
-    Color(unsigned r, unsigned g, unsigned b) {
-        red = r; green = g; blue = b;
-    }
-
-    /**
-     * Creates a color based on given red, green and blue values, encoded as \#RRGGBB in a string.
-     */
-    explicit Color(const char* c) {
-        std::sscanf(c, "#%2x%2x%2x", &red, &green, &blue);
-    }
-
-    friend inline bool operator==(const Color&, const Color&);
-    friend inline bool operator!=(const Color&, const Color&);
-};
-
-/**
-    Returns true if c1 is equal to c2; otherwise returns false.
-*/
-inline bool operator==(const Color& c1, const Color& c2)
-{
-    return c1.red == c2.red && c1.green == c2.green && c1.blue == c2.blue;
-}
-
-/**
-    Returns true if c1 is not equal to c2; otherwise returns false.
-*/
-inline bool operator!=(const Color& c1, const Color& c2)
-{
-    return c1.red != c2.red || c1.green != c2.green || c1.blue != c2.blue;
-}
-
 class Pen
 {
 public:
     unsigned style;
     float width;
-    Color color;
+    QColor color;
 
     enum {
         NoLine,         // no line at all
@@ -193,12 +133,12 @@
     /**
      * Returns the color of the font.
      */
-    Color color() const;
+    QColor color() const;
 
     /**
      * Sets the color of the font.
      */
-    void setColor(const Color& color);
+    void setColor(const QColor& color);
 
     /**
      * Returns true if bold has been set.
@@ -506,28 +446,28 @@
      *
      * \sa setBackgroundColor
      */
-    Color backgroundColor() const;
+    QColor backgroundColor() const;
 
     /**
      * Set the background color.
      *
      * \sa backgroundColor
      */
-    void setBackgroundColor(const Color&);
+    void setBackgroundColor(const QColor&);
 
     /**
      * Returns the foreground color of the background area.
      *
      * \sa setForegroundColor
      */
-    Color foregroundColor() const;
+    QColor foregroundColor() const;
 
     /**
      * Sets the foreground color.
      *
      * \sa foregroundColor
      */
-    void setForegroundColor(const Color&);
+    void setForegroundColor(const QColor&);
 
     /**
      * Returns true if this background is equal to f; otherwise returns false.
--- trunk/koffice/filters/kspread/excel/sidewinder/globalssubstreamhandler.cpp #1162940:1162941
@@ -73,7 +73,7 @@
     std::vector<std::map<unsigned, FormatFont> > formatRunsTable;
 
     // color table (from Palette record)
-    std::vector<Color> colorTable;
+    std::vector<QColor> colorTable;
 
     // table of Xformat
     std::vector<XFRecord> xfTable;
@@ -105,7 +105,7 @@
         "#339966", "#003300", "#333300", "#993300", "#993366", "#333399", "#333333",
     };
     for (int i = 0; i < 64 - 8; i++) {
-        d->colorTable.push_back(Color(default_palette[i]));
+        d->colorTable.push_back(QColor(default_palette[i]));
     }
 }
 
@@ -198,12 +198,12 @@
         return FontRecord(d->workbook);
 }
 
-Color GlobalsSubStreamHandler::customColor(unsigned index) const
+QColor GlobalsSubStreamHandler::customColor(unsigned index) const
 {
     if (index < d->colorTable.size())
         return d->colorTable[index];
     else
-        return Color();
+        return QColor();
 }
 
 unsigned GlobalsSubStreamHandler::xformatCount() const
@@ -272,7 +272,7 @@
     return font;
 }
 
-Color GlobalsSubStreamHandler::convertedColor(unsigned index) const
+QColor GlobalsSubStreamHandler::convertedColor(unsigned index) const
 {
     if ((index >= 8) && (index < 0x40))
         return customColor(index - 8);
@@ -281,24 +281,24 @@
     // 0x0040  system window text color for border lines
     // 0x0041  system window background color for pattern background
     // 0x7fff  system window text color for fonts
-    if (index == 0x40) return Color(0, 0, 0);
-    if (index == 0x41) return Color(255, 255, 255);
-    if (index == 0x7fff) return Color(0, 0, 0);
+    if (index == 0x40) return QColor(0, 0, 0);
+    if (index == 0x41) return QColor(255, 255, 255);
+    if (index == 0x7fff) return QColor(0, 0, 0);
 
     // fallback: just "black"
-    Color color;
+    QColor color;
 
     // standard colors: black, white, red, green, blue,
     // yellow, magenta, cyan
     switch (index) {
-    case 0:   color = Color(0, 0, 0); break;
-    case 1:   color = Color(255, 255, 255); break;
-    case 2:   color = Color(255, 0, 0); break;
-    case 3:   color = Color(0, 255, 0); break;
-    case 4:   color = Color(0, 0, 255); break;
-    case 5:   color = Color(255, 255, 0); break;
-    case 6:   color = Color(255, 0, 255); break;
-    case 7:   color = Color(0, 255, 255); break;
+    case 0:   color = QColor(0, 0, 0); break;
+    case 1:   color = QColor(255, 255, 255); break;
+    case 2:   color = QColor(255, 0, 0); break;
+    case 3:   color = QColor(0, 255, 0); break;
+    case 4:   color = QColor(0, 0, 255); break;
+    case 5:   color = QColor(255, 255, 0); break;
+    case 6:   color = QColor(255, 0, 255); break;
+    case 7:   color = QColor(0, 255, 255); break;
     default:  break;
     }
 
@@ -777,7 +777,7 @@
 
     d->colorTable.clear();
     for (unsigned i = 0; i < record->count(); i++)
-        d->colorTable.push_back(Color(record->red(i), record->green(i), record->blue(i)));
+        d->colorTable.push_back(QColor(record->red(i), record->green(i), record->blue(i)));
 }
 
 void GlobalsSubStreamHandler::handleSST(SSTRecord* record)
--- trunk/koffice/filters/kspread/excel/sidewinder/globalssubstreamhandler.h #1162940:1162941
@@ -79,8 +79,8 @@
 
     FormatFont convertedFont(unsigned index) const;
 
-    Color customColor(unsigned index) const;  //
-    Color convertedColor(unsigned index) const;
+    QColor customColor(unsigned index) const;  //
+    QColor convertedColor(unsigned index) const;
 
     unsigned xformatCount() const;//
     XFRecord xformat(unsigned index) const;  //
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic