[gnumeric] Export repeating rows to ODF



commit 000a188be89e90109a3cd072aa7589fdff8c2fbf
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Wed Jun 22 20:35:24 2011 -0600

    Export repeating rows to ODF
    
    2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* openoffice-read.c (opendoc_content_dtd): add more items
    	* openoffice-write.c (odf_write_sheet): write table:table-header-rows

 plugins/openoffice/ChangeLog          |    5 ++
 plugins/openoffice/openoffice-read.c  |    1 +
 plugins/openoffice/openoffice-write.c |   68 +++++++++++++++++++++++++++++----
 3 files changed, 66 insertions(+), 8 deletions(-)
---
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 70097f2..ecdc609 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,10 @@
 2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* openoffice-read.c (opendoc_content_dtd): add more items
+	* openoffice-write.c (odf_write_sheet): write table:table-header-rows
+
+2011-06-22  Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* openoffice-read.c (oo_table_end): we may have repeating rows w/o
 	repeating columns and vice versa
 	(opendoc_content_dtd): add more items
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index d64326d..9c83f85 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -8997,6 +8997,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
 	      GSF_XML_IN_NODE (TABLE_ROWS, TABLE_ROW, OO_NS_TABLE, "table-row", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd def */
 	      GSF_XML_IN_NODE (TABLE_H_ROWS, TABLE_ROW, OO_NS_TABLE, "table-row", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd def */
 	      GSF_XML_IN_NODE (TABLE_ROWS, SOFTPAGEBREAK, OO_NS_TEXT, "soft-page-break", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd def */
+	      GSF_XML_IN_NODE (TABLE_H_ROWS, SOFTPAGEBREAK, OO_NS_TEXT, "soft-page-break", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd def */
 
 		GSF_XML_IN_NODE (TABLE_ROW, TABLE_CELL, OO_NS_TABLE, "table-cell", GSF_XML_NO_CONTENT, &oo_cell_start, &oo_cell_end),
 		  GSF_XML_IN_NODE (TABLE_CELL, CELL_TEXT, OO_NS_TEXT, "p", GSF_XML_CONTENT, NULL, &oo_cell_content_end),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 53893ba..f97c8b3 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -3434,14 +3434,66 @@ odf_write_sheet (GnmOOExport *state)
 		odf_write_formatted_columns (state, sheet, col_styles, 0, max_cols);
 		gsf_xml_out_end_element (state->xml); 
 	}
-	odf_write_styled_empty_rows (state, sheet, 0, extent.start.row,
-				     max_cols, pb, col_styles);
-	odf_write_content_rows (state, sheet,
-				extent.start.row, extent.end.row + 1,
-				extent.start.col, extent.end.col + 1,
-				max_cols, &sheet_merges, pb, col_styles);
-	odf_write_styled_empty_rows (state, sheet, extent.end.row + 1, max_rows,
-				     max_cols, pb, col_styles);
+
+	if (repeat_top_use) {
+		gint esr, eer;
+		if (repeat_top_start > 0) {
+			esr = MIN (extent.start.row, repeat_top_start);
+			eer = MIN (extent.end.row, repeat_top_start - 1);
+			gsf_xml_out_start_element 
+				(state->xml, TABLE "table-rows");
+			odf_write_styled_empty_rows (state, sheet, 0, esr,
+						     max_cols, pb, col_styles);
+			odf_write_content_rows (state, sheet,
+						esr, eer + 1,
+						extent.start.col, extent.end.col + 1,
+						max_cols, &sheet_merges, pb, col_styles);
+			odf_write_styled_empty_rows (state, sheet, eer + 1, repeat_top_start,
+						     max_cols, pb, col_styles);
+			gsf_xml_out_end_element (state->xml); 
+		}
+		esr = MAX (extent.start.row, repeat_top_start);
+		eer = MIN (extent.end.row, repeat_top_end);
+		gsf_xml_out_start_element 
+			(state->xml, TABLE "table-header-rows");
+		odf_write_styled_empty_rows (state, sheet, repeat_top_start, esr,
+					     max_cols, pb, col_styles);
+		odf_write_content_rows (state, sheet,
+					esr, eer + 1,
+					extent.start.col, extent.end.col + 1,
+					max_cols, &sheet_merges, pb, col_styles);
+		odf_write_styled_empty_rows (state, sheet, eer + 1, repeat_top_end + 1,
+					     max_cols, pb, col_styles);
+		gsf_xml_out_end_element (state->xml); 
+		if (repeat_top_end < max_rows) {
+			esr = MAX (extent.start.row, repeat_top_end + 1);
+			eer = MAX (extent.end.row, repeat_top_end + 1);
+			gsf_xml_out_start_element 
+				(state->xml, TABLE "table-rows");
+			odf_write_styled_empty_rows (state, sheet, repeat_top_end + 1, 
+						     esr,
+						     max_cols, pb, col_styles);
+			odf_write_content_rows (state, sheet,
+						esr, eer + 1,
+						extent.start.col, extent.end.col + 1,
+						max_cols, &sheet_merges, pb, col_styles);
+			odf_write_styled_empty_rows (state, sheet, eer + 1, max_rows,
+						     max_cols, pb, col_styles);
+			gsf_xml_out_end_element (state->xml); 
+		}
+	} else {
+		gsf_xml_out_start_element 
+			(state->xml, TABLE "table-rows");
+		odf_write_styled_empty_rows (state, sheet, 0, extent.start.row,
+					     max_cols, pb, col_styles);
+		odf_write_content_rows (state, sheet,
+					extent.start.row, extent.end.row + 1,
+					extent.start.col, extent.end.col + 1,
+					max_cols, &sheet_merges, pb, col_styles);
+		odf_write_styled_empty_rows (state, sheet, extent.end.row + 1, max_rows,
+					     max_cols, pb, col_styles);
+		gsf_xml_out_end_element (state->xml); 
+	}
 
 	go_slist_free_custom (sheet_merges, g_free);
 	g_free (col_styles);



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