[gnumeric] Export repeating cols to ODF
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Export repeating cols to ODF
- Date: Thu, 23 Jun 2011 01:15:31 +0000 (UTC)
commit 6e81cde7a28bd1aeaf2f45e1126de730fe5e20ce
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jun 22 19:14:05 2011 -0600
Export repeating cols to ODF
2011-06-22 Andreas J. Guelzow <aguelzow pyrshep ca>
* print.c (load_repeat_range): move from here to
* print-info.c (print_load_repeat_range): renaming as we go
* print-info.h (print_load_repeat_range): new
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
* openoffice-write.c (odf_write_style_cell_properties): don't write
attributes outside of elements
(odf_write_sheet): write table:table-header-columns as appropriate
ChangeLog | 6 ++++
plugins/openoffice/ChangeLog | 9 ++++++
plugins/openoffice/openoffice-read.c | 7 +++-
plugins/openoffice/openoffice-write.c | 46 +++++++++++++++++++++++++++++---
src/print-info.c | 24 +++++++++++++++++
src/print-info.h | 3 ++
src/print.c | 25 +----------------
7 files changed, 90 insertions(+), 30 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d380026..f235d60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-06-22 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * print.c (load_repeat_range): move from here to
+ * print-info.c (print_load_repeat_range): renaming as we go
+ * print-info.h (print_load_repeat_range): new
+
2011-06-17 Morten Welinder <terra gnome org>
* src/session.c: Fix --with-gnome compilation. #652802
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index ce324cf..70097f2 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,14 @@
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
+ * openoffice-write.c (odf_write_style_cell_properties): don't write
+ attributes outside of elements
+ (odf_write_sheet): write table:table-header-columns as appropriate
+
+2011-06-22 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* openoffice-read.c (OOParseState): add fields
(oo_table_start): initialize repeating rows/cols fields
(oo_table_end): save repeating rows/cols data
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 87e0752..d64326d 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -2279,12 +2279,14 @@ oo_table_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
if (state->print.rep_rows_from >= 0) {
if (state->print.rep_rows_to < 0)
state->print.rep_rows_to = max_rows - 1;
- if (state->print.rep_cols_to < 0)
- state->print.rep_cols_to = max_cols - 1;
g_free (state->pos.sheet->print_info->repeat_top);
state->pos.sheet->print_info->repeat_top
= g_strdup (rows_name (state->print.rep_rows_from,
state->print.rep_rows_to));
+ }
+ if (state->print.rep_cols_from >= 0) {
+ if (state->print.rep_cols_to < 0)
+ state->print.rep_cols_to = max_cols - 1;
g_free (state->pos.sheet->print_info->repeat_left);
state->pos.sheet->print_info->repeat_left
= g_strdup (cols_name (state->print.rep_cols_from,
@@ -9047,6 +9049,7 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (TABLE, TABLE_COL_GROUP, OO_NS_TABLE, "table-column-group", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TABLE_COL_GROUP, TABLE_COL_GROUP, OO_NS_TABLE, "table-column-group", GSF_XML_NO_CONTENT, NULL, NULL),
+ GSF_XML_IN_NODE (TABLE_COL_GROUP, TABLE_H_COLS, OO_NS_TABLE, "table-header-columns", GSF_XML_NO_CONTENT, NULL, NULL),/* 2nd def */
GSF_XML_IN_NODE (TABLE_COL_GROUP, TABLE_COL, OO_NS_TABLE, "table-column", GSF_XML_NO_CONTENT, NULL, NULL), /* 2nd def */
GSF_XML_IN_NODE (TABLE_ROW_GROUP, TABLE_ROW_GROUP, OO_NS_TABLE, "table-row-group", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TABLE, TABLE_ROW_GROUP, OO_NS_TABLE, "table-row-group", GSF_XML_NO_CONTENT, NULL, NULL),
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 828281e..53893ba 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1186,11 +1186,10 @@ odf_write_style_cell_properties (GnmOOExport *state, GnmStyle const *style)
gsf_xml_out_add_cstr (state->xml, STYLE "text-align-source", source);
}
- gsf_xml_out_end_element (state->xml); /* </style:table-cell-properties */
-
/* Repeat Content */
odf_add_bool (state->xml, STYLE "repeat-content", rep_content);
+ gsf_xml_out_end_element (state->xml); /* </style:table-cell-properties */
}
static void
@@ -3383,9 +3382,11 @@ odf_write_sheet (GnmOOExport *state)
int max_cols = gnm_sheet_get_max_cols (sheet);
int max_rows = gnm_sheet_get_max_rows (sheet);
GnmStyle **col_styles = g_new0 (GnmStyle *, max_cols);
- GnmRange extent, style_extent, cell_extent;
+ GnmRange extent, style_extent, cell_extent, r;
GSList *sheet_merges = NULL;
GnmPageBreaks *pb = sheet->print_info->page_breaks.v;
+ gboolean repeat_top_use, repeat_left_use;
+ int repeat_top_start, repeat_top_end, repeat_left_start, repeat_left_end;
extent = sheet_get_extent (sheet, FALSE);
cell_extent = sheet_get_cells_extent (sheet);
@@ -3395,9 +3396,44 @@ odf_write_sheet (GnmOOExport *state)
/* We only want to get the common column style */
sheet_style_get_extent (sheet, &style_extent, col_styles);
- /* ODF does not allow us to mark soft page breaks between columns */
- odf_write_formatted_columns (state, sheet, col_styles, 0, max_cols);
+ repeat_top_use = print_load_repeat_range
+ (sheet->print_info->repeat_top, &r, sheet);
+ repeat_top_start = repeat_top_use ? r.start.row : 0;
+ repeat_top_end = repeat_top_use ? r.end.row : 0;
+ repeat_left_use = print_load_repeat_range
+ (sheet->print_info->repeat_left, &r, sheet);
+ repeat_left_start = repeat_left_use ? r.start.col : 0;
+ repeat_left_end = repeat_left_use ? r.end.col : 0;
+
+ /* ODF does not allow us to mark soft page breaks between columns */
+ if (repeat_left_use) {
+ if (repeat_left_start > 0) {
+ gsf_xml_out_start_element
+ (state->xml, TABLE "table-columns");
+ odf_write_formatted_columns (state, sheet, col_styles,
+ 0, repeat_left_start);
+ gsf_xml_out_end_element (state->xml);
+ }
+ gsf_xml_out_start_element
+ (state->xml, TABLE "table-header-columns");
+ odf_write_formatted_columns (state, sheet, col_styles,
+ repeat_left_start,
+ repeat_left_end + 1);
+ gsf_xml_out_end_element (state->xml);
+ if (repeat_left_end < max_cols) {
+ gsf_xml_out_start_element
+ (state->xml, TABLE "table-columns");
+ odf_write_formatted_columns (state, sheet, col_styles,
+ repeat_left_end + 1, max_cols);
+ gsf_xml_out_end_element (state->xml);
+ }
+ } else {
+ gsf_xml_out_start_element
+ (state->xml, TABLE "table-columns");
+ 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,
diff --git a/src/print-info.c b/src/print-info.c
index 04a7185..4d86f38 100644
--- a/src/print-info.c
+++ b/src/print-info.c
@@ -1568,3 +1568,27 @@ print_info_get_printtofile_uri (PrintInformation *pi)
print_info_load_defaults (pi);
return pi->printtofile_uri;
}
+
+
+gboolean
+print_load_repeat_range (char const *str, GnmRange *r, Sheet const *sheet)
+{
+ GnmParsePos pp;
+ GnmRangeRef res;
+
+ if (str == NULL || *str == '\0')
+ return FALSE;
+
+ if (str != rangeref_parse (&res, str,
+ parse_pos_init_sheet (&pp, sheet),
+ gnm_conventions_default)) {
+ Sheet *start_sheet = (Sheet *)sheet;
+ Sheet *end_sheet = (Sheet *)sheet;
+ gnm_rangeref_normalize_pp (&res, &pp,
+ &start_sheet, &end_sheet,
+ r);
+ return TRUE;
+ } else
+ return FALSE;
+}
+
diff --git a/src/print-info.h b/src/print-info.h
index f51fa59..b55db2b 100644
--- a/src/print-info.h
+++ b/src/print-info.h
@@ -206,6 +206,9 @@ int gnm_page_breaks_get_next_manual_break (GnmPageBreaks *breaks,
int gnm_page_breaks_get_next_break (GnmPageBreaks *breaks, int pos);
GnmPageBreaks * gnm_page_breaks_dup_non_auto_breaks (GnmPageBreaks const *src);
+gboolean print_load_repeat_range (char const *str, GnmRange *r, Sheet const *sheet);
+
+
/* Formats known */
extern GList *hf_formats;
diff --git a/src/print.c b/src/print.c
index 19e5cab..85e5cfd 100644
--- a/src/print.c
+++ b/src/print.c
@@ -900,27 +900,6 @@ compute_sheet_pages_across_then_down (PrintingInstance * pi,
}
-static gboolean
-load_repeat_range (char const *str, GnmRange *r, Sheet *sheet)
-{
- GnmParsePos pp;
- GnmRangeRef res;
-
- if (str == NULL || *str == '\0')
- return FALSE;
-
- if (str != rangeref_parse (&res, str,
- parse_pos_init_sheet (&pp, sheet),
- gnm_conventions_default)) {
- Sheet *start_sheet = sheet, *end_sheet = sheet;
- gnm_rangeref_normalize_pp (&res, &pp,
- &start_sheet, &end_sheet,
- r);
- return TRUE;
- } else
- return FALSE;
-}
-
/*
return TRUE in case of trouble
*/
@@ -976,11 +955,11 @@ compute_sheet_pages (GtkPrintContext *context,
page_height -= ((edge_to_below_header - top_margin)
+ (edge_to_above_footer - bottom_margin));
- repeat_top_use = load_repeat_range (pinfo->repeat_top, &r, sheet);
+ repeat_top_use = print_load_repeat_range (pinfo->repeat_top, &r, sheet);
repeat_top_start = repeat_top_use ? r.start.row : 0;
repeat_top_end = repeat_top_use ? r.end.row : 0;
- repeat_left_use = load_repeat_range (pinfo->repeat_left, &r, sheet);
+ repeat_left_use = print_load_repeat_range (pinfo->repeat_left, &r, sheet);
repeat_left_start = repeat_left_use ? r.start.col : 0;
repeat_left_end = repeat_left_use ? r.end.col : 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]