Annotation of Amaya/amaya/MathMLbuilder.c, revision 1.143
1.1 cvs 1: /*
2: *
1.110 cvs 3: * (c) COPYRIGHT MIT and INRIA, 1996-2001
1.1 cvs 4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
7:
8: /*
9: *
10: * MathMLbuilder
11: *
12: * Author: V. Quint
13: */
14:
15: #define THOT_EXPORT extern
1.4 cvs 16: #include "amaya.h"
1.25 cvs 17: #include "css.h"
1.59 cvs 18: #include "html2thot_f.h"
1.133 cvs 19: #include "HTMLactions_f.h"
1.25 cvs 20: #include "MathML.h"
21: #include "parser.h"
1.59 cvs 22: #include "styleparser_f.h"
23: #include "style.h"
24: #include "undo.h"
1.133 cvs 25: #include "Xml2thot_f.h"
1.109 cvs 26:
1.106 cvs 27: /* Define a pointer to let parser functions access the Math entity table */
28: extern XmlEntity *pMathEntityTable;
1.1 cvs 29:
30: /* mapping table of attribute values */
31: static AttrValueMapping MathMLAttrValueMappingTable[] =
32: {
1.115 cvs 33: {MathML_ATTR_accent, "true", MathML_ATTR_accent_VAL_true},
34: {MathML_ATTR_accent, "false", MathML_ATTR_accent_VAL_false},
1.46 cvs 35:
1.115 cvs 36: {MathML_ATTR_accentunder, "true", MathML_ATTR_accentunder_VAL_true},
37: {MathML_ATTR_accentunder, "false", MathML_ATTR_accentunder_VAL_false},
1.46 cvs 38:
1.115 cvs 39: {MathML_ATTR_align, "top", MathML_ATTR_align_VAL_top_},
40: {MathML_ATTR_align, "bottom", MathML_ATTR_align_VAL_bottom_},
41: {MathML_ATTR_align, "center", MathML_ATTR_align_VAL_center},
42: {MathML_ATTR_align, "baseline", MathML_ATTR_align_VAL_baseline},
43: {MathML_ATTR_align, "axis", MathML_ATTR_align_VAL_axis},
44:
45: {MathML_ATTR_bevelled, "true", MathML_ATTR_bevelled_VAL_true},
46: {MathML_ATTR_bevelled, "false", MathML_ATTR_bevelled_VAL_false},
47:
48: {MathML_ATTR_columnalign_mtd, "center", MathML_ATTR_columnalign_mtd_VAL_center_},
49: {MathML_ATTR_columnalign_mtd, "left", MathML_ATTR_columnalign_mtd_VAL_left_},
50: {MathML_ATTR_columnalign_mtd, "right", MathML_ATTR_columnalign_mtd_VAL_right_},
51:
52: {MathML_ATTR_denomalign, "center", MathML_ATTR_denomalign_VAL_center_},
53: {MathML_ATTR_denomalign, "left", MathML_ATTR_denomalign_VAL_left_},
54: {MathML_ATTR_denomalign, "right", MathML_ATTR_denomalign_VAL_right_},
55:
56: {MathML_ATTR_display, "block", MathML_ATTR_display_VAL_block},
57: {MathML_ATTR_display, "display", MathML_ATTR_display_VAL_block},
58: {MathML_ATTR_display, "inline", MathML_ATTR_display_VAL_inline_},
59:
60: {MathML_ATTR_displaystyle, "true", MathML_ATTR_displaystyle_VAL_true},
61: {MathML_ATTR_displaystyle, "false", MathML_ATTR_displaystyle_VAL_false},
62:
63: {MathML_ATTR_edge, "left", MathML_ATTR_edge_VAL_left_},
64: {MathML_ATTR_edge, "right", MathML_ATTR_edge_VAL_right_},
65:
66: {MathML_ATTR_equalcolumns, "true", MathML_ATTR_equalcolumns_VAL_true},
67: {MathML_ATTR_equalcolumns, "false", MathML_ATTR_equalcolumns_VAL_false},
68:
69: {MathML_ATTR_equalrows, "true", MathML_ATTR_equalrows_VAL_true},
70: {MathML_ATTR_equalrows, "false", MathML_ATTR_equalrows_VAL_false},
71:
72: {MathML_ATTR_fence, "true", MathML_ATTR_fence_VAL_true},
73: {MathML_ATTR_fence, "false", MathML_ATTR_fence_VAL_false},
74:
75: {MathML_ATTR_fontstyle, "italic", MathML_ATTR_fontstyle_VAL_italic},
76: {MathML_ATTR_fontstyle, "normal", MathML_ATTR_fontstyle_VAL_normal_},
77:
78: {MathML_ATTR_fontweight, "normal", MathML_ATTR_fontweight_VAL_normal_},
79: {MathML_ATTR_fontweight, "bold", MathML_ATTR_fontweight_VAL_bold_},
80:
81: {MathML_ATTR_form, "prefix", MathML_ATTR_form_VAL_prefix},
82: {MathML_ATTR_form, "infix", MathML_ATTR_form_VAL_infix},
83: {MathML_ATTR_form, "postfix", MathML_ATTR_form_VAL_postfix},
84:
85: {MathML_ATTR_frame, "none", MathML_ATTR_frame_VAL_none_},
86: {MathML_ATTR_frame, "solid", MathML_ATTR_frame_VAL_solid_},
87: {MathML_ATTR_frame, "dashed", MathML_ATTR_frame_VAL_dashed_},
88:
89: {MathML_ATTR_groupalign_malgr, "left", MathML_ATTR_groupalign_malgr_VAL_left_},
90: {MathML_ATTR_groupalign_malgr, "center", MathML_ATTR_groupalign_malgr_VAL_center_},
91: {MathML_ATTR_groupalign_malgr, "right", MathML_ATTR_groupalign_malgr_VAL_right_},
92: {MathML_ATTR_groupalign_malgr, "decimalpoint", MathML_ATTR_groupalign_malgr_VAL_decimalpoint},
93:
94: {MathML_ATTR_largeop, "true", MathML_ATTR_largeop_VAL_true},
95: {MathML_ATTR_largeop, "false", MathML_ATTR_largeop_VAL_false},
96:
97: {MathML_ATTR_linebreak_, "auto", MathML_ATTR_linebreak__VAL_auto_},
98: {MathML_ATTR_linebreak_, "newline", MathML_ATTR_linebreak__VAL_newline},
99: {MathML_ATTR_linebreak_, "indentingnewline", MathML_ATTR_linebreak__VAL_indentingnewline},
100: {MathML_ATTR_linebreak_, "nobreak", MathML_ATTR_linebreak__VAL_nobreak_},
101: {MathML_ATTR_linebreak_, "goodbreak", MathML_ATTR_linebreak__VAL_goodbreak},
102: {MathML_ATTR_linebreak_, "badbreak", MathML_ATTR_linebreak__VAL_badbreak},
103:
104: {MathML_ATTR_mathvariant, "normal", MathML_ATTR_mathvariant_VAL_normal_},
105: {MathML_ATTR_mathvariant, "bold", MathML_ATTR_mathvariant_VAL_bold_},
106: {MathML_ATTR_mathvariant, "italic", MathML_ATTR_mathvariant_VAL_italic},
107: {MathML_ATTR_mathvariant, "bold-italic", MathML_ATTR_mathvariant_VAL_bold_italic},
108: {MathML_ATTR_mathvariant, "double-struck", MathML_ATTR_mathvariant_VAL_double_struck},
109: {MathML_ATTR_mathvariant, "bold-fraktur", MathML_ATTR_mathvariant_VAL_bold_fraktur},
110: {MathML_ATTR_mathvariant, "script", MathML_ATTR_mathvariant_VAL_script},
111: {MathML_ATTR_mathvariant, "bold-script", MathML_ATTR_mathvariant_VAL_bold_script},
112: {MathML_ATTR_mathvariant, "fraktur", MathML_ATTR_mathvariant_VAL_fraktur},
113: {MathML_ATTR_mathvariant, "sans-serif", MathML_ATTR_mathvariant_VAL_sans_serif},
114: {MathML_ATTR_mathvariant, "bold-sans-serif", MathML_ATTR_mathvariant_VAL_bold_sans_serif},
115: {MathML_ATTR_mathvariant, "sans-serif-italic", MathML_ATTR_mathvariant_VAL_sans_serif_italic},
116: {MathML_ATTR_mathvariant, "sans-serif-bold-italic", MathML_ATTR_mathvariant_VAL_sans_serif_bold_italic},
117: {MathML_ATTR_mathvariant, "monospace", MathML_ATTR_mathvariant_VAL_monospace},
118:
119: {MathML_ATTR_movablelimits, "true", MathML_ATTR_movablelimits_VAL_true},
120: {MathML_ATTR_movablelimits, "false", MathML_ATTR_movablelimits_VAL_false},
121:
122: {MathML_ATTR_notation, "longdiv", MathML_ATTR_notation_VAL_longdiv},
123: {MathML_ATTR_notation, "actuarial", MathML_ATTR_notation_VAL_actuarial},
124: {MathML_ATTR_notation, "radical", MathML_ATTR_notation_VAL_radical},
125:
126: {MathML_ATTR_numalign, "center", MathML_ATTR_numalign_VAL_center_},
127: {MathML_ATTR_numalign, "left", MathML_ATTR_numalign_VAL_left_},
128: {MathML_ATTR_numalign, "right", MathML_ATTR_numalign_VAL_right_},
129:
130: {MathML_ATTR_overflow, "scroll", MathML_ATTR_overflow_VAL_scroll},
131: {MathML_ATTR_overflow, "elide", MathML_ATTR_overflow_VAL_elide},
132: {MathML_ATTR_overflow, "truncate", MathML_ATTR_overflow_VAL_truncate},
133: {MathML_ATTR_overflow, "scale", MathML_ATTR_overflow_VAL_scale_},
134:
135: {MathML_ATTR_rowalign_mtr, "top", MathML_ATTR_rowalign_mtr_VAL_top_},
136: {MathML_ATTR_rowalign_mtr, "bottom", MathML_ATTR_rowalign_mtr_VAL_bottom_},
137: {MathML_ATTR_rowalign_mtr, "center", MathML_ATTR_rowalign_mtr_VAL_center},
138: {MathML_ATTR_rowalign_mtr, "baseline", MathML_ATTR_rowalign_mtr_VAL_baseline},
139: {MathML_ATTR_rowalign_mtr, "axis", MathML_ATTR_rowalign_mtr_VAL_axis},
140:
141: {MathML_ATTR_separator, "true", MathML_ATTR_separator_VAL_true},
142: {MathML_ATTR_separator, "false", MathML_ATTR_separator_VAL_false},
143:
144: {MathML_ATTR_side, "left", MathML_ATTR_side_VAL_left_},
145: {MathML_ATTR_side, "leftoverlap", MathML_ATTR_side_VAL_leftoverlap},
146: {MathML_ATTR_side, "right", MathML_ATTR_side_VAL_right_},
147: {MathML_ATTR_side, "rightoverlap", MathML_ATTR_side_VAL_rightoverlap},
148:
149: {MathML_ATTR_stretchy, "true", MathML_ATTR_stretchy_VAL_true},
150: {MathML_ATTR_stretchy, "false", MathML_ATTR_stretchy_VAL_false},
1.46 cvs 151:
1.115 cvs 152: {MathML_ATTR_symmetric, "true", MathML_ATTR_symmetric_VAL_true},
153: {MathML_ATTR_symmetric, "false", MathML_ATTR_symmetric_VAL_false},
1.21 cvs 154:
1.115 cvs 155: {MathML_ATTR_xml_space, "default", MathML_ATTR_xml_space_VAL_xml_space_default},
156: {MathML_ATTR_xml_space, "preserve", MathML_ATTR_xml_space_VAL_xml_space_preserve},
1.73 cvs 157:
1.115 cvs 158: {0, "", 0} /* Last entry. Mandatory */
1.1 cvs 159: };
160:
161: #define MaxMsgLength 200
162:
1.12 cvs 163: #include "HTMLtable_f.h"
1.29 cvs 164: #include "Mathedit_f.h"
165: #include "styleparser_f.h"
166: #include "fetchXMLname_f.h"
1.1 cvs 167:
168: /*----------------------------------------------------------------------
169: MapMathMLAttribute
170: Search in the Attribute Mapping Table the entry for the
171: attribute of name Attr and returns the corresponding Thot attribute type.
172: ----------------------------------------------------------------------*/
1.120 cvs 173: void MapMathMLAttribute (char *attrName, AttributeType *attrType,
174: char *elementName, ThotBool *level, Document doc)
1.1 cvs 175: {
1.68 cvs 176: attrType->AttrSSchema = GetMathMLSSchema (doc);
1.91 cvs 177: MapXMLAttribute (MATH_TYPE, attrName, elementName, level, doc, &(attrType->AttrTypeNum));
1.1 cvs 178: }
179:
180: /*----------------------------------------------------------------------
181: MapMathMLAttributeValue
182: Search in the Attribute Value Mapping Table the entry for the attribute
183: ThotAtt and its value AttrVal. Returns the corresponding Thot value.
184: ----------------------------------------------------------------------*/
1.120 cvs 185: void MapMathMLAttributeValue (char *AttrVal, AttributeType attrType,
186: int *value)
1.1 cvs 187: {
1.123 cvs 188: int i;
1.1 cvs 189:
1.123 cvs 190: *value = 0;
191: i = 0;
192: while (MathMLAttrValueMappingTable[i].ThotAttr != attrType.AttrTypeNum &&
193: MathMLAttrValueMappingTable[i].ThotAttr != 0)
194: i++;
195: if (MathMLAttrValueMappingTable[i].ThotAttr == attrType.AttrTypeNum)
196: do
197: if (!strcmp (MathMLAttrValueMappingTable[i].XMLattrValue, AttrVal))
198: *value = MathMLAttrValueMappingTable[i].ThotAttrValue;
199: else
200: i++;
201: while (*value == 0 &&
202: MathMLAttrValueMappingTable[i].ThotAttr == attrType.AttrTypeNum);
1.1 cvs 203: }
204:
205: /*----------------------------------------------------------------------
206: MapMathMLEntity
207: Search that entity in the entity table and return the corresponding value.
208: ----------------------------------------------------------------------*/
1.120 cvs 209: void MapMathMLEntity (char *entityName, char *entityValue,
1.143 ! vatton 210: char *script)
1.1 cvs 211: {
212: int i;
1.67 cvs 213: ThotBool found;
1.1 cvs 214:
1.67 cvs 215: found = FALSE;
1.106 cvs 216: for (i = 0; pMathEntityTable[i].charCode >= 0 && !found; i++)
1.116 cvs 217: found = !strcmp (pMathEntityTable[i].charName, entityName);
1.67 cvs 218:
219: if (found)
220: /* entity found */
221: {
222: i--;
1.116 cvs 223: entityValue[0] = (unsigned char) pMathEntityTable[i].charCode;
1.1 cvs 224: entityValue[1] = EOS;
1.143 ! vatton 225: *script = 'G';
! 226: /* *script = pMathEntityTable[i].charScript;*/
1.67 cvs 227: }
228: else
229: {
1.1 cvs 230: entityValue[0] = EOS;
1.143 ! vatton 231: *script = EOS;
1.67 cvs 232: }
1.1 cvs 233: }
234:
235: /*----------------------------------------------------------------------
1.130 carcone 236: MathMLEntityCreated
237: ----------------------------------------------------------------------*/
238: void MathMLEntityCreated (unsigned char *entityValue, Language lang,
239: char *entityName, Document doc)
240: {
241: }
242:
243: /*----------------------------------------------------------------------
1.1 cvs 244: ElementNeedsPlaceholder
245: returns TRUE if element el needs a sibling placeholder.
246: ----------------------------------------------------------------------*/
1.18 cvs 247: ThotBool ElementNeedsPlaceholder (Element el)
1.1 cvs 248: {
249: ElementType elType;
1.138 cvs 250: Element child, parent, sibling;
1.18 cvs 251: ThotBool ret;
1.139 quint 252:
1.1 cvs 253: ret = FALSE;
254: elType = TtaGetElementType (el);
1.43 cvs 255: if (elType.ElTypeNum == MathML_EL_MS ||
1.39 cvs 256: elType.ElTypeNum == MathML_EL_MFRAC ||
1.54 cvs 257: elType.ElTypeNum == MathML_EL_BevelledMFRAC ||
1.39 cvs 258: elType.ElTypeNum == MathML_EL_MSQRT ||
259: elType.ElTypeNum == MathML_EL_MROOT ||
260: elType.ElTypeNum == MathML_EL_MSTYLE ||
261: elType.ElTypeNum == MathML_EL_MERROR ||
262: elType.ElTypeNum == MathML_EL_MPADDED ||
263: elType.ElTypeNum == MathML_EL_MPHANTOM ||
264: elType.ElTypeNum == MathML_EL_MFENCED ||
1.1 cvs 265: elType.ElTypeNum == MathML_EL_MF ||
266: elType.ElTypeNum == MathML_EL_MSUB ||
267: elType.ElTypeNum == MathML_EL_MSUP ||
1.39 cvs 268: elType.ElTypeNum == MathML_EL_MSUBSUP ||
1.1 cvs 269: elType.ElTypeNum == MathML_EL_MUNDER ||
270: elType.ElTypeNum == MathML_EL_MOVER ||
271: elType.ElTypeNum == MathML_EL_MUNDEROVER ||
1.28 cvs 272: elType.ElTypeNum == MathML_EL_MMULTISCRIPTS ||
1.39 cvs 273: elType.ElTypeNum == MathML_EL_MTABLE ||
274: elType.ElTypeNum == MathML_EL_MACTION)
1.1 cvs 275: ret = TRUE;
1.138 cvs 276: else if (elType.ElTypeNum == MathML_EL_MROW)
277: /* a mrow needs a place holder only if it's not the sole child of
278: an element such as Numerator, Denominator, RootBase, Index, etc. */
279: {
280: ret = TRUE;
281: sibling = el; TtaNextSibling (&sibling);
282: if (!sibling)
283: {
1.139 quint 284: sibling = el; TtaPreviousSibling (&sibling);
1.138 cvs 285: if (!sibling)
286: {
287: parent = TtaGetParent (el);
288: if (parent)
289: {
290: elType = TtaGetElementType (parent);
291: if (elType.ElTypeNum == MathML_EL_Numerator ||
292: elType.ElTypeNum == MathML_EL_Denominator ||
293: elType.ElTypeNum == MathML_EL_RootBase ||
294: elType.ElTypeNum == MathML_EL_Index ||
295: elType.ElTypeNum == MathML_EL_FencedExpression ||
296: elType.ElTypeNum == MathML_EL_Base ||
297: elType.ElTypeNum == MathML_EL_Subscript ||
298: elType.ElTypeNum == MathML_EL_Superscript ||
299: elType.ElTypeNum == MathML_EL_UnderOverBase ||
300: elType.ElTypeNum == MathML_EL_Underscript ||
301: elType.ElTypeNum == MathML_EL_Overscript ||
302: elType.ElTypeNum == MathML_EL_MultiscriptBase ||
303: elType.ElTypeNum == MathML_EL_MSubscript ||
304: elType.ElTypeNum == MathML_EL_MSuperscript)
305: ret = FALSE;
306: }
307: }
308: }
309: }
310: else if (elType.ElTypeNum == MathML_EL_MO)
311: /* an operator that contains a single Symbol needs a placeholder,
312: except when it is in a Base or UnderOverBase */
313: {
314: child = TtaGetFirstChild (el);
315: if (child != NULL)
1.1 cvs 316: {
1.138 cvs 317: elType = TtaGetElementType (child);
318: if (elType.ElTypeNum == MathML_EL_SYMBOL_UNIT)
319: {
1.1 cvs 320: ret = TRUE;
321: parent = TtaGetParent (el);
322: if (parent != NULL)
323: {
1.138 cvs 324: elType = TtaGetElementType (parent);
325: if (elType.ElTypeNum == MathML_EL_Base ||
326: elType.ElTypeNum == MathML_EL_UnderOverBase)
1.139 quint 327: ret = FALSE;
328: }
329: }
330: }
331: }
332: else if (elType.ElTypeNum == MathML_EL_MSPACE)
333: {
334: /* in principle mspace needs a placeholder sibling */
335: ret = TRUE;
336: /* but if it's the only child of a mstyle element, the placeholders
337: would change the height and width of the mstyle. Consider for
338: instance:
339: <mstyle background="#000099">
340: <mspace depth="2mm" width=".2in"/>
341: </mstyle> */
342: sibling = el; TtaNextSibling (&sibling);
343: if (!sibling)
344: {
345: sibling = el; TtaPreviousSibling (&sibling);
346: if (!sibling)
347: {
348: parent = TtaGetParent (el);
349: if (parent)
350: {
351: elType = TtaGetElementType (parent);
352: if (elType.ElTypeNum == MathML_EL_MSTYLE)
1.138 cvs 353: ret = FALSE;
1.1 cvs 354: }
1.138 cvs 355: }
1.1 cvs 356: }
1.138 cvs 357: }
1.1 cvs 358: return ret;
359: }
1.132 cvs 360:
1.1 cvs 361: /*----------------------------------------------------------------------
362: CreatePlaceholders
363: ----------------------------------------------------------------------*/
364: static void CreatePlaceholders (Element el, Document doc)
365: {
1.132 cvs 366: Element sibling, prev, constr, child;
367: Attribute attr;
368: ElementType elType;
369: AttributeType attrType;
370: ThotBool create, stretchableSubsup;
1.1 cvs 371:
1.55 cvs 372: if (!el)
373: return;
1.2 cvs 374: elType.ElSSchema = GetMathMLSSchema (doc);
1.1 cvs 375: prev = NULL;
376: create = TRUE;
377: sibling = el;
378: while (sibling != NULL)
379: {
380: if (!ElementNeedsPlaceholder (sibling))
381: create = FALSE;
382: else
383: {
384: if (sibling == el)
385: /* first element */
386: {
387: elType = TtaGetElementType (sibling);
388: if (elType.ElTypeNum == MathML_EL_MF)
389: /* the first element is a MF. Don't create a placeholder
390: before */
391: create = FALSE;
392: else if (elType.ElTypeNum == MathML_EL_MROW)
393: /* the first element is a MROW */
394: {
395: child = TtaGetFirstChild (sibling);
396: if (child != NULL)
397: {
398: elType = TtaGetElementType (child);
399: if (elType.ElTypeNum != MathML_EL_MF)
400: /* the first child of the MROW element is not a MF */
401: /* Don't create a placeholder before */
402: create = FALSE;
403: }
404: }
405: }
406: if (create)
407: {
408: elType.ElTypeNum = MathML_EL_Construct;
409: constr = TtaNewElement (doc, elType);
410: TtaInsertSibling (constr, sibling, TRUE, doc);
411: attrType.AttrSSchema = elType.ElSSchema;
1.22 cvs 412: attrType.AttrTypeNum = MathML_ATTR_IntPlaceholder;
1.1 cvs 413: attr = TtaNewAttribute (attrType);
414: TtaAttachAttribute (constr, attr, doc);
1.55 cvs 415: TtaSetAttributeValue (attr, MathML_ATTR_IntPlaceholder_VAL_yes_,
416: constr, doc);
1.1 cvs 417: }
418: create = TRUE;
419: }
420: prev = sibling;
421: TtaNextSibling (&sibling);
422: }
423: if (prev != NULL && create)
424: {
1.132 cvs 425: stretchableSubsup = FALSE;
1.1 cvs 426: elType = TtaGetElementType (prev);
1.95 cvs 427: /* don't insert a placeholder after the last element if it's a MF */
428: if (elType.ElTypeNum == MathML_EL_MF)
1.1 cvs 429: create = FALSE;
430: else if (elType.ElTypeNum == MathML_EL_MROW)
431: /* the last element is a MROW */
432: {
433: child = TtaGetLastChild (prev);
434: if (child != NULL)
435: {
436: elType = TtaGetElementType (child);
437: if (elType.ElTypeNum != MathML_EL_MF)
438: /* the last child of the MROW element is not a MF */
439: /* Don't create a placeholder before */
440: create = FALSE;
441: }
442: }
1.132 cvs 443: else if (elType.ElTypeNum == MathML_EL_MSUBSUP ||
444: elType.ElTypeNum == MathML_EL_MSUB ||
445: elType.ElTypeNum == MathML_EL_MSUP ||
446: elType.ElTypeNum == MathML_EL_MUNDEROVER ||
447: elType.ElTypeNum == MathML_EL_MUNDER ||
448: elType.ElTypeNum == MathML_EL_MUNDEROVER)
449: {
450: attrType.AttrSSchema = elType.ElSSchema;
451: attrType.AttrTypeNum = MathML_ATTR_IntVertStretch;
452: if (TtaGetAttribute (prev, attrType))
453: stretchableSubsup = TRUE;
454: }
455:
1.1 cvs 456: if (create)
457: {
1.132 cvs 458: if (stretchableSubsup)
459: elType.ElTypeNum = MathML_EL_Construct1;
460: else
461: elType.ElTypeNum = MathML_EL_Construct;
1.1 cvs 462: constr = TtaNewElement (doc, elType);
463: TtaInsertSibling (constr, prev, FALSE, doc);
464: attrType.AttrSSchema = elType.ElSSchema;
1.22 cvs 465: attrType.AttrTypeNum = MathML_ATTR_IntPlaceholder;
1.1 cvs 466: attr = TtaNewAttribute (attrType);
467: TtaAttachAttribute (constr, attr, doc);
1.55 cvs 468: TtaSetAttributeValue (attr, MathML_ATTR_IntPlaceholder_VAL_yes_,
469: constr, doc);
1.132 cvs 470: }
1.1 cvs 471: }
472: }
473:
474: /*----------------------------------------------------------------------
1.95 cvs 475: NextNotComment
476: Return the next sibling of element el that is not an XMLcomment element.
477: Return el itself if it's not a comment.
1.1 cvs 478: ----------------------------------------------------------------------*/
1.95 cvs 479: static void NextNotComment (Element* el, Element* prev)
1.1 cvs 480: {
481: ElementType elType;
482:
483: if (*el == NULL)
484: return;
485: elType = TtaGetElementType (*el);
1.95 cvs 486: while (*el != NULL && elType.ElTypeNum == MathML_EL_XMLcomment)
1.1 cvs 487: {
488: *prev = *el;
489: TtaNextSibling (el);
490: if (*el != NULL)
491: elType = TtaGetElementType (*el);
492: }
493: }
494:
495: /*----------------------------------------------------------------------
496: CheckMathSubExpressions
497: Children of element el should be of type type1, type2, and type3.
1.56 cvs 498: If they are not, wrap them in elements of these types.
1.124 cvs 499: If element el has too many or not enough children, return FALSE.
1.1 cvs 500: ----------------------------------------------------------------------*/
1.56 cvs 501: static ThotBool CheckMathSubExpressions (Element el, int type1, int type2, int type3, Document doc)
1.1 cvs 502: {
503: Element child, new, prev;
504: ElementType elType, childType;
1.124 cvs 505: char msgBuffer[200];
1.56 cvs 506: ThotBool result;
1.1 cvs 507:
1.56 cvs 508: result = TRUE;
1.2 cvs 509: elType.ElSSchema = GetMathMLSSchema (doc);
1.1 cvs 510: child = TtaGetFirstChild (el);
511: prev = NULL;
1.95 cvs 512: NextNotComment (&child, &prev);
1.56 cvs 513: if (type1 == 0)
1.1 cvs 514: {
1.56 cvs 515: if (child)
516: /* no child expected and there is one, error */
1.124 cvs 517: {
518: sprintf (msgBuffer, "No subexpression allowed in %s",
519: TtaGetElementTypeName (TtaGetElementType (el)));
520: XmlParseError (errorParsing, msgBuffer, 0);
521: result = FALSE;
522: }
1.56 cvs 523: }
524: else
525: if (!child)
526: /* a first child is expected and it's missing */
1.124 cvs 527: {
528: sprintf (msgBuffer, "Missing subexpression in %s",
529: TtaGetElementTypeName (TtaGetElementType (el)));
530: XmlParseError (errorParsing, msgBuffer, 0);
531: result = FALSE;
532: }
1.56 cvs 533: else
534: {
1.1 cvs 535: elType.ElTypeNum = type1;
536: childType = TtaGetElementType (child);
537: if (TtaSameTypes (childType, elType) == 0)
538: {
539: TtaRemoveTree (child, doc);
540: new = TtaNewElement (doc, elType);
541: if (prev == NULL)
542: TtaInsertFirstChild (&new, el, doc);
543: else
544: TtaInsertSibling (new, prev, FALSE, doc);
545: TtaInsertFirstChild (&child, new, doc);
546: CreatePlaceholders (child, doc);
547: child = new;
548: }
1.56 cvs 549: prev = child;
550: TtaNextSibling (&child);
1.95 cvs 551: NextNotComment (&child, &prev);
1.56 cvs 552: if (type2 == 0)
553: {
554: if (child)
555: /* this second child is not expected, error */
1.124 cvs 556: {
557: sprintf (msgBuffer, "Only 1 subexpression allowed in %s",
558: TtaGetElementTypeName (TtaGetElementType (el)));
559: XmlParseError (errorParsing, msgBuffer, 0);
560: result = FALSE;
561: }
1.56 cvs 562: }
563: else
1.1 cvs 564: {
1.56 cvs 565: if (!child)
566: /* a second child is expected and it's missing */
1.124 cvs 567: {
568: sprintf (msgBuffer, "2 subexpressions required in %s",
569: TtaGetElementTypeName (TtaGetElementType (el)));
570: XmlParseError (errorParsing, msgBuffer, 0);
571: result = FALSE;
572: }
1.56 cvs 573: else
1.1 cvs 574: {
575: elType.ElTypeNum = type2;
576: childType = TtaGetElementType (child);
577: if (TtaSameTypes (childType, elType) == 0)
578: {
579: TtaRemoveTree (child, doc);
580: new = TtaNewElement (doc, elType);
581: TtaInsertSibling (new, prev, FALSE, doc);
582: TtaInsertFirstChild (&child, new, doc);
583: CreatePlaceholders (child, doc);
584: child = new;
585: }
1.56 cvs 586: prev = child;
587: TtaNextSibling (&child);
1.95 cvs 588: NextNotComment (&child, &prev);
1.56 cvs 589: if (type3 == 0)
1.1 cvs 590: {
1.56 cvs 591: if (child)
592: /* this third child is not expected, error */
1.124 cvs 593: {
594: sprintf (msgBuffer, "Only 2 subexpressions allowed in %s",
595: TtaGetElementTypeName (TtaGetElementType (el)));
596: XmlParseError (errorParsing, msgBuffer, 0);
597: result = FALSE;
598: }
1.56 cvs 599: }
600: else
601: {
602: if (!child)
603: /* a third child is expected and it's missing */
1.124 cvs 604: {
605: sprintf (msgBuffer, "3 subexpressions required in %s",
606: TtaGetElementTypeName (TtaGetElementType (el)));
607: XmlParseError (errorParsing, msgBuffer, 0);
608: result = FALSE;
609: }
1.56 cvs 610: else
1.1 cvs 611: {
612: elType.ElTypeNum = type3;
613: childType = TtaGetElementType (child);
614: if (TtaSameTypes (childType, elType) == 0)
615: {
616: TtaRemoveTree (child, doc);
617: new = TtaNewElement (doc, elType);
618: TtaInsertSibling (new, prev, FALSE, doc);
619: TtaInsertFirstChild (&child, new, doc);
620: CreatePlaceholders (child, doc);
1.56 cvs 621: child = new;
1.1 cvs 622: }
623: }
1.56 cvs 624: prev = child;
625: TtaNextSibling (&child);
1.95 cvs 626: NextNotComment (&child, &prev);
1.56 cvs 627: if (child)
628: /* this fourth child is unexpected */
1.124 cvs 629: {
630: sprintf (msgBuffer,"Only 3 subexpressions allowed in %s",
631: TtaGetElementTypeName (TtaGetElementType (el)));
632: XmlParseError (errorParsing, msgBuffer, 0);
633: result = FALSE;
634: }
1.1 cvs 635: }
636: }
637: }
1.56 cvs 638: }
639: return result;
1.1 cvs 640: }
641:
642:
643: /*----------------------------------------------------------------------
1.22 cvs 644: SetSingleIntHorizStretchAttr
1.1 cvs 645:
1.22 cvs 646: Put a IntHorizStretch attribute on element el if it contains only
1.1 cvs 647: a MO element that is a stretchable symbol.
648: -----------------------------------------------------------------------*/
1.22 cvs 649: void SetSingleIntHorizStretchAttr (Element el, Document doc, Element* selEl)
1.1 cvs 650: {
651: Element child, sibling, textEl, symbolEl;
652: ElementType elType;
653: Attribute attr;
654: AttributeType attrType;
1.55 cvs 655: Language lang;
1.128 vatton 656: CHAR_T text[2];
1.143 ! vatton 657: char script;
1.49 cvs 658: unsigned char c;
1.128 vatton 659: int len;
1.1 cvs 660:
661: if (el == NULL)
662: return;
663: child = TtaGetFirstChild (el);
1.55 cvs 664: if (child)
1.1 cvs 665: {
666: elType = TtaGetElementType (child);
1.98 cvs 667: while (elType.ElTypeNum == MathML_EL_MROW && child)
668: /* the first child is a mrow. Look whether it contains a single
669: child of type mo */
670: {
671: child = TtaGetFirstChild (child);
672: if (child)
673: {
674: sibling = child;
675: TtaNextSibling (&sibling);
676: if (sibling == NULL)
677: /* the mrow element has a single child. Get its type */
678: elType = TtaGetElementType (child);
679: else
680: child = NULL;
681: }
682: }
683: if (elType.ElTypeNum == MathML_EL_MO && child)
1.1 cvs 684: /* the first child is a MO */
685: {
686: sibling = child;
687: TtaNextSibling (&sibling);
688: if (sibling == NULL)
689: /* there is no other child */
690: {
691: textEl = TtaGetFirstChild (child);
692: elType = TtaGetElementType (textEl);
693: if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)
1.55 cvs 694: /* the MO child contains a TEXT element */
1.1 cvs 695: {
1.128 vatton 696: len = TtaGetVolume (textEl);
1.1 cvs 697: if (len == 1)
1.123 cvs 698: /* the TEXT element contains a single character */
699: {
700: c = EOS;
701: /* get that character */
702: len = 2;
1.128 vatton 703: TtaGiveBufferContent (textEl, text, len, &lang);
1.143 ! vatton 704: script = TtaGetScript (lang);
! 705: if (script == 'L')
1.123 cvs 706: {
707: if (text[0] == '-' || text[0] == '_' ||
1.128 vatton 708: text[0] == 175)
1.123 cvs 709: /* a horizontal line in the middle of the box */
710: c = 'h';
711: }
1.143 ! vatton 712: else if (script == 'G')
1.123 cvs 713: /* a single Symbol character */
714: {
1.128 vatton 715: if (text[0] == 172)
1.123 cvs 716: c = 'L'; /* arrow left */
1.128 vatton 717: else if (text[0] == 174)
1.123 cvs 718: c = 'R'; /* arrow right */
1.128 vatton 719: else if (text[0] == 45) /* - (minus) */
1.123 cvs 720: /* a horizontal line in the middle of the box */
721: c = 'h';
1.128 vatton 722: else if (text[0] == 132)
1.123 cvs 723: c = 'o'; /* Over brace */
1.128 vatton 724: else if (text[0] == 133)
1.123 cvs 725: c = 'u'; /* Under brace */
726: }
727: if (c != EOS)
728: {
729: /* attach a IntHorizStretch attribute to the mo */
730: attrType.AttrSSchema = elType.ElSSchema;
731: attrType.AttrTypeNum = MathML_ATTR_IntHorizStretch;
732: attr = TtaNewAttribute (attrType);
733: TtaAttachAttribute (el, attr, doc);
734: TtaSetAttributeValue (attr, MathML_ATTR_IntHorizStretch_VAL_yes_, el, doc);
735: /* replace the TEXT element by a Thot SYMBOL element */
736: elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
737: symbolEl = TtaNewElement (doc, elType);
738: TtaInsertSibling (symbolEl, textEl, FALSE, doc);
739: if (selEl != NULL)
740: if (*selEl == textEl)
741: *selEl = symbolEl;
742: TtaDeleteTree (textEl, doc);
743: if (c != EOS)
744: TtaSetGraphicsShape (symbolEl, c, doc);
745: }
746: }
1.1 cvs 747: }
748: }
749: }
750: }
751: }
1.123 cvs 752:
1.1 cvs 753: /*----------------------------------------------------------------------
1.22 cvs 754: SetIntHorizStretchAttr
1.1 cvs 755:
1.22 cvs 756: Put a IntHorizStretch attribute on all children of element el which
1.1 cvs 757: contain only a MO element that is a stretchable symbol.
758: -----------------------------------------------------------------------*/
1.22 cvs 759: static void SetIntHorizStretchAttr (Element el, Document doc)
1.1 cvs 760: {
761: Element child;
762:
763: if (el == NULL)
764: return;
765: child = TtaGetFirstChild (el);
766: while (child != NULL)
767: {
1.22 cvs 768: SetSingleIntHorizStretchAttr (child, doc, NULL);
1.1 cvs 769: TtaNextSibling (&child);
770: }
771: }
772:
773: /*----------------------------------------------------------------------
1.22 cvs 774: SetIntVertStretchAttr
1.1 cvs 775:
1.22 cvs 776: Put a IntVertStretch attribute on element el if its base element
1.1 cvs 777: (Base for a MSUBSUP, MSUP or MSUB; UnderOverBase for a MUNDEROVER,
778: a MUNDER of a MOVER) contains only a MO element that is a vertically
1.132 cvs 779: stretchable symbol (integral).
1.1 cvs 780: -----------------------------------------------------------------------*/
1.22 cvs 781: void SetIntVertStretchAttr (Element el, Document doc, int base, Element* selEl)
1.1 cvs 782: {
1.132 cvs 783: Element child, sibling, textEl, symbolEl, parent, operator, next;
1.1 cvs 784: ElementType elType;
785: Attribute attr;
786: AttributeType attrType;
1.131 cvs 787: SSchema MathMLSSchema;
1.128 vatton 788: Language lang;
1.143 ! vatton 789: char script;
1.131 cvs 790: #define buflen 50
791: CHAR_T text[buflen];
1.49 cvs 792: unsigned char c;
1.131 cvs 793: int len, i;
794: ThotBool inbase, integral;
1.1 cvs 795:
796: if (el == NULL)
1.131 cvs 797: return;
1.1 cvs 798: operator = NULL;
1.131 cvs 799: inbase = FALSE;
800: MathMLSSchema = TtaGetElementType(el).ElSSchema;
801:
1.1 cvs 802: if (base == 0)
1.131 cvs 803: /* it's a MO */
804: {
805: parent = TtaGetParent (el);
806: if (parent != NULL)
1.1 cvs 807: {
1.131 cvs 808: /* don't process the mo if it is within a base. It will be processed
809: when the enclosing construct is processed (see below) */
810: elType = TtaGetElementType (parent);
811: if (elType.ElSSchema != MathMLSSchema ||
812: (elType.ElTypeNum != MathML_EL_Base &&
813: elType.ElTypeNum != MathML_EL_UnderOverBase &&
814: elType.ElTypeNum != MathML_EL_MSUBSUP &&
815: elType.ElTypeNum != MathML_EL_MSUB &&
816: elType.ElTypeNum != MathML_EL_MSUP &&
817: elType.ElTypeNum != MathML_EL_MUNDEROVER &&
818: elType.ElTypeNum != MathML_EL_MUNDER &&
819: elType.ElTypeNum != MathML_EL_MUNDEROVER))
820: operator = el;
1.1 cvs 821: }
1.131 cvs 822: }
1.1 cvs 823: else
1.131 cvs 824: /* it's not a MO */
825: {
826: /* search the Base or UnderOverBase child */
827: child = TtaGetFirstChild (el);
828: if (child != NULL)
1.1 cvs 829: {
1.131 cvs 830: elType = TtaGetElementType (child);
831: if (elType.ElTypeNum == base && elType.ElSSchema == MathMLSSchema)
832: /* the first child is a Base or UnderOverBase */
833: {
834: child = TtaGetFirstChild (child);
835: if (child != NULL)
836: {
837: elType = TtaGetElementType (child);
838: if (elType.ElTypeNum == MathML_EL_MO &&
839: elType.ElSSchema == MathMLSSchema)
840: /* its first child is a MO */
841: {
842: sibling = child;
843: TtaNextSibling (&sibling);
844: if (sibling == NULL)
845: /* there is no other child */
846: {
847: operator = child;
848: if (base == MathML_EL_Base ||
849: base == MathML_EL_UnderOverBase)
850: {
851: parent = el;
852: inbase = TRUE;
853: }
854: }
855: }
856: }
857: }
1.1 cvs 858: }
1.131 cvs 859: }
860: if (operator)
861: {
862: textEl = TtaGetFirstChild (operator);
863: if (textEl != NULL)
1.84 cvs 864: {
1.131 cvs 865: elType = TtaGetElementType (textEl);
866: if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)
867: {
868: len = TtaGetVolume (textEl);
869: if (len >= 1)
870: {
871: if (len >= buflen)
872: len = buflen-1;
873: len++;
874: TtaGiveBufferContent (textEl, text, len, &lang);
875: len --;
1.143 ! vatton 876: script = TtaGetScript (lang);
! 877: if (script == 'G')
1.131 cvs 878: /* Adobe Symbol character set */
1.55 cvs 879: {
1.131 cvs 880: integral = TRUE;
881: /* check all characters in this TEXT element */
882: for (i = 0; i < len; i++)
883: if (text[i] != 242)
884: /**** accept also other symbols like double or triple
885: integral, contour integral, etc. ****/
886: integral = FALSE;
887: if (integral)
888: /* the operator contains only integral symbols */
889: {
890: /* attach a IntVertStretch attribute */
891: attrType.AttrSSchema = MathMLSSchema;
892: attrType.AttrTypeNum = MathML_ATTR_IntVertStretch;
893: attr = TtaNewAttribute (attrType);
894: TtaAttachAttribute (el, attr, doc);
895: TtaSetAttributeValue (attr,
896: MathML_ATTR_IntVertStretch_VAL_yes_,
897: el, doc);
898: TtaRegisterAttributeCreate (attr, el, doc);
899:
900: /* replace the Integral characters by a Thot SYMBOL
901: element. If there are several such characters in
902: the mo (multiple integral), replace them too. */
903: do
904: {
905: /* replace the TEXT element by a Thot SYMBOL */
906: elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
907: elType.ElSSchema = MathMLSSchema;
908: for (i = 0; i < len; i++)
909: if (text[i] == 242)
910: {
911: symbolEl = TtaNewElement (doc, elType);
912: TtaInsertSibling (symbolEl, textEl, TRUE,doc);
913: if (selEl != NULL)
914: if (*selEl == textEl)
915: *selEl = symbolEl;
916: c = 'i';
917: TtaSetGraphicsShape (symbolEl, c, doc);
918: TtaRegisterElementCreate (symbolEl, doc);
919: }
920: TtaRegisterElementDelete (textEl, doc);
921: TtaDeleteTree (textEl, doc);
922: /* is there an other text element after the
923: integral symbol? */
924: textEl = symbolEl; TtaNextSibling (&textEl);
925: if (textEl)
926: {
927: elType = TtaGetElementType (textEl);
928: if (elType.ElTypeNum != MathML_EL_TEXT_UNIT)
929: textEl = NULL;
930: else
931: /* there is another text element.
932: Is it a single integral symbol? */
933: {
934: len = TtaGetVolume (textEl);
935: if (len < 1)
936: /* not a single character */
937: textEl = NULL;
938: else
939: {
940: if (len >= buflen)
941: len = buflen-1;
942: len++;
943: TtaGiveBufferContent (textEl, text,
944: len, &lang);
1.143 ! vatton 945: script = TtaGetScript (lang);
! 946: if (script != 'G')
! 947: /* not the right script for an
1.131 cvs 948: integral*/
949: textEl = NULL;
950: else
951: if (text[0] != 242)
952: /* not an integral symbol */
953: textEl = NULL;
954: }
955: }
956: }
957: }
958: while (textEl);
959:
960: if (inbase)
961: /* it's within a Base or UnderOverBase element */
962: {
963: sibling = parent;
964: TtaNextSibling (&sibling);
1.132 cvs 965: if (sibling)
966: /* the msubsup of munderover element has a next
967: sibling */
1.131 cvs 968: {
969: elType = TtaGetElementType (sibling);
970: if (elType.ElTypeNum == MathML_EL_Construct &&
971: elType.ElSSchema == MathMLSSchema)
1.132 cvs 972: /* the next sibling is a Construct */
1.131 cvs 973: {
1.132 cvs 974: next = sibling;
975: TtaNextSibling (&next);
976: if (!next)
977: /* there is no other sibling after the
978: Construct. Change it into Construct1*/
979: {
980: TtaRegisterElementDelete (sibling, doc);
981: TtaRemoveTree (sibling, doc);
982: ChangeElementType (sibling,
983: MathML_EL_Construct1);
984: TtaInsertSibling (sibling, parent,
985: FALSE, doc);
986: TtaRegisterElementCreate (sibling, doc);
987: /* force the msubsup element to be
988: reformatted and to take into account
989: its new next sibling */
990: TtaRemoveTree (parent, doc);
991: TtaInsertSibling (parent, sibling, TRUE,
992: doc);
993: }
1.131 cvs 994: }
995: }
996: }
997: }
1.55 cvs 998: }
1.131 cvs 999: }
1000: }
1.84 cvs 1001: }
1.131 cvs 1002: }
1.1 cvs 1003: }
1004:
1005: /*----------------------------------------------------------------------
1.22 cvs 1006: SetIntPlaceholderAttr
1.1 cvs 1007:
1.22 cvs 1008: Put a IntPlaceholder attribute on all Construct elements in the
1.1 cvs 1009: subtree of root el.
1010: -----------------------------------------------------------------------*/
1.22 cvs 1011: static void SetIntPlaceholderAttr (Element el, Document doc)
1.1 cvs 1012: {
1013: Element child;
1014: ElementType elType;
1015: Attribute attr;
1016: AttributeType attrType;
1017:
1018: if (el == NULL)
1019: return;
1020: elType = TtaGetElementType (el);
1021: if (elType.ElTypeNum == MathML_EL_Construct &&
1.2 cvs 1022: elType.ElSSchema == GetMathMLSSchema (doc))
1.1 cvs 1023: {
1024: attrType.AttrSSchema = elType.ElSSchema;
1.22 cvs 1025: attrType.AttrTypeNum = MathML_ATTR_IntPlaceholder;
1.1 cvs 1026: attr = TtaNewAttribute (attrType);
1027: TtaAttachAttribute (el, attr, doc);
1.22 cvs 1028: TtaSetAttributeValue (attr, MathML_ATTR_IntPlaceholder_VAL_yes_, el, doc);
1.1 cvs 1029: }
1030: else
1031: {
1032: child = TtaGetFirstChild (el);
1033: while (child != NULL)
1034: {
1.22 cvs 1035: SetIntPlaceholderAttr (child, doc);
1.1 cvs 1036: TtaNextSibling (&child);
1037: }
1038: }
1039: }
1040:
1041: /*----------------------------------------------------------------------
1042: BuildMultiscript
1043:
1044: The content of a MMULTISCRIPT element has been created following
1045: the original MathML structure. Create all Thot elements defined
1046: in the MathML S schema.
1047: -----------------------------------------------------------------------*/
1048: static void BuildMultiscript (Element elMMULTISCRIPT, Document doc)
1049: {
1050: Element elem, base, next, group, pair, script, prevPair, prevScript;
1051: ElementType elType, elTypeGroup, elTypePair, elTypeScript;
1.2 cvs 1052: SSchema MathMLSSchema;
1.1 cvs 1053: base = NULL;
1054: group = NULL;
1055: prevPair = NULL;
1056: prevScript = NULL;
1057:
1.2 cvs 1058: MathMLSSchema = GetMathMLSSchema (doc);
1.1 cvs 1059: elTypeGroup.ElSSchema = MathMLSSchema;
1060: elTypePair.ElSSchema = MathMLSSchema;
1061: elTypeScript.ElSSchema = MathMLSSchema;
1062:
1063: /* process all children of the MMULTISCRIPT element */
1064: elem = TtaGetFirstChild (elMMULTISCRIPT);
1065: while (elem != NULL)
1066: {
1067: /* remember the element to be processed after the current one */
1068: next = elem;
1069: TtaNextSibling (&next);
1070:
1071: /* remove the current element from the tree */
1072: TtaRemoveTree (elem, doc);
1073:
1074: if (base == NULL)
1075: /* the current element is the first child of the MMULTISCRIPT
1076: element */
1077: {
1078: /* Create a MultiscriptBase element as the first child of
1079: MMULTISCRIPT and move the current element as the first child
1080: of the MultiscriptBase element */
1081: elTypeGroup.ElTypeNum = MathML_EL_MultiscriptBase;
1082: base = TtaNewElement (doc, elTypeGroup);
1083: TtaInsertFirstChild (&base, elMMULTISCRIPT, doc);
1084: TtaInsertFirstChild (&elem, base, doc);
1085: }
1086: else
1087: /* the current element is a subscript or a superscript */
1088: {
1089: if (group == NULL)
1090: /* there is no PostscriptPairs element. Create one */
1091: {
1092: elTypeGroup.ElTypeNum = MathML_EL_PostscriptPairs;
1093: group = TtaNewElement (doc, elTypeGroup);
1094: TtaInsertSibling (group, base, FALSE, doc);
1095: elTypePair.ElTypeNum = MathML_EL_PostscriptPair;
1096: /* create a first and a last PostscriptPair as placeholders */
1.47 cvs 1097: pair = TtaNewTree (doc, elTypePair, "");
1.1 cvs 1098: TtaInsertFirstChild (&pair, group, doc);
1.22 cvs 1099: SetIntPlaceholderAttr (pair, doc);
1.1 cvs 1100: prevPair = pair;
1.47 cvs 1101: pair = TtaNewTree (doc, elTypePair, "");
1.1 cvs 1102: TtaInsertSibling (pair, prevPair, FALSE, doc);
1.22 cvs 1103: SetIntPlaceholderAttr (pair, doc);
1.1 cvs 1104: prevScript = NULL;
1105: }
1106: if (prevScript == NULL)
1107: /* the current element is the first subscript or superscript
1108: in a pair */
1109: {
1110: /* create a PostscriptPair or PrescriptPair element */
1111: pair = TtaNewElement (doc, elTypePair);
1112: if (prevPair == NULL)
1113: TtaInsertFirstChild (&pair, group, doc);
1114: else
1115: TtaInsertSibling (pair, prevPair, FALSE, doc);
1116: prevPair = pair;
1117: /* create a MSubscript element */
1118: elTypeScript.ElTypeNum = MathML_EL_MSubscript;
1119: script = TtaNewElement (doc, elTypeScript);
1120: TtaInsertFirstChild (&script, pair, doc);
1121: prevScript = script;
1122: }
1123: else
1124: /* the current element is a superscript in a pair */
1125: {
1126: /* create a MSuperscript element */
1127: elTypeScript.ElTypeNum = MathML_EL_MSuperscript;
1128: script = TtaNewElement (doc, elTypeScript);
1129: /* insert it as a sibling of the previous MSubscript element */
1130: TtaInsertSibling (script, prevScript, FALSE, doc);
1131: prevScript = NULL;
1132: }
1133: /* insert the current element as a child of the new MSuperscript or
1134: MSubscript element */
1135: TtaInsertFirstChild (&elem, script, doc);
1.22 cvs 1136: SetIntPlaceholderAttr (elem, doc);
1.1 cvs 1137: }
1138:
1139: CreatePlaceholders (elem, doc);
1140:
1141: /* get next child of the MMULTISCRIPT element */
1142: elem = next;
1143: if (elem != NULL)
1144: {
1145: elType = TtaGetElementType (elem);
1146: if (elType.ElSSchema == MathMLSSchema &&
1147: elType.ElTypeNum == MathML_EL_PrescriptPairs)
1148: /* the next element is a PrescriptPairs */
1149: {
1150: /* if there there is no PostscriptPairs element, create one as a
1151: placeholder */
1152: if (elTypeGroup.ElTypeNum != MathML_EL_PostscriptPairs)
1153: {
1154: elTypeGroup.ElTypeNum = MathML_EL_PostscriptPairs;
1.47 cvs 1155: group = TtaNewTree (doc, elTypeGroup, "");
1.1 cvs 1156: TtaInsertSibling (group, elem, TRUE, doc);
1.22 cvs 1157: SetIntPlaceholderAttr (group, doc);
1.1 cvs 1158: }
1159: /* the following elements will be interpreted as sub- superscripts
1160: in PrescriptPair elements, wich will be children of this
1161: PrescriptPairs element */
1162: elTypeGroup.ElTypeNum = MathML_EL_PrescriptPairs;
1163: elTypePair.ElTypeNum = MathML_EL_PrescriptPair;
1164: group = elem;
1165: /* create a first and a last PostscriptPair as placeholders */
1.47 cvs 1166: pair = TtaNewTree (doc, elTypePair, "");
1.1 cvs 1167: TtaInsertFirstChild (&pair, group, doc);
1.22 cvs 1168: SetIntPlaceholderAttr (pair, doc);
1.1 cvs 1169: prevPair = pair;
1.47 cvs 1170: pair = TtaNewTree (doc, elTypePair, "");
1.1 cvs 1171: TtaInsertSibling (pair, prevPair, FALSE, doc);
1.22 cvs 1172: SetIntPlaceholderAttr (pair, doc);
1.1 cvs 1173: prevScript = NULL;
1174: TtaNextSibling (&elem);
1175: }
1176: }
1177: }
1178: /* all children of element MMULTISCRIPTS have been processed */
1179: /* if the last group processed is not a PrescriptPairs element,
1180: create one as a placeholder */
1181: if (elTypeGroup.ElTypeNum != MathML_EL_PrescriptPairs && base != NULL)
1182: {
1183: elTypeGroup.ElTypeNum = MathML_EL_PrescriptPairs;
1.47 cvs 1184: elem = TtaNewTree (doc, elTypeGroup, "");
1.1 cvs 1185: if (group == NULL)
1186: group = base;
1187: TtaInsertSibling (elem, group, TRUE, doc);
1.22 cvs 1188: SetIntPlaceholderAttr (elem, doc);
1.1 cvs 1189: }
1190: }
1191:
1.39 cvs 1192: /*----------------------------------------------------------------------
1193: CreateWrapper
1194:
1195: Create an element of type wrapperType as a child of element el and
1196: move all chidren of element el within the new element.
1197: -----------------------------------------------------------------------*/
1198: static void CreateWrapper (Element el, int wrapperType, Document doc)
1199: {
1200: Element wrapper, child, prevChild, nextChild;
1201: ElementType elType;
1202:
1203: child = TtaGetFirstChild (el);
1204: elType.ElSSchema = GetMathMLSSchema (doc);
1205: elType.ElTypeNum = wrapperType;
1206: wrapper = TtaNewElement (doc, elType);
1207: TtaInsertFirstChild (&wrapper, el, doc);
1208: prevChild = NULL;
1209: while (child)
1210: {
1211: nextChild = child;
1212: TtaNextSibling (&nextChild);
1213: TtaRemoveTree (child, doc);
1214: if (prevChild == NULL)
1215: TtaInsertFirstChild (&child, wrapper, doc);
1216: else
1217: TtaInsertSibling (child, prevChild, FALSE, doc);
1218: prevChild = child;
1219: child = nextChild;
1220: }
1221: }
1.5 cvs 1222:
1223: /*----------------------------------------------------------------------
1224: CheckMTable
1225:
1226: The content of a MTABLE element has been created following
1227: the original MathML structure. Create all Thot elements defined
1228: in the MathML S schema.
1.64 cvs 1229: If placeholder, associate an attribute IntPlaceholder with all
1.103 cvs 1230: cells generated in the MathML table.
1.5 cvs 1231: -----------------------------------------------------------------------*/
1.64 cvs 1232: void CheckMTable (Element elMTABLE, Document doc, ThotBool placeholder)
1.5 cvs 1233: {
1234: ElementType elType;
1235: Element MTableHead, MTableBody, row, nextRow, el, prevRow, cell,
1.103 cvs 1236: nextCell, newMTD, firstColHead, label;
1.5 cvs 1237: SSchema MathMLSSchema;
1238:
1239: MathMLSSchema = GetMathMLSSchema (doc);
1240: row = TtaGetFirstChild (elMTABLE);
1241:
1242: /* create a MTable_head as the first child of element MTABLE */
1243: elType.ElSSchema = MathMLSSchema;
1244: elType.ElTypeNum = MathML_EL_MTable_head;
1245: MTableHead = TtaNewElement (doc, elType);
1246: TtaInsertFirstChild (&MTableHead, elMTABLE, doc);
1247: elType.ElTypeNum = MathML_EL_MColumn_head;
1.47 cvs 1248: firstColHead = TtaNewTree (doc, elType, "");
1.5 cvs 1249: TtaInsertFirstChild (&firstColHead, MTableHead, doc);
1250:
1251: /* create a MTable_body */
1252: elType.ElTypeNum = MathML_EL_MTable_body;
1253: MTableBody = TtaNewElement (doc, elType);
1254: TtaInsertSibling (MTableBody, MTableHead, FALSE, doc);
1255:
1256: /* move all children of element MTABLE into the new MTable_body element
1.103 cvs 1257: and wrap each non-MTR element in a MTR, except comments */
1.5 cvs 1258: prevRow = NULL;
1259: while (row)
1260: {
1261: nextRow = row;
1262: TtaNextSibling (&nextRow);
1263: elType = TtaGetElementType (row);
1264: TtaRemoveTree (row, doc);
1265: if (TtaSameSSchemas (elType.ElSSchema, MathMLSSchema) &&
1266: (elType.ElTypeNum == MathML_EL_XMLcomment ||
1.101 cvs 1267: elType.ElTypeNum == MathML_EL_MTR ||
1268: elType.ElTypeNum == MathML_EL_MLABELEDTR))
1.5 cvs 1269: {
1270: if (prevRow == NULL)
1271: TtaInsertFirstChild (&row, MTableBody, doc);
1272: else
1273: TtaInsertSibling (row, prevRow, FALSE, doc);
1274: prevRow = row;
1.101 cvs 1275: if (elType.ElTypeNum == MathML_EL_MTR ||
1276: elType.ElTypeNum == MathML_EL_MLABELEDTR)
1.103 cvs 1277: {
1.5 cvs 1278: cell = TtaGetFirstChild (row);
1.103 cvs 1279: if (elType.ElTypeNum == MathML_EL_MLABELEDTR)
1280: /* skip the first significant child of the mlabeledtr element */
1281: {
1282: /* skip comments first */
1283: do
1284: {
1285: elType = TtaGetElementType (cell);
1286: if (TtaSameSSchemas (elType.ElSSchema, MathMLSSchema) &&
1287: elType.ElTypeNum == MathML_EL_XMLcomment)
1288: TtaNextSibling (&cell);
1289: }
1290: while (cell && elType.ElTypeNum == MathML_EL_XMLcomment);
1291: /* skip the first element after the comments: it's a label */
1292: if (cell)
1293: {
1.105 cvs 1294: /* if it's a MTD change its type into LabelCell */
1295: if (elType.ElTypeNum == MathML_EL_MTD &&
1296: elType.ElSSchema == MathMLSSchema)
1297: ChangeElementType (cell, MathML_EL_LabelCell);
1.103 cvs 1298: /* wrap this element in a RowLabel element */
1.105 cvs 1299: /* This will allow the P schema to specify the horizontal
1300: position of the label */
1.103 cvs 1301: elType.ElSSchema = MathMLSSchema;
1302: elType.ElTypeNum = MathML_EL_RowLabel;
1303: label = TtaNewElement (doc, elType);
1304: TtaInsertSibling (label, cell, TRUE, doc);
1305: TtaRemoveTree (cell, doc);
1306: TtaInsertFirstChild (&cell, label, doc);
1307: cell = label;
1308: TtaNextSibling (&cell);
1309: }
1310: }
1311: }
1.5 cvs 1312: else
1313: cell = NULL;
1314: }
1315: else
1.103 cvs 1316: /* this child is not a MTR, MLABELEDTR, or a comment.
1317: In MathML 2.0, this in an error, but we try to recover by
1318: creating a MTR element */
1.5 cvs 1319: {
1320: elType.ElSSchema = MathMLSSchema;
1321: elType.ElTypeNum = MathML_EL_MTR;
1322: el = TtaNewElement (doc, elType);
1323: if (prevRow == NULL)
1324: TtaInsertFirstChild (&el, MTableBody, doc);
1325: else
1326: TtaInsertSibling (el, prevRow, FALSE, doc);
1327: TtaInsertFirstChild (&row, el, doc);
1328: cell = row;
1329: prevRow = el;
1330: }
1331: while (cell)
1332: /* check all children of the current MTR element */
1333: {
1334: nextCell = cell;
1335: TtaNextSibling (&nextCell);
1336: elType = TtaGetElementType (cell);
1337: if (!TtaSameSSchemas (elType.ElSSchema, MathMLSSchema) ||
1338: (elType.ElTypeNum != MathML_EL_XMLcomment &&
1339: elType.ElTypeNum != MathML_EL_MTD))
1340: /* this is not a MTD nor a comment, create a wrapping MTD */
1341: {
1342: elType.ElSSchema = MathMLSSchema;
1343: elType.ElTypeNum = MathML_EL_MTD;
1344: newMTD = TtaNewElement (doc, elType);
1345: TtaInsertSibling (newMTD, cell, TRUE, doc);
1346: TtaRemoveTree (cell, doc);
1347: TtaInsertFirstChild (&cell, newMTD, doc);
1348: cell = newMTD;
1349: }
1350: if (elType.ElTypeNum == MathML_EL_MTD)
1351: /* This is a MTD element. Wrap its contents with a CellWrapper */
1.39 cvs 1352: CreateWrapper (cell, MathML_EL_CellWrapper, doc);
1.5 cvs 1353: cell = nextCell;
1354: }
1355: row = nextRow;
1356: }
1.107 cvs 1357: CheckAllRows (elMTABLE, doc, placeholder, FALSE);
1.5 cvs 1358: }
1.12 cvs 1359:
1.46 cvs 1360: /*----------------------------------------------------------------------
1.1 cvs 1361: SetFontstyleAttr
1362: The content of a MI element has been created or modified.
1363: Create or change attribute IntFontstyle for that element accordingly.
1364: -----------------------------------------------------------------------*/
1365: void SetFontstyleAttr (Element el, Document doc)
1366: {
1367: ElementType elType;
1368: AttributeType attrType;
1369: Attribute attr, IntAttr;
1.54 cvs 1370: Element textEl;
1.1 cvs 1371: int len;
1.120 cvs 1372: char *value;
1.54 cvs 1373: ThotBool italic;
1.1 cvs 1374:
1375: if (el != NULL)
1.142 quint 1376: {
1377: /* search the fontstyle attribute */
1378: elType = TtaGetElementType (el);
1379: attrType.AttrSSchema = elType.ElSSchema;
1380: attrType.AttrTypeNum = MathML_ATTR_fontstyle;
1381: attr = TtaGetAttribute (el, attrType);
1382: attrType.AttrTypeNum = MathML_ATTR_IntFontstyle;
1383: IntAttr = TtaGetAttribute (el, attrType);
1384: if (attr != NULL)
1.1 cvs 1385: /* there is a fontstyle attribute. Remove the corresponding
1386: internal attribute that is not needed */
1387: {
1.142 quint 1388: if (IntAttr != NULL)
1389: TtaRemoveAttribute (el, IntAttr, doc);
1.1 cvs 1390: }
1.142 quint 1391: else
1.1 cvs 1392: /* there is no fontstyle attribute. Create an internal attribute
1393: IntFontstyle with a value that depends on the content of the MI */
1394: {
1.142 quint 1395: /* get content length */
1396: len = TtaGetElementVolume (el);
1397: if (len > 1)
1398: /* put an attribute IntFontstyle = IntNormal */
1399: {
1400: if (IntAttr == NULL)
1401: {
1402: IntAttr = TtaNewAttribute (attrType);
1403: TtaAttachAttribute (el, IntAttr, doc);
1404: }
1405: TtaSetAttributeValue (IntAttr,
1406: MathML_ATTR_IntFontstyle_VAL_IntNormal,
1407: el, doc);
1408: }
1409: else
1410: /* MI contains a single character. Remove attribute IntFontstyle
1411: if it exists, except if it's ImaginaryI, ExponentialE or
1412: DifferentialD */
1413: {
1414: italic = TRUE;
1415: textEl = TtaGetFirstChild (el);
1416: if (textEl != NULL)
1417: {
1418: elType = TtaGetElementType (textEl);
1419: if (elType.ElTypeNum == MathML_EL_MGLYPH)
1420: /* the content of the MI element is a MGLYPH element */
1421: /* check the length if it's alt attribute */
1422: {
1423: /* by default, use normal style */
1424: italic = FALSE;
1425: attrType.AttrTypeNum = MathML_ATTR_alt;
1426: attr = TtaGetAttribute (textEl, attrType);
1427: if (attr)
1428: /* the MGLYPH element has an alt attribute */
1429: {
1430: len = TtaGetTextAttributeLength (attr);
1431: if (len == 1)
1432: italic = TRUE;
1433: }
1434: }
1435: else
1436: {
1437: /* is there an attribute EntityName on that character? */
1438: attrType.AttrTypeNum = MathML_ATTR_EntityName;
1439: attr = TtaGetAttribute (textEl, attrType);
1440: if (attr)
1441: {
1442: len = TtaGetTextAttributeLength (attr);
1443: if (len > 0)
1444: {
1445: value = TtaGetMemory (len+1);
1446: TtaGiveTextAttributeValue (attr, value, &len);
1447: if (strcmp (&value[1], "ImaginaryI;") == 0 ||
1448: strcmp (&value[1], "ExponentialE;") == 0 ||
1449: strcmp (&value[1], "DifferentialD;") == 0)
1450: italic = FALSE;
1451: TtaFreeMemory (value);
1452: }
1453: }
1454: }
1455: if (italic)
1456: {
1457: if (IntAttr != NULL)
1458: TtaRemoveAttribute (el, IntAttr, doc);
1459: }
1460: else
1461: {
1462: /* put an attribute IntFontstyle = IntNormal */
1463: if (IntAttr == NULL)
1464: {
1465: attrType.AttrTypeNum = MathML_ATTR_IntFontstyle;
1466: IntAttr = TtaNewAttribute (attrType);
1467: TtaAttachAttribute (el, IntAttr, doc);
1468: }
1469: TtaSetAttributeValue (IntAttr,
1470: MathML_ATTR_IntFontstyle_VAL_IntNormal,
1471: el, doc);
1472: }
1473: }
1474: }
1.1 cvs 1475: }
1.142 quint 1476: }
1.1 cvs 1477: }
1478:
1479: /*----------------------------------------------------------------------
1.22 cvs 1480: SetIntAddSpaceAttr
1.1 cvs 1481: The content of a MO element has been created or modified.
1.22 cvs 1482: Create or change attribute IntAddSpace for that element accordingly.
1.1 cvs 1483: -----------------------------------------------------------------------*/
1.22 cvs 1484: void SetIntAddSpaceAttr (Element el, Document doc)
1.1 cvs 1485: {
1486: Element textEl, previous;
1487: ElementType elType;
1488: AttributeType attrType;
1.60 cvs 1489: Attribute attr, formAttr;
1490: int len, val, form;
1.1 cvs 1491: #define BUFLEN 10
1.116 cvs 1492: unsigned char text[BUFLEN];
1.1 cvs 1493: Language lang;
1.143 ! vatton 1494: char script;
1.1 cvs 1495:
1.60 cvs 1496: /* get the content of the mo element */
1.1 cvs 1497: textEl = TtaGetFirstChild (el);
1498: if (textEl != NULL)
1.60 cvs 1499: /* the mo element is not empty */
1.1 cvs 1500: {
1.60 cvs 1501: /* does the mo element have an IntAddSpace attribute? */
1.1 cvs 1502: elType = TtaGetElementType (el);
1503: attrType.AttrSSchema = elType.ElSSchema;
1.22 cvs 1504: attrType.AttrTypeNum = MathML_ATTR_IntAddSpace;
1.1 cvs 1505: attr = TtaGetAttribute (el, attrType);
1506: if (attr == NULL)
1.60 cvs 1507: /* no IntAddSpace Attr, create one */
1.1 cvs 1508: {
1509: attr = TtaNewAttribute (attrType);
1510: TtaAttachAttribute (el, attr, doc);
1511: }
1.135 cvs 1512: /* space on both sides by default */
1513: val = MathML_ATTR_IntAddSpace_VAL_both;
1.60 cvs 1514: /* does the mo element have a form attribute? */
1515: attrType.AttrTypeNum = MathML_ATTR_form;
1516: formAttr = TtaGetAttribute (el, attrType);
1517: if (formAttr)
1518: /* there is a form attribute */
1519: {
1520: form = TtaGetAttributeValue (formAttr);
1521: switch (form)
1522: {
1523: case MathML_ATTR_form_VAL_prefix:
1524: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1525: break;
1526: case MathML_ATTR_form_VAL_infix:
1527: val = MathML_ATTR_IntAddSpace_VAL_both;
1528: break;
1529: case MathML_ATTR_form_VAL_postfix:
1530: val = MathML_ATTR_IntAddSpace_VAL_spaceafter;
1531: break;
1.136 cvs 1532: default:
1533: val = MathML_ATTR_IntAddSpace_VAL_both;
1534: break;
1.60 cvs 1535: }
1536: }
1537: else
1538: /* no form attribute. Analyze the content */
1539: {
1540: len = TtaGetTextLength (textEl);
1541: if (len > 0 && len < BUFLEN)
1542: {
1543: len = BUFLEN;
1544: TtaGiveTextContent (textEl, text, &len, &lang);
1.143 ! vatton 1545: script = TtaGetScript (lang);
1.60 cvs 1546: if (len == 1)
1.99 cvs 1547: {
1.60 cvs 1548: /* the mo element contains a single character */
1.143 ! vatton 1549: if (script == 'L')
1.60 cvs 1550: /* ISO-Latin 1 character */
1551: {
1552: if (text[0] == '-')
1553: /* prefix or infix operator? */
1554: {
1555: previous = el;
1556: TtaPreviousSibling (&previous);
1557: if (previous == NULL)
1558: /* no previous sibling => prefix operator */
1559: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1560: else
1561: {
1562: elType = TtaGetElementType (previous);
1563: if (elType.ElTypeNum == MathML_EL_MO)
1564: /* after an operator => prefix operator */
1565: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1566: else
1567: /* infix operator */
1568: val = MathML_ATTR_IntAddSpace_VAL_both;
1569: }
1570: }
1.111 cvs 1571: else if (text[0] == '&' ||
1.60 cvs 1572: text[0] == '*' ||
1.111 cvs 1573: text[0] == '+' ||
1.100 cvs 1574: text[0] == '/' ||
1.60 cvs 1575: text[0] == '<' ||
1576: text[0] == '=' ||
1577: text[0] == '>' ||
1.111 cvs 1578: text[0] == '^' ||
1579: (int)text[0] == 177 || /* plus or minus */
1580: (int)text[0] == 215 || /* times */
1581: (int)text[0] == 247) /* divide */
1.60 cvs 1582: /* infix operator */
1583: val = MathML_ATTR_IntAddSpace_VAL_both;
1584: else if (text[0] == ',' ||
1.135 cvs 1585: text[0] == '!' ||
1586: text[0] == '&' ||
1587: text[0] == ':' ||
1.60 cvs 1588: text[0] == ';')
1589: /* separator */
1590: val = MathML_ATTR_IntAddSpace_VAL_spaceafter;
1.135 cvs 1591: else if (text[0] == '(' ||
1592: text[0] == ')' ||
1593: text[0] == '[' ||
1594: text[0] == ']' ||
1595: text[0] == '{' ||
1596: text[0] == '}' ||
1597: text[0] == '.' ||
1598: text[0] == '@' ||
1599: (int)text[0] == 129 || /* thin space */
1600: (int)text[0] == 130 || /* en space */
1601: (int)text[0] == 160) /* em space */
1602: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1.60 cvs 1603: }
1.143 ! vatton 1604: else if (script == 'G')
1.137 vatton 1605: {
1606: /* Symbol character set */
1607: if ((int)text[0] == 163 || /* less or equal */
1608: (int)text[0] == 177 || /* plus or minus */
1609: (int)text[0] == 179 || /* greater or equal */
1610: (int)text[0] == 180 || /* times */
1611: (int)text[0] == 184 || /* divide */
1612: (int)text[0] == 185 || /* not equal */
1613: (int)text[0] == 186 || /* identical */
1614: (int)text[0] == 187 || /* equivalent */
1615: (int)text[0] == 196 || /* circle times */
1616: (int)text[0] == 197 || /* circle plus */
1617: ((int)text[0] >= 199 && (int)text[0] <= 209) || /* */
1618: (int)text[0] == 217 || /* and */
1619: (int)text[0] == 218 ) /* or */
1620: /* infix operator */
1621: val = MathML_ATTR_IntAddSpace_VAL_both;
1622: else
1623: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1624: }
1.99 cvs 1625: }
1.60 cvs 1626: }
1627: }
1.1 cvs 1628: TtaSetAttributeValue (attr, val, el, doc);
1629: }
1630: }
1631:
1632: /*----------------------------------------------------------------------
1.58 cvs 1633: ChildOfMRowOrInferred
1634: Return TRUE if element el is a child of a MROW element or an
1635: inferred MROW element
1636: ----------------------------------------------------------------------*/
1637: ThotBool ChildOfMRowOrInferred (Element el)
1638: {
1639: ElementType elType;
1640: Element parent;
1641: ThotBool result;
1642:
1643: result = FALSE;
1644: parent = TtaGetParent (el);
1645: if (parent)
1646: {
1647: elType = TtaGetElementType (parent);
1648: result = (elType.ElTypeNum == MathML_EL_MROW ||
1649: elType.ElTypeNum == MathML_EL_SqrtBase ||
1650: elType.ElTypeNum == MathML_EL_MSTYLE ||
1651: elType.ElTypeNum == MathML_EL_MERROR ||
1.92 cvs 1652: elType.ElTypeNum == MathML_EL_MENCLOSE ||
1.58 cvs 1653: elType.ElTypeNum == MathML_EL_MPADDED ||
1654: elType.ElTypeNum == MathML_EL_MPHANTOM ||
1655: elType.ElTypeNum == MathML_EL_CellWrapper ||
1.92 cvs 1656: elType.ElTypeNum == MathML_EL_MathML ||
1.58 cvs 1657: elType.ElTypeNum == MathML_EL_FencedExpression);
1658: }
1659: return result;
1660: }
1661:
1662: /*----------------------------------------------------------------------
1.1 cvs 1663: CheckFence
1.84 cvs 1664: If el is a MO element,
1665: - if it's a large operator (∑ for instance), put a presentation
1666: rule to enlarge the character.
1667: - if it's a child of a MROW (or equivalent) element and if it contains
1668: a single fence character, transform the MO into a MF and the fence
1669: character into a Thot stretchable symbol.
1.1 cvs 1670: ----------------------------------------------------------------------*/
1.84 cvs 1671: void CheckFence (Element el, Document doc)
1.1 cvs 1672: {
1.128 vatton 1673: ElementType elType;
1674: Element content;
1675: AttributeType attrType;
1676: Attribute attr, attrStretchy;
1677: Language lang;
1.84 cvs 1678: PresentationValue pval;
1679: PresentationContext ctxt;
1.128 vatton 1680: CHAR_T text[2];
1.143 ! vatton 1681: char script;
1.128 vatton 1682: unsigned char c;
1683: int len, val;
1.1 cvs 1684:
1685: elType = TtaGetElementType (el);
1686: if (elType.ElTypeNum == MathML_EL_MO)
1.58 cvs 1687: /* the element is a MO */
1688: {
1.84 cvs 1689: content = TtaGetFirstChild (el);
1690: if (content != NULL)
1691: {
1692: elType = TtaGetElementType (content);
1693: if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)
1694: {
1.128 vatton 1695: len = TtaGetVolume (content);
1.84 cvs 1696: if (len == 1)
1697: /* the MO element contains a single character */
1698: {
1699: len = 2;
1.128 vatton 1700: TtaGiveBufferContent (content, text, len, &lang);
1.143 ! vatton 1701: script = TtaGetScript (lang);
! 1702: if ((script == 'G') &&
1.128 vatton 1703: (text[0] == 229 || text[0] == 213)) /* Sigma, Pi */
1.84 cvs 1704: /* it's a large operator */
1705: {
1706: ctxt = TtaGetSpecificStyleContext (doc);
1707: ctxt->destroy = FALSE;
1708: /* the specific presentation to be created is not a CSS rule */
1709: ctxt->cssLevel = 0;
1710: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1711: pval.typed_data.real = FALSE;
1712: pval.typed_data.value = 180;
1713: TtaSetStylePresentation (PRSize, content, NULL, ctxt, pval);
1714: }
1715: else if (ChildOfMRowOrInferred (el))
1716: /* the MO element is a child of a MROW element */
1.1 cvs 1717: {
1.143 ! vatton 1718: if (((script == 'L') &&
1.115 cvs 1719: (text[0] == '(' || text[0] == ')' ||
1720: text[0] == '[' || text[0] == ']' ||
1721: text[0] == '{' || text[0] == '}' ||
1722: text[0] == '|')) ||
1.143 ! vatton 1723: ((script == 'G') &&
1.128 vatton 1724: (text[0] == 225 || text[0] == 241)))
1.84 cvs 1725: /* it's a stretchable parenthesis or equivalent */
1726: {
1727: /* remove the content of the MO element */
1728: TtaDeleteTree (content, doc);
1729: /* change the MO element into a MF element */
1730: ChangeTypeOfElement (el, doc, MathML_EL_MF);
1.55 cvs 1731:
1.84 cvs 1732: /* is there an attribute stretchy on this mo element? */
1733: attrType.AttrSSchema = elType.ElSSchema;
1734: attrType.AttrTypeNum = MathML_ATTR_stretchy;
1735: attrStretchy = TtaGetAttribute (el, attrType);
1736: if (attrStretchy)
1737: val = TtaGetAttributeValue (attrStretchy);
1738: else
1739: val = MathML_ATTR_stretchy_VAL_true;
1740: if (val == MathML_ATTR_stretchy_VAL_true)
1741: {
1742: /* attach a IntVertStretch attribute to the MF element*/
1743: attrType.AttrTypeNum = MathML_ATTR_IntVertStretch;
1744: attr = TtaNewAttribute (attrType);
1745: TtaAttachAttribute (el, attr, doc);
1746: TtaSetAttributeValue (attr,
1747: MathML_ATTR_IntVertStretch_VAL_yes_,
1748: el, doc);
1749: }
1750: /* create a new content for the MF element */
1.87 cvs 1751: elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
1.143 ! vatton 1752: if (script == 'G' && text[0] == 241)
1.102 cvs 1753: c = '>'; /* RightAngleBracket */
1.143 ! vatton 1754: else if (script == 'G' && text[0] == 225)
1.102 cvs 1755: c = '<'; /* LeftAngleBracket */
1756: else
1757: c = (char) text[0];
1.84 cvs 1758: content = TtaNewElement (doc, elType);
1759: TtaInsertFirstChild (&content, el, doc);
1760: TtaSetGraphicsShape (content, c, doc);
1761: }
1.1 cvs 1762: }
1.84 cvs 1763: }
1764: }
1.58 cvs 1765: }
1766: }
1.1 cvs 1767: }
1768:
1769: /*----------------------------------------------------------------------
1770: CreateFencedSeparators
1771: Create FencedSeparator elements within the fencedExpression
1772: according to attribute separators of the MFENCED element.
1773: ----------------------------------------------------------------------*/
1.110 cvs 1774: void CreateFencedSeparators (Element fencedExpression, Document doc, ThotBool record)
1.1 cvs 1775: {
1776: ElementType elType;
1777: Element child, separator, leaf, next, prev, mfenced;
1778: AttributeType attrType;
1779: Attribute attr;
1780: int length, sep, i;
1781: Language lang;
1.116 cvs 1782: char text[32], sepValue[4];
1.1 cvs 1783:
1784: /* get the separators attribute */
1785: mfenced = TtaGetParent (fencedExpression);
1786: elType = TtaGetElementType (fencedExpression);
1787: attrType.AttrSSchema = elType.ElSSchema;
1788: attrType.AttrTypeNum = MathML_ATTR_separators;
1789: text[0] = ','; /* default value is sparators="," */
1790: text[1] = EOS;
1791: length = 1;
1792: attr = TtaGetAttribute (mfenced, attrType);
1793: if (attr != NULL)
1794: {
1795: length = 31;
1796: TtaGiveTextAttributeValue (attr, text, &length);
1797: }
1798:
1799: /* create FencedSeparator elements in the FencedExpression */
1800: prev = NULL;
1801: sep = 0;
1802: /* skip leading spaces in attribute separators */
1803: while (text[sep] <= SPACE && text[sep] != EOS)
1804: sep++;
1805: /* if attribute separators is empty or contains only spaces, do not
1806: insert any separator element */
1807: if (text[sep] != EOS)
1808: {
1809: child = TtaGetFirstChild (fencedExpression);
1810: while (child != NULL)
1811: {
1812: next = child;
1813: TtaNextSibling (&next);
1814: elType = TtaGetElementType (child);
1815: if (elType.ElTypeNum != MathML_EL_Construct)
1816: {
1817: if (prev != NULL)
1818: {
1819: elType.ElTypeNum = MathML_EL_FencedSeparator;
1820: separator = TtaNewElement (doc, elType);
1821: TtaInsertSibling (separator, prev, FALSE, doc);
1822: elType.ElTypeNum = MathML_EL_TEXT_UNIT;
1823: leaf = TtaNewElement (doc, elType);
1824: TtaInsertFirstChild (&leaf, separator, doc);
1825: sepValue[0] = text[sep];
1826: sepValue[1] = SPACE;
1827: sepValue[2] = EOS;
1.143 ! vatton 1828: lang = TtaGetLanguageIdFromScript('L');
1.1 cvs 1829: TtaSetTextContent (leaf, sepValue, lang, doc);
1830: /* is there a following non-space character in separators? */
1831: i = sep + 1;
1832: while (text[i] <= SPACE && text[i] != EOS)
1833: i++;
1834: if (text[i] > SPACE && text[i] != EOS)
1835: sep = i;
1.17 cvs 1836: if (record)
1837: TtaRegisterElementCreate (separator, doc);
1.1 cvs 1838: }
1839: prev = child;
1840: }
1841: child = next;
1842: }
1843: }
1844: }
1845:
1.124 cvs 1846: /*----------------------------------------------------------------------
1847: CreateOpeningOrClosingFence
1848: Create the OpeningFence or ClosingFence element (depending on parameter
1849: open) for the MFENCED element el which contain the fencedExpression
1850: element.
1851: ----------------------------------------------------------------------*/
1852: static void CreateOpeningOrClosingFence (Element fencedExpression,
1853: Element el, Document doc,
1854: ThotBool open)
1855: {
1856: ElementType elType;
1857: Element leaf, fence;
1858: AttributeType attrType;
1859: Attribute attr;
1860: int length;
1861: char text[32];
1862: char c;
1863:
1864: elType = TtaGetElementType (el);
1865: attrType.AttrSSchema = elType.ElSSchema;
1866: if (open)
1867: {
1868: c = '('; /* default value of attribute 'open' */
1869: attrType.AttrTypeNum = MathML_ATTR_open;
1870: elType.ElTypeNum = MathML_EL_OpeningFence;
1871: }
1872: else
1873: {
1874: c = ')'; /* default value of attribute 'close' */
1875: attrType.AttrTypeNum = MathML_ATTR_close;
1876: elType.ElTypeNum = MathML_EL_ClosingFence;
1877: }
1878: attr = TtaGetAttribute (el, attrType);
1879: if (attr != NULL)
1880: {
1881: length = 31;
1882: TtaGiveTextAttributeValue (attr, text, &length);
1883: if (length != 1)
1884: /* content of attribute open or close should be a single character */
1885: c = '?';
1886: else
1887: {
1.128 vatton 1888: c = text[0];
1.124 cvs 1889: /* filter characters that would represent strange symbols, such
1890: as root, integrals, arrows, etc. */
1891: if (c == 'r' || c == 'i' || c == 'c' || c == 'd' || c == 'S' ||
1892: c == 'P' || c == 'I' || c == 'U' || c == 'o' || c == 'u' ||
1893: c == 'h' || c == 'v' || c == 'R' || c == '^' || c == 'L' ||
1894: c == 'V' || c == 'D')
1895: c = '?';
1896: }
1897: }
1898: fence = TtaNewElement (doc, elType);
1899: TtaInsertSibling (fence, fencedExpression, open, doc);
1900: elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
1901: leaf = TtaNewElement (doc, elType);
1902: TtaInsertFirstChild (&leaf, fence, doc);
1903: TtaSetGraphicsShape (leaf, c, doc);
1904: }
1.1 cvs 1905:
1906: /*----------------------------------------------------------------------
1907: TransformMFENCED
1908: Transform the content of a MFENCED element: create elements
1909: OpeningFence, FencedExpression, ClosingFence and FencedSeparator.
1910: ----------------------------------------------------------------------*/
1.46 cvs 1911: static void TransformMFENCED (Element el, Document doc)
1.1 cvs 1912: {
1913: ElementType elType;
1.124 cvs 1914: Element child, fencedExpression, next, prev, firstChild;
1.1 cvs 1915:
1916: child = TtaGetFirstChild (el);
1917: if (child != NULL)
1918: elType = TtaGetElementType (child);
1919: if (child != NULL && elType.ElTypeNum == MathML_EL_OpeningFence)
1920: /* The first child of this MFENCED element is an OpeningFence.
1921: This MFENCED expression has already been transformed, possibly
1922: by the Transform command */
1923: {
1924: TtaNextSibling (&child);
1925: fencedExpression = child;
1926: if (fencedExpression != NULL)
1927: elType = TtaGetElementType (fencedExpression);
1928: if (elType.ElTypeNum == MathML_EL_FencedExpression)
1929: /* the second child is a FencedExpression. OK.
1930: Remove all existing FencedSeparator elements */
1931: {
1932: child = TtaGetFirstChild (fencedExpression);
1933: prev = NULL;
1934: while (child != NULL)
1935: {
1936: elType = TtaGetElementType (child);
1937: next = child;
1938: TtaNextSibling (&next);
1939: if (elType.ElTypeNum == MathML_EL_FencedSeparator)
1940: /* Remove this separator */
1941: TtaDeleteTree (child, doc);
1942: child = next;
1943: }
1944: /* create FencedSeparator elements in the FencedExpression */
1.17 cvs 1945: CreateFencedSeparators (fencedExpression, doc, FALSE);
1.1 cvs 1946: }
1947: }
1948: else
1949: /* this MFENCED element must be transformed */
1950: {
1951: /* create a FencedExpression element as a child of the MFENCED elem. */
1952: elType = TtaGetElementType (el);
1953: elType.ElTypeNum = MathML_EL_FencedExpression;
1954: fencedExpression = TtaNewElement (doc, elType);
1955: TtaInsertFirstChild (&fencedExpression, el, doc);
1956: if (child == NULL)
1957: /* empty MFENCED element */
1958: {
1959: elType.ElTypeNum = MathML_EL_Construct;
1960: child = TtaNewElement (doc, elType);
1961: TtaInsertFirstChild (&child, fencedExpression, doc);
1.22 cvs 1962: SetIntPlaceholderAttr (child, doc);
1.1 cvs 1963: }
1964: else
1965: {
1966: /* move the content of the MFENCED element within the new
1967: FencedExpression element */
1968: prev = NULL;
1969: firstChild = NULL;
1970: while (child != NULL)
1971: {
1972: next = child;
1973: TtaNextSibling (&next);
1974: TtaRemoveTree (child, doc);
1975: if (prev == NULL)
1976: {
1977: TtaInsertFirstChild (&child, fencedExpression, doc);
1978: firstChild = child;
1979: }
1980: else
1981: TtaInsertSibling (child, prev, FALSE, doc);
1982: prev = child;
1983: child = next;
1984: }
1985:
1986: /* create FencedSeparator elements in the FencedExpression */
1.17 cvs 1987: CreateFencedSeparators (fencedExpression, doc, FALSE);
1.1 cvs 1988:
1989: /* Create placeholders within the FencedExpression element */
1990: CreatePlaceholders (firstChild, doc);
1991: }
1992:
1993: /* create the OpeningFence element according to the open attribute */
1.124 cvs 1994: CreateOpeningOrClosingFence (fencedExpression, el, doc, TRUE);
1.1 cvs 1995:
1996: /* create the ClosingFence element according to close attribute */
1.124 cvs 1997: CreateOpeningOrClosingFence (fencedExpression, el, doc, FALSE);
1.1 cvs 1998: }
1999: }
2000:
2001: /*----------------------------------------------------------------------
1.59 cvs 2002: MathMLScriptShift
2003: The MathML attribute attr (superscriptshift or subscriptshift) is associated
2004: with element el (a msub, msup or msubsup).
2005: If value is not NULL, generate the corresponding Thot VertPos rule for the
2006: Subscript or Superscript child of el.
2007: If value is NULL, remove the Thot VertPos rule.
2008: -----------------------------------------------------------------------*/
1.120 cvs 2009: void MathMLScriptShift (Document doc, Element el, char *value, int attr)
1.59 cvs 2010: {
2011: ElementType elType;
2012: Element script, child;
2013: int scrType;
2014: PresentationValue pval;
2015: PresentationContext ctxt;
2016:
2017: /* get the Superscript or Subscript child of el */
2018: if (attr == MathML_ATTR_superscriptshift)
2019: scrType = MathML_EL_Superscript;
2020: else if (attr == MathML_ATTR_subscriptshift)
2021: scrType = MathML_EL_Subscript;
2022: else
2023: return;
2024: script = NULL;
2025: child = TtaGetFirstChild (el);
2026: while (!script && child)
2027: {
2028: elType = TtaGetElementType (child);
2029: if (elType.ElTypeNum == scrType)
2030: script = child;
2031: else
2032: TtaNextSibling (&child);
2033: }
2034: if (script)
2035: /* Superscript or Subscript element found */
2036: {
2037: ctxt = TtaGetSpecificStyleContext (doc);
2038: if (!value)
2039: /* remove the presentation rule */
2040: {
2041: ctxt->destroy = TRUE;
1.75 cvs 2042: pval.typed_data.value = 0;
1.59 cvs 2043: TtaSetStylePresentation (PRVertPos, script, NULL, ctxt, pval);
2044: }
2045: else
2046: {
2047: ctxt->destroy = FALSE;
2048: /* parse the attribute value (a number followed by a unit) */
1.119 cvs 2049: value = TtaSkipBlanks (value);
1.59 cvs 2050: value = ParseCSSUnit (value, &pval);
2051: if (pval.typed_data.unit != STYLE_UNIT_INVALID)
2052: {
1.78 cvs 2053: /* the specific presentation to be created is not a CSS rule */
2054: ctxt->cssLevel = 0;
1.59 cvs 2055: if (attr == MathML_ATTR_superscriptshift)
2056: pval.typed_data.value = - pval.typed_data.value;
2057: TtaSetStylePresentation (PRVertPos, script, NULL, ctxt, pval);
2058: }
2059: }
2060: TtaFreeMemory (ctxt);
2061: }
2062: }
2063:
2064: /*----------------------------------------------------------------------
2065: SetScriptShift
2066: If element el (which is a msup, msub or msubsup) has an attribute
2067: att (which is subscriptshift or superscriptshift), generate the
2068: corresponding Thot presentation rule.
2069: ----------------------------------------------------------------------*/
1.120 cvs 2070: static void SetScriptShift (Element el, Document doc, int att)
1.59 cvs 2071: {
2072: AttributeType attrType;
2073: ElementType elType;
2074: Attribute attr;
1.120 cvs 2075: char *value;
1.59 cvs 2076: int length;
2077:
2078: elType = TtaGetElementType (el);
2079: attrType.AttrSSchema = elType.ElSSchema;
2080: attrType.AttrTypeNum = att;
2081: attr = TtaGetAttribute (el, attrType);
2082: if (attr)
2083: {
2084: length = TtaGetTextAttributeLength (attr);
2085: if (length > 0)
2086: {
1.116 cvs 2087: value = TtaGetMemory (length+1);
1.59 cvs 2088: value[0] = EOS;
2089: TtaGiveTextAttributeValue (attr, value, &length);
2090: MathMLScriptShift (doc, el, value, att);
2091: TtaFreeMemory (value);
2092: }
2093: }
2094: }
2095:
2096: /*----------------------------------------------------------------------
1.1 cvs 2097: MathMLElementComplete
2098: Check the Thot structure of the MathML element el.
2099: ----------------------------------------------------------------------*/
1.56 cvs 2100: void MathMLElementComplete (Element el, Document doc, int *error)
1.1 cvs 2101: {
1.74 cvs 2102: ElementType elType, parentType;
1.1 cvs 2103: Element child, parent, new, prev, next;
1.101 cvs 2104: AttributeType attrType;
2105: Attribute attr;
1.56 cvs 2106: SSchema MathMLSSchema;
2107: ThotBool ok;
1.1 cvs 2108:
1.56 cvs 2109: ok = TRUE;
2110: *error = 0;
1.1 cvs 2111: elType = TtaGetElementType (el);
1.2 cvs 2112: MathMLSSchema = GetMathMLSSchema (doc);
1.1 cvs 2113:
1.76 cvs 2114: if (elType.ElSSchema == MathMLSSchema)
1.1 cvs 2115: {
2116: switch (elType.ElTypeNum)
2117: {
1.76 cvs 2118: case MathML_EL_MathML:
2119: /* Create placeholders within the MathML element */
2120: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.132 cvs 2121: break;
1.1 cvs 2122: case MathML_EL_MI:
2123: SetFontstyleAttr (el, doc);
2124: break;
2125: case MathML_EL_MO:
1.22 cvs 2126: SetIntAddSpaceAttr (el, doc);
2127: SetIntVertStretchAttr (el, doc, 0, NULL);
1.58 cvs 2128: /* if the MO element is a child of a MROW (or equivalent) and if it
2129: contains a fence character, transform this MO into MF and
2130: transform the fence character into a Thot SYMBOL */
2131: CheckFence (el, doc);
1.1 cvs 2132: break;
1.60 cvs 2133: case MathML_EL_MSPACE:
2134: break;
1.39 cvs 2135: case MathML_EL_MROW:
1.55 cvs 2136: /* Create placeholders within the MROW */
2137: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.39 cvs 2138: break;
2139: case MathML_EL_MFRAC:
1.54 cvs 2140: case MathML_EL_BevelledMFRAC:
1.39 cvs 2141: /* end of a fraction. Create a Numerator and a Denominator */
1.56 cvs 2142: ok = CheckMathSubExpressions (el, MathML_EL_Numerator,
2143: MathML_EL_Denominator, 0, doc);
1.39 cvs 2144: break;
2145: case MathML_EL_MSQRT:
1.50 cvs 2146: /* end of a Square Root */
2147: /* Create placeholders within the element */
2148: CreatePlaceholders (TtaGetFirstChild (el), doc);
2149: /* Create a SqrtBase that contains all children of the MSQRT */
1.39 cvs 2150: CreateWrapper (el, MathML_EL_SqrtBase, doc);
2151: break;
1.1 cvs 2152: case MathML_EL_MROOT:
2153: /* end of a Root. Create a RootBase and an Index */
1.56 cvs 2154: ok = CheckMathSubExpressions (el, MathML_EL_RootBase,
2155: MathML_EL_Index, 0, doc);
1.1 cvs 2156: break;
1.50 cvs 2157: case MathML_EL_MENCLOSE:
2158: /* Create placeholders within the element */
2159: CreatePlaceholders (TtaGetFirstChild (el), doc);
2160: break;
1.39 cvs 2161: case MathML_EL_MSTYLE:
2162: case MathML_EL_MERROR:
2163: case MathML_EL_MPADDED:
2164: case MathML_EL_MPHANTOM:
2165: /* Create placeholders within the element */
2166: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.1 cvs 2167: break;
2168: case MathML_EL_MFENCED:
2169: TransformMFENCED (el, doc);
2170: break;
2171: case MathML_EL_MSUB:
2172: /* end of a MSUB. Create Base and Subscript */
1.56 cvs 2173: ok = CheckMathSubExpressions (el, MathML_EL_Base,
2174: MathML_EL_Subscript, 0, doc);
1.59 cvs 2175: SetScriptShift (el, doc, MathML_ATTR_subscriptshift);
1.22 cvs 2176: SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1 cvs 2177: break;
2178: case MathML_EL_MSUP:
2179: /* end of a MSUP. Create Base and Superscript */
1.56 cvs 2180: ok = CheckMathSubExpressions (el, MathML_EL_Base,
2181: MathML_EL_Superscript, 0, doc);
1.59 cvs 2182: SetScriptShift (el, doc, MathML_ATTR_superscriptshift);
1.22 cvs 2183: SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1 cvs 2184: break;
1.39 cvs 2185: case MathML_EL_MSUBSUP:
2186: /* end of a MSUBSUP. Create Base, Subscript, and Superscript */
1.56 cvs 2187: ok = CheckMathSubExpressions (el, MathML_EL_Base,
2188: MathML_EL_Subscript,
2189: MathML_EL_Superscript, doc);
1.59 cvs 2190: SetScriptShift (el, doc, MathML_ATTR_subscriptshift);
2191: SetScriptShift (el, doc, MathML_ATTR_superscriptshift);
1.39 cvs 2192: SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1 cvs 2193: break;
2194: case MathML_EL_MUNDER:
2195: /* end of a MUNDER. Create UnderOverBase, and Underscript */
1.56 cvs 2196: ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
2197: MathML_EL_Underscript, 0, doc);
1.22 cvs 2198: SetIntHorizStretchAttr (el, doc);
2199: SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
1.1 cvs 2200: break;
2201: case MathML_EL_MOVER:
2202: /* end of a MOVER. Create UnderOverBase, and Overscript */
1.56 cvs 2203: ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
2204: MathML_EL_Overscript, 0, doc);
1.22 cvs 2205: SetIntHorizStretchAttr (el, doc);
2206: SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
1.1 cvs 2207: break;
1.39 cvs 2208: case MathML_EL_MUNDEROVER:
2209: /* end of a MUNDEROVER. Create UnderOverBase, Underscript, and
2210: Overscript */
1.56 cvs 2211: ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
2212: MathML_EL_Underscript,
2213: MathML_EL_Overscript, doc);
1.39 cvs 2214: SetIntHorizStretchAttr (el, doc);
2215: SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
2216: break;
1.1 cvs 2217: case MathML_EL_MMULTISCRIPTS:
2218: /* end of a MMULTISCRIPTS. Create all elements defined in the
2219: MathML S schema */
2220: BuildMultiscript (el, doc);
1.5 cvs 2221: break;
2222: case MathML_EL_MTABLE:
2223: /* end of a MTABLE. Create all elements defined in the MathML S
2224: schema */
1.64 cvs 2225: CheckMTable (el, doc, TRUE);
1.101 cvs 2226: /* if the table has a rowalign attribute, process it */
2227: attrType.AttrSSchema = MathMLSSchema;
2228: attrType.AttrTypeNum = MathML_ATTR_rowalign;
2229: attr = TtaGetAttribute (el, attrType);
2230: if (attr)
2231: HandleRowalignAttribute (attr, el, doc, FALSE);
2232: /* if the table has a columnalign attribute, process it */
2233: attrType.AttrTypeNum = MathML_ATTR_columnalign;
2234: attr = TtaGetAttribute (el, attrType);
2235: if (attr)
1.108 cvs 2236: HandleColalignAttribute (attr, el, doc, FALSE, FALSE);
1.101 cvs 2237: break;
2238: case MathML_EL_MTR:
2239: /* if the row has a columnalign attribute, process it */
2240: attrType.AttrSSchema = MathMLSSchema;
2241: attrType.AttrTypeNum = MathML_ATTR_columnalign;
2242: attr = TtaGetAttribute (el, attrType);
2243: if (attr)
1.108 cvs 2244: HandleColalignAttribute (attr, el, doc, FALSE, TRUE);
1.101 cvs 2245: break;
2246: case MathML_EL_MLABELEDTR:
2247: /* if the row has a columnalign attribute, process it */
2248: attrType.AttrSSchema = MathMLSSchema;
2249: attrType.AttrTypeNum = MathML_ATTR_columnalign;
2250: attr = TtaGetAttribute (el, attrType);
2251: if (attr)
1.108 cvs 2252: HandleColalignAttribute (attr, el, doc, FALSE, TRUE);
1.1 cvs 2253: break;
1.39 cvs 2254: case MathML_EL_MTD:
2255: /* Create placeholders within the table cell */
2256: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.46 cvs 2257: break;
1.39 cvs 2258: case MathML_EL_MACTION:
2259: /* Create placeholders within the MACTION element */
2260: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.1 cvs 2261: break;
2262: default:
2263: break;
2264: }
2265: parent = TtaGetParent (el);
1.118 cvs 2266: if (parent)
2267: {
2268: parentType = TtaGetElementType (parent);
2269: if (parentType.ElSSchema != elType.ElSSchema)
2270: /* root of a MathML tree, Create a MathML element if there is no */
2271: if (elType.ElTypeNum != MathML_EL_MathML)
2272: {
2273: elType.ElSSchema = MathMLSSchema;
2274: elType.ElTypeNum = MathML_EL_MathML;
2275: new = TtaNewElement (doc, elType);
2276: TtaInsertSibling (new, el, TRUE, doc);
2277: next = el;
2278: TtaNextSibling (&next);
2279: TtaRemoveTree (el, doc);
2280: TtaInsertFirstChild (&el, new, doc);
2281: prev = el;
2282: while (next != NULL)
2283: {
2284: child = next;
2285: TtaNextSibling (&next);
2286: TtaRemoveTree (child, doc);
2287: TtaInsertSibling (child, prev, FALSE, doc);
2288: prev = child;
2289: }
2290: /* Create placeholders within the MathML element */
2291: CreatePlaceholders (el, doc);
2292: }
2293: }
1.1 cvs 2294: }
1.56 cvs 2295: if (!ok)
2296: /* send an error message */
2297: *error = 1;
1.1 cvs 2298: }
2299:
2300: /*----------------------------------------------------------------------
1.126 cvs 2301: UnknownMathMLNameSpace
2302: Create an element that belongs to a non-supported namespace
2303: ----------------------------------------------------------------------*/
2304: void UnknownMathMLNameSpace (ParserData *context, char* content)
2305: {
2306: ElementType elType;
2307: Element elInv, elText;
2308:
2309: /* Create a new Invalid_element */
2310: elType.ElSSchema = GetXMLSSchema (MATH_TYPE, context->doc);
2311: elType.ElTypeNum = MathML_EL_Unknown_namespace;
2312: elInv = TtaNewElement (context->doc, elType);
2313: if (elInv != NULL)
2314: {
2315: XmlSetElemLineNumber (elInv);
2316: InsertXmlElement (&elInv);
2317: context->lastElementClosed = TRUE;
2318: elType.ElTypeNum = MathML_EL_TEXT_UNIT;
2319: elText = TtaNewElement (context->doc, elType);
2320: XmlSetElemLineNumber (elText);
2321: TtaInsertFirstChild (&elText, elInv, context->doc);
2322: TtaSetTextContent (elText, content, context->language, context->doc);
2323: TtaSetAccessRight (elText, ReadOnly, context->doc);
2324: }
2325: }
2326:
2327: /*----------------------------------------------------------------------
1.24 cvs 2328: SetFontfamily
2329: -----------------------------------------------------------------------*/
1.120 cvs 2330: void SetFontfamily (Document doc, Element el, char *value)
1.24 cvs 2331: {
2332: #define buflen 50
1.116 cvs 2333: char css_command[buflen+20];
1.24 cvs 2334:
1.116 cvs 2335: sprintf (css_command, "font-family: %s", value);
1.72 cvs 2336: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.24 cvs 2337: }
2338:
2339: /*----------------------------------------------------------------------
1.83 cvs 2340: MathMLlinethickness
2341: The MathML attribute linthickness is associated with element el. Generate
2342: the corresponding style property for this element.
2343: -----------------------------------------------------------------------*/
1.120 cvs 2344: void MathMLlinethickness (Document doc, Element el, char *value)
1.83 cvs 2345: {
2346: #define buflen 50
1.116 cvs 2347: char css_command[buflen+20];
1.83 cvs 2348:
1.116 cvs 2349: if (strcmp (value, "thin") == 0)
2350: strcpy (value, "1pt");
2351: else if (strcmp (value, "medium") == 0)
2352: strcpy (value, "1pt");
2353: else if (strcmp (value, "thick") == 0)
2354: strcpy (value, "2pt");
2355: sprintf (css_command, "stroke-width: %s", value);
1.83 cvs 2356: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
2357: }
2358:
2359: /*----------------------------------------------------------------------
1.58 cvs 2360: MathMLAttrToStyleProperty
2361: The MathML attribute attr is associated with element el. Generate
2362: the corresponding style property for this element.
1.24 cvs 2363: -----------------------------------------------------------------------*/
1.138 cvs 2364: void MathMLAttrToStyleProperty (Document doc, Element el, char *value,
2365: int attr)
1.24 cvs 2366: {
1.116 cvs 2367: char css_command[buflen+20];
1.141 quint 2368: int i;
1.58 cvs 2369:
2370: switch (attr)
2371: {
2372: case MathML_ATTR_fontsize:
1.116 cvs 2373: sprintf (css_command, "font-size: %s", value);
1.58 cvs 2374: break;
1.93 cvs 2375: case MathML_ATTR_mathsize:
1.116 cvs 2376: if (strcmp (value, "small") == 0)
2377: strcpy (value, "80%");
2378: else if (strcmp (value, "normal") == 0)
2379: strcpy (value, "100%");
2380: else if (strcmp (value, "big") == 0)
2381: strcpy (value, "125%");
2382: sprintf (css_command, "font-size: %s", value);
1.93 cvs 2383: break;
1.58 cvs 2384: case MathML_ATTR_lspace:
2385: case MathML_ATTR_rspace:
1.141 quint 2386: if (attr == MathML_ATTR_lspace)
2387: strcpy (css_command, "padding-left: ");
2388: else
2389: strcpy (css_command, "padding-right: ");
2390: /* is the value a named space? */
2391: if (strcmp (value, "veryverythinmathspace") == 0)
2392: strcat (css_command, "0.0555556em");
2393: else if (strcmp (value, "verythinmathspace") == 0)
2394: strcat (css_command, "0.111111em");
2395: else if (strcmp (value, "thinmathspace") == 0)
2396: strcat (css_command, "0.166667em");
2397: else if (strcmp (value, "mediummathspace") == 0)
2398: strcat (css_command, "0.222222em");
2399: else if (strcmp (value, "thickmathspace") == 0)
2400: strcat (css_command, "0.277778em");
2401: else if (strcmp (value, "verythickmathspace") == 0)
2402: strcat (css_command, "0.333333em");
2403: else if (strcmp (value, "veryverythickmathspace") == 0)
2404: strcat (css_command, "0.388889em");
2405: else
2406: {
2407: strcat (css_command, value);
2408: /* does the value contain an unit at the end? */
2409: i = strlen (value) - 1;
2410: if ((value[i] <= '9' && value[i] >= '0') ||
2411: value[i] == '.')
2412: /* it's just a number. Add the (implicit) unit: em */
2413: strcat (css_command, "em");
2414: }
1.58 cvs 2415: break;
2416: }
1.72 cvs 2417: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.24 cvs 2418: }
2419:
2420: /*----------------------------------------------------------------------
1.60 cvs 2421: MathMLSetScriptLevel
2422: A scriptlevel attribute with value value is associated with element el.
2423: Generate the corresponding style property for this element.
2424: -----------------------------------------------------------------------*/
1.120 cvs 2425: void MathMLSetScriptLevel (Document doc, Element el, char *value)
1.60 cvs 2426: {
2427: PresentationValue pval;
2428: PresentationContext ctxt;
2429: ThotBool relative;
2430: int percentage;
2431:
2432: ctxt = TtaGetSpecificStyleContext (doc);
2433: if (!value)
2434: /* remove the presentation rule */
2435: {
2436: ctxt->destroy = TRUE;
1.75 cvs 2437: pval.typed_data.value = 0;
1.60 cvs 2438: TtaSetStylePresentation (PRSize, el, NULL, ctxt, pval);
2439: }
2440: else
2441: {
2442: ctxt->destroy = FALSE;
2443: /* parse the attribute value (an optional sign and an integer) */
1.119 cvs 2444: value = TtaSkipBlanks (value);
1.60 cvs 2445: relative = (value[0] == '-' || value[0] == '+');
2446: value = ParseCSSUnit (value, &pval);
2447: if (pval.typed_data.unit != STYLE_UNIT_REL &&
2448: pval.typed_data.real)
2449: /* this is an error: it should be an integer without any unit name */
2450: /* error */;
2451: else
2452: {
2453: if (relative)
2454: {
1.63 cvs 2455: percentage = 100;
1.60 cvs 2456: if (pval.typed_data.value == 0)
2457: /* scriptlevel="+0" */
2458: percentage = 100;
2459: else if (pval.typed_data.value == 1)
2460: /* scriptlevel="+1" */
2461: percentage = 71;
2462: else if (pval.typed_data.value == 2)
2463: /* scriptlevel="+2" */
2464: percentage = 50;
2465: else if (pval.typed_data.value >= 3)
2466: /* scriptlevel="+3" or more */
2467: percentage = 35;
2468: else if (pval.typed_data.value == -1)
2469: /* scriptlevel="-1" */
2470: percentage = 141;
2471: else if (pval.typed_data.value == -2)
2472: /* scriptlevel="-2" */
2473: percentage = 200;
2474: else if (pval.typed_data.value <= -3)
2475: /* scriptlevel="-3" or less */
2476: percentage = 282;
2477: pval.typed_data.value = percentage;
2478: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1.78 cvs 2479: /* the specific presentation to be created is not a CSS rule */
2480: ctxt->cssLevel = 0;
1.60 cvs 2481: TtaSetStylePresentation (PRSize, el, NULL, ctxt, pval);
2482: }
2483: else
2484: /* absolute value */
2485: {
2486: /**** ****/;
2487: }
2488: }
2489: }
2490: TtaFreeMemory (ctxt);
2491: }
2492:
2493: /*----------------------------------------------------------------------
2494: MathMLSpacingAttr
2495: The MathML attribute attr (height, width or depth) is associated
2496: with element el (a mspace or mpadding).
2497: If value is not NULL, generate the corresponding Thot presentation rule for
2498: the element.
2499: If value is NULL, remove the corresponding Thot presentation rule.
2500: -----------------------------------------------------------------------*/
1.120 cvs 2501: void MathMLSpacingAttr (Document doc, Element el, char *value, int attr)
1.60 cvs 2502: {
2503: ElementType elType;
2504: PresentationValue pval;
2505: PresentationContext ctxt;
2506: int ruleType;
2507:
2508: /* provisionally, handles only mspace elements */
2509: elType = TtaGetElementType (el);
1.96 cvs 2510: if (elType.ElTypeNum != MathML_EL_MSPACE &&
1.97 cvs 2511: elType.ElTypeNum != MathML_EL_MPADDED &&
2512: elType.ElTypeNum != MathML_EL_MTABLE)
1.60 cvs 2513: return;
2514: switch (attr)
2515: {
2516: case MathML_ATTR_width_:
2517: ruleType = PRWidth;
2518: break;
2519: case MathML_ATTR_height_:
2520: ruleType = PRPaddingTop;
2521: break;
2522: case MathML_ATTR_depth_:
2523: ruleType = PRPaddingBottom;
2524: break;
2525: default:
2526: return;
2527: }
2528: ctxt = TtaGetSpecificStyleContext (doc);
1.116 cvs 2529: if (!value || (strcmp (value, "auto") == 0))
1.60 cvs 2530: /* remove the presentation rule */
2531: {
2532: ctxt->destroy = TRUE;
1.75 cvs 2533: pval.typed_data.value = 0;
1.60 cvs 2534: TtaSetStylePresentation (ruleType, el, NULL, ctxt, pval);
2535: }
2536: else
2537: {
2538: ctxt->destroy = FALSE;
2539: /* parse the attribute value (a number followed by a unit) */
1.119 cvs 2540: value = TtaSkipBlanks (value);
1.60 cvs 2541: value = ParseCSSUnit (value, &pval);
2542: /***** we should accept namedspace for width *****/
2543: if (pval.typed_data.unit != STYLE_UNIT_INVALID)
1.78 cvs 2544: {
2545: /* the specific presentation to be created is not a CSS rule */
2546: ctxt->cssLevel = 0;
2547: TtaSetStylePresentation (ruleType, el, NULL, ctxt, pval);
2548: }
1.60 cvs 2549: }
2550: TtaFreeMemory (ctxt);
2551: }
2552:
2553: /*----------------------------------------------------------------------
1.1 cvs 2554: MathMLAttributeComplete
1.58 cvs 2555: The XML parser has completed parsing attribute attr (as well as its value)
2556: that is associated with element el in document doc.
1.1 cvs 2557: ----------------------------------------------------------------------*/
1.120 cvs 2558: void MathMLAttributeComplete (Attribute attr, Element el, Document doc)
1.1 cvs 2559: {
1.134 cvs 2560: AttributeType attrType, depAttrType;
1.23 cvs 2561: int attrKind;
1.50 cvs 2562: ElementType elType;
1.23 cvs 2563: #define buflen 50
1.120 cvs 2564: char *value;
1.50 cvs 2565: int val, length;
1.101 cvs 2566: Attribute intAttr;
1.23 cvs 2567:
1.58 cvs 2568: /* first get the type of that attribute */
1.23 cvs 2569: TtaGiveAttributeType (attr, &attrType, &attrKind);
1.54 cvs 2570: if (attrType.AttrTypeNum == MathML_ATTR_bevelled)
1.58 cvs 2571: /* it's a bevelled attribute */
1.50 cvs 2572: {
2573: val = TtaGetAttributeValue (attr);
1.54 cvs 2574: if (val == MathML_ATTR_bevelled_VAL_true)
2575: /* bevelled = true. Transform MFRAC into BevelledMFRAC */
1.50 cvs 2576: {
2577: elType = TtaGetElementType (el);
2578: if (elType.ElTypeNum == MathML_EL_MFRAC)
1.54 cvs 2579: ChangeTypeOfElement (el, doc, MathML_EL_BevelledMFRAC);
1.50 cvs 2580: }
2581: }
1.101 cvs 2582:
2583: else if (attrType.AttrTypeNum == MathML_ATTR_rowalign_mtr)
2584: {
2585: /* create an equivalent IntRowAlign attribute on the same element */
2586: attrType.AttrTypeNum = MathML_ATTR_IntRowAlign;
2587: intAttr = TtaGetAttribute (el, attrType);
2588: if (!intAttr)
2589: /* no IntRowAlign attribute, create one */
2590: {
2591: intAttr = TtaNewAttribute (attrType);
2592: TtaAttachAttribute (el, intAttr, doc);
2593: }
2594: val = TtaGetAttributeValue (attr);
2595: TtaSetAttributeValue (intAttr, val, el, doc);
2596: }
2597:
2598: else if (attrType.AttrTypeNum == MathML_ATTR_rowalign)
2599: {
2600: /* parse the attribute value and create a IntRowAlign attribute
2601: for each mrow contained in the element */
2602: HandleRowalignAttribute (attr, el, doc, FALSE);
2603: }
2604:
2605: else if (attrType.AttrTypeNum == MathML_ATTR_columnalign_mtd)
2606: {
2607: /* create an equivalent IntColAlign attribute on the same element */
2608: attrType.AttrTypeNum = MathML_ATTR_IntColAlign;
2609: intAttr = TtaGetAttribute (el, attrType);
2610: if (!intAttr)
2611: /* no IntColAlign attribute, create one */
2612: {
2613: intAttr = TtaNewAttribute (attrType);
2614: TtaAttachAttribute (el, intAttr, doc);
2615: }
2616: val = TtaGetAttributeValue (attr);
2617: TtaSetAttributeValue (intAttr, val, el, doc);
2618: }
2619:
1.104 cvs 2620: /* don't handle attribute columnalign now: the table or the row is not
2621: complete yet. Handle it when the element is complete.
1.101 cvs 2622: else if (attrType.AttrTypeNum == MathML_ATTR_columnalign)
1.104 cvs 2623: */
1.138 cvs 2624:
2625: else if (attrType.AttrTypeNum == MathML_ATTR_Language)
2626: {
2627: if (el == TtaGetRootElement (doc))
2628: /* it's the lang attribute on the root element */
2629: /* set the RealLang attribute */
2630: {
2631: depAttrType.AttrSSchema = attrType.AttrSSchema ;
2632: depAttrType.AttrTypeNum = MathML_ATTR_RealLang;
2633: if (!TtaGetAttribute (el, depAttrType))
2634: /* it's not present. Add it */
2635: {
2636: intAttr = TtaNewAttribute (depAttrType);
2637: TtaAttachAttribute (el, intAttr, doc);
2638: TtaSetAttributeValue (intAttr, MathML_ATTR_RealLang_VAL_Yes_,
2639: el, doc);
2640: }
2641: }
2642: }
1.101 cvs 2643:
1.50 cvs 2644: else if (attrType.AttrTypeNum == MathML_ATTR_color ||
1.93 cvs 2645: attrType.AttrTypeNum == MathML_ATTR_mathcolor ||
2646: attrType.AttrTypeNum == MathML_ATTR_background_ ||
2647: attrType.AttrTypeNum == MathML_ATTR_mathbackground ||
2648: attrType.AttrTypeNum == MathML_ATTR_fontsize ||
2649: attrType.AttrTypeNum == MathML_ATTR_mathsize ||
2650: attrType.AttrTypeNum == MathML_ATTR_fontfamily ||
2651: attrType.AttrTypeNum == MathML_ATTR_linethickness ||
2652: attrType.AttrTypeNum == MathML_ATTR_lspace ||
2653: attrType.AttrTypeNum == MathML_ATTR_rspace ||
2654: attrType.AttrTypeNum == MathML_ATTR_scriptlevel ||
2655: attrType.AttrTypeNum == MathML_ATTR_width_ ||
2656: attrType.AttrTypeNum == MathML_ATTR_height_ ||
2657: attrType.AttrTypeNum == MathML_ATTR_depth_ )
2658: {
1.23 cvs 2659: length = TtaGetTextAttributeLength (attr);
2660: if (length >= buflen)
2661: length = buflen - 1;
2662: if (length > 0)
2663: {
1.116 cvs 2664: value = TtaGetMemory (buflen);
1.33 cvs 2665: value[0] = EOS;
2666: TtaGiveTextAttributeValue (attr, value, &length);
2667: switch (attrType.AttrTypeNum)
2668: {
2669: case MathML_ATTR_color:
1.134 cvs 2670: /* deprecated attribute */
2671: /* if the same element has a mathcolor attribute, ignore
2672: the color attribute */
2673: depAttrType.AttrSSchema = attrType.AttrSSchema ;
2674: depAttrType.AttrTypeNum = MathML_ATTR_mathcolor;
2675: if (!TtaGetAttribute (el, depAttrType))
2676: HTMLSetForegroundColor (doc, el, value);
2677: break;
1.93 cvs 2678: case MathML_ATTR_mathcolor:
1.24 cvs 2679: HTMLSetForegroundColor (doc, el, value);
2680: break;
1.33 cvs 2681: case MathML_ATTR_background_:
1.134 cvs 2682: /* deprecated attribute */
2683: /* if the same element has a mathbackground attribute, ignore
2684: the background attribute */
2685: depAttrType.AttrSSchema = attrType.AttrSSchema;
2686: depAttrType.AttrTypeNum = MathML_ATTR_mathbackground;
2687: if (!TtaGetAttribute (el, depAttrType))
2688: HTMLSetBackgroundColor (doc, el, value);
2689: break;
1.93 cvs 2690: case MathML_ATTR_mathbackground:
1.24 cvs 2691: HTMLSetBackgroundColor (doc, el, value);
2692: break;
1.33 cvs 2693: case MathML_ATTR_fontfamily:
1.24 cvs 2694: SetFontfamily (doc, el, value);
1.83 cvs 2695: break;
2696: case MathML_ATTR_linethickness:
2697: MathMLlinethickness (doc, el, value);
1.58 cvs 2698: break;
2699: case MathML_ATTR_fontsize:
1.134 cvs 2700: /* deprecated attribute */
2701: /* if the same element has a mathsize attribute, ignore
2702: the fontsize attribute */
2703: depAttrType.AttrSSchema = attrType.AttrSSchema;
2704: depAttrType.AttrTypeNum = MathML_ATTR_mathsize;
2705: if (!TtaGetAttribute (el, depAttrType))
2706: MathMLAttrToStyleProperty (doc, el, value,
2707: attrType.AttrTypeNum);
2708: break;
1.93 cvs 2709: case MathML_ATTR_mathsize:
1.58 cvs 2710: case MathML_ATTR_lspace:
2711: case MathML_ATTR_rspace:
1.60 cvs 2712: MathMLAttrToStyleProperty (doc, el, value,attrType.AttrTypeNum);
2713: break;
2714: case MathML_ATTR_scriptlevel:
2715: MathMLSetScriptLevel (doc, el, value);
2716: break;
2717: case MathML_ATTR_width_:
2718: case MathML_ATTR_height_:
2719: case MathML_ATTR_depth_:
2720: MathMLSpacingAttr (doc, el, value, attrType.AttrTypeNum);
1.59 cvs 2721: break;
2722: default:
1.24 cvs 2723: break;
1.33 cvs 2724: }
2725: TtaFreeMemory (value);
1.23 cvs 2726: }
2727: }
1.1 cvs 2728: }
2729:
2730: /*----------------------------------------------------------------------
2731: MathMLGetDTDName
2732: ----------------------------------------------------------------------*/
1.120 cvs 2733: void MathMLGetDTDName (char *DTDname, char *elementName)
1.1 cvs 2734: {
2735: /* no other DTD allowed within MathML elements */
1.116 cvs 2736: strcpy (DTDname, "");
1.1 cvs 2737: }
2738:
2739: /* end of module */
Webmaster