Annotation of Amaya/amaya/XHTMLbuilder.c, revision 1.134

1.1       cvs         1: /*
                      2:  *
1.123     vatton      3:  *  (c) COPYRIGHT INRIA and W3C, 1996-2005
1.1       cvs         4:  *  Please first read the full copyright statement in file COPYRIGHT.
                      5:  *
                      6:  */
                      7: 
                      8: /*
1.30      cvs         9:  * XHTMLbuilder.c
1.23      cvs        10:  * Builds the corresponding abstract tree for a Thot document of type HTML.
1.1       cvs        11:  *
1.20      cvs        12:  * Authors: L. Carcone
                     13:  *          V. Quint 
1.1       cvs        14:  */
                     15: 
                     16: #define THOT_EXPORT extern
                     17: #include "amaya.h"
                     18: #include "css.h"
1.2       cvs        19: #include "parser.h"
                     20: #include "HTML.h"
1.30      cvs        21: #include "fetchHTMLname.h"
1.2       cvs        22: 
1.13      cvs        23: #include "css_f.h"
1.76      vatton     24: #include "EDITstyle_f.h"
1.13      cvs        25: #include "fetchXMLname_f.h"
1.30      cvs        26: #include "fetchHTMLname_f.h"
1.22      cvs        27: #include "html2thot_f.h"
1.1       cvs        28: #include "HTMLactions_f.h"
                     29: #include "HTMLedit_f.h"
1.22      cvs        30: #include "HTMLform_f.h"
1.1       cvs        31: #include "HTMLimage_f.h"
                     32: #include "HTMLtable_f.h"
                     33: #include "HTMLimage_f.h"
1.104     vatton     34: #include "init_f.h"
1.1       cvs        35: #include "UIcss_f.h"
1.13      cvs        36: #include "styleparser_f.h"
1.2       cvs        37: #include "XHTMLbuilder_f.h"
1.13      cvs        38: #include "Xml2thot_f.h"
1.1       cvs        39: 
1.47      cvs        40: /* Elements that cannot contain text as immediate children.
                     41:    When some text is present in the HTML file it must be 
                     42:    surrounded by a Pseudo_paragraph element */
                     43: static int          NoTextChild[] =
1.129     vatton     44:   {
                     45:     HTML_EL_Document, HTML_EL_HTML, HTML_EL_HEAD, HTML_EL_BODY,
                     46:     HTML_EL_Definition_List, HTML_EL_Block_Quote, HTML_EL_Directory,
                     47:     HTML_EL_Form, HTML_EL_Menu, HTML_EL_FIELDSET,
                     48:     HTML_EL_Numbered_List, HTML_EL_Option_Menu,
                     49:     HTML_EL_Unnumbered_List, HTML_EL_Definition, HTML_EL_List_Item,
                     50:     HTML_EL_MAP, HTML_EL_map, HTML_EL_Applet,
                     51:     HTML_EL_Object, HTML_EL_IFRAME, HTML_EL_NOFRAMES,
                     52:     HTML_EL_Division, HTML_EL_Center, HTML_EL_NOSCRIPT,
                     53:     HTML_EL_Data_cell, HTML_EL_Heading_cell,
                     54:     0};
1.47      cvs        55: 
1.28      cvs        56: /* Define a pointer to let parser functions access the HTML entity table */
                     57: extern XmlEntity *pXhtmlEntityTable;
1.6       cvs        58: 
1.30      cvs        59: /* maximum size of error messages */
                     60: #define MaxMsgLength 200
                     61: 
1.6       cvs        62: /*----------------------------------------------------------------------
1.104     vatton     63:   ParseCharsetAndContentType:
1.6       cvs        64:   Parses the element HTTP-EQUIV and looks for the charset value.
                     65:   ----------------------------------------------------------------------*/
1.104     vatton     66: void ParseCharsetAndContentType (Element el, Document doc) 
1.30      cvs        67: 
1.6       cvs        68: {
1.129     vatton     69:   AttributeType attrType;
                     70:   Attribute     attr;
                     71:   ElementType   elType;
                     72:   CHARSET       charset;
                     73:   char         *text, *text2, *ptrText, *str;
                     74:   char          charsetname[MAX_LENGTH];
                     75:   int           length;
                     76:   int           pos, index = 0;
                     77: 
                     78:   charset = TtaGetDocumentCharset (doc);
                     79:   if (charset != UNDEFINED_CHARSET &&
                     80:       DocumentMeta[doc] && DocumentMeta[doc]->content_type)
                     81:     return;
                     82: 
                     83:   elType = TtaGetElementType (el);
                     84:   attrType.AttrSSchema = elType.ElSSchema;
                     85:   attrType.AttrTypeNum = HTML_ATTR_http_equiv;
                     86:   attr = TtaGetAttribute (el, attrType);
                     87:   if (attr != NULL)
                     88:     {
                     89:       /* There is a HTTP-EQUIV attribute */
                     90:       length = TtaGetTextAttributeLength (attr);
                     91:       if (length > 0)
                     92:         {
                     93:           text = (char *)TtaGetMemory (length + 1);
                     94:           TtaGiveTextAttributeValue (attr, text, &length);
                     95:           if (!strcasecmp (text, "content-type"))
                     96:             {
                     97:               attrType.AttrTypeNum = HTML_ATTR_meta_content;
                     98:               attr = TtaGetAttribute (el, attrType);
                     99:               if (attr != NULL)
                    100:                 {
                    101:                   length = TtaGetTextAttributeLength (attr);
                    102:                   if (length > 0)
                    103:                     {
                    104:                       text2 = (char *)TtaGetMemory (length + 1);
                    105:                       TtaGiveTextAttributeValue (attr, text2, &length);
                    106:                       ptrText = text2;
                    107:                       while (*ptrText)
                    108:                         {
                    109:                           *ptrText = tolower (*ptrText);
                    110:                           ptrText++;
                    111:                         }
                    112: 
                    113:                       if (!DocumentMeta[doc])
                    114:                         DocumentMeta[doc] = DocumentMetaDataAlloc ();
                    115:                       if (DocumentMeta[doc]->content_type == NULL)
                    116:                         {
1.104     vatton    117:                           
1.129     vatton    118:                           if (!strncmp (text2, "text/html", 9))
                    119:                             DocumentMeta[doc]->content_type = TtaStrdup ("text/html");
                    120:                           else
                    121:                             DocumentMeta[doc]->content_type = TtaStrdup (AM_XHTML_MIME_TYPE);
                    122:                         }
                    123: 
                    124:                       if (charset == UNDEFINED_CHARSET)
                    125:                         {
                    126:                           /* the charset is not already defined by the http header */
                    127:                           str = strstr (text2, "charset=");
                    128:                           if (str)
                    129:                             {
                    130:                               pos = str - text2 + 8;
                    131:                               while (text2[pos] != SPACE &&
                    132:                                      text2[pos] != TAB && text2[pos] != EOS)
                    133:                                 charsetname[index++] = text2[pos++];
                    134:                               charsetname[index] = EOS;
                    135:                               charset = TtaGetCharset (charsetname);
                    136:                               if (charset != UNDEFINED_CHARSET)
                    137:                                 TtaSetDocumentCharset (doc, charset, FALSE);
                    138:                             }
                    139:                         }
                    140:                       TtaFreeMemory (text2);
                    141:                     }       
                    142:                 } 
                    143:             }
                    144:           TtaFreeMemory (text);
                    145:         }
                    146:     }
1.6       cvs       147: }
                    148: 
1.126     tollenae  149: #ifdef TEMPLATES
1.130     vatton    150: /*----------------------------------------------------------------------
                    151:   ----------------------------------------------------------------------*/
1.126     tollenae  152: void ParseTemplateMeta (Element el, Document doc)
                    153: {
                    154:   AttributeType attrType;
                    155:   Attribute     attr;
                    156:   ElementType   elType;
                    157:   char         *text, *text2, *ptrText;
                    158:   int           length;
                    159: 
                    160:   elType = TtaGetElementType (el);
                    161:   attrType.AttrSSchema = elType.ElSSchema;
                    162:   attrType.AttrTypeNum = HTML_ATTR_meta_name;
                    163:   attr = TtaGetAttribute (el, attrType);
                    164: 
                    165:   if (attr != NULL)
                    166:     {
                    167:       /* There is a name attribute */
                    168:       length = TtaGetTextAttributeLength (attr);
                    169:       if (length > 0)
1.129     vatton    170:         {
                    171:           text = (char *)TtaGetMemory (length + 1);
                    172:           TtaGiveTextAttributeValue (attr, text, &length);
                    173:           if (!strcasecmp (text, "template"))
                    174:             {
                    175:               /* We are parsing the 'template' meta */
                    176:               attrType.AttrTypeNum = HTML_ATTR_meta_content;
                    177:               attr = TtaGetAttribute (el, attrType);
                    178:               if (attr != NULL)
                    179:                 {
                    180:                   length = TtaGetTextAttributeLength (attr);
                    181:                   if (length > 0)
                    182:                     {
                    183:                       text2 = (char *)TtaGetMemory (length + 1);
                    184:                       TtaGiveTextAttributeValue (attr, text2, &length);
                    185:                       ptrText = text2;
1.126     tollenae  186:                      
1.129     vatton    187:                       /* Convert all char to lower case */
                    188:                       while (*ptrText)
                    189:                         {
                    190:                           *ptrText = tolower (*ptrText);
                    191:                           ptrText++;
                    192:                         }
                    193: 
                    194:                       if (!DocumentMeta[doc])
                    195:                         DocumentMeta[doc] = DocumentMetaDataAlloc ();
                    196:                       if (DocumentMeta[doc]->template_version == NULL)
                    197:                         {
                    198:                           DocumentMeta[doc]->template_version = TtaStrdup (text2);
                    199:                         }
                    200:                       TtaFreeMemory (text2);
                    201:                     }       
                    202:                 } 
                    203:             }
                    204:           TtaFreeMemory (text);
                    205:         }
1.126     tollenae  206:     }
                    207: }
                    208: #endif /* TEMPLATES */
                    209: 
                    210: 
1.23      cvs       211: /*----------------------------------------------------------------------
1.129     vatton    212:   XhtmlCannotContainText 
                    213:   Return TRUE if element el is a block element.
1.47      cvs       214:   ----------------------------------------------------------------------*/
1.109     vatton    215: ThotBool XhtmlCannotContainText (ElementType elType)
1.47      cvs       216: 
                    217: {
1.129     vatton    218:   int        i;
                    219:   ThotBool   ret;
1.47      cvs       220: 
1.129     vatton    221:   if (strcmp (TtaGetSSchemaName (elType.ElSSchema), "HTML"))
                    222:     /* not an HTML element */
                    223:     ret = TRUE;
                    224:   else
                    225:     {
                    226:       ret = FALSE;
                    227:       i = 0;
                    228:       while (NoTextChild[i] > 0 && NoTextChild[i] != elType.ElTypeNum)
                    229:         i++;
                    230:       if (NoTextChild[i] == elType.ElTypeNum)
                    231:         ret = TRUE;
                    232:     }
                    233:   return ret;
1.23      cvs       234: }
                    235: 
1.6       cvs       236: /*----------------------------------------------------------------------
1.117     quint     237:   CheckMandatoryAttribute
                    238:   If attribute attrNum is not present on element el, generate a
                    239:   parsing error message.
1.111     vatton    240:   ----------------------------------------------------------------------*/
1.128     tollenae  241: void CheckMandatoryAttribute (Element el, Document doc, int attrNum)
1.111     vatton    242: {
                    243:   ElementType    elType;
                    244:   Attribute      attr;
                    245:   AttributeType  attrType;
1.117     quint     246:   int            lineNum;
1.114     vatton    247:   char          *name;
                    248:   char           msgBuffer[MaxMsgLength];
1.111     vatton    249: 
1.129     vatton    250:   elType = TtaGetElementType (el);
                    251:   attrType.AttrSSchema = elType.ElSSchema;
                    252:   attrType.AttrTypeNum = attrNum;
                    253:   attr = TtaGetAttribute (el, attrType);
                    254:   if (attr == NULL)
                    255:     {
                    256:       name = GetXMLAttributeName (attrType, elType, doc);
                    257:       if (name)
                    258:         {
                    259:           sprintf (msgBuffer, "Missing mandatory attribute %s for element %s",
                    260:                    name, TtaGetElementTypeName(TtaGetElementType(el)));
                    261:           lineNum = TtaGetElementLineNumber(el);
                    262:           if (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat)
                    263:             XmlParseError (errorParsing, (unsigned char *)msgBuffer, lineNum);
                    264:           else
                    265:             HTMLParseError (doc, msgBuffer, lineNum);
                    266:         }
                    267:     }
1.111     vatton    268: }
                    269: 
1.118     vatton    270: 
                    271: /*----------------------------------------------------------------------
                    272:   AddRowsColumns
                    273:   Add default rows and columns attributes to a TEXTAREA element.
                    274:   ----------------------------------------------------------------------*/
                    275: void AddRowsColumns (Element el, Document doc)
                    276: {
                    277:   ElementType    elType;
                    278:   Attribute      attr;
                    279:   AttributeType  attrType;
                    280: 
                    281:   /* Add defaults rows and columns to display the textarea */
                    282:   elType = TtaGetElementType (el);
                    283:   attrType.AttrSSchema = elType.ElSSchema;
                    284:   attrType.AttrTypeNum = HTML_ATTR_Rows;
                    285:   attr = TtaGetAttribute (el, attrType);
                    286:   if (attr == NULL)
                    287:     {
                    288:       attr = TtaNewAttribute (attrType);
                    289:       TtaAttachAttribute (el, attr, doc);
                    290:       TtaSetAttributeValue (attr, 4, el, doc);
                    291:     }
                    292:   attrType.AttrTypeNum = HTML_ATTR_Columns;
                    293:   attr = TtaGetAttribute (el, attrType);
                    294:   if (attr == NULL)
                    295:     {
                    296:       attr = TtaNewAttribute (attrType);
                    297:       TtaAttachAttribute (el, attr, doc);
                    298:       TtaSetAttributeValue (attr, 20, el, doc);
                    299:     }
                    300: }
                    301: 
1.111     vatton    302: /*----------------------------------------------------------------------
1.6       cvs       303:   XhtmlElementComplete
1.20      cvs       304:   Complete Xhtml elements.
1.6       cvs       305:   Check its attributes and its contents.
                    306:   ----------------------------------------------------------------------*/
1.99      cvs       307: void XhtmlElementComplete (ParserData *context, Element el, int *error)
1.30      cvs       308: {
1.129     vatton    309:   Document       doc;   
                    310:   ElementType    elType, newElType, childType;
                    311:   Element        child, desc, leaf, prev, next, last,
                    312:     elFrames, lastFrame, lastChild, parent, picture, content;
                    313:   Attribute      attr;
                    314:   AttributeType  attrType;
                    315:   Language       lang;
                    316:   char           *text;
                    317:   char           lastChar[2];
                    318:   char           *name1, *data;
                    319:   int            length;
                    320:   SSchema        htmlSchema;
1.134   ! vatton    321:   ThotBool       isImage, isInline, clean;
1.129     vatton    322:   char           msgBuffer[MaxMsgLength];
                    323:   int            lineNum;
                    324: 
                    325:   *error = 0;
                    326:   doc = context->doc;
                    327: 
                    328:   elType = TtaGetElementType (el);
                    329:   htmlSchema = elType.ElSSchema;
                    330:   isInline = IsXMLElementInline (elType, doc);
                    331:   newElType.ElSSchema = elType.ElSSchema;
                    332: 
                    333:   if (elType.ElTypeNum == HTML_EL_Paragraph ||
                    334:       elType.ElTypeNum == HTML_EL_Address ||
                    335:       elType.ElTypeNum == HTML_EL_H1 ||
                    336:       elType.ElTypeNum == HTML_EL_H2 ||
                    337:       elType.ElTypeNum == HTML_EL_H3 ||
                    338:       elType.ElTypeNum == HTML_EL_H4 ||
                    339:       elType.ElTypeNum == HTML_EL_H5 ||
                    340:       elType.ElTypeNum == HTML_EL_H6 ||
                    341:       elType.ElTypeNum == HTML_EL_Preformatted ||
                    342:       elType.ElTypeNum == HTML_EL_Term ||
                    343:       elType.ElTypeNum == HTML_EL_LEGEND ||
                    344:       elType.ElTypeNum == HTML_EL_CAPTION ||
                    345:       elType.ElTypeNum == HTML_EL_rb ||
                    346:       elType.ElTypeNum == HTML_EL_rt ||
                    347:       (isInline &&  !TtaIsLeaf (elType) &&
                    348:        elType.ElTypeNum != HTML_EL_Text_Area))
                    349:     /* It's an element that is supposed to contain at least a Basic_Elem.
                    350:        If it is empty, insert a Basic_Elem to allow the user to put the
                    351:        selection within this element */
                    352:     /* Don't do it for a Text_Area, as an Inserted_Text element has to be
                    353:        created (see below) */
                    354:     {
                    355:       child = TtaGetFirstChild (el);
                    356:       if (child == NULL)
                    357:         /* it's an empty inline element */
                    358:         /* insert a Basic_Elem element in the element */
                    359:         {
                    360:           newElType.ElTypeNum = HTML_EL_Basic_Elem;
                    361:           child = TtaNewTree (doc, newElType, "");
                    362:           TtaInsertFirstChild (&child, el, doc);
                    363:         }
                    364:     }
                    365:   if (!isInline)
                    366:     /* It's a block-level element. Is it within a character-level element? */
                    367:     if (elType.ElTypeNum != HTML_EL_Comment_ &&
                    368:         elType.ElTypeNum != HTML_EL_XMLPI)
                    369:       BlockInCharLevelElem (el);
                    370: 
                    371:   switch (elType.ElTypeNum)
                    372:     {
1.134   ! vatton    373:     case HTML_EL_PICTURE_UNIT:
        !           374:       /* Check the mandatory SRC attribute */
        !           375:       CheckMandatoryAttribute (el, doc, HTML_ATTR_SRC);
        !           376:       break;
        !           377: 
1.129     vatton    378:     case HTML_EL_Object:       /* it's an object */
                    379:       data = NULL;
                    380:       isImage = FALSE;
                    381:       /* is there a type attribute on the object element? */
                    382:       attrType.AttrSSchema = elType.ElSSchema;
                    383:       attrType.AttrTypeNum = HTML_ATTR_Object_type;
                    384:       attr = TtaGetAttribute (el, attrType);
                    385:       if (attr)
                    386:         /* there is a type attribute. Get its value to see if the object
                    387:            represents an image */
                    388:         {
                    389:           length = TtaGetTextAttributeLength (attr);
                    390:           if (length > 0)
                    391:             {
                    392:               name1 = (char *)TtaGetMemory (length + 1);
                    393:               TtaGiveTextAttributeValue (attr, name1, &length);
                    394:               if (!strcmp (name1, AM_MATHML_MIME_TYPE) ||
                    395:                   !strcmp (name1, "application/postscript") ||
                    396:                   !strcmp (name1, "image/x-bitmap") ||
                    397:                   !strcmp (name1, "image/x-xpixmap") ||
                    398:                   !strcmp (name1, "image/gif") ||
                    399:                   !strcmp (name1, "image/jpeg") ||
                    400:                   !strcmp (name1, "image/png") ||
                    401:                   !strcmp (name1, "image/svg") ||
                    402:                   !strcmp (name1, AM_SVG_MIME_TYPE) ||
                    403:                   !strcmp (name1, AM_XHTML_MIME_TYPE) ||
                    404:                   !strcmp (name1, "text/html") ||
                    405:                   !strcmp (name1, "text/htm") ||
                    406:                   !strcmp (name1, AM_GENERIC_XML_MIME_TYPE))
                    407:                 isImage = TRUE;
                    408:               TtaFreeMemory (name1);
                    409:             }
                    410:         }
                    411: 
                    412:       attrType.AttrTypeNum = HTML_ATTR_data;
                    413:       attr = TtaGetAttribute (el, attrType);
                    414:       if (attr)
                    415:         /* the object has a data attribute */
                    416:         {
                    417:           length = TtaGetTextAttributeLength (attr);
                    418:           if (length > 0)
                    419:             {
                    420:               data = (char *)TtaGetMemory (length + 1);
                    421:               TtaGiveTextAttributeValue (attr, data, &length);
                    422:               if (!isImage)
                    423:                 if (!strcmp (&data[length-3], "mml") ||
                    424:                     !strcmp (&data[length-3], "gif") ||
                    425:                     !strcmp (&data[length-3], "jpg") ||
                    426:                     !strcmp (&data[length-4], "jpeg") ||
                    427:                     !strcmp (&data[length-3], "png") ||
                    428:                     !strcmp (&data[length-3], "svg") ||
                    429:                     !strcmp (&data[length-4], "svgz") ||
                    430:                     !strcmp (&data[length-3], "htm") ||
                    431:                     !strcmp (&data[length-4], "html") ||
                    432:                     !strcmp (&data[length-3], "xml"))
                    433:                   isImage = TRUE;
                    434:             }
                    435:         }
                    436:       picture = NULL;     /* no PICTURE element yet */
                    437:       child = TtaGetFirstChild (el);
                    438:       if (isImage)
                    439:         {
                    440:           /* the object represents an image. We need a PICTURE element as
                    441:              child of the object to hold the image */
                    442:           elType.ElTypeNum = HTML_EL_PICTURE_UNIT;
                    443:           picture = TtaNewTree (doc, elType, "");
                    444:           if (child)
                    445:             TtaInsertSibling (picture, child, TRUE, doc);
                    446:           else
                    447:             TtaInsertFirstChild (&picture, el, doc);
                    448:           /* copy attribute data of the object into the SRC attribute of
                    449:              the PICTURE element */
                    450:           if (data)
                    451:             /* the object has a data attribute */
                    452:             {
1.134   ! vatton    453:               // remove extra spaces
        !           454:               clean = FALSE;
        !           455:               while (length > 0 && data[length-1] == SPACE)
        !           456:                 {
        !           457:                   data[length-1] = EOS;
        !           458:                   length--;
        !           459:                   clean = TRUE;
        !           460:                 }
        !           461:               if (clean)
        !           462:                 TtaSetAttributeText (attr, data, el, doc);
        !           463:               // copy the attribute in the picture element
1.129     vatton    464:               attrType.AttrTypeNum = HTML_ATTR_SRC;
                    465:               attr = TtaGetAttribute (picture, attrType);
                    466:               if (attr == NULL)
                    467:                 {
                    468:                   attr = TtaNewAttribute (attrType);
                    469:                   TtaAttachAttribute (picture, attr, doc);
1.134   ! vatton    470: 
1.129     vatton    471:                 }
                    472:               TtaSetAttributeText (attr, data, picture, doc);
1.134   ! vatton    473:               }
1.129     vatton    474:           attrType.AttrTypeNum = HTML_ATTR_Height_;
                    475:           attr = TtaGetAttribute (el, attrType);
                    476:           if (attr)
                    477:             /* the Object has a height attribute. Applies it to the
                    478:                picture element */
                    479:             {
                    480:               length = TtaGetTextAttributeLength (attr);
                    481:               if (length > 0)
                    482:                 {
                    483:                   text = (char *)TtaGetMemory (length + 1);
                    484:                   TtaGiveTextAttributeValue (attr, text, &length);
                    485:                   /* create the corresponding attribute IntHeightPercent or */
                    486:                   /* IntHeightPxl */
                    487:                   CreateAttrHeightPercentPxl (text, el, doc, -1);
                    488:                   TtaFreeMemory (text);
                    489:                 }
                    490:             }
                    491:           attrType.AttrTypeNum = HTML_ATTR_Width__;
                    492:           attr = TtaGetAttribute (el, attrType);
                    493:           if (attr)
                    494:             /* the Object has a width attribute. Applies it to the
                    495:                picture element */
                    496:             {
                    497:               length = TtaGetTextAttributeLength (attr);
                    498:               if (length > 0)
                    499:                 {
                    500:                   text = (char *)TtaGetMemory (length + 1);
                    501:                   TtaGiveTextAttributeValue (attr, text, &length);
                    502:                   /* create the corresponding attribute IntWidthPercent or */
                    503:                   /* IntWidthPxl */
                    504:                   CreateAttrWidthPercentPxl (text, el, doc, -1);
                    505:                   TtaFreeMemory (text);
                    506:                 }
                    507:             }
                    508:         }
                    509: 
                    510:       /* is the Object_Content element already created ? */
                    511:       if (child)
                    512:         /* the object element has at least 1 child element */
                    513:         {
                    514:           content = NULL;
                    515:           desc = child;
                    516:           elType = TtaGetElementType (desc);
                    517:           if (elType.ElTypeNum != HTML_EL_Object_Content)
                    518:             {
                    519:               TtaNextSibling(&desc);
                    520:               if (desc)
                    521:                 elType = TtaGetElementType (desc);
                    522:             }
                    523:           /* is it the Object_Content element ? */
                    524:           if (elType.ElTypeNum == HTML_EL_Object_Content)
                    525:             content = desc;
                    526:           else
                    527:             {
                    528:               /* create an Object_Content element */
                    529:               elType.ElTypeNum = HTML_EL_Object_Content;
                    530:               content = TtaNewElement (doc, elType);
                    531:               if (picture)
                    532:                 TtaInsertSibling (content, picture, FALSE, doc);
                    533:               else
                    534:                 TtaInsertSibling (content, child, TRUE, doc);
                    535:               /* move previous existing children into Object_Content */
                    536:               child = TtaGetLastChild(el);
                    537:               while (child != content)
                    538:                 {
                    539:                   TtaRemoveTree (child, doc);
                    540:                   TtaInsertFirstChild (&child, content, doc);
                    541:                   child = TtaGetLastChild(el);
                    542:                 }
                    543:             }
                    544:         }
1.134   ! vatton    545:       TtaFreeMemory (data);
        !           546:       break;
        !           547: 
        !           548:     case HTML_EL_IMG:
        !           549:       /* Check the mandatory ALT attribute */
        !           550:       CheckMandatoryAttribute (el, doc, HTML_ATTR_ALT);
        !           551:       /* Check the mandatory SRC attribute */
        !           552:       CheckMandatoryAttribute (el, doc, HTML_ATTR_SRC);
        !           553:       /* We need a PICTURE element as child to hold the image */
        !           554:       picture = NULL;
        !           555:       child = TtaGetFirstChild (el);
        !           556:       if (child)
        !           557:         {
        !           558:           elType = TtaGetElementType (child);
        !           559:           if (elType.ElTypeNum == HTML_EL_PICTURE_UNIT)
        !           560:             // the picture is already created
        !           561:             picture = child;
        !           562:         }
        !           563:       if (picture == NULL)
        !           564:         {
        !           565:           elType.ElTypeNum = HTML_EL_PICTURE_UNIT;
        !           566:           picture = TtaNewTree (doc, elType, "");
        !           567:           if (child)
        !           568:             TtaInsertSibling (picture, child, TRUE, doc);
        !           569:           else
        !           570:             TtaInsertFirstChild (&picture, el, doc);
        !           571:         }
        !           572:       attrType.AttrSSchema = elType.ElSSchema;
        !           573:       attrType.AttrTypeNum = HTML_ATTR_SRC;
        !           574:       attr = TtaGetAttribute (el, attrType);
        !           575:       if (attr)
        !           576:         /* the img has a src attribute */
        !           577:         {
        !           578:           length = TtaGetTextAttributeLength (attr);
        !           579:           data = (char *)TtaGetMemory (length + 1);
        !           580:           TtaGiveTextAttributeValue (attr, data, &length);
        !           581:           if (data)
        !           582:             {
        !           583:               // remove extra spaces
        !           584:               clean = FALSE;
        !           585:               while (length > 0 && data[length-1] == SPACE)
        !           586:                 {
        !           587:                   data[length-1] = EOS;
        !           588:                   length--;
        !           589:                   clean = TRUE;
        !           590:                 }
        !           591:               if (clean)
        !           592:                 TtaSetAttributeText (attr, data, el, doc);
        !           593:               // copy the attribute in the picture element
        !           594:               attr = TtaGetAttribute (picture, attrType);
        !           595:               if (attr == NULL)
        !           596:                 {
        !           597:                   attr = TtaNewAttribute (attrType);
        !           598:                   TtaAttachAttribute (picture, attr, doc);
        !           599:                 }
        !           600:               TtaSetAttributeText (attr, data, picture, doc);
        !           601:               TtaFreeMemory (data);
        !           602:             }
        !           603:         }
        !           604:       attrType.AttrTypeNum = HTML_ATTR_Height_;
        !           605:       attr = TtaGetAttribute (el, attrType);
        !           606:       if (attr)
        !           607:         /* the img has a height attribute. Applies it to the
        !           608:            picture element */
        !           609:         {
        !           610:           length = TtaGetTextAttributeLength (attr);
        !           611:           if (length > 0)
        !           612:             {
        !           613:               text = (char *)TtaGetMemory (length + 1);
        !           614:               TtaGiveTextAttributeValue (attr, text, &length);
        !           615:               /* create the corresponding attribute IntHeightPercent or */
        !           616:               /* IntHeightPxl */
        !           617:               CreateAttrHeightPercentPxl (text, el, doc, -1);
        !           618:               TtaFreeMemory (text);
        !           619:             }
        !           620:         }
        !           621:       attrType.AttrTypeNum = HTML_ATTR_Width__;
        !           622:       attr = TtaGetAttribute (el, attrType);
        !           623:       if (attr)
        !           624:         /* the img has a width attribute. Applies it to the
        !           625:            picture element */
        !           626:         {
        !           627:           length = TtaGetTextAttributeLength (attr);
        !           628:           if (length > 0)
        !           629:             {
        !           630:               text = (char *)TtaGetMemory (length + 1);
        !           631:               TtaGiveTextAttributeValue (attr, text, &length);
        !           632:               /* create the corresponding attribute IntWidthPercent or */
        !           633:               /* IntWidthPxl */
        !           634:               CreateAttrWidthPercentPxl (text, el, doc, -1);
        !           635:               TtaFreeMemory (text);
        !           636:             }
        !           637:         }
1.129     vatton    638:       break;
                    639: 
                    640:     case HTML_EL_Parameter:
                    641:       /* Check the mandatory name attribute */
                    642:       CheckMandatoryAttribute (el, doc, HTML_ATTR_Param_name);
                    643:       break;
                    644: 
                    645:     case HTML_EL_IFRAME:         /* it's an iframe */
                    646:       child = TtaGetFirstChild (el);
                    647:       /* is the Iframe_Content element already created ? */
                    648:       if (child)
                    649:         /* the iframe element has at least 1 child element */
                    650:         {
                    651:           content = NULL;
                    652:           desc = child;
                    653:           elType = TtaGetElementType (desc);
                    654:           if (elType.ElTypeNum != HTML_EL_Iframe_Content)
                    655:             {
                    656:               TtaNextSibling(&desc);
                    657:               if (desc)
                    658:                 elType = TtaGetElementType (desc);
                    659:             }
                    660:           /* is it the Iframe_Content element ? */
                    661:           if (elType.ElTypeNum == HTML_EL_Iframe_Content)
                    662:             content = desc;
                    663:           else
                    664:             {
                    665:               /* create an Iframe_Content element */
                    666:               elType.ElTypeNum = HTML_EL_Iframe_Content;
                    667:               content = TtaNewElement (doc, elType);
                    668:               TtaInsertSibling (content, child, TRUE, doc);
                    669:               /* move previous existing children into Iframe_Content */
                    670:               child = TtaGetLastChild(el);
                    671:               while (child != content)
                    672:                 {
                    673:                   TtaRemoveTree (child, doc);
                    674:                   TtaInsertFirstChild (&child, content, doc);
                    675:                   child = TtaGetLastChild(el);
                    676:                 }
                    677:             }
                    678:         }
                    679:       break;
                    680: 
                    681:     case HTML_EL_Unnumbered_List:
                    682:     case HTML_EL_Numbered_List:
                    683:     case HTML_EL_Menu:
                    684:     case HTML_EL_Directory:
                    685:       /* It's a List element. It should only have List_Item children.
                    686:          If it has List element chidren, move these List elements
                    687:          within their previous List_Item sibling.  This is to fix
                    688:          a bug in document generated by Mozilla. */
                    689:       prev = NULL;
                    690:       next = NULL;
                    691:       child = TtaGetFirstChild (el);
                    692:       while (child != NULL)
                    693:         {
                    694:           next = child;
                    695:           TtaNextSibling (&next);
                    696:           elType = TtaGetElementType (child);
                    697:           if (elType.ElTypeNum == HTML_EL_Unnumbered_List ||
                    698:               elType.ElTypeNum == HTML_EL_Numbered_List ||
                    699:               elType.ElTypeNum == HTML_EL_Menu ||
                    700:               elType.ElTypeNum == HTML_EL_Directory)
                    701:             /* this list element is a child of another list element */
                    702:             if (prev)
                    703:               {
                    704:                 elType = TtaGetElementType (prev);
                    705:                 if (elType.ElTypeNum == HTML_EL_List_Item)
                    706:                   {
                    707:                     /* get the last child of the previous List_Item */
                    708:                     desc = TtaGetFirstChild (prev);
                    709:                     last = NULL;
                    710:                     while (desc)
                    711:                       {
                    712:                         last = desc;
                    713:                         TtaNextSibling (&desc);
                    714:                       }
                    715:                     /* move the list element after the last child of the
                    716:                        previous List_Item */
                    717:                     TtaRemoveTree (child, doc);
                    718:                     if (last)
                    719:                       TtaInsertSibling (child, last, FALSE, doc);
                    720:                     else
                    721:                       TtaInsertFirstChild (&child, prev, doc);
                    722:                     child = prev;
                    723:                   }
                    724:               }
                    725:           prev = child;
                    726:           child = next;
                    727:         }
                    728:       break;
1.6       cvs       729:        
1.129     vatton    730:     case HTML_EL_FRAMESET:
                    731:       /* The FRAMESET element is now complete.  Gather all its FRAMESET
                    732:          and FRAME children and wrap them up in a Frames element */
                    733:       elFrames = NULL; lastFrame = NULL;
                    734:       lastChild = NULL;
                    735:       child = TtaGetFirstChild (el);
                    736:       while (child != NULL)
                    737:         {
                    738:           next = child;
                    739:           TtaNextSibling (&next);
                    740:           elType = TtaGetElementType (child);
                    741:           if (elType.ElTypeNum == HTML_EL_FRAMESET ||
                    742:               elType.ElTypeNum == HTML_EL_FRAME ||
                    743:               elType.ElTypeNum == HTML_EL_Comment_)
                    744:             {
                    745:               /* create the Frames element if it does not exist */
                    746:               if (elFrames == NULL)
                    747:                 {
                    748:                   newElType.ElSSchema = htmlSchema;
                    749:                   newElType.ElTypeNum = HTML_EL_Frames;
                    750:                   elFrames = TtaNewElement (doc, newElType);
                    751:                   if (DocumentMeta[doc]->xmlformat)
                    752:                     XmlSetElemLineNumber (elFrames);
                    753:                   else
                    754:                     SetHtmlElemLineNumber (elFrames);
                    755:                   TtaInsertSibling (elFrames, child, TRUE, doc);
                    756:                 }
                    757:               /* move the element as the last child of the Frames element */
                    758:               TtaRemoveTree (child, doc);
                    759:               if (lastFrame == NULL)
                    760:                 TtaInsertFirstChild (&child, elFrames, doc);
                    761:               else
                    762:                 TtaInsertSibling (child, lastFrame, FALSE, doc);
                    763:               lastFrame = child;
                    764:             }
                    765:           child = next;
                    766:         }
                    767:       break;
1.6       cvs       768:        
1.129     vatton    769:     case HTML_EL_Form:
                    770:       /* Check the mandatory action attribute */
                    771:       CheckMandatoryAttribute (el, doc, HTML_ATTR_Script_URL);
                    772:       break;
                    773: 
                    774:     case HTML_EL_Input:        /* it's an INPUT without any TYPE attribute */
                    775:       /* Create a child of type Text_Input */
                    776:       elType.ElTypeNum = HTML_EL_Text_Input;
                    777:       child = TtaNewTree (doc, elType, "");
                    778:       if (DocumentMeta[doc]->xmlformat)
                    779:         XmlSetElemLineNumber (child);
                    780:       else
                    781:         SetHtmlElemLineNumber (child);
                    782:       TtaInsertFirstChild (&child, el, doc);
                    783:       /* now, process it like a Text_Input element */
                    784: 
                    785:     case HTML_EL_Text_Input:
                    786:     case HTML_EL_Password_Input:
                    787:     case HTML_EL_File_Input:
                    788:       /* set default size */
                    789:       attrType.AttrSSchema = elType.ElSSchema;
                    790:       attrType.AttrTypeNum = HTML_ATTR_IntAreaSize;
                    791:       attr = TtaGetAttribute (el, attrType);
                    792:       if (!attr)
                    793:         CreateAttrIntAreaSize (20, el, doc);
                    794:       /* get element Inserted_Text */
                    795:       child = TtaGetFirstChild (el);
                    796:       if (child != NULL)
                    797:         {
                    798:           attrType.AttrTypeNum = HTML_ATTR_Value_;
                    799:           attr = TtaGetAttribute (el, attrType);
                    800:           if (attr != NULL)
                    801:             {
                    802:               /* copy the value of attribute "value" into the first text
                    803:                  leaf of element */
                    804:               length = TtaGetTextAttributeLength (attr);
                    805:               if (length > 0)
                    806:                 {
                    807:                   /* get the text leaf */
                    808:                   leaf = TtaGetFirstChild (child);
                    809:                   if (leaf != NULL)
                    810:                     {
                    811:                       childType = TtaGetElementType (leaf);
                    812:                       if (childType.ElTypeNum == HTML_EL_TEXT_UNIT)
                    813:                         {
                    814:                           /* copy attribute value into the text leaf */
                    815:                           text = (char *)TtaGetMemory (length + 1);
                    816:                           TtaGiveTextAttributeValue (attr, text, &length);
                    817:                           TtaSetTextContent (leaf, (unsigned char *)text, 
                    818:                                              TtaGetDefaultLanguage (), doc);
                    819:                           TtaFreeMemory (text);
                    820:                         }
                    821:                     }
                    822:                 }
                    823:             }
                    824:         }
                    825:       break;
1.6       cvs       826:        
1.129     vatton    827:     case HTML_EL_META:
                    828:       ParseCharsetAndContentType (el, doc);
                    829:       /* Check the mandatory CONTENT attribute */
                    830:       CheckMandatoryAttribute (el, doc, HTML_ATTR_meta_content);
1.126     tollenae  831: #ifdef TEMPLATES
1.129     vatton    832:       ParseTemplateMeta (el, doc);
1.126     tollenae  833: #endif /* TEMPLATES */
1.129     vatton    834:       break;
                    835: 
                    836:     case HTML_EL_BASE:
                    837:       /* Check the mandatory HREF attribute */
                    838:       CheckMandatoryAttribute (el, doc, HTML_ATTR_HREF_);
                    839:       break;
                    840: 
                    841:     case HTML_EL_BaseFont:
                    842:       /* Check the mandatory size attribute */
                    843:       CheckMandatoryAttribute (el, doc, HTML_ATTR_BaseFontSize);
                    844:       break;
                    845: 
                    846:     case HTML_EL_BDO:
                    847:       /* Check the mandatory DIR attribute */
                    848:       CheckMandatoryAttribute (el, doc, HTML_ATTR_dir);
                    849:       break;
1.114     vatton    850: 
1.129     vatton    851:     case HTML_EL_STYLE_:       /* it's a STYLE element */
                    852:     case HTML_EL_SCRIPT_:      /* it's a SCRIPT element */
                    853:     case HTML_EL_Preformatted: /* it's a PRE */
1.131     quint     854:       if (elType.ElTypeNum == HTML_EL_SCRIPT_)
                    855:         if (DocumentMeta[doc]->xmlformat)
                    856:           SetParsingScript (FALSE);
                    857:         else
                    858:           SetHtmlParsingScript (FALSE);
                    859: 
1.129     vatton    860:       /* if the last line of the Preformatted is empty, remove it */
                    861:       leaf = XmlLastLeafInElement (el);
                    862:       if (leaf != NULL)
                    863:         {
                    864:           elType = TtaGetElementType (leaf);
                    865:           if (elType.ElTypeNum == HTML_EL_TEXT_UNIT)
                    866:             /* the last leaf is a TEXT element */
                    867:             {
                    868:               length = TtaGetTextLength (leaf);
                    869:               if (length > 0)
                    870:                 {
                    871:                   TtaGiveSubString (leaf, (unsigned char *)lastChar, length, 1);
                    872:                   if (lastChar[0] == EOL)
                    873:                     /* last character is new line, delete it */
                    874:                     {
                    875:                       if (length == 1)
                    876:                         /* empty TEXT element */
                    877:                         TtaDeleteTree (leaf, doc);
                    878:                       else
                    879:                         /* remove the last character */
                    880:                         TtaDeleteTextContent (leaf, length, 1, doc);
                    881:                     }
                    882:                 }
                    883:             }
                    884:         }
                    885: 
                    886:       if (elType.ElTypeNum == HTML_EL_STYLE_)
                    887:         /* Check the mandatory TYPE attribute */
                    888:         CheckMandatoryAttribute (el, doc, HTML_ATTR_Notation);
                    889:       else if (elType.ElTypeNum == HTML_EL_SCRIPT_)
                    890:         /* Check the mandatory TYPE attribute */
                    891:         CheckMandatoryAttribute (el, doc, HTML_ATTR_content_type);
                    892: 
                    893:       if (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat)
                    894:         {
                    895:           if (IsXmlParsingCSS ())
                    896:             {
                    897:               text = GetStyleContents (el);
                    898:               if (text)
                    899:                 {
                    900:                   ReadCSSRules (doc, NULL, text, NULL,
                    901:                                 TtaGetElementLineNumber (el), FALSE, el);
                    902:                   TtaFreeMemory (text);
                    903:                 }
                    904:               SetXmlParsingCSS (FALSE);
                    905:             }
                    906:         }
                    907:       else
                    908:         {
                    909:           if (IsHtmlParsingCSS ())
                    910:             {
                    911:               text = GetStyleContents (el);
                    912:               if (text)
                    913:                 {
                    914:                   ReadCSSRules (doc, NULL, text, NULL,
                    915:                                 TtaGetElementLineNumber (el), FALSE, el);
                    916:                   TtaFreeMemory (text);
                    917:                 }
                    918:               SetHtmlParsingCSS (FALSE);
                    919:             }
                    920:         }
                    921:       /* and continue as if it were a Preformatted or a Script */
                    922:       break;
1.6       cvs       923:        
1.129     vatton    924:     case HTML_EL_Text_Area:    /* it's a Text_Area */
                    925:       if (DocumentMeta[doc]->xmlformat)
                    926:         SetParsingTextArea (FALSE);
                    927:       else
                    928:         SetHtmlParsingTextArea (FALSE);
                    929:       child = TtaGetFirstChild (el);
                    930:       if (child == NULL)
                    931:         /* it's an empty Text_Area */
                    932:         /* insert a Inserted_Text element and a child Basic_Elem in the
                    933:            Text_Area element */
                    934:         {
                    935:           newElType.ElTypeNum = HTML_EL_Inserted_Text;
                    936:           child = TtaNewTree (doc, newElType, "");
                    937:           TtaInsertFirstChild (&child, el, doc);
                    938:         }
                    939:       else
                    940:         {
                    941:           /* save the text into Default_Value attribute */
                    942:           attrType.AttrSSchema = htmlSchema;
                    943:           attrType.AttrTypeNum = HTML_ATTR_Default_Value;
                    944:           if (TtaGetAttribute (el, attrType) == NULL)
                    945:             /* attribute Default_Value is missing */
                    946:             {
                    947:               desc = TtaGetFirstChild (child);
                    948:               if (desc)
                    949:                 {
                    950:                   length = TtaGetTextLength (desc);
                    951:                   if (length > 0)
                    952:                     {
                    953:                       length++;
                    954:                       attr = TtaNewAttribute (attrType);
                    955:                       TtaAttachAttribute (el, attr, doc);
                    956:                       text = (char *)TtaGetMemory (length);
                    957:                       TtaGiveTextContent (desc, (unsigned char *)text, &length, &lang);
                    958:                       TtaSetAttributeText (attr, text, el, doc);
                    959:                       TtaFreeMemory (text);
                    960:                     }
                    961:                 }
                    962:             }
                    963:         }
                    964:       /* Check the mandatory rows attribute */
                    965:       CheckMandatoryAttribute (el, doc, HTML_ATTR_Rows);
                    966:       /* Check the mandatory columns attribute */
                    967:       CheckMandatoryAttribute (el, doc, HTML_ATTR_Columns);
                    968:       /* Add default rows and columns attributes */
                    969:       AddRowsColumns (el, doc);
                    970:       break;
                    971: 
                    972:     case HTML_EL_Radio_Input:
                    973:     case HTML_EL_Checkbox_Input:
                    974:       /* put an attribute Checked if it is missing */
                    975:       attrType.AttrSSchema = htmlSchema;
                    976:       attrType.AttrTypeNum = HTML_ATTR_Checked;
                    977:       if (TtaGetAttribute (el, attrType) == NULL)
                    978:         /* attribute Checked is missing */
                    979:         {
                    980:           attr = TtaNewAttribute (attrType);
                    981:           TtaAttachAttribute (el, attr, doc);
                    982:           TtaSetAttributeValue (attr, HTML_ATTR_Checked_VAL_No_, el, doc);
                    983:         }
                    984:       break;
1.6       cvs       985:        
1.129     vatton    986:     case HTML_EL_Option_Menu:
                    987:       /* Check that at least one option has a SELECTED attribute */
                    988:       OnlyOneOptionSelected (el, doc, TRUE);
                    989:       break;
                    990: 
                    991:     case HTML_EL_OptGroup:
                    992:       /* Check the mandatory label attribute */
                    993:       CheckMandatoryAttribute (el, doc, HTML_ATTR_label);
                    994:       break;
                    995: 
                    996:     case HTML_EL_MAP:
                    997:     case HTML_EL_map:
                    998:       /* Check the mandatory attributes */
                    999:       if (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat)
                   1000:         /* it's XHTML. Check attribute id */
                   1001:         CheckMandatoryAttribute (el, doc, HTML_ATTR_ID);
                   1002:       else
                   1003:         /* it's a HTML document. Check attribute name */
                   1004:         CheckMandatoryAttribute (el, doc, HTML_ATTR_NAME);
                   1005:       break;
                   1006: 
                   1007:     case HTML_EL_AREA:
                   1008:       /* Check the mandatory alt attribute */
                   1009:       CheckMandatoryAttribute (el, doc, HTML_ATTR_ALT);
                   1010:       break;
1.6       cvs      1011:        
1.129     vatton   1012:     case HTML_EL_LINK:
                   1013:       CheckCSSLink (el, doc, htmlSchema);
                   1014:       break;
1.6       cvs      1015:        
1.129     vatton   1016:     case HTML_EL_Data_cell:
                   1017:     case HTML_EL_Heading_cell:
                   1018:     case HTML_EL_List_Item:
                   1019:     case HTML_EL_Definition:
                   1020:       /* insert a pseudo paragraph into empty cells or list items */
                   1021:       child = TtaGetFirstChild (el);
                   1022:       if (child == NULL)
                   1023:         {
                   1024:           elType.ElTypeNum = HTML_EL_Pseudo_paragraph;
                   1025:           child = TtaNewTree (doc, elType, "");
                   1026:           if (child != NULL)
                   1027:             TtaInsertFirstChild (&child, el, doc);
                   1028:         }
                   1029:       if (elType.ElTypeNum == HTML_EL_Data_cell ||
                   1030:           elType.ElTypeNum == HTML_EL_Heading_cell)
                   1031:         /* detect whether we are parsing a whole table or just a cell */
                   1032:         {
                   1033:           if (DocumentMeta[doc]->xmlformat)
                   1034:             {
                   1035:               if (IsWithinXmlTable ())
                   1036:                 NewCell (el, doc, FALSE, FALSE, FALSE);
                   1037:             }
                   1038:           else
                   1039:             {
                   1040:               if (IsWithinHtmlTable ())
                   1041:                 NewCell (el, doc, FALSE, FALSE, FALSE);
                   1042:             }
                   1043:         }
                   1044:       break;
1.6       cvs      1045:        
1.129     vatton   1046:     case HTML_EL_Table_:
                   1047:       CheckTable (el, doc);
                   1048:       SubWithinTable ();
                   1049:       break;
1.6       cvs      1050:        
1.129     vatton   1051:     case HTML_EL_TITLE:
                   1052:       /* show the TITLE in the main window */
                   1053:       UpdateTitle (el, doc);
                   1054:       break;
                   1055: 
                   1056:     case HTML_EL_rbc:
                   1057:       /* an rbc element has been read. Its parent should be a complex_ruby.
                   1058:          Change the type of the parent, as simple_ruby are created by
                   1059:          default */
                   1060:       parent = TtaGetParent (el);
                   1061:       if (parent)
                   1062:         {
                   1063:           newElType = TtaGetElementType (parent);
                   1064:           if (newElType.ElSSchema == elType.ElSSchema &&
                   1065:               newElType.ElTypeNum == HTML_EL_simple_ruby)
                   1066:             TtaChangeElementType (parent, HTML_EL_complex_ruby);
                   1067:         }
                   1068:       break;
1.41      cvs      1069: 
1.129     vatton   1070:     case HTML_EL_rtc1:
                   1071:       /* an rtc element has been parsed. If it has already a rtc1 sibling,
                   1072:          change its type to rtc2 */
                   1073:       prev = el;
                   1074:       do
                   1075:         {
                   1076:           TtaPreviousSibling(&prev);
                   1077:           if (prev)
                   1078:             {
                   1079:               newElType = TtaGetElementType (prev);
                   1080:               if (newElType.ElSSchema == elType.ElSSchema &&
                   1081:                   newElType.ElTypeNum == HTML_EL_rtc1)
                   1082:                 {
                   1083:                   TtaChangeElementType (el, HTML_EL_rtc2);
                   1084:                   prev = NULL;
                   1085:                 }
                   1086:             }
                   1087:         }
                   1088:       while (prev);
                   1089:       break;
                   1090: 
                   1091:     case HTML_EL_FIELDSET:
1.124     cvs      1092:        
1.129     vatton   1093:       childType.ElTypeNum = 0;
                   1094:       child = TtaGetFirstChild (el);
                   1095:       if (child != NULL)
                   1096:         childType = TtaGetElementType (child);
                   1097:       if (childType.ElTypeNum != HTML_EL_LEGEND)
                   1098:         {
                   1099:           sprintf (msgBuffer, "The <fieldset> element requires <legend> as first child element");
                   1100:           lineNum = TtaGetElementLineNumber(el);
                   1101:           if (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat)
                   1102:             XmlParseError (errorParsing, (unsigned char *)msgBuffer, lineNum);
                   1103:           else
                   1104:             HTMLParseError (doc, msgBuffer, lineNum);
                   1105: 
                   1106:         }
                   1107:       break;
                   1108: 
                   1109:     default:
                   1110:       break;
                   1111:     }
1.6       cvs      1112: }
1.1       cvs      1113: 
                   1114: /*----------------------------------------------------------------------
1.129     vatton   1115:   PutInContent    
                   1116:   Put the string ChrString in the leaf of current element.
1.30      cvs      1117:   ----------------------------------------------------------------------*/
1.39      cvs      1118: Element         PutInContent (char *ChrString, ParserData *context)
1.30      cvs      1119: 
                   1120: {
1.129     vatton   1121:   Element      el, child;
                   1122:   ElementType  elType;
                   1123:   int          length;
                   1124: 
                   1125:   el = NULL;
                   1126:   if (context->lastElement != NULL)
                   1127:     {
                   1128:       /* search first leaf of current element */
                   1129:       el = context->lastElement;
                   1130:       do
                   1131:         {
                   1132:           child = TtaGetFirstChild (el);
                   1133:           if (child != NULL)
                   1134:             el = child;
                   1135:         }
                   1136:       while (child != NULL);
                   1137:       elType = TtaGetElementType (el);
                   1138:       length = 0;
                   1139:       if (elType.ElTypeNum == 1)
                   1140:         length = TtaGetTextLength (el);
                   1141:       if (length == 0)
                   1142:         TtaSetTextContent (el, (unsigned char *)ChrString,
                   1143:                            context->language, context->doc);
                   1144:       else
                   1145:         TtaAppendTextContent (el, (unsigned char *)ChrString, context->doc);
                   1146:     }
                   1147:   return el;
1.30      cvs      1148: }
                   1149: 
                   1150: /*----------------------------------------------------------------------
1.93      vatton   1151:   UnknownXhtmlNameSpace
                   1152:   The element doesn't belong to a supported namespace
1.51      cvs      1153:   ----------------------------------------------------------------------*/
1.93      vatton   1154: void UnknownXhtmlNameSpace (ParserData *context, Element *unknownEl,
1.129     vatton   1155:                             char* content)
1.51      cvs      1156: {
1.129     vatton   1157:   ElementType     elType;
                   1158:   Element         elText;
1.51      cvs      1159: 
1.129     vatton   1160:   /* Create a new Invalid_element */
                   1161:   elType.ElSSchema = GetXMLSSchema (XHTML_TYPE, context->doc);
                   1162:   elType.ElTypeNum = HTML_EL_XHTML_Unknown_namespace;
                   1163:   *unknownEl = TtaNewElement (context->doc, elType);
                   1164:   if (*unknownEl != NULL)
                   1165:     {
                   1166:       XmlSetElemLineNumber (*unknownEl);
                   1167:       InsertXmlElement (unknownEl);
                   1168:       context->lastElementClosed = TRUE;
                   1169:       elType.ElTypeNum = HTML_EL_TEXT_UNIT;
                   1170:       elText = TtaNewElement (context->doc, elType);
                   1171:       XmlSetElemLineNumber (elText);
                   1172:       TtaInsertFirstChild (&elText, *unknownEl, context->doc);
                   1173:       TtaSetTextContent (elText, (unsigned char *)content, context->language, context->doc);
                   1174:       TtaSetAccessRight (elText, ReadOnly, context->doc);
                   1175:     }
1.51      cvs      1176: }
                   1177: 
                   1178: /*----------------------------------------------------------------------
1.129     vatton   1179:   CreateHTMLAttribute
                   1180:   create an attribute of type attrType for the element el.
1.30      cvs      1181:   ----------------------------------------------------------------------*/
1.93      vatton   1182: void CreateHTMLAttribute (Element       el,
1.129     vatton   1183:                           AttributeType attrType,
                   1184:                           char*         text,
                   1185:                           ThotBool      isInvalid,
                   1186:                           Document      doc,
                   1187:                           Attribute    *lastAttribute,
                   1188:                           Element      *lastAttrElement)
1.30      cvs      1189: {
1.129     vatton   1190:   int         attrKind;
                   1191:   int         length;
                   1192:   char       *buffer;
                   1193:   Attribute   attr, oldAttr;
                   1194: 
                   1195:   if (attrType.AttrTypeNum != 0)
                   1196:     {
                   1197:       oldAttr = TtaGetAttribute (el, attrType);
                   1198:       if (oldAttr != NULL)
                   1199:         /* this attribute already exists */
                   1200:         attr = oldAttr;
                   1201:       else
                   1202:         /* create a new attribute and attach it to the element */
                   1203:         {
                   1204:           attr = TtaNewAttribute (attrType);
                   1205:           TtaAttachAttribute (el, attr, doc);
                   1206:         }
                   1207:       *lastAttribute = attr;
                   1208:       *lastAttrElement = el;
                   1209: 
                   1210:       TtaGiveAttributeType (attr, &attrType, &attrKind);
                   1211:       if (attrKind == 0)       /* enumerate */
                   1212:         TtaSetAttributeValue (attr, 1, el, doc);
                   1213: 
                   1214:       /* attribute BORDER without any value (ThotBool attribute) is */
                   1215:       /* considered as BORDER=1 */
                   1216:       if (attrType.AttrTypeNum == HTML_ATTR_Border)
                   1217:         TtaSetAttributeValue (attr, 1, el, doc);
                   1218: 
                   1219:       if (isInvalid)
                   1220:         /* Copy the name of the invalid attribute as the content */
                   1221:         /* of the Invalid_attribute attribute. */
                   1222:         {
                   1223:           length = strlen (text) + 2;
                   1224:           length += TtaGetTextAttributeLength (attr);
                   1225:           buffer = (char *)TtaGetMemory (length + 1);
                   1226:           TtaGiveTextAttributeValue (attr, buffer, &length);
                   1227:           strcat (buffer, " ");
                   1228:           strcat (buffer, text);
                   1229:           TtaSetAttributeText (attr, buffer, el, doc);
                   1230:           TtaFreeMemory (buffer);
                   1231:         }
                   1232:     }
1.30      cvs      1233: }
                   1234: 
                   1235: /*----------------------------------------------------------------------
1.129     vatton   1236:   HTMLTypeAttrValue
                   1237:   Value val has been read for the HTML attribute TYPE.
                   1238:   Create a child for the current Thot element INPUT accordingly.
1.30      cvs      1239:   ----------------------------------------------------------------------*/
1.109     vatton   1240: void HTMLTypeAttrValue (char *val, Attribute lastAttribute,
1.129     vatton   1241:                         Element lastAttrElement, ParserData *context)
1.30      cvs      1242: {
                   1243:   ElementType      elType;
                   1244:   Element          newChild;
                   1245:   AttributeType    attrType;
                   1246:   Attribute        attr;
1.39      cvs      1247:   char             msgBuffer[MaxMsgLength];
1.30      cvs      1248:   int              value;
                   1249:   int              numberOfLinesRead;
                   1250: 
                   1251:   value = MapAttrValue (DummyAttribute, val);
1.109     vatton   1252:   elType = TtaGetElementType (context->lastElement);
1.91      quint    1253:   if (value <= 0)
1.30      cvs      1254:     {
1.37      cvs      1255:       if (strlen (val) > MaxMsgLength - 40)
1.129     vatton   1256:         val[MaxMsgLength - 40] = EOS;
1.37      cvs      1257:       sprintf (msgBuffer, "Unknown attribute value \"type = %s\"", val);
1.117     quint    1258:       HTMLParseError (context->doc, msgBuffer, 0);
1.109     vatton   1259:       attrType.AttrSSchema = elType.ElSSchema;
1.30      cvs      1260:       attrType.AttrTypeNum = pHTMLAttributeMapping[0].ThotAttribute;
1.37      cvs      1261:       sprintf (msgBuffer, "type=%s", val);
1.30      cvs      1262:       CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,
1.129     vatton   1263:                            context->doc, &lastAttribute, &lastAttrElement);
1.30      cvs      1264:     }
                   1265:   else
                   1266:     {
                   1267:       if (elType.ElTypeNum != HTML_EL_Input)
1.129     vatton   1268:         {
                   1269:           if (strlen (val) > MaxMsgLength - 40)
                   1270:             val[MaxMsgLength - 40] = EOS;
                   1271:           sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val);
                   1272:         }
1.30      cvs      1273:       else
1.129     vatton   1274:         {
                   1275:           elType.ElTypeNum = value;
                   1276:           newChild = TtaNewTree (context->doc, elType, "");
                   1277:           numberOfLinesRead = 0;
                   1278:           TtaSetElementLineNumber (newChild, numberOfLinesRead);
                   1279:           TtaInsertFirstChild (&newChild, context->lastElement, context->doc);
                   1280:           if (value == HTML_EL_PICTURE_UNIT)
                   1281:             {
                   1282:               /* add the attribute IsInput to input pictures */
                   1283:               attrType.AttrSSchema = elType.ElSSchema;
                   1284:               attrType.AttrTypeNum = HTML_ATTR_IsInput;
                   1285:               attr = TtaNewAttribute (attrType);
                   1286:               TtaAttachAttribute (newChild, attr, context->doc);
                   1287:             }
                   1288:         }
1.30      cvs      1289:     }
                   1290: }
                   1291: 
                   1292: /*----------------------------------------------------------------------
1.129     vatton   1293:   XhtmlTypeAttrValue 
                   1294:   Value val has been read for the HTML attribute TYPE.
                   1295:   Create a child for the current Thot element INPUT accordingly.
1.30      cvs      1296:   ----------------------------------------------------------------------*/
1.111     vatton   1297: void XhtmlTypeAttrValue (char       *val,
1.129     vatton   1298:                          Attribute   currentAttribute,
                   1299:                          Element     lastAttrElement,
                   1300:                          ParserData *context)
1.30      cvs      1301: {
                   1302:   ElementType     elType;
                   1303:   Element         newChild;
                   1304:   AttributeType   attrType;
                   1305:   Attribute       attr;
1.39      cvs      1306:   char            msgBuffer[MaxMsgLength];
1.30      cvs      1307:   int             value;
                   1308:   ThotBool        level;
                   1309: 
1.91      quint    1310:   /* Look in the dummy section of the attribute value table */
1.30      cvs      1311:   attrType.AttrTypeNum = DummyAttribute;
1.100     gully    1312:   MapHTMLAttributeValue (val, &attrType, &value);
1.91      quint    1313:   if (value <= 0)
                   1314:     /* invalid value for the type attribute of an input element */
1.30      cvs      1315:     {
1.37      cvs      1316:       sprintf (msgBuffer, "Unknown attribute value \"type=%s\"", val);
1.100     gully    1317:       XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
1.36      cvs      1318:       MapHTMLAttribute ("unknown_attr", &attrType, NULL,
1.129     vatton   1319:                         &level, context->doc);
1.37      cvs      1320:       sprintf (msgBuffer, "type=%s", val);
1.30      cvs      1321:       CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,
1.129     vatton   1322:                            context->doc, &currentAttribute, &lastAttrElement);
1.30      cvs      1323:     }
                   1324:   else
1.91      quint    1325:     /* value is the Thot type of the element to be created for this value of
                   1326:        the TYPE attribute */
1.30      cvs      1327:     {
                   1328:       elType = TtaGetElementType (context->lastElement);
                   1329:       if (elType.ElTypeNum != HTML_EL_Input)
1.129     vatton   1330:         {
                   1331:           sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val);
                   1332:           XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
                   1333:         }
1.30      cvs      1334:       else
1.129     vatton   1335:         {
                   1336:           elType.ElTypeNum = value;
                   1337:           newChild = TtaNewTree (context->doc, elType, "");
                   1338:           XmlSetElemLineNumber (newChild);
                   1339:           TtaInsertFirstChild (&newChild, context->lastElement, context->doc);
                   1340:           if (value == HTML_EL_PICTURE_UNIT)
                   1341:             {
                   1342:               /* add the attribute IsInput to input pictures */
                   1343:               attrType.AttrSSchema = elType.ElSSchema;
                   1344:               attrType.AttrTypeNum = HTML_ATTR_IsInput;
                   1345:               attr = TtaNewAttribute (attrType);
                   1346:               TtaAttachAttribute (newChild, attr, context->doc);
                   1347:             }
                   1348:         }
1.30      cvs      1349:     }
                   1350: }
                   1351: 
                   1352: /*----------------------------------------------------------------------
1.129     vatton   1353:   CreateAttrWidthPercentPxl
                   1354:   an HTML attribute "width" has been created for a Table, an image,
                   1355:   an Object of a HR.
                   1356:   Create the corresponding attribute IntWidthPercent or IntWidthPxl.
                   1357:   oldWidth is -1 or the old image width.
1.30      cvs      1358:   ----------------------------------------------------------------------*/
1.58      vatton   1359: void CreateAttrWidthPercentPxl (char *buffer, Element el,
1.129     vatton   1360:                                 Document doc, int oldWidth)
1.30      cvs      1361: {
                   1362:   AttributeType   attrTypePxl, attrTypePercent;
                   1363:   Attribute       attrOld, attrNew;
                   1364:   int             length, val;
1.39      cvs      1365:   char            msgBuffer[MaxMsgLength];
1.133     vatton   1366:   ElementType      elType, childType;
1.79      quint    1367:   Element         origEl, child;
1.30      cvs      1368:   int             w, h;
1.133     vatton   1369:   ThotBool        isImage, isSVG = FALSE;
1.30      cvs      1370: 
1.132     vatton   1371:   if (buffer == NULL || buffer[0] == EOS)
                   1372:     return;
1.79      quint    1373:   origEl = el;
1.30      cvs      1374:   elType = TtaGetElementType (el);
                   1375:   isImage = (elType.ElTypeNum == HTML_EL_PICTURE_UNIT ||
1.129     vatton   1376:              elType.ElTypeNum == HTML_EL_Data_cell ||
                   1377:              elType.ElTypeNum == HTML_EL_Heading_cell ||
1.134   ! vatton   1378:              elType.ElTypeNum == HTML_EL_Object ||
        !          1379:              elType.ElTypeNum == HTML_EL_IMG);
1.133     vatton   1380: 
1.79      quint    1381:   if (elType.ElTypeNum == HTML_EL_Object)
                   1382:     /* the width attribute is attached to an Object element */
                   1383:     {
                   1384:       child = TtaGetFirstChild (el);
                   1385:       if (child)
1.129     vatton   1386:         {
                   1387:           childType = TtaGetElementType (child);
                   1388:           if (childType.ElTypeNum == HTML_EL_PICTURE_UNIT)
                   1389:             /* the Object element is of type image. apply the width
                   1390:                attribute to the actual image element */
                   1391:             el = child;
1.133     vatton   1392: #ifdef _SVG
                   1393:           else
                   1394:             {
                   1395:               el = child;
                   1396:               child = TtaGetFirstChild (el);
                   1397:               if (child)
                   1398:                 {
                   1399:                   childType = TtaGetElementType (child);
                   1400:                   isSVG = (!strcmp (TtaGetSSchemaName (childType.ElSSchema), "SVG") &&
                   1401:                       childType.ElTypeNum == SVG_EL_SVG);
                   1402:                 }
                   1403:             }
                   1404: #endif /* _SVG */
1.129     vatton   1405:         }
1.79      quint    1406:     }
1.133     vatton   1407: 
1.30      cvs      1408:   /* remove trailing spaces */
1.37      cvs      1409:   length = strlen (buffer) - 1;
1.30      cvs      1410:   while (length > 0 && buffer[length] <= SPACE)
                   1411:     length--;
1.109     vatton   1412:   attrTypePxl.AttrSSchema = elType.ElSSchema;
                   1413:   attrTypePercent.AttrSSchema = elType.ElSSchema;
1.30      cvs      1414:   attrTypePxl.AttrTypeNum = HTML_ATTR_IntWidthPxl;
                   1415:   attrTypePercent.AttrTypeNum = HTML_ATTR_IntWidthPercent;
                   1416:   /* is the last character a '%' ? */
                   1417:   if (buffer[length] == '%')
                   1418:     {
                   1419:       /* remove IntWidthPxl */
                   1420:       attrOld = TtaGetAttribute (el, attrTypePxl);
                   1421:       /* update IntWidthPercent */
                   1422:       attrNew = TtaGetAttribute (el, attrTypePercent);
                   1423:       if (attrNew == NULL)
1.129     vatton   1424:         {
                   1425:           attrNew = TtaNewAttribute (attrTypePercent);
                   1426:           TtaAttachAttribute (el, attrNew, doc);
                   1427:         }
1.30      cvs      1428:       else if (isImage && oldWidth == -1)
1.129     vatton   1429:         {
                   1430:           if (attrOld == NULL)
                   1431:             oldWidth = TtaGetAttributeValue (attrNew);
                   1432:           else
                   1433:             oldWidth = TtaGetAttributeValue (attrOld);
                   1434:         }
1.30      cvs      1435:     }
                   1436:   else
                   1437:     {
                   1438:       /* remove IntWidthPercent */
                   1439:       attrOld = TtaGetAttribute (el, attrTypePercent);
                   1440:       /* update IntWidthPxl */
                   1441:       attrNew = TtaGetAttribute (el, attrTypePxl);
                   1442:       if (attrNew == NULL)
1.129     vatton   1443:         {
                   1444:           attrNew = TtaNewAttribute (attrTypePxl);
                   1445:           TtaAttachAttribute (el, attrNew, doc);
                   1446:         }
1.30      cvs      1447:       else if (isImage && oldWidth == -1)
1.129     vatton   1448:         {
                   1449:           TtaGiveBoxSize (el, doc, 1, UnPixel, &w, &h);
                   1450:           if (attrOld == NULL)
                   1451:             oldWidth = w * TtaGetAttributeValue (attrNew) / 100;
                   1452:           else
                   1453:             oldWidth = w * TtaGetAttributeValue (attrOld) / 100;         
                   1454:         }
1.30      cvs      1455:     }
                   1456: 
                   1457:   if (attrOld != NULL)
                   1458:     TtaRemoveAttribute (el, attrOld, doc);
1.43      cvs      1459:   if (sscanf (buffer, "%d", &val))
1.30      cvs      1460:     TtaSetAttributeValue (attrNew, val, el, doc);
                   1461:   else
                   1462:     /* its not a number. Delete attribute and send an error message */
                   1463:     {
1.129     vatton   1464:       TtaRemoveAttribute (el, attrNew, doc);
                   1465:       if (strlen (buffer) > MaxMsgLength - 30)
1.30      cvs      1466:         buffer[MaxMsgLength - 30] = EOS;
1.129     vatton   1467:       sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
                   1468:       HTMLParseError (doc, msgBuffer, 0);
1.30      cvs      1469:     }
                   1470:   if (isImage)
1.79      quint    1471:     UpdateImageMap (origEl, doc, oldWidth, -1);
1.133     vatton   1472:   else if (isSVG && oldWidth != -1)
                   1473:     {
                   1474:       // force the redisplay of the SVG element
                   1475:       el = TtaGetParent (child);
                   1476:       if (el)
                   1477:         {
                   1478:           TtaRemoveTree (child, doc);
                   1479:           TtaInsertFirstChild (&child, el, doc);
                   1480:         }
                   1481:     }
1.30      cvs      1482: }
                   1483: 
                   1484: /*----------------------------------------------------------------------
1.129     vatton   1485:   CreateAttrHeightPercentPxl
                   1486:   an HTML attribute "width" has been created for a Table, an image,
                   1487:   an Object or a HR.
                   1488:   Create the corresponding attribute IntHeightPercent or IntHeightPxl.
                   1489:   oldHeight is -1 or the old image width.
1.58      vatton   1490:   ----------------------------------------------------------------------*/
                   1491: void CreateAttrHeightPercentPxl (char *buffer, Element el,
1.129     vatton   1492:                                  Document doc, int oldHeight)
1.58      vatton   1493: {
                   1494:   AttributeType   attrTypePxl, attrTypePercent;
                   1495:   Attribute       attrOld, attrNew;
                   1496:   int             length, val;
                   1497:   char            msgBuffer[MaxMsgLength];
1.133     vatton   1498:   ElementType      elType, childType;
1.79      quint    1499:   Element         origEl, child;
1.58      vatton   1500:   int             w, h;
1.133     vatton   1501:   ThotBool        isImage, isSVG = FALSE;
1.58      vatton   1502: 
1.79      quint    1503:   origEl = el;
1.58      vatton   1504:   elType = TtaGetElementType (el);
                   1505:   isImage = (elType.ElTypeNum == HTML_EL_PICTURE_UNIT ||
1.129     vatton   1506:              elType.ElTypeNum == HTML_EL_Data_cell ||
                   1507:              elType.ElTypeNum == HTML_EL_Heading_cell ||
1.134   ! vatton   1508:              elType.ElTypeNum == HTML_EL_Object ||
        !          1509:              elType.ElTypeNum == HTML_EL_IMG);
1.133     vatton   1510: 
1.79      quint    1511:   if (elType.ElTypeNum == HTML_EL_Object)
                   1512:     /* the height attribute is attached to an Object element */
                   1513:     {
                   1514:       child = TtaGetFirstChild (el);
1.81      cvs      1515:       if (!child)
1.129     vatton   1516:         return;
1.81      cvs      1517:       else
1.129     vatton   1518:         {
                   1519:           childType = TtaGetElementType (child);
                   1520:           if (childType.ElTypeNum == HTML_EL_PICTURE_UNIT)
                   1521:             /* the Object element is of type image. apply the width
                   1522:                attribute to the actual image element */
                   1523:             el = child;
1.133     vatton   1524: #ifdef _SVG
1.129     vatton   1525:           else
1.133     vatton   1526:             {
                   1527:               el = child;
                   1528:               child = TtaGetFirstChild (el);
                   1529:               if (child)
                   1530:                 {
                   1531:                   childType = TtaGetElementType (child);
                   1532:                   isSVG = (!strcmp (TtaGetSSchemaName (childType.ElSSchema), "SVG") &&
                   1533:                       childType.ElTypeNum == SVG_EL_SVG);
                   1534:                 }
                   1535:             }
                   1536: #endif /* _SVG */
1.129     vatton   1537:         }
1.79      quint    1538:     }
1.133     vatton   1539: 
1.58      vatton   1540:   /* remove trailing spaces */
                   1541:   length = strlen (buffer) - 1;
                   1542:   while (length > 0 && buffer[length] <= SPACE)
                   1543:     length--;
1.109     vatton   1544:   attrTypePxl.AttrSSchema = elType.ElSSchema;
                   1545:   attrTypePercent.AttrSSchema = elType.ElSSchema;
1.58      vatton   1546:   attrTypePxl.AttrTypeNum = HTML_ATTR_IntHeightPxl;
                   1547:   attrTypePercent.AttrTypeNum = HTML_ATTR_IntHeightPercent;
                   1548:   /* is the last character a '%' ? */
                   1549:   if (buffer[length] == '%')
                   1550:     {
                   1551:       /* remove IntHeightPxl */
                   1552:       attrOld = TtaGetAttribute (el, attrTypePxl);
                   1553:       /* update IntHeightPercent */
                   1554:       attrNew = TtaGetAttribute (el, attrTypePercent);
                   1555:       if (attrNew == NULL)
1.129     vatton   1556:         {
                   1557:           attrNew = TtaNewAttribute (attrTypePercent);
                   1558:           TtaAttachAttribute (el, attrNew, doc);
                   1559:         }
1.58      vatton   1560:       else if (isImage && oldHeight == -1)
1.129     vatton   1561:         {
                   1562:           if (attrOld == NULL)
                   1563:             oldHeight = TtaGetAttributeValue (attrNew);
                   1564:           else
                   1565:             oldHeight = TtaGetAttributeValue (attrOld);
                   1566:         }
1.58      vatton   1567:     }
                   1568:   else
                   1569:     {
                   1570:       /* remove IntHeightPercent */
                   1571:       attrOld = TtaGetAttribute (el, attrTypePercent);
                   1572:       /* update IntHeightPxl */
                   1573:       attrNew = TtaGetAttribute (el, attrTypePxl);
                   1574:       if (attrNew == NULL)
1.129     vatton   1575:         {
                   1576:           attrNew = TtaNewAttribute (attrTypePxl);
                   1577:           TtaAttachAttribute (el, attrNew, doc);
                   1578:         }
1.58      vatton   1579:       else if (isImage && oldHeight == -1)
1.129     vatton   1580:         {
                   1581:           TtaGiveBoxSize (el, doc, 1, UnPixel, &w, &h);
                   1582:           if (attrOld == NULL)
                   1583:             oldHeight = w * TtaGetAttributeValue (attrNew) / 100;
                   1584:           else
                   1585:             oldHeight = w * TtaGetAttributeValue (attrOld) / 100;        
                   1586:         }
1.58      vatton   1587:     }
                   1588: 
                   1589:   if (attrOld != NULL)
                   1590:     TtaRemoveAttribute (el, attrOld, doc);
                   1591:   if (sscanf (buffer, "%d", &val))
                   1592:     TtaSetAttributeValue (attrNew, val, el, doc);
                   1593:   else
                   1594:     /* its not a number. Delete attribute and send an error message */
                   1595:     {
1.129     vatton   1596:       TtaRemoveAttribute (el, attrNew, doc);
                   1597:       if (strlen (buffer) > MaxMsgLength - 30)
1.58      vatton   1598:         buffer[MaxMsgLength - 30] = EOS;
1.129     vatton   1599:       sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
                   1600:       HTMLParseError (doc, msgBuffer, 0);
1.58      vatton   1601:     }
                   1602:   if (isImage)
1.79      quint    1603:     UpdateImageMap (origEl, doc, oldHeight, -1);
1.133     vatton   1604:   else if (isSVG && oldHeight != -1)
                   1605:     {
                   1606:       // force the redisplay of the SVG element
                   1607:       el = TtaGetParent (child);
                   1608:       if (el)
                   1609:         {
                   1610:           TtaRemoveTree (child, doc);
                   1611:           TtaInsertFirstChild (&child, el, doc);
                   1612:         }
                   1613:     }
1.58      vatton   1614: }
                   1615: 
                   1616: /*----------------------------------------------------------------------
1.129     vatton   1617:   CreateAttrIntAreaSize
                   1618:   an HTML attribute "size" has been created or modified for a input element.
                   1619:   Create or update the corresponding attribute IntAreaSize.
1.91      quint    1620:   ----------------------------------------------------------------------*/
                   1621: void CreateAttrIntAreaSize (int value, Element el, Document doc)
                   1622: {
                   1623:   AttributeType   attrType;
                   1624:   Attribute       attr;
                   1625:   ElementType    elType;
                   1626: 
                   1627:   elType = TtaGetElementType (el);
                   1628:   attrType.AttrSSchema = elType.ElSSchema;
                   1629:   attrType.AttrTypeNum = HTML_ATTR_IntAreaSize;
                   1630:   attr = TtaGetAttribute (el, attrType);
                   1631:   if (!attr)
                   1632:     {
                   1633:       attr = TtaNewAttribute (attrType);
                   1634:       TtaAttachAttribute (el, attr, doc);
                   1635:     }
                   1636:   /* the presentation rule associated with attribute IntAreaSize expresses
                   1637:      the element width in "em". Convert the value into em */
1.122     vatton   1638:   TtaSetAttributeValue (attr, (int) (value * 0.40), el, doc);
1.91      quint    1639: }
                   1640: 
                   1641: /*----------------------------------------------------------------------
1.129     vatton   1642:   CreateAttrIntSize
                   1643:   an HTML attribute "size" has been created for a Font element.
                   1644:   Create the corresponding internal attribute.
1.30      cvs      1645:   ----------------------------------------------------------------------*/
1.109     vatton   1646: void CreateAttrIntSize (char *buffer, Element el, Document doc)
1.30      cvs      1647: 
                   1648: {
1.129     vatton   1649:   ElementType    elType;
                   1650:   AttributeType  attrType;
                   1651:   int            val, ind, factor, delta;
                   1652:   Attribute      attr;
                   1653:   char         msgBuffer[MaxMsgLength];
                   1654: 
                   1655:   /* is the first character a '+' or a '-' ? */
                   1656:   elType = TtaGetElementType (el);
                   1657:   ind = 0;
                   1658:   factor = 1;
                   1659:   delta = 0;
                   1660:   if (buffer[0] == '+')
                   1661:     {
                   1662:       attrType.AttrTypeNum = HTML_ATTR_IntSizeIncr;
                   1663:       ind++;
                   1664:       factor = 1;
                   1665:     }
                   1666:   else if (buffer[0] == '-')
                   1667:     {
                   1668:       attrType.AttrTypeNum = HTML_ATTR_IntSizeDecr;
                   1669:       ind++;
                   1670:       factor = 1;
                   1671:     }
                   1672:   else
                   1673:     {
                   1674:       attrType.AttrTypeNum = HTML_ATTR_IntSizeRel;
                   1675:       delta = 1;
                   1676:     }
                   1677:   attrType.AttrSSchema = elType.ElSSchema;
                   1678:   attr = TtaGetAttribute (el, attrType);
                   1679:   if (sscanf (&buffer[ind], "%d", &val))
                   1680:     {
                   1681:       val = val * factor + delta;
                   1682:       if (attr == NULL)
                   1683:         {
                   1684:           /* this attribute doesn't exist, create it */
                   1685:           attr = TtaNewAttribute (attrType);
                   1686:           TtaAttachAttribute (el, attr, doc);
                   1687:         }
                   1688:       TtaSetAttributeValue (attr, val, el, doc);
                   1689:     }
                   1690:   else
                   1691:     /* its not a number. Delete attribute and send an error message */
                   1692:     {
                   1693:       if (attr)
                   1694:         TtaRemoveAttribute (el, attr, doc);
                   1695:       if (strlen (buffer) > MaxMsgLength - 30)
                   1696:         buffer[MaxMsgLength - 30] = EOS;
                   1697:       sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
                   1698:       HTMLParseError (doc, msgBuffer, 0);
                   1699:     }
1.30      cvs      1700: }
                   1701: /*----------------------------------------------------------------------
1.129     vatton   1702:   EndOfHTMLAttributeValue
                   1703:   Filling of an HTML attribute value
1.30      cvs      1704:   ----------------------------------------------------------------------*/
1.109     vatton   1705: void EndOfHTMLAttributeValue (char *attrValue, AttributeMapping *lastMappedAttr,
1.129     vatton   1706:                               Attribute currentAttribute, Element lastAttrElement,
                   1707:                               ThotBool UnknownAttr, ParserData *context,
                   1708:                               ThotBool isXML)
1.30      cvs      1709: {
1.48      vatton   1710:   AttributeType   attrType, attrType1;
                   1711:   Attribute       attr;
1.79      quint    1712:   ElementType    elType;
1.48      vatton   1713:   Element         child, root;
                   1714:   Language        lang;
                   1715:   char            translation;
                   1716:   char            shape;
                   1717:   char           *buffer;
                   1718:   char           *attrName;
                   1719:   char            msgBuffer[MaxMsgLength];
                   1720:   int             val;
                   1721:   int             length;
                   1722:   int             attrKind;
                   1723:   ThotBool        done = FALSE;
1.88      vatton   1724:   ThotBool            loadcss;
1.30      cvs      1725: 
1.48      vatton   1726:   /* treatments of some particular HTML attributes */
                   1727:   if (!strcmp (lastMappedAttr->XMLattribute, "style"))
                   1728:     {
                   1729:       TtaSetAttributeText (currentAttribute, attrValue,
1.129     vatton   1730:                            lastAttrElement, context->doc);
1.88      vatton   1731:       /* check if we have to load CSS */
                   1732:       TtaGetEnvBoolean ("LOAD_CSS", &loadcss);
                   1733:       if (loadcss)
1.129     vatton   1734:         ParseHTMLSpecificStyle (context->lastElement, attrValue,
                   1735:                                 context->doc, 200, FALSE);
1.48      vatton   1736:       done = TRUE;
                   1737:     }
                   1738:   else
                   1739:     {
                   1740:       if (!strcmp (lastMappedAttr->XMLattribute, "link"))
1.129     vatton   1741:         HTMLSetAlinkColor (context->doc, context->lastElement, attrValue);
1.48      vatton   1742:       else if (!strcmp (lastMappedAttr->XMLattribute, "alink"))
1.129     vatton   1743:         HTMLSetAactiveColor (context->doc, context->lastElement, attrValue);
1.48      vatton   1744:       else if (!strcmp (lastMappedAttr->XMLattribute, "vlink"))
1.129     vatton   1745:         HTMLSetAvisitedColor (context->doc, context->lastElement, attrValue);
1.48      vatton   1746:     }
1.30      cvs      1747: 
1.48      vatton   1748:   if (!done)
                   1749:     {
1.109     vatton   1750:       elType = TtaGetElementType (lastAttrElement);
1.48      vatton   1751:       val = 0;
                   1752:       translation = lastMappedAttr->AttrOrContent;
                   1753:       switch (translation)
1.129     vatton   1754:         {
                   1755:         case 'C':      /* Content */
                   1756:           child = PutInContent (attrValue, context);
                   1757:           if (child != NULL)
                   1758:             TtaAppendTextContent (child, (unsigned char *)"\" ", context->doc);
                   1759:           break;
                   1760:         case 'A':
                   1761:           if (currentAttribute != NULL)
                   1762:             {
                   1763:               TtaGiveAttributeType (currentAttribute, &attrType, &attrKind);
                   1764:               switch (attrKind)
                   1765:                 {
                   1766:                 case 0:        /* enumerate */
                   1767:                   if (isXML)
                   1768:                     MapHTMLAttributeValue (attrValue, &attrType, &val);
                   1769:                   else
                   1770:                     val = MapAttrValue (lastMappedAttr->ThotAttribute,
                   1771:                                         attrValue);
                   1772:                   if (val < 0)
                   1773:                     {
                   1774:                       TtaGiveAttributeType (currentAttribute,
                   1775:                                             &attrType, &attrKind);
                   1776:                       attrName = TtaGetAttributeName (attrType);
                   1777:                       sprintf (msgBuffer,
                   1778:                                "Invalid attribute value \"%s = %s\"",
                   1779:                                attrName, attrValue);
                   1780:                       if (isXML)
                   1781:                         XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
                   1782:                       else
                   1783:                         /* we are parsing an HTML file, not an XHTML file */
                   1784:                         {
                   1785:                           /* generate an error message in the log */
                   1786:                           HTMLParseError (context->doc, msgBuffer, 0);
                   1787:                           /* special case for value POLYGON of attribute 
                   1788:                              shape (AREA element) */
                   1789:                           if (attrType.AttrTypeNum == HTML_ATTR_shape &&
                   1790:                               strcasecmp (attrValue, "POLYGON") == 0)
                   1791:                             {
                   1792:                               val = HTML_ATTR_shape_VAL_polygon;
                   1793:                               /* interpret it as if it were "poly" */
                   1794:                               TtaSetAttributeValue (currentAttribute, val,
                   1795:                                                     lastAttrElement, context->doc);
                   1796:                             }
                   1797:                           else
                   1798:                             /* remove the attribute and replace it by an */
                   1799:                             /* Invalid_attribute (not for XHTML) */
                   1800:                             {
                   1801:                               TtaRemoveAttribute (lastAttrElement,
                   1802:                                                   currentAttribute, context->doc);
                   1803:                               attrType.AttrSSchema = elType.ElSSchema;
                   1804:                               attrType.AttrTypeNum =
                   1805:                                 pHTMLAttributeMapping[0].ThotAttribute;
                   1806:                               sprintf (msgBuffer, "%s=%s", attrName,attrValue);
                   1807:                               CreateHTMLAttribute (lastAttrElement, attrType,
                   1808:                                                    msgBuffer, TRUE, context->doc,
                   1809:                                                    &currentAttribute, &lastAttrElement);
                   1810:                             }
                   1811:                         }
                   1812:                     }
                   1813:                   else
                   1814:                     TtaSetAttributeValue (currentAttribute, val,
                   1815:                                           lastAttrElement, context->doc);
                   1816:                   break;
                   1817:                 case 1:        /* integer */
                   1818:                   if (attrType.AttrTypeNum == HTML_ATTR_Border &&
                   1819:                       !strcasecmp (attrValue, "border"))
                   1820:                     {
                   1821:                       /* border="border" for a table */
                   1822:                       val = 1;
                   1823:                       TtaSetAttributeValue (currentAttribute, val,
                   1824:                                             lastAttrElement, context->doc);
                   1825:                     }
                   1826:                   else if (sscanf (attrValue, "%d", &val))
                   1827:                     TtaSetAttributeValue (currentAttribute, val,
                   1828:                                           lastAttrElement, context->doc);
                   1829:                   else
                   1830:                     {
                   1831:                       TtaRemoveAttribute (lastAttrElement, currentAttribute,
                   1832:                                           context->doc);
                   1833:                       sprintf (msgBuffer,
                   1834:                                "Unknown attribute value \"%s\"",
                   1835:                                attrValue);
                   1836:                       if (isXML)
                   1837:                         XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
                   1838:                       else
                   1839:                         HTMLParseError (context->doc, msgBuffer, 0);
                   1840:                     }
                   1841:                   break;
                   1842:                 case 2:        /* text */
                   1843:                   if (!UnknownAttr)
                   1844:                     {
                   1845:                       TtaSetAttributeText (currentAttribute, attrValue,
                   1846:                                            lastAttrElement, context->doc);
                   1847:                       if (attrType.AttrTypeNum == HTML_ATTR_Language)
                   1848:                         {
                   1849:                           /* it's a LANG attribute value */
                   1850:                           lang = TtaGetLanguageIdFromName (attrValue);
                   1851:                           if (lang < 0)
                   1852:                             {
                   1853:                               sprintf (msgBuffer,
                   1854:                                        "warning - unsupported language: %s",
                   1855:                                        attrValue);
                   1856:                               if (isXML)
                   1857:                                 XmlParseError (warningMessage, (unsigned char *)msgBuffer, 0);
                   1858:                               else
                   1859:                                 HTMLParseError (context->doc, msgBuffer, 0);
                   1860:                             }
                   1861:                           else
                   1862:                             {
                   1863:                               /* change current language */
                   1864:                               context->language = lang;
                   1865:                               if (isXML)
                   1866:                                 SetLanguagInXmlStack (lang);
                   1867:                               else
                   1868:                                 SetLanguagInHTMLStack (lang);
                   1869:                             }
                   1870:                           root = TtaGetRootElement (context->doc);
                   1871:                           if (lastAttrElement == root)
                   1872:                             /* it's a LANG attribute on the root element */
                   1873:                             /* set the RealLang attribute */
                   1874:                             {
                   1875:                               attrType1.AttrSSchema = elType.ElSSchema;
                   1876:                               attrType1.AttrTypeNum = HTML_ATTR_RealLang;
                   1877:                               /* this attribute could be already present,
                   1878:                                  (lang and xml:lang attributes) */
                   1879:                               if (!TtaGetAttribute (lastAttrElement,
                   1880:                                                     attrType1))
                   1881:                                 /* it's not present. Add it */
                   1882:                                 {
                   1883:                                   attr = TtaNewAttribute (attrType1);
                   1884:                                   TtaAttachAttribute (lastAttrElement,
                   1885:                                                       attr, context->doc);
                   1886:                                   TtaSetAttributeValue (attr,
                   1887:                                                         HTML_ATTR_RealLang_VAL_Yes_,
                   1888:                                                         lastAttrElement,
                   1889:                                                         context->doc);
                   1890:                                 }
                   1891:                             }
                   1892:                         }
                   1893:                       else if (attrType.AttrTypeNum == HTML_ATTR_ID ||
                   1894:                                attrType.AttrTypeNum == HTML_ATTR_NAME)
                   1895:                         CheckUniqueName (lastAttrElement, context->doc,
                   1896:                                          currentAttribute, attrType);
                   1897:                       else if (attrType.AttrTypeNum == HTML_ATTR_accesskey)
                   1898:                         TtaAddAccessKey (context->doc, (unsigned int)attrValue[0],
                   1899:                                          lastAttrElement);
                   1900:                     }
                   1901:                   else
                   1902:                     {
                   1903:                       /* this is the content of an invalid attribute */
                   1904:                       /* append it to the current Invalid_attribute */
                   1905:                       if (!isXML)
                   1906:                         {
                   1907:                           length = strlen (attrValue) + 2;
                   1908:                           length += TtaGetTextAttributeLength (currentAttribute);
                   1909:                           buffer = (char *)TtaGetMemory (length + 1);
                   1910:                           TtaGiveTextAttributeValue (currentAttribute,
                   1911:                                                      buffer, &length);
                   1912:                           strcat (buffer, "=");
                   1913:                           strcat (buffer, attrValue);
                   1914:                           TtaSetAttributeText (currentAttribute, buffer,
                   1915:                                                lastAttrElement, context->doc);
                   1916:                           TtaFreeMemory (buffer);
                   1917:                         }
                   1918:                     }
                   1919:                   break;
                   1920:                 case 3:        /* reference */
                   1921:                   break;
                   1922:                 }
                   1923:             }
                   1924:           break;
                   1925:         case SPACE:
                   1926:           if (isXML)
                   1927:             XhtmlTypeAttrValue (attrValue, currentAttribute,
                   1928:                                 lastAttrElement, context);
                   1929:           else
                   1930:             HTMLTypeAttrValue (attrValue, currentAttribute,
                   1931:                                lastAttrElement, context);
                   1932:           break;  
                   1933:         default:
                   1934:           break;
                   1935:         }
1.30      cvs      1936: 
                   1937:       if (lastMappedAttr->ThotAttribute == HTML_ATTR_Width__)
1.129     vatton   1938:         /* HTML attribute "width" */
                   1939:         {
                   1940:           /* if it's an Object element, wait until all attributes are handled,
                   1941:              especially the data attribute that may generate the image to
                   1942:              which the width has to be applied */
                   1943:           if (elType.ElTypeNum != HTML_EL_Object)
                   1944:             /* create the corresponding attribute IntWidthPercent or */
                   1945:             /* IntWidthPxl */
                   1946:             CreateAttrWidthPercentPxl (attrValue, lastAttrElement,
                   1947:                                        context->doc, -1);
                   1948:         }
1.58      vatton   1949:       else if (lastMappedAttr->ThotAttribute == HTML_ATTR_Height_)
1.129     vatton   1950:         /* HTML attribute "height" */
                   1951:         {
                   1952:           /* if it's an Object element, wait until all attributes are handled,
                   1953:              especially the data attribute that may generate the image to
                   1954:              which the height has to be applied */
                   1955:           if (elType.ElTypeNum != HTML_EL_Object)
                   1956:             /* create the corresponding attribute IntHeightPercent or */
                   1957:             /* IntHeightPxl */
                   1958:             CreateAttrHeightPercentPxl (attrValue, lastAttrElement,
                   1959:                                         context->doc, -1);
                   1960:         }
1.91      quint    1961:       else if (lastMappedAttr->ThotAttribute == HTML_ATTR_Area_Size)
1.129     vatton   1962:         /* HTML attribute "size" for an element "input" */
                   1963:         CreateAttrIntAreaSize (val, lastAttrElement, context->doc);
1.48      vatton   1964:       else if (!strcmp (lastMappedAttr->XMLattribute, "size"))
1.129     vatton   1965:         {
                   1966:           TtaGiveAttributeType (currentAttribute, &attrType, &attrKind);
                   1967:           if (attrType.AttrTypeNum == HTML_ATTR_Font_size)
                   1968:             CreateAttrIntSize (attrValue, lastAttrElement, context->doc);
                   1969:         }
1.48      vatton   1970:       else if (!strcmp (lastMappedAttr->XMLattribute, "shape"))
1.129     vatton   1971:         {
                   1972:           child = TtaGetFirstChild (lastAttrElement);
                   1973:           if (child != NULL)
                   1974:             {
                   1975:               switch (val)
                   1976:                 {
                   1977:                 case HTML_ATTR_shape_VAL_rectangle:
                   1978:                   shape = 'R';
                   1979:                   break;
                   1980:                 case HTML_ATTR_shape_VAL_circle:
                   1981:                   shape = 'a';
                   1982:                   break;
                   1983:                 case HTML_ATTR_shape_VAL_polygon:
                   1984:                   shape = 'p';
                   1985:                   break;
                   1986:                 default:
                   1987:                   shape = SPACE;
                   1988:                   break;
                   1989:                 }
                   1990:               TtaSetGraphicsShape (child, shape, context->doc);
                   1991:             }
                   1992:         }
1.48      vatton   1993:       else if (!strcmp (lastMappedAttr->XMLattribute, "value"))
1.129     vatton   1994:         {
                   1995:           if (elType.ElTypeNum == HTML_EL_Text_Input ||
                   1996:               elType.ElTypeNum == HTML_EL_Password_Input ||
                   1997:               elType.ElTypeNum == HTML_EL_File_Input ||
                   1998:               elType.ElTypeNum == HTML_EL_Input)
                   1999:             /* create a Default_Value attribute with the same content */
                   2000:             {
                   2001:               attrType1.AttrSSchema = attrType.AttrSSchema;
                   2002:               attrType1.AttrTypeNum = HTML_ATTR_Default_Value;
                   2003:               attr = TtaNewAttribute (attrType1);
                   2004:               TtaAttachAttribute (lastAttrElement, attr, context->doc);
                   2005:               TtaSetAttributeText (attr, attrValue,
                   2006:                                    lastAttrElement, context->doc);
                   2007:             }
                   2008:         }
1.30      cvs      2009:       else
1.129     vatton   2010:         {
                   2011:           /* Some HTML attributes are equivalent to a CSS property:      */
                   2012:           /*      background     ->                   background         */
                   2013:           /*      bgcolor        ->                   background         */
                   2014:           /*      text           ->                   color              */
                   2015:           /*      color          ->                   color              */
                   2016:           if (!strcmp (lastMappedAttr->XMLattribute, "background"))
                   2017:             {
                   2018:               if (strlen (attrValue) > MaxMsgLength - 30)
                   2019:                 attrValue[MaxMsgLength - 30] = EOS;
                   2020:               HTMLSetBackgroundImage (context->doc, context->lastElement,
                   2021:                                       REPEAT, 0, attrValue, FALSE);
                   2022:             }
                   2023:           else if (!strcmp (lastMappedAttr->XMLattribute, "bgcolor"))
                   2024:             HTMLSetBackgroundColor (context->doc, context->lastElement,
                   2025:                                     0, attrValue);
                   2026:           else if (!strcmp (lastMappedAttr->XMLattribute, "text") ||
                   2027:                    !strcmp (lastMappedAttr->XMLattribute, "color"))
                   2028:             HTMLSetForegroundColor (context->doc, context->lastElement,
                   2029:                                     0, attrValue);
                   2030:         }
1.48      vatton   2031:     }
1.30      cvs      2032: }
                   2033: 
                   2034: /*----------------------------------------------------------------------
1.129     vatton   2035:   MapHTMLAttributeValue
                   2036:   Search in the Attribute Value Mapping Table the entry for the attribute
                   2037:   ThotAtt and its value attVal. Returns the corresponding Thot value.
1.1       cvs      2038:   ----------------------------------------------------------------------*/
1.118     vatton   2039: void MapHTMLAttributeValue (char *attVal, const AttributeType *attrType,
1.129     vatton   2040:                             int *value)
1.1       cvs      2041: {
1.66      vatton   2042:   MapXMLAttributeValue (XHTML_TYPE, attVal, attrType, value);
1.1       cvs      2043: }

Webmaster