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

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);
                   1025:      if (elType.ElTypeNum == MathML_EL_MO)
                   1026:        /* the first child is a MO */
                   1027:         {
                   1028:         sibling = child;
                   1029:         TtaNextSibling (&sibling);
                   1030:        if (sibling == NULL)
                   1031:           /* there is no other child */
                   1032:           {
                   1033:           textEl = TtaGetFirstChild (child);
                   1034:           elType = TtaGetElementType (textEl);
                   1035:           if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)
1.55      cvs      1036:              /* the MO child contains a TEXT element */
1.1       cvs      1037:              {
                   1038:              len = TtaGetTextLength (textEl);
                   1039:              if (len == 1)
1.55      cvs      1040:                /* the TEXT element contains a single character */
1.1       cvs      1041:                {
1.55      cvs      1042:                /* get that character */
1.1       cvs      1043:                len = 2;
                   1044:                TtaGiveTextContent (textEl, text, &len, &lang);
                   1045:                alphabet = TtaGetAlphabet (lang);
1.55      cvs      1046:                if (alphabet == 'G')
                   1047:                   /* a single Symbol character */
                   1048:                   if ((int)text[0] == 172 || (int)text[0] == 174 ||
1.89      cvs      1049:                       (int)text[0] == 45  ||
                   1050:                       (int)text[0] == 132 || (int)text[0] == 133)
                   1051:                      /* horizontal arrow, horizontal bar, horizontal brace */
1.55      cvs      1052:                      {
                   1053:                      c = EOS;
                   1054:                      /* attach a IntHorizStretch attribute */
                   1055:                      attrType.AttrSSchema = elType.ElSSchema;
                   1056:                      attrType.AttrTypeNum = MathML_ATTR_IntHorizStretch;
                   1057:                      attr = TtaNewAttribute (attrType);
                   1058:                      TtaAttachAttribute (el, attr, doc);
                   1059:                      TtaSetAttributeValue (attr, MathML_ATTR_IntHorizStretch_VAL_yes_, el, doc);
                   1060:                      /* replace the TEXT element by a Thot SYMBOL element */
                   1061:                      elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
                   1062:                      symbolEl = TtaNewElement (doc, elType);
                   1063:                      TtaInsertSibling (symbolEl, textEl, FALSE, doc);
                   1064:                      if (selEl != NULL)
                   1065:                        if (*selEl == textEl)
                   1066:                          *selEl = symbolEl;
                   1067:                      TtaDeleteTree (textEl, doc);
                   1068:                      if ((int)text[0] == 172)
1.89      cvs      1069:                        c = 'L';  /* arrow left */
                   1070:                      else if ((int)text[0] == 174)
                   1071:                        c = 'R';  /* arrow right */
                   1072:                      else if ((int)text[0] == 45)    /* - (minus) */
1.55      cvs      1073:                        /* a horizontal line in the middle of the box */
                   1074:                        c = 'h'; 
1.89      cvs      1075:                      else if ((int)text[0] == 132)
                   1076:                        c = 'o';  /* Over brace */
                   1077:                      else if ((int)text[0] == 133)
                   1078:                        c = 'u';  /* Under brace */
1.55      cvs      1079:                      if (c != EOS)
                   1080:                        TtaSetGraphicsShape (symbolEl, c, doc);
                   1081:                      }
1.1       cvs      1082:                }
                   1083:              }
                   1084:           }
                   1085:        }
                   1086:      }
                   1087: }
                   1088: 
                   1089: /*----------------------------------------------------------------------
1.22      cvs      1090:    SetIntHorizStretchAttr
1.1       cvs      1091: 
1.22      cvs      1092:    Put a IntHorizStretch attribute on all children of element el which
1.1       cvs      1093:    contain only a MO element that is a stretchable symbol.
                   1094:  -----------------------------------------------------------------------*/
                   1095: #ifdef __STDC__
1.22      cvs      1096: static void SetIntHorizStretchAttr (Element el, Document doc)
1.1       cvs      1097: #else /* __STDC__*/
1.22      cvs      1098: static void SetIntHorizStretchAttr (el, doc)
1.1       cvs      1099:   Element      el;
                   1100:   Document     doc;
                   1101: #endif /* __STDC__*/
                   1102: {
                   1103:   Element      child;
                   1104: 
                   1105:   if (el == NULL)
                   1106:      return;
                   1107:   child = TtaGetFirstChild (el);
                   1108:   while (child != NULL)
                   1109:      {
1.22      cvs      1110:      SetSingleIntHorizStretchAttr (child, doc, NULL);
1.1       cvs      1111:      TtaNextSibling (&child);
                   1112:      }
                   1113: }
                   1114: 
                   1115: /*----------------------------------------------------------------------
1.22      cvs      1116:    SetIntVertStretchAttr
1.1       cvs      1117: 
1.22      cvs      1118:    Put a IntVertStretch attribute on element el if its base element
1.1       cvs      1119:    (Base for a MSUBSUP, MSUP or MSUB; UnderOverBase for a MUNDEROVER,
                   1120:    a MUNDER of a MOVER) contains only a MO element that is a vertically
                   1121:    stretchable symbol.
                   1122:  -----------------------------------------------------------------------*/
                   1123: #ifdef __STDC__
1.22      cvs      1124: void SetIntVertStretchAttr (Element el, Document doc, int base, Element* selEl)
1.1       cvs      1125: #else /* __STDC__*/
1.22      cvs      1126: void SetIntVertStretchAttr (el, doc, base, selEl)
1.1       cvs      1127:   Element      el;
                   1128:   Document     doc;
                   1129:   int          base;
                   1130:   Element*     selEl;
                   1131: #endif /* __STDC__*/
                   1132: {
                   1133:   Element      child, sibling, textEl, symbolEl, parent, operator;
                   1134:   ElementType  elType;
                   1135:   Attribute    attr;
                   1136:   AttributeType        attrType;
1.47      cvs      1137:   int              len;
                   1138:   Language         lang;
1.15      cvs      1139:   CHAR_T               alphabet;
1.49      cvs      1140:   UCHAR_T       text[2];
                   1141:   unsigned char c;
1.1       cvs      1142: 
                   1143:   if (el == NULL)
                   1144:      return;
                   1145:   operator = NULL;
                   1146:   if (base == 0)
                   1147:      /* it's a MO */
                   1148:      {
                   1149:      parent = TtaGetParent (el);
                   1150:      if (parent != NULL)
                   1151:        {
                   1152:        elType = TtaGetElementType (parent);
                   1153:        if (elType.ElTypeNum != MathML_EL_Base &&
                   1154:            elType.ElTypeNum != MathML_EL_UnderOverBase &&
                   1155:            elType.ElTypeNum != MathML_EL_MSUBSUP &&
                   1156:            elType.ElTypeNum != MathML_EL_MSUB &&
                   1157:            elType.ElTypeNum != MathML_EL_MSUP &&
                   1158:            elType.ElTypeNum != MathML_EL_MUNDEROVER &&
                   1159:            elType.ElTypeNum != MathML_EL_MUNDER &&
                   1160:            elType.ElTypeNum != MathML_EL_MUNDEROVER)
                   1161:           operator = el;
                   1162:         }
                   1163:      }
                   1164:   else
                   1165:      /* it's not a MO */
                   1166:      {
                   1167:      /* search the Base or UnderOverBase child */
                   1168:      child = TtaGetFirstChild (el);
                   1169:      if (child != NULL)
                   1170:         {
                   1171:         elType = TtaGetElementType (child);
                   1172:         if (elType.ElTypeNum == base)
                   1173:           /* the first child is a Base or UnderOverBase */
                   1174:            {
                   1175:           child = TtaGetFirstChild (child);
                   1176:           if (child != NULL)
                   1177:              {
                   1178:              elType = TtaGetElementType (child);
                   1179:               if (elType.ElTypeNum == MathML_EL_MO)
                   1180:                 /* its first child is a MO */
                   1181:                  {
                   1182:                  sibling = child;
                   1183:                  TtaNextSibling (&sibling);
                   1184:                 if (sibling == NULL)
                   1185:                    /* there is no other child */
                   1186:                    operator = child;
                   1187:                 }
                   1188:              }
                   1189:           }
                   1190:        }
                   1191:      }
                   1192:   if (operator != NULL)
                   1193:      {
1.84      cvs      1194:      textEl = TtaGetFirstChild (operator);
                   1195:      if (textEl != NULL)
                   1196:         {
                   1197:        elType = TtaGetElementType (textEl);
                   1198:        if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)
                   1199:           {
                   1200:           len = TtaGetTextLength (textEl);
                   1201:           if (len == 1)
1.1       cvs      1202:              {
1.84      cvs      1203:              len = 2;
                   1204:              TtaGiveTextContent (textEl, text, &len, &lang); 
                   1205:              alphabet = TtaGetAlphabet (lang);
                   1206:              if (alphabet == 'G')
                   1207:                 /* a single Symbol character */
                   1208:                 if ((int)text[0] == 242)
                   1209:                    /* Integral */
1.55      cvs      1210:                    {
1.84      cvs      1211:                    /* attach a IntVertStretch attribute */
                   1212:                    attrType.AttrSSchema = elType.ElSSchema;
                   1213:                    attrType.AttrTypeNum = MathML_ATTR_IntVertStretch;
                   1214:                    attr = TtaNewAttribute (attrType);
                   1215:                    TtaAttachAttribute (el, attr, doc);
                   1216:                    TtaSetAttributeValue (attr,
                   1217:                                          MathML_ATTR_IntVertStretch_VAL_yes_,
                   1218:                                          el, doc);
                   1219:                    /* replace the TEXT element by a Thot SYMBOL element*/
                   1220:                    elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
                   1221:                    symbolEl = TtaNewElement (doc, elType);
                   1222:                    TtaInsertSibling (symbolEl, textEl, FALSE, doc);
                   1223:                    if (selEl != NULL)
                   1224:                       if (*selEl == textEl)
                   1225:                          *selEl = symbolEl;
                   1226:                    TtaDeleteTree (textEl, doc);
                   1227:                    c = 'i';
                   1228:                    TtaSetGraphicsShape (symbolEl, c, doc);
1.55      cvs      1229:                    }
1.1       cvs      1230:              }
1.84      cvs      1231:           }
                   1232:        }
1.1       cvs      1233:      }
                   1234: }
                   1235: 
                   1236: /*----------------------------------------------------------------------
1.22      cvs      1237:    SetIntPlaceholderAttr
1.1       cvs      1238: 
1.22      cvs      1239:    Put a IntPlaceholder attribute on all Construct elements in the
1.1       cvs      1240:    subtree of root el.
                   1241:  -----------------------------------------------------------------------*/
                   1242: #ifdef __STDC__
1.22      cvs      1243: static void SetIntPlaceholderAttr (Element el, Document doc)
1.1       cvs      1244: #else /* __STDC__*/
1.22      cvs      1245: static void SetIntPlaceholderAttr (el, doc)
1.1       cvs      1246:   Element      el;
                   1247:   Document     doc;
                   1248: #endif /* __STDC__*/
                   1249: {
                   1250:   Element      child;
                   1251:   ElementType  elType;
                   1252:   Attribute    attr;
                   1253:   AttributeType        attrType;
                   1254: 
                   1255:   if (el == NULL)
                   1256:      return;
                   1257:   elType = TtaGetElementType (el);
                   1258:   if (elType.ElTypeNum == MathML_EL_Construct &&
1.2       cvs      1259:       elType.ElSSchema == GetMathMLSSchema (doc))
1.1       cvs      1260:      {
                   1261:      attrType.AttrSSchema = elType.ElSSchema;
1.22      cvs      1262:      attrType.AttrTypeNum = MathML_ATTR_IntPlaceholder;
1.1       cvs      1263:      attr = TtaNewAttribute (attrType);
                   1264:      TtaAttachAttribute (el, attr, doc);
1.22      cvs      1265:      TtaSetAttributeValue (attr, MathML_ATTR_IntPlaceholder_VAL_yes_, el, doc);
1.1       cvs      1266:      }
                   1267:   else
                   1268:      {
                   1269:      child = TtaGetFirstChild (el);
                   1270:      while (child != NULL)
                   1271:         {
1.22      cvs      1272:         SetIntPlaceholderAttr (child, doc);
1.1       cvs      1273:         TtaNextSibling (&child);
                   1274:         }
                   1275:      }
                   1276: }
                   1277: 
                   1278: /*----------------------------------------------------------------------
                   1279:    BuildMultiscript
                   1280: 
                   1281:    The content of a MMULTISCRIPT element has been created following
                   1282:    the original MathML structure.  Create all Thot elements defined
                   1283:    in the MathML S schema.
                   1284:  -----------------------------------------------------------------------*/
                   1285: #ifdef __STDC__
                   1286: static void BuildMultiscript (Element elMMULTISCRIPT, Document doc)
                   1287: #else /* __STDC__*/
                   1288: static void BuildMultiscript (elMMULTISCRIPT, doc)
                   1289:   Element      elMMULTISCRIPT;
                   1290:   Document     doc;
                   1291: #endif /* __STDC__*/
                   1292: {
                   1293:   Element      elem, base, next, group, pair, script, prevPair, prevScript;
                   1294:   ElementType  elType, elTypeGroup, elTypePair, elTypeScript;
1.2       cvs      1295:   SSchema       MathMLSSchema;
1.1       cvs      1296:   base = NULL;
                   1297:   group = NULL;
                   1298:   prevPair = NULL;
                   1299:   prevScript = NULL;
                   1300: 
1.2       cvs      1301:   MathMLSSchema = GetMathMLSSchema (doc);
1.1       cvs      1302:   elTypeGroup.ElSSchema = MathMLSSchema;
                   1303:   elTypePair.ElSSchema = MathMLSSchema;
                   1304:   elTypeScript.ElSSchema = MathMLSSchema;
                   1305: 
                   1306:   /* process all children of the MMULTISCRIPT element */
                   1307:   elem = TtaGetFirstChild (elMMULTISCRIPT);
                   1308:   while (elem != NULL)
                   1309:     {
                   1310:       /* remember the element to be processed after the current one */
                   1311:       next = elem;
                   1312:       TtaNextSibling (&next);
                   1313: 
                   1314:       /* remove the current element from the tree */
                   1315:       TtaRemoveTree (elem, doc);
                   1316: 
                   1317:       if (base == NULL)
                   1318:        /* the current element is the first child of the MMULTISCRIPT
                   1319:           element */
                   1320:        {
                   1321:          /* Create a MultiscriptBase element as the first child of
                   1322:             MMULTISCRIPT and move the current element as the first child
                   1323:             of the MultiscriptBase element */
                   1324:          elTypeGroup.ElTypeNum = MathML_EL_MultiscriptBase;
                   1325:          base = TtaNewElement (doc, elTypeGroup);
                   1326:          TtaInsertFirstChild (&base, elMMULTISCRIPT, doc);
                   1327:          TtaInsertFirstChild (&elem, base, doc);
                   1328:        }
                   1329:       else
                   1330:        /* the current element is a subscript or a superscript */
                   1331:        {
                   1332:          if (group == NULL)
                   1333:            /* there is no PostscriptPairs element. Create one */
                   1334:            {
                   1335:              elTypeGroup.ElTypeNum = MathML_EL_PostscriptPairs;
                   1336:              group = TtaNewElement (doc, elTypeGroup);
                   1337:              TtaInsertSibling (group, base, FALSE, doc);
                   1338:              elTypePair.ElTypeNum = MathML_EL_PostscriptPair;
                   1339:              /* create a first and a last PostscriptPair as placeholders */
1.47      cvs      1340:              pair = TtaNewTree (doc, elTypePair, "");
1.1       cvs      1341:              TtaInsertFirstChild (&pair, group, doc);
1.22      cvs      1342:              SetIntPlaceholderAttr (pair, doc);
1.1       cvs      1343:              prevPair = pair;
1.47      cvs      1344:              pair = TtaNewTree (doc, elTypePair, "");
1.1       cvs      1345:              TtaInsertSibling (pair, prevPair, FALSE, doc);
1.22      cvs      1346:              SetIntPlaceholderAttr (pair, doc);
1.1       cvs      1347:              prevScript = NULL;
                   1348:            }
                   1349:          if (prevScript == NULL)
                   1350:            /* the current element is the first subscript or superscript
                   1351:               in a pair */
                   1352:            {
                   1353:              /* create a PostscriptPair or PrescriptPair element */
                   1354:              pair = TtaNewElement (doc, elTypePair);
                   1355:              if (prevPair == NULL)
                   1356:                TtaInsertFirstChild (&pair, group, doc);
                   1357:              else
                   1358:                TtaInsertSibling (pair, prevPair, FALSE, doc);
                   1359:              prevPair = pair;
                   1360:              /* create a MSubscript element */
                   1361:              elTypeScript.ElTypeNum = MathML_EL_MSubscript;
                   1362:              script = TtaNewElement (doc, elTypeScript);
                   1363:              TtaInsertFirstChild (&script, pair, doc);
                   1364:              prevScript = script;        
                   1365:            }
                   1366:          else
                   1367:            /* the current element is a superscript in a pair */
                   1368:            {
                   1369:              /* create a MSuperscript element */
                   1370:              elTypeScript.ElTypeNum = MathML_EL_MSuperscript;
                   1371:              script = TtaNewElement (doc, elTypeScript);
                   1372:              /* insert it as a sibling of the previous MSubscript element */
                   1373:              TtaInsertSibling (script, prevScript, FALSE, doc);
                   1374:              prevScript = NULL;          
                   1375:            }
                   1376:          /* insert the current element as a child of the new MSuperscript or
                   1377:             MSubscript element */
                   1378:          TtaInsertFirstChild (&elem, script, doc);
1.22      cvs      1379:          SetIntPlaceholderAttr (elem, doc);
1.1       cvs      1380:        }
                   1381: 
                   1382:       CreatePlaceholders (elem, doc);
                   1383: 
                   1384:       /* get next child of the MMULTISCRIPT element */
                   1385:       elem = next;
                   1386:       if (elem != NULL)
                   1387:        {
                   1388:          elType = TtaGetElementType (elem);
                   1389:          if (elType.ElSSchema == MathMLSSchema &&
                   1390:              elType.ElTypeNum == MathML_EL_PrescriptPairs)
                   1391:            /* the next element is a PrescriptPairs */
                   1392:            {
                   1393:              /* if there there is no PostscriptPairs element, create one as a
                   1394:                 placeholder */
                   1395:              if (elTypeGroup.ElTypeNum != MathML_EL_PostscriptPairs)
                   1396:                {
                   1397:                  elTypeGroup.ElTypeNum = MathML_EL_PostscriptPairs;
1.47      cvs      1398:                  group = TtaNewTree (doc, elTypeGroup, "");
1.1       cvs      1399:                  TtaInsertSibling (group, elem, TRUE, doc);
1.22      cvs      1400:                  SetIntPlaceholderAttr (group, doc);
1.1       cvs      1401:                }
                   1402:              /* the following elements will be interpreted as sub- superscripts
                   1403:                 in PrescriptPair elements, wich will be children of this
                   1404:                 PrescriptPairs element */
                   1405:              elTypeGroup.ElTypeNum = MathML_EL_PrescriptPairs;
                   1406:              elTypePair.ElTypeNum = MathML_EL_PrescriptPair;
                   1407:              group = elem;
                   1408:              /* create a first and a last PostscriptPair as placeholders */
1.47      cvs      1409:              pair = TtaNewTree (doc, elTypePair, "");
1.1       cvs      1410:              TtaInsertFirstChild (&pair, group, doc);
1.22      cvs      1411:              SetIntPlaceholderAttr (pair, doc);
1.1       cvs      1412:              prevPair = pair;
1.47      cvs      1413:              pair = TtaNewTree (doc, elTypePair, "");
1.1       cvs      1414:              TtaInsertSibling (pair, prevPair, FALSE, doc);
1.22      cvs      1415:              SetIntPlaceholderAttr (pair, doc);
1.1       cvs      1416:              prevScript = NULL;
                   1417:              TtaNextSibling (&elem);
                   1418:            }
                   1419:        }
                   1420:     }
                   1421:   /* all children of element MMULTISCRIPTS have been processed */
                   1422:   /* if the last group processed is not a PrescriptPairs element,
                   1423:      create one as a placeholder */
                   1424:   if (elTypeGroup.ElTypeNum != MathML_EL_PrescriptPairs && base != NULL)
                   1425:     {
                   1426:       elTypeGroup.ElTypeNum = MathML_EL_PrescriptPairs;
1.47      cvs      1427:       elem = TtaNewTree (doc, elTypeGroup, "");
1.1       cvs      1428:       if (group == NULL)
                   1429:        group = base;
                   1430:       TtaInsertSibling (elem, group, TRUE, doc);
1.22      cvs      1431:       SetIntPlaceholderAttr (elem, doc);
1.1       cvs      1432:     }
                   1433: }
                   1434: 
1.39      cvs      1435: /*----------------------------------------------------------------------
                   1436:    CreateWrapper
                   1437: 
                   1438:    Create an element of type wrapperType as a child of element el and
                   1439:    move all chidren of element el within the new element.
                   1440:  -----------------------------------------------------------------------*/
                   1441: #ifdef __STDC__
                   1442: static void CreateWrapper (Element el, int wrapperType, Document doc)
                   1443: #else /* __STDC__*/
                   1444: static void CreateWrapper (el, wrapperType, doc)
                   1445: Element el;
                   1446: int wrapperType;
                   1447: Document doc;
                   1448: #endif /* __STDC__*/
                   1449: {
                   1450:    Element       wrapper, child, prevChild, nextChild;
                   1451:    ElementType   elType;
                   1452: 
                   1453:    child = TtaGetFirstChild (el);
                   1454:    elType.ElSSchema = GetMathMLSSchema (doc);
                   1455:    elType.ElTypeNum = wrapperType;
                   1456:    wrapper = TtaNewElement (doc, elType);
                   1457:    TtaInsertFirstChild (&wrapper, el, doc);
                   1458:    prevChild = NULL;
                   1459:    while (child)
                   1460:      {
                   1461:        nextChild = child;
                   1462:        TtaNextSibling (&nextChild);
                   1463:        TtaRemoveTree (child, doc);
                   1464:        if (prevChild == NULL)
                   1465:         TtaInsertFirstChild (&child, wrapper, doc);
                   1466:        else
                   1467:         TtaInsertSibling (child, prevChild, FALSE, doc);
                   1468:        prevChild = child;
                   1469:        child = nextChild;
                   1470:      }
                   1471: }
1.5       cvs      1472: 
                   1473: /*----------------------------------------------------------------------
                   1474:    CheckMTable
                   1475: 
                   1476:    The content of a MTABLE element has been created following
                   1477:    the original MathML structure.  Create all Thot elements defined
                   1478:    in the MathML S schema.
1.64      cvs      1479:    If placeholder, associate an attribute IntPlaceholder with all
                   1480:    cells generated in a MathML table.
1.5       cvs      1481:  -----------------------------------------------------------------------*/
                   1482: #ifdef __STDC__
1.64      cvs      1483: void CheckMTable (Element elMTABLE, Document doc, ThotBool placeholder)
1.5       cvs      1484: #else /* __STDC__*/
1.64      cvs      1485: void CheckMTable (elMTABLE, doc, placeholder)
1.5       cvs      1486:   Element      elMTABLE;
                   1487:   Document     doc;
1.64      cvs      1488:   ThotBool      placeholder;
1.5       cvs      1489: #endif /* __STDC__*/
                   1490: {
                   1491:   ElementType  elType;
                   1492:   Element      MTableHead, MTableBody, row, nextRow, el, prevRow, cell,
1.40      cvs      1493:                nextCell, newMTD, firstColHead;
1.5       cvs      1494:   SSchema      MathMLSSchema;
                   1495: 
                   1496:   MathMLSSchema = GetMathMLSSchema (doc);
                   1497:   row = TtaGetFirstChild (elMTABLE);
                   1498: 
                   1499:   /* create a MTable_head as the first child of element MTABLE */
                   1500:   elType.ElSSchema = MathMLSSchema;
                   1501:   elType.ElTypeNum = MathML_EL_MTable_head;
                   1502:   MTableHead = TtaNewElement (doc, elType);
                   1503:   TtaInsertFirstChild (&MTableHead, elMTABLE, doc);
                   1504:   elType.ElTypeNum = MathML_EL_MColumn_head;
1.47      cvs      1505:   firstColHead = TtaNewTree (doc, elType, "");
1.5       cvs      1506:   TtaInsertFirstChild (&firstColHead, MTableHead, doc);
                   1507: 
                   1508:   /* create a MTable_body */
                   1509:   elType.ElSSchema = MathMLSSchema;
                   1510:   elType.ElTypeNum = MathML_EL_MTable_body;
                   1511:   MTableBody = TtaNewElement (doc, elType);
                   1512:   TtaInsertSibling (MTableBody, MTableHead, FALSE, doc);
                   1513: 
                   1514:   /* move all children of element MTABLE into the new MTable_body element
                   1515:      and wrap each non-MTR element with a MTR */
                   1516:   prevRow = NULL;
                   1517:   while (row)
                   1518:     {
                   1519:     nextRow = row;
                   1520:     TtaNextSibling (&nextRow);
                   1521:     elType = TtaGetElementType (row);
                   1522:     TtaRemoveTree (row, doc);
                   1523:     if (TtaSameSSchemas (elType.ElSSchema, MathMLSSchema) &&
                   1524:        (elType.ElTypeNum == MathML_EL_XMLcomment ||
                   1525:         elType.ElTypeNum == MathML_EL_MTR))
                   1526:        {
                   1527:        if (prevRow == NULL)
                   1528:          TtaInsertFirstChild (&row, MTableBody, doc);
                   1529:        else
                   1530:          TtaInsertSibling (row, prevRow, FALSE, doc);
                   1531:        prevRow = row;
                   1532:        if (elType.ElTypeNum == MathML_EL_MTR)
                   1533:           cell = TtaGetFirstChild (row);
                   1534:        else
                   1535:          cell = NULL;
                   1536:        }
                   1537:     else
                   1538:        /* this child is not a MTR nor a comment, create a MTR element */
                   1539:        {
                   1540:        elType.ElSSchema = MathMLSSchema;
                   1541:        elType.ElTypeNum = MathML_EL_MTR;
                   1542:        el = TtaNewElement (doc, elType);
                   1543:        if (prevRow == NULL)
                   1544:          TtaInsertFirstChild (&el, MTableBody, doc);
                   1545:        else
                   1546:          TtaInsertSibling (el, prevRow, FALSE, doc);
                   1547:        TtaInsertFirstChild (&row, el, doc);
                   1548:        cell = row;
                   1549:        prevRow = el;
                   1550:        }
                   1551:     while (cell)
                   1552:       /* check all children of the current MTR element */
                   1553:       {
                   1554:       nextCell = cell;
                   1555:       TtaNextSibling (&nextCell);
                   1556:       elType = TtaGetElementType (cell);
                   1557:       if (!TtaSameSSchemas (elType.ElSSchema, MathMLSSchema) ||
                   1558:           (elType.ElTypeNum != MathML_EL_XMLcomment &&
                   1559:            elType.ElTypeNum != MathML_EL_MTD))
                   1560:         /* this is not a MTD nor a comment, create a wrapping MTD */
                   1561:          {
                   1562:         elType.ElSSchema = MathMLSSchema;
                   1563:         elType.ElTypeNum = MathML_EL_MTD;
                   1564:         newMTD = TtaNewElement (doc, elType);
                   1565:         TtaInsertSibling (newMTD, cell, TRUE, doc);
                   1566:         TtaRemoveTree (cell, doc);
                   1567:         TtaInsertFirstChild (&cell, newMTD, doc);
                   1568:         cell = newMTD;
                   1569:         }
                   1570:       if (elType.ElTypeNum == MathML_EL_MTD)
                   1571:         /* This is a MTD element. Wrap its contents with a CellWrapper */
1.39      cvs      1572:          CreateWrapper (cell, MathML_EL_CellWrapper, doc);
1.5       cvs      1573:       cell = nextCell;
                   1574:       }
                   1575:     row = nextRow;
                   1576:     }
1.64      cvs      1577:   CheckAllRows (elMTABLE, doc, placeholder);
1.5       cvs      1578: }
1.12      cvs      1579: 
1.46      cvs      1580: /*----------------------------------------------------------------------
1.1       cvs      1581:    SetFontstyleAttr
                   1582:    The content of a MI element has been created or modified.
                   1583:    Create or change attribute IntFontstyle for that element accordingly.
                   1584:  -----------------------------------------------------------------------*/
                   1585: #ifdef __STDC__
                   1586: void SetFontstyleAttr (Element el, Document doc)
                   1587: #else /* __STDC__*/
                   1588: void SetFontstyleAttr (el, doc)
                   1589:   Element      el;
                   1590:   Document     doc;
                   1591: #endif /* __STDC__*/
                   1592: {
                   1593:   ElementType  elType;
                   1594:   AttributeType        attrType;
                   1595:   Attribute    attr, IntAttr;
1.54      cvs      1596:   Element       textEl;
1.1       cvs      1597:   int          len;
1.54      cvs      1598:   STRING        value;
                   1599:   ThotBool      italic;
1.1       cvs      1600: 
                   1601:   if (el != NULL)
                   1602:      {
                   1603:      /* search the fontstyle attribute */
                   1604:      elType = TtaGetElementType (el);
                   1605:      attrType.AttrSSchema = elType.ElSSchema;
                   1606:      attrType.AttrTypeNum = MathML_ATTR_fontstyle;
                   1607:      attr = TtaGetAttribute (el, attrType);
                   1608:      attrType.AttrTypeNum = MathML_ATTR_IntFontstyle;
                   1609:      IntAttr = TtaGetAttribute (el, attrType);
                   1610:      if (attr != NULL)
                   1611:        /* there is a fontstyle attribute. Remove the corresponding
                   1612:           internal attribute that is not needed */
                   1613:        {
                   1614:        if (IntAttr != NULL)
1.54      cvs      1615:          TtaRemoveAttribute (el, IntAttr, doc);
1.1       cvs      1616:        }
                   1617:      else
                   1618:        /* there is no fontstyle attribute. Create an internal attribute
                   1619:           IntFontstyle with a value that depends on the content of the MI */
                   1620:        {
                   1621:         /* get content length */
                   1622:         len = TtaGetElementVolume (el);
                   1623:         if (len > 1)
                   1624:            /* put an attribute IntFontstyle = IntNormal */
                   1625:           {
                   1626:           if (IntAttr == NULL)
                   1627:              {
                   1628:              IntAttr = TtaNewAttribute (attrType);
                   1629:              TtaAttachAttribute (el, IntAttr, doc);
                   1630:              }
                   1631:           TtaSetAttributeValue (IntAttr, MathML_ATTR_IntFontstyle_VAL_IntNormal,
                   1632:                                 el, doc);
                   1633:           }
                   1634:         else
                   1635:           /* MI contains a single character. Remove attribute IntFontstyle
1.54      cvs      1636:              if it exists, except if it's ImaginaryI, ExponentialE or
                   1637:              DifferentialD. */
1.1       cvs      1638:           {
1.54      cvs      1639:           italic = TRUE;
                   1640:           textEl = TtaGetFirstChild (el);
                   1641:           if (textEl != NULL)
                   1642:             {
                   1643:             /* is there an attribute EntityName on that character? */
                   1644:             attrType.AttrTypeNum = MathML_ATTR_EntityName;
                   1645:             attr = TtaGetAttribute (textEl, attrType);
                   1646:             if (attr)
                   1647:               {
                   1648:               len = TtaGetTextAttributeLength (attr);
                   1649:               if (len > 0)
                   1650:                  {
                   1651:                  value = TtaAllocString (len+1);
                   1652:                  TtaGiveTextAttributeValue (attr, value, &len);
                   1653:                  if (ustrcmp (value, TEXT("&ImaginaryI;")) == 0 ||
                   1654:                      ustrcmp (value, TEXT("&ExponentialE;")) == 0 ||
                   1655:                      ustrcmp (value, TEXT("&DifferentialD;")) == 0)
                   1656:                    italic = FALSE;
                   1657:                  TtaFreeMemory (value);
                   1658:                  }
                   1659:               }
                   1660:             if (italic)
                   1661:               {
                   1662:                 if (IntAttr != NULL)
                   1663:                   TtaRemoveAttribute (el, IntAttr, doc);
                   1664:               }
                   1665:             else
                   1666:               {
                   1667:                 /* put an attribute IntFontstyle = IntNormal */
                   1668:                 if (IntAttr == NULL)
                   1669:                   {
                   1670:                     attrType.AttrTypeNum = MathML_ATTR_IntFontstyle;
                   1671:                     IntAttr = TtaNewAttribute (attrType);
                   1672:                     TtaAttachAttribute (el, IntAttr, doc);
                   1673:                   }
                   1674:                 TtaSetAttributeValue (IntAttr, MathML_ATTR_IntFontstyle_VAL_IntNormal,
                   1675:                                       el, doc);
                   1676:               }
                   1677:             }
1.1       cvs      1678:           }
                   1679:         }
                   1680:      }
                   1681: }
                   1682: 
                   1683: /*----------------------------------------------------------------------
1.22      cvs      1684:    SetIntAddSpaceAttr
1.1       cvs      1685:    The content of a MO element has been created or modified.
1.22      cvs      1686:    Create or change attribute IntAddSpace for that element accordingly.
1.1       cvs      1687:  -----------------------------------------------------------------------*/
                   1688: #ifdef __STDC__
1.22      cvs      1689: void SetIntAddSpaceAttr (Element el, Document doc)
1.1       cvs      1690: #else /* __STDC__*/
1.22      cvs      1691: void SetIntAddSpaceAttr (el, doc)
1.1       cvs      1692:   Element      el;
                   1693:   Document     doc;
                   1694: #endif /* __STDC__*/
                   1695: {
                   1696:   Element      textEl, previous;
                   1697:   ElementType  elType;
                   1698:   AttributeType        attrType;
1.60      cvs      1699:   Attribute    attr, formAttr;
                   1700:   int          len, val, form;
1.1       cvs      1701: #define BUFLEN 10
1.15      cvs      1702:   UCHAR_T      text[BUFLEN];
1.1       cvs      1703:   Language     lang;
1.15      cvs      1704:   CHAR_T               alphabet;
1.1       cvs      1705: 
1.60      cvs      1706:   /* get the content of the mo element */
1.1       cvs      1707:   textEl = TtaGetFirstChild (el);
                   1708:   if (textEl != NULL)
1.60      cvs      1709:      /* the mo element is not empty */
1.1       cvs      1710:      {
1.60      cvs      1711:      /* does the mo element have an IntAddSpace attribute? */
1.1       cvs      1712:      elType = TtaGetElementType (el);
                   1713:      attrType.AttrSSchema = elType.ElSSchema;
1.22      cvs      1714:      attrType.AttrTypeNum = MathML_ATTR_IntAddSpace;
1.1       cvs      1715:      attr = TtaGetAttribute (el, attrType);
                   1716:      if (attr == NULL)
1.60      cvs      1717:         /* no IntAddSpace Attr, create one */
1.1       cvs      1718:        {
                   1719:        attr = TtaNewAttribute (attrType);
                   1720:        TtaAttachAttribute (el, attr, doc);
                   1721:        }
1.60      cvs      1722:      /* nospace by default */
1.22      cvs      1723:      val = MathML_ATTR_IntAddSpace_VAL_nospace;
1.60      cvs      1724:      /* does the mo element have a form attribute? */
                   1725:      attrType.AttrTypeNum = MathML_ATTR_form;
                   1726:      formAttr = TtaGetAttribute (el, attrType);
                   1727:      if (formAttr)
                   1728:        /* there is a form attribute */
                   1729:        {
                   1730:        form = TtaGetAttributeValue (formAttr);
                   1731:        switch (form)
                   1732:         {
                   1733:         case MathML_ATTR_form_VAL_prefix:
                   1734:           val = MathML_ATTR_IntAddSpace_VAL_nospace;
                   1735:           break;
                   1736:         case MathML_ATTR_form_VAL_infix:
                   1737:           val = MathML_ATTR_IntAddSpace_VAL_both;
                   1738:           break;
                   1739:         case MathML_ATTR_form_VAL_postfix:
                   1740:           val = MathML_ATTR_IntAddSpace_VAL_spaceafter;
                   1741:           break;
                   1742:         } 
                   1743:        }
                   1744:      else
                   1745:        /* no form attribute. Analyze the content */
                   1746:        {
                   1747:        len = TtaGetTextLength (textEl);
                   1748:        if (len > 0 && len < BUFLEN)
                   1749:          {
                   1750:            len = BUFLEN;
                   1751:            TtaGiveTextContent (textEl, text, &len, &lang);
                   1752:            alphabet = TtaGetAlphabet (lang);
                   1753:            if (len == 1)
                   1754:               /* the mo element contains a single character */
                   1755:               if (alphabet == 'L')
                   1756:                  /* ISO-Latin 1 character */
                   1757:                  {
                   1758:                  if (text[0] == '-')
                   1759:                     /* prefix or infix operator? */
                   1760:                     {
                   1761:                     previous = el;
                   1762:                     TtaPreviousSibling (&previous);
                   1763:                     if (previous == NULL)
                   1764:                        /* no previous sibling => prefix operator */
                   1765:                        val = MathML_ATTR_IntAddSpace_VAL_nospace;
                   1766:                     else
                   1767:                        {
                   1768:                        elType = TtaGetElementType (previous);
                   1769:                        if (elType.ElTypeNum == MathML_EL_MO)
                   1770:                           /* after an operator => prefix operator */
                   1771:                           val = MathML_ATTR_IntAddSpace_VAL_nospace;
                   1772:                        else
                   1773:                           /* infix operator */
                   1774:                           val = MathML_ATTR_IntAddSpace_VAL_both;
                   1775:                        }
                   1776:                     }
                   1777:                  else if (text[0] == '+' ||
                   1778:                           text[0] == '&' ||
                   1779:                           text[0] == '*' ||
                   1780:                           text[0] == '<' ||
                   1781:                           text[0] == '=' ||
                   1782:                           text[0] == '>' ||
                   1783:                           text[0] == '^')
                   1784:                     /* infix operator */
                   1785:                     val = MathML_ATTR_IntAddSpace_VAL_both;
                   1786:                  else if (text[0] == ',' ||
                   1787:                           text[0] == ';')
                   1788:                     /* separator */
                   1789:                     val = MathML_ATTR_IntAddSpace_VAL_spaceafter;
                   1790:                  }
                   1791:               else if (alphabet == 'G')
                   1792:                  /* Symbol character set */
                   1793:                 if ((int)text[0] == 163 || /* less or equal */
                   1794:                     (int)text[0] == 177 ||     /* plus or minus */
                   1795:                     (int)text[0] == 179 || /* greater or equal */
                   1796:                     (int)text[0] == 180 || /* times */
                   1797:                     (int)text[0] == 184 || /* divide */
                   1798:                     (int)text[0] == 185 || /* not equal */
                   1799:                     (int)text[0] == 186 || /* identical */
                   1800:                     (int)text[0] == 187 || /* equivalent */
                   1801:                     (int)text[0] == 196 || /* circle times */
                   1802:                     (int)text[0] == 197 || /* circle plus */
                   1803:                     ((int)text[0] >= 199 && (int)text[0] <= 209) || /*  */
                   1804:                     (int)text[0] == 217 || /* and */
                   1805:                     (int)text[0] == 218 )  /* or */
                   1806:                    /* infix operator */
                   1807:                    val = MathML_ATTR_IntAddSpace_VAL_both;
                   1808:          }
                   1809:        }
1.1       cvs      1810:      TtaSetAttributeValue (attr, val, el, doc);
                   1811:      }
                   1812: }
                   1813: 
                   1814: 
                   1815: /*----------------------------------------------------------------------
                   1816:    ChangeTypeOfElement
                   1817:    Change the type of element elem into newTypeNum
                   1818:  -----------------------------------------------------------------------*/
                   1819: #ifdef __STDC__
                   1820: void ChangeTypeOfElement (Element elem, Document doc, int newTypeNum)
                   1821: #else /* __STDC__*/
                   1822: void ChangeTypeOfElement (elem, doc, newTypeNum)
                   1823:      Element elem;
                   1824:      Document doc;
                   1825:      int newTypeNum;
                   1826: #endif /* __STDC__*/
                   1827:  
                   1828: {
                   1829:      Element    prev, next, parent;
1.10      cvs      1830: 
                   1831:      parent = NULL;
1.1       cvs      1832:      prev = elem;
                   1833:      TtaPreviousSibling (&prev);
                   1834:      if (prev == NULL)
                   1835:         {
                   1836:         next = elem;
                   1837:         TtaNextSibling (&next);
                   1838:         if (next == NULL)
                   1839:            parent = TtaGetParent (elem);
                   1840:         }
                   1841:      TtaRemoveTree (elem, doc);
                   1842:      ChangeElementType (elem, newTypeNum);
                   1843:      if (prev != NULL)
                   1844:         TtaInsertSibling (elem, prev, FALSE, doc);
                   1845:      else if (next != NULL)
                   1846:         TtaInsertSibling (elem, next, TRUE, doc);
                   1847:      else
                   1848:         TtaInsertFirstChild (&elem, parent, doc);
                   1849: }
                   1850: 
                   1851: 
                   1852: /*----------------------------------------------------------------------
1.58      cvs      1853:    ChildOfMRowOrInferred
                   1854:    Return TRUE if element el is a child of a MROW element or an
                   1855:    inferred MROW element
                   1856:   ----------------------------------------------------------------------*/
                   1857: #ifdef __STDC__
                   1858: ThotBool      ChildOfMRowOrInferred (Element el)
                   1859: #else
                   1860: ThotBool      ChildOfMRowOrInferred (el)
                   1861: Element                 el;
                   1862: #endif
                   1863: {
                   1864:    ElementType  elType;
                   1865:    Element       parent;
                   1866:    ThotBool      result;
                   1867: 
                   1868:    result = FALSE;
                   1869:    parent = TtaGetParent (el);
                   1870:    if (parent)
                   1871:       {
                   1872:       elType = TtaGetElementType (parent);
                   1873:       result = (elType.ElTypeNum == MathML_EL_MROW ||
                   1874:                elType.ElTypeNum == MathML_EL_SqrtBase ||
                   1875:                elType.ElTypeNum == MathML_EL_MSTYLE ||
                   1876:                elType.ElTypeNum == MathML_EL_MERROR ||
1.92      cvs      1877:                elType.ElTypeNum == MathML_EL_MENCLOSE ||
1.58      cvs      1878:                elType.ElTypeNum == MathML_EL_MPADDED ||
                   1879:                elType.ElTypeNum == MathML_EL_MPHANTOM ||
                   1880:                elType.ElTypeNum == MathML_EL_CellWrapper ||
1.92      cvs      1881:                elType.ElTypeNum == MathML_EL_MathML ||
1.58      cvs      1882:                 elType.ElTypeNum == MathML_EL_FencedExpression);
                   1883:       }
                   1884:    return result;   
                   1885: }
                   1886: 
                   1887: /*----------------------------------------------------------------------
1.1       cvs      1888:    CheckFence
1.84      cvs      1889:    If el is a MO element,
                   1890:     - if it's a large operator (&Sum; for instance), put a presentation
                   1891:       rule to enlarge the character.
                   1892:     - if it's a child of a MROW (or equivalent) element and if it contains
                   1893:       a single fence character, transform the MO into a MF and the fence
                   1894:       character into a Thot stretchable symbol.
1.1       cvs      1895:   ----------------------------------------------------------------------*/
                   1896: #ifdef __STDC__
1.84      cvs      1897: void      CheckFence (Element el, Document doc)
1.1       cvs      1898: #else
1.84      cvs      1899: void      CheckFence (el, doc)
1.1       cvs      1900: Element                 el;
                   1901: Document               doc;
                   1902: 
                   1903: #endif
                   1904: {
1.46      cvs      1905:    ElementType  elType;
1.58      cvs      1906:    Element      content;
1.1       cvs      1907:    AttributeType attrType;
1.46      cvs      1908:    Attribute    attr, attrStretchy;
1.47      cvs      1909:    int           len, val;
1.58      cvs      1910:    Language     lang;
                   1911:    CHAR_T       alphabet;
1.49      cvs      1912:    UCHAR_T       text[2];
                   1913:    unsigned char c;
1.84      cvs      1914:    PresentationValue   pval;
                   1915:    PresentationContext ctxt;
1.1       cvs      1916: 
                   1917:    elType = TtaGetElementType (el);
                   1918:    if (elType.ElTypeNum == MathML_EL_MO)
1.58      cvs      1919:      /* the element is a MO */
                   1920:      {
1.84      cvs      1921:      content = TtaGetFirstChild (el);
                   1922:      if (content != NULL)
                   1923:        {
                   1924:        elType = TtaGetElementType (content);
                   1925:        if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)
                   1926:         {
                   1927:         len = TtaGetTextLength (content);
                   1928:         if (len == 1)
                   1929:           /* the MO element contains a single character */
                   1930:           {
                   1931:           len = 2;
                   1932:           TtaGiveTextContent (content, text, &len, &lang);
                   1933:           alphabet = TtaGetAlphabet (lang);
                   1934:           if ((alphabet == 'G') &&
                   1935:               ((int)text[0] == 229 || (int)text[0] == 213))  /* Sigma,  Pi */
                   1936:             /* it's a large operator */
                   1937:             {
                   1938:             ctxt = TtaGetSpecificStyleContext (doc);
                   1939:             ctxt->destroy = FALSE;
                   1940:             /* the specific presentation to be created is not a CSS rule */
                   1941:             ctxt->cssLevel = 0;
                   1942:             pval.typed_data.unit = STYLE_UNIT_PERCENT;
                   1943:             pval.typed_data.real = FALSE;
                   1944:             pval.typed_data.value = 180;
                   1945:             TtaSetStylePresentation (PRSize, content, NULL, ctxt, pval);
                   1946:             }
                   1947:           else if (ChildOfMRowOrInferred (el))
                   1948:             /* the MO element is a child of a MROW element */
1.1       cvs      1949:              {
1.84      cvs      1950:              if ((alphabet == 'L') &&
                   1951:                  (text[0] == TEXT('(') || text[0] == TEXT(')') ||
                   1952:                   text[0] == TEXT('[') || text[0] == TEXT(']') ||
                   1953:                   text[0] == TEXT('{') || text[0] == TEXT('}') ||
                   1954:                   text[0] == TEXT('|')))
                   1955:                /* it's a stretchable parenthesis or equivalent */
                   1956:                {
                   1957:                /* remove the content of the MO element */
                   1958:                TtaDeleteTree (content, doc);
                   1959:                /* change the MO element into a MF element */
                   1960:                ChangeTypeOfElement (el, doc, MathML_EL_MF);
1.55      cvs      1961:                    
1.84      cvs      1962:                /* is there an attribute stretchy on this mo element? */
                   1963:                attrType.AttrSSchema = elType.ElSSchema;
                   1964:                attrType.AttrTypeNum = MathML_ATTR_stretchy;
                   1965:                attrStretchy = TtaGetAttribute (el, attrType);
                   1966:                if (attrStretchy)
                   1967:                  val = TtaGetAttributeValue (attrStretchy);
                   1968:                else
                   1969:                  val = MathML_ATTR_stretchy_VAL_true;
                   1970:                if (val == MathML_ATTR_stretchy_VAL_true)
                   1971:                  {
                   1972:                  /* attach a IntVertStretch attribute to the MF element*/
                   1973:                  attrType.AttrTypeNum = MathML_ATTR_IntVertStretch;
                   1974:                  attr = TtaNewAttribute (attrType);
                   1975:                  TtaAttachAttribute (el, attr, doc);
                   1976:                  TtaSetAttributeValue (attr,
                   1977:                                        MathML_ATTR_IntVertStretch_VAL_yes_,
                   1978:                                        el, doc);
                   1979:                  }
                   1980:                /* create a new content for the MF element */
1.87      cvs      1981:                elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
                   1982:                c = (char) text[0];
1.84      cvs      1983:                content = TtaNewElement (doc, elType);
                   1984:                TtaInsertFirstChild (&content, el, doc);
                   1985:                TtaSetGraphicsShape (content, c, doc);
                   1986:                }
1.1       cvs      1987:              }
1.84      cvs      1988:           }
                   1989:         }
1.58      cvs      1990:        }
                   1991:      }
1.1       cvs      1992: }
                   1993: 
                   1994: /*----------------------------------------------------------------------
                   1995:    CreateFencedSeparators
                   1996:    Create FencedSeparator elements within the fencedExpression
                   1997:    according to attribute separators of the MFENCED element.
                   1998:   ----------------------------------------------------------------------*/
                   1999: #ifdef __STDC__
1.18      cvs      2000: void      CreateFencedSeparators (Element fencedExpression, Document doc, ThotBool record)
1.1       cvs      2001: #else
1.17      cvs      2002: void      CreateFencedSeparators (fencedExpression, doc, record)
1.1       cvs      2003: Element                fencedExpression;
                   2004: Document       doc;
1.18      cvs      2005: ThotBool        record;
1.1       cvs      2006: 
                   2007: #endif
                   2008: {
                   2009:    ElementType  elType;
                   2010:    Element      child, separator, leaf, next, prev, mfenced;
                   2011:    AttributeType attrType;
                   2012:    Attribute     attr;
                   2013:    int          length, sep, i;
                   2014:    Language     lang;
1.46      cvs      2015:    CHAR_T       text[32], sepValue[4];
1.1       cvs      2016: 
                   2017:    /* get the separators attribute */
                   2018:    mfenced = TtaGetParent (fencedExpression);
                   2019:    elType = TtaGetElementType (fencedExpression);
                   2020:    attrType.AttrSSchema = elType.ElSSchema;
                   2021:    attrType.AttrTypeNum = MathML_ATTR_separators;
                   2022:    text[0] = ',';      /* default value is  sparators=","  */
                   2023:    text[1] = EOS;
                   2024:    length = 1;
                   2025:    attr = TtaGetAttribute (mfenced, attrType);
                   2026:    if (attr != NULL)
                   2027:       {
                   2028:       length = 31;
                   2029:       TtaGiveTextAttributeValue (attr, text, &length);
                   2030:       }
                   2031: 
                   2032:    /* create FencedSeparator elements in the FencedExpression */
                   2033:    prev = NULL;
                   2034:    sep = 0;
                   2035:    /* skip leading spaces in attribute separators */
                   2036:    while (text[sep] <= SPACE && text[sep] != EOS)
                   2037:       sep++;
                   2038:    /* if attribute separators is empty or contains only spaces, do not
                   2039:       insert any separator element */
                   2040:    if (text[sep] != EOS)
                   2041:      {
                   2042:      child = TtaGetFirstChild (fencedExpression);
                   2043:      while (child != NULL)
                   2044:        {
                   2045:        next = child;
                   2046:        TtaNextSibling (&next);
                   2047:        elType = TtaGetElementType (child);
                   2048:        if (elType.ElTypeNum != MathML_EL_Construct)
                   2049:          {
                   2050:          if (prev != NULL)
                   2051:            {
                   2052:            elType.ElTypeNum = MathML_EL_FencedSeparator;
                   2053:            separator = TtaNewElement (doc, elType);
                   2054:            TtaInsertSibling (separator, prev, FALSE, doc);
                   2055:            elType.ElTypeNum = MathML_EL_TEXT_UNIT;
                   2056:            leaf = TtaNewElement (doc, elType);
                   2057:            TtaInsertFirstChild (&leaf, separator, doc);
                   2058:            sepValue[0] = text[sep];
                   2059:            sepValue[1] = SPACE;
                   2060:            sepValue[2] = EOS;
                   2061:           lang = TtaGetLanguageIdFromAlphabet('L');
                   2062:            TtaSetTextContent (leaf, sepValue, lang, doc);
                   2063:           /* is there a following non-space character in separators? */
                   2064:           i = sep + 1;
                   2065:           while (text[i] <= SPACE && text[i] != EOS)
                   2066:              i++;
                   2067:            if (text[i] > SPACE && text[i] != EOS)
                   2068:               sep = i;
1.17      cvs      2069:           if (record)
                   2070:             TtaRegisterElementCreate (separator, doc);
1.1       cvs      2071:            }
                   2072:          prev = child;
                   2073:          }
                   2074:        child = next;
                   2075:        }
                   2076:      }
                   2077: }
                   2078: 
                   2079: 
                   2080: /*----------------------------------------------------------------------
                   2081:    TransformMFENCED
                   2082:    Transform the content of a MFENCED element: create elements
                   2083:    OpeningFence, FencedExpression, ClosingFence and FencedSeparator.
                   2084:   ----------------------------------------------------------------------*/
                   2085: #ifdef __STDC__
1.46      cvs      2086: static void      TransformMFENCED (Element el, Document doc)
1.1       cvs      2087: #else
1.46      cvs      2088: static void      TransformMFENCED (el, doc)
1.1       cvs      2089: Element                el;
                   2090: Document       doc;
                   2091: 
                   2092: #endif
                   2093: {
                   2094:    ElementType  elType;
                   2095:    Element      child, fencedExpression, leaf, fence, next, prev,
                   2096:                 firstChild;
                   2097:    AttributeType attrType;
                   2098:    Attribute     attr;
1.47      cvs      2099:    int           length;
1.49      cvs      2100:    CHAR_T        text[32];
                   2101:    char          c;
1.1       cvs      2102: 
                   2103:    child = TtaGetFirstChild (el);
                   2104:    if (child != NULL)
                   2105:         elType = TtaGetElementType (child);
                   2106:    if (child != NULL && elType.ElTypeNum == MathML_EL_OpeningFence)
                   2107:       /* The first child of this MFENCED element is an OpeningFence.
                   2108:         This MFENCED expression has already been transformed, possibly
                   2109:         by the Transform command */
                   2110:       {
                   2111:       TtaNextSibling (&child);
                   2112:       fencedExpression = child;
                   2113:       if (fencedExpression != NULL)
                   2114:         elType = TtaGetElementType (fencedExpression);
                   2115:       if (elType.ElTypeNum == MathML_EL_FencedExpression)
                   2116:         /* the second child is a FencedExpression. OK.
                   2117:            Remove all existing FencedSeparator elements */
                   2118:         {
                   2119:         child = TtaGetFirstChild (fencedExpression);
                   2120:         prev = NULL;
                   2121:         while (child != NULL)
                   2122:            {
                   2123:            elType = TtaGetElementType (child);
                   2124:            next = child;
                   2125:            TtaNextSibling (&next);
                   2126:            if (elType.ElTypeNum == MathML_EL_FencedSeparator)
                   2127:                /* Remove this separator */
                   2128:                TtaDeleteTree (child, doc);
                   2129:            child = next;
                   2130:            }
                   2131:         /* create FencedSeparator elements in the FencedExpression */
1.17      cvs      2132:         CreateFencedSeparators (fencedExpression, doc, FALSE);
1.1       cvs      2133:         }
                   2134:       }
                   2135:    else
                   2136:       /* this MFENCED element must be transformed */
                   2137:       {
                   2138:       /* create a FencedExpression element as a child of the MFENCED elem. */
                   2139:       elType = TtaGetElementType (el);
                   2140:       elType.ElTypeNum = MathML_EL_FencedExpression;
                   2141:       fencedExpression = TtaNewElement (doc, elType);
                   2142:       TtaInsertFirstChild (&fencedExpression, el, doc);
                   2143:       if (child == NULL)
                   2144:        /* empty MFENCED element */
                   2145:        {
                   2146:         elType.ElTypeNum = MathML_EL_Construct;
                   2147:        child = TtaNewElement (doc, elType);
                   2148:        TtaInsertFirstChild (&child, fencedExpression, doc);
1.22      cvs      2149:        SetIntPlaceholderAttr (child, doc);
1.1       cvs      2150:        }
                   2151:       else
                   2152:        {
                   2153:         /* move the content of the MFENCED element within the new
                   2154:           FencedExpression element */
                   2155:         prev = NULL;
                   2156:        firstChild = NULL;
                   2157:         while (child != NULL)
                   2158:          {
                   2159:          next = child;
                   2160:          TtaNextSibling (&next);
                   2161:          TtaRemoveTree (child, doc);
                   2162:          if (prev == NULL)
                   2163:            {
                   2164:            TtaInsertFirstChild (&child, fencedExpression, doc);
                   2165:            firstChild = child;
                   2166:            }
                   2167:          else
                   2168:            TtaInsertSibling (child, prev, FALSE, doc);
                   2169:          prev = child;
                   2170:          child = next;
                   2171:          }
                   2172: 
                   2173:        /* create FencedSeparator elements in the FencedExpression */
1.17      cvs      2174:        CreateFencedSeparators (fencedExpression, doc, FALSE);
1.1       cvs      2175: 
                   2176:         /* Create placeholders within the FencedExpression element */
                   2177:         CreatePlaceholders (firstChild, doc);
                   2178:        }
                   2179: 
                   2180:       /* create the OpeningFence element according to the open attribute */
                   2181:       c = '(';
                   2182:       attrType.AttrSSchema = elType.ElSSchema;
                   2183:       attrType.AttrTypeNum = MathML_ATTR_open;
                   2184:       attr = TtaGetAttribute (el, attrType);
                   2185:       if (attr != NULL)
                   2186:        {
                   2187:         length = 7;
                   2188:         TtaGiveTextAttributeValue (attr, text, &length);
1.49      cvs      2189:        c = (char)text[0];
1.1       cvs      2190:        }
                   2191:       elType.ElTypeNum = MathML_EL_OpeningFence;
                   2192:       fence = TtaNewElement (doc, elType);
                   2193:       TtaInsertSibling (fence, fencedExpression, TRUE, doc);
                   2194:       elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
                   2195:       leaf = TtaNewElement (doc, elType);
                   2196:       TtaInsertFirstChild (&leaf, fence, doc);
                   2197:       TtaSetGraphicsShape (leaf, c, doc);
                   2198: 
                   2199:       /* create the ClosingFence element according to close attribute */
                   2200:       c = ')';
                   2201:       attrType.AttrTypeNum = MathML_ATTR_close;
                   2202:       attr = TtaGetAttribute (el, attrType);
                   2203:       if (attr != NULL)
                   2204:        {
                   2205:         length = 7;
                   2206:         TtaGiveTextAttributeValue (attr, text, &length);
1.49      cvs      2207:        c = (char) text[0];
1.1       cvs      2208:        }
                   2209:       elType.ElTypeNum = MathML_EL_ClosingFence;
                   2210:       fence = TtaNewElement (doc, elType);
                   2211:       TtaInsertSibling (fence, fencedExpression, FALSE, doc);
                   2212:       elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
                   2213:       leaf = TtaNewElement (doc, elType);
                   2214:       TtaInsertFirstChild (&leaf, fence, doc);
                   2215:       TtaSetGraphicsShape (leaf, c, doc);
                   2216:       }
                   2217: }
                   2218: 
                   2219: /*----------------------------------------------------------------------
1.59      cvs      2220:  MathMLScriptShift
                   2221:  The MathML attribute attr (superscriptshift or subscriptshift) is associated
                   2222:  with element el (a msub, msup or msubsup).
                   2223:  If value is not NULL, generate the corresponding Thot VertPos rule for the
                   2224:  Subscript or  Superscript child of el.
                   2225:  If value is NULL, remove the Thot VertPos rule.
                   2226:  -----------------------------------------------------------------------*/
                   2227: #ifdef __STDC__
                   2228: void MathMLScriptShift (Document doc, Element el, STRING value, int attr)
                   2229: #else /* __STDC__*/
                   2230: void MathMLScriptShift (doc, el, value, attr)
                   2231:   Document doc;
                   2232:   Element el;
                   2233:   STRING value;
                   2234:   int attr;
                   2235: #endif /* __STDC__*/
                   2236: {
                   2237:   ElementType         elType;
                   2238:   Element             script, child;
                   2239:   int                 scrType;
                   2240:   PresentationValue   pval;
                   2241:   PresentationContext ctxt;
                   2242: 
                   2243:   /* get the Superscript or Subscript child of el */
                   2244:   if (attr == MathML_ATTR_superscriptshift)
                   2245:      scrType = MathML_EL_Superscript;
                   2246:   else if (attr == MathML_ATTR_subscriptshift)
                   2247:      scrType = MathML_EL_Subscript;
                   2248:   else
                   2249:      return;
                   2250:   script = NULL;
                   2251:   child = TtaGetFirstChild (el);
                   2252:   while (!script && child)
                   2253:     {
                   2254:     elType = TtaGetElementType (child);
                   2255:     if (elType.ElTypeNum == scrType)
                   2256:        script = child;
                   2257:     else
                   2258:        TtaNextSibling (&child);
                   2259:     }
                   2260:   if (script)
                   2261:     /* Superscript or Subscript element found */
                   2262:     {
                   2263:     ctxt = TtaGetSpecificStyleContext (doc);
                   2264:     if (!value)
                   2265:        /* remove the presentation rule */
                   2266:        {
                   2267:        ctxt->destroy = TRUE;
1.75      cvs      2268:        pval.typed_data.value = 0;
1.59      cvs      2269:        TtaSetStylePresentation (PRVertPos, script, NULL, ctxt, pval);
                   2270:        }
                   2271:     else
                   2272:        {
                   2273:        ctxt->destroy = FALSE;
                   2274:        /* parse the attribute value (a number followed by a unit) */
                   2275:        value = TtaSkipWCBlanks (value);
                   2276:        value = ParseCSSUnit (value, &pval);
                   2277:        if (pval.typed_data.unit != STYLE_UNIT_INVALID)
                   2278:          {
1.78      cvs      2279:          /* the specific presentation to be created is not a CSS rule */
                   2280:          ctxt->cssLevel = 0;
1.59      cvs      2281:           if (attr == MathML_ATTR_superscriptshift)
                   2282:            pval.typed_data.value = - pval.typed_data.value;
                   2283:          TtaSetStylePresentation (PRVertPos, script, NULL, ctxt, pval);
                   2284:          }
                   2285:        }
                   2286:     TtaFreeMemory (ctxt);
                   2287:     }
                   2288: }
                   2289: 
                   2290: /*----------------------------------------------------------------------
                   2291:    SetScriptShift
                   2292:    If element el (which is a msup, msub or msubsup) has an attribute
                   2293:    att (which is subscriptshift or superscriptshift), generate the
                   2294:    corresponding Thot presentation rule.
                   2295:   ----------------------------------------------------------------------*/
                   2296: #ifdef __STDC__
                   2297: static void     SetScriptShift (Element el, Document doc, int att)
                   2298: #else
                   2299: static void     SetScriptShift (el, doc, att)
                   2300: Element                el;
                   2301: Document       doc;
                   2302: int             att;
                   2303: 
                   2304: #endif
                   2305: {
                   2306:    AttributeType     attrType;
                   2307:    ElementType       elType;
                   2308:    Attribute         attr;
                   2309:    STRING            value;
                   2310:    int               length;
                   2311: 
                   2312:    elType = TtaGetElementType (el);
                   2313:    attrType.AttrSSchema = elType.ElSSchema;
                   2314:    attrType.AttrTypeNum = att;
                   2315:    attr = TtaGetAttribute (el, attrType);
                   2316:    if (attr)
                   2317:       {
                   2318:       length = TtaGetTextAttributeLength (attr);
                   2319:       if (length > 0)
                   2320:         {
                   2321:         value = TtaAllocString (length+1);
                   2322:         value[0] = EOS;
                   2323:         TtaGiveTextAttributeValue (attr, value, &length);
                   2324:         MathMLScriptShift (doc, el, value, att);
                   2325:         TtaFreeMemory (value);
                   2326:         }
                   2327:       }
                   2328: }
                   2329: 
                   2330: /*----------------------------------------------------------------------
1.1       cvs      2331:    MathMLElementComplete
                   2332:    Check the Thot structure of the MathML element el.
                   2333:   ----------------------------------------------------------------------*/
                   2334: #ifdef __STDC__
1.56      cvs      2335: void      MathMLElementComplete (Element el, Document doc, int *error)
1.1       cvs      2336: #else
1.56      cvs      2337: void      MathMLElementComplete (el, doc, error)
1.1       cvs      2338: Element                el;
                   2339: Document       doc;
1.56      cvs      2340: int             *error;
1.1       cvs      2341: 
                   2342: #endif
                   2343: {
1.74      cvs      2344:    ElementType         elType, parentType;
1.1       cvs      2345:    Element             child, parent, new, prev, next;
1.56      cvs      2346:    SSchema              MathMLSSchema;
                   2347:    ThotBool             ok;
1.1       cvs      2348: 
1.56      cvs      2349:    ok = TRUE;
                   2350:    *error = 0;
1.1       cvs      2351:    elType = TtaGetElementType (el);
1.2       cvs      2352:    MathMLSSchema = GetMathMLSSchema (doc);
1.1       cvs      2353: 
1.76      cvs      2354:    if (elType.ElSSchema == MathMLSSchema)
1.1       cvs      2355:      {
                   2356:      switch (elType.ElTypeNum)
                   2357:        {
1.76      cvs      2358:        case MathML_EL_MathML:
                   2359:          /* Create placeholders within the MathML element */
                   2360:          CreatePlaceholders (TtaGetFirstChild (el), doc);
1.1       cvs      2361:        case MathML_EL_MI:
                   2362:          SetFontstyleAttr (el, doc);
                   2363:          break;
                   2364:        case MathML_EL_MO:
1.22      cvs      2365:          SetIntAddSpaceAttr (el, doc);
                   2366:          SetIntVertStretchAttr (el, doc, 0, NULL);
1.58      cvs      2367:          /* if the MO element is a child of a MROW (or equivalent) and if it
                   2368:             contains a fence character, transform this MO into MF and
                   2369:             transform the fence character into a Thot SYMBOL */
                   2370:          CheckFence (el, doc);
1.1       cvs      2371:          break;
1.60      cvs      2372:        case MathML_EL_MSPACE:
                   2373:          break;
1.39      cvs      2374:        case MathML_EL_MROW:
1.55      cvs      2375:          /* Create placeholders within the MROW */
                   2376:           CreatePlaceholders (TtaGetFirstChild (el), doc);
1.39      cvs      2377:          break;
                   2378:        case MathML_EL_MFRAC:
1.54      cvs      2379:        case MathML_EL_BevelledMFRAC:
1.39      cvs      2380:          /* end of a fraction. Create a Numerator and a Denominator */
1.56      cvs      2381:          ok = CheckMathSubExpressions (el, MathML_EL_Numerator,
                   2382:                                        MathML_EL_Denominator, 0, doc);
1.39      cvs      2383:          break;
                   2384:        case MathML_EL_MSQRT:
1.50      cvs      2385:          /* end of a Square Root */
                   2386:          /* Create placeholders within the element */
                   2387:           CreatePlaceholders (TtaGetFirstChild (el), doc);
                   2388:          /* Create a SqrtBase that contains all children of the MSQRT */
1.39      cvs      2389:          CreateWrapper (el, MathML_EL_SqrtBase, doc);
                   2390:          break;
1.1       cvs      2391:        case MathML_EL_MROOT:
                   2392:          /* end of a Root. Create a RootBase and an Index */
1.56      cvs      2393:          ok = CheckMathSubExpressions (el, MathML_EL_RootBase,
                   2394:                                        MathML_EL_Index, 0, doc);
1.1       cvs      2395:          break;
1.50      cvs      2396:        case MathML_EL_MENCLOSE:
                   2397:          /* Create placeholders within the element */
                   2398:           CreatePlaceholders (TtaGetFirstChild (el), doc);
                   2399:          break;
1.39      cvs      2400:        case MathML_EL_MSTYLE:
                   2401:        case MathML_EL_MERROR:
                   2402:        case MathML_EL_MPADDED:
                   2403:        case MathML_EL_MPHANTOM:
                   2404:          /* Create placeholders within the element */
                   2405:           CreatePlaceholders (TtaGetFirstChild (el), doc);
1.1       cvs      2406:          break;
                   2407:        case MathML_EL_MFENCED:
                   2408:          TransformMFENCED (el, doc);
                   2409:          break;
                   2410:        case MathML_EL_MSUB:
                   2411:          /* end of a MSUB. Create Base and Subscript */
1.56      cvs      2412:          ok = CheckMathSubExpressions (el, MathML_EL_Base,
                   2413:                                        MathML_EL_Subscript, 0, doc);
1.59      cvs      2414:          SetScriptShift (el, doc, MathML_ATTR_subscriptshift);
1.22      cvs      2415:          SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1       cvs      2416:          break;
                   2417:        case MathML_EL_MSUP:
                   2418:          /* end of a MSUP. Create Base and Superscript */
1.56      cvs      2419:          ok = CheckMathSubExpressions (el, MathML_EL_Base,
                   2420:                                        MathML_EL_Superscript, 0, doc);
1.59      cvs      2421:          SetScriptShift (el, doc, MathML_ATTR_superscriptshift);
1.22      cvs      2422:          SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1       cvs      2423:          break;
1.39      cvs      2424:        case MathML_EL_MSUBSUP:
                   2425:          /* end of a MSUBSUP. Create Base, Subscript, and Superscript */
1.56      cvs      2426:          ok = CheckMathSubExpressions (el, MathML_EL_Base,
                   2427:                                        MathML_EL_Subscript,
                   2428:                                        MathML_EL_Superscript, doc);
1.59      cvs      2429:          SetScriptShift (el, doc, MathML_ATTR_subscriptshift);
                   2430:          SetScriptShift (el, doc, MathML_ATTR_superscriptshift);
1.39      cvs      2431:          SetIntVertStretchAttr (el, doc, MathML_EL_Base, NULL);
1.1       cvs      2432:          break;
                   2433:        case MathML_EL_MUNDER:
                   2434:          /* end of a MUNDER. Create UnderOverBase, and Underscript */
1.56      cvs      2435:          ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
                   2436:                                        MathML_EL_Underscript, 0, doc);
1.22      cvs      2437:          SetIntHorizStretchAttr (el, doc);
                   2438:          SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
1.1       cvs      2439:          break;
                   2440:        case MathML_EL_MOVER:
                   2441:          /* end of a MOVER. Create UnderOverBase, and Overscript */
1.56      cvs      2442:          ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
                   2443:                                        MathML_EL_Overscript, 0, doc);
1.22      cvs      2444:          SetIntHorizStretchAttr (el, doc);
                   2445:          SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
1.1       cvs      2446:          break;
1.39      cvs      2447:        case MathML_EL_MUNDEROVER:
                   2448:          /* end of a MUNDEROVER. Create UnderOverBase, Underscript, and
                   2449:             Overscript */
1.56      cvs      2450:          ok = CheckMathSubExpressions (el, MathML_EL_UnderOverBase,
                   2451:                                        MathML_EL_Underscript,
                   2452:                                        MathML_EL_Overscript, doc);
1.39      cvs      2453:          SetIntHorizStretchAttr (el, doc);
                   2454:          SetIntVertStretchAttr (el, doc, MathML_EL_UnderOverBase, NULL);
                   2455:          break;
1.1       cvs      2456:        case MathML_EL_MMULTISCRIPTS:
                   2457:          /* end of a MMULTISCRIPTS. Create all elements defined in the
                   2458:             MathML S schema */
                   2459:          BuildMultiscript (el, doc);
1.5       cvs      2460:          break;
                   2461:        case MathML_EL_MTABLE:
                   2462:          /* end of a MTABLE. Create all elements defined in the MathML S
                   2463:              schema */
1.64      cvs      2464:          CheckMTable (el, doc, TRUE);
1.1       cvs      2465:          break;
1.39      cvs      2466:        case MathML_EL_MTD:
                   2467:          /* Create placeholders within the table cell */
                   2468:           CreatePlaceholders (TtaGetFirstChild (el), doc);
1.46      cvs      2469:          break;
1.39      cvs      2470:        case MathML_EL_MACTION:
                   2471:          /* Create placeholders within the MACTION element */
                   2472:           CreatePlaceholders (TtaGetFirstChild (el), doc);
1.1       cvs      2473:          break;
                   2474:        default:
                   2475:          break;
                   2476:        }
                   2477:      parent = TtaGetParent (el);
                   2478:      parentType = TtaGetElementType (parent);
                   2479:      if (parentType.ElSSchema != elType.ElSSchema)
                   2480:         /* root of a MathML tree, Create a MathML element if there is no */
                   2481:         if (elType.ElTypeNum != MathML_EL_MathML)
                   2482:          {
                   2483:          elType.ElSSchema = MathMLSSchema;
                   2484:          elType.ElTypeNum = MathML_EL_MathML;
                   2485:          new = TtaNewElement (doc, elType);
                   2486:          TtaInsertSibling (new, el, TRUE, doc);
                   2487:          next = el;
                   2488:          TtaNextSibling (&next);
                   2489:          TtaRemoveTree (el, doc);
                   2490:          TtaInsertFirstChild (&el, new, doc);
                   2491:          prev = el;
                   2492:          while (next != NULL)
                   2493:            {
                   2494:            child = next;
                   2495:            TtaNextSibling (&next);
                   2496:            TtaRemoveTree (child, doc);
                   2497:            TtaInsertSibling (child, prev, FALSE, doc);
                   2498:            prev = child;
                   2499:            }
                   2500:          /* Create placeholders within the MathML element */
                   2501:          CreatePlaceholders (el, doc);
                   2502:          }
                   2503:      }
1.56      cvs      2504:    if (!ok)
                   2505:      /* send an error message */
                   2506:      *error = 1;
1.1       cvs      2507: }
                   2508: 
                   2509: /*----------------------------------------------------------------------
1.24      cvs      2510:  SetFontfamily
                   2511:  -----------------------------------------------------------------------*/
                   2512: #ifdef __STDC__
                   2513: void SetFontfamily (Document doc, Element el, STRING value)
                   2514: #else /* __STDC__*/
                   2515: void SetFontfamily (doc, el, value)
                   2516:   Document doc;
                   2517:   Element el;
                   2518:   STRING value;
                   2519: #endif /* __STDC__*/
                   2520: {
                   2521: #define buflen 50
                   2522:   CHAR_T           css_command[buflen+20];
                   2523:  
1.26      cvs      2524:   usprintf (css_command, TEXT("font-family: %s"), value);
1.72      cvs      2525:   ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.24      cvs      2526: }
                   2527: 
                   2528: /*----------------------------------------------------------------------
1.83      cvs      2529:  MathMLlinethickness
                   2530:  The MathML attribute linthickness is associated with element el. Generate
                   2531:  the corresponding style property for this element. 
                   2532:  -----------------------------------------------------------------------*/
                   2533: #ifdef __STDC__
                   2534: void MathMLlinethickness (Document doc, Element el, STRING value)
                   2535: #else /* __STDC__*/
                   2536: void MathMLlinethickness (doc, el, value)
                   2537:   Document doc;
                   2538:   Element el;
                   2539:   STRING value;
                   2540: #endif /* __STDC__*/
                   2541: {
                   2542: #define buflen 50
                   2543:   CHAR_T           css_command[buflen+20];
                   2544: 
                   2545:   if (ustrcmp (value, TEXT("thin")) == 0)
                   2546:      ustrcpy (value, TEXT("1pt"));
                   2547:   else if (ustrcmp (value, TEXT("medium")) == 0)
                   2548:      ustrcpy (value, TEXT("1pt"));
                   2549:   else if (ustrcmp (value, TEXT("thick")) == 0)
                   2550:      ustrcpy (value, TEXT("2pt"));
                   2551:   usprintf (css_command, TEXT("stroke-width: %s"), value);
                   2552:   ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
                   2553: }
                   2554: 
                   2555: /*----------------------------------------------------------------------
1.58      cvs      2556:  MathMLAttrToStyleProperty
                   2557:  The MathML attribute attr is associated with element el. Generate
                   2558:  the corresponding style property for this element.
1.24      cvs      2559:  -----------------------------------------------------------------------*/
                   2560: #ifdef __STDC__
1.58      cvs      2561: void MathMLAttrToStyleProperty (Document doc, Element el, STRING value, int attr)
1.24      cvs      2562: #else /* __STDC__*/
1.58      cvs      2563: void MathMLAttrToStyleProperty (doc, el, value, attr)
1.24      cvs      2564:   Document doc;
                   2565:   Element el;
                   2566:   STRING value;
1.58      cvs      2567:   int attr;
1.24      cvs      2568: #endif /* __STDC__*/
                   2569: {
                   2570:   CHAR_T           css_command[buflen+20];
1.58      cvs      2571: 
                   2572:   switch (attr)
                   2573:     {
                   2574:     case MathML_ATTR_fontsize:
                   2575:        usprintf (css_command, TEXT("font-size: %s"), value);
                   2576:        break;
1.93      cvs      2577:     case MathML_ATTR_mathsize:
                   2578:        if (ustrcmp (value, TEXT("small")) == 0)
                   2579:         ustrcpy (value, TEXT("80%"));
                   2580:        else if (ustrcmp (value, TEXT("normal")) == 0)
                   2581:         ustrcpy (value, TEXT("100%"));
                   2582:        else if (ustrcmp (value, TEXT("big")) == 0)
                   2583:         ustrcpy (value, TEXT("125%"));
                   2584:        usprintf (css_command, TEXT("font-size: %s"), value);
                   2585:        break;
1.58      cvs      2586:     case MathML_ATTR_lspace:
                   2587:        usprintf (css_command, TEXT("padding-left: %s"), value);
                   2588:        break;
                   2589:     case MathML_ATTR_rspace:
                   2590:        usprintf (css_command, TEXT("padding-right: %s"), value);
                   2591:        break;
                   2592:     }
1.72      cvs      2593:   ParseHTMLSpecificStyle (el, css_command, doc, 0, FALSE);
1.24      cvs      2594: }
                   2595: 
                   2596: /*----------------------------------------------------------------------
1.60      cvs      2597:  MathMLSetScriptLevel
                   2598:  A scriptlevel attribute with value value is associated with element el.
                   2599:  Generate the corresponding style property for this element.
                   2600:  -----------------------------------------------------------------------*/
                   2601: #ifdef __STDC__
                   2602: void MathMLSetScriptLevel (Document doc, Element el, STRING value)
                   2603: #else /* __STDC__*/
                   2604: void MathMLSetScriptLevel (doc, el, value)
                   2605:   Document doc;
                   2606:   Element el;
                   2607:   STRING value;
                   2608: #endif /* __STDC__*/
                   2609: {
                   2610:   PresentationValue   pval;
                   2611:   PresentationContext ctxt;
                   2612:   ThotBool            relative;
                   2613:   int                 percentage;
                   2614: 
                   2615:   ctxt = TtaGetSpecificStyleContext (doc);
                   2616:   if (!value)
                   2617:      /* remove the presentation rule */
                   2618:      {
                   2619:      ctxt->destroy = TRUE;
1.75      cvs      2620:      pval.typed_data.value = 0;
1.60      cvs      2621:      TtaSetStylePresentation (PRSize, el, NULL, ctxt, pval);
                   2622:      }
                   2623:   else
                   2624:      {
                   2625:      ctxt->destroy = FALSE;
                   2626:      /* parse the attribute value (an optional sign and an integer) */
                   2627:      value = TtaSkipWCBlanks (value);
                   2628:      relative = (value[0] == '-' || value[0] == '+');
                   2629:      value = ParseCSSUnit (value, &pval);
                   2630:      if (pval.typed_data.unit != STYLE_UNIT_REL &&
                   2631:         pval.typed_data.real)
                   2632:        /* this is an error: it should be an integer without any unit name */
                   2633:        /* error */;
                   2634:      else
                   2635:        {
                   2636:        if (relative)
                   2637:         {
1.63      cvs      2638:         percentage = 100;
1.60      cvs      2639:          if (pval.typed_data.value == 0)
                   2640:           /* scriptlevel="+0" */
                   2641:           percentage = 100;
                   2642:          else if (pval.typed_data.value == 1)
                   2643:           /* scriptlevel="+1" */
                   2644:           percentage = 71;
                   2645:         else if (pval.typed_data.value == 2)
                   2646:           /* scriptlevel="+2" */
                   2647:           percentage = 50;
                   2648:         else if (pval.typed_data.value >= 3)
                   2649:           /* scriptlevel="+3" or more */
                   2650:           percentage = 35;
                   2651:         else if (pval.typed_data.value == -1)
                   2652:           /* scriptlevel="-1" */
                   2653:           percentage = 141;
                   2654:         else if (pval.typed_data.value == -2)
                   2655:           /* scriptlevel="-2" */
                   2656:           percentage = 200;
                   2657:         else if (pval.typed_data.value <= -3)
                   2658:           /* scriptlevel="-3" or less */
                   2659:           percentage = 282;
                   2660:         pval.typed_data.value = percentage;
                   2661:         pval.typed_data.unit = STYLE_UNIT_PERCENT;
1.78      cvs      2662:         /* the specific presentation to be created is not a CSS rule */
                   2663:         ctxt->cssLevel = 0;
1.60      cvs      2664:         TtaSetStylePresentation (PRSize, el, NULL, ctxt, pval);       
                   2665:         }
                   2666:        else
                   2667:         /* absolute value */
                   2668:         {
                   2669:           /****  ****/;
                   2670:         }
                   2671:        }
                   2672:      }
                   2673:   TtaFreeMemory (ctxt);
                   2674: }
                   2675: 
                   2676: /*----------------------------------------------------------------------
                   2677:  MathMLSpacingAttr
                   2678:  The MathML attribute attr (height, width or depth) is associated
                   2679:  with element el (a mspace or mpadding).
                   2680:  If value is not NULL, generate the corresponding Thot presentation rule for
                   2681:  the element.
                   2682:  If value is NULL, remove the corresponding Thot presentation rule.
                   2683:  -----------------------------------------------------------------------*/
                   2684: #ifdef __STDC__
                   2685: void MathMLSpacingAttr (Document doc, Element el, STRING value, int attr)
                   2686: #else /* __STDC__*/
                   2687: void MathMLSpacingAttr (doc, el, value, attr)
                   2688:   Document doc;
                   2689:   Element el;
                   2690:   STRING value;
                   2691:   int attr;
                   2692: #endif /* __STDC__*/
                   2693: {
                   2694:   ElementType         elType;
                   2695:   PresentationValue   pval;
                   2696:   PresentationContext ctxt;
                   2697:   int                 ruleType;
                   2698: 
                   2699:   /* provisionally, handles only mspace elements */
                   2700:   elType = TtaGetElementType (el);
1.96      cvs      2701:   if (elType.ElTypeNum != MathML_EL_MSPACE &&
1.97    ! cvs      2702:       elType.ElTypeNum != MathML_EL_MPADDED &&
        !          2703:       elType.ElTypeNum != MathML_EL_MTABLE)
1.60      cvs      2704:      return;
                   2705:   switch (attr)
                   2706:     {
                   2707:     case MathML_ATTR_width_:
                   2708:       ruleType = PRWidth;
                   2709:       break;
                   2710:     case MathML_ATTR_height_:
                   2711:       ruleType = PRPaddingTop;
                   2712:       break;
                   2713:     case MathML_ATTR_depth_:
                   2714:       ruleType = PRPaddingBottom;
                   2715:       break;
                   2716:     default:
                   2717:       return;
                   2718:     }
                   2719:   ctxt = TtaGetSpecificStyleContext (doc);
1.97    ! cvs      2720:   if (!value || (ustrcmp (value, TEXT("auto")) == 0))
1.60      cvs      2721:     /* remove the presentation rule */
                   2722:     {
                   2723:       ctxt->destroy = TRUE;
1.75      cvs      2724:       pval.typed_data.value = 0;
1.60      cvs      2725:       TtaSetStylePresentation (ruleType, el, NULL, ctxt, pval);
                   2726:     }
                   2727:   else
                   2728:     {
                   2729:       ctxt->destroy = FALSE;
                   2730:       /* parse the attribute value (a number followed by a unit) */
                   2731:       value = TtaSkipWCBlanks (value);
                   2732:       value = ParseCSSUnit (value, &pval);
                   2733:       /***** we should accept namedspace for width *****/
                   2734:       if (pval.typed_data.unit != STYLE_UNIT_INVALID)
1.78      cvs      2735:        {
                   2736:          /* the specific presentation to be created is not a CSS rule */
                   2737:          ctxt->cssLevel = 0;
                   2738:          TtaSetStylePresentation (ruleType, el, NULL, ctxt, pval);
                   2739:        }
1.60      cvs      2740:     }
                   2741:   TtaFreeMemory (ctxt);
                   2742: }
                   2743: 
                   2744: /*----------------------------------------------------------------------
1.1       cvs      2745:    MathMLAttributeComplete
1.58      cvs      2746:    The XML parser has completed parsing attribute attr (as well as its value)
                   2747:    that is associated with element el in document doc.
1.1       cvs      2748:   ----------------------------------------------------------------------*/
                   2749: #ifdef __STDC__
                   2750: void      MathMLAttributeComplete (Attribute attr, Element el, Document doc)
                   2751: #else
                   2752: void      MathMLAttributeComplete (attr, el, doc)
                   2753: Attribute      attr;
                   2754: Element                el;
                   2755: Document       doc;
                   2756: 
                   2757: #endif
                   2758: {
1.23      cvs      2759:    AttributeType     attrType;
                   2760:    int              attrKind;
1.50      cvs      2761:    ElementType       elType;
1.23      cvs      2762: #define buflen 50
1.33      cvs      2763:    STRING            value;
1.50      cvs      2764:    int               val, length;
1.23      cvs      2765:  
1.58      cvs      2766:    /* first get the type of that attribute */
1.23      cvs      2767:    TtaGiveAttributeType (attr, &attrType, &attrKind);
1.54      cvs      2768:    if (attrType.AttrTypeNum == MathML_ATTR_bevelled)
1.58      cvs      2769:      /* it's a bevelled attribute */
1.50      cvs      2770:      {
                   2771:        val = TtaGetAttributeValue (attr);
1.54      cvs      2772:        if (val == MathML_ATTR_bevelled_VAL_true)
                   2773:         /* bevelled = true.  Transform MFRAC into BevelledMFRAC */
1.50      cvs      2774:         {
                   2775:         elType = TtaGetElementType (el);
                   2776:         if (elType.ElTypeNum == MathML_EL_MFRAC)
1.54      cvs      2777:            ChangeTypeOfElement (el, doc, MathML_EL_BevelledMFRAC);
1.50      cvs      2778:         }
                   2779:      }
                   2780:    else if (attrType.AttrTypeNum == MathML_ATTR_color ||
1.93      cvs      2781:            attrType.AttrTypeNum == MathML_ATTR_mathcolor ||
                   2782:            attrType.AttrTypeNum == MathML_ATTR_background_ ||
                   2783:            attrType.AttrTypeNum == MathML_ATTR_mathbackground ||
                   2784:            attrType.AttrTypeNum == MathML_ATTR_fontsize ||
                   2785:            attrType.AttrTypeNum == MathML_ATTR_mathsize ||
                   2786:            attrType.AttrTypeNum == MathML_ATTR_fontfamily ||
                   2787:            attrType.AttrTypeNum == MathML_ATTR_linethickness ||
                   2788:            attrType.AttrTypeNum == MathML_ATTR_lspace ||
                   2789:            attrType.AttrTypeNum == MathML_ATTR_rspace ||
                   2790:            attrType.AttrTypeNum == MathML_ATTR_scriptlevel ||
                   2791:            attrType.AttrTypeNum == MathML_ATTR_width_ ||
                   2792:            attrType.AttrTypeNum == MathML_ATTR_height_ ||
                   2793:            attrType.AttrTypeNum == MathML_ATTR_depth_ )
                   2794:      {
1.23      cvs      2795:       length = TtaGetTextAttributeLength (attr);
                   2796:       if (length >= buflen)
                   2797:          length = buflen - 1;
                   2798:       if (length > 0)
                   2799:         {
1.42      cvs      2800:           value = TtaAllocString (buflen);
1.33      cvs      2801:           value[0] = EOS;
                   2802:           TtaGiveTextAttributeValue (attr, value, &length);
                   2803:           switch (attrType.AttrTypeNum)
                   2804:             {
                   2805:             case MathML_ATTR_color:
1.93      cvs      2806:             case MathML_ATTR_mathcolor:
1.24      cvs      2807:                HTMLSetForegroundColor (doc, el, value);
                   2808:               break;
1.33      cvs      2809:             case MathML_ATTR_background_:
1.93      cvs      2810:             case MathML_ATTR_mathbackground:
1.24      cvs      2811:                HTMLSetBackgroundColor (doc, el, value);
                   2812:               break;
1.33      cvs      2813:             case MathML_ATTR_fontfamily:
1.24      cvs      2814:               SetFontfamily (doc, el, value);
1.83      cvs      2815:               break;
                   2816:             case MathML_ATTR_linethickness:
                   2817:               MathMLlinethickness (doc, el, value);
1.58      cvs      2818:               break;
                   2819:             case MathML_ATTR_fontsize:
1.93      cvs      2820:             case MathML_ATTR_mathsize:
1.58      cvs      2821:             case MathML_ATTR_lspace:
                   2822:             case MathML_ATTR_rspace:
1.60      cvs      2823:               MathMLAttrToStyleProperty (doc, el, value,attrType.AttrTypeNum);
                   2824:               break;
                   2825:             case MathML_ATTR_scriptlevel:
                   2826:               MathMLSetScriptLevel (doc, el, value);
                   2827:               break;
                   2828:              case MathML_ATTR_width_:
                   2829:             case MathML_ATTR_height_:
                   2830:             case MathML_ATTR_depth_:
                   2831:               MathMLSpacingAttr (doc, el, value, attrType.AttrTypeNum);
1.59      cvs      2832:               break;
                   2833:             default:
1.24      cvs      2834:               break;
1.33      cvs      2835:             }
                   2836:           TtaFreeMemory (value);
1.23      cvs      2837:         }
                   2838:       }
1.1       cvs      2839: }
                   2840: 
                   2841: /*----------------------------------------------------------------------
                   2842:    MathMLGetDTDName
                   2843:   ----------------------------------------------------------------------*/
                   2844: #ifdef __STDC__
1.14      cvs      2845: void      MathMLGetDTDName (STRING DTDname, STRING elementName)
1.1       cvs      2846: #else
                   2847: void      MathMLGetDTDName (DTDname, elementName)
1.14      cvs      2848: STRING DTDname;
                   2849: STRING elementName;
1.1       cvs      2850: 
                   2851: #endif
                   2852: {
                   2853:    /* no other DTD allowed within MathML elements */
1.49      cvs      2854:    ustrcpy (DTDname, TEXT(""));
1.1       cvs      2855: }
                   2856: 
                   2857: /* end of module */

Webmaster