[gnumeric] xlsx: more colour modification handling.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] xlsx: more colour modification handling.
- Date: Mon, 30 Mar 2015 21:55:37 +0000 (UTC)
commit 5a546fcc2b0752df420288cc147952955c025d41
Author: Morten Welinder <terra gnome org>
Date: Mon Mar 30 17:55:32 2015 -0400
xlsx: more colour modification handling.
plugins/excel/ChangeLog | 5 ++
plugins/excel/xlsx-read-drawing.c | 76 ++++++++++++++++++++----------------
plugins/excel/xlsx-read.c | 3 -
3 files changed, 47 insertions(+), 37 deletions(-)
---
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 3798843..1eca1e9 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-30 Morten Welinder <terra gnome org>
+
+ * xlsx-read-drawing.c (xlsx_draw_color_rgba_channel): Rename from
+ xlsx_draw_color_alpha. Handle all four channels.
+
2015-03-30 Jean Brefort <jean brefort normalesup org>
* ms-chart.c (ms_excel_chart_read): support absolute sheet object anchoring.
diff --git a/plugins/excel/xlsx-read-drawing.c b/plugins/excel/xlsx-read-drawing.c
index d557e7e..f2fa2d1 100644
--- a/plugins/excel/xlsx-read-drawing.c
+++ b/plugins/excel/xlsx-read-drawing.c
@@ -2011,30 +2011,38 @@ xlsx_draw_color_rgb (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
-xlsx_draw_color_alpha (GsfXMLIn *xin, xmlChar const **attrs)
-{
- XLSXReadState *state = (XLSXReadState *)xin->user_state;
- guint action = xin->node->user_data.v_int;
- unsigned val;
- if (simple_uint (xin, attrs, &val)) {
- const unsigned scale = 100000u;
- int a = GO_COLOR_UINT_A (state->color);
+xlsx_draw_color_rgba_channel (GsfXMLIn *xin, xmlChar const **attrs)
+{
+ XLSXReadState *state = (XLSXReadState *)xin->user_state;
+ guint action = xin->node->user_data.v_int & 3;
+ guint channel = xin->node->user_data.v_int >> 2;
+ int val;
+ if (simple_int (xin, attrs, &val)) {
+ const double f = val / 100000.0;
+ int v;
+ double vf;
+
+ switch (channel) {
+ case 3: v = GO_COLOR_UINT_A (state->color); break;
+ case 2: v = GO_COLOR_UINT_R (state->color); break;
+ case 1: v = GO_COLOR_UINT_G (state->color); break;
+ case 0: v = GO_COLOR_UINT_B (state->color); break;
+ default: g_assert_not_reached ();
+ }
switch (action) {
- case 0:
- a = 255u * CLAMP (val, 0u, scale) / scale;
- break;
- case 1:
- a += 255u * CLAMP (val, 0u, scale) / scale;
- break;
- case 2:
- a = a * CLAMP (val, 0u, scale) / scale;
- break;
- default:
- g_assert_not_reached ();
+ case 0: vf = 256 * f; break;
+ case 1: vf = v + 256 * f; break;
+ case 2: vf = v * f; break;
+ default: g_assert_not_reached ();
+ }
+ v = CLAMP (vf, 0, 255);
+ switch (channel) {
+ case 3: state->color = GO_COLOR_CHANGE_A (state->color, v); break;
+ case 2: state->color = GO_COLOR_CHANGE_R (state->color, v); break;
+ case 1: state->color = GO_COLOR_CHANGE_G (state->color, v); break;
+ case 0: state->color = GO_COLOR_CHANGE_B (state->color, v); break;
+ default: g_assert_not_reached ();
}
-
- a = CLAMP (a, 0, 255);
- state->color = GO_COLOR_CHANGE_A (state->color, a);
color_set_helper (state);
}
}
@@ -2352,9 +2360,9 @@ xlsx_ext_gostyle (GsfXMLIn *xin, xmlChar const **attrs)
COLOR_MODIFIER_NODE(parent, COLOR_COMP, "comp", first, NULL, 0), \
COLOR_MODIFIER_NODE(parent, COLOR_INV, "inv", first, NULL, 0), \
COLOR_MODIFIER_NODE(parent, COLOR_GRAY, "gray", first, NULL, 0), \
- COLOR_MODIFIER_NODE(parent, COLOR_ALPHA, "alpha", first, &xlsx_draw_color_alpha, 0), \
- COLOR_MODIFIER_NODE(parent, COLOR_ALPHA_OFF, "alphaOff", first, &xlsx_draw_color_alpha, 1), \
- COLOR_MODIFIER_NODE(parent, COLOR_ALPHA_MOD, "alphaMod", first, &xlsx_draw_color_alpha, 2), \
+ COLOR_MODIFIER_NODE(parent, COLOR_ALPHA, "alpha", first, &xlsx_draw_color_rgba_channel, 12), \
+ COLOR_MODIFIER_NODE(parent, COLOR_ALPHA_OFF, "alphaOff", first, &xlsx_draw_color_rgba_channel, 13), \
+ COLOR_MODIFIER_NODE(parent, COLOR_ALPHA_MOD, "alphaMod", first, &xlsx_draw_color_rgba_channel, 14), \
COLOR_MODIFIER_NODE(parent, COLOR_HUE, "hue", first, NULL, 0), \
COLOR_MODIFIER_NODE(parent, COLOR_HUE_OFF, "hueOff", first, NULL, 1), \
COLOR_MODIFIER_NODE(parent, COLOR_HUE_MOD, "hueMod", first, NULL, 2), \
@@ -2364,15 +2372,15 @@ xlsx_ext_gostyle (GsfXMLIn *xin, xmlChar const **attrs)
COLOR_MODIFIER_NODE(parent, COLOR_LUM, "lum", first, NULL, 0), \
COLOR_MODIFIER_NODE(parent, COLOR_LUM_OFF, "lumOff", first, NULL, 1), \
COLOR_MODIFIER_NODE(parent, COLOR_LUM_MOD, "lumMod", first, NULL, 2), \
- COLOR_MODIFIER_NODE(parent, COLOR_RED, "red", first, NULL, 0), \
- COLOR_MODIFIER_NODE(parent, COLOR_RED_OFF, "redOff", first, NULL, 1), \
- COLOR_MODIFIER_NODE(parent, COLOR_RED_MOD, "redMod", first, NULL, 2), \
- COLOR_MODIFIER_NODE(parent, COLOR_GREEN, "green", first, NULL, 0), \
- COLOR_MODIFIER_NODE(parent, COLOR_GREEN_OFF, "greenOff", first, NULL, 1), \
- COLOR_MODIFIER_NODE(parent, COLOR_GREEN_MOD, "greenMod", first, NULL, 2), \
- COLOR_MODIFIER_NODE(parent, COLOR_BLUE, "blue", first, NULL, 0), \
- COLOR_MODIFIER_NODE(parent, COLOR_BLUE_OFF, "blueOff", first, NULL, 1), \
- COLOR_MODIFIER_NODE(parent, COLOR_BLUE_MOD, "blueMod", first, NULL, 2), \
+ COLOR_MODIFIER_NODE(parent, COLOR_RED, "red", first, &xlsx_draw_color_rgba_channel, 8), \
+ COLOR_MODIFIER_NODE(parent, COLOR_RED_OFF, "redOff", first, &xlsx_draw_color_rgba_channel, 9), \
+ COLOR_MODIFIER_NODE(parent, COLOR_RED_MOD, "redMod", first, &xlsx_draw_color_rgba_channel, 10), \
+ COLOR_MODIFIER_NODE(parent, COLOR_GREEN, "green", first, &xlsx_draw_color_rgba_channel, 4), \
+ COLOR_MODIFIER_NODE(parent, COLOR_GREEN_OFF, "greenOff", first, &xlsx_draw_color_rgba_channel, 5), \
+ COLOR_MODIFIER_NODE(parent, COLOR_GREEN_MOD, "greenMod", first, &xlsx_draw_color_rgba_channel, 6), \
+ COLOR_MODIFIER_NODE(parent, COLOR_BLUE, "blue", first, &xlsx_draw_color_rgba_channel, 0), \
+ COLOR_MODIFIER_NODE(parent, COLOR_BLUE_OFF, "blueOff", first, &xlsx_draw_color_rgba_channel, 1), \
+ COLOR_MODIFIER_NODE(parent, COLOR_BLUE_MOD, "blueMod", first, &xlsx_draw_color_rgba_channel, 2), \
COLOR_MODIFIER_NODE(parent, COLOR_GAMMA, "gamma", first, NULL, 0), \
COLOR_MODIFIER_NODE(parent, COLOR_INV_GAMMA, "invGamma", first, NULL, 0)
diff --git a/plugins/excel/xlsx-read.c b/plugins/excel/xlsx-read.c
index 61ef640..5dc890c 100644
--- a/plugins/excel/xlsx-read.c
+++ b/plugins/excel/xlsx-read.c
@@ -821,7 +821,6 @@ simple_bool (GsfXMLIn *xin, xmlChar const **attrs, int *res)
return FALSE;
}
-#if 0
static gboolean
simple_int (GsfXMLIn *xin, xmlChar const **attrs, int *res)
{
@@ -830,8 +829,6 @@ simple_int (GsfXMLIn *xin, xmlChar const **attrs, int *res)
return TRUE;
return FALSE;
}
-#endif
-
static gboolean
simple_uint (GsfXMLIn *xin, xmlChar const **attrs, unsigned *res)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]