[gnumeric] use gsf_xml_out_add_enum and xml_sax_attr_enum to write/read print_range fto/from .gnumeric files
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] use gsf_xml_out_add_enum and xml_sax_attr_enum to write/read print_range fto/from .gnumeric files
- Date: Mon, 21 Nov 2011 06:33:40 +0000 (UTC)
commit dda2d034aa5f2c89fb55e02fb9cd76f8f038f81d
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Sun Nov 20 23:32:35 2011 -0700
use gsf_xml_out_add_enum and xml_sax_attr_enum to write/read print_range fto/from .gnumeric files
2011-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print.c (gnm_print_range_get_type): new
* src/print.h (gnm_print_range_get_type): new
* src/xml-sax-read.c (xml_sax_print_print_range): use
xml_sax_attr_enum
* src/xml-sax-write.c (xml_write_print_info): use gsf_xml_out_add_enum
ChangeLog | 8 ++++++++
src/print.c | 26 ++++++++++++++++++++++++++
src/print.h | 7 ++++++-
src/xml-sax-read.c | 3 ++-
src/xml-sax-write.c | 4 +++-
5 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 114cbff..ea6fce0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/print.c (gnm_print_range_get_type): new
+ * src/print.h (gnm_print_range_get_type): new
+ * src/xml-sax-read.c (xml_sax_print_print_range): use
+ xml_sax_attr_enum
+ * src/xml-sax-write.c (xml_write_print_info): use gsf_xml_out_add_enum
+
2011-11-20 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print-info.h (gnm_print_comment_placement_get_type): new
diff --git a/src/print.c b/src/print.c
index 216a70f..b644b3a 100644
--- a/src/print.c
+++ b/src/print.c
@@ -109,6 +109,32 @@ typedef struct {
gboolean gnm_print_debug = FALSE;
+GType
+gnm_print_range_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ { PRINT_SAVED_INFO, "GNM_PRINT_SAVED_INFO", "as-saved"},
+ { PRINT_ACTIVE_SHEET, "GNM_PRINT_ACTIVE_SHEET", "active-sheet"},
+ { PRINT_ALL_SHEETS, "GNM_PRINT_ALL_SHEETS", "all-sheets"},
+ { PRINT_ALL_SHEETS_INCLUDING_HIDDEN, "GNM_PRINT_ALL_SHEETS_INCLUDING_HIDDEN",
+ "all-sheets-incl-hidden"},
+ { PRINT_SHEET_RANGE, "GNM_PRINT_SHEET_RANGE", "sheet-range"},
+ { PRINT_SHEET_SELECTION, "GNM_PRINT_SHEET_SELECTION", "sheet-selection"},
+ { PRINT_IGNORE_PRINTAREA, "GNM_PRINT_IGNORE_PRINTAREA", "ignore-print-area"},
+ { PRINT_SHEET_SELECTION_IGNORE_PRINTAREA,
+ "GNM_PRINT_SHEET_SELECTION_IGNORE_PRINTAREA",
+ "sheet-selection-ignore-printarea"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmPrintRange",
+ values);
+ }
+ return etype;
+}
+
+
static PrintingInstance *
printing_instance_new (void)
{
diff --git a/src/print.h b/src/print.h
index c60c1fc..7bb379c 100644
--- a/src/print.h
+++ b/src/print.h
@@ -13,7 +13,12 @@ G_BEGIN_DECLS
#define GNUMERIC_PRINT_SETTING_PRINT_TO_SHEET_KEY "GnumericPrintToSheet"
#define GNUMERIC_PRINT_SETTING_IGNORE_PAGE_BREAKS_KEY "GnumericPrintIgnorePageBreaks"
-typedef enum { /* These numbers are saved in .gnumeric files */
+GType gnm_print_range_get_type (void);
+#define GNM_PRINT_RANGE_TYPE (gnm_print_range_get_type ())
+
+typedef enum { /* These numbers are saved in pre 1.11.x .gnumeric files */
+ /* In 1.11.x and later the names as defined in */
+ /* gnm_print_range_get_type are used */
PRINT_SAVED_INFO = -1,
PRINT_ACTIVE_SHEET = 0,
PRINT_ALL_SHEETS = 1,
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index b3310dd..20a2d28 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -1055,7 +1055,8 @@ xml_sax_print_print_range (GsfXMLIn *xin, xmlChar const **attrs)
pi = state->sheet->print_info;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)
- if (gnm_xml_attr_int (attrs, "value", &val))
+ if (xml_sax_attr_enum (attrs, "value", GNM_PRINT_RANGE_TYPE,
+ &val))
print_info_set_printrange (pi, val);
}
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index c164e5c..2972f9a 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -381,7 +381,9 @@ xml_write_print_info (GnmOutputXML *state, PrintInformation *pi)
gsf_xml_out_end_element (state->output);
gsf_xml_out_start_element (state->output, GNM "print_range");
- gsf_xml_out_add_int (state->output, "value", print_info_get_printrange (pi));
+ gsf_xml_out_add_enum (state->output, "value",
+ GNM_PRINT_RANGE_TYPE,
+ print_info_get_printrange (pi) );
gsf_xml_out_end_element (state->output);
xml_write_print_repeat_range (state, GNM "repeat_top", pi->repeat_top);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]