[lasem] mathml: notation trait for menclose
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [lasem] mathml: notation trait for menclose
- Date: Sun, 18 Jan 2015 22:21:00 +0000 (UTC)
commit 442eaf3610425c2c41b93fc73200df199cdabe08
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Sun Jan 18 23:20:40 2015 +0100
mathml: notation trait for menclose
src/lsmmathmlencloseelement.c | 20 ++++++++++++++++++++
src/lsmmathmlencloseelement.h | 2 ++
src/lsmmathmlenums.c | 35 +++++++++++++++++++++++++++++++++++
src/lsmmathmlenums.h | 25 ++++++++++++++++++++++++-
src/lsmmathmltraits.c | 24 ++++++++++++++++++++++++
src/lsmmathmltraits.h | 1 +
6 files changed, 106 insertions(+), 1 deletions(-)
---
diff --git a/src/lsmmathmlencloseelement.c b/src/lsmmathmlencloseelement.c
index 13c7d8c..285cb73 100644
--- a/src/lsmmathmlencloseelement.c
+++ b/src/lsmmathmlencloseelement.c
@@ -31,6 +31,14 @@ lsm_mathml_enclose_element_get_node_name (LsmDomNode *node)
return "menclose";
}
+static gboolean
+lsm_mathml_enclose_element_can_append_child (LsmDomNode *self, LsmDomNode *child)
+{
+ return (LSM_IS_MATHML_ELEMENT (child) &&
+ (self->first_child == NULL ||
+ self->first_child->next_sibling == NULL));
+}
+
/* LsmMathmlEncloseElement implementation */
LsmDomNode *
@@ -39,6 +47,8 @@ lsm_mathml_enclose_element_new (void)
return g_object_new (LSM_TYPE_MATHML_ENCLOSE_ELEMENT, NULL);
}
+static const LsmMathmlNotation notation_default = LSM_MATHML_NOTATION_LONGDIV;
+
static void
lsm_mathml_enclose_element_init (LsmMathmlEncloseElement *element)
{
@@ -46,12 +56,22 @@ lsm_mathml_enclose_element_init (LsmMathmlEncloseElement *element)
/* LsmMathmlEncloseElement class */
+static const LsmAttributeInfos _attribute_infos[] = {
+ {
+ .name = "notation",
+ .attribute_offset = offsetof (LsmMathmlEncloseElement, notation),
+ .trait_class = &lsm_mathml_notation_trait_class,
+ .trait_default = ¬ation_default
+ }
+};
+
static void
lsm_mathml_enclose_element_class_init (LsmMathmlEncloseElementClass *klass)
{
LsmDomNodeClass *d_node_class = LSM_DOM_NODE_CLASS (klass);
d_node_class->get_node_name = lsm_mathml_enclose_element_get_node_name;
+ d_node_class->can_append_child = lsm_mathml_enclose_element_can_append_child;
}
G_DEFINE_TYPE (LsmMathmlEncloseElement, lsm_mathml_enclose_element, LSM_TYPE_MATHML_PRESENTATION_CONTAINER)
diff --git a/src/lsmmathmlencloseelement.h b/src/lsmmathmlencloseelement.h
index 8496029..46a64f0 100644
--- a/src/lsmmathmlencloseelement.h
+++ b/src/lsmmathmlencloseelement.h
@@ -40,6 +40,8 @@ typedef struct _LsmMathmlEncloseElementClass LsmMathmlEncloseElementClass;
struct _LsmMathmlEncloseElement {
LsmMathmlPresentationContainer presentation_container;
+
+ LsmMathmlEnumAttribute notation;
};
struct _LsmMathmlEncloseElementClass {
diff --git a/src/lsmmathmlenums.c b/src/lsmmathmlenums.c
index 37aeeb5..944e54d 100644
--- a/src/lsmmathmlenums.c
+++ b/src/lsmmathmlenums.c
@@ -427,3 +427,38 @@ lsm_mathml_line_from_string (const char *string)
return lsm_enum_value_from_string (string, lsm_mathml_line_strings,
G_N_ELEMENTS (lsm_mathml_line_strings));
}
+
+static const char *lsm_mathml_notation_strings[] = {
+ "longdiv",
+ "actuarial",
+ "radical",
+ "box",
+ "roundedbox",
+ "circle",
+ "left",
+ "right",
+ "top",
+ "bottom",
+ "updiagonalstrike",
+ "downdiagonalstrike",
+ "verticalstrike",
+ "horizontalstrike",
+ "madruwb",
+ "updiagonalarrow"
+};
+
+const char *
+lsm_mathml_notation_to_string (LsmMathmlNotation notation)
+{
+ if (notation < 0 || notation > LSM_MATHML_NOTATION_UP_DIAGONAL_ARROW)
+ return NULL;
+
+ return lsm_mathml_notation_strings [notation];
+}
+
+LsmMathmlNotation
+lsm_mathml_notation_from_string (const char *string)
+{
+ return lsm_enum_value_from_string (string, lsm_mathml_notation_strings,
+ G_N_ELEMENTS (lsm_mathml_notation_strings));
+}
diff --git a/src/lsmmathmlenums.h b/src/lsmmathmlenums.h
index bdfc4d6..509e016 100644
--- a/src/lsmmathmlenums.h
+++ b/src/lsmmathmlenums.h
@@ -166,7 +166,7 @@ typedef enum {
LSM_MATHML_LINE_DASHED
} LsmMathmlLine;
-const char * lsm_mathml_line_to_string (LsmMathmlLine line);
+const char * lsm_mathml_line_to_string (LsmMathmlLine line);
LsmMathmlLine lsm_mathml_line_from_string (const char *string);
typedef enum {
@@ -176,6 +176,29 @@ typedef enum {
LSM_MATHML_SCRIPT_LEVEL_SIGN_MINUS
} LsmMathmlScriptLevelSign;
+typedef enum {
+ LSM_MATHML_NOTATION_ERROR = -1,
+ LSM_MATHML_NOTATION_LONGDIV,
+ LSM_MATHML_NOTATION_ACTUARIAL,
+ LSM_MATHML_NOTATION_RADICAL,
+ LSM_MATHML_NOTATION_BOX,
+ LSM_MATHML_NOTATION_ROUNDED_BOX,
+ LSM_MATHML_NOTATION_CIRCLE,
+ LSM_MATHML_NOTATION_LEFT,
+ LSM_MATHML_NOTATION_RIGHT,
+ LSM_MATHML_NOTATION_TOP,
+ LSM_MATHML_NOTATION_BOTTOM,
+ LSM_MATHML_NOTATION_UP_DIAGONAL_STRIKE,
+ LSM_MATHML_NOTATION_DOWN_DIAGONAL_STRIKE,
+ LSM_MATHML_NOTATION_VERTICAL_STRIKE,
+ LSM_MATHML_NOTATION_HORIZONTAL_STRIKE,
+ LSM_MATHML_NOTATION_MADRUWB,
+ LSM_MATHML_NOTATION_UP_DIAGONAL_ARROW
+} LsmMathmlNotation;
+
+const char * lsm_mathml_notation_to_string (LsmMathmlNotation notation);
+LsmMathmlNotation lsm_mathml_notation_from_string (const char *string);
+
G_END_DECLS
#endif
diff --git a/src/lsmmathmltraits.c b/src/lsmmathmltraits.c
index b4e9067..f986099 100644
--- a/src/lsmmathmltraits.c
+++ b/src/lsmmathmltraits.c
@@ -251,6 +251,30 @@ const LsmTraitClass lsm_mathml_form_trait_class = {
.to_string = lsm_mathml_form_trait_to_string
};
+static gboolean
+lsm_mathml_notation_trait_from_string (LsmTrait *abstract_trait, char *string)
+{
+ LsmMathmlNotation *value = (LsmMathmlNotation *) abstract_trait;
+
+ *value = lsm_mathml_notation_from_string (string);
+
+ return *value >= 0;
+}
+
+static char *
+lsm_mathml_notation_trait_to_string (LsmTrait *abstract_trait)
+{
+ LsmMathmlNotation *value = (LsmMathmlNotation *) abstract_trait;
+
+ return g_strdup (lsm_mathml_notation_to_string (*value));
+}
+
+const LsmTraitClass lsm_mathml_notation_trait_class = {
+ .size = sizeof (int),
+ .from_string = lsm_mathml_notation_trait_from_string,
+ .to_string = lsm_mathml_notation_trait_to_string
+};
+
typedef int (*LsmMathmlEnumFromString) (const char *string);
typedef char * (*LsmMathmlEnumToString) (unsigned int value);
diff --git a/src/lsmmathmltraits.h b/src/lsmmathmltraits.h
index 51e4ed4..65f23e2 100644
--- a/src/lsmmathmltraits.h
+++ b/src/lsmmathmltraits.h
@@ -98,6 +98,7 @@ extern const LsmTraitClass lsm_mathml_font_style_trait_class;
extern const LsmTraitClass lsm_mathml_font_weight_trait_class;
extern const LsmTraitClass lsm_mathml_variant_trait_class;
extern const LsmTraitClass lsm_mathml_form_trait_class;
+extern const LsmTraitClass lsm_mathml_notation_trait_class;
extern const LsmTraitClass lsm_mathml_row_align_list_trait_class;
extern const LsmTraitClass lsm_mathml_column_align_list_trait_class;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]