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