[gnumeric] Add a PNG representation since everybody else seems to have difficulties with svg.



commit aecebbc88c7ee737b509c7738625ea66b7eecc15
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Fri Jul 10 16:15:40 2009 -0600

    Add a PNG representation since everybody else seems to have difficulties with svg.
    
     2009-07-10 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_write_frame): also link to a png
    	  representation
    	(odf_write_graph_manifest): include the png representations
    	(odf_write_axis_style): we should use "start" rather than 0
    	  as default axis-position
    	(odf_write_graphs): write png representation

 plugins/openoffice/ChangeLog          |    9 +++++++++
 plugins/openoffice/openoffice-write.c |   26 +++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 948f787..0d0b507 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
 2009-07-10 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-write.c (odf_write_frame): also link to a png
+	  representation
+	(odf_write_graph_manifest): include the png representations
+	(odf_write_axis_style): we should use "start" rather than 0
+	  as default axis-position
+	(odf_write_graphs): write png representation
+
+2009-07-10 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-write.c (odf_write_cell): let gsf figure
 	  out precision
 	(odf_print_spreadsheet_content_prelude): ditto
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 8f1bfdf..fa8db0d 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -2170,6 +2170,14 @@ odf_write_frame (GnmOOExport *state, SheetObject *so)
 			gsf_xml_out_add_cstr (state->xml, XLINK "show", "embed");
 			gsf_xml_out_add_cstr (state->xml, XLINK "actuate", "onLoad");
 			gsf_xml_out_end_element (state->xml); /*  DRAW "image" */
+			full_name = g_strdup_printf ("./Pictures/%s.png", name);
+			gsf_xml_out_start_element (state->xml, DRAW "image");
+			gsf_xml_out_add_cstr (state->xml, XLINK "href", full_name);
+			g_free (full_name);
+			gsf_xml_out_add_cstr (state->xml, XLINK "type", "simple");
+			gsf_xml_out_add_cstr (state->xml, XLINK "show", "embed");
+			gsf_xml_out_add_cstr (state->xml, XLINK "actuate", "onLoad");
+			gsf_xml_out_end_element (state->xml); /*  DRAW "image" */
 		} else
 			g_warning ("Graph is missing from hash.");
 	} else {
@@ -3110,6 +3118,9 @@ odf_write_graph_manifest (G_GNUC_UNUSED SheetObject *graph, char const *name, Gn
 	fullname = g_strdup_printf ("Pictures/%s", name);
 	odf_file_entry (state->xml, "image/svg+xml", fullname);
 	g_free(fullname);
+	fullname = g_strdup_printf ("Pictures/%s.png", name);
+	odf_file_entry (state->xml, "image/png", fullname);
+	g_free(fullname);
 }
 
 static void
@@ -3170,7 +3181,7 @@ odf_write_axis_style (GnmOOExport *state, GogObject const *chart, char const *ax
 		
 		g_object_get (G_OBJECT (axis), "map-name", &type, NULL);
 		odf_add_bool (state->xml, CHART "logarithmic", 0 != strcmp (type, "Linear"));
-		gsf_xml_out_add_int (state->xml, CHART "axis-position", 0);
+		gsf_xml_out_add_cstr (state->xml, CHART "axis-position", "start");
 
 		if (gog_axis_get_bounds (GOG_AXIS (axis), &minima, &maxima)) {
 			gsf_xml_out_add_float (state->xml, CHART "minimum", minima, -1);
@@ -3331,6 +3342,19 @@ odf_write_graphs (SheetObject *graph, char const *name, GnmOOExport *state)
 			g_object_unref (G_OBJECT (sec_child));
 		}
 		g_free (fullname);
+
+		fullname = g_strdup_printf ("Pictures/%s.png", name);
+		sec_child = gsf_outfile_new_child_full (state->outfile, fullname, FALSE,
+							"compression-level", GSF_ZIP_DEFLATED,
+							NULL);
+		if (NULL != sec_child) {
+			GogGraph *gog = sheet_object_graph_get_gog (graph);
+			if (!gog_graph_export_image (gog, GO_IMAGE_FORMAT_PNG, sec_child, 100., 100.))
+				g_print ("Failed to create png image of graph.\n");
+			gsf_output_close (sec_child);
+			g_object_unref (G_OBJECT (sec_child));
+		}
+		g_free (fullname);
 	}
 }
 



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