[gnumeric] Read and write the graph titles to/from ODF. [#675820]



commit d6220c345b8f121a907a08208caa4a66d2bd6645
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Sun May 13 21:06:52 2012 -0600

    Read and write the graph titles to/from ODF. [#675820]
    
    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
    	chart:subtitle
    	* openoffice-write.c (odf_write_plot): write the graph title as
    	chart:title and the chart title as chart:subtitle; add argument
    	(odf_write_graph_content): call odf_write_plot with the
    	additional argument

 NEWS                                  |    3 ++-
 plugins/openoffice/ChangeLog          |   11 +++++++++++
 plugins/openoffice/openoffice-read.c  |   15 +++++++++------
 plugins/openoffice/openoffice-write.c |   21 +++++++++++++--------
 4 files changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/NEWS b/NEWS
index 27884e0..a0ba4dd 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,8 @@ Andreas:
 	* Export/Import validation error message to/from ODF.
 	* Export in-cell font colours. [#675210]
 	* Fix warning on column insertion. [#675224]
-	* Correctly read & write rich-text graph titles to/from ODF. [#675821]
+	* Correctly read & write rich-text chart titles to/from ODF. [#675821]
+	* Read and write the graph titles to/from ODF. [#675820]
 
 Morten:
 	* Minor doc improvement for non-C locales.  [Part of #675000]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 8d0cab4..53c9390 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,14 @@
+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
+	chart:subtitle
+	* openoffice-write.c (odf_write_plot): write the graph title as
+	chart:title and the chart title as chart:subtitle; add argument
+	(odf_write_graph_content): call odf_write_plot with the
+	additional argument
+
 2012-05-12  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (odf_pango_attrs_to_markup): move to goffice
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index be93315..1f30c88 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -7613,10 +7613,13 @@ 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) {
+			obj = (GogObject *)state->chart.graph;
+			tag = "Title";
 		} else {
 			obj = (GogObject *)state->chart.chart;
 			tag = "Title";
-		}
+		} 
 
 		label = gog_object_add_by_name (obj, tag, NULL);
 		gog_dataset_set_dim (GOG_DATASET (label), 0, data, NULL);
@@ -9981,12 +9984,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 (CHART_CHART, CHART_TITLE, OO_NS_CHART, "title", GSF_XML_NO_CONTENT,  &oo_chart_title, &oo_chart_title_end),
-	            GSF_XML_IN_NODE (CHART_TITLE, TEXT_CONTENT, OO_NS_TEXT, "p", GSF_XML_NO_CONTENT, NULL, NULL),/* 2nd Def */
-	      GSF_XML_IN_NODE (CHART_CHART, CHART_SUBTITLE, OO_NS_CHART, "subtitle", GSF_XML_NO_CONTENT, &oo_chart_title, &oo_chart_title_end),
-	            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_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 (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 (CHART_SUBTITLE, 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, 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 */
 	      GSF_XML_IN_NODE (CHART_CHART, CHART_PLOT_AREA, OO_NS_CHART, "plot-area", GSF_XML_NO_CONTENT, &oo_plot_area, &oo_plot_area_end),
 		GSF_XML_IN_NODE (CHART_PLOT_AREA, CHART_SERIES, OO_NS_CHART, "series", GSF_XML_NO_CONTENT, &oo_plot_series, &oo_plot_series_end),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 6503c6b..7d11971 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -7091,7 +7091,8 @@ odf_write_generic_axis (GnmOOExport *state,
 }
 
 static void
-odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, GogObject const *plot)
+odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *graph, 
+		GogObject const *chart, GogObject const *plot)
 {
 	char const *plot_type = G_OBJECT_TYPE_NAME (plot);
 	SheetObjectAnchor const *anchor = sheet_object_get_anchor (so);
@@ -7099,7 +7100,10 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
 	GSList const *series, *l;
 	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"));
+	GogObjectRole const *trole = gog_object_find_role_by_name (graph, "Title");
+	GSList *titles = gog_object_get_children (graph, trole);
+	GogObjectRole const *trole2 = gog_object_find_role_by_name (chart, "Title");
+	GSList *subtitles = gog_object_get_children (chart, trole2);
 	char *name;
 	gchar *x_style = NULL;
 	gchar *y_style = NULL;
@@ -7299,13 +7303,13 @@ odf_write_plot (GnmOOExport *state, SheetObject *so, GogObject const *chart, Gog
 	if (titles != NULL) {
 		GogObject const *title = titles->data;
 		odf_write_title (state, title, CHART "title", TRUE);
-		if (titles->next != NULL) {
-			title = titles->next->data;
-			odf_write_title (state, title, CHART "subtitle", TRUE);
-		}
-
 		g_slist_free (titles);
 	}
+	if (subtitles != NULL) {
+		GogObject const *title = subtitles->data;
+		odf_write_title (state, title, CHART "subtitle", TRUE);
+		g_slist_free (subtitles);
+	}
 
 
 	/* Set up legend if appropriate*/
@@ -7481,7 +7485,8 @@ odf_write_graph_content (GnmOOExport *state, GsfOutput *child, SheetObject *so)
 					GSList *plots = gog_object_get_children
 						(chart, gog_object_find_role_by_name (chart, "Plot"));
 					if (plots != NULL && plots->data != NULL) {
-						odf_write_plot (state, so, chart, plots->data);
+						odf_write_plot (state, so, GOG_OBJECT (graph), 
+								chart, plots->data);
 						plot_written = TRUE;
 					}
 					g_slist_free (plots);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]