Annotation of Amaya/amaya/MathMLbuilder.c, revision 1.141
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,
210: char *alphabet)
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.110 cvs 225: *alphabet = 'G';
1.109 cvs 226: /* *alphabet = pMathEntityTable[i].charAlphabet;*/
1.67 cvs 227: }
228: else
229: {
1.1 cvs 230: entityValue[0] = EOS;
231: *alphabet = 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];
657: char alphabet;
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.123 cvs 704: alphabet = TtaGetAlphabet (lang);
705: if (alphabet == 'L')
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: }
712: else if (alphabet == 'G')
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.116 cvs 789: char alphabet;
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 --;
876: alphabet = TtaGetAlphabet (lang);
877: if (alphabet == 'G')
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);
945: alphabet = TtaGetAlphabet (lang);
946: if (alphabet != 'G')
947: /* not the right alphabet for an
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)
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)
1385: /* there is a fontstyle attribute. Remove the corresponding
1386: internal attribute that is not needed */
1387: {
1388: if (IntAttr != NULL)
1.54 cvs 1389: TtaRemoveAttribute (el, IntAttr, doc);
1.1 cvs 1390: }
1391: else
1392: /* there is no fontstyle attribute. Create an internal attribute
1393: IntFontstyle with a value that depends on the content of the MI */
1394: {
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, MathML_ATTR_IntFontstyle_VAL_IntNormal,
1406: el, doc);
1407: }
1408: else
1409: /* MI contains a single character. Remove attribute IntFontstyle
1.54 cvs 1410: if it exists, except if it's ImaginaryI, ExponentialE or
1.124 cvs 1411: DifferentialD */
1.1 cvs 1412: {
1.54 cvs 1413: italic = TRUE;
1414: textEl = TtaGetFirstChild (el);
1415: if (textEl != NULL)
1416: {
1417: /* is there an attribute EntityName on that character? */
1418: attrType.AttrTypeNum = MathML_ATTR_EntityName;
1419: attr = TtaGetAttribute (textEl, attrType);
1420: if (attr)
1421: {
1422: len = TtaGetTextAttributeLength (attr);
1423: if (len > 0)
1424: {
1.116 cvs 1425: value = TtaGetMemory (len+1);
1.54 cvs 1426: TtaGiveTextAttributeValue (attr, value, &len);
1.124 cvs 1427: if (strcmp (&value[1], "ImaginaryI;") == 0 ||
1428: strcmp (&value[1], "ExponentialE;") == 0 ||
1429: strcmp (&value[1], "DifferentialD;") == 0)
1.54 cvs 1430: italic = FALSE;
1431: TtaFreeMemory (value);
1432: }
1433: }
1434: if (italic)
1435: {
1436: if (IntAttr != NULL)
1437: TtaRemoveAttribute (el, IntAttr, doc);
1438: }
1439: else
1440: {
1441: /* put an attribute IntFontstyle = IntNormal */
1442: if (IntAttr == NULL)
1443: {
1444: attrType.AttrTypeNum = MathML_ATTR_IntFontstyle;
1445: IntAttr = TtaNewAttribute (attrType);
1446: TtaAttachAttribute (el, IntAttr, doc);
1447: }
1448: TtaSetAttributeValue (IntAttr, MathML_ATTR_IntFontstyle_VAL_IntNormal,
1449: el, doc);
1450: }
1451: }
1.1 cvs 1452: }
1453: }
1454: }
1455: }
1456:
1457: /*----------------------------------------------------------------------
1.22 cvs 1458: SetIntAddSpaceAttr
1.1 cvs 1459: The content of a MO element has been created or modified.
1.22 cvs 1460: Create or change attribute IntAddSpace for that element accordingly.
1.1 cvs 1461: -----------------------------------------------------------------------*/
1.22 cvs 1462: void SetIntAddSpaceAttr (Element el, Document doc)
1.1 cvs 1463: {
1464: Element textEl, previous;
1465: ElementType elType;
1466: AttributeType attrType;
1.60 cvs 1467: Attribute attr, formAttr;
1468: int len, val, form;
1.1 cvs 1469: #define BUFLEN 10
1.116 cvs 1470: unsigned char text[BUFLEN];
1.1 cvs 1471: Language lang;
1.116 cvs 1472: char alphabet;
1.1 cvs 1473:
1.60 cvs 1474: /* get the content of the mo element */
1.1 cvs 1475: textEl = TtaGetFirstChild (el);
1476: if (textEl != NULL)
1.60 cvs 1477: /* the mo element is not empty */
1.1 cvs 1478: {
1.60 cvs 1479: /* does the mo element have an IntAddSpace attribute? */
1.1 cvs 1480: elType = TtaGetElementType (el);
1481: attrType.AttrSSchema = elType.ElSSchema;
1.22 cvs 1482: attrType.AttrTypeNum = MathML_ATTR_IntAddSpace;
1.1 cvs 1483: attr = TtaGetAttribute (el, attrType);
1484: if (attr == NULL)
1.60 cvs 1485: /* no IntAddSpace Attr, create one */
1.1 cvs 1486: {
1487: attr = TtaNewAttribute (attrType);
1488: TtaAttachAttribute (el, attr, doc);
1489: }
1.135 cvs 1490: /* space on both sides by default */
1491: val = MathML_ATTR_IntAddSpace_VAL_both;
1.60 cvs 1492: /* does the mo element have a form attribute? */
1493: attrType.AttrTypeNum = MathML_ATTR_form;
1494: formAttr = TtaGetAttribute (el, attrType);
1495: if (formAttr)
1496: /* there is a form attribute */
1497: {
1498: form = TtaGetAttributeValue (formAttr);
1499: switch (form)
1500: {
1501: case MathML_ATTR_form_VAL_prefix:
1502: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1503: break;
1504: case MathML_ATTR_form_VAL_infix:
1505: val = MathML_ATTR_IntAddSpace_VAL_both;
1506: break;
1507: case MathML_ATTR_form_VAL_postfix:
1508: val = MathML_ATTR_IntAddSpace_VAL_spaceafter;
1509: break;
1.136 cvs 1510: default:
1511: val = MathML_ATTR_IntAddSpace_VAL_both;
1512: break;
1.60 cvs 1513: }
1514: }
1515: else
1516: /* no form attribute. Analyze the content */
1517: {
1518: len = TtaGetTextLength (textEl);
1519: if (len > 0 && len < BUFLEN)
1520: {
1521: len = BUFLEN;
1522: TtaGiveTextContent (textEl, text, &len, &lang);
1523: alphabet = TtaGetAlphabet (lang);
1524: if (len == 1)
1.99 cvs 1525: {
1.60 cvs 1526: /* the mo element contains a single character */
1527: if (alphabet == 'L')
1528: /* ISO-Latin 1 character */
1529: {
1530: if (text[0] == '-')
1531: /* prefix or infix operator? */
1532: {
1533: previous = el;
1534: TtaPreviousSibling (&previous);
1535: if (previous == NULL)
1536: /* no previous sibling => prefix operator */
1537: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1538: else
1539: {
1540: elType = TtaGetElementType (previous);
1541: if (elType.ElTypeNum == MathML_EL_MO)
1542: /* after an operator => prefix operator */
1543: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1544: else
1545: /* infix operator */
1546: val = MathML_ATTR_IntAddSpace_VAL_both;
1547: }
1548: }
1.111 cvs 1549: else if (text[0] == '&' ||
1.60 cvs 1550: text[0] == '*' ||
1.111 cvs 1551: text[0] == '+' ||
1.100 cvs 1552: text[0] == '/' ||
1.60 cvs 1553: text[0] == '<' ||
1554: text[0] == '=' ||
1555: text[0] == '>' ||
1.111 cvs 1556: text[0] == '^' ||
1557: (int)text[0] == 177 || /* plus or minus */
1558: (int)text[0] == 215 || /* times */
1559: (int)text[0] == 247) /* divide */
1.60 cvs 1560: /* infix operator */
1561: val = MathML_ATTR_IntAddSpace_VAL_both;
1562: else if (text[0] == ',' ||
1.135 cvs 1563: text[0] == '!' ||
1564: text[0] == '&' ||
1565: text[0] == ':' ||
1.60 cvs 1566: text[0] == ';')
1567: /* separator */
1568: val = MathML_ATTR_IntAddSpace_VAL_spaceafter;
1.135 cvs 1569: else if (text[0] == '(' ||
1570: text[0] == ')' ||
1571: text[0] == '[' ||
1572: text[0] == ']' ||
1573: text[0] == '{' ||
1574: text[0] == '}' ||
1575: text[0] == '.' ||
1576: text[0] == '@' ||
1577: (int)text[0] == 129 || /* thin space */
1578: (int)text[0] == 130 || /* en space */
1579: (int)text[0] == 160) /* em space */
1580: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1.60 cvs 1581: }
1582: else if (alphabet == 'G')
1.137 vatton 1583: {
1584: /* Symbol character set */
1585: if ((int)text[0] == 163 || /* less or equal */
1586: (int)text[0] == 177 || /* plus or minus */
1587: (int)text[0] == 179 || /* greater or equal */
1588: (int)text[0] == 180 || /* times */
1589: (int)text[0] == 184 || /* divide */
1590: (int)text[0] == 185 || /* not equal */
1591: (int)text[0] == 186 || /* identical */
1592: (int)text[0] == 187 || /* equivalent */
1593: (int)text[0] == 196 || /* circle times */
1594: (int)text[0] == 197 || /* circle plus */
1595: ((int)text[0] >= 199 && (int)text[0] <= 209) || /* */
1596: (int)text[0] == 217 || /* and */
1597: (int)text[0] == 218 ) /* or */
1598: /* infix operator */
1599: val = MathML_ATTR_IntAddSpace_VAL_both;
1600: else
1601: val = MathML_ATTR_IntAddSpace_VAL_nospace;
1602: }
1.99 cvs 1603: }
1.60 cvs 1604: }
1605: }
1.1 cvs 1606: TtaSetAttributeValue (attr, val, el, doc);
1607: }
1608: }
1609:
1610: /*----------------------------------------------------------------------
1.58 cvs 1611: ChildOfMRowOrInferred
1612: Return TRUE if element el is a child of a MROW element or an
1613: inferred MROW element
1614: ----------------------------------------------------------------------*/
1615: ThotBool ChildOfMRowOrInferred (Element el)
1616: {
1617: ElementType elType;
1618: Element parent;
1619: ThotBool result;
1620:
1621: result = FALSE;
1622: parent = TtaGetParent (el);
1623: if (parent)
1624: {
1625: elType = TtaGetElementType (parent);
1626: result = (elType.ElTypeNum == MathML_EL_MROW ||
1627: elType.ElTypeNum == MathML_EL_SqrtBase ||
1628: elType.ElTypeNum == MathML_EL_MSTYLE ||
1629: elType.ElTypeNum == MathML_EL_MERROR ||
1.92 cvs 1630: elType.ElTypeNum == MathML_EL_MENCLOSE ||
1.58 cvs 1631: elType.ElTypeNum == MathML_EL_MPADDED ||
1632: elType.ElTypeNum == MathML_EL_MPHANTOM ||
1633: elType.ElTypeNum == MathML_EL_CellWrapper ||
1.92 cvs 1634: elType.ElTypeNum == MathML_EL_MathML ||
1.58 cvs 1635: elType.ElTypeNum == MathML_EL_FencedExpression);
1636: }
1637: return result;
1638: }
1639:
1640: /*----------------------------------------------------------------------
1.1 cvs 1641: CheckFence
1.84 cvs 1642: If el is a MO element,
1643: - if it's a large operator (∑ for instance), put a presentation
1644: rule to enlarge the character.
1645: - if it's a child of a MROW (or equivalent) element and if it contains
1646: a single fence character, transform the MO into a MF and the fence
1647: character into a Thot stretchable symbol.
1.1 cvs 1648: ----------------------------------------------------------------------*/
1.84 cvs 1649: void CheckFence (Element el, Document doc)
1.1 cvs 1650: {
1.128 vatton 1651: ElementType elType;
1652: Element content;
1653: AttributeType attrType;
1654: Attribute attr, attrStretchy;
1655: Language lang;
1.84 cvs 1656: PresentationValue pval;
1657: PresentationContext ctxt;
1.128 vatton 1658: CHAR_T text[2];
1659: char alphabet;
1660: unsigned char c;
1661: int len, val;
1.1 cvs 1662:
1663: elType = TtaGetElementType (el);
1664: if (elType.ElTypeNum == MathML_EL_MO)
1.58 cvs 1665: /* the element is a MO */
1666: {
1.84 cvs 1667: content = TtaGetFirstChild (el);
1668: if (content != NULL)
1669: {
1670: elType = TtaGetElementType (content);
1671: if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)
1672: {
1.128 vatton 1673: len = TtaGetVolume (content);
1.84 cvs 1674: if (len == 1)
1675: /* the MO element contains a single character */
1676: {
1677: len = 2;
1.128 vatton 1678: TtaGiveBufferContent (content, text, len, &lang);
1.84 cvs 1679: alphabet = TtaGetAlphabet (lang);
1680: if ((alphabet == 'G') &&
1.128 vatton 1681: (text[0] == 229 || text[0] == 213)) /* Sigma, Pi */
1.84 cvs 1682: /* it's a large operator */
1683: {
1684: ctxt = TtaGetSpecificStyleContext (doc);
1685: ctxt->destroy = FALSE;
1686: /* the specific presentation to be created is not a CSS rule */
1687: ctxt->cssLevel = 0;
1688: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1689: pval.typed_data.real = FALSE;
1690: pval.typed_data.value = 180;
1691: TtaSetStylePresentation (PRSize, content, NULL, ctxt, pval);
1692: }
1693: else if (ChildOfMRowOrInferred (el))
1694: /* the MO element is a child of a MROW element */
1.1 cvs 1695: {
1.102 cvs 1696: if (((alphabet == 'L') &&
1.115 cvs 1697: (text[0] == '(' || text[0] == ')' ||
1698: text[0] == '[' || text[0] == ']' ||
1699: text[0] == '{' || text[0] == '}' ||
1700: text[0] == '|')) ||
1.102 cvs 1701: ((alphabet == 'G') &&
1.128 vatton 1702: (text[0] == 225 || text[0] == 241)))
1.84 cvs 1703: /* it's a stretchable parenthesis or equivalent */
1704: {
1705: /* remove the content of the MO element */
1706: TtaDeleteTree (content, doc);
1707: /* change the MO element into a MF element */
1708: ChangeTypeOfElement (el, doc, MathML_EL_MF);
1.55 cvs 1709:
1.84 cvs 1710: /* is there an attribute stretchy on this mo element? */
1711: attrType.AttrSSchema = elType.ElSSchema;
1712: attrType.AttrTypeNum = MathML_ATTR_stretchy;
1713: attrStretchy = TtaGetAttribute (el, attrType);
1714: if (attrStretchy)
1715: val = TtaGetAttributeValue (attrStretchy);
1716: else
1717: val = MathML_ATTR_stretchy_VAL_true;
1718: if (val == MathML_ATTR_stretchy_VAL_true)
1719: {
1720: /* attach a IntVertStretch attribute to the MF element*/
1721: attrType.AttrTypeNum = MathML_ATTR_IntVertStretch;
1722: attr = TtaNewAttribute (attrType);
1723: TtaAttachAttribute (el, attr, doc);
1724: TtaSetAttributeValue (attr,
1725: MathML_ATTR_IntVertStretch_VAL_yes_,
1726: el, doc);
1727: }
1728: /* create a new content for the MF element */
1.87 cvs 1729: elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
1.128 vatton 1730: if (alphabet == 'G' && text[0] == 241)
1.102 cvs 1731: c = '>'; /* RightAngleBracket */
1.128 vatton 1732: else if (alphabet == 'G' && text[0] == 225)
1.102 cvs 1733: c = '<'; /* LeftAngleBracket */
1734: else
1735: c = (char) text[0];
1.84 cvs 1736: content = TtaNewElement (doc, elType);
1737: TtaInsertFirstChild (&content, el, doc);
1738: TtaSetGraphicsShape (content, c, doc);
1739: }
1.1 cvs 1740: }
1.84 cvs 1741: }
1742: }
1.58 cvs 1743: }
1744: }
1.1 cvs 1745: }
1746:
1747: /*----------------------------------------------------------------------
1748: CreateFencedSeparators
1749: Create FencedSeparator elements within the fencedExpression
1750: according to attribute separators of the MFENCED element.
1751: ----------------------------------------------------------------------*/
1.110 cvs 1752: void CreateFencedSeparators (Element fencedExpression, Document doc, ThotBool record)
1.1 cvs 1753: {
1754: ElementType elType;
1755: Element child, separator, leaf, next, prev, mfenced;
1756: AttributeType attrType;
1757: Attribute attr;
1758: int length, sep, i;
1759: Language lang;
1.116 cvs 1760: char text[32], sepValue[4];
1.1 cvs 1761:
1762: /* get the separators attribute */
1763: mfenced = TtaGetParent (fencedExpression);
1764: elType = TtaGetElementType (fencedExpression);
1765: attrType.AttrSSchema = elType.ElSSchema;
1766: attrType.AttrTypeNum = MathML_ATTR_separators;
1767: text[0] = ','; /* default value is sparators="," */
1768: text[1] = EOS;
1769: length = 1;
1770: attr = TtaGetAttribute (mfenced, attrType);
1771: if (attr != NULL)
1772: {
1773: length = 31;
1774: TtaGiveTextAttributeValue (attr, text, &length);
1775: }
1776:
1777: /* create FencedSeparator elements in the FencedExpression */
1778: prev = NULL;
1779: sep = 0;
1780: /* skip leading spaces in attribute separators */
1781: while (text[sep] <= SPACE && text[sep] != EOS)
1782: sep++;
1783: /* if attribute separators is empty or contains only spaces, do not
1784: insert any separator element */
1785: if (text[sep] != EOS)
1786: {
1787: child = TtaGetFirstChild (fencedExpression);
1788: while (child != NULL)
1789: {
1790: next = child;
1791: TtaNextSibling (&next);
1792: elType = TtaGetElementType (child);
1793: if (elType.ElTypeNum != MathML_EL_Construct)
1794: {
1795: if (prev != NULL)
1796: {
1797: elType.ElTypeNum = MathML_EL_FencedSeparator;
1798: separator = TtaNewElement (doc, elType);
1799: TtaInsertSibling (separator, prev, FALSE, doc);
1800: elType.ElTypeNum = MathML_EL_TEXT_UNIT;
1801: leaf = TtaNewElement (doc, elType);
1802: TtaInsertFirstChild (&leaf, separator, doc);
1803: sepValue[0] = text[sep];
1804: sepValue[1] = SPACE;
1805: sepValue[2] = EOS;
1806: lang = TtaGetLanguageIdFromAlphabet('L');
1807: TtaSetTextContent (leaf, sepValue, lang, doc);
1808: /* is there a following non-space character in separators? */
1809: i = sep + 1;
1810: while (text[i] <= SPACE && text[i] != EOS)
1811: i++;
1812: if (text[i] > SPACE && text[i] != EOS)
1813: sep = i;
1.17 cvs 1814: if (record)
1815: TtaRegisterElementCreate (separator, doc);
1.1 cvs 1816: }
1817: prev = child;
1818: }
1819: child = next;
1820: }
1821: }
1822: }
1823:
1.124 cvs 1824: /*----------------------------------------------------------------------
1825: CreateOpeningOrClosingFence
1826: Create the OpeningFence or ClosingFence element (depending on parameter
1827: open) for the MFENCED element el which contain the fencedExpression
1828: element.
1829: ----------------------------------------------------------------------*/
1830: static void CreateOpeningOrClosingFence (Element fencedExpression,
1831: Element el, Document doc,
1832: ThotBool open)
1833: {
1834: ElementType elType;
1835: Element leaf, fence;
1836: AttributeType attrType;
1837: Attribute attr;
1838: int length;
1839: char text[32];
1840: char c;
1841:
1842: elType = TtaGetElementType (el);
1843: attrType.AttrSSchema = elType.ElSSchema;
1844: if (open)
1845: {
1846: c = '('; /* default value of attribute 'open' */
1847: attrType.AttrTypeNum = MathML_ATTR_open;
1848: elType.ElTypeNum = MathML_EL_OpeningFence;
1849: }
1850: else
1851: {
1852: c = ')'; /* default value of attribute 'close' */
1853: attrType.AttrTypeNum = MathML_ATTR_close;
1854: elType.ElTypeNum = MathML_EL_ClosingFence;
1855: }
1856: attr = TtaGetAttribute (el, attrType);
1857: if (attr != NULL)
1858: {
1859: length = 31;
1860: TtaGiveTextAttributeValue (attr, text, &length);
1861: if (length != 1)
1862: /* content of attribute open or close should be a single character */
1863: c = '?';
1864: else
1865: {
1.128 vatton 1866: c = text[0];
1.124 cvs 1867: /* filter characters that would represent strange symbols, such
1868: as root, integrals, arrows, etc. */
1869: if (c == 'r' || c == 'i' || c == 'c' || c == 'd' || c == 'S' ||
1870: c == 'P' || c == 'I' || c == 'U' || c == 'o' || c == 'u' ||
1871: c == 'h' || c == 'v' || c == 'R' || c == '^' || c == 'L' ||
1872: c == 'V' || c == 'D')
1873: c = '?';
1874: }
1875: }
1876: fence = TtaNewElement (doc, elType);
1877: TtaInsertSibling (fence, fencedExpression, open, doc);
1878: elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
1879: leaf = TtaNewElement (doc, elType);
1880: TtaInsertFirstChild (&leaf, fence, doc);
1881: TtaSetGraphicsShape (leaf, c, doc);
1882: }
1.1 cvs 1883:
1884: /*----------------------------------------------------------------------
1885: TransformMFENCED
1886: Transform the content of a MFENCED element: create elements
1887: OpeningFence, FencedExpression, ClosingFence and FencedSeparator.
1888: ----------------------------------------------------------------------*/
1.46 cvs 1889: static void TransformMFENCED (Element el, Document doc)
1.1 cvs 1890: {
1891: ElementType elType;
1.124 cvs 1892: Element child, fencedExpression, next, prev, firstChild;
1.1 cvs 1893:
1894: child = TtaGetFirstChild (el);
1895: if (child != NULL)
1896: elType = TtaGetElementType (child);
1897: if (child != NULL && elType.ElTypeNum == MathML_EL_OpeningFence)
1898: /* The first child of this MFENCED element is an OpeningFence.
1899: This MFENCED expression has already been transformed, possibly
1900: by the Transform command */
1901: {
1902: TtaNextSibling (&child);
1903: fencedExpression = child;
1904: if (fencedExpression != NULL)
1905: elType = TtaGetElementType (fencedExpression);
1906: if (elType.ElTypeNum == MathML_EL_FencedExpression)
1907: /* the second child is a FencedExpression. OK.
1908: Remove all existing FencedSeparator elements */
1909: {
1910: child = TtaGetFirstChild (fencedExpression);
1911: prev = NULL;
1912: while (child != NULL)
1913: {
1914: elType = TtaGetElementType (child);
1915: next = child;
1916: TtaNextSibling (&next);
1917: if (elType.ElTypeNum == MathML_EL_FencedSeparator)
1918: /* Remove this separator */
1919: TtaDeleteTree (child, doc);
1920: child = next;
1921: }
1922: /* create FencedSeparator elements in the FencedExpression */
1.17 cvs 1923: CreateFencedSeparators (fencedExpression, doc, FALSE);
1.1 cvs 1924: }
1925: }
1926: else
1927: /* this MFENCED element must be transformed */
1928: {
1929: /* create a FencedExpression element as a child of the MFENCED elem. */
1930: elType = TtaGetElementType (el);
1931: elType.ElTypeNum = MathML_EL_FencedExpression;
1932: fencedExpression = TtaNewElement (doc, elType);
1933: TtaInsertFirstChild (&fencedExpression, el, doc);
1934: if (child == NULL)
1935: /* empty MFENCED element */
1936: {
1937: elType.ElTypeNum = MathML_EL_Construct;
1938: child = TtaNewElement (doc, elType);
1939: TtaInsertFirstChild (&child, fencedExpression, doc);
1.22 cvs 1940: SetIntPlaceholderAttr (child, doc);
1.1 cvs 1941: }
1942: else
1943: {
1944: /* move the content of the MFENCED element within the new
1945: FencedExpression element */
1946: prev = NULL;
1947: firstChild = NULL;
1948: while (child != NULL)
1949: {
1950: next = child;
1951: TtaNextSibling (&next);
1952: TtaRemoveTree (child, doc);
1953: if (prev == NULL)
1954: {
1955: TtaInsertFirstChild (&child, fencedExpression, doc);
1956: firstChild = child;
1957: }
1958: else
1959: TtaInsertSibling (child, prev, FALSE, doc);
1960: prev = child;
1961: child = next;
1962: }
1963:
1964: /* create FencedSeparator elements in the FencedExpression */
1.17 cvs 1965: CreateFencedSeparators (fencedExpression, doc, FALSE);
1.1 cvs 1966:
1967: /* Create placeholders within the FencedExpression element */
1968: CreatePlaceholders (firstChild, doc);
1969: }
1970:
1971: /* create the OpeningFence element according to the open attribute */
1.124 cvs 1972: CreateOpeningOrClosingFence (fencedExpression, el, doc, TRUE);
1.1 cvs 1973:
1974: /* create the ClosingFence element according to close attribute */
1.124 cvs 1975: CreateOpeningOrClosingFence (fencedExpression, el, doc, FALSE);
1.1 cvs 1976: }
1977: }
1978:
1979: /*----------------------------------------------------------------------
1.59 cvs 1980: MathMLScriptShift
1981: The MathML attribute attr (superscriptshift or subscriptshift) is associated
1982: with element el (a msub, msup or msubsup).
1983: If value is not NULL, generate the corresponding Thot VertPos rule for the
1984: Subscript or Superscript child of el.
1985: If value is NULL, remove the Thot VertPos rule.
1986: -----------------------------------------------------------------------*/
1.120 cvs 1987: void MathMLScriptShift (Document doc, Element el, char *value, int attr)
1.59 cvs 1988: {
1989: ElementType elType;
1990: Element script, child;
1991: int scrType;
1992: PresentationValue pval;
1993: PresentationContext ctxt;
1994:
1995: /* get the Superscript or Subscript child of el */
1996: if (attr == MathML_ATTR_superscriptshift)
1997: scrType = MathML_EL_Superscript;
1998: else if (attr == MathML_ATTR_subscriptshift)
1999: scrType = MathML_EL_Subscript;
2000: else
2001: return;
2002: script = NULL;
2003: child = TtaGetFirstChild (el);
2004: while (!script && child)
2005: {
2006: elType = TtaGetElementType (child);
2007: if (elType.ElTypeNum == scrType)
2008: script = child;
2009: else
2010: TtaNextSibling (&child);
2011: }
2012: if (script)
2013: /* Superscript or Subscript element found */
2014: {
2015: ctxt = TtaGetSpecificStyleContext (doc);
2016: if (!value)
2017: /* remove the presentation rule */
2018: {
2019: ctxt->destroy = TRUE;
1.75 cvs 2020: pval.typed_data.value = 0;
1.59 cvs 2021: TtaSetStylePresentation (PRVertPos, script, NULL, ctxt, pval);
2022: }
2023: else
2024: {
2025: ctxt->destroy = FALSE;
2026: /* parse the attribute value (a number followed by a unit) */
1.119 cvs 2027: value = TtaSkipBlanks (value);
1.59 cvs 2028: value = ParseCSSUnit (value, &pval);
2029: if (pval.typed_data.unit != STYLE_UNIT_INVALID)
2030: {
1.78 cvs 2031: /* the specific presentation to be created is not a CSS rule */
2032: ctxt->cssLevel = 0;
1.59 cvs 2033: if (attr == MathML_ATTR_superscriptshift)
2034: pval.typed_data.value = - pval.typed_data.value;
2035: TtaSetStylePresentation (PRVertPos, script, NULL, ctxt, pval);
2036: }
2037: }
2038: TtaFreeMemory (ctxt);
2039: }
2040: }
2041:
2042: /*----------------------------------------------------------------------
2043: SetScriptShift
2044: If element el (which is a msup, msub or msubsup) has an attribute
2045: att (which is subscriptshift or superscriptshift), generate the
2046: corresponding Thot presentation rule.
2047: ----------------------------------------------------------------------*/
1.120 cvs 2048: static void SetScriptShift (Element el, Document doc, int att)
1.59 cvs 2049: {
2050: AttributeType attrType;
2051: ElementType elType;
2052: Attribute attr;
1.120 cvs 2053: char *value;
1.59 cvs 2054: int length;
2055:
2056: elType = TtaGetElementType (el);
2057: attrType.AttrSSchema = elType.ElSSchema;
2058: attrType.AttrTypeNum = att;
2059: attr = TtaGetAttribute (el, attrType);
2060: if (attr)
2061: {
2062: length = TtaGetTextAttributeLength (attr);
2063: if (length > 0)
2064: {
1.116 cvs 2065: value = TtaGetMemory (length+1);
1.59 cvs 2066: value[0] = EOS;
2067: TtaGiveTextAttributeValue (attr, value, &length);
2068: MathMLScriptShift (doc, el, value, att);
2069: TtaFreeMemory (value);
2070: }
2071: }
2072: }
2073:
2074: /*----------------------------------------------------------------------
1.1 cvs 2075: MathMLElementComplete
2076: Check the Thot structure of the MathML element el.
2077: ----------------------------------------------------------------------*/
1.56 cvs 2078: void MathMLElementComplete (Element el, Document doc, int *error)
1.1 cvs 2079: {
1.74 cvs 2080: ElementType elType, parentType;
1.1 cvs 2081: Element child, parent, new, prev, next;
1.101 cvs 2082: AttributeType attrType;
2083: Attribute attr;
1.56 cvs 2084: SSchema MathMLSSchema;
2085: ThotBool ok;
1.1 cvs 2086:
1.56 cvs 2087: ok = TRUE;
2088: *error = 0;
1.1 cvs 2089: elType = TtaGetElementType (el);
1.2 cvs 2090: MathMLSSchema = GetMathMLSSchema (doc);
1.1 cvs 2091:
1.76 cvs 2092: if (elType.ElSSchema == MathMLSSchema)
1.1 cvs 2093: {
2094: switch (elType.ElTypeNum)
2095: {
1.76 cvs 2096: case MathML_EL_MathML:
2097: /* Create placeholders within the MathML element */
2098: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.132 cvs 2099: break;
1.1 cvs 2100: case MathML_EL_MI:
2101: SetFontstyleAttr (el, doc);
2102: break;
2103: case MathML_EL_MO:
1.22 cvs 2104: SetIntAddSpaceAttr (el, doc);
2105: SetIntVertStretchAttr (el, doc, 0, NULL);
1.58 cvs 2106: /* if the MO element is a child of a MROW (or equivalent) and if it
2107: contains a fence character, transform this MO into MF and
2108: transform the fence character into a Thot SYMBOL */
2109: CheckFence (el, doc);
1.1 cvs 2110: break;
1.60 cvs 2111: case MathML_EL_MSPACE:
2112: break;
1.39 cvs 2113: case MathML_EL_MROW:
1.55 cvs 2114: /* Create placeholders within the MROW */
2115: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.39 cvs 2116: break;
2117: case MathML_EL_MFRAC:
1.54 cvs 2118: case MathML_EL_BevelledMFRAC:
1.39 cvs 2119: /* end of a fraction. Create a Numerator and a Denominator */
1.56 cvs 2120: ok = CheckMathSubExpressions (el, MathML_EL_Numerator,
2121: MathML_EL_Denominator, 0, doc);
1.39 cvs 2122: break;
2123: case MathML_EL_MSQRT:
1.50 cvs 2124: /* end of a Square Root */
2125: /* Create placeholders within the element */
2126: CreatePlaceholders (TtaGetFirstChild (el), doc);
2127: /* Create a SqrtBase that contains all children of the MSQRT */
1.39 cvs 2128: CreateWrapper (el, MathML_EL_SqrtBase, doc);
2129: break;
1.1 cvs 2130: case MathML_EL_MROOT:
2131: /* end of a Root. Create a RootBase and an Index */
1.56 cvs 2132: ok = CheckMathSubExpressions (el, MathML_EL_RootBase,
2133: MathML_EL_Index, 0, doc);
1.1 cvs 2134: break;
1.50 cvs 2135: case MathML_EL_MENCLOSE:
2136: /* Create placeholders within the element */
2137: CreatePlaceholders (TtaGetFirstChild (el), doc);
2138: break;
1.39 cvs 2139: case MathML_EL_MSTYLE:
2140: case MathML_EL_MERROR:
2141: case MathML_EL_MPADDED:
2142: case MathML_EL_MPHANTOM:
2143: /* Create placeholders within the element */
2144: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.1 cvs 2145: break;
2146: case MathML_EL_MFENCED:
2147: TransformMFENCED (el, doc);
2148: break;
2149: case MathML_EL_MSUB:
2150: /* end of a MSUB. Create Base and Subscript */
1.56 cvs 2151: ok = CheckMathSubExpressions (el, MathML_EL_Base,
2152: MathML_EL_Subscript, 0, doc);
1.59 cvs 2153: SetScriptShift (el, doc, MathML_ATTR_subscriptshift);
1.22 cvs 2154: SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1 cvs 2155: break;
2156: case MathML_EL_MSUP:
2157: /* end of a MSUP. Create Base and Superscript */
1.56 cvs 2158: ok = CheckMathSubExpressions (el, MathML_EL_Base,
2159: MathML_EL_Superscript, 0, doc);
1.59 cvs 2160: SetScriptShift (el, doc, MathML_ATTR_superscriptshift);
1.22 cvs 2161: SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1 cvs 2162: break;
1.39 cvs 2163: case MathML_EL_MSUBSUP:
2164: /* end of a MSUBSUP. Create Base, Subscript, and Superscript */
1.56 cvs 2165: ok = CheckMathSubExpressions (el, MathML_EL_Base,
2166: MathML_EL_Subscript,
2167: MathML_EL_Superscript, doc);
1.59 cvs 2168: SetScriptShift (el, doc, MathML_ATTR_subscriptshift);
2169: SetScriptShift (el, doc, MathML_ATTR_superscriptshift);
1.39 cvs 2170: SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1 cvs 2171: break;
2172: case MathML_EL_MUNDER:
2173: /* end of a MUNDER. Create UnderOverBase, and Underscript */
1.56 cvs 2174: ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
2175: MathML_EL_Underscript, 0, doc);
1.22 cvs 2176: SetIntHorizStretchAttr (el, doc);
2177: SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
1.1 cvs 2178: break;
2179: case MathML_EL_MOVER:
2180: /* end of a MOVER. Create UnderOverBase, and Overscript */
1.56 cvs 2181: ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
2182: MathML_EL_Overscript, 0, doc);
1.22 cvs 2183: SetIntHorizStretchAttr (el, doc);
2184: SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
1.1 cvs 2185: break;
1.39 cvs 2186: case MathML_EL_MUNDEROVER:
2187: /* end of a MUNDEROVER. Create UnderOverBase, Underscript, and
2188: Overscript */
1.56 cvs 2189: ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
2190: MathML_EL_Underscript,
2191: MathML_EL_Overscript, doc);
1.39 cvs 2192: SetIntHorizStretchAttr (el, doc);
2193: SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
2194: break;
1.1 cvs 2195: case MathML_EL_MMULTISCRIPTS:
2196: /* end of a MMULTISCRIPTS. Create all elements defined in the
2197: MathML S schema */
2198: BuildMultiscript (el, doc);
1.5 cvs 2199: break;
2200: case MathML_EL_MTABLE:
2201: /* end of a MTABLE. Create all elements defined in the MathML S
2202: schema */
1.64 cvs 2203: CheckMTable (el, doc, TRUE);
1.101 cvs 2204: /* if the table has a rowalign attribute, process it */
2205: attrType.AttrSSchema = MathMLSSchema;
2206: attrType.AttrTypeNum = MathML_ATTR_rowalign;
2207: attr = TtaGetAttribute (el, attrType);
2208: if (attr)
2209: HandleRowalignAttribute (attr, el, doc, FALSE);
2210: /* if the table has a columnalign attribute, process it */
2211: attrType.AttrTypeNum = MathML_ATTR_columnalign;
2212: attr = TtaGetAttribute (el, attrType);
2213: if (attr)
1.108 cvs 2214: HandleColalignAttribute (attr, el, doc, FALSE, FALSE);
1.101 cvs 2215: break;
2216: case MathML_EL_MTR:
2217: /* if the row has a columnalign attribute, process it */
2218: attrType.AttrSSchema = MathMLSSchema;
2219: attrType.AttrTypeNum = MathML_ATTR_columnalign;
2220: attr = TtaGetAttribute (el, attrType);
2221: if (attr)
1.108 cvs 2222: HandleColalignAttribute (attr, el, doc, FALSE, TRUE);
1.101 cvs 2223: break;
2224: case MathML_EL_MLABELEDTR:
2225: /* if the row has a columnalign attribute, process it */
2226: attrType.AttrSSchema = MathMLSSchema;
2227: attrType.AttrTypeNum = MathML_ATTR_columnalign;
2228: attr = TtaGetAttribute (el, attrType);
2229: if (attr)
1.108 cvs 2230: HandleColalignAttribute (attr, el, doc, FALSE, TRUE);
1.1 cvs 2231: break;
1.39 cvs 2232: case MathML_EL_MTD:
2233: /* Create placeholders within the table cell */
2234: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.46 cvs 2235: break;
1.39 cvs 2236: case MathML_EL_MACTION:
2237: /* Create placeholders within the MACTION element */
2238: CreatePlaceholders (TtaGetFirstChild (el), doc);
1.1 cvs 2239: break;
2240: default:
2241: break;
2242: }
2243: parent = TtaGetParent (el);
1.118 cvs 2244: if (parent)
2245: {
2246: parentType = TtaGetElementType (parent);
2247: if (parentType.ElSSchema != elType.ElSSchema)
2248: /* root of a MathML tree, Create a MathML element if there is no */
2249: if (elType.ElTypeNum != MathML_EL_MathML)
2250: {
2251: elType.ElSSchema = MathMLSSchema;
2252: elType.ElTypeNum = MathML_EL_MathML;
2253: new = TtaNewElement (doc, elType);
2254: TtaInsertSibling (new, el, TRUE, doc);
2255: next = el;
2256: TtaNextSibling (&next);
2257: TtaRemoveTree (el, doc);
2258: TtaInsertFirstChild (&el, new, doc);
2259: prev = el;
2260: while (next != NULL)
2261: {
2262: child = next;
2263: TtaNextSibling (&next);
2264: TtaRemoveTree (child, doc);
2265: TtaInsertSibling (child, prev, FALSE, doc);
2266: prev = child;
2267: }
2268: /* Create placeholders within the MathML element */
2269: CreatePlaceholders (el, doc);
2270: }
2271: }
1.1 cvs 2272: }
1.56 cvs 2273: if (!ok)
2274: /* send an error message */
2275: *error = 1;
1.1 cvs 2276: }
2277:
2278: /*----------------------------------------------------------------------
1.126 cvs 2279: UnknownMathMLNameSpace
2280: Create an element that belongs to a non-supported namespace
2281: ----------------------------------------------------------------------*/
2282: void UnknownMathMLNameSpace (ParserData *context, char* content)
2283: {
2284: ElementType elType;
2285: Element elInv, elText;
2286:
2287: /* Create a new Invalid_element */
2288: elType.ElSSchema = GetXMLSSchema (MATH_TYPE, context->doc);
2289: elType.ElTypeNum = MathML_EL_Unknown_namespace;
2290: elInv = TtaNewElement (context->doc, elType);
2291: if (elInv != NULL)
2292: {
2293: XmlSetElemLineNumber (elInv);
2294: InsertXmlElement (&elInv);
2295: context->lastElementClosed = TRUE;
2296: elType.ElTypeNum = MathML_EL_TEXT_UNIT;
2297: elText = TtaNewElement (context->doc, elType);
2298: XmlSetElemLineNumber (elText);
2299: TtaInsertFirstChild (&elText, elInv, context->doc);
2300: TtaSetTextContent (elText, content, context->language, context->doc);
2301: TtaSetAccessRight (elText, ReadOnly, context->doc);
2302: }
2303: }
2304:
2305: /*----------------------------------------------------------------------
1.24 cvs 2306: SetFontfamily
2307: -----------------------------------------------------------------------*/
1.120 cvs 2308: void SetFontfamily (Document doc, Element el, char *value)
1.24 cvs 2309: {
2310: #define buflen 50
1.116 cvs 2311: char css_command[buflen+20];
1.24 cvs 2312:
1.116 cvs 2313: sprintf (css_command, "font-family: %s", value);
1.72 cvs 2314: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.24 cvs 2315: }
2316:
2317: /*----------------------------------------------------------------------
1.83 cvs 2318: MathMLlinethickness
2319: The MathML attribute linthickness is associated with element el. Generate
2320: the corresponding style property for this element.
2321: -----------------------------------------------------------------------*/
1.120 cvs 2322: void MathMLlinethickness (Document doc, Element el, char *value)
1.83 cvs 2323: {
2324: #define buflen 50
1.116 cvs 2325: char css_command[buflen+20];
1.83 cvs 2326:
1.116 cvs 2327: if (strcmp (value, "thin") == 0)
2328: strcpy (value, "1pt");
2329: else if (strcmp (value, "medium") == 0)
2330: strcpy (value, "1pt");
2331: else if (strcmp (value, "thick") == 0)
2332: strcpy (value, "2pt");
2333: sprintf (css_command, "stroke-width: %s", value);
1.83 cvs 2334: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
2335: }
2336:
2337: /*----------------------------------------------------------------------
1.58 cvs 2338: MathMLAttrToStyleProperty
2339: The MathML attribute attr is associated with element el. Generate
2340: the corresponding style property for this element.
1.24 cvs 2341: -----------------------------------------------------------------------*/
1.138 cvs 2342: void MathMLAttrToStyleProperty (Document doc, Element el, char *value,
2343: int attr)
1.24 cvs 2344: {
1.116 cvs 2345: char css_command[buflen+20];
1.141 ! quint 2346: int i;
1.58 cvs 2347:
2348: switch (attr)
2349: {
2350: case MathML_ATTR_fontsize:
1.116 cvs 2351: sprintf (css_command, "font-size: %s", value);
1.58 cvs 2352: break;
1.93 cvs 2353: case MathML_ATTR_mathsize:
1.116 cvs 2354: if (strcmp (value, "small") == 0)
2355: strcpy (value, "80%");
2356: else if (strcmp (value, "normal") == 0)
2357: strcpy (value, "100%");
2358: else if (strcmp (value, "big") == 0)
2359: strcpy (value, "125%");
2360: sprintf (css_command, "font-size: %s", value);
1.93 cvs 2361: break;
1.58 cvs 2362: case MathML_ATTR_lspace:
2363: case MathML_ATTR_rspace:
1.141 ! quint 2364: if (attr == MathML_ATTR_lspace)
! 2365: strcpy (css_command, "padding-left: ");
! 2366: else
! 2367: strcpy (css_command, "padding-right: ");
! 2368: /* is the value a named space? */
! 2369: if (strcmp (value, "veryverythinmathspace") == 0)
! 2370: strcat (css_command, "0.0555556em");
! 2371: else if (strcmp (value, "verythinmathspace") == 0)
! 2372: strcat (css_command, "0.111111em");
! 2373: else if (strcmp (value, "thinmathspace") == 0)
! 2374: strcat (css_command, "0.166667em");
! 2375: else if (strcmp (value, "mediummathspace") == 0)
! 2376: strcat (css_command, "0.222222em");
! 2377: else if (strcmp (value, "thickmathspace") == 0)
! 2378: strcat (css_command, "0.277778em");
! 2379: else if (strcmp (value, "verythickmathspace") == 0)
! 2380: strcat (css_command, "0.333333em");
! 2381: else if (strcmp (value, "veryverythickmathspace") == 0)
! 2382: strcat (css_command, "0.388889em");
! 2383: else
! 2384: {
! 2385: strcat (css_command, value);
! 2386: /* does the value contain an unit at the end? */
! 2387: i = strlen (value) - 1;
! 2388: if ((value[i] <= '9' && value[i] >= '0') ||
! 2389: value[i] == '.')
! 2390: /* it's just a number. Add the (implicit) unit: em */
! 2391: strcat (css_command, "em");
! 2392: }
1.58 cvs 2393: break;
2394: }
1.72 cvs 2395: ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.24 cvs 2396: }
2397:
2398: /*----------------------------------------------------------------------
1.60 cvs 2399: MathMLSetScriptLevel
2400: A scriptlevel attribute with value value is associated with element el.
2401: Generate the corresponding style property for this element.
2402: -----------------------------------------------------------------------*/
1.120 cvs 2403: void MathMLSetScriptLevel (Document doc, Element el, char *value)
1.60 cvs 2404: {
2405: PresentationValue pval;
2406: PresentationContext ctxt;
2407: ThotBool relative;
2408: int percentage;
2409:
2410: ctxt = TtaGetSpecificStyleContext (doc);
2411: if (!value)
2412: /* remove the presentation rule */
2413: {
2414: ctxt->destroy = TRUE;
1.75 cvs 2415: pval.typed_data.value = 0;
1.60 cvs 2416: TtaSetStylePresentation (PRSize, el, NULL, ctxt, pval);
2417: }
2418: else
2419: {
2420: ctxt->destroy = FALSE;
2421: /* parse the attribute value (an optional sign and an integer) */
1.119 cvs 2422: value = TtaSkipBlanks (value);
1.60 cvs 2423: relative = (value[0] == '-' || value[0] == '+');
2424: value = ParseCSSUnit (value, &pval);
2425: if (pval.typed_data.unit != STYLE_UNIT_REL &&
2426: pval.typed_data.real)
2427: /* this is an error: it should be an integer without any unit name */
2428: /* error */;
2429: else
2430: {
2431: if (relative)
2432: {
1.63 cvs 2433: percentage = 100;
1.60 cvs 2434: if (pval.typed_data.value == 0)
2435: /* scriptlevel="+0" */
2436: percentage = 100;
2437: else if (pval.typed_data.value == 1)
2438: /* scriptlevel="+1" */
2439: percentage = 71;
2440: else if (pval.typed_data.value == 2)
2441: /* scriptlevel="+2" */
2442: percentage = 50;
2443: else if (pval.typed_data.value >= 3)
2444: /* scriptlevel="+3" or more */
2445: percentage = 35;
2446: else if (pval.typed_data.value == -1)
2447: /* scriptlevel="-1" */
2448: percentage = 141;
2449: else if (pval.typed_data.value == -2)
2450: /* scriptlevel="-2" */
2451: percentage = 200;
2452: else if (pval.typed_data.value <= -3)
2453: /* scriptlevel="-3" or less */
2454: percentage = 282;
2455: pval.typed_data.value = percentage;
2456: pval.typed_data.unit = STYLE_UNIT_PERCENT;
1.78 cvs 2457: /* the specific presentation to be created is not a CSS rule */
2458: ctxt->cssLevel = 0;
1.60 cvs 2459: TtaSetStylePresentation (PRSize, el, NULL, ctxt, pval);
2460: }
2461: else
2462: /* absolute value */
2463: {
2464: /**** ****/;
2465: }
2466: }
2467: }
2468: TtaFreeMemory (ctxt);
2469: }
2470:
2471: /*----------------------------------------------------------------------
2472: MathMLSpacingAttr
2473: The MathML attribute attr (height, width or depth) is associated
2474: with element el (a mspace or mpadding).
2475: If value is not NULL, generate the corresponding Thot presentation rule for
2476: the element.
2477: If value is NULL, remove the corresponding Thot presentation rule.
2478: -----------------------------------------------------------------------*/
1.120 cvs 2479: void MathMLSpacingAttr (Document doc, Element el, char *value, int attr)
1.60 cvs 2480: {
2481: ElementType elType;
2482: PresentationValue pval;
2483: PresentationContext ctxt;
2484: int ruleType;
2485:
2486: /* provisionally, handles only mspace elements */
2487: elType = TtaGetElementType (el);
1.96 cvs 2488: if (elType.ElTypeNum != MathML_EL_MSPACE &&
1.97 cvs 2489: elType.ElTypeNum != MathML_EL_MPADDED &&
2490: elType.ElTypeNum != MathML_EL_MTABLE)
1.60 cvs 2491: return;
2492: switch (attr)
2493: {
2494: case MathML_ATTR_width_:
2495: ruleType = PRWidth;
2496: break;
2497: case MathML_ATTR_height_:
2498: ruleType = PRPaddingTop;
2499: break;
2500: case MathML_ATTR_depth_:
2501: ruleType = PRPaddingBottom;
2502: break;
2503: default:
2504: return;
2505: }
2506: ctxt = TtaGetSpecificStyleContext (doc);
1.116 cvs 2507: if (!value || (strcmp (value, "auto") == 0))
1.60 cvs 2508: /* remove the presentation rule */
2509: {
2510: ctxt->destroy = TRUE;
1.75 cvs 2511: pval.typed_data.value = 0;
1.60 cvs 2512: TtaSetStylePresentation (ruleType, el, NULL, ctxt, pval);
2513: }
2514: else
2515: {
2516: ctxt->destroy = FALSE;
2517: /* parse the attribute value (a number followed by a unit) */
1.119 cvs 2518: value = TtaSkipBlanks (value);
1.60 cvs 2519: value = ParseCSSUnit (value, &pval);
2520: /***** we should accept namedspace for width *****/
2521: if (pval.typed_data.unit != STYLE_UNIT_INVALID)
1.78 cvs 2522: {
2523: /* the specific presentation to be created is not a CSS rule */
2524: ctxt->cssLevel = 0;
2525: TtaSetStylePresentation (ruleType, el, NULL, ctxt, pval);
2526: }
1.60 cvs 2527: }
2528: TtaFreeMemory (ctxt);
2529: }
2530:
2531: /*----------------------------------------------------------------------
1.1 cvs 2532: MathMLAttributeComplete
1.58 cvs 2533: The XML parser has completed parsing attribute attr (as well as its value)
2534: that is associated with element el in document doc.
1.1 cvs 2535: ----------------------------------------------------------------------*/
1.120 cvs 2536: void MathMLAttributeComplete (Attribute attr, Element el, Document doc)
1.1 cvs 2537: {
1.134 cvs 2538: AttributeType attrType, depAttrType;
1.23 cvs 2539: int attrKind;
1.50 cvs 2540: ElementType elType;
1.23 cvs 2541: #define buflen 50
1.120 cvs 2542: char *value;
1.50 cvs 2543: int val, length;
1.101 cvs 2544: Attribute intAttr;
1.23 cvs 2545:
1.58 cvs 2546: /* first get the type of that attribute */
1.23 cvs 2547: TtaGiveAttributeType (attr, &attrType, &attrKind);
1.54 cvs 2548: if (attrType.AttrTypeNum == MathML_ATTR_bevelled)
1.58 cvs 2549: /* it's a bevelled attribute */
1.50 cvs 2550: {
2551: val = TtaGetAttributeValue (attr);
1.54 cvs 2552: if (val == MathML_ATTR_bevelled_VAL_true)
2553: /* bevelled = true. Transform MFRAC into BevelledMFRAC */
1.50 cvs 2554: {
2555: elType = TtaGetElementType (el);
2556: if (elType.ElTypeNum == MathML_EL_MFRAC)
1.54 cvs 2557: ChangeTypeOfElement (el, doc, MathML_EL_BevelledMFRAC);
1.50 cvs 2558: }
2559: }
1.101 cvs 2560:
2561: else if (attrType.AttrTypeNum == MathML_ATTR_rowalign_mtr)
2562: {
2563: /* create an equivalent IntRowAlign attribute on the same element */
2564: attrType.AttrTypeNum = MathML_ATTR_IntRowAlign;
2565: intAttr = TtaGetAttribute (el, attrType);
2566: if (!intAttr)
2567: /* no IntRowAlign attribute, create one */
2568: {
2569: intAttr = TtaNewAttribute (attrType);
2570: TtaAttachAttribute (el, intAttr, doc);
2571: }
2572: val = TtaGetAttributeValue (attr);
2573: TtaSetAttributeValue (intAttr, val, el, doc);
2574: }
2575:
2576: else if (attrType.AttrTypeNum == MathML_ATTR_rowalign)
2577: {
2578: /* parse the attribute value and create a IntRowAlign attribute
2579: for each mrow contained in the element */
2580: HandleRowalignAttribute (attr, el, doc, FALSE);
2581: }
2582:
2583: else if (attrType.AttrTypeNum == MathML_ATTR_columnalign_mtd)
2584: {
2585: /* create an equivalent IntColAlign attribute on the same element */
2586: attrType.AttrTypeNum = MathML_ATTR_IntColAlign;
2587: intAttr = TtaGetAttribute (el, attrType);
2588: if (!intAttr)
2589: /* no IntColAlign 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:
1.104 cvs 2598: /* don't handle attribute columnalign now: the table or the row is not
2599: complete yet. Handle it when the element is complete.
1.101 cvs 2600: else if (attrType.AttrTypeNum == MathML_ATTR_columnalign)
1.104 cvs 2601: */
1.138 cvs 2602:
2603: else if (attrType.AttrTypeNum == MathML_ATTR_Language)
2604: {
2605: if (el == TtaGetRootElement (doc))
2606: /* it's the lang attribute on the root element */
2607: /* set the RealLang attribute */
2608: {
2609: depAttrType.AttrSSchema = attrType.AttrSSchema ;
2610: depAttrType.AttrTypeNum = MathML_ATTR_RealLang;
2611: if (!TtaGetAttribute (el, depAttrType))
2612: /* it's not present. Add it */
2613: {
2614: intAttr = TtaNewAttribute (depAttrType);
2615: TtaAttachAttribute (el, intAttr, doc);
2616: TtaSetAttributeValue (intAttr, MathML_ATTR_RealLang_VAL_Yes_,
2617: el, doc);
2618: }
2619: }
2620: }
1.101 cvs 2621:
1.50 cvs 2622: else if (attrType.AttrTypeNum == MathML_ATTR_color ||
1.93 cvs 2623: attrType.AttrTypeNum == MathML_ATTR_mathcolor ||
2624: attrType.AttrTypeNum == MathML_ATTR_background_ ||
2625: attrType.AttrTypeNum == MathML_ATTR_mathbackground ||
2626: attrType.AttrTypeNum == MathML_ATTR_fontsize ||
2627: attrType.AttrTypeNum == MathML_ATTR_mathsize ||
2628: attrType.AttrTypeNum == MathML_ATTR_fontfamily ||
2629: attrType.AttrTypeNum == MathML_ATTR_linethickness ||
2630: attrType.AttrTypeNum == MathML_ATTR_lspace ||
2631: attrType.AttrTypeNum == MathML_ATTR_rspace ||
2632: attrType.AttrTypeNum == MathML_ATTR_scriptlevel ||
2633: attrType.AttrTypeNum == MathML_ATTR_width_ ||
2634: attrType.AttrTypeNum == MathML_ATTR_height_ ||
2635: attrType.AttrTypeNum == MathML_ATTR_depth_ )
2636: {
1.23 cvs 2637: length = TtaGetTextAttributeLength (attr);
2638: if (length >= buflen)
2639: length = buflen - 1;
2640: if (length > 0)
2641: {
1.116 cvs 2642: value = TtaGetMemory (buflen);
1.33 cvs 2643: value[0] = EOS;
2644: TtaGiveTextAttributeValue (attr, value, &length);
2645: switch (attrType.AttrTypeNum)
2646: {
2647: case MathML_ATTR_color:
1.134 cvs 2648: /* deprecated attribute */
2649: /* if the same element has a mathcolor attribute, ignore
2650: the color attribute */
2651: depAttrType.AttrSSchema = attrType.AttrSSchema ;
2652: depAttrType.AttrTypeNum = MathML_ATTR_mathcolor;
2653: if (!TtaGetAttribute (el, depAttrType))
2654: HTMLSetForegroundColor (doc, el, value);
2655: break;
1.93 cvs 2656: case MathML_ATTR_mathcolor:
1.24 cvs 2657: HTMLSetForegroundColor (doc, el, value);
2658: break;
1.33 cvs 2659: case MathML_ATTR_background_:
1.134 cvs 2660: /* deprecated attribute */
2661: /* if the same element has a mathbackground attribute, ignore
2662: the background attribute */
2663: depAttrType.AttrSSchema = attrType.AttrSSchema;
2664: depAttrType.AttrTypeNum = MathML_ATTR_mathbackground;
2665: if (!TtaGetAttribute (el, depAttrType))
2666: HTMLSetBackgroundColor (doc, el, value);
2667: break;
1.93 cvs 2668: case MathML_ATTR_mathbackground:
1.24 cvs 2669: HTMLSetBackgroundColor (doc, el, value);
2670: break;
1.33 cvs 2671: case MathML_ATTR_fontfamily:
1.24 cvs 2672: SetFontfamily (doc, el, value);
1.83 cvs 2673: break;
2674: case MathML_ATTR_linethickness:
2675: MathMLlinethickness (doc, el, value);
1.58 cvs 2676: break;
2677: case MathML_ATTR_fontsize:
1.134 cvs 2678: /* deprecated attribute */
2679: /* if the same element has a mathsize attribute, ignore
2680: the fontsize attribute */
2681: depAttrType.AttrSSchema = attrType.AttrSSchema;
2682: depAttrType.AttrTypeNum = MathML_ATTR_mathsize;
2683: if (!TtaGetAttribute (el, depAttrType))
2684: MathMLAttrToStyleProperty (doc, el, value,
2685: attrType.AttrTypeNum);
2686: break;
1.93 cvs 2687: case MathML_ATTR_mathsize:
1.58 cvs 2688: case MathML_ATTR_lspace:
2689: case MathML_ATTR_rspace:
1.60 cvs 2690: MathMLAttrToStyleProperty (doc, el, value,attrType.AttrTypeNum);
2691: break;
2692: case MathML_ATTR_scriptlevel:
2693: MathMLSetScriptLevel (doc, el, value);
2694: break;
2695: case MathML_ATTR_width_:
2696: case MathML_ATTR_height_:
2697: case MathML_ATTR_depth_:
2698: MathMLSpacingAttr (doc, el, value, attrType.AttrTypeNum);
1.59 cvs 2699: break;
2700: default:
1.24 cvs 2701: break;
1.33 cvs 2702: }
2703: TtaFreeMemory (value);
1.23 cvs 2704: }
2705: }
1.1 cvs 2706: }
2707:
2708: /*----------------------------------------------------------------------
2709: MathMLGetDTDName
2710: ----------------------------------------------------------------------*/
1.120 cvs 2711: void MathMLGetDTDName (char *DTDname, char *elementName)
1.1 cvs 2712: {
2713: /* no other DTD allowed within MathML elements */
1.116 cvs 2714: strcpy (DTDname, "");
1.1 cvs 2715: }
2716:
2717: /* end of module */
Webmaster