[gnumeric] handle chart wall
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] handle chart wall
- Date: Thu, 19 Aug 2010 07:57:19 +0000 (UTC)
commit ac2f86fc39825b14d4ad561752ed6d64e0876a73
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Aug 19 01:56:59 2010 -0600
handle chart wall
2010-08-19 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (OOChartStyle): new field
(oo_style): initalize new field
(od_style_prop_chart): new attributes
(odf_apply_style_props): new
(oo_chart_wall): implement
(oo_chart_style_free): finalize new field
* openoffice-write.c (odf_go_color_to_string): new
(gnm_xml_out_add_hex_color): use odf_go_color_to_string
(odf_write_plot): Backplane belongs to chart, write wallstyle
plugins/openoffice/ChangeLog | 12 +++++++
plugins/openoffice/openoffice-read.c | 58 ++++++++++++++++++++++++++++++--
plugins/openoffice/openoffice-write.c | 34 +++++++++++++++----
3 files changed, 92 insertions(+), 12 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 44ac3bf..95c3db3 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-19 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (OOChartStyle): new field
+ (oo_style): initalize new field
+ (od_style_prop_chart): new attributes
+ (odf_apply_style_props): new
+ (oo_chart_wall): implement
+ (oo_chart_style_free): finalize new field
+ * openoffice-write.c (odf_go_color_to_string): new
+ (gnm_xml_out_add_hex_color): use odf_go_color_to_string
+ (odf_write_plot): Backplane belongs to chart, write wallstyle
+
2010-08-18 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_chart_title_end): add to the correct object. That
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 896c3d2..ff5eebf 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -163,6 +163,7 @@ typedef struct {
GSList *axis_props; /* axis properties */
GSList *plot_props; /* plot properties */
GSList *series_props; /* any other properties */
+ GSList *style_props; /* any other properties */
GSList *other_props; /* any other properties */
} OOChartStyle;
@@ -1729,6 +1730,7 @@ oo_style (GsfXMLIn *xin, xmlChar const **attrs)
cur_style->axis_props = NULL;
cur_style->plot_props = NULL;
cur_style->series_props = NULL;
+ cur_style->style_props = NULL;
cur_style->other_props = NULL;
state->chart.cur_graph_style = cur_style;
g_hash_table_replace (state->chart.graph_styles,
@@ -3392,6 +3394,16 @@ od_style_prop_chart (GsfXMLIn *xin, xmlChar const **attrs)
else if (oo_attr_bool (xin, attrs, OO_GNUM_NS_EXT, "multi-series", &btmp))
style->other_props = g_slist_prepend (style->other_props,
oo_prop_new_bool ("multi-series", btmp));
+ else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "fill"))
+ style->style_props = g_slist_prepend
+ (style->style_props,
+ oo_prop_new_string ("fill",
+ CXML2C(attrs[1])));
+ else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_DRAW, "fill-color"))
+ style->style_props = g_slist_prepend
+ (style->style_props,
+ oo_prop_new_string ("fill-color",
+ CXML2C(attrs[1])));
}
if (draw_stroke_set && !default_style_has_lines_set)
@@ -4549,15 +4561,52 @@ oo_chart_grid (GsfXMLIn *xin, xmlChar const **attrs)
}
static void
+odf_apply_style_props (GSList *props, GOStyle *style)
+{
+ GSList *l;
+ for (l = props; l != NULL; l = l->next) {
+ OOProp *prop = l->data;
+ if (0 == strcmp (prop->name, "fill")) {
+ if (0 == strcmp (g_value_get_string (&prop->value), "solid")) {
+ style->fill.type = GO_STYLE_FILL_PATTERN;
+ style->fill.pattern.pattern = GO_PATTERN_SOLID;
+ } else {
+ style->fill.type = GO_STYLE_FILL_NONE;
+ }
+ } else if (0 == strcmp (prop->name, "fill-color")) {
+ GdkColor gdk_color;
+ gchar const *color = g_value_get_string (&prop->value);
+ if (gdk_color_parse (color, &gdk_color))
+ style->fill.pattern.back = GO_COLOR_FROM_GDK (gdk_color);
+ }
+ }
+}
+
+
+static void
oo_chart_wall (GsfXMLIn *xin, xmlChar const **attrs)
{
OOParseState *state = (OOParseState *)xin->user_state;
-/* GOStyle *style = NULL; */
-/* GogObject *backplane; */
+ GogObject *backplane;
+ gchar *style_name = NULL;
+
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_CHART, "style-name"))
+ style_name = g_strdup (CXML2C (attrs[1]));
- /* backplane = */gog_object_add_by_name (GOG_OBJECT (state->chart.chart), "Backplane", NULL);
+ backplane = gog_object_add_by_name (GOG_OBJECT (state->chart.chart), "Backplane", NULL);
-/* g_object_get (G_OBJECT (backplane), "style", &style, NULL); */
+ if (style_name != NULL && backplane != NULL) {
+ GOStyle *style = NULL;
+ g_object_get (G_OBJECT (backplane), "style", &style, NULL);
+
+ if (style != NULL) {
+ OOChartStyle *chart_style = g_hash_table_lookup
+ (state->chart.graph_styles, style_name);
+ odf_apply_style_props (chart_style->style_props, style);
+ g_object_unref (style);
+ }
+ }
}
static void
@@ -4565,6 +4614,7 @@ oo_chart_style_free (OOChartStyle *cstyle)
{
oo_prop_list_free (cstyle->axis_props);
oo_prop_list_free (cstyle->series_props);
+ oo_prop_list_free (cstyle->style_props);
oo_prop_list_free (cstyle->plot_props);
oo_prop_list_free (cstyle->other_props);
g_free (cstyle);
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 1485649..1e1d277 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -409,6 +409,15 @@ odf_add_pt (GsfXMLOut *xml, char const *id, double l)
g_string_free (str, TRUE);
}
+static char *
+odf_go_color_to_string (GOColor color)
+{
+ return g_strdup_printf ("#%.2x%.2x%.2x",
+ GO_COLOR_UINT_R (color),
+ GO_COLOR_UINT_G (color),
+ GO_COLOR_UINT_B (color));
+}
+
static void
gnm_xml_out_add_hex_color (GsfXMLOut *o, char const *id, GnmColor const *c, int pattern)
{
@@ -418,10 +427,7 @@ gnm_xml_out_add_hex_color (GsfXMLOut *o, char const *id, GnmColor const *c, int
gsf_xml_out_add_cstr_unchecked (o, id, "transparent");
else {
char *color;
- color = g_strdup_printf ("#%.2x%.2x%.2x",
- GO_COLOR_UINT_R (c->go_color),
- GO_COLOR_UINT_G (c->go_color),
- GO_COLOR_UINT_B (c->go_color));
+ color = odf_go_color_to_string (c->go_color);
gsf_xml_out_add_cstr_unchecked (o, id, color);
g_free (color);
}
@@ -4146,7 +4152,7 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
double res_pts[4] = {0.,0.,0.,0.};
GSList const *series, *l;
int i;
- GogObject const *wall = gog_object_get_child_by_name (plot, "Backplane");
+ GogObject const *wall = gog_object_get_child_by_name (chart, "Backplane");
GogObject const *legend = gog_object_get_child_by_name (chart, "Legend");
GSList *titles = gog_object_get_children (chart, gog_object_find_role_by_name (chart, "Title"));
@@ -4379,13 +4385,25 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
}
if (wall != NULL) {
+ GOStyle *style = NULL;
+ g_object_get (G_OBJECT (wall), "style", &style, NULL);
+
odf_start_style (state->xml, "wallstyle", "chart");
gsf_xml_out_start_element (state->xml, STYLE "graphic-properties");
- gsf_xml_out_add_cstr (state->xml, DRAW "fill", "solid");
-/* gnm_xml_out_add_hex_color (state->xml, DRAW "fill-color", GnmColor const *c, 1) */
- gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", "#D0D0D0");
+
+ if (style->fill.type == GO_STYLE_FILL_PATTERN) {
+ char *color;
+ color = odf_go_color_to_string (style->fill.pattern.back);
+ gsf_xml_out_add_cstr (state->xml, DRAW "fill", "solid");
+ gsf_xml_out_add_cstr (state->xml, DRAW "fill-color", color);
+ g_free (color);
+ } else
+ gsf_xml_out_add_cstr (state->xml, DRAW "fill", "none");
+
gsf_xml_out_end_element (state->xml); /* </style:graphic-properties> */
gsf_xml_out_end_element (state->xml); /* </style:style> */
+
+ g_object_unref (G_OBJECT (style));
}
gsf_xml_out_end_element (state->xml); /* </office:automatic-styles> */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]