[lasem/mml-attrs: 5/5] [Mathml] Migration to lsm_attribute_manager WIP.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [lasem/mml-attrs: 5/5] [Mathml] Migration to lsm_attribute_manager WIP.
- Date: Mon, 16 Nov 2009 22:41:44 +0000 (UTC)
commit bfc598baf0af03b5cd178dfbbe919c3bb7c44c3b
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Mon Nov 16 23:40:06 2009 +0100
[Mathml] Migration to lsm_attribute_manager WIP.
lsm_mathml_boolean_attribute
src/Makefile.am | 8 ++-
src/lsmmathmlattributes.c | 11 ++++
src/lsmmathmlattributes.h | 15 +++++
src/lsmmathmlelement.c | 40 ++++++++++---
src/lsmmathmlelement.h | 10 ++-
src/lsmmathmlfractionelement.c | 24 +++++++-
src/lsmmathmloperatorelement.c | 127 ++++++++++++++++++++++++++++-----------
src/lsmmathmlstyleelement.c | 22 ++++++-
src/lsmmathmltableelement.c | 47 +++++++++++----
src/lsmmathmltableelement.h | 1 +
src/lsmmathmltraits.c | 46 ++++++++++++++
src/lsmmathmltraits.h | 33 ++++++++++
src/lsmmathmlunderoverelement.c | 40 ++++++++++---
src/lsmsvgtraits.c | 3 +-
14 files changed, 346 insertions(+), 81 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f145d5..8b8bcf7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,6 +35,8 @@ liblasem_la_SOURCES = \
lsmdomparser.c \
lsmdomimplementation.c \
lsmmathmlenums.c \
+ lsmmathmltraits.c \
+ lsmmathmlattributes.c \
lsmmathmlentitydictionary.c \
lsmmathmloperatordictionary.c \
lsmmathmldocument.c \
@@ -59,7 +61,6 @@ liblasem_la_SOURCES = \
lsmmathmlpaddedelement.c \
lsmmathmlerrorelement.c \
lsmmathmlactionelement.c \
- lsmmathmlattributes.c \
lsmmathmlstyle.c \
lsmmathmlview.c \
lsmmathmlglyphtableams.c \
@@ -117,6 +118,9 @@ LASEM_HDRS = \
lsmdomparser.h \
lsmdomimplementation.h \
lsmmathml.h \
+ lsmmathmlenums.h \
+ lsmmathmltraits.h \
+ lsmmathmlattributes.h \
lsmmathmlentitydictionary.h \
lsmmathmloperatordictionary.h \
lsmmathmldocument.h \
@@ -141,13 +145,11 @@ LASEM_HDRS = \
lsmmathmlpaddedelement.h \
lsmmathmlerrorelement.h \
lsmmathmlactionelement.h \
- lsmmathmlattributes.h \
lsmmathmlstyle.h \
lsmmathmlview.h \
lsmmathmlglyphtableams.h \
lsmmathmlalignmarkelement.h \
lsmmathmlaligngroupelement.h \
- lsmmathmlenums.h \
lsmmathmlutils.h \
lsmmathmllayoututils.h \
lsmsvg.h \
diff --git a/src/lsmmathmlattributes.c b/src/lsmmathmlattributes.c
index 52e2c02..f739ced 100644
--- a/src/lsmmathmlattributes.c
+++ b/src/lsmmathmlattributes.c
@@ -30,6 +30,15 @@
#include <glib-object.h>
#include <math.h>
+void
+lsm_mathml_boolean_attribute_inherit (LsmMathmlBooleanAttribute *attribute, gboolean value)
+{
+ if (attribute->base.value == NULL)
+ attribute->value = value;
+}
+
+/**************************/
+
typedef struct {
ptrdiff_t bag_offset;
const LsmMathmlAttributeBagClass *bag_class;
@@ -346,6 +355,7 @@ lsm_mathml_attribute_get_value (const LsmMathmlAttribute *attribute)
return attribute->value;
}
+#if 0
void
lsm_mathml_boolean_attribute_parse (LsmMathmlBooleanAttribute *attribute,
gboolean *style_value)
@@ -364,6 +374,7 @@ lsm_mathml_boolean_attribute_parse (LsmMathmlBooleanAttribute *attribute,
attribute->value = (strcmp (string, "true") == 0);
*style_value = attribute->value;
}
+#endif
void
lsm_mathml_unsigned_attribute_parse (LsmMathmlUnsignedAttribute *attribute,
diff --git a/src/lsmmathmlattributes.h b/src/lsmmathmlattributes.h
index 7739f59..8b8051c 100644
--- a/src/lsmmathmlattributes.h
+++ b/src/lsmmathmlattributes.h
@@ -22,14 +22,25 @@
#ifndef LSM_MATHML_ATTRIBUTES_H
#define LSM_MATHML_ATTRIBUTES_H
+#include <lsmattributes.h>
#include <lsmdom.h>
#include <lsmmathml.h>
#include <lsmmathmlenums.h>
+#include <lsmmathmltraits.h>
#include <pango/pango-attributes.h>
G_BEGIN_DECLS
typedef struct {
+ LsmAttribute base;
+ gboolean value;
+} LsmMathmlBooleanAttribute;
+
+void lsm_mathml_boolean_attribute_inherit (LsmMathmlBooleanAttribute *attribute, gboolean value);
+
+/*******************************/
+
+typedef struct {
char *value;
char *css_value;
LsmMathmlCssType css_type;
@@ -104,10 +115,12 @@ typedef unsigned int (*LsmDomNamedConvert) (const char *string);
#define LSM_MATHML_SPACE_EM_VERY_THICK 0.333333
#define LSM_MATHML_SPACE_EM_VERY_VERY_THICK 0.388889
+#if 0
typedef struct {
LsmMathmlAttribute attr;
gboolean value;
} LsmMathmlBooleanAttribute;
+#endif
typedef struct {
LsmMathmlAttribute attr;
@@ -208,8 +221,10 @@ typedef struct {
double *values;
} LsmMathmlSpaceListAttribute;
+#if 0
void lsm_mathml_boolean_attribute_parse (LsmMathmlBooleanAttribute *attribute,
gboolean *default_value);
+#endif
void lsm_mathml_unsigned_attribute_parse (LsmMathmlUnsignedAttribute *attribute,
unsigned *default_value);
void lsm_mathml_double_attribute_parse (LsmMathmlDoubleAttribute *attribute,
diff --git a/src/lsmmathmlelement.c b/src/lsmmathmlelement.c
index ce1c96f..3bbb967 100644
--- a/src/lsmmathmlelement.c
+++ b/src/lsmmathmlelement.c
@@ -20,11 +20,11 @@
* Emmanuel Pacaud <emmanuel gnome org>
*/
-#include <lsmdebug.h>
#include <lsmmathmlelement.h>
#include <lsmmathmlspaceelement.h>
#include <lsmmathmloperatorelement.h>
#include <lsmmathmlview.h>
+#include <lsmdebug.h>
static GObjectClass *parent_class;
@@ -68,14 +68,22 @@ lsm_mathml_element_set_attribute (LsmDomElement *self, const char* name, const c
{
LsmMathmlElementClass *m_element_class = LSM_MATHML_ELEMENT_GET_CLASS(self);
- lsm_mathml_attribute_map_set_attribute (m_element_class->attributes, self,
- name, value);
+ if (!lsm_attribute_manager_set_attribute (m_element_class->attribute_manager,
+ self, name, value))
+ lsm_mathml_attribute_map_set_attribute (m_element_class->attributes, self,
+ name, value);
}
const char *
lsm_mathml_element_get_attribute (LsmDomElement *self, const char *name)
{
LsmMathmlElementClass *m_element_class = LSM_MATHML_ELEMENT_GET_CLASS(self);
+ const char *value;
+
+ value = lsm_attribute_manager_get_attribute (m_element_class->attribute_manager,
+ self, name);
+ if (value != NULL)
+ return value;
return lsm_mathml_attribute_map_get_attribute (m_element_class->attributes, self, name);
}
@@ -422,6 +430,24 @@ lsm_mathml_element_finalize (GObject *object)
/* LsmMathmlElement class */
+static const LsmAttributeInfos lsm_svg_attribute_infos[] = {
+ {
+ .name = "id",
+ .trait_class = &lsm_null_trait_class,
+ .attribute_offset = offsetof (LsmMathmlElement, id)
+ },
+ {
+ .name = "class",
+ .trait_class = &lsm_null_trait_class,
+ .attribute_offset = offsetof (LsmMathmlElement, class_name)
+ },
+ {
+ .name = "href",
+ .trait_class = &lsm_null_trait_class,
+ .attribute_offset = offsetof (LsmMathmlElement, href)
+ }
+};
+
static void
lsm_mathml_element_class_init (LsmMathmlElementClass *m_element_class)
{
@@ -450,12 +476,8 @@ lsm_mathml_element_class_init (LsmMathmlElementClass *m_element_class)
m_element_class->attributes = lsm_mathml_attribute_map_new ();
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "class",
- offsetof (LsmMathmlElement, class_name));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "id",
- offsetof (LsmMathmlElement, id));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "href",
- offsetof (LsmMathmlElement, href));
+ m_element_class->attribute_manager = lsm_attribute_manager_new (G_N_ELEMENTS (lsm_svg_attribute_infos),
+ lsm_svg_attribute_infos);
}
G_DEFINE_ABSTRACT_TYPE (LsmMathmlElement, lsm_mathml_element, LSM_TYPE_DOM_ELEMENT)
diff --git a/src/lsmmathmlelement.h b/src/lsmmathmlelement.h
index d7f5f24..747de8d 100644
--- a/src/lsmmathmlelement.h
+++ b/src/lsmmathmlelement.h
@@ -23,10 +23,11 @@
#ifndef LSM_MATHML_ELEMENT_H
#define LSM_MATHML_ELEMENT_H
+#include <lsmdomelement.h>
#include <lsmmathml.h>
#include <lsmmathmlutils.h>
#include <lsmmathmlstyle.h>
-#include <lsmdomelement.h>
+#include <lsmmathmlattributes.h>
#include <cairo.h>
G_BEGIN_DECLS
@@ -51,9 +52,9 @@ typedef struct _LsmMathmlElementClass LsmMathmlElementClass;
struct _LsmMathmlElement {
LsmDomElement element;
- LsmMathmlAttribute class_name;
- LsmMathmlAttribute id;
- LsmMathmlAttribute href;
+ LsmAttribute class_name;
+ LsmAttribute id;
+ LsmAttribute href;
LsmMathmlElementStyle style;
@@ -71,6 +72,7 @@ struct _LsmMathmlElement {
struct _LsmMathmlElementClass {
LsmDomElementClass parent_class;
+ LsmAttributeManager *attribute_manager;
LsmMathmlAttributeMap *attributes;
void (*update) (LsmMathmlElement *element, LsmMathmlStyle *style);
diff --git a/src/lsmmathmlfractionelement.c b/src/lsmmathmlfractionelement.c
index a14fadd..a4c1dfd 100644
--- a/src/lsmmathmlfractionelement.c
+++ b/src/lsmmathmlfractionelement.c
@@ -49,7 +49,7 @@ lsm_mathml_fraction_element_update (LsmMathmlElement *self, LsmMathmlStyle *styl
LsmMathmlFractionElement *fraction = LSM_MATHML_FRACTION_ELEMENT (self);
lsm_mathml_length_attribute_parse (&fraction->line_thickness, &style->line_thickness, style->math_size_value);
- lsm_mathml_boolean_attribute_parse (&fraction->bevelled, &style->bevelled);
+/* lsm_mathml_boolean_attribute_parse (&fraction->bevelled, &style->bevelled);*/
fraction->display = style->display;
}
@@ -183,6 +183,8 @@ lsm_mathml_fraction_element_get_embellished_core (const LsmMathmlElement *self)
/* LsmMathmlFraction implementation */
+static const gboolean bevelled_default = FALSE;
+
LsmDomNode *
lsm_mathml_fraction_element_new (void)
{
@@ -193,10 +195,21 @@ static void
lsm_mathml_fraction_element_init (LsmMathmlFractionElement *self)
{
self->axis_offset = 0.0;
+
+ self->bevelled.value = bevelled_default;
}
/* LsmMathmlFractionElement class */
+static const LsmAttributeInfos _attribute_infos[] = {
+ {
+ .name = "bevelled",
+ .attribute_offset = offsetof (LsmMathmlFractionElement, bevelled),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ .trait_default = &bevelled_default
+ }
+};
+
static void
lsm_mathml_fraction_element_class_init (LsmMathmlFractionElementClass *fraction_class)
{
@@ -215,13 +228,18 @@ lsm_mathml_fraction_element_class_init (LsmMathmlFractionElementClass *fraction_
m_element_class->render = lsm_mathml_fraction_element_render;
m_element_class->get_embellished_core = lsm_mathml_fraction_element_get_embellished_core;
m_element_class->is_inferred_row = NULL;
+ m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+ lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+ G_N_ELEMENTS (_attribute_infos),
+ _attribute_infos);
m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "linethickness",
offsetof (LsmMathmlFractionElement, line_thickness));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "bevelled",
- offsetof (LsmMathmlFractionElement, bevelled));
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "bevelled",*/
+/* offsetof (LsmMathmlFractionElement, bevelled));*/
}
G_DEFINE_TYPE (LsmMathmlFractionElement, lsm_mathml_fraction_element, LSM_TYPE_MATHML_ELEMENT)
diff --git a/src/lsmmathmloperatorelement.c b/src/lsmmathmloperatorelement.c
index 75e5f04..a962b4c 100644
--- a/src/lsmmathmloperatorelement.c
+++ b/src/lsmmathmloperatorelement.c
@@ -77,19 +77,23 @@ lsm_mathml_operator_element_post_new_child (LsmDomNode *self, LsmDomNode *child)
{
LsmMathmlOperatorElement *operator_element = LSM_MATHML_OPERATOR_ELEMENT (self);
const LsmMathmlOperatorDictionaryEntry *entry;
- gboolean flag;
+/* gboolean flag;*/
entry = lsm_mathml_operator_element_dictionary_lookup (operator_element);
lsm_debug ("[OperatorElement::post_new_child] found %s %s",
lsm_mathml_form_to_string (entry->form), entry->name);
- flag = entry->stretchy;
- lsm_mathml_boolean_attribute_parse (&operator_element->stretchy, &flag);
- flag = entry->fence;
- lsm_mathml_boolean_attribute_parse (&operator_element->fence, &flag);
- flag = entry->accent;
- lsm_mathml_boolean_attribute_parse (&operator_element->accent, &flag);
+/* flag = entry->stretchy;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->stretchy, &flag);*/
+/* flag = entry->fence;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->fence, &flag);*/
+/* flag = entry->accent;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->accent, &flag);*/
+
+ lsm_mathml_boolean_attribute_inherit (&operator_element->stretchy, entry->stretchy);
+ lsm_mathml_boolean_attribute_inherit (&operator_element->fence, entry->fence);
+ lsm_mathml_boolean_attribute_inherit (&operator_element->accent, entry->accent);
}
/* LsmMathmlElement implementation */
@@ -100,7 +104,7 @@ lsm_mathml_operator_element_update (LsmMathmlElement *self, LsmMathmlStyle *styl
LsmMathmlOperatorElement *operator_element = LSM_MATHML_OPERATOR_ELEMENT (self);
const LsmMathmlOperatorDictionaryEntry *entry;
LsmMathmlSpace space;
- gboolean flag;
+/* gboolean flag;*/
LSM_MATHML_ELEMENT_CLASS (parent_class)->update (self, style);
@@ -113,28 +117,36 @@ lsm_mathml_operator_element_update (LsmMathmlElement *self, LsmMathmlStyle *styl
lsm_mathml_space_attribute_parse (&operator_element->left_space, &space, style);
space = entry->right_space;
lsm_mathml_space_attribute_parse (&operator_element->right_space, &space, style);
- flag = entry->stretchy;
- lsm_mathml_boolean_attribute_parse (&operator_element->stretchy, &flag);
- flag = entry->fence;
- lsm_mathml_boolean_attribute_parse (&operator_element->fence, &flag);
- flag = entry->accent;
- lsm_mathml_boolean_attribute_parse (&operator_element->accent, &flag);
+/* flag = entry->stretchy;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->stretchy, &flag);*/
+/* flag = entry->fence;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->fence, &flag);*/
+/* flag = entry->accent;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->accent, &flag);*/
+/* flag = entry->stretchy;*/
+ lsm_mathml_boolean_attribute_inherit (&operator_element->stretchy, entry->stretchy);
+ lsm_mathml_boolean_attribute_inherit (&operator_element->fence, entry->fence);
+ lsm_mathml_boolean_attribute_inherit (&operator_element->accent, entry->accent);
if (operator_element->accent.value)
lsm_debug ("[OperatorElement::update] Is accent");
- flag = entry->large_op;
- lsm_mathml_boolean_attribute_parse (&operator_element->large_op, &flag);
- flag = entry->movable_limits;
- lsm_mathml_boolean_attribute_parse (&operator_element->movable_limits, &flag);
- flag = entry->separator;
- lsm_mathml_boolean_attribute_parse (&operator_element->separator, &flag);
+/* flag = entry->large_op;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->large_op, &flag);*/
+/* flag = entry->movable_limits;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->movable_limits, &flag);*/
+/* flag = entry->separator;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->separator, &flag);*/
+ lsm_mathml_boolean_attribute_inherit (&operator_element->large_op, entry->large_op);
+ lsm_mathml_boolean_attribute_inherit (&operator_element->movable_limits, entry->movable_limits);
+ lsm_mathml_boolean_attribute_inherit (&operator_element->separator, entry->separator);
space = entry->min_size;
lsm_mathml_space_attribute_parse (&operator_element->min_size, &space, style);
space = entry->max_size;
lsm_mathml_space_attribute_parse (&operator_element->max_size, &space, style);
- flag = entry->symmetric;
- lsm_mathml_boolean_attribute_parse (&operator_element->symmetric, &flag);
+/* flag = entry->symmetric;*/
+/* lsm_mathml_boolean_attribute_parse (&operator_element->symmetric, &flag);*/
+ lsm_mathml_boolean_attribute_inherit (&operator_element->symmetric, entry->symmetric);
operator_element->is_large_op = operator_element->large_op.value &&
(style->display == LSM_MATHML_DISPLAY_BLOCK);
@@ -220,6 +232,44 @@ lsm_mathml_operator_element_init (LsmMathmlOperatorElement *self)
/* LsmMathmlOperatorElement class */
+static const LsmAttributeInfos _attribute_infos[] = {
+ {
+ .name = "fence",
+ .attribute_offset = offsetof (LsmMathmlOperatorElement, fence),
+ .trait_class = &lsm_mathml_boolean_trait_class
+ },
+ {
+ .name = "separator",
+ .attribute_offset = offsetof (LsmMathmlOperatorElement, separator),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ },
+ {
+ .name = "stretchy",
+ .attribute_offset = offsetof (LsmMathmlOperatorElement, stretchy),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ },
+ {
+ .name = "symmetric",
+ .attribute_offset = offsetof (LsmMathmlOperatorElement, symmetric),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ },
+ {
+ .name = "large_op",
+ .attribute_offset = offsetof (LsmMathmlOperatorElement, large_op),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ },
+ {
+ .name = "movable_limits",
+ .attribute_offset = offsetof (LsmMathmlOperatorElement, movable_limits),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ },
+ {
+ .name = "accent",
+ .attribute_offset = offsetof (LsmMathmlOperatorElement, accent),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ }
+};
+
static void
lsm_mathml_operator_element_class_init (LsmMathmlOperatorElementClass *operator_class)
{
@@ -235,33 +285,38 @@ lsm_mathml_operator_element_class_init (LsmMathmlOperatorElementClass *operator_
m_element_class->measure = lsm_mathml_operator_element_measure;
m_element_class->render = lsm_mathml_operator_element_render;
m_element_class->get_embellished_core = lsm_mathml_operator_element_get_embellished_core;
+ m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+ lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+ G_N_ELEMENTS (_attribute_infos),
+ _attribute_infos);
m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "form",
offsetof (LsmMathmlOperatorElement, form));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "fence",
- offsetof (LsmMathmlOperatorElement, fence));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "separator",
- offsetof (LsmMathmlOperatorElement, separator));
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "fence",*/
+/* offsetof (LsmMathmlOperatorElement, fence));*/
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "separator",*/
+/* offsetof (LsmMathmlOperatorElement, separator));*/
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "lspace",
offsetof (LsmMathmlOperatorElement, left_space));
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "rspace",
offsetof (LsmMathmlOperatorElement, right_space));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "stretchy",
- offsetof (LsmMathmlOperatorElement, stretchy));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "symmetric",
- offsetof (LsmMathmlOperatorElement, symmetric));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "accent",
- offsetof (LsmMathmlOperatorElement, accent));
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "stretchy",*/
+/* offsetof (LsmMathmlOperatorElement, stretchy));*/
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "symmetric",*/
+/* offsetof (LsmMathmlOperatorElement, symmetric));*/
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "accent",*/
+/* offsetof (LsmMathmlOperatorElement, accent));*/
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "minsize",
offsetof (LsmMathmlOperatorElement, min_size));
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "maxsize",
offsetof (LsmMathmlOperatorElement, max_size));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "largeop",
- offsetof (LsmMathmlOperatorElement, large_op));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "movablelimits",
- offsetof (LsmMathmlOperatorElement, movable_limits));
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "largeop",*/
+/* offsetof (LsmMathmlOperatorElement, large_op));*/
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "movablelimits",*/
+/* offsetof (LsmMathmlOperatorElement, movable_limits));*/
}
G_DEFINE_TYPE (LsmMathmlOperatorElement, lsm_mathml_operator_element, LSM_TYPE_MATHML_PRESENTATION_TOKEN)
diff --git a/src/lsmmathmlstyleelement.c b/src/lsmmathmlstyleelement.c
index b3828d0..caf9477 100644
--- a/src/lsmmathmlstyleelement.c
+++ b/src/lsmmathmlstyleelement.c
@@ -46,8 +46,9 @@ lsm_mathml_style_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
LsmMathmlStyleElement *style_element = LSM_MATHML_STYLE_ELEMENT (self);
display_style = style->display == LSM_MATHML_DISPLAY_BLOCK;
- lsm_mathml_boolean_attribute_parse (&style_element->display_style, &display_style);
- style->display = display_style ? LSM_MATHML_DISPLAY_BLOCK : LSM_MATHML_DISPLAY_INLINE;
+/* lsm_mathml_boolean_attribute_parse (&style_element->display_style, &display_style);*/
+ lsm_mathml_boolean_attribute_inherit (&style_element->display_style, display_style);
+ style->display = style_element->display_style.value ? LSM_MATHML_DISPLAY_BLOCK : LSM_MATHML_DISPLAY_INLINE;
lsm_mathml_double_attribute_parse (&style_element->script_size_multiplier, &style->script_size_multiplier);
lsm_mathml_color_attribute_parse (&style_element->math_background, &style->math_background);
@@ -123,6 +124,14 @@ lsm_mathml_style_element_init (LsmMathmlStyleElement *self)
/* LsmMathmlStyleElement class */
+static const LsmAttributeInfos _attribute_infos[] = {
+ {
+ .name = "displaystyle",
+ .attribute_offset = offsetof (LsmMathmlStyleElement, display_style),
+ .trait_class = &lsm_mathml_boolean_trait_class
+ }
+};
+
static void
lsm_mathml_style_element_class_init (LsmMathmlStyleElementClass *style_class)
{
@@ -134,13 +143,18 @@ lsm_mathml_style_element_class_init (LsmMathmlStyleElementClass *style_class)
node_class->get_node_name = lsm_mathml_style_element_get_node_name;
m_element_class->update = lsm_mathml_style_element_update;
+ m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+ lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+ G_N_ELEMENTS (_attribute_infos),
+ _attribute_infos);
m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "scriptlevel",
offsetof (LsmMathmlStyleElement, script_level));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "displaystyle",
- offsetof (LsmMathmlStyleElement, display_style));
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "displaystyle",*/
+/* offsetof (LsmMathmlStyleElement, display_style));*/
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "scriptsizemultiplier",
offsetof (LsmMathmlStyleElement, script_size_multiplier));
lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "scriptminsize",
diff --git a/src/lsmmathmltableelement.c b/src/lsmmathmltableelement.c
index 4508bd3..dc76a98 100644
--- a/src/lsmmathmltableelement.c
+++ b/src/lsmmathmltableelement.c
@@ -52,7 +52,7 @@ lsm_mathml_table_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
LsmMathmlSpaceList *space_list;
LsmMathmlEnumList enum_list;
unsigned int enum_attribute;
- gboolean flag;
+/* gboolean flag;*/
enum_list.n_values = 1;
enum_list.values = &enum_attribute;
@@ -101,14 +101,14 @@ lsm_mathml_table_element_update (LsmMathmlElement *self, LsmMathmlStyle *style)
lsm_mathml_space_list_free (space_list);
- flag = FALSE;
- lsm_mathml_boolean_attribute_parse (&table->equal_rows, &flag);
+/* flag = FALSE;*/
+/* lsm_mathml_boolean_attribute_parse (&table->equal_rows, &flag);*/
- flag = FALSE;
- lsm_mathml_boolean_attribute_parse (&table->equal_columns, &flag);
+/* flag = FALSE;*/
+/* lsm_mathml_boolean_attribute_parse (&table->equal_columns, &flag);*/
- flag = FALSE;
- lsm_mathml_boolean_attribute_parse (&table->display_style, &flag);
+/* flag = FALSE;*/
+/* lsm_mathml_boolean_attribute_parse (&table->display_style, &flag);*/
}
static const LsmMathmlBbox *
@@ -435,6 +435,8 @@ lsm_mathml_table_element_new (void)
return g_object_new (LSM_TYPE_MATHML_TABLE_ELEMENT, NULL);
}
+static const gboolean equal_default = FALSE;
+
static void
lsm_mathml_table_element_init (LsmMathmlTableElement *table)
{
@@ -444,6 +446,9 @@ lsm_mathml_table_element_init (LsmMathmlTableElement *table)
table->n_columns = 0;
table->n_rows = 0;
table->line_width = 0;
+
+ table->equal_columns.value = equal_default;
+ table->equal_rows.value = equal_default;
}
static void
@@ -463,6 +468,21 @@ lsm_mathml_table_element_finalize (GObject *object)
/* LsmMathmlTableElement class */
+static const LsmAttributeInfos _attribute_infos[] = {
+ {
+ .name = "equalrows",
+ .attribute_offset = offsetof (LsmMathmlTableElement, equal_rows),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ .trait_default = &equal_default
+ },
+ {
+ .name = "equalcolumns",
+ .attribute_offset = offsetof (LsmMathmlTableElement, equal_columns),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ .trait_default = &equal_default
+ }
+};
+
static void
lsm_mathml_table_element_class_init (LsmMathmlTableElementClass *table_class)
{
@@ -482,6 +502,11 @@ lsm_mathml_table_element_class_init (LsmMathmlTableElementClass *table_class)
m_element_class->layout = lsm_mathml_table_element_layout;
m_element_class->render = lsm_mathml_table_element_render;
m_element_class->is_inferred_row = NULL;
+ m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+ lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+ G_N_ELEMENTS (_attribute_infos),
+ _attribute_infos);
m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
@@ -501,10 +526,10 @@ lsm_mathml_table_element_class_init (LsmMathmlTableElementClass *table_class)
offsetof (LsmMathmlTableElement, frame));
lsm_mathml_attribute_map_add_space_list (m_element_class->attributes, "framespacing",
offsetof (LsmMathmlTableElement, frame_spacing));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "equalrows",
- offsetof (LsmMathmlTableElement, equal_rows));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "equalcolumns",
- offsetof (LsmMathmlTableElement, equal_columns));
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "equalrows",*/
+/* offsetof (LsmMathmlTableElement, equal_rows));*/
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "equalcolumns",*/
+/* offsetof (LsmMathmlTableElement, equal_columns));*/
}
G_DEFINE_TYPE (LsmMathmlTableElement, lsm_mathml_table_element, LSM_TYPE_MATHML_ELEMENT)
diff --git a/src/lsmmathmltableelement.h b/src/lsmmathmltableelement.h
index 1fcc82e..2f96d79 100644
--- a/src/lsmmathmltableelement.h
+++ b/src/lsmmathmltableelement.h
@@ -48,6 +48,7 @@ struct _LsmMathmlTableElement {
LsmMathmlEnumListAttribute column_lines;
LsmMathmlEnumAttribute frame;
LsmMathmlSpaceListAttribute frame_spacing;
+
LsmMathmlBooleanAttribute equal_rows;
LsmMathmlBooleanAttribute equal_columns;
LsmMathmlBooleanAttribute display_style;
diff --git a/src/lsmmathmltraits.c b/src/lsmmathmltraits.c
new file mode 100644
index 0000000..e2c31a4
--- /dev/null
+++ b/src/lsmmathmltraits.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#include <lsmmathmltraits.h>
+#include <math.h>
+#include <string.h>
+
+static void
+lsm_mathml_boolean_trait_from_string (LsmTrait *abstract_trait, char *string)
+{
+ gboolean *value = (gboolean *) abstract_trait;
+
+ *value = (g_strcmp0 (string, "true") == 0);
+}
+
+static char *
+lsm_mathml_boolean_trait_to_string (LsmTrait *abstract_trait)
+{
+ gboolean *value = (gboolean *) abstract_trait;
+
+ return g_strdup_printf ("%s", *value ? "true" : "false");
+}
+
+const LsmTraitClass lsm_mathml_boolean_trait_class = {
+ .size = sizeof (gboolean),
+ .from_string = lsm_mathml_boolean_trait_from_string,
+ .to_string = lsm_mathml_boolean_trait_to_string
+};
diff --git a/src/lsmmathmltraits.h b/src/lsmmathmltraits.h
new file mode 100644
index 0000000..8295f48
--- /dev/null
+++ b/src/lsmmathmltraits.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2009 Emmanuel Pacaud
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Emmanuel Pacaud <emmanuel gnome org>
+ */
+
+#ifndef LSM_MATHML_TRAITS_H
+#define LSM_MATHML_TRAITS_H
+
+#include <lsmtraits.h>
+
+G_BEGIN_DECLS
+
+extern const LsmTraitClass lsm_mathml_boolean_trait_class;
+
+G_END_DECLS
+
+#endif
diff --git a/src/lsmmathmlunderoverelement.c b/src/lsmmathmlunderoverelement.c
index 9f0ef56..047b192 100644
--- a/src/lsmmathmlunderoverelement.c
+++ b/src/lsmmathmlunderoverelement.c
@@ -156,7 +156,8 @@ lsm_mathml_under_over_element_update_children (LsmMathmlElement *self, LsmMathml
lsm_dom_node_get_node_name (LSM_DOM_NODE (operator)));
}
- lsm_mathml_boolean_attribute_parse (&under_over->accent_under, &accent_under);
+/* lsm_mathml_boolean_attribute_parse (&under_over->accent_under, &accent_under);*/
+ lsm_mathml_boolean_attribute_inherit (&under_over->accent_under, accent_under);
if (!under_over->accent_under.value)
lsm_mathml_style_change_script_level (style, +1);
@@ -177,7 +178,8 @@ lsm_mathml_under_over_element_update_children (LsmMathmlElement *self, LsmMathml
lsm_dom_node_get_node_name (LSM_DOM_NODE (operator)));
}
- lsm_mathml_boolean_attribute_parse (&under_over->accent, &accent);
+/* lsm_mathml_boolean_attribute_parse (&under_over->accent, &accent);*/
+ lsm_mathml_boolean_attribute_inherit (&under_over->accent, accent);
if (!under_over->accent.value)
lsm_mathml_style_change_script_level (overscript_style, +1);
@@ -198,8 +200,10 @@ lsm_mathml_under_over_element_update_children (LsmMathmlElement *self, LsmMathml
}
}
- under_over->under_space = accent_under ? accent_v_space : v_space;
- under_over->over_space = accent ? accent_v_space : v_space;
+/* under_over->under_space = accent_under ? accent_v_space : v_space;*/
+/* under_over->over_space = accent ? accent_v_space : v_space;*/
+ under_over->under_space = under_over->accent_under.value ? accent_v_space : v_space;
+ under_over->over_space = under_over->accent.value ? accent_v_space : v_space;
under_over->as_script = under_over->display == LSM_MATHML_DISPLAY_INLINE && movable_limits;
@@ -444,6 +448,19 @@ lsm_mathml_under_over_element_init (LsmMathmlUnderOverElement *self)
/* LsmMathmlUnderOverElement class */
+static const LsmAttributeInfos _attribute_infos[] = {
+ {
+ .name = "accent",
+ .attribute_offset = offsetof (LsmMathmlUnderOverElement, accent),
+ .trait_class = &lsm_mathml_boolean_trait_class
+ },
+ {
+ .name = "accentunder",
+ .attribute_offset = offsetof (LsmMathmlUnderOverElement, accent_under),
+ .trait_class = &lsm_mathml_boolean_trait_class,
+ }
+};
+
static void
lsm_mathml_under_over_element_class_init (LsmMathmlUnderOverElementClass *under_over_class)
{
@@ -462,13 +479,18 @@ lsm_mathml_under_over_element_class_init (LsmMathmlUnderOverElementClass *under_
m_element_class->layout = lsm_mathml_under_over_element_layout;
m_element_class->get_embellished_core = lsm_mathml_under_over_element_get_embellished_core;
m_element_class->is_inferred_row = NULL;
+ m_element_class->attribute_manager = lsm_attribute_manager_duplicate (m_element_class->attribute_manager);
+
+ lsm_attribute_manager_add_attributes (m_element_class->attribute_manager,
+ G_N_ELEMENTS (_attribute_infos),
+ _attribute_infos);
- m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);
+/* m_element_class->attributes = lsm_mathml_attribute_map_duplicate (m_element_class->attributes);*/
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "accent",
- offsetof (LsmMathmlUnderOverElement, accent));
- lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "accentunder",
- offsetof (LsmMathmlUnderOverElement, accent_under));
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "accent",*/
+/* offsetof (LsmMathmlUnderOverElement, accent));*/
+/* lsm_mathml_attribute_map_add_attribute (m_element_class->attributes, "accentunder",*/
+/* offsetof (LsmMathmlUnderOverElement, accent_under));*/
}
G_DEFINE_TYPE (LsmMathmlUnderOverElement, lsm_mathml_under_over_element, LSM_TYPE_MATHML_ELEMENT)
diff --git a/src/lsmsvgtraits.c b/src/lsmsvgtraits.c
index e8da5bd..2f0cacc 100644
--- a/src/lsmsvgtraits.c
+++ b/src/lsmsvgtraits.c
@@ -1,5 +1,4 @@
-/* lsmdom.h
- *
+/*
* Copyright © 2009 Emmanuel Pacaud
*
* This program is free software; you can redistribute it and/or modify
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]