[gnumeric] some soft page break handling
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] some soft page break handling
- Date: Tue, 9 Jun 2009 04:32:01 -0400 (EDT)
commit 3f6d90df1c697ce847163a4c40cc312a4f7245a7
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Tue Jun 9 02:31:18 2009 -0600
some soft page break handling
2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print-info.c (gnm_page_breaks_get_next_break): new
* src/print-info.h (gnm_page_breaks_get_next_break): new
* src/xml-io.c (xml_read_breaks): adjust to cahnge in enum
interpretation
* src/xml-sax-read.c (xml_sax_page_break): ditto
* src/xml-sax-write.c (xml_write_breaks): also write soft breaks
2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (opendoc_content_dtd): include
text:soft-page-break
* openoffice-write.c (odf_write_formatted_empty_rows):
write text:soft-page-break also in empty territory
---
ChangeLog | 9 +++
plugins/openoffice/ChangeLog | 7 +++
plugins/openoffice/openoffice-read.c | 2 +
plugins/openoffice/openoffice-write.c | 92 +++++++++++++++++++--------------
src/print-info.c | 20 +++++++-
src/print-info.h | 11 ++--
src/xml-io.c | 2 +-
src/xml-sax-read.c | 2 +-
src/xml-sax-write.c | 2 +
9 files changed, 100 insertions(+), 47 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b0d2fa0..402aeab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/print-info.c (gnm_page_breaks_get_next_break): new
+ * src/print-info.h (gnm_page_breaks_get_next_break): new
+ * src/xml-io.c (xml_read_breaks): adjust to cahnge in enum
+ interpretation
+ * src/xml-sax-read.c (xml_sax_page_break): ditto
+ * src/xml-sax-write.c (xml_write_breaks): also write soft breaks
+
2009-06-08 Morten Welinder <terra gnome org>
* src/sheet-style.c (sample_styles): Check equality using
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index f652f7b..aa442a5 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-09 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * openoffice-read.c (opendoc_content_dtd): include
+ text:soft-page-break
+ * openoffice-write.c (odf_write_formatted_empty_rows):
+ write text:soft-page-break also in empty territory
+
2009-06-08 Andreas J. Guelzow <aguelzow pyrshep ca>
* openoffice-read.c (oo_append_page_break): soft pagebreaks are
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 844456d..b5006a1 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -3496,7 +3496,9 @@ static GsfXMLInNode const opendoc_content_dtd [] =
GSF_XML_IN_NODE (TABLE, TABLE_ROWS, OO_NS_TABLE, "table-rows", GSF_XML_NO_CONTENT, NULL, NULL),
GSF_XML_IN_NODE (TABLE, TABLE_COL, OO_NS_TABLE, "table-column", GSF_XML_NO_CONTENT, &oo_col_start, NULL),
GSF_XML_IN_NODE (TABLE, TABLE_ROW, OO_NS_TABLE, "table-row", GSF_XML_NO_CONTENT, &oo_row_start, &oo_row_end),
+ GSF_XML_IN_NODE (TABLE, SOFTPAGEBREAK, OO_NS_TEXT, "soft-page-break", GSF_XML_NO_CONTENT, NULL, NULL),
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_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 882e865..2f01124 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -1684,50 +1684,61 @@ write_row_style (GnmOOExport *state, ColRowInfo const *ci,
}
static void
-odf_write_formatted_empty_rows (GnmOOExport *state, Sheet const *sheet, int from, int to, int row_length)
+odf_write_formatted_empty_rows (GnmOOExport *state, Sheet const *sheet,
+ int from, int to, int row_length)
{
int number_rows_rep;
ColRowInfo const *last_ci;
- int i;
-
- if (from >= to)
- return;
+ int i, next_to;
+ GnmPageBreaks *pb = sheet->print_info->page_breaks.v;
- gsf_xml_out_start_element (state->xml, TABLE "table-row");
- number_rows_rep = 1;
- last_ci = sheet_row_get (sheet, from);
- write_row_style (state, last_ci, sheet);
+ for (i = from; i < to; ) {
+ if (gnm_page_breaks_get_break (pb, i) != GNM_PAGE_BREAK_NONE)
+ gsf_xml_out_simple_element (state->xml,
+ TEXT "soft-page-break",
+ NULL);
+ next_to = gnm_page_breaks_get_next_break (pb, i);
+ if (next_to < from || next_to > to)
+ next_to = to;
- for (i = from + 1; i < to; i++) {
- ColRowInfo const *this_ci = sheet_row_get (sheet, i);
+ gsf_xml_out_start_element (state->xml, TABLE "table-row");
+ number_rows_rep = 1;
+ last_ci = sheet_row_get (sheet, from);
+ write_row_style (state, last_ci, sheet);
- if (colrow_equal (last_ci, this_ci))
- number_rows_rep++;
- else {
- if (number_rows_rep > 1)
- gsf_xml_out_add_int (state->xml, TABLE "number-rows-repeated",
- number_rows_rep);
- gsf_xml_out_start_element (state->xml, TABLE "table-cell");
- gsf_xml_out_add_int (state->xml, TABLE "number-columns-repeated",
- row_length);
- gsf_xml_out_end_element (state->xml); /* table-cell */
- gsf_xml_out_end_element (state->xml); /* table-row */
-
- gsf_xml_out_start_element (state->xml, TABLE "table-row");
- number_rows_rep = 1;
- last_ci = this_ci;
- write_row_style (state, last_ci, sheet);
+ i++;
+
+ for (; i < next_to; i++) {
+ ColRowInfo const *this_ci = sheet_row_get (sheet, i);
+
+ if (colrow_equal (last_ci, this_ci))
+ number_rows_rep++;
+ else {
+ if (number_rows_rep > 1)
+ gsf_xml_out_add_int (state->xml, TABLE "number-rows-repeated",
+ number_rows_rep);
+ gsf_xml_out_start_element (state->xml, TABLE "table-cell");
+ gsf_xml_out_add_int (state->xml, TABLE "number-columns-repeated",
+ row_length);
+ gsf_xml_out_end_element (state->xml); /* table-cell */
+ gsf_xml_out_end_element (state->xml); /* table-row */
+
+ gsf_xml_out_start_element (state->xml, TABLE "table-row");
+ number_rows_rep = 1;
+ last_ci = this_ci;
+ write_row_style (state, last_ci, sheet);
+ }
}
- }
-
- if (number_rows_rep > 1)
- gsf_xml_out_add_int (state->xml, TABLE "number-rows-repeated",
- number_rows_rep);
- gsf_xml_out_start_element (state->xml, TABLE "table-cell");
- gsf_xml_out_add_int (state->xml, TABLE "number-columns-repeated",
- row_length);
- gsf_xml_out_end_element (state->xml); /* table-cell */
- gsf_xml_out_end_element (state->xml); /* table-row */
+
+ if (number_rows_rep > 1)
+ gsf_xml_out_add_int (state->xml, TABLE "number-rows-repeated",
+ number_rows_rep);
+ gsf_xml_out_start_element (state->xml, TABLE "table-cell");
+ gsf_xml_out_add_int (state->xml, TABLE "number-columns-repeated",
+ row_length);
+ gsf_xml_out_end_element (state->xml); /* table-cell */
+ gsf_xml_out_end_element (state->xml); /* table-row */
+ }
}
static void
@@ -1756,9 +1767,11 @@ odf_write_sheet (GnmOOExport *state, Sheet const *sheet)
break;
}
+ /* ODF does not allow us to mark sof page breaks between columns */
odf_write_formatted_columns (state, sheet, col_styles, 0, max_cols);
- odf_write_formatted_empty_rows (state, sheet, 0, extent.start.row, max_cols);
+ odf_write_formatted_empty_rows (state, sheet,
+ 0, extent.start.row, max_cols);
for (row = extent.start.row; row <= extent.end.row; row++) {
ColRowInfo const *ci = sheet_row_get (sheet, row);
@@ -1824,7 +1837,8 @@ odf_write_sheet (GnmOOExport *state, Sheet const *sheet)
go_slist_free_custom (sheet_merges, g_free);
g_free (col_styles);
- odf_write_formatted_empty_rows (state, sheet, extent.end.row + 1, max_rows, max_cols);
+ odf_write_formatted_empty_rows (state, sheet,
+ extent.end.row + 1, max_rows, max_cols);
}
diff --git a/src/print-info.c b/src/print-info.c
index 5ac0ea8..a35e5bc 100644
--- a/src/print-info.c
+++ b/src/print-info.c
@@ -1346,7 +1346,25 @@ gnm_page_breaks_get_next_manual_break (GnmPageBreaks *breaks,
GnmPageBreak const *pbreak;
pbreak = &g_array_index (breaks->details, GnmPageBreak, i);
if (pbreak->pos > pos
- && pbreak->type == GNM_PAGE_BREAK_MANUAL)
+ && pbreak->type != GNM_PAGE_BREAK_AUTO)
+ return pbreak->pos;
+ }
+ return -1;
+}
+
+int
+gnm_page_breaks_get_next_break (GnmPageBreaks *breaks,
+ int pos)
+{
+ guint i;
+
+ if (breaks == NULL)
+ return -1;
+
+ for (i = 0; i < breaks->details->len; i++) {
+ GnmPageBreak const *pbreak;
+ pbreak = &g_array_index (breaks->details, GnmPageBreak, i);
+ if (pbreak->pos > pos)
return pbreak->pos;
}
return -1;
diff --git a/src/print-info.h b/src/print-info.h
index 19c1321..7544b5d 100644
--- a/src/print-info.h
+++ b/src/print-info.h
@@ -19,10 +19,10 @@ typedef struct {
} PrintHF;
typedef enum {
- GNM_PAGE_BREAK_NONE,
- GNM_PAGE_BREAK_MANUAL,
- GNM_PAGE_BREAK_AUTO,
- GNM_PAGE_BREAK_DATA_SLICE
+ GNM_PAGE_BREAK_NONE, /* Not actually a page break */
+ GNM_PAGE_BREAK_MANUAL, /* hard page break */
+ GNM_PAGE_BREAK_AUTO, /* soft (automatic) pagebreak */
+ GNM_PAGE_BREAK_DATA_SLICE /* place holder ? */
} GnmPageBreakType;
GnmPageBreakType gnm_page_break_type_from_str (char const *str);
@@ -33,7 +33,7 @@ typedef struct {
typedef struct {
gboolean is_vert;
- GArray *details; /* ordered array of GnmPageBreaks */
+ GArray *details; /* ordered array of GnmPageBreak */
} GnmPageBreaks;
struct _PrintInformation {
@@ -183,6 +183,7 @@ gboolean gnm_page_breaks_set_break (GnmPageBreaks *breaks,
GnmPageBreakType type);
GnmPageBreakType gnm_page_breaks_get_break (GnmPageBreaks *breaks, int pos);
int gnm_page_breaks_get_next_manual_break (GnmPageBreaks *breaks, int pos);
+int gnm_page_breaks_get_next_break (GnmPageBreaks *breaks, int pos);
GnmPageBreaks * gnm_page_breaks_dup_non_auto_breaks (GnmPageBreaks const *src);
diff --git a/src/xml-io.c b/src/xml-io.c
index e307555..83e52d1 100644
--- a/src/xml-io.c
+++ b/src/xml-io.c
@@ -587,7 +587,7 @@ xml_read_breaks (XmlParseContext *ctxt, xmlNodePtr tree, gboolean is_vert)
if (NULL != (type_str = xml_node_get_cstr (tree, "type")))
type = gnm_page_break_type_from_str (CXML2C (type_str));
else
- type = GNM_PAGE_BREAK_AUTO;
+ type = GNM_PAGE_BREAK_NONE;
/* drops invalid positions */
gnm_page_breaks_append_break (page_breaks, pos, type);
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index e76a660..0dc374b 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -844,7 +844,7 @@ static void
xml_sax_page_break (GsfXMLIn *xin, xmlChar const **attrs)
{
XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
- GnmPageBreakType type = GNM_PAGE_BREAK_AUTO;
+ GnmPageBreakType type = GNM_PAGE_BREAK_NONE;
int pos = -1;
if (NULL == state->page_breaks)
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 8e15f1c..a70c732 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -273,6 +273,8 @@ xml_write_breaks (GnmOutputXML *state, GnmPageBreaks *breaks)
gsf_xml_out_add_cstr_unchecked (state->output, "type", "manual");
else if (binfo->type == GNM_PAGE_BREAK_DATA_SLICE)
gsf_xml_out_add_cstr_unchecked (state->output, "type", "data-slice");
+ else if (binfo->type == GNM_PAGE_BREAK_AUTO)
+ gsf_xml_out_add_cstr_unchecked (state->output, "type", "auto");
gsf_xml_out_end_element (state->output); /* </break> */
}
gsf_xml_out_end_element (state->output);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]