[gnumeric] ODF import and export axes labels.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ODF import and export axes labels.
- Date: Thu, 19 Aug 2010 05:14:30 +0000 (UTC)
commit c0556eb21d44c891235a65ccc353d888978ab55c
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Aug 18 23:14:02 2010 -0600
ODF import and export axes labels.
2010-08-18 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_chart_title_end): add to the correct object. That
might be an axis.
(oo_chart_axis_end): new
(opendoc_content_dtd): connect oo_chart_axis_end
* openoffice-write.c (odf_write_label): new
(odf_write_axis): also write label
plugins/openoffice/ChangeLog | 9 +++
plugins/openoffice/openoffice-read.c | 29 +++++++--
plugins/openoffice/openoffice-write.c | 102 +++++++++++++++++++-------------
3 files changed, 91 insertions(+), 49 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 918ca19..44ac3bf 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
2010-08-18 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (oo_chart_title_end): add to the correct object. That
+ might be an axis.
+ (oo_chart_axis_end): new
+ (opendoc_content_dtd): connect oo_chart_axis_end
+ * openoffice-write.c (odf_write_label): new
+ (odf_write_axis): also write label
+
+2010-08-18 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (oo_style): don't ignore non-default styles without
name
(oo_style_end): dispose of them here
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index c90ca7d..896c3d2 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -3878,12 +3878,20 @@ oo_chart_title_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
if (state->chart.title_expr) {
GOData *data = gnm_go_data_scalar_new_expr
(state->chart.src_sheet, state->chart.title_expr);
- GogObject *label = NULL;
- label = gog_object_add_by_name
- ((GogObject *)state->chart.chart, "Title", NULL);
- gog_dataset_set_dim (GOG_DATASET (label), 0,
- data,
- NULL);
+ GogObject *label;
+ GogObject *obj;
+ gchar const *tag;
+
+ if (state->chart.axis == NULL) {
+ obj = (GogObject *)state->chart.chart;
+ tag = "Title";
+ } else {
+ obj = (GogObject *)state->chart.axis;
+ tag = "Label";
+ }
+
+ label = gog_object_add_by_name (obj, tag, NULL);
+ gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
state->chart.title_expr = NULL;
}
@@ -3963,6 +3971,13 @@ oo_chart_axis (GsfXMLIn *xin, xmlChar const **attrs)
}
}
+static void
+oo_chart_axis_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+{
+ OOParseState *state = (OOParseState *)xin->user_state;
+ state->chart.axis = NULL;
+}
+
static int
gog_series_map_dim (GogSeries const *series, GogMSDimType ms_type)
{
@@ -4925,7 +4940,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (CHART_SERIES, SERIES_DATA_ERR, OO_NS_CHART, "error-indicator", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_WALL, OO_NS_CHART, "wall", GSF_XML_NO_CONTENT, &oo_chart_wall, NULL),
GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_FLOOR, OO_NS_CHART, "floor", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_AXIS, OO_NS_CHART, "axis", GSF_XML_NO_CONTENT, &oo_chart_axis, NULL),
+ GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_AXIS, OO_NS_CHART, "axis", GSF_XML_NO_CONTENT, &oo_chart_axis, &oo_chart_axis_end),
GSF_XML_IN_NODE (CHART_AXIS, CHART_GRID, OO_NS_CHART, "grid", GSF_XML_NO_CONTENT, &oo_chart_grid, NULL),
GSF_XML_IN_NODE (CHART_AXIS, CHART_AXIS_CAT, OO_NS_CHART, "categories", GSF_XML_NO_CONTENT, &od_chart_axis_categories, NULL),
GSF_XML_IN_NODE (CHART_AXIS, CHART_TITLE, OO_NS_CHART, "title", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 6b0e5b5..1485649 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4014,6 +4014,65 @@ odf_write_axis_grid (GnmOOExport *state, GogObject const *axis)
odf_write_one_axis_grid (state, axis, "MinorGrid", "minor");
}
+static void
+odf_write_title (GnmOOExport *state, GogObject const *title, char const *id)
+{
+ if (title != NULL && id != NULL) {
+ GOData const *dat = gog_dataset_get_dim (GOG_DATASET(title),0);
+ if (dat != NULL) {
+ GnmExprTop const *texpr = gnm_go_data_get_expr (dat);
+ if (texpr != NULL) {
+ GnmParsePos pp;
+ char *formula;
+ parse_pos_init (&pp, WORKBOOK (state->wb), NULL, 0,0 );
+ formula = gnm_expr_top_as_string (texpr, &pp, state->conv);
+
+ gsf_xml_out_start_element (state->xml, id);
+
+ if (gnm_expr_top_is_rangeref (texpr)) {
+ gsf_xml_out_add_cstr (state->xml, TABLE "cell-address",
+ odf_strip_brackets (formula));
+ } else if (GNM_EXPR_GET_OPER (texpr->expr) == GNM_EXPR_OP_CONSTANT
+ && texpr->expr->constant.value->type == VALUE_STRING) {
+ gboolean white_written = TRUE;
+ char const *str;
+ gsf_xml_out_start_element (state->xml, TEXT "p");
+ str = value_peek_string (texpr->expr->constant.value);
+ odf_add_chars (state, str, strlen (str), &white_written);
+ gsf_xml_out_end_element (state->xml); /* </text:p> */
+ } else {
+ gboolean white_written = TRUE;
+ if (state->with_extension)
+ gsf_xml_out_add_cstr (state->xml, GNMSTYLE "expression",
+ formula);
+ gsf_xml_out_start_element (state->xml, TEXT "p");
+ odf_add_chars (state, formula, strlen (formula),
+ &white_written);
+ gsf_xml_out_end_element (state->xml); /* </text:p> */
+ }
+ gsf_xml_out_end_element (state->xml); /* </chart:title> */
+ g_free (formula);
+ }
+ }
+ }
+}
+
+static void
+odf_write_label (GnmOOExport *state, GogObject const *axis)
+{
+ GSList *labels = gog_object_get_children
+ (axis, gog_object_find_role_by_name (axis, "Label"));
+
+ if (labels != NULL) {
+ GogObject const *label = NULL;
+
+ label = labels->data;
+ odf_write_title (state, label, CHART "title");
+ g_slist_free (labels);
+ }
+
+
+}
static void
odf_write_axis (GnmOOExport *state, GogObject const *chart, char const *axis_role,
@@ -4030,6 +4089,7 @@ odf_write_axis (GnmOOExport *state, GogObject const *chart, char const *axis_rol
gsf_xml_out_start_element (state->xml, CHART "axis");
gsf_xml_out_add_cstr (state->xml, CHART "dimension", dimension);
gsf_xml_out_add_cstr (state->xml, CHART "style-name", style_label);
+ odf_write_label (state, axis);
odf_write_axis_grid (state, axis);
gsf_xml_out_end_element (state->xml); /* </chart:axis> */
}
@@ -4077,48 +4137,6 @@ odf_write_axis_ring (GnmOOExport *state, GogObject const *chart, char const *axi
gsf_xml_out_end_element (state->xml); /* </chart:axis> */
}
-static void
-odf_write_title (GnmOOExport *state, GogObject const *title, char const *id)
-{
- if (title != NULL && id != NULL) {
- GOData const *dat = gog_dataset_get_dim (GOG_DATASET(title),0);
- if (dat != NULL) {
- GnmExprTop const *texpr = gnm_go_data_get_expr (dat);
- if (texpr != NULL) {
- GnmParsePos pp;
- char *formula;
- parse_pos_init (&pp, WORKBOOK (state->wb), NULL, 0,0 );
- formula = gnm_expr_top_as_string (texpr, &pp, state->conv);
-
- gsf_xml_out_start_element (state->xml, id);
-
- if (gnm_expr_top_is_rangeref (texpr)) {
- gsf_xml_out_add_cstr (state->xml, TABLE "cell-address",
- odf_strip_brackets (formula));
- } else if (GNM_EXPR_GET_OPER (texpr->expr) == GNM_EXPR_OP_CONSTANT
- && texpr->expr->constant.value->type == VALUE_STRING) {
- gboolean white_written = TRUE;
- char const *str;
- gsf_xml_out_start_element (state->xml, TEXT "p");
- str = value_peek_string (texpr->expr->constant.value);
- odf_add_chars (state, str, strlen (str), &white_written);
- gsf_xml_out_end_element (state->xml); /* </text:p> */
- } else {
- gboolean white_written = TRUE;
- if (state->with_extension)
- gsf_xml_out_add_cstr (state->xml, GNMSTYLE "expression",
- formula);
- gsf_xml_out_start_element (state->xml, TEXT "p");
- odf_add_chars (state, formula, strlen (formula),
- &white_written);
- gsf_xml_out_end_element (state->xml); /* </text:p> */
- }
- gsf_xml_out_end_element (state->xml); /* </chart:title> */
- g_free (formula);
- }
- }
- }
-}
static void
odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, GogObject const *plot)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]