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