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

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

Webmaster