[goffice] GOFormat: implement numbered colours in formats.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] GOFormat: implement numbered colours in formats.
- Date: Sat, 29 Mar 2014 00:26:25 +0000 (UTC)
commit ec9aac9e017825c562c1f2b9294cd5284efae6cc
Author: Morten Welinder <terra gnome org>
Date: Fri Mar 28 20:24:59 2014 -0400
GOFormat: implement numbered colours in formats.
There are 56 numbered colours in number formats: [Color1] through [Color56].
With this change, we will actually use the right colour, not black.
ChangeLog | 5 +++
NEWS | 1 +
goffice/utils/go-format.c | 66 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 70 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 20af1ff..3f8f8df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-28 Morten Welinder <terra gnome org>
+
+ * goffice/utils/go-format.c (go_format_parse_color): Implement
+ numbered colours instead of just parsing them.
+
2014-03-27 Morten Welinder <terra gnome org>
* goffice/utils/go-format.c (go_format_output_general_to_odf):
diff --git a/NEWS b/NEWS
index a2ca8d9..dc07b5e 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Andreas:
Morten:
* Work on conditional formats for ODF.
+ * Implement numbered colours in number formats.
--------------------------------------------------------------------------
goffice 0.10.13:
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index b6a4ab8..e97535d 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -725,6 +725,68 @@ static struct {
{ N_("Yellow"), GO_COLOR_YELLOW }
};
+static const GOColor
+format_numbered_colors[56 + 1] = {
+ GO_COLOR_BLACK, /* Invalid */
+ GO_COLOR_BLACK,
+ GO_COLOR_WHITE,
+ GO_COLOR_RED,
+ GO_COLOR_GREEN,
+ GO_COLOR_BLUE,
+ GO_COLOR_YELLOW,
+ GO_COLOR_VIOLET,
+ GO_COLOR_CYAN,
+ GO_COLOR_FROM_RGB (0x80, 0x00, 0x00),
+ GO_COLOR_FROM_RGB (0x00, 0x80, 0x00),
+ GO_COLOR_FROM_RGB (0x00, 0x00, 0x80),
+ GO_COLOR_FROM_RGB (0x80, 0x80, 0x00),
+ GO_COLOR_FROM_RGB (0x80, 0x00, 0x80),
+ GO_COLOR_FROM_RGB (0x00, 0x80, 0x80),
+ GO_COLOR_FROM_RGB (0xC0, 0xC0, 0xC0),
+ GO_COLOR_FROM_RGB (0x80, 0x80, 0x80),
+ GO_COLOR_FROM_RGB (0x99, 0x99, 0xFF),
+ GO_COLOR_FROM_RGB (0x99, 0x33, 0x66),
+ GO_COLOR_FROM_RGB (0xFF, 0xFF, 0xCC),
+ GO_COLOR_FROM_RGB (0xCC, 0xFF, 0xFF),
+ GO_COLOR_FROM_RGB (0x66, 0x00, 0x66),
+ GO_COLOR_FROM_RGB (0xFF, 0x80, 0x80),
+ GO_COLOR_FROM_RGB (0x00, 0x66, 0xCC),
+ GO_COLOR_FROM_RGB (0xCC, 0xCC, 0xFF),
+ GO_COLOR_FROM_RGB (0x00, 0x00, 0x80),
+ GO_COLOR_FROM_RGB (0xFF, 0x00, 0xFF),
+ GO_COLOR_FROM_RGB (0xFF, 0xFF, 0x00),
+ GO_COLOR_FROM_RGB (0x00, 0xFF, 0xFF),
+ GO_COLOR_FROM_RGB (0x80, 0x00, 0x80),
+ GO_COLOR_FROM_RGB (0x80, 0x00, 0x00),
+ GO_COLOR_FROM_RGB (0x00, 0x80, 0x80),
+ GO_COLOR_FROM_RGB (0x00, 0x00, 0xFF),
+ GO_COLOR_FROM_RGB (0x00, 0xCC, 0xFF),
+ GO_COLOR_FROM_RGB (0xCC, 0xFF, 0xFF),
+ GO_COLOR_FROM_RGB (0xCC, 0xFF, 0xCC),
+ GO_COLOR_FROM_RGB (0xFF, 0xFF, 0x99),
+ GO_COLOR_FROM_RGB (0x99, 0xCC, 0xFF),
+ GO_COLOR_FROM_RGB (0xFF, 0x99, 0xCC),
+ GO_COLOR_FROM_RGB (0xCC, 0x99, 0xFF),
+ GO_COLOR_FROM_RGB (0xFF, 0xCC, 0x99),
+ GO_COLOR_FROM_RGB (0x33, 0x66, 0xFF),
+ GO_COLOR_FROM_RGB (0x33, 0xCC, 0xCC),
+ GO_COLOR_FROM_RGB (0x99, 0xCC, 0x00),
+ GO_COLOR_FROM_RGB (0xFF, 0xCC, 0x00),
+ GO_COLOR_FROM_RGB (0xFF, 0x99, 0x00),
+ GO_COLOR_FROM_RGB (0xFF, 0x66, 0x00),
+ GO_COLOR_FROM_RGB (0x66, 0x66, 0x99),
+ GO_COLOR_FROM_RGB (0x96, 0x96, 0x96),
+ GO_COLOR_FROM_RGB (0x00, 0x33, 0x66),
+ GO_COLOR_FROM_RGB (0x33, 0x99, 0x66),
+ GO_COLOR_FROM_RGB (0x00, 0x33, 0x00),
+ GO_COLOR_FROM_RGB (0x33, 0x33, 0x00),
+ GO_COLOR_FROM_RGB (0x99, 0x33, 0x00),
+ GO_COLOR_FROM_RGB (0x99, 0x33, 0x66),
+ GO_COLOR_FROM_RGB (0x33, 0x33, 0x99),
+ GO_COLOR_FROM_RGB (0x33, 0x33, 0x33)
+};
+
+
/*
* go_format_parse_color :
* @str:
@@ -774,14 +836,14 @@ go_format_parse_color (char const *str, GOColor *color,
if (g_ascii_strncasecmp (str, color_txt, len) == 0) {
char *end;
guint64 ull = g_ascii_strtoull (str + len, &end, 10);
- if (end == str || errno == ERANGE || ull > 56)
+ if (end == str || errno == ERANGE || ull > 56 || ull <= 0)
return FALSE;
if (n)
*n = ull;
if (named)
*named = FALSE;
- /* FIXME: What do we do about *color? */
+ *color = format_numbered_colors[ull];
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]