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