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