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