Annotation of Amaya/amaya/MathMLbuilder.c, revision 1.98

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

Webmaster