[gnumeric] Improve print area handling and export to ODF



commit 7328cb04612128fa5b6d75f9e16a79d281bbc5dc
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Wed Jun 10 00:48:16 2009 -0600

    Improve print area handling and export to ODF
    
    2009-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	openoffice-write.c (odf_write_content): export print area to ODF
---
 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    4 +++
 plugins/openoffice/openoffice-write.c |   34 ++++++++++++++++++++++++++++++++-
 3 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index 2ee4273..25ae6a9 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@ Andreas:
 	* New FOURIER function
 	* Added Tests for Independence and Homogeneity
 	* Make imported manual page breaks work
+	* Improve print area handling and export to ODF
 
 Jody:
 	* GOString start of richtext and phonetic support.
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index aa442a5..32f9cad 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,7 @@
+2009-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	openoffice-write.c (odf_write_content): export print area to ODF 
+
 2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (opendoc_content_dtd): include 
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 2f01124..dcd3fc0 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1989,8 +1989,9 @@ odf_write_content (GnmOOExport *state, GsfOutput *child)
 	odf_print_spreadsheet_content_prelude (state);
 
 	for (i = 0; i < workbook_sheet_count (state->wb); i++) {
-		Sheet const *sheet = workbook_sheet_by_index (state->wb, i);
+		Sheet *sheet = workbook_sheet_by_index (state->wb, i);
 		char *style_name;
+		GnmRange    *p_area;
 
 		gsf_xml_out_start_element (state->xml, TABLE "table");
 		gsf_xml_out_add_cstr (state->xml, TABLE "name", sheet->name_unquoted);
@@ -1999,6 +2000,37 @@ odf_write_content (GnmOOExport *state, GsfOutput *child)
 		gsf_xml_out_add_cstr (state->xml, TABLE "style-name", style_name);
 		g_free (style_name);
 
+		p_area  = sheet_get_nominal_printarea (sheet);
+
+		if (p_area != NULL) { 
+			GnmValue *v = value_new_cellrange_r (sheet, p_area);
+			GnmExprTop const *texpr;
+			char *formula;
+			GnmParsePos pp;
+			char *closing;
+			GnmCellRef *a, *b;
+			
+			a = &v->v_range.cell.a;
+			b = &v->v_range.cell.b;
+			a->col_relative = b->col_relative = TRUE;
+			a->row_relative = b->row_relative = TRUE;
+	
+			texpr = gnm_expr_top_new_constant (v);
+
+			g_free (p_area);
+			parse_pos_init_sheet (&pp, sheet);
+			formula = gnm_expr_top_as_string (texpr,
+							  &pp,
+							  state->conv);
+			/* While this should be enough, ODF doesn't want the same format here as in formulas: */
+			closing = strrchr(formula, ']');
+			if (closing != NULL)
+				*closing = '\0';
+			gnm_expr_top_unref (texpr);
+			gsf_xml_out_add_cstr (state->xml, TABLE "print-ranges", (*formula == '[') ? (formula + 1) : formula);
+			g_free (formula);
+		}
+
 		odf_write_sheet (state, sheet);
 		gsf_xml_out_end_element (state->xml); /* </table:table> */
 



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