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

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

Webmaster