[gnumeric] the remaining gsf_xml_out_add_enum/xml_sax_attr_enum adjustments
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] the remaining gsf_xml_out_add_enum/xml_sax_attr_enum adjustments
- Date: Tue, 22 Nov 2011 20:17:38 +0000 (UTC)
commit ca44ce155184a1530c21b4b9326800b1e20b88d9
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Tue Nov 22 13:16:49 2011 -0700
the remaining gsf_xml_out_add_enum/xml_sax_attr_enum adjustments
2011-11-22 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/style.c (gnm_align_h_get_type): new
(gnm_align_v_get_type): new
* src/style.h (gnm_align_h_get_type): new
(gnm_align_v_get_type): new
* src/validation.c (gnm_validation_type_get_type): new
(gnm_validation_style_get_type): new
(gnm_validation_op_get_type): new
* src/validation.h (gnm_validation_type_get_type): new
(gnm_validation_style_get_type): new
(gnm_validation_op_get_type): new
* src/xml-sax-read.c (xml_sax_style_start): use xml_sax_attr_enum
(xml_sax_validation): ditto
* src/xml-sax-write.c (xml_write_attribute): change argument
type, rename to xml_write_boolean_attribute and adjust all callers
(xml_write_style): use gsf_xml_out_add_enum
ChangeLog | 20 +++++++++++-
src/style.c | 47 +++++++++++++++++++++++++++
src/style.h | 6 +++
src/validation.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/validation.h | 10 ++++++
src/xml-sax-read.c | 18 +++++++---
src/xml-sax-write.c | 75 +++++++++++++++++++++++++++----------------
7 files changed, 230 insertions(+), 35 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 13d5c74..e2b0696 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,27 @@
+2011-11-22 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/style.c (gnm_align_h_get_type): new
+ (gnm_align_v_get_type): new
+ * src/style.h (gnm_align_h_get_type): new
+ (gnm_align_v_get_type): new
+ * src/validation.c (gnm_validation_type_get_type): new
+ (gnm_validation_style_get_type): new
+ (gnm_validation_op_get_type): new
+ * src/validation.h (gnm_validation_type_get_type): new
+ (gnm_validation_style_get_type): new
+ (gnm_validation_op_get_type): new
+ * src/xml-sax-read.c (xml_sax_style_start): use xml_sax_attr_enum
+ (xml_sax_validation): ditto
+ * src/xml-sax-write.c (xml_write_attribute): change argument
+ type, rename to xml_write_boolean_attribute and adjust all callers
+ (xml_write_style): use gsf_xml_out_add_enum
+
2011-11-22 Morten Welinder <terra gnome org>
* src/print.c (gnm_print_range_get_type): Rename enums to match
gtype.
-2011-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
+2011-11-21 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print.c (compute_scale_fit_to): remove unsued variables
(compute_pages): remove arguments and chnge all callers
diff --git a/src/style.c b/src/style.c
index 3a494d8..4f8cd9f 100644
--- a/src/style.c
+++ b/src/style.c
@@ -323,6 +323,53 @@ gnm_font_hash (gconstpointer v)
GPOINTER_TO_UINT (k->context);
}
+GType
+gnm_align_h_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ {HALIGN_GENERAL, "GNM_HALIGN_GENERAL", "general"},
+ {HALIGN_LEFT, "GNM_HALIGN_LEFT", "left"},
+ {HALIGN_RIGHT, "GNM_HALIGN_RIGHT", "right"},
+ {HALIGN_CENTER, "GNM_HALIGN_CENTER", "center"},
+ {HALIGN_FILL, "GNM_HALIGN_FILL", "fill"},
+ {HALIGN_JUSTIFY, "GNM_HALIGN_JUSTIFY", "justify"},
+ {HALIGN_CENTER_ACROSS_SELECTION,
+ "GNM_HALIGN_CENTER_ACROSS_SELECTION",
+ "across-selection"},
+ {HALIGN_DISTRIBUTED,
+ "GNM_HALIGN_DISTRIBUTED", "distributed"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmHAlign",
+ values);
+ }
+ return etype;
+}
+
+GType
+gnm_align_v_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ {VALIGN_TOP, "GNM_VALIGN_TOP", "top"},
+ {VALIGN_BOTTOM, "GNM_VALIGN_BOTTOM", "bottom"},
+ {VALIGN_CENTER, "GNM_VALIGN_CENTER", "center"},
+ {VALIGN_JUSTIFY, "GNM_VALIGN_JUSTIFY", "justify"},
+ {VALIGN_DISTRIBUTED,
+ "GNM_VALIGN_DISTRIBUTED", "distributed"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmVAlign",
+ values);
+ }
+ return etype;
+}
+
+
+
static PangoFontMap *fontmap;
static PangoContext *context;
diff --git a/src/style.h b/src/style.h
index cb09cde..afdc54c 100644
--- a/src/style.h
+++ b/src/style.h
@@ -54,6 +54,12 @@ typedef enum {
#include "mstyle.h"
+GType gnm_align_h_get_type (void);
+#define GNM_ALIGN_H_TYPE (gnm_print_range_get_type ())
+
+GType gnm_align_v_get_type (void);
+#define GNM_ALIGN_V_TYPE (gnm_print_range_get_type ())
+
GnmSpanCalcFlags gnm_style_required_spanflags (GnmStyle const *style);
GnmHAlign gnm_style_default_halign (GnmStyle const *style,
GnmCell const *c);
diff --git a/src/validation.c b/src/validation.c
index 5608654..719732d 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -141,6 +141,95 @@ gnm_validation_combo_new (GnmValidation const *val, SheetView *sv)
/***************************************************************************/
+GType
+gnm_validation_style_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ { VALIDATION_STYLE_NONE,
+ "GNM_VALIDATION_STYLE_NONE", "none"},
+ { VALIDATION_STYLE_STOP,
+ "GNM_VALIDATION_STYLE_STOP", "stop"},
+ { VALIDATION_STYLE_WARNING,
+ "GNM_VALIDATION_STYLE_WARNING", "warning"},
+ { VALIDATION_STYLE_INFO,
+ "GNM_VALIDATION_STYLE_INFO", "info"},
+ { VALIDATION_STYLE_PARSE_ERROR,
+ "GNM_VALIDATION_STYLE_PARSE_ERROR", "parse-error"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmValidationStyle",
+ values);
+ }
+ return etype;
+}
+
+GType
+gnm_validation_type_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ { VALIDATION_TYPE_ANY,
+ "GNM_VALIDATION_TYPE_ANY", "any"},
+ { VALIDATION_TYPE_AS_INT,
+ "GNM_VALIDATION_TYPE_AS_INT", "int"},
+ { VALIDATION_TYPE_AS_NUMBER,
+ "GNM_VALIDATION_TYPE_AS_NUMBER", "number"},
+ { VALIDATION_TYPE_IN_LIST,
+ "GNM_VALIDATION_TYPE_IN_LIST", "list"},
+ { VALIDATION_TYPE_AS_DATE,
+ "GNM_VALIDATION_TYPE_AS_DATE", "date"},
+ { VALIDATION_TYPE_AS_TIME,
+ "GNM_VALIDATION_TYPE_AS_TIME", "time"},
+ { VALIDATION_TYPE_TEXT_LENGTH,
+ "GNM_VALIDATION_TYPE_TEXT_LENGTH", "length"},
+ { VALIDATION_TYPE_CUSTOM,
+ "GNM_VALIDATION_TYPE_CUSTOM", "custom"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmValidationType",
+ values);
+ }
+ return etype;
+}
+
+GType
+gnm_validation_op_get_type (void)
+{
+ static GType etype = 0;
+ if (etype == 0) {
+ static GEnumValue const values[] = {
+ { VALIDATION_OP_NONE,
+ "GNM_VALIDATION_OP_NONE", "none"},
+ { VALIDATION_OP_BETWEEN,
+ "GNM_VALIDATION_OP_BETWEEN", "between"},
+ { VALIDATION_OP_NOT_BETWEEN,
+ "GNM_VALIDATION_OP_NOT_BETWEEN", "not-between"},
+ { VALIDATION_OP_EQUAL,
+ "GNM_VALIDATION_OP_EQUAL", "equal"},
+ { VALIDATION_OP_NOT_EQUAL,
+ "GNM_VALIDATION_OP_NOT_EQUAL", "not-equal"},
+ { VALIDATION_OP_GT,
+ "GNM_VALIDATION_OP_GT", "gt"},
+ { VALIDATION_OP_LT,
+ "GNM_VALIDATION_OP_LT", "lt"},
+ { VALIDATION_OP_GTE,
+ "GNM_VALIDATION_OP_GTE", "gte"},
+ { VALIDATION_OP_LTE,
+ "GNM_VALIDATION_OP_LTE", "lte"},
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("GnmValidationOp",
+ values);
+ }
+ return etype;
+}
+
+
+/***************************************************************************/
+
/**
* validation_new :
* @title : will be copied.
diff --git a/src/validation.h b/src/validation.h
index 6cdf410..419d8b2 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -53,6 +53,16 @@ struct _GnmValidation {
gboolean use_dropdown;
};
+GType gnm_validation_type_get_type (void);
+#define GNM_VALIDATION_TYPE_TYPE (gnm_validation_type_get_type ())
+
+GType gnm_validation_style_get_type (void);
+#define GNM_VALIDATION_STYLE_TYPE (gnm_validation_style_get_type ())
+
+GType gnm_validation_op_get_type (void);
+#define GNM_VALIDATION_OP_TYPE (gnm_validation_op_get_type ())
+
+
GnmValidation *validation_new (ValidationStyle style,
ValidationType type,
ValidationOp op,
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index 2ea06ec..75e54d3 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -633,7 +633,7 @@ xml_sax_finish_parse_wb_attr (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
state->attribute.name,
state->attribute.value);
} else {
- xml_sax_barf (G_STRFUNC, "workbook view attributes complete");
+ xml_sax_barf (G_STRFUNC, _("workbook view attribute is incomplete"));
}
g_free (state->attribute.value); state->attribute.value = NULL;
@@ -1426,9 +1426,9 @@ xml_sax_style_start (GsfXMLIn *xin, xmlChar const **attrs)
xml_sax_must_have_style (state);
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
- if (gnm_xml_attr_int (attrs, "HAlign", &val))
+ if (xml_sax_attr_enum (attrs, "HAlign", GNM_ALIGN_H_TYPE, &val))
gnm_style_set_align_h (state->style, val);
- else if (gnm_xml_attr_int (attrs, "VAlign", &val))
+ else if (xml_sax_attr_enum (attrs, "VAlign", GNM_ALIGN_V_TYPE, &val))
gnm_style_set_align_v (state->style, val);
/* Pre version V6 */
@@ -1592,11 +1592,17 @@ xml_sax_validation (GsfXMLIn *xin, xmlChar const **attrs)
state->validation.use_dropdown = FALSE;
for (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2) {
- if (gnm_xml_attr_int (attrs, "Style", &dummy)) {
+ if (xml_sax_attr_enum (attrs, "Style",
+ GNM_VALIDATION_STYLE_TYPE,
+ &dummy)) {
state->validation.style = dummy;
- } else if (gnm_xml_attr_int (attrs, "Type", &dummy)) {
+ } else if (xml_sax_attr_enum (attrs, "Type",
+ GNM_VALIDATION_TYPE_TYPE,
+ &dummy)) {
state->validation.type = dummy;
- } else if (gnm_xml_attr_int (attrs, "Operator", &dummy)) {
+ } else if (xml_sax_attr_enum (attrs, "Operator",
+ GNM_VALIDATION_OP_TYPE,
+ &dummy)) {
state->validation.op = dummy;
} else if (attr_eq (attrs[0], "Title")) {
state->validation.title = g_strdup (CXML2C (attrs[1]));
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 2972f9a..53a0a35 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -118,13 +118,11 @@ xml_out_add_points (GsfXMLOut *xml, char const *name, double val)
}
static void
-xml_write_attribute (GnmOutputXML *state, char const *name, char const *value)
+xml_write_boolean_attribute (GnmOutputXML *state, char const *name, gboolean value)
{
gsf_xml_out_start_element (state->output, GNM "Attribute");
- /* backwards compatibility with 1.0.x which uses gtk-1.2 GTK_TYPE_BOOLEAN */
- gsf_xml_out_simple_element (state->output, GNM "type", "4");
gsf_xml_out_simple_element (state->output, GNM "name", name);
- gsf_xml_out_simple_element (state->output, GNM "value", value);
+ gsf_xml_out_simple_element (state->output, GNM "value", value ? "TRUE" : "FALSE");
gsf_xml_out_end_element (state->output); /* </Attribute> */
}
@@ -143,16 +141,21 @@ static void
xml_write_attributes (GnmOutputXML *state)
{
gsf_xml_out_start_element (state->output, GNM "Attributes");
- xml_write_attribute (state, "WorkbookView::show_horizontal_scrollbar",
- state->wb_view->show_horizontal_scrollbar ? "TRUE" : "FALSE");
- xml_write_attribute (state, "WorkbookView::show_vertical_scrollbar",
- state->wb_view->show_vertical_scrollbar ? "TRUE" : "FALSE");
- xml_write_attribute (state, "WorkbookView::show_notebook_tabs",
- state->wb_view->show_notebook_tabs ? "TRUE" : "FALSE");
- xml_write_attribute (state, "WorkbookView::do_auto_completion",
- state->wb_view->do_auto_completion ? "TRUE" : "FALSE");
- xml_write_attribute (state, "WorkbookView::is_protected",
- state->wb_view->is_protected ? "TRUE" : "FALSE");
+ xml_write_boolean_attribute
+ (state, "WorkbookView::show_horizontal_scrollbar",
+ state->wb_view->show_horizontal_scrollbar);
+ xml_write_boolean_attribute
+ (state, "WorkbookView::show_vertical_scrollbar",
+ state->wb_view->show_vertical_scrollbar);
+ xml_write_boolean_attribute
+ (state, "WorkbookView::show_notebook_tabs",
+ state->wb_view->show_notebook_tabs);
+ xml_write_boolean_attribute
+ (state, "WorkbookView::do_auto_completion",
+ state->wb_view->do_auto_completion);
+ xml_write_boolean_attribute
+ (state, "WorkbookView::is_protected",
+ state->wb_view->is_protected);
gsf_xml_out_end_element (state->output); /* </Attributes> */
}
@@ -457,29 +460,42 @@ xml_write_style (GnmOutputXML *state, GnmStyle const *style)
gsf_xml_out_start_element (state->output, GNM "Style");
if (gnm_style_is_element_set (style, MSTYLE_ALIGN_H))
- gsf_xml_out_add_int (state->output, "HAlign", gnm_style_get_align_h (style));
+ gsf_xml_out_add_enum (state->output, "HAlign",
+ GNM_ALIGN_H_TYPE,
+ gnm_style_get_align_h (style));
if (gnm_style_is_element_set (style, MSTYLE_ALIGN_V))
- gsf_xml_out_add_int (state->output, "VAlign", gnm_style_get_align_v (style));
+ gsf_xml_out_add_enum (state->output, "VAlign",
+ GNM_ALIGN_V_TYPE,
+ gnm_style_get_align_v (style));
if (gnm_style_is_element_set (style, MSTYLE_WRAP_TEXT))
- gsf_xml_out_add_bool (state->output, "WrapText", gnm_style_get_wrap_text (style));
+ gsf_xml_out_add_bool (state->output, "WrapText",
+ gnm_style_get_wrap_text (style));
if (gnm_style_is_element_set (style, MSTYLE_SHRINK_TO_FIT))
- gsf_xml_out_add_bool (state->output, "ShrinkToFit", gnm_style_get_shrink_to_fit (style));
+ gsf_xml_out_add_bool (state->output, "ShrinkToFit",
+ gnm_style_get_shrink_to_fit (style));
if (gnm_style_is_element_set (style, MSTYLE_ROTATION))
- gsf_xml_out_add_int (state->output, "Rotation", gnm_style_get_rotation (style));
+ gsf_xml_out_add_int (state->output, "Rotation",
+ gnm_style_get_rotation (style));
if (gnm_style_is_element_set (style, MSTYLE_PATTERN))
- gsf_xml_out_add_int (state->output, "Shade", gnm_style_get_pattern (style));
+ gsf_xml_out_add_int (state->output, "Shade",
+ gnm_style_get_pattern (style));
if (gnm_style_is_element_set (style, MSTYLE_INDENT))
gsf_xml_out_add_int (state->output, "Indent", gnm_style_get_indent (style));
if (gnm_style_is_element_set (style, MSTYLE_CONTENTS_LOCKED))
- gsf_xml_out_add_bool (state->output, "Locked", gnm_style_get_contents_locked (style));
+ gsf_xml_out_add_bool (state->output, "Locked",
+ gnm_style_get_contents_locked (style));
if (gnm_style_is_element_set (style, MSTYLE_CONTENTS_HIDDEN))
- gsf_xml_out_add_bool (state->output, "Hidden", gnm_style_get_contents_hidden (style));
+ gsf_xml_out_add_bool (state->output, "Hidden",
+ gnm_style_get_contents_hidden (style));
if (gnm_style_is_element_set (style, MSTYLE_FONT_COLOR))
- gnm_xml_out_add_color (state->output, "Fore", gnm_style_get_font_color (style));
+ gnm_xml_out_add_color (state->output, "Fore",
+ gnm_style_get_font_color (style));
if (gnm_style_is_element_set (style, MSTYLE_COLOR_BACK))
- gnm_xml_out_add_color (state->output, "Back", gnm_style_get_back_color (style));
+ gnm_xml_out_add_color (state->output, "Back",
+ gnm_style_get_back_color (style));
if (gnm_style_is_element_set (style, MSTYLE_COLOR_PATTERN))
- gnm_xml_out_add_color (state->output, "PatternColor", gnm_style_get_pattern_color (style));
+ gnm_xml_out_add_color (state->output, "PatternColor",
+ gnm_style_get_pattern_color (style));
if (gnm_style_is_element_set (style, MSTYLE_FORMAT)) {
const char *fmt = go_format_as_XL (gnm_style_get_format (style));
gsf_xml_out_add_cstr (state->output, "Format", fmt);
@@ -534,8 +550,10 @@ xml_write_style (GnmOutputXML *state, GnmStyle const *style)
char *tmp;
gsf_xml_out_start_element (state->output, GNM "Validation");
- gsf_xml_out_add_int (state->output, "Style", v->style);
- gsf_xml_out_add_int (state->output, "Type", v->type);
+ gsf_xml_out_add_enum (state->output, "Style",
+ GNM_VALIDATION_STYLE_TYPE, v->style);
+ gsf_xml_out_add_enum (state->output, "Type",
+ GNM_VALIDATION_TYPE_TYPE, v->type);
switch (v->type) {
case VALIDATION_TYPE_AS_INT :
@@ -543,7 +561,8 @@ xml_write_style (GnmOutputXML *state, GnmStyle const *style)
case VALIDATION_TYPE_AS_DATE :
case VALIDATION_TYPE_AS_TIME :
case VALIDATION_TYPE_TEXT_LENGTH :
- gsf_xml_out_add_int (state->output, "Operator", v->op);
+ gsf_xml_out_add_enum (state->output, "Operator",
+ GNM_VALIDATION_OP_TYPE, v->op);
break;
default :
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]