[gnumeric] Import print area from ODF



commit 2fd6f52a273a3922656d0b96ac84629cbd9c560a
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Thu Jun 23 00:35:13 2011 -0600

    Import print area from ODF
    
    2011-06-23  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_parse_range_address_or_expr): new, extracted from
    	oo_plot_series
    	(oo_table_start): read table:print and table:print-ranges
    	(odf_page_layout_properties): we will be using table:print instead of
    	do_not_print in gnm:style-print
    	* openoffice-write.c (odf_write_content): write table:print
    	(odf_write_page_layout): do not include do_not_print in gnm:style-print
    
    2011-06-23  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* developer/odf-foreign.txt: update

 doc/ChangeLog                         |    4 ++
 doc/developer/odf-foreign.txt         |    6 ++-
 plugins/openoffice/ChangeLog          |   10 ++++
 plugins/openoffice/openoffice-read.c  |   83 +++++++++++++++++++++------------
 plugins/openoffice/openoffice-write.c |    5 +-
 5 files changed, 74 insertions(+), 34 deletions(-)
---
diff --git a/doc/ChangeLog b/doc/ChangeLog
index b5ba897..c7f65e3 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* developer/odf-foreign.txt: update
+
 2011-06-16  Morten Welinder <terra gnome org>
 
 	* Release 1.10.16
diff --git a/doc/developer/odf-foreign.txt b/doc/developer/odf-foreign.txt
index 142ba11..da137f4 100644
--- a/doc/developer/odf-foreign.txt
+++ b/doc/developer/odf-foreign.txt
@@ -29,6 +29,7 @@ An attribute to <number:scientific-number>. A value of "true" indicates that the
 
 gnm:max-denominator-digits
 An attribute to <number:fraction> giving the maximum number of denominator digits to be used.
+(In ODF 1.3 to be replaced by number:max-denominator-value.)
 
 2) Attribute _values_ added by Gnumeric. 
 Since these are not eleemnts or new attributes they are used in all ODF exports.
@@ -64,7 +65,7 @@ gnm:GnmVAlign
 An attribute of the <style:table-cell-properties> adding to the "automatic" value of style:vertical-align. Possible values are any GnmVAlign enumeration values other than VALIGN_TOP, VALIGN_BOTTOM, VALIGN_CENTER
 
 gnm:GnmHAlign
-An attribute of the <style:paragraph-properties> clarifying the "start" value of style:text-align. Possible values are any GnmHAlign enumeration values other than HALIGN_LEFT, HALIGN_RIGHT, HALIGN_CENTER, HALIGN_JUSTIFY 
+An attribute of the <style:paragraph-properties> clarifying the "start" value of style:text-align. Possible values are any GnmHAlign enumeration values other than HALIGN_LEFT, HALIGN_RIGHT, HALIGN_CENTER, HALIGN_JUSTIFY, HALIGN_FILL
 
 gnm:input-title
 gnm:input-msg
@@ -117,6 +118,9 @@ gnm:tab-color
 gnm:tab-text-color 
 attributes to the style:table-properties
 
+gnm:style-print
+A space separated list of items from annotations_at_end, black_n_white, draft, print_even_if_only_styles, errors_as_blank, errors_as_dashes, errors_as_na
+
 3) Attribute _values_ added by Gnumeric. 
 Since these are not eleemnts or new attributes they are used in all ODF exports.
 
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index ecdc609..2c15976 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,13 @@
+2011-06-23  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* openoffice-read.c (odf_parse_range_address_or_expr): new, extracted from
+	oo_plot_series
+	(oo_table_start): read table:print and table:print-ranges
+	(odf_page_layout_properties): we will be using table:print instead of
+	do_not_print in gnm:style-print
+	* openoffice-write.c (odf_write_content): write table:print
+	(odf_write_page_layout): do not include do_not_print in gnm:style-print
+
 2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* openoffice-read.c (opendoc_content_dtd): add more items
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 9c83f85..a771de7 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -1321,6 +1321,7 @@ oo_expr_rangeref_parse (GnmRangeRef *ref, char const *start, GnmParsePos const *
 	return start;
 }
 
+
 static char const *
 odf_strunescape (char const *string, GString *target,
 		   G_GNUC_UNUSED GnmConventions const *convs)
@@ -1602,6 +1603,35 @@ oo_expr_parse_str (GsfXMLIn *xin, char const *str,
 	return texpr;
 }
 
+static GnmExprTop const *
+odf_parse_range_address_or_expr (GsfXMLIn *xin, char const *str) 
+{
+	OOParseState *state = (OOParseState *)xin->user_state;
+	GnmExprTop const *texpr = NULL;
+	OOFormula f_type = odf_get_formula_type (xin, &str);
+	
+	if (f_type != FORMULA_NOT_SUPPORTED) {
+		GnmParsePos pp;
+		GnmRangeRef ref;
+		char const *ptr = oo_rangeref_parse
+			(&ref, str,
+			 parse_pos_init_sheet (&pp, state->pos.sheet),
+			 NULL);
+		if (ptr == str 
+		    || ref.a.sheet == invalid_sheet)
+			texpr = oo_expr_parse_str (xin, str,
+						   &state->pos,
+						   GNM_EXPR_PARSE_DEFAULT,
+						   f_type);
+		else {
+			GnmValue *v = value_new_cellrange (&ref.a, &ref.b, 0, 0);
+			texpr = gnm_expr_top_new_constant (v);
+		}
+	}
+	return texpr;
+}
+
+
 /****************************************************************************/
 
 static void
@@ -1727,6 +1757,8 @@ oo_table_start (GsfXMLIn *xin, xmlChar const **attrs)
 	OOParseState *state = (OOParseState *)xin->user_state;
 	gchar *style_name = NULL;
 	gchar *table_name = NULL;
+	gchar *print_range = NULL;
+	gboolean do_not_print = FALSE, tmp_b;
 
 	state->pos.eval.col = 0;
 	state->pos.eval.row = 0;
@@ -1742,7 +1774,10 @@ oo_table_start (GsfXMLIn *xin, xmlChar const **attrs)
 			table_name = g_strdup (CXML2C (attrs[1]));
 		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "style-name"))  {
 			style_name = g_strdup (CXML2C (attrs[1]));
-		}
+		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_TABLE, "print-ranges"))  {
+			print_range = g_strdup (CXML2C (attrs[1]));
+		} else if (oo_attr_bool (xin, attrs, OO_NS_TABLE, "print", &tmp_b))
+			do_not_print = !tmp_b;
 
 	if (table_name != NULL) {
 		state->pos.sheet = workbook_sheet_by_name (state->pos.wb, table_name);
@@ -1836,12 +1871,23 @@ oo_table_start (GsfXMLIn *xin, xmlChar const **attrs)
 		}
 		g_free (style_name);
 	}
+
+	state->pos.sheet->print_info->do_not_print = do_not_print;
+
 	if (state->default_style.rows != NULL)
 		sheet_row_set_default_size_pts (state->pos.sheet,
 							state->default_style.rows->size_pts);
 	if (state->default_style.columns != NULL)
 		sheet_col_set_default_size_pts (state->pos.sheet,
 						state->default_style.columns->size_pts);
+	if (print_range != NULL) {
+		GnmExprTop const *texpr = odf_parse_range_address_or_expr (xin, print_range);
+		if (texpr != NULL) {
+			GnmNamedExpr *nexpr = expr_name_lookup (&state->pos, "Print_Area");
+			if (nexpr != NULL)
+				expr_name_set_expr (nexpr, texpr);
+		}
+	}
 }
 
 /* odf_validation <table:name> <val1> */
@@ -4500,7 +4546,6 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 			state->print.cur_pi->print_black_and_white = 0;
 			state->print.cur_pi->print_as_draft = 0;
 			state->print.cur_pi->print_even_if_only_styles = 0;
-			state->print.cur_pi->do_not_print = 0;
 			state->print.cur_pi->error_display = PRINT_ERRORS_AS_DISPLAYED;
 			for (;items != NULL && *items; items++)
 				if (0 == strcmp (*items, "annotations_at_end"))
@@ -4517,8 +4562,6 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 					state->print.cur_pi->error_display = PRINT_ERRORS_AS_NA;
 				else if (0 == strcmp (*items, "print_even_if_only_styles"))
 					state->print.cur_pi->print_even_if_only_styles = 1;
-				else if (0 == strcmp (*items, "do_not_print"))
-					state->print.cur_pi->do_not_print = 1;
 			g_strfreev (items_c);
 		}
 	/* STYLE "writing-mode" is being ignored since we can't store it anywhere atm */
@@ -7252,32 +7295,12 @@ oo_plot_series (GsfXMLIn *xin, xmlChar const **attrs)
 	}
 
 	if (label != NULL) {
-		GnmExprTop const *texpr;
-		OOFormula f_type = odf_get_formula_type (xin, (char const **)&label);
-
-		if (f_type != FORMULA_NOT_SUPPORTED) {
-			GnmParsePos pp;
-			GnmRangeRef ref;
-			char const *ptr = oo_rangeref_parse
-				(&ref, CXML2C (label),
-				 parse_pos_init_sheet (&pp, state->pos.sheet),
-				 NULL);
-			if (ptr == CXML2C (label) 
-			    || ref.a.sheet == invalid_sheet)
-				texpr = oo_expr_parse_str (xin, label,
-							   &state->pos,
-							   GNM_EXPR_PARSE_DEFAULT,
-							   f_type);
-			else {
-				GnmValue *v = value_new_cellrange (&ref.a, &ref.b, 0, 0);
-				texpr = gnm_expr_top_new_constant (v);
-			}
-			if (texpr != NULL)
-				gog_series_set_name (state->chart.series,
-						     GO_DATA_SCALAR (gnm_go_data_scalar_new_expr
-								     (state->pos.sheet, texpr)),
-						     NULL);
-		}
+		GnmExprTop const *texpr = odf_parse_range_address_or_expr (xin, label);
+		if (texpr != NULL)
+			gog_series_set_name (state->chart.series,
+					     GO_DATA_SCALAR (gnm_go_data_scalar_new_expr
+							     (state->pos.sheet, texpr)),
+					     NULL);
 	}
 	oo_chart_style_to_series (xin, state->chart.i_plot_styles[OO_CHART_STYLE_PLOTAREA],
 				  G_OBJECT (state->chart.series));
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index f97c8b3..06db29d 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4351,8 +4351,9 @@ 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);
+		odf_add_bool (state->xml, TABLE "print", !sheet->print_info->do_not_print);
 
+		p_area  = sheet_get_nominal_printarea (sheet);
 		if (p_area != NULL) {
 			GnmValue *v = value_new_cellrange_r (sheet, p_area);
 			GnmExprTop const *texpr;
@@ -4962,8 +4963,6 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
 			g_string_append (gstr, " draft");
 		if (pi->print_even_if_only_styles)
 			g_string_append (gstr, " print_even_if_only_styles");
-		if (pi->do_not_print)
-			g_string_append (gstr, " do_not_print");
 		switch (pi->error_display) {
 		case PRINT_ERRORS_AS_BLANK:
 			g_string_append (gstr, " errors_as_blank");



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