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