[gnumeric] Import/Export some more print formatting settings from/to ODF.



commit e985714275f894a30be029a78f63304904c60722
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Jun 21 22:44:59 2011 -0600

    Import/Export some more print formatting settings from/to ODF.
    
    2011-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (odf_page_layout_properties): read style:print and
    	gnm:style-print
    	* openoffice-write.c (odf_write_page_layout) write
    	style:print and gnm:style-print

 NEWS                                  |    2 +-
 plugins/openoffice/ChangeLog          |    7 +++++
 plugins/openoffice/openoffice-read.c  |   42 +++++++++++++++++++++++++++++++++
 plugins/openoffice/openoffice-write.c |   42 +++++++++++++++++++++++++++++++++
 4 files changed, 92 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index 62c0c2a..d734b25 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ Andreas:
 	* Fix some style import from ODF. [#652492]
 	* Import/Export header and footer from/to ODF.
 	* Import/Export margins from/to ODF.
-	* Import/Export some print formatting settings from/to ODF.
+	* Import/Export print formatting settings from/to ODF.
 
 Morten:
 	* Fix --with-gnome compilation:  [#652802]
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 214ef36..f0e37d1 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2011-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (odf_page_layout_properties): read style:print and
+	gnm:style-print
+	* openoffice-write.c (odf_write_page_layout) write
+	style:print and gnm:style-print
+
+2011-06-21  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (odf_get_paper_size): consider orientation
 	(odf_page_layout_properties): read style:print-page-order and
 	style:print-orientation
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index bb94045..27bd4bc 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4368,6 +4368,48 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 		} else if (oo_attr_enum (xin, attrs, OO_NS_STYLE, "print-orientation",
 					 print_orientation_type, &orient)) {
 			gtk_page_setup_set_orientation (gps, orient);
+		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
+					       OO_NS_STYLE, "print")) {
+			gchar **items = g_strsplit (CXML2C (attrs[1]), " ", 0);
+			gchar **items_c = items;
+			state->cur_pi->print_grid_lines = 0;
+			state->cur_pi->print_titles = 0;
+			state->cur_pi->comment_placement = PRINT_COMMENTS_NONE;
+			for (;items != NULL && *items; items++)
+				if (0 == strcmp (*items, "grid"))
+					state->cur_pi->print_grid_lines = 1;
+				else if (0 == strcmp (*items, "headers"))
+					state->cur_pi->print_titles = 1;
+				else if (0 == strcmp (*items, "annotations"))
+					state->cur_pi->comment_placement = PRINT_COMMENTS_IN_PLACE;
+			g_strfreev (items_c);
+		} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), 
+					       OO_GNUM_NS_EXT, "style-print")) {
+			gchar **items = g_strsplit (CXML2C (attrs[1]), " ", 0);
+			gchar **items_c = items;
+			state->cur_pi->print_black_and_white = 0;
+			state->cur_pi->print_as_draft = 0;
+			state->cur_pi->print_even_if_only_styles = 0;
+			state->cur_pi->do_not_print = 0;
+			state->cur_pi->error_display = PRINT_ERRORS_AS_DISPLAYED;
+			for (;items != NULL && *items; items++)
+				if (0 == strcmp (*items, "annotations_at_end"))
+					state->cur_pi->comment_placement = PRINT_COMMENTS_AT_END;
+				else if (0 == strcmp (*items, "black_n_white"))
+					state->cur_pi->print_black_and_white = 1;
+				else if (0 == strcmp (*items, "draft"))
+					state->cur_pi->print_as_draft = 1;
+				else if (0 == strcmp (*items, "errors_as_blank"))
+					state->cur_pi->error_display = PRINT_ERRORS_AS_BLANK;
+				else if (0 == strcmp (*items, "errors_as_dashes"))
+					state->cur_pi->error_display = PRINT_ERRORS_AS_DASHES;
+				else if (0 == strcmp (*items, "errors_as_na"))
+					state->cur_pi->error_display = PRINT_ERRORS_AS_NA;
+				else if (0 == strcmp (*items, "print_even_if_only_styles"))
+					state->cur_pi->print_even_if_only_styles = 1;
+				else if (0 == strcmp (*items, "do_not_print"))
+					state->cur_pi->do_not_print = 1;
+			g_strfreev (items_c);
 		}
 	/* STYLE "writing-mode" is being ignored since we can't store it anywhere atm */
 	
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index f0fd154..dca3b44 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4771,6 +4771,7 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
 	GtkPageOrientation orient = gtk_page_setup_get_orientation (gps);
 	gboolean landscape = !(orient == GTK_PAGE_ORIENTATION_PORTRAIT ||
 			       orient == GTK_PAGE_ORIENTATION_REVERSE_PORTRAIT);
+	GString *gstr = g_string_new ("charts drawings objects"); 
 
 	gsf_xml_out_start_element (state->xml, STYLE "page-layout");
 	gsf_xml_out_add_cstr_unchecked (state->xml, STYLE "name", name);
@@ -4802,6 +4803,47 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
 	gsf_xml_out_add_cstr_unchecked 
 		(state->xml, STYLE "print-orientation", 
 		 landscape ? "landscape" : "portrait");
+
+	if (pi->print_grid_lines)
+		g_string_append (gstr, " grid");
+	if (pi->print_titles)
+		g_string_append (gstr, " headers");
+	if (pi->comment_placement == PRINT_COMMENTS_IN_PLACE)
+		g_string_append (gstr, " annotations");
+	gsf_xml_out_add_cstr_unchecked 
+		(state->xml, STYLE "print", gstr->str);
+	
+	if (state->with_extension) {
+		g_string_truncate (gstr, 0);
+		if (pi->comment_placement == PRINT_COMMENTS_AT_END)
+			g_string_append (gstr, " annotations_at_end");
+		if (pi->print_black_and_white)
+			g_string_append (gstr, " black_n_white");
+		if (pi->print_as_draft)
+			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");
+			break;
+		case PRINT_ERRORS_AS_DASHES:
+			g_string_append (gstr, " errors_as_dashes");
+			break;
+		case PRINT_ERRORS_AS_NA:
+			g_string_append (gstr, " errors_as_na");
+			break;
+		default:
+		case PRINT_ERRORS_AS_DISPLAYED:
+			break;
+		}
+		gsf_xml_out_add_cstr_unchecked 
+			(state->xml, GNMSTYLE "style-print", gstr->str);
+	}
+
+	g_string_free (gstr, TRUE);
 	
 	gsf_xml_out_end_element (state->xml); /* </style:page-layout-properties> */
 



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