[gnumeric] support compass position for chart titles
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] support compass position for chart titles
- Date: Mon, 14 May 2012 04:51:41 +0000 (UTC)
commit e4e6fdb5a6e20b6ac8cacda379b251ea0e1fcce1
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun May 13 22:50:59 2012 -0600
support compass position for chart titles
2012-05-13 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_chart_title): handle compass position
(oo_chart_title_end): ditto
(opendoc_content_dtd): support chart:footer
* openoffice-write.c (odf_write_title): write compass position,
add argument and change all callers
(odf_write_plot): write chart:footer or chart:subtitle depending
on compass position
plugins/openoffice/ChangeLog | 10 ++++++++++
plugins/openoffice/openoffice-read.c | 22 ++++++++++++++++++----
plugins/openoffice/openoffice-write.c | 31 +++++++++++++++++++++++++------
3 files changed, 53 insertions(+), 10 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 53c9390..f2f64d5 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,15 @@
2012-05-13 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * openoffice-read.c (oo_chart_title): handle compass position
+ (oo_chart_title_end): ditto
+ (opendoc_content_dtd): support chart:footer
+ * openoffice-write.c (odf_write_title): write compass position,
+ add argument and change all callers
+ (odf_write_plot): write chart:footer or chart:subtitle depending
+ on compass position
+
+2012-05-13 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (oo_chart_title_end): potetially add a title
to the graph, not just the chart
(opendoc_content_dtd): differentiate between chart:title and
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 1f30c88..65ff5c5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -244,6 +244,7 @@ typedef struct {
GnmExprTop const *title_expr;
gchar *title_style;
+ gchar *title_position;
OOChartStyle *cur_graph_style; /* for reading of styles */
@@ -7543,6 +7544,8 @@ oo_chart_title (GsfXMLIn *xin, xmlChar const **attrs)
state->chart.title_expr = NULL;
state->chart.title_style = NULL;
+ state->chart.title_position = NULL;
+
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2){
if ((gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
OO_NS_TABLE, "cell-address" ) ||
@@ -7575,9 +7578,14 @@ oo_chart_title (GsfXMLIn *xin, xmlChar const **attrs)
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
OO_NS_CHART, "style-name")) {
state->chart.title_style = g_strdup (CXML2C (attrs[1]));
- }
+ } else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
+ OO_GNUM_NS_EXT, "compass"))
+ state->chart.title_position = g_strdup (CXML2C (attrs[1]));
}
+ if (state->chart.title_position == NULL)
+ state->chart.title_position = g_strdup ((xin->node->user_data.v_int == 2) ? "bottom" : "top");
+
odf_push_text_p (state, FALSE);
}
@@ -7613,7 +7621,7 @@ oo_chart_title_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
} else if (state->chart.legend != NULL) {
obj = (GogObject *)state->chart.legend;
tag = "Title";
- } else if (xin->node->user_data.v_bool) {
+ } else if (xin->node->user_data.v_int == 0) {
obj = (GogObject *)state->chart.graph;
tag = "Title";
} else {
@@ -7641,7 +7649,11 @@ oo_chart_title_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
}
if (use_markup)
g_object_set (label, "allow-markup", TRUE, NULL);
+ if (state->chart.title_position)
+ g_object_set (label, "compass", state->chart.title_position, NULL);
}
+ g_free (state->chart.title_position);
+ state->chart.title_position = NULL;
odf_pop_text_p (state);
}
@@ -9984,10 +9996,12 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (CHART_TABLE_HCOLS, CHART_TABLE_HCOL, OO_NS_TABLE, "table-header-column", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (CHART_TABLE_HCOLS, CHART_TABLE_COL, OO_NS_TABLE, "table-column", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
- GSF_XML_IN_NODE_FULL (CHART_CHART, CHART_TITLE, OO_NS_CHART, "title", GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_bool = TRUE),
+ GSF_XML_IN_NODE_FULL (CHART_CHART, CHART_TITLE, OO_NS_CHART, "title", GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_int = 0),
GSF_XML_IN_NODE (CHART_TITLE, TEXT_CONTENT, OO_NS_TEXT, "p", GSF_XML_NO_CONTENT, NULL, NULL),/* 2nd Def */
- GSF_XML_IN_NODE_FULL (CHART_CHART, CHART_SUBTITLE, OO_NS_CHART, "subtitle", GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_str = FALSE),
+ GSF_XML_IN_NODE_FULL (CHART_CHART, CHART_SUBTITLE, OO_NS_CHART, "subtitle", GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_int = 1),
GSF_XML_IN_NODE (CHART_SUBTITLE, TEXT_CONTENT, OO_NS_TEXT, "p", GSF_XML_NO_CONTENT, NULL, NULL),/* 2nd Def */
+ GSF_XML_IN_NODE_FULL (CHART_CHART, CHART_FOOTER, OO_NS_CHART, "footer", GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_int = 2),
+ GSF_XML_IN_NODE (CHART_FOOTER, TEXT_CONTENT, OO_NS_TEXT, "p", GSF_XML_NO_CONTENT, NULL, NULL),/* 2nd Def */
GSF_XML_IN_NODE (CHART_CHART, CHART_LEGEND, OO_NS_CHART, "legend", GSF_XML_NO_CONTENT, &oo_legend, &oo_legend_end),
GSF_XML_IN_NODE (CHART_LEGEND, CHART_LEGEND_TITLE, OO_GNUM_NS_EXT, "title", GSF_XML_NO_CONTENT, &oo_chart_title, &oo_chart_title_end),
GSF_XML_IN_NODE (CHART_LEGEND_TITLE, TEXT_CONTENT, OO_NS_TEXT, "p", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd Def */
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 7d11971..8474984 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -6523,10 +6523,16 @@ odf_write_axis_grid (GnmOOExport *state, GogObject const *axis)
static void
odf_write_title (GnmOOExport *state, GogObject const *title,
- char const *id, gboolean allow_content)
+ char const *id, gboolean allow_content, char *position)
{
if (title != NULL && id != NULL) {
GOData const *dat = gog_dataset_get_dim (GOG_DATASET(title),0);
+
+ if (position == NULL && state->with_extension)
+ g_object_get (G_OBJECT (title),
+ "compass", &position,
+ NULL);
+
if (dat != NULL) {
GnmExprTop const *texpr = gnm_go_data_get_expr (dat);
if (texpr != NULL) {
@@ -6537,6 +6543,9 @@ odf_write_title (GnmOOExport *state, GogObject const *title,
g_object_get (G_OBJECT (state->xml), "pretty-print", &pp, NULL);
gsf_xml_out_start_element (state->xml, id);
+ if (position && state->with_extension)
+ gsf_xml_out_add_cstr (state->xml,
+ GNMSTYLE "compass", position);
name = odf_get_gog_style_name_from_obj (title);
@@ -6606,6 +6615,7 @@ odf_write_title (GnmOOExport *state, GogObject const *title,
}
}
}
+ g_free (position);
}
static void
@@ -6618,7 +6628,7 @@ odf_write_label (GnmOOExport *state, GogObject const *axis)
GogObject const *label = NULL;
label = labels->data;
- odf_write_title (state, label, CHART "title", TRUE);
+ odf_write_title (state, label, CHART "title", TRUE, NULL);
g_slist_free (labels);
}
@@ -7302,12 +7312,21 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *graph,
if (titles != NULL) {
GogObject const *title = titles->data;
- odf_write_title (state, title, CHART "title", TRUE);
+ odf_write_title (state, title, CHART "title", TRUE, NULL);
g_slist_free (titles);
}
if (subtitles != NULL) {
GogObject const *title = subtitles->data;
- odf_write_title (state, title, CHART "subtitle", TRUE);
+ char *position = NULL;
+ gboolean is_footer = FALSE;
+
+ g_object_get (G_OBJECT (title),
+ "compass", &position,
+ NULL);
+ is_footer = NULL != g_strstr_len (position, -1, "bottom");
+ odf_write_title (state, title,
+ is_footer ? CHART "footer" : CHART "subtitle",
+ TRUE, position);
g_slist_free (subtitles);
}
@@ -7358,7 +7377,7 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *graph,
if (state->with_extension)
odf_write_title (state, title,
- GNMSTYLE "title", state->odf_version > 101);
+ GNMSTYLE "title", state->odf_version > 101, NULL);
else if (state->odf_version > 101) {
GOData const *dat =
gog_dataset_get_dim (GOG_DATASET(title),0);
@@ -7536,7 +7555,7 @@ odf_write_images (SheetObjectImage *image, char const *name, GnmOOExport *state)
g_object_unref (G_OBJECT (child));
}
- g_free(fullname);
+ g_free (fullname);
g_free (image_type);
odf_update_progress (state, state->graph_progress);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]