[gnumeric] use gsf_xml_out_add_enum for print comment placement and error display in .gnumeric file export and
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] use gsf_xml_out_add_enum for print comment placement and error display in .gnumeric file export and
- Date: Mon, 21 Nov 2011 04:33:27 +0000 (UTC)
commit 735adff788b9a2b1341bb8e4af5fc1c26a73dc20
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Nov 20 21:31:40 2011 -0700
use gsf_xml_out_add_enum for print comment placement and error display in .gnumeric file export and import
2011-11-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print-info.h (gnm_print_comment_placement_get_type): new
(gnm_print_errors_get_type): new
(GnmPrintCommentPlacementType): new
(GnmPrintErrorsType): new
(_PrintInformation): use the above
* src/print-cell.c (print_cell_gtk): rename print-error and comment-
placement constants
* src/print-info.c (gnm_print_comment_placement_get_type): new
(gnm_print_errors_get_type): new
(print_info_new): rename print-error and comment-placement constants
* src/xml-sax-read.c (xml_sax_print_comments_start): new
(xml_sax_print_comments): rename to xml_sax_print_comments_end, change
all callers; rename comment-placement constants
(xml_sax_print_errors_start): new
(xml_sax_print_errors): rename to xml_sax_print_errors_end, change
all callers; rename print-error constants
(xml_cellregion_read): remove unused variable
* src/xml-sax-write.c (xml_write_print_info): use gsf_xml_out_add_enum
2011-11-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* ms-excel-read.c (excel_read_SETUP): rename
PRINT_ERROR and PRINT_COMMENTS constants
* ms-excel-write.c (excel_write_SETUP): ditto
2011-11-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-printer-setup.c (do_setup_error_display): rename
PRINT_ERROR constants
(do_setup_comment_display): rename PRINT_COMMENTS constants
ChangeLog | 21 +++++++++
plugins/excel/ChangeLog | 6 +++
plugins/excel/ms-excel-read.c | 15 ++++---
plugins/excel/ms-excel-write.c | 14 +++---
plugins/openoffice/openoffice-read.c | 18 ++++----
plugins/openoffice/openoffice-write.c | 12 +++---
src/dialogs/ChangeLog | 6 +++
src/dialogs/dialog-printer-setup.c | 18 ++++----
src/print-cell.c | 10 +++--
src/print-info.c | 46 ++++++++++++++++++++-
src/print-info.h | 33 ++++++++++-----
src/xml-sax-read.c | 73 ++++++++++++++++++++++++++-------
src/xml-sax-write.c | 46 +++++----------------
13 files changed, 213 insertions(+), 105 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4563771..114cbff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2011-11-20 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/print-info.h (gnm_print_comment_placement_get_type): new
+ (gnm_print_errors_get_type): new
+ (GnmPrintCommentPlacementType): new
+ (GnmPrintErrorsType): new
+ (_PrintInformation): use the above
+ * src/print-cell.c (print_cell_gtk): rename print-error and comment-
+ placement constants
+ * src/print-info.c (gnm_print_comment_placement_get_type): new
+ (gnm_print_errors_get_type): new
+ (print_info_new): rename print-error and comment-placement constants
+ * src/xml-sax-read.c (xml_sax_print_comments_start): new
+ (xml_sax_print_comments): rename to xml_sax_print_comments_end, change
+ all callers; rename comment-placement constants
+ (xml_sax_print_errors_start): new
+ (xml_sax_print_errors): rename to xml_sax_print_errors_end, change
+ all callers; rename print-error constants
+ (xml_cellregion_read): remove unused variable
+ * src/xml-sax-write.c (xml_write_print_info): use gsf_xml_out_add_enum
+
2011-11-20 Jean Brefort <jean brefort normalesup org>
* src/gui-clipboard.c (object_write), (x_clipboard_get_cb): add support for
diff --git a/plugins/excel/ChangeLog b/plugins/excel/ChangeLog
index 6524ad8..0482c90 100644
--- a/plugins/excel/ChangeLog
+++ b/plugins/excel/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-20 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * ms-excel-read.c (excel_read_SETUP): rename
+ PRINT_ERROR and PRINT_COMMENTS constants
+ * ms-excel-write.c (excel_write_SETUP): ditto
+
2011-10-29 Jean Brefort <jean brefort normalesup org>
* xlsx-read-drawing.c (xlsx_blip_start): don't set an invalid image type.
diff --git a/plugins/excel/ms-excel-read.c b/plugins/excel/ms-excel-read.c
index dd2a01b..fd170bc 100644
--- a/plugins/excel/ms-excel-read.c
+++ b/plugins/excel/ms-excel-read.c
@@ -4767,7 +4767,7 @@ excel_read_SETUP (BiffQuery *q, ExcelReadSheet *esheet)
pi->print_as_draft = (flags & 0x10) != 0;
pi->comment_placement = (flags & 0x20)
- ? PRINT_COMMENTS_IN_PLACE : PRINT_COMMENTS_NONE;
+ ? GNM_PRINT_COMMENTS_IN_PLACE : GNM_PRINT_COMMENTS_NONE;
print_info_set_margin_header (pi,
GO_IN_TO_PT (gsf_le_get_double (q->data + 16)));
print_info_set_margin_footer (pi,
@@ -4780,13 +4780,14 @@ excel_read_SETUP (BiffQuery *q, ExcelReadSheet *esheet)
}
if (esheet_ver (esheet) >= MS_BIFF_V8) {
- if ((flags & 0x200) && pi->comment_placement == PRINT_COMMENTS_IN_PLACE)
- pi->comment_placement = PRINT_COMMENTS_AT_END;
+ if ((flags & 0x200) &&
+ pi->comment_placement == GNM_PRINT_COMMENTS_IN_PLACE)
+ pi->comment_placement = GNM_PRINT_COMMENTS_AT_END;
switch ((flags >> 10) & 3) {
- case 0 : pi->error_display = PRINT_ERRORS_AS_DISPLAYED; break;
- case 1 : pi->error_display = PRINT_ERRORS_AS_BLANK; break;
- case 2 : pi->error_display = PRINT_ERRORS_AS_DASHES; break;
- case 3 : pi->error_display = PRINT_ERRORS_AS_NA; break;
+ case 0 : pi->error_display = GNM_PRINT_ERRORS_AS_DISPLAYED; break;
+ case 1 : pi->error_display = GNM_PRINT_ERRORS_AS_BLANK; break;
+ case 2 : pi->error_display = GNM_PRINT_ERRORS_AS_DASHES; break;
+ case 3 : pi->error_display = GNM_PRINT_ERRORS_AS_NA; break;
}
}
}
diff --git a/plugins/excel/ms-excel-write.c b/plugins/excel/ms-excel-write.c
index 0062835..a00e7fc 100644
--- a/plugins/excel/ms-excel-write.c
+++ b/plugins/excel/ms-excel-write.c
@@ -495,18 +495,18 @@ excel_write_SETUP (BiffPut *bp, ExcelWriteSheet *esheet)
if (pi->print_as_draft)
flags |= 0x10;
switch (pi->comment_placement) {
- case PRINT_COMMENTS_NONE: break;
+ case GNM_PRINT_COMMENTS_NONE: break;
default:
- case PRINT_COMMENTS_IN_PLACE: flags |= 0x020; break;
- case PRINT_COMMENTS_AT_END: flags |= 0x220; break;
+ case GNM_PRINT_COMMENTS_IN_PLACE: flags |= 0x020; break;
+ case GNM_PRINT_COMMENTS_AT_END: flags |= 0x220; break;
}
switch (pi->error_display) {
default :
- case PRINT_ERRORS_AS_DISPLAYED: break;
- case PRINT_ERRORS_AS_BLANK: flags |= 0x400; break;
- case PRINT_ERRORS_AS_DASHES: flags |= 0x800; break;
- case PRINT_ERRORS_AS_NA: flags |= 0xC00; break;
+ case GNM_PRINT_ERRORS_AS_DISPLAYED: break;
+ case GNM_PRINT_ERRORS_AS_BLANK: flags |= 0x400; break;
+ case GNM_PRINT_ERRORS_AS_DASHES: flags |= 0x800; break;
+ case GNM_PRINT_ERRORS_AS_NA: flags |= 0xC00; break;
}
if (pi->scaling.percentage.x < USHRT_MAX)
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 4ecbf55..91ebebc 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -4842,7 +4842,7 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
gchar **items_c = items;
state->print.cur_pi->print_grid_lines = 0;
state->print.cur_pi->print_titles = 0;
- state->print.cur_pi->comment_placement = PRINT_COMMENTS_NONE;
+ state->print.cur_pi->comment_placement = GNM_PRINT_COMMENTS_NONE;
for (;items != NULL && *items; items++)
if (0 == strcmp (*items, "grid"))
state->print.cur_pi->print_grid_lines = 1;
@@ -4850,7 +4850,7 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
state->print.cur_pi->print_titles = 1;
else if (0 == strcmp (*items, "annotations"))
/* ODF does not distinguish AT_END and IN_PLACE */
- state->print.cur_pi->comment_placement = PRINT_COMMENTS_AT_END;
+ state->print.cur_pi->comment_placement = GNM_PRINT_COMMENTS_AT_END;
g_strfreev (items_c);
} else if (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]),
OO_GNUM_NS_EXT, "style-print")) {
@@ -4860,7 +4860,7 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
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;
+ state->print.cur_pi->error_display = GNM_PRINT_ERRORS_AS_DISPLAYED;
for (;items != NULL && *items; items++)
if (0 == strcmp (*items, "annotations_at_end"))
annotations_at_end = TRUE;
@@ -4869,19 +4869,19 @@ odf_page_layout_properties (GsfXMLIn *xin, xmlChar const **attrs)
else if (0 == strcmp (*items, "draft"))
state->print.cur_pi->print_as_draft = 1;
else if (0 == strcmp (*items, "errors_as_blank"))
- state->print.cur_pi->error_display = PRINT_ERRORS_AS_BLANK;
+ state->print.cur_pi->error_display = GNM_PRINT_ERRORS_AS_BLANK;
else if (0 == strcmp (*items, "errors_as_dashes"))
- state->print.cur_pi->error_display = PRINT_ERRORS_AS_DASHES;
+ state->print.cur_pi->error_display = GNM_PRINT_ERRORS_AS_DASHES;
else if (0 == strcmp (*items, "errors_as_na"))
- state->print.cur_pi->error_display = PRINT_ERRORS_AS_NA;
+ state->print.cur_pi->error_display = GNM_PRINT_ERRORS_AS_NA;
else if (0 == strcmp (*items, "print_even_if_only_styles"))
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;
+ if (gnm_style_print && state->print.cur_pi->comment_placement != GNM_PRINT_COMMENTS_NONE)
+ state->print.cur_pi->comment_placement = annotations_at_end ? GNM_PRINT_COMMENTS_AT_END :
+ GNM_PRINT_COMMENTS_IN_PLACE;
/* 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 76d8ed1..6894fd8 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -5056,14 +5056,14 @@ 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_NONE)
+ if (pi->comment_placement != GNM_PRINT_COMMENTS_NONE)
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)
+ if (pi->comment_placement == GNM_PRINT_COMMENTS_AT_END)
g_string_append (gstr, " annotations_at_end");
if (pi->print_black_and_white)
g_string_append (gstr, " black_n_white");
@@ -5072,17 +5072,17 @@ odf_write_page_layout (GnmOOExport *state, PrintInformation *pi,
if (pi->print_even_if_only_styles)
g_string_append (gstr, " print_even_if_only_styles");
switch (pi->error_display) {
- case PRINT_ERRORS_AS_BLANK:
+ case GNM_PRINT_ERRORS_AS_BLANK:
g_string_append (gstr, " errors_as_blank");
break;
- case PRINT_ERRORS_AS_DASHES:
+ case GNM_PRINT_ERRORS_AS_DASHES:
g_string_append (gstr, " errors_as_dashes");
break;
- case PRINT_ERRORS_AS_NA:
+ case GNM_PRINT_ERRORS_AS_NA:
g_string_append (gstr, " errors_as_na");
break;
default:
- case PRINT_ERRORS_AS_DISPLAYED:
+ case GNM_PRINT_ERRORS_AS_DISPLAYED:
break;
}
gsf_xml_out_add_cstr_unchecked
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 8986903..47dabe0 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,9 @@
+2011-11-20 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * dialog-printer-setup.c (do_setup_error_display): rename
+ PRINT_ERROR constants
+ (do_setup_comment_display): rename PRINT_COMMENTS constants
+
2011-11-20 Jean Brefort <jean brefort normalesup org>
* autoformat.ui: replaced GtkTable with GtkGrid.
diff --git a/src/dialogs/dialog-printer-setup.c b/src/dialogs/dialog-printer-setup.c
index 4d1c802..296688f 100644
--- a/src/dialogs/dialog-printer-setup.c
+++ b/src/dialogs/dialog-printer-setup.c
@@ -2187,15 +2187,15 @@ do_setup_error_display (PrinterSetupState *state)
char const *label;
guint type;
} display_types[] = {
- {N_("Print as displayed"), PRINT_ERRORS_AS_DISPLAYED},
- {N_("Print as spaces"), PRINT_ERRORS_AS_BLANK},
- {N_("Print as dashes"), PRINT_ERRORS_AS_DASHES},
- {N_("Print as #N/A"), PRINT_ERRORS_AS_NA}
+ {N_("Print as displayed"), GNM_PRINT_ERRORS_AS_DISPLAYED},
+ {N_("Print as spaces"), GNM_PRINT_ERRORS_AS_BLANK},
+ {N_("Print as dashes"), GNM_PRINT_ERRORS_AS_DASHES},
+ {N_("Print as #N/A"), GNM_PRINT_ERRORS_AS_NA}
};
gint i;
GtkCellRenderer *cell;
- gint item = PRINT_ERRORS_AS_DISPLAYED;
+ gint item = GNM_PRINT_ERRORS_AS_DISPLAYED;
GtkTreeIter iter;
for (i = 0; i < (int)G_N_ELEMENTS (display_types); i++) {
@@ -2223,14 +2223,14 @@ do_setup_comment_display (PrinterSetupState *state)
char const *label;
guint type;
} display_types[] = {
- {N_("Do not print"), PRINT_COMMENTS_NONE},
- {N_("Print in place"), PRINT_COMMENTS_IN_PLACE},
- {N_("Print at end"), PRINT_COMMENTS_AT_END}
+ {N_("Do not print"), GNM_PRINT_COMMENTS_NONE},
+ {N_("Print in place"), GNM_PRINT_COMMENTS_IN_PLACE},
+ {N_("Print at end"), GNM_PRINT_COMMENTS_AT_END}
};
gint i;
GtkCellRenderer *cell;
- gint item = PRINT_COMMENTS_NONE;
+ gint item = GNM_PRINT_COMMENTS_NONE;
GtkTreeIter iter;
for (i = 0; i < (int)G_N_ELEMENTS (display_types); i++) {
diff --git a/src/print-cell.c b/src/print-cell.c
index 578c798..7a75853 100644
--- a/src/print-cell.c
+++ b/src/print-cell.c
@@ -75,7 +75,8 @@ print_cell_gtk (GnmCell const *cell,
cell_shows_error = (gnm_cell_is_error (cell) != NULL)
&& !(gnm_cell_has_expr (cell) && sheet->display_formulas);
- if (cell_shows_error && pinfo->error_display == PRINT_ERRORS_AS_BLANK)
+ if (cell_shows_error && pinfo->error_display ==
+ GNM_PRINT_ERRORS_AS_BLANK)
return;
/* Get the sizes exclusive of margins and grids */
@@ -86,11 +87,12 @@ print_cell_gtk (GnmCell const *cell,
rv = gnm_cell_fetch_rendered_value (cell, TRUE);
/* Create a rendered value for printing */
- if (cell_shows_error && (pinfo->error_display == PRINT_ERRORS_AS_NA
- || pinfo->error_display == PRINT_ERRORS_AS_DASHES)) {
+ if (cell_shows_error &&
+ (pinfo->error_display == GNM_PRINT_ERRORS_AS_NA
+ || pinfo->error_display == GNM_PRINT_ERRORS_AS_DASHES)) {
GnmCell *t_cell = (GnmCell *)cell;
GnmValue *old = t_cell->value;
- if (pinfo->error_display == PRINT_ERRORS_AS_NA)
+ if (pinfo->error_display == GNM_PRINT_ERRORS_AS_NA)
t_cell->value = value_new_error_NA (NULL);
else
t_cell->value = value_new_error
diff --git a/src/print-info.c b/src/print-info.c
index 2aa2a63..5a5af48 100644
--- a/src/print-info.c
+++ b/src/print-info.c
@@ -42,6 +42,48 @@
GList *hf_formats = NULL;
static gint hf_formats_base_num = 0;
+GType
+gnm_print_comment_placement_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ { GNM_PRINT_COMMENTS_NONE, "GNM_PRINT_COMMENTS_NONE", "none"},
+ { GNM_PRINT_COMMENTS_IN_PLACE, "GNM_PRINT_COMMENTS_IN_PLACE",
+ "in-place"},
+ { GNM_PRINT_COMMENTS_AT_END, "GNM_PRINT_COMMENTS_AT_END",
+ "at-end"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmPrintCommentPlacementType",
+ values);
+ }
+ return etype;
+}
+
+GType
+gnm_print_errors_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ { GNM_PRINT_ERRORS_AS_DISPLAYED,
+ "GNM_PRINT_ERRORS_AS_DISPLAYED", "as-displayed"},
+ { GNM_PRINT_ERRORS_AS_BLANK,
+ "GNM_PRINT_ERRORS_AS_BLANK", "as-blank"},
+ { GNM_PRINT_ERRORS_AS_DASHES,
+ "GNM_PRINT_ERRORS_AS_DASHES", "as-dashes"},
+ { GNM_PRINT_ERRORS_AS_NA,
+ "GNM_PRINT_ERRORS_AS_NA", "as-na"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmPrintErrorsType",
+ values);
+ }
+ return etype;
+}
+
+
PrintHF *
print_hf_new (char const *left_side_format,
char const *middle_format,
@@ -295,8 +337,8 @@ print_info_new (gboolean load_defaults)
PrintInformation *res = g_new0 (PrintInformation, 1);
res->print_as_draft = FALSE;
- res->comment_placement = PRINT_COMMENTS_IN_PLACE;
- res->error_display = PRINT_ERRORS_AS_DISPLAYED;
+ res->comment_placement = GNM_PRINT_COMMENTS_IN_PLACE;
+ res->error_display = GNM_PRINT_ERRORS_AS_DISPLAYED;
res->start_page = -1;
res->n_copies = 0;
diff --git a/src/print-info.h b/src/print-info.h
index af8c59f..05a81c1 100644
--- a/src/print-info.h
+++ b/src/print-info.h
@@ -8,6 +8,13 @@
G_BEGIN_DECLS
+GType gnm_print_comment_placement_get_type (void);
+#define GNM_PRINT_COMMENT_PLACEMENT_TYPE (gnm_print_comment_placement_get_type ())
+
+GType gnm_print_errors_get_type (void);
+#define GNM_PRINT_ERRORS_TYPE (gnm_print_errors_get_type ())
+
+
typedef struct {
GtkUnit top, bottom, left, right, header, footer;
} DesiredDisplay;
@@ -20,6 +27,19 @@ typedef struct {
} PrintHF;
typedef enum {
+ GNM_PRINT_COMMENTS_NONE,
+ GNM_PRINT_COMMENTS_IN_PLACE,
+ GNM_PRINT_COMMENTS_AT_END
+} GnmPrintCommentPlacementType;
+
+typedef enum {
+ GNM_PRINT_ERRORS_AS_DISPLAYED,
+ GNM_PRINT_ERRORS_AS_BLANK,
+ GNM_PRINT_ERRORS_AS_DASHES,
+ GNM_PRINT_ERRORS_AS_NA
+} GnmPrintErrorsType;
+
+typedef enum {
GNM_PAGE_BREAK_NONE, /* Not actually a page break */
GNM_PAGE_BREAK_MANUAL, /* hard page break */
GNM_PAGE_BREAK_AUTO, /* soft (automatic) pagebreak */
@@ -75,17 +95,8 @@ struct _PrintInformation {
unsigned int print_even_if_only_styles:1;
unsigned int do_not_print:1;
- enum {
- PRINT_COMMENTS_NONE,
- PRINT_COMMENTS_IN_PLACE,
- PRINT_COMMENTS_AT_END
- } comment_placement;
- enum {
- PRINT_ERRORS_AS_DISPLAYED,
- PRINT_ERRORS_AS_BLANK,
- PRINT_ERRORS_AS_DASHES,
- PRINT_ERRORS_AS_NA
- } error_display;
+ GnmPrintCommentPlacementType comment_placement;
+ GnmPrintErrorsType error_display;
struct {
GnmPageBreaks *h, /* between rows */
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 1249ee9..b3310dd 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -2711,35 +2711,79 @@ xml_sax_print_order (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
}
static void
-xml_sax_print_comments (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+xml_sax_print_comments_start (GsfXMLIn *xin, xmlChar const **attrs)
{
XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
+ gint tmpi;
+
+ xml_sax_must_have_sheet (state);
+
+ /* In 1.11.x and later this is saved as an enum value */
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ if (xml_sax_attr_enum (attrs, "placement", GNM_PRINT_COMMENT_PLACEMENT_TYPE, &tmpi))
+ state->sheet->print_info->comment_placement = tmpi;
+}
+
+static void
+xml_sax_print_comments_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+{
+ XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
+
+ if (xin->content->str == NULL || *xin->content->str == 0)
+ /* 1.11.x or later file */
+ return;
xml_sax_must_have_sheet (state);
if (strcmp (xin->content->str, "in_place") == 0)
- state->sheet->print_info->comment_placement = PRINT_COMMENTS_IN_PLACE;
+ state->sheet->print_info->comment_placement =
+ GNM_PRINT_COMMENTS_IN_PLACE;
else if (strcmp (xin->content->str, "at_end") == 0)
- state->sheet->print_info->comment_placement = PRINT_COMMENTS_AT_END;
+ state->sheet->print_info->comment_placement =
+ GNM_PRINT_COMMENTS_AT_END;
else
- state->sheet->print_info->comment_placement = PRINT_COMMENTS_NONE;
+ state->sheet->print_info->comment_placement =
+ GNM_PRINT_COMMENTS_NONE;
}
static void
-xml_sax_print_errors (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+xml_sax_print_errors_start (GsfXMLIn *xin, xmlChar const **attrs)
{
XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
+ gint tmpi;
+
+ xml_sax_must_have_sheet (state);
+
+ /* In 1.11.x and later this is saved as an enum value */
+ for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
+ if (xml_sax_attr_enum (attrs, "PrintErrorsAs", GNM_PRINT_ERRORS_TYPE, &tmpi))
+ state->sheet->print_info->error_display = tmpi;
+}
+
+
+static void
+xml_sax_print_errors_end (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
+{
+ XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
+
+ if (xin->content->str == NULL || *xin->content->str == 0)
+ /* 1.11.x or later file */
+ return;
xml_sax_must_have_sheet (state);
if (strcmp (xin->content->str, "as_blank") == 0)
- state->sheet->print_info->error_display = PRINT_ERRORS_AS_BLANK;
+ state->sheet->print_info->error_display =
+ GNM_PRINT_ERRORS_AS_BLANK;
else if (strcmp (xin->content->str, "as_dashes") == 0)
- state->sheet->print_info->error_display = PRINT_ERRORS_AS_DASHES;
+ state->sheet->print_info->error_display =
+ GNM_PRINT_ERRORS_AS_DASHES;
else if (strcmp (xin->content->str, "as_na") == 0)
- state->sheet->print_info->error_display = PRINT_ERRORS_AS_NA;
+ state->sheet->print_info->error_display =
+ GNM_PRINT_ERRORS_AS_NA;
else
- state->sheet->print_info->error_display = PRINT_ERRORS_AS_DISPLAYED;
+ state->sheet->print_info->error_display =
+ GNM_PRINT_ERRORS_AS_DISPLAYED;
}
@@ -2930,8 +2974,8 @@ GSF_XML_IN_NODE_FULL (START, WB, GNM, "Workbook", GSF_XML_NO_CONTENT, TRUE, TRUE
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_PRINT_RANGE, GNM, "print_range",GSF_XML_NO_CONTENT, &xml_sax_print_print_range, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_MONO, GNM, "monochrome", GSF_XML_NO_CONTENT, &xml_sax_monochrome, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_AS_DRAFT, GNM, "draft", GSF_XML_NO_CONTENT, NULL, NULL),
- GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_COMMENTS, GNM, "comments", GSF_XML_CONTENT, NULL, &xml_sax_print_comments),
- GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ERRORS, GNM, "errors", GSF_XML_CONTENT, NULL, &xml_sax_print_errors),
+ GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_COMMENTS, GNM, "comments", GSF_XML_CONTENT, &xml_sax_print_comments_start, &xml_sax_print_comments_end),
+ GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_ERRORS, GNM, "errors", GSF_XML_CONTENT, &xml_sax_print_errors_start, &xml_sax_print_errors_end),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_TITLES, GNM, "titles", GSF_XML_NO_CONTENT, &xml_sax_print_titles, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_REPEAT_TOP, GNM, "repeat_top", GSF_XML_NO_CONTENT, &xml_sax_repeat_top, NULL),
GSF_XML_IN_NODE (SHEET_PRINTINFO, PRINT_REPEAT_LEFT,GNM, "repeat_left", GSF_XML_NO_CONTENT, &xml_sax_repeat_left, NULL),
@@ -3419,14 +3463,13 @@ xml_cellregion_read (WorkbookControl *wbc, GOIOContext *io_context,
WorkbookView *wb_view;
GsfInput *input;
XMLSaxParseState state;
- gboolean ok;
GnmCellRegion *result;
wb_view = wb_control_view (wbc);
input = gsf_input_memory_new (buffer, length, FALSE);
- ok = read_file_common (READ_CLIPBOARD, &state,
- io_context, wb_view, sheet,
- input);
+ read_file_common (READ_CLIPBOARD, &state,
+ io_context, wb_view, sheet,
+ input);
g_object_unref (input);
result = state.clipboard;
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 0d594de..c164e5c 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -417,41 +417,17 @@ xml_write_print_info (GnmOutputXML *state, PrintInformation *pi)
if (NULL != pi->page_breaks.h)
xml_write_breaks (state, pi->page_breaks.h);
- switch (pi->comment_placement) {
- case PRINT_COMMENTS_IN_PLACE:
- gsf_xml_out_simple_element (state->output, GNM "comments",
- "in_place");
- break;
- case PRINT_COMMENTS_AT_END:
- gsf_xml_out_simple_element (state->output, GNM "comments",
- "at_end");
- break;
- case PRINT_COMMENTS_NONE:
- default:
- gsf_xml_out_simple_element (state->output, GNM "comments",
- "none");
- break;
- }
-
- switch (pi->error_display) {
- case PRINT_ERRORS_AS_BLANK:
- gsf_xml_out_simple_element (state->output, GNM "errors",
- "as_blank");
- break;
- case PRINT_ERRORS_AS_DASHES:
- gsf_xml_out_simple_element (state->output, GNM "errors",
- "as_dashes");
- break;
- case PRINT_ERRORS_AS_NA:
- gsf_xml_out_simple_element (state->output, GNM "errors",
- "as_na");
- break;
- case PRINT_ERRORS_AS_DISPLAYED:
- default:
- gsf_xml_out_simple_element (state->output, GNM "errors",
- "as_displayed");
- break;
- }
+ gsf_xml_out_start_element (state->output, GNM "comments");
+ gsf_xml_out_add_enum (state->output, "placement",
+ GNM_PRINT_COMMENT_PLACEMENT_TYPE,
+ pi->comment_placement);
+ gsf_xml_out_end_element (state->output);
+
+ gsf_xml_out_start_element (state->output, GNM "errors");
+ gsf_xml_out_add_enum (state->output, "PrintErrorsAs",
+ GNM_PRINT_ERRORS_TYPE,
+ pi->error_display);
+ gsf_xml_out_end_element (state->output);
gsf_xml_out_end_element (state->output);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]