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