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