[gnumeric] ODF import/export additional axes. [#743787]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] ODF import/export additional axes. [#743787]
- Date: Sun, 22 Feb 2015 05:01:55 +0000 (UTC)
commit 86ea464e0bc89da913710df2f76af32243bc6065
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Sat Feb 21 21:59:14 2015 -0700
ODF import/export additional axes. [#743787]
2015-02-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_chart_axis): read and use gnm:id
(opendoc_content_dtd): attach gnm:axis
(opendoc_content_preparse_dtd): ditto
* openoffice-write.c (odf_write_axis_full): write all axes
NEWS | 1 +
plugins/openoffice/ChangeLog | 7 +++++
plugins/openoffice/openoffice-read.c | 42 +++++++++++++++++++++++++++++----
plugins/openoffice/openoffice-write.c | 36 ++++++++++++++++++----------
4 files changed, 68 insertions(+), 18 deletions(-)
---
diff --git a/NEWS b/NEWS
index ae98c54..e356366 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Andreas:
* Fix ODF import/export of axes label visibility. [#743788]
* ODF import/export additional axislines.
* Fix ODF import/export of fonts in charts. [#744632]
+ * ODF import/export additional axes. [#743787]
Morten:
* Initial xlsx import of sheet widgets.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index fee3a85..9f4446a 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (oo_chart_axis): read and use gnm:id
+ (opendoc_content_dtd): attach gnm:axis
+ (opendoc_content_preparse_dtd): ditto
+ * openoffice-write.c (odf_write_axis_full): write all axes
+
2015-02-19 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-write.c (odf_write_gradient_info): use positive angles
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index a00adcd..4c48813 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -8596,13 +8596,13 @@ oo_chart_axis (GsfXMLIn *xin, xmlChar const **attrs)
{ "y", GOG_AXIS_RADIAL },
{ NULL, 0 },
};
- GSList *axes;
+ GSList *axes, *l;
OOParseState *state = (OOParseState *)xin->user_state;
OOChartStyle *style = NULL;
gchar const *style_name = NULL;
GogAxisType axis_type;
- int tmp;
+ int tmp, gnm_id = 1;
OOEnum const *axes_types;
switch (state->chart.plot_type) {
@@ -8628,12 +8628,34 @@ oo_chart_axis (GsfXMLIn *xin, xmlChar const **attrs)
style_name = CXML2C (attrs[1]);
else if (oo_attr_enum (xin, attrs, OO_NS_CHART, "dimension", axes_types, &tmp))
axis_type = tmp;
+ else if (oo_attr_int_range (xin, attrs, OO_GNUM_NS_EXT, "id", &gnm_id, 1, INT_MAX))
+ ;
axes = gog_chart_get_axes (state->chart.chart, axis_type);
- if (NULL != axes) {
- state->chart.axis = axes->data;
- g_slist_free (axes);
+ for (l = axes; NULL != l; l = l->next) {
+ if (((unsigned)gnm_id) == gog_object_get_id (GOG_OBJECT (l->data))) {
+ state->chart.axis = l->data;
+ break;
+ }
+ }
+ g_slist_free (axes);
+ if (NULL == state->chart.axis && (axis_type == GOG_AXIS_X || axis_type == GOG_AXIS_Y
+ || axis_type == GOG_AXIS_Z)) {
+ GogObject *axis = GOG_OBJECT (g_object_new (GOG_TYPE_AXIS, "type", axis_type, NULL));
+ gog_object_add_by_name (GOG_OBJECT (state->chart.chart),
+ axis_type == GOG_AXIS_X ? "X-Axis" :
+ (axis_type == GOG_AXIS_Y ? "Y-Axis" : "Z-Axis"), axis);
+ axes = gog_chart_get_axes (state->chart.chart, axis_type);
+ for (l = axes; NULL != l; l = l->next) {
+ if (((unsigned)gnm_id) == gog_object_get_id (GOG_OBJECT (l->data))) {
+ state->chart.axis = l->data;
+ break;
+ }
+ }
+ g_slist_free (axes);
}
+ if (NULL == state->chart.axis)
+ g_print ("Did not find axis with type %i and id %i.\n", axis_type, gnm_id);
if (NULL != style_name &&
NULL != (style = g_hash_table_lookup (state->chart.graph_styles, style_name))) {
@@ -11879,10 +11901,15 @@ static GsfXMLInNode const opendoc_content_dtd [] =
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, &oo_chart_axis_end),
+ GSF_XML_IN_NODE (CHART_PLOT_AREA, GNM_CHART_AXIS, OO_GNUM_NS_EXT, "axis", GSF_XML_NO_CONTENT,
&oo_chart_axis, &oo_chart_axis_end),
GSF_XML_IN_NODE (CHART_AXIS, CHART_AXIS_LINE, OO_GNUM_NS_EXT, "axisline",
GSF_XML_NO_CONTENT, &oo_chart_axisline, NULL),
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_FULL (CHART_AXIS, CHART_AXIS_TITLE, OO_NS_CHART, "title",
GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_int = 3),
+ GSF_XML_IN_NODE (GNM_CHART_AXIS, GNM_CHART_AXIS_LINE, OO_GNUM_NS_EXT, "axisline",
GSF_XML_NO_CONTENT, &oo_chart_axisline, NULL),
+ GSF_XML_IN_NODE (GNM_CHART_AXIS, GNM_CHART_GRID, OO_NS_CHART, "grid", GSF_XML_NO_CONTENT,
&oo_chart_grid, NULL),
+ GSF_XML_IN_NODE (GNM_CHART_AXIS, GNM_CHART_AXIS_CAT, OO_NS_CHART, "categories",
GSF_XML_NO_CONTENT, &od_chart_axis_categories, NULL),
+ GSF_XML_IN_NODE_FULL (GNM_CHART_AXIS, GNM_CHART_AXIS_TITLE, OO_NS_CHART, "title",
GSF_XML_NO_CONTENT, FALSE, FALSE, &oo_chart_title, &oo_chart_title_end, .v_int = 3),
GSF_XML_IN_NODE (CHART_AXIS_TITLE, TEXT_CONTENT, OO_NS_TEXT, "p", GSF_XML_NO_CONTENT,
NULL, NULL),/* 2nd Def */
GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_OOO_COORDINATE_REGION, OO_NS_CHART_OOO,
"coordinate-region", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SPREADSHEET, TABLE, OO_NS_TABLE, "table", GSF_XML_NO_CONTENT, &oo_table_start,
&oo_table_end),
@@ -12152,10 +12179,15 @@ static GsfXMLInNode const opendoc_content_preparse_dtd [] =
GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_WALL, OO_NS_CHART, "wall", GSF_XML_NO_CONTENT, NULL,
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, NULL,
NULL),
+ GSF_XML_IN_NODE (CHART_PLOT_AREA, GNM_CHART_AXIS, OO_GNUM_NS_EXT, "axis", GSF_XML_NO_CONTENT,
NULL, NULL),
GSF_XML_IN_NODE (CHART_AXIS, CHART_AXISLINE, OO_GNUM_NS_EXT, "axisline",
GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (CHART_AXIS, CHART_GRID, OO_NS_CHART, "grid", GSF_XML_NO_CONTENT, NULL,
NULL),
GSF_XML_IN_NODE (CHART_AXIS, CHART_AXIS_CAT, OO_NS_CHART, "categories",
GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE_FULL (CHART_AXIS, CHART_AXIS_TITLE, OO_NS_CHART, "title",
GSF_XML_NO_CONTENT, FALSE, FALSE, NULL, NULL, .v_int = 3),
+ GSF_XML_IN_NODE (GNM_CHART_AXIS, GNM_CHART_AXISLINE, OO_GNUM_NS_EXT, "axisline",
GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (GNM_CHART_AXIS, GNM_CHART_GRID, OO_NS_CHART, "grid", GSF_XML_NO_CONTENT,
NULL, NULL),
+ GSF_XML_IN_NODE (GNM_CHART_AXIS, GNM_CHART_AXIS_CAT, OO_NS_CHART, "categories",
GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE_FULL (GNM_CHART_AXIS, GNM_CHART_AXIS_TITLE, OO_NS_CHART, "title",
GSF_XML_NO_CONTENT, FALSE, FALSE, NULL, NULL, .v_int = 3),
GSF_XML_IN_NODE (CHART_AXIS_TITLE, TEXT_CONTENT, OO_NS_TEXT, "p", GSF_XML_NO_CONTENT,
NULL, NULL),/* 2nd Def */
GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_OOO_COORDINATE_REGION, OO_NS_CHART_OOO,
"coordinate-region", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (SPREADSHEET, TABLE, OO_NS_TABLE, "table", GSF_XML_NO_CONTENT,
&odf_preparse_table_start, &odf_preparse_table_end),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index e705997..03643b8 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -7845,24 +7845,34 @@ odf_write_axis_full (GnmOOExport *state,
GSList const *series,
gboolean include_cats)
{
- GogObject const *axis;
+ GSList *children = NULL, *l;
if (axis_role == NULL)
return;
- axis = gog_object_get_child_by_name (chart, axis_role);
- if (axis != NULL) {
- 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);
- if (include_cats)
- odf_write_axis_categories (state, series);
- odf_write_axis_grid (state, axis);
- odf_write_axislines (state, axis);
- gsf_xml_out_end_element (state->xml); /* </chart:axis> */
+ children = gog_object_get_children (chart, gog_object_find_role_by_name (chart, axis_role));
+
+ for (l = children; l != NULL; l = l->next) {
+ GogObject const *axis = l->data;
+ if (axis != NULL) {
+ int id = gog_object_get_id (GOG_OBJECT (axis));
+ if (state->with_extension || id == 1) {
+ gsf_xml_out_start_element (state->xml,
+ (id == 1) ? CHART "axis" : GNMSTYLE "axis");
+ gsf_xml_out_add_cstr (state->xml, CHART "dimension", dimension);
+ if (state->with_extension)
+ gsf_xml_out_add_int (state->xml, GNMSTYLE "id", id);
+ gsf_xml_out_add_cstr (state->xml, CHART "style-name", style_label);
+ odf_write_label (state, axis);
+ if (include_cats)
+ odf_write_axis_categories (state, series);
+ odf_write_axis_grid (state, axis);
+ odf_write_axislines (state, axis);
+ gsf_xml_out_end_element (state->xml); /* </chart:axis> or </gnm:axis>*/
+ }
+ }
}
-
+ g_slist_free (children);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]