[gnumeric] Be more careful on import/export of comment placement to ODF



commit 4986e1092a00fe7363fbc07478bcad9e8ba9b72f
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Jul 26 17:48:10 2011 -0600

    Be more careful on import/export of comment placement to ODF
    
    2011-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-write.c (odf_write_page_layout): in ODF combine
    	PRINT_COMMENTS_IN_PLACE and PRINT_COMMENTS_AT_END
    	* openoffice-read.c (odf_page_layout_properties): do not count on the
    	order of the attributes.

 plugins/openoffice/ChangeLog          |    7 +++++++
 plugins/openoffice/openoffice-read.c  |   13 +++++++++++--
 plugins/openoffice/openoffice-write.c |    2 +-
 3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 02f8266..5a01186 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,12 @@
 2011-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-write.c (odf_write_page_layout): in ODF combine
+	PRINT_COMMENTS_IN_PLACE and PRINT_COMMENTS_AT_END
+	* openoffice-read.c (odf_page_layout_properties): do not count on the
+	order of the attributes. 
+
+2011-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c: use G_GNUC_UNUSED
 
 2011-07-26  Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index bcd54a0..58d60c5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4499,6 +4499,8 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 	GtkPageSetup *gps;
 	gint tmp;
 	gint orient = GTK_PAGE_ORIENTATION_PORTRAIT;
+	gboolean gnm_style_print = FALSE;
+	gboolean annotations_at_end = FALSE;
 
 	if (state->print.cur_pi == NULL)
 		return;
@@ -4541,19 +4543,21 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 				else if (0 == strcmp (*items, "headers"))
 					state->print.cur_pi->print_titles = 1;
 				else if (0 == strcmp (*items, "annotations"))
-					state->print.cur_pi->comment_placement = PRINT_COMMENTS_IN_PLACE;
+					/* ODF does not distinguish AT_END and IN_PLACE */
+					state->print.cur_pi->comment_placement = PRINT_COMMENTS_AT_END;
 			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;
+			gnm_style_print = TRUE;
 			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->error_display = PRINT_ERRORS_AS_DISPLAYED;
 			for (;items != NULL && *items; items++)
 				if (0 == strcmp (*items, "annotations_at_end"))
-					state->print.cur_pi->comment_placement = PRINT_COMMENTS_AT_END;
+					annotations_at_end = TRUE;
 				else if (0 == strcmp (*items, "black_n_white"))
 					state->print.cur_pi->print_black_and_white = 1;
 				else if (0 == strcmp (*items, "draft"))
@@ -4568,6 +4572,11 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
 					state->print.cur_pi->print_even_if_only_styles = 1;
 			g_strfreev (items_c);
 		}
+
+	if (gnm_style_print && state->print.cur_pi->comment_placement != PRINT_COMMENTS_NONE)
+		state->print.cur_pi->comment_placement = annotations_at_end ? PRINT_COMMENTS_AT_END :
+			PRINT_COMMENTS_IN_PLACE;
+
 	/* STYLE "writing-mode" is being ignored since we can't store it anywhere atm */
 	
 	if (h_set && w_set) {
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 307bcb0..5dcf49f 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4985,7 +4985,7 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
 		g_string_append (gstr, " grid");
 	if (pi->print_titles)
 		g_string_append (gstr, " headers");
-	if (pi->comment_placement == PRINT_COMMENTS_IN_PLACE)
+	if (pi->comment_placement != PRINT_COMMENTS_NONE)
 		g_string_append (gstr, " annotations");
 	gsf_xml_out_add_cstr_unchecked 
 		(state->xml, STYLE "print", gstr->str);



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