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

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

Webmaster