Annotation of Amaya/amaya/XHTMLbuilder.c, revision 1.116
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:
1.116 ! quint 559: case HTML_EL_Form:
! 560: /* Check the mandatory action attribute */
! 561: CheckMandatoryAttribute (el, doc, HTML_ATTR_Script_URL);
! 562: break;
! 563:
1.6 cvs 564: case HTML_EL_Input: /* it's an INPUT without any TYPE attribute */
565: /* Create a child of type Text_Input */
566: elType.ElTypeNum = HTML_EL_Text_Input;
567: child = TtaNewTree (doc, elType, "");
1.63 cvs 568: if (DocumentMeta[doc]->xmlformat)
569: XmlSetElemLineNumber (child);
570: else
571: SetHtmlElemLineNumber (child);
1.6 cvs 572: TtaInsertFirstChild (&child, el, doc);
573: /* now, process it like a Text_Input element */
574:
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: }
615: break;
616:
617: case HTML_EL_META:
1.104 vatton 618: ParseCharsetAndContentType (el, doc);
1.114 vatton 619: /* Check the mandatory CONTENT attribute */
620: CheckMandatoryAttribute (el, doc, HTML_ATTR_meta_content);
621: break;
622:
623: case HTML_EL_BASE:
624: /* Check the mandatory HREF attribute */
625: CheckMandatoryAttribute (el, doc, HTML_ATTR_HREF_);
626: break;
627:
628: case HTML_EL_BaseFont:
629: /* Check the mandatory size attribute */
630: CheckMandatoryAttribute (el, doc, HTML_ATTR_BaseFontSize);
631: break;
632:
633: case HTML_EL_BDO:
634: /* Check the mandatory DIR attribute */
635: CheckMandatoryAttribute (el, doc, HTML_ATTR_dir);
1.6 cvs 636: break;
637:
638: case HTML_EL_STYLE_: /* it's a STYLE element */
1.60 vatton 639: case HTML_EL_SCRIPT_: /* it's a SCRIPT element */
1.6 cvs 640: case HTML_EL_Preformatted: /* it's a PRE */
641: /* if the last line of the Preformatted is empty, remove it */
642: leaf = XmlLastLeafInElement (el);
643: if (leaf != NULL)
644: {
645: elType = TtaGetElementType (leaf);
646: if (elType.ElTypeNum == HTML_EL_TEXT_UNIT)
647: /* the last leaf is a TEXT element */
648: {
649: length = TtaGetTextLength (leaf);
650: if (length > 0)
651: {
1.100 gully 652: TtaGiveSubString (leaf, (unsigned char *)lastChar, length, 1);
1.6 cvs 653: if (lastChar[0] == EOL)
654: /* last character is new line, delete it */
655: {
656: if (length == 1)
657: /* empty TEXT element */
658: TtaDeleteTree (leaf, doc);
659: else
660: /* remove the last character */
661: TtaDeleteTextContent (leaf, length, 1, doc);
662: }
663: }
664: }
665: }
1.114 vatton 666:
667: if (elType.ElTypeNum == HTML_EL_STYLE_)
668: /* Check the mandatory TYPE attribute */
669: CheckMandatoryAttribute (el, doc, HTML_ATTR_Notation);
670: else if (elType.ElTypeNum == HTML_EL_SCRIPT_)
671: /* Check the mandatory TYPE attribute */
672: CheckMandatoryAttribute (el, doc, HTML_ATTR_content_type);
673:
1.75 kahan 674: if (DocumentMeta[doc] && DocumentMeta[doc]->xmlformat)
1.63 cvs 675: {
676: if (IsXmlParsingCSS ())
677: {
678: text = GetStyleContents (el);
679: if (text)
680: {
1.71 vatton 681: ReadCSSRules (doc, NULL, text, NULL,
1.82 quint 682: TtaGetElementLineNumber (el), FALSE, el);
1.63 cvs 683: TtaFreeMemory (text);
684: }
685: SetXmlParsingCSS (FALSE);
686: }
687: }
688: else
1.6 cvs 689: {
1.63 cvs 690: if (IsHtmlParsingCSS ())
1.6 cvs 691: {
1.63 cvs 692: text = GetStyleContents (el);
693: if (text)
694: {
1.71 vatton 695: ReadCSSRules (doc, NULL, text, NULL,
1.82 quint 696: TtaGetElementLineNumber (el), FALSE, el);
1.63 cvs 697: TtaFreeMemory (text);
698: }
699: SetHtmlParsingCSS (FALSE);
1.6 cvs 700: }
701: }
702: /* and continue as if it were a Preformatted or a Script */
703: break;
704:
705: case HTML_EL_Text_Area: /* it's a Text_Area */
1.69 cvs 706: if (DocumentMeta[doc]->xmlformat)
707: SetParsingTextArea (FALSE);
708: else
709: SetHtmlParsingTextArea (FALSE);
1.6 cvs 710: child = TtaGetFirstChild (el);
711: if (child == NULL)
712: /* it's an empty Text_Area */
1.97 quint 713: /* insert a Inserted_Text element and a child Basic_Elem in the
714: Text_Area element */
1.6 cvs 715: {
716: newElType.ElTypeNum = HTML_EL_Inserted_Text;
717: child = TtaNewTree (doc, newElType, "");
718: TtaInsertFirstChild (&child, el, doc);
719: }
720: else
721: {
722: /* save the text into Default_Value attribute */
1.109 vatton 723: attrType.AttrSSchema = htmlSchema;
1.6 cvs 724: attrType.AttrTypeNum = HTML_ATTR_Default_Value;
725: if (TtaGetAttribute (el, attrType) == NULL)
726: /* attribute Default_Value is missing */
727: {
728: desc = TtaGetFirstChild (child);
1.97 quint 729: if (desc)
730: {
731: length = TtaGetTextLength (desc);
732: if (length > 0)
733: {
734: length++;
735: attr = TtaNewAttribute (attrType);
736: TtaAttachAttribute (el, attr, doc);
1.100 gully 737: text = (char *)TtaGetMemory (length);
738: TtaGiveTextContent (desc, (unsigned char *)text, &length, &lang);
1.97 quint 739: TtaSetAttributeText (attr, text, el, doc);
740: TtaFreeMemory (text);
741: }
742: }
1.6 cvs 743: }
744: }
1.114 vatton 745: /* Check the mandatory rows attribute */
746: CheckMandatoryAttribute (el, doc, HTML_ATTR_Rows);
747: /* Check the mandatory columns attribute */
748: CheckMandatoryAttribute (el, doc, HTML_ATTR_Columns);
1.6 cvs 749: break;
1.103 quint 750:
1.6 cvs 751: case HTML_EL_Radio_Input:
752: case HTML_EL_Checkbox_Input:
753: /* put an attribute Checked if it is missing */
1.109 vatton 754: attrType.AttrSSchema = htmlSchema;
1.6 cvs 755: attrType.AttrTypeNum = HTML_ATTR_Checked;
756: if (TtaGetAttribute (el, attrType) == NULL)
757: /* attribute Checked is missing */
758: {
759: attr = TtaNewAttribute (attrType);
760: TtaAttachAttribute (el, attr, doc);
761: TtaSetAttributeValue (attr, HTML_ATTR_Checked_VAL_No_, el, doc);
762: }
763: break;
764:
765: case HTML_EL_Option_Menu:
766: /* Check that at least one option has a SELECTED attribute */
767: OnlyOneOptionSelected (el, doc, TRUE);
1.114 vatton 768: /* Check the mandatory name attribute */
769: CheckMandatoryAttribute (el, doc, HTML_ATTR_NAME);
770: break;
771:
772: case HTML_EL_OptGroup:
773: /* Check the mandatory label attribute */
774: CheckMandatoryAttribute (el, doc, HTML_ATTR_label);
1.6 cvs 775: break;
776:
1.116 ! quint 777: case HTML_EL_MAP:
! 778: case HTML_EL_map:
! 779: /* Check the mandatory name attribute */
! 780: CheckMandatoryAttribute (el, doc, HTML_ATTR_NAME);
! 781: break;
! 782:
! 783: case HTML_EL_AREA:
! 784: /* Check the mandatory alt attribute */
! 785: CheckMandatoryAttribute (el, doc, HTML_ATTR_ALT);
! 786: break;
! 787:
1.6 cvs 788: case HTML_EL_PICTURE_UNIT:
1.111 vatton 789: /* Check the mandatory ALT attribute */
1.114 vatton 790: attrType.AttrSSchema = htmlSchema;
791: attrType.AttrTypeNum = HTML_ATTR_IsInput;
792: if (TtaGetAttribute (el, attrType) == NULL)
793: CheckMandatoryAttribute (el, doc, HTML_ATTR_ALT);
794: /* Check the mandatory SRC attribute */
795: CheckMandatoryAttribute (el, doc, HTML_ATTR_SRC);
1.6 cvs 796: break;
797:
798: case HTML_EL_LINK:
1.109 vatton 799: CheckCSSLink (el, doc, htmlSchema);
1.6 cvs 800: break;
801:
802: case HTML_EL_Data_cell:
803: case HTML_EL_Heading_cell:
1.107 quint 804: case HTML_EL_List_Item:
805: case HTML_EL_Definition:
806: /* insert a pseudo paragraph into empty cells or list items */
1.6 cvs 807: child = TtaGetFirstChild (el);
808: if (child == NULL)
809: {
810: elType.ElTypeNum = HTML_EL_Pseudo_paragraph;
811: child = TtaNewTree (doc, elType, "");
812: if (child != NULL)
813: TtaInsertFirstChild (&child, el, doc);
814: }
1.107 quint 815: if (elType.ElTypeNum == HTML_EL_Data_cell ||
816: elType.ElTypeNum == HTML_EL_Heading_cell)
817: /* detect whether we are parsing a whole table or just a cell */
1.63 cvs 818: {
1.107 quint 819: if (DocumentMeta[doc]->xmlformat)
820: {
821: if (IsWithinXmlTable ())
822: NewCell (el, doc, FALSE, FALSE, FALSE);
823: }
824: else
825: {
826: if (IsWithinHtmlTable ())
827: NewCell (el, doc, FALSE, FALSE, FALSE);
828: }
1.63 cvs 829: }
1.6 cvs 830: break;
831:
1.110 quint 832: case HTML_EL_Table_:
1.6 cvs 833: CheckTable (el, doc);
834: SubWithinTable ();
835: break;
836:
837: case HTML_EL_TITLE:
838: /* show the TITLE in the main window */
839: UpdateTitle (el, doc);
840: break;
1.41 cvs 841:
842: case HTML_EL_rbc:
843: /* an rbc element has been read. Its parent should be a complex_ruby.
844: Change the type of the parent, as simple_ruby are created by
845: default */
846: parent = TtaGetParent (el);
847: if (parent)
848: {
849: newElType = TtaGetElementType (parent);
850: if (newElType.ElSSchema == elType.ElSSchema &&
851: newElType.ElTypeNum == HTML_EL_simple_ruby)
1.95 vatton 852: TtaChangeElementType (parent, HTML_EL_complex_ruby);
1.41 cvs 853: }
854: break;
855:
856: case HTML_EL_rtc1:
857: /* an rtc element has been parsed. If it has already a rtc1 sibling,
858: change its type to rtc2 */
859: prev = el;
860: do
861: {
862: TtaPreviousSibling(&prev);
863: if (prev)
864: {
865: newElType = TtaGetElementType (prev);
866: if (newElType.ElSSchema == elType.ElSSchema &&
867: newElType.ElTypeNum == HTML_EL_rtc1)
868: {
1.95 vatton 869: TtaChangeElementType (el, HTML_EL_rtc2);
1.41 cvs 870: prev = NULL;
871: }
872: }
873: }
874: while (prev);
875: break;
876:
1.6 cvs 877: default:
878: break;
879: }
880: }
1.1 cvs 881:
882: /*----------------------------------------------------------------------
1.30 cvs 883: PutInContent
884: Put the string ChrString in the leaf of current element.
885: ----------------------------------------------------------------------*/
1.39 cvs 886: Element PutInContent (char *ChrString, ParserData *context)
1.30 cvs 887:
888: {
889: Element el, child;
890: ElementType elType;
891: int length;
892:
893: el = NULL;
894: if (context->lastElement != NULL)
895: {
896: /* search first leaf of current element */
897: el = context->lastElement;
898: do
899: {
900: child = TtaGetFirstChild (el);
901: if (child != NULL)
902: el = child;
903: }
904: while (child != NULL);
905: elType = TtaGetElementType (el);
906: length = 0;
907: if (elType.ElTypeNum == 1)
908: length = TtaGetTextLength (el);
909: if (length == 0)
1.114 vatton 910: TtaSetTextContent (el, (unsigned char *)ChrString,
911: context->language, context->doc);
1.30 cvs 912: else
1.100 gully 913: TtaAppendTextContent (el, (unsigned char *)ChrString, context->doc);
1.30 cvs 914: }
915: return el;
916: }
917:
918: /*----------------------------------------------------------------------
1.93 vatton 919: UnknownXhtmlNameSpace
920: The element doesn't belong to a supported namespace
1.51 cvs 921: ----------------------------------------------------------------------*/
1.93 vatton 922: void UnknownXhtmlNameSpace (ParserData *context, Element *unknownEl,
923: char* content)
1.51 cvs 924: {
925: ElementType elType;
1.65 cvs 926: Element elText;
1.51 cvs 927:
928: /* Create a new Invalid_element */
929: elType.ElSSchema = GetXMLSSchema (XHTML_TYPE, context->doc);
1.94 cvs 930: elType.ElTypeNum = HTML_EL_XHTML_Unknown_namespace;
1.65 cvs 931: *unknownEl = TtaNewElement (context->doc, elType);
932: if (*unknownEl != NULL)
1.51 cvs 933: {
1.65 cvs 934: XmlSetElemLineNumber (*unknownEl);
935: InsertXmlElement (unknownEl);
1.51 cvs 936: context->lastElementClosed = TRUE;
937: elType.ElTypeNum = HTML_EL_TEXT_UNIT;
938: elText = TtaNewElement (context->doc, elType);
939: XmlSetElemLineNumber (elText);
1.65 cvs 940: TtaInsertFirstChild (&elText, *unknownEl, context->doc);
1.100 gully 941: TtaSetTextContent (elText, (unsigned char *)content, context->language, context->doc);
1.51 cvs 942: TtaSetAccessRight (elText, ReadOnly, context->doc);
943: }
944: }
945:
946: /*----------------------------------------------------------------------
1.30 cvs 947: CreateHTMLAttribute
948: create an attribute of type attrType for the element el.
949: ----------------------------------------------------------------------*/
1.93 vatton 950: void CreateHTMLAttribute (Element el,
951: AttributeType attrType,
952: char* text,
953: ThotBool isInvalid,
954: Document doc,
955: Attribute *lastAttribute,
956: Element *lastAttrElement)
1.30 cvs 957: {
958: int attrKind;
959: int length;
1.39 cvs 960: char *buffer;
1.30 cvs 961: Attribute attr, oldAttr;
962:
963: if (attrType.AttrTypeNum != 0)
964: {
965: oldAttr = TtaGetAttribute (el, attrType);
966: if (oldAttr != NULL)
967: /* this attribute already exists */
968: attr = oldAttr;
969: else
970: /* create a new attribute and attach it to the element */
971: {
972: attr = TtaNewAttribute (attrType);
973: TtaAttachAttribute (el, attr, doc);
974: }
975: *lastAttribute = attr;
976: *lastAttrElement = el;
977:
978: TtaGiveAttributeType (attr, &attrType, &attrKind);
979: if (attrKind == 0) /* enumerate */
980: TtaSetAttributeValue (attr, 1, el, doc);
981:
982: /* attribute BORDER without any value (ThotBool attribute) is */
983: /* considered as BORDER=1 */
984: if (attrType.AttrTypeNum == HTML_ATTR_Border)
985: TtaSetAttributeValue (attr, 1, el, doc);
986:
987: if (isInvalid)
988: /* Copy the name of the invalid attribute as the content */
989: /* of the Invalid_attribute attribute. */
990: {
1.37 cvs 991: length = strlen (text) + 2;
1.30 cvs 992: length += TtaGetTextAttributeLength (attr);
1.100 gully 993: buffer = (char *)TtaGetMemory (length + 1);
1.30 cvs 994: TtaGiveTextAttributeValue (attr, buffer, &length);
1.37 cvs 995: strcat (buffer, " ");
996: strcat (buffer, text);
1.30 cvs 997: TtaSetAttributeText (attr, buffer, el, doc);
998: TtaFreeMemory (buffer);
999: }
1000: }
1001: }
1002:
1003: /*----------------------------------------------------------------------
1004: HTMLTypeAttrValue
1005: Value val has been read for the HTML attribute TYPE.
1006: Create a child for the current Thot element INPUT accordingly.
1007: ----------------------------------------------------------------------*/
1.109 vatton 1008: void HTMLTypeAttrValue (char *val, Attribute lastAttribute,
1009: Element lastAttrElement, ParserData *context)
1.30 cvs 1010: {
1011: ElementType elType;
1012: Element newChild;
1013: AttributeType attrType;
1014: Attribute attr;
1.39 cvs 1015: char msgBuffer[MaxMsgLength];
1.30 cvs 1016: int value;
1017: int numberOfLinesRead;
1018:
1019: value = MapAttrValue (DummyAttribute, val);
1.109 vatton 1020: elType = TtaGetElementType (context->lastElement);
1.91 quint 1021: if (value <= 0)
1.30 cvs 1022: {
1.37 cvs 1023: if (strlen (val) > MaxMsgLength - 40)
1024: val[MaxMsgLength - 40] = EOS;
1025: sprintf (msgBuffer, "Unknown attribute value \"type = %s\"", val);
1.42 cvs 1026: HTMLParseError (context->doc, msgBuffer);
1.109 vatton 1027: attrType.AttrSSchema = elType.ElSSchema;
1.30 cvs 1028: attrType.AttrTypeNum = pHTMLAttributeMapping[0].ThotAttribute;
1.37 cvs 1029: sprintf (msgBuffer, "type=%s", val);
1.30 cvs 1030: CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,
1031: context->doc, &lastAttribute, &lastAttrElement);
1032: }
1033: else
1034: {
1035: if (elType.ElTypeNum != HTML_EL_Input)
1036: {
1.37 cvs 1037: if (strlen (val) > MaxMsgLength - 40)
1038: val[MaxMsgLength - 40] = EOS;
1039: sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val);
1.30 cvs 1040: }
1041: else
1042: {
1043: elType.ElTypeNum = value;
1044: newChild = TtaNewTree (context->doc, elType, "");
1045: numberOfLinesRead = 0;
1046: TtaSetElementLineNumber (newChild, numberOfLinesRead);
1047: TtaInsertFirstChild (&newChild, context->lastElement, context->doc);
1048: if (value == HTML_EL_PICTURE_UNIT)
1049: {
1050: /* add the attribute IsInput to input pictures */
1051: attrType.AttrSSchema = elType.ElSSchema;
1052: attrType.AttrTypeNum = HTML_ATTR_IsInput;
1053: attr = TtaNewAttribute (attrType);
1054: TtaAttachAttribute (newChild, attr, context->doc);
1055: }
1056: }
1057: }
1058: }
1059:
1060: /*----------------------------------------------------------------------
1061: XhtmlTypeAttrValue
1062: Value val has been read for the HTML attribute TYPE.
1063: Create a child for the current Thot element INPUT accordingly.
1064: ----------------------------------------------------------------------*/
1.111 vatton 1065: void XhtmlTypeAttrValue (char *val,
1066: Attribute currentAttribute,
1067: Element lastAttrElement,
1068: ParserData *context)
1.30 cvs 1069: {
1070: ElementType elType;
1071: Element newChild;
1072: AttributeType attrType;
1073: Attribute attr;
1.39 cvs 1074: char msgBuffer[MaxMsgLength];
1.30 cvs 1075: int value;
1076: ThotBool level;
1077:
1.91 quint 1078: /* Look in the dummy section of the attribute value table */
1.30 cvs 1079: attrType.AttrTypeNum = DummyAttribute;
1.100 gully 1080: MapHTMLAttributeValue (val, &attrType, &value);
1.91 quint 1081: if (value <= 0)
1082: /* invalid value for the type attribute of an input element */
1.30 cvs 1083: {
1.37 cvs 1084: sprintf (msgBuffer, "Unknown attribute value \"type=%s\"", val);
1.100 gully 1085: XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
1.36 cvs 1086: MapHTMLAttribute ("unknown_attr", &attrType, NULL,
1.30 cvs 1087: &level, context->doc);
1.37 cvs 1088: sprintf (msgBuffer, "type=%s", val);
1.30 cvs 1089: CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE,
1090: context->doc, ¤tAttribute, &lastAttrElement);
1091: }
1092: else
1.91 quint 1093: /* value is the Thot type of the element to be created for this value of
1094: the TYPE attribute */
1.30 cvs 1095: {
1096: elType = TtaGetElementType (context->lastElement);
1097: if (elType.ElTypeNum != HTML_EL_Input)
1098: {
1.37 cvs 1099: sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val);
1.100 gully 1100: XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
1.30 cvs 1101: }
1102: else
1103: {
1104: elType.ElTypeNum = value;
1105: newChild = TtaNewTree (context->doc, elType, "");
1106: XmlSetElemLineNumber (newChild);
1107: TtaInsertFirstChild (&newChild, context->lastElement, context->doc);
1108: if (value == HTML_EL_PICTURE_UNIT)
1109: {
1110: /* add the attribute IsInput to input pictures */
1111: attrType.AttrSSchema = elType.ElSSchema;
1112: attrType.AttrTypeNum = HTML_ATTR_IsInput;
1113: attr = TtaNewAttribute (attrType);
1114: TtaAttachAttribute (newChild, attr, context->doc);
1115: }
1116: }
1117: }
1118: }
1119:
1120: /*----------------------------------------------------------------------
1121: CreateAttrWidthPercentPxl
1.79 quint 1122: an HTML attribute "width" has been created for a Table, an image,
1123: an Object of a HR.
1.30 cvs 1124: Create the corresponding attribute IntWidthPercent or IntWidthPxl.
1125: oldWidth is -1 or the old image width.
1126: ----------------------------------------------------------------------*/
1.58 vatton 1127: void CreateAttrWidthPercentPxl (char *buffer, Element el,
1128: Document doc, int oldWidth)
1.30 cvs 1129: {
1130: AttributeType attrTypePxl, attrTypePercent;
1131: Attribute attrOld, attrNew;
1132: int length, val;
1.39 cvs 1133: char msgBuffer[MaxMsgLength];
1.79 quint 1134: ElementType elType, childType;
1135: Element origEl, child;
1.30 cvs 1136: int w, h;
1137: ThotBool isImage;
1138:
1.79 quint 1139: origEl = el;
1.30 cvs 1140: elType = TtaGetElementType (el);
1141: isImage = (elType.ElTypeNum == HTML_EL_PICTURE_UNIT ||
1142: elType.ElTypeNum == HTML_EL_Data_cell ||
1.79 quint 1143: elType.ElTypeNum == HTML_EL_Heading_cell ||
1144: elType.ElTypeNum == HTML_EL_Object);
1145: if (elType.ElTypeNum == HTML_EL_Object)
1146: /* the width attribute is attached to an Object element */
1147: {
1148: child = TtaGetFirstChild (el);
1149: if (child)
1150: {
1151: childType = TtaGetElementType (child);
1152: if (childType.ElTypeNum == HTML_EL_PICTURE_UNIT)
1153: /* the Object element is of type image. apply the width
1154: attribute to the actual image element */
1155: el = child;
1156: }
1157: }
1.30 cvs 1158: /* remove trailing spaces */
1.37 cvs 1159: length = strlen (buffer) - 1;
1.30 cvs 1160: while (length > 0 && buffer[length] <= SPACE)
1161: length--;
1.109 vatton 1162: attrTypePxl.AttrSSchema = elType.ElSSchema;
1163: attrTypePercent.AttrSSchema = elType.ElSSchema;
1.30 cvs 1164: attrTypePxl.AttrTypeNum = HTML_ATTR_IntWidthPxl;
1165: attrTypePercent.AttrTypeNum = HTML_ATTR_IntWidthPercent;
1166: /* is the last character a '%' ? */
1167: if (buffer[length] == '%')
1168: {
1169: /* remove IntWidthPxl */
1170: attrOld = TtaGetAttribute (el, attrTypePxl);
1171: /* update IntWidthPercent */
1172: attrNew = TtaGetAttribute (el, attrTypePercent);
1173: if (attrNew == NULL)
1174: {
1175: attrNew = TtaNewAttribute (attrTypePercent);
1176: TtaAttachAttribute (el, attrNew, doc);
1177: }
1178: else if (isImage && oldWidth == -1)
1179: {
1180: if (attrOld == NULL)
1181: oldWidth = TtaGetAttributeValue (attrNew);
1182: else
1183: oldWidth = TtaGetAttributeValue (attrOld);
1184: }
1185: }
1186: else
1187: {
1188: /* remove IntWidthPercent */
1189: attrOld = TtaGetAttribute (el, attrTypePercent);
1190: /* update IntWidthPxl */
1191: attrNew = TtaGetAttribute (el, attrTypePxl);
1192: if (attrNew == NULL)
1193: {
1194: attrNew = TtaNewAttribute (attrTypePxl);
1195: TtaAttachAttribute (el, attrNew, doc);
1196: }
1197: else if (isImage && oldWidth == -1)
1198: {
1199: TtaGiveBoxSize (el, doc, 1, UnPixel, &w, &h);
1200: if (attrOld == NULL)
1201: oldWidth = w * TtaGetAttributeValue (attrNew) / 100;
1202: else
1203: oldWidth = w * TtaGetAttributeValue (attrOld) / 100;
1204: }
1205: }
1206:
1207: if (attrOld != NULL)
1208: TtaRemoveAttribute (el, attrOld, doc);
1.43 cvs 1209: if (sscanf (buffer, "%d", &val))
1.30 cvs 1210: TtaSetAttributeValue (attrNew, val, el, doc);
1211: else
1212: /* its not a number. Delete attribute and send an error message */
1213: {
1214: TtaRemoveAttribute (el, attrNew, doc);
1.37 cvs 1215: if (strlen (buffer) > MaxMsgLength - 30)
1.30 cvs 1216: buffer[MaxMsgLength - 30] = EOS;
1.37 cvs 1217: sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
1.42 cvs 1218: HTMLParseError (doc, msgBuffer);
1.30 cvs 1219: }
1220: if (isImage)
1.79 quint 1221: UpdateImageMap (origEl, doc, oldWidth, -1);
1.30 cvs 1222: }
1223:
1224: /*----------------------------------------------------------------------
1.58 vatton 1225: CreateAttrHeightPercentPxl
1.79 quint 1226: an HTML attribute "width" has been created for a Table, an image,
1227: an Object or a HR.
1.58 vatton 1228: Create the corresponding attribute IntHeightPercent or IntHeightPxl.
1229: oldHeight is -1 or the old image width.
1230: ----------------------------------------------------------------------*/
1231: void CreateAttrHeightPercentPxl (char *buffer, Element el,
1232: Document doc, int oldHeight)
1233: {
1234: AttributeType attrTypePxl, attrTypePercent;
1235: Attribute attrOld, attrNew;
1236: int length, val;
1237: char msgBuffer[MaxMsgLength];
1.79 quint 1238: ElementType elType, childType;
1239: Element origEl, child;
1.58 vatton 1240: int w, h;
1241: ThotBool isImage;
1242:
1.79 quint 1243: origEl = el;
1.58 vatton 1244: elType = TtaGetElementType (el);
1245: isImage = (elType.ElTypeNum == HTML_EL_PICTURE_UNIT ||
1246: elType.ElTypeNum == HTML_EL_Data_cell ||
1.79 quint 1247: elType.ElTypeNum == HTML_EL_Heading_cell ||
1248: elType.ElTypeNum == HTML_EL_Object);
1249: if (elType.ElTypeNum == HTML_EL_Object)
1250: /* the height attribute is attached to an Object element */
1251: {
1252: child = TtaGetFirstChild (el);
1.81 cvs 1253: if (!child)
1254: return;
1255: else
1.79 quint 1256: {
1257: childType = TtaGetElementType (child);
1258: if (childType.ElTypeNum == HTML_EL_PICTURE_UNIT)
1259: /* the Object element is of type image. apply the width
1260: attribute to the actual image element */
1261: el = child;
1.81 cvs 1262: else
1263: return;
1.79 quint 1264: }
1265: }
1.58 vatton 1266: /* remove trailing spaces */
1267: length = strlen (buffer) - 1;
1268: while (length > 0 && buffer[length] <= SPACE)
1269: length--;
1.109 vatton 1270: attrTypePxl.AttrSSchema = elType.ElSSchema;
1271: attrTypePercent.AttrSSchema = elType.ElSSchema;
1.58 vatton 1272: attrTypePxl.AttrTypeNum = HTML_ATTR_IntHeightPxl;
1273: attrTypePercent.AttrTypeNum = HTML_ATTR_IntHeightPercent;
1274: /* is the last character a '%' ? */
1275: if (buffer[length] == '%')
1276: {
1277: /* remove IntHeightPxl */
1278: attrOld = TtaGetAttribute (el, attrTypePxl);
1279: /* update IntHeightPercent */
1280: attrNew = TtaGetAttribute (el, attrTypePercent);
1281: if (attrNew == NULL)
1282: {
1283: attrNew = TtaNewAttribute (attrTypePercent);
1284: TtaAttachAttribute (el, attrNew, doc);
1285: }
1286: else if (isImage && oldHeight == -1)
1287: {
1288: if (attrOld == NULL)
1289: oldHeight = TtaGetAttributeValue (attrNew);
1290: else
1291: oldHeight = TtaGetAttributeValue (attrOld);
1292: }
1293: }
1294: else
1295: {
1296: /* remove IntHeightPercent */
1297: attrOld = TtaGetAttribute (el, attrTypePercent);
1298: /* update IntHeightPxl */
1299: attrNew = TtaGetAttribute (el, attrTypePxl);
1300: if (attrNew == NULL)
1301: {
1302: attrNew = TtaNewAttribute (attrTypePxl);
1303: TtaAttachAttribute (el, attrNew, doc);
1304: }
1305: else if (isImage && oldHeight == -1)
1306: {
1307: TtaGiveBoxSize (el, doc, 1, UnPixel, &w, &h);
1308: if (attrOld == NULL)
1309: oldHeight = w * TtaGetAttributeValue (attrNew) / 100;
1310: else
1311: oldHeight = w * TtaGetAttributeValue (attrOld) / 100;
1312: }
1313: }
1314:
1315: if (attrOld != NULL)
1316: TtaRemoveAttribute (el, attrOld, doc);
1317: if (sscanf (buffer, "%d", &val))
1318: TtaSetAttributeValue (attrNew, val, el, doc);
1319: else
1320: /* its not a number. Delete attribute and send an error message */
1321: {
1322: TtaRemoveAttribute (el, attrNew, doc);
1323: if (strlen (buffer) > MaxMsgLength - 30)
1324: buffer[MaxMsgLength - 30] = EOS;
1325: sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
1326: HTMLParseError (doc, msgBuffer);
1327: }
1328: if (isImage)
1.79 quint 1329: UpdateImageMap (origEl, doc, oldHeight, -1);
1.58 vatton 1330: }
1331:
1332: /*----------------------------------------------------------------------
1.91 quint 1333: CreateAttrIntAreaSize
1334: an HTML attribute "size" has been created or modified for a input element.
1335: Create or update the corresponding attribute IntAreaSize.
1336: ----------------------------------------------------------------------*/
1337: void CreateAttrIntAreaSize (int value, Element el, Document doc)
1338: {
1339: AttributeType attrType;
1340: Attribute attr;
1341: ElementType elType;
1342:
1343: elType = TtaGetElementType (el);
1344: attrType.AttrSSchema = elType.ElSSchema;
1345: attrType.AttrTypeNum = HTML_ATTR_IntAreaSize;
1346: attr = TtaGetAttribute (el, attrType);
1347: if (!attr)
1348: {
1349: attr = TtaNewAttribute (attrType);
1350: TtaAttachAttribute (el, attr, doc);
1351: }
1352: /* the presentation rule associated with attribute IntAreaSize expresses
1353: the element width in "em". Convert the value into em */
1354: TtaSetAttributeValue (attr, (int) (value * 0.55), el, doc);
1355: }
1356:
1357: /*----------------------------------------------------------------------
1.30 cvs 1358: CreateAttrIntSize
1359: an HTML attribute "size" has been created for a Font element.
1360: Create the corresponding internal attribute.
1361: ----------------------------------------------------------------------*/
1.109 vatton 1362: void CreateAttrIntSize (char *buffer, Element el, Document doc)
1.30 cvs 1363:
1364: {
1.109 vatton 1365: ElementType elType;
1.30 cvs 1366: AttributeType attrType;
1367: int val, ind, factor, delta;
1368: Attribute attr;
1.37 cvs 1369: char msgBuffer[MaxMsgLength];
1.30 cvs 1370:
1371: /* is the first character a '+' or a '-' ? */
1.109 vatton 1372: elType = TtaGetElementType (el);
1.30 cvs 1373: ind = 0;
1374: factor = 1;
1375: delta = 0;
1376: if (buffer[0] == '+')
1377: {
1378: attrType.AttrTypeNum = HTML_ATTR_IntSizeIncr;
1379: ind++;
1.90 vatton 1380: factor = 1;
1.30 cvs 1381: }
1382: else if (buffer[0] == '-')
1383: {
1384: attrType.AttrTypeNum = HTML_ATTR_IntSizeDecr;
1385: ind++;
1.90 vatton 1386: factor = 1;
1.30 cvs 1387: }
1388: else
1389: {
1390: attrType.AttrTypeNum = HTML_ATTR_IntSizeRel;
1391: delta = 1;
1392: }
1.109 vatton 1393: attrType.AttrSSchema = elType.ElSSchema;
1.30 cvs 1394: attr = TtaGetAttribute (el, attrType);
1.43 cvs 1395: if (sscanf (&buffer[ind], "%d", &val))
1.30 cvs 1396: {
1397: val = val * factor + delta;
1398: if (attr == NULL)
1399: {
1400: /* this attribute doesn't exist, create it */
1401: attr = TtaNewAttribute (attrType);
1402: TtaAttachAttribute (el, attr, doc);
1403: }
1404: TtaSetAttributeValue (attr, val, el, doc);
1405: }
1406: else
1407: /* its not a number. Delete attribute and send an error message */
1408: {
1409: if (attr)
1410: TtaRemoveAttribute (el, attr, doc);
1.37 cvs 1411: if (strlen (buffer) > MaxMsgLength - 30)
1.30 cvs 1412: buffer[MaxMsgLength - 30] = EOS;
1.37 cvs 1413: sprintf (msgBuffer, "Invalid attribute value \"%s\"", buffer);
1.42 cvs 1414: HTMLParseError (doc, msgBuffer);
1.30 cvs 1415: }
1416: }
1417: /*----------------------------------------------------------------------
1418: EndOfHTMLAttributeValue
1419: Filling of an HTML attribute value
1420: ----------------------------------------------------------------------*/
1.109 vatton 1421: void EndOfHTMLAttributeValue (char *attrValue, AttributeMapping *lastMappedAttr,
1422: Attribute currentAttribute, Element lastAttrElement,
1423: ThotBool UnknownAttr, ParserData *context,
1.48 vatton 1424: ThotBool isXML)
1.30 cvs 1425: {
1.48 vatton 1426: AttributeType attrType, attrType1;
1427: Attribute attr;
1.79 quint 1428: ElementType elType;
1.48 vatton 1429: Element child, root;
1430: Language lang;
1431: char translation;
1432: char shape;
1433: char *buffer;
1434: char *attrName;
1435: char msgBuffer[MaxMsgLength];
1436: int val;
1437: int length;
1438: int attrKind;
1439: ThotBool done = FALSE;
1.88 vatton 1440: ThotBool loadcss;
1.30 cvs 1441:
1.48 vatton 1442: /* treatments of some particular HTML attributes */
1443: if (!strcmp (lastMappedAttr->XMLattribute, "style"))
1444: {
1445: TtaSetAttributeText (currentAttribute, attrValue,
1446: lastAttrElement, context->doc);
1.88 vatton 1447: /* check if we have to load CSS */
1448: TtaGetEnvBoolean ("LOAD_CSS", &loadcss);
1449: if (loadcss)
1450: ParseHTMLSpecificStyle (context->lastElement, attrValue,
1.115 quint 1451: context->doc, 200, FALSE);
1.48 vatton 1452: done = TRUE;
1453: }
1454: else
1455: {
1456: if (!strcmp (lastMappedAttr->XMLattribute, "link"))
1.89 vatton 1457: HTMLSetAlinkColor (context->doc, context->lastElement, attrValue);
1.48 vatton 1458: else if (!strcmp (lastMappedAttr->XMLattribute, "alink"))
1.89 vatton 1459: HTMLSetAactiveColor (context->doc, context->lastElement, attrValue);
1.48 vatton 1460: else if (!strcmp (lastMappedAttr->XMLattribute, "vlink"))
1.89 vatton 1461: HTMLSetAvisitedColor (context->doc, context->lastElement, attrValue);
1.48 vatton 1462: }
1.30 cvs 1463:
1.48 vatton 1464: if (!done)
1465: {
1.109 vatton 1466: elType = TtaGetElementType (lastAttrElement);
1.48 vatton 1467: val = 0;
1468: translation = lastMappedAttr->AttrOrContent;
1469: switch (translation)
1470: {
1471: case 'C': /* Content */
1472: child = PutInContent (attrValue, context);
1473: if (child != NULL)
1.100 gully 1474: TtaAppendTextContent (child, (unsigned char *)"\" ", context->doc);
1.48 vatton 1475: break;
1476: case 'A':
1477: if (currentAttribute != NULL)
1478: {
1479: TtaGiveAttributeType (currentAttribute, &attrType, &attrKind);
1480: switch (attrKind)
1481: {
1482: case 0: /* enumerate */
1483: if (isXML)
1.100 gully 1484: MapHTMLAttributeValue (attrValue, &attrType, &val);
1.48 vatton 1485: else
1486: val = MapAttrValue (lastMappedAttr->ThotAttribute,
1.40 cvs 1487: attrValue);
1.48 vatton 1488: if (val < 0)
1489: {
1490: TtaGiveAttributeType (currentAttribute,
1491: &attrType, &attrKind);
1492: attrName = TtaGetAttributeName (attrType);
1493: sprintf (msgBuffer,
1.51 cvs 1494: "Invalid attribute value \"%s = %s\"",
1.48 vatton 1495: attrName, attrValue);
1496: if (isXML)
1.100 gully 1497: XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
1.48 vatton 1498: else
1.84 quint 1499: /* we are parsing an HTML file, not an XHTML file */
1.51 cvs 1500: {
1.84 quint 1501: /* generate an error message in the log */
1.51 cvs 1502: HTMLParseError (context->doc, msgBuffer);
1.84 quint 1503: /* special case for value POLYGON of attribute
1504: shape (AREA element) */
1505: if (attrType.AttrTypeNum == HTML_ATTR_shape &&
1506: strcasecmp (attrValue, "POLYGON") == 0)
1507: {
1508: val = HTML_ATTR_shape_VAL_polygon;
1509: /* interpret it as if it were "poly" */
1510: TtaSetAttributeValue (currentAttribute, val,
1511: lastAttrElement, context->doc);
1512: }
1513: else
1514: /* remove the attribute and replace it by an */
1515: /* Invalid_attribute (not for XHTML) */
1516: {
1517: TtaRemoveAttribute (lastAttrElement,
1.51 cvs 1518: currentAttribute, context->doc);
1.109 vatton 1519: attrType.AttrSSchema = elType.ElSSchema;
1.84 quint 1520: attrType.AttrTypeNum =
1521: pHTMLAttributeMapping[0].ThotAttribute;
1522: sprintf (msgBuffer, "%s=%s", attrName,attrValue);
1523: CreateHTMLAttribute (lastAttrElement, attrType,
1524: msgBuffer, TRUE, context->doc,
1525: ¤tAttribute, &lastAttrElement);
1526: }
1.48 vatton 1527: }
1528: }
1529: else
1530: TtaSetAttributeValue (currentAttribute, val,
1531: lastAttrElement, context->doc);
1532: break;
1533: case 1: /* integer */
1534: if (attrType.AttrTypeNum == HTML_ATTR_Border &&
1535: !strcasecmp (attrValue, "border"))
1536: {
1537: /* border="border" for a table */
1538: val = 1;
1539: TtaSetAttributeValue (currentAttribute, val,
1.30 cvs 1540: lastAttrElement, context->doc);
1.48 vatton 1541: }
1542: else if (sscanf (attrValue, "%d", &val))
1543: TtaSetAttributeValue (currentAttribute, val,
1544: lastAttrElement, context->doc);
1545: else
1546: {
1547: TtaRemoveAttribute (lastAttrElement, currentAttribute,
1548: context->doc);
1549: sprintf (msgBuffer,
1550: "Unknown attribute value \"%s\"",
1551: attrValue);
1552: if (isXML)
1.100 gully 1553: XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0);
1.48 vatton 1554: else
1555: HTMLParseError (context->doc, msgBuffer);
1556: }
1557: break;
1558: case 2: /* text */
1559: if (!UnknownAttr)
1560: {
1561: TtaSetAttributeText (currentAttribute, attrValue,
1562: lastAttrElement, context->doc);
1.55 cvs 1563: if (attrType.AttrTypeNum == HTML_ATTR_Language)
1.48 vatton 1564: {
1565: /* it's a LANG attribute value */
1566: lang = TtaGetLanguageIdFromName (attrValue);
1.70 vatton 1567: if (lang < 0)
1.48 vatton 1568: {
1569: sprintf (msgBuffer,
1570: "warning - unsupported language: %s",
1571: attrValue);
1572: if (isXML)
1.100 gully 1573: XmlParseError (warningMessage, (unsigned char *)msgBuffer, 0);
1.48 vatton 1574: else
1575: HTMLParseError (context->doc, msgBuffer);
1576: }
1577: else
1578: {
1579: /* change current language */
1580: context->language = lang;
1581: if (isXML)
1582: SetLanguagInXmlStack (lang);
1583: else
1584: SetLanguagInHTMLStack (lang);
1585: }
1586: root = TtaGetRootElement (context->doc);
1587: if (lastAttrElement == root)
1588: /* it's a LANG attribute on the root element */
1589: /* set the RealLang attribute */
1590: {
1.109 vatton 1591: attrType1.AttrSSchema = elType.ElSSchema;
1.48 vatton 1592: attrType1.AttrTypeNum = HTML_ATTR_RealLang;
1593: /* this attribute could be already present,
1594: (lang and xml:lang attributes) */
1595: if (!TtaGetAttribute (lastAttrElement,
1596: attrType1))
1597: /* it's not present. Add it */
1598: {
1599: attr = TtaNewAttribute (attrType1);
1600: TtaAttachAttribute (lastAttrElement,
1601: attr, context->doc);
1602: TtaSetAttributeValue (attr,
1603: HTML_ATTR_RealLang_VAL_Yes_,
1604: lastAttrElement,
1605: context->doc);
1606: }
1607: }
1608: }
1609: else if (attrType.AttrTypeNum == HTML_ATTR_accesskey)
1610: TtaAddAccessKey (context->doc, (unsigned int)attrValue[0],
1611: lastAttrElement);
1612: }
1613: else
1614: {
1.51 cvs 1615: /* this is the content of an invalid attribute */
1616: /* append it to the current Invalid_attribute */
1617: if (!isXML)
1618: {
1619: length = strlen (attrValue) + 2;
1620: length += TtaGetTextAttributeLength (currentAttribute);
1.100 gully 1621: buffer = (char *)TtaGetMemory (length + 1);
1.51 cvs 1622: TtaGiveTextAttributeValue (currentAttribute,
1623: buffer, &length);
1624: strcat (buffer, "=");
1625: strcat (buffer, attrValue);
1626: TtaSetAttributeText (currentAttribute, buffer,
1627: lastAttrElement, context->doc);
1628: TtaFreeMemory (buffer);
1629: }
1.48 vatton 1630: }
1631: break;
1632: case 3: /* reference */
1633: break;
1634: }
1635: }
1636: break;
1637: case SPACE:
1638: if (isXML)
1639: XhtmlTypeAttrValue (attrValue, currentAttribute,
1.30 cvs 1640: lastAttrElement, context);
1.48 vatton 1641: else
1642: HTMLTypeAttrValue (attrValue, currentAttribute,
1643: lastAttrElement, context);
1.109 vatton 1644: break;
1.30 cvs 1645: default:
1646: break;
1.48 vatton 1647: }
1.30 cvs 1648:
1649: if (lastMappedAttr->ThotAttribute == HTML_ATTR_Width__)
1.79 quint 1650: /* HTML attribute "width" */
1651: {
1652: /* if it's an Object element, wait until all attributes are handled,
1653: especially the data attribute that may generate the image to
1654: which the width has to be applied */
1655: if (elType.ElTypeNum != HTML_EL_Object)
1656: /* create the corresponding attribute IntWidthPercent or */
1657: /* IntWidthPxl */
1658: CreateAttrWidthPercentPxl (attrValue, lastAttrElement,
1659: context->doc, -1);
1660: }
1.58 vatton 1661: else if (lastMappedAttr->ThotAttribute == HTML_ATTR_Height_)
1.79 quint 1662: /* HTML attribute "height" */
1663: {
1664: /* if it's an Object element, wait until all attributes are handled,
1665: especially the data attribute that may generate the image to
1666: which the height has to be applied */
1667: if (elType.ElTypeNum != HTML_EL_Object)
1668: /* create the corresponding attribute IntHeightPercent or */
1669: /* IntHeightPxl */
1670: CreateAttrHeightPercentPxl (attrValue, lastAttrElement,
1671: context->doc, -1);
1672: }
1.91 quint 1673: else if (lastMappedAttr->ThotAttribute == HTML_ATTR_Area_Size)
1674: /* HTML attribute "size" for an element "input" */
1675: CreateAttrIntAreaSize (val, lastAttrElement, context->doc);
1.48 vatton 1676: else if (!strcmp (lastMappedAttr->XMLattribute, "size"))
1677: {
1678: TtaGiveAttributeType (currentAttribute, &attrType, &attrKind);
1679: if (attrType.AttrTypeNum == HTML_ATTR_Font_size)
1680: CreateAttrIntSize (attrValue, lastAttrElement, context->doc);
1681: }
1682: else if (!strcmp (lastMappedAttr->XMLattribute, "shape"))
1683: {
1684: child = TtaGetFirstChild (lastAttrElement);
1685: if (child != NULL)
1686: {
1687: switch (val)
1688: {
1689: case HTML_ATTR_shape_VAL_rectangle:
1690: shape = 'R';
1691: break;
1692: case HTML_ATTR_shape_VAL_circle:
1693: shape = 'a';
1694: break;
1695: case HTML_ATTR_shape_VAL_polygon:
1696: shape = 'p';
1697: break;
1698: default:
1699: shape = SPACE;
1700: break;
1701: }
1702: TtaSetGraphicsShape (child, shape, context->doc);
1703: }
1704: }
1705: else if (!strcmp (lastMappedAttr->XMLattribute, "value"))
1706: {
1707: if (elType.ElTypeNum == HTML_EL_Text_Input ||
1708: elType.ElTypeNum == HTML_EL_Password_Input ||
1709: elType.ElTypeNum == HTML_EL_File_Input ||
1710: elType.ElTypeNum == HTML_EL_Input)
1711: /* create a Default_Value attribute with the same content */
1712: {
1713: attrType1.AttrSSchema = attrType.AttrSSchema;
1714: attrType1.AttrTypeNum = HTML_ATTR_Default_Value;
1715: attr = TtaNewAttribute (attrType1);
1716: TtaAttachAttribute (lastAttrElement, attr, context->doc);
1717: TtaSetAttributeText (attr, attrValue,
1718: lastAttrElement, context->doc);
1719: }
1720: }
1.30 cvs 1721: else
1.48 vatton 1722: {
1723: /* Some HTML attributes are equivalent to a CSS property: */
1724: /* background -> background */
1725: /* bgcolor -> background */
1726: /* text -> color */
1727: /* color -> color */
1728: if (!strcmp (lastMappedAttr->XMLattribute, "background"))
1729: {
1730: if (strlen (attrValue) > MaxMsgLength - 30)
1731: attrValue[MaxMsgLength - 30] = EOS;
1.76 vatton 1732: HTMLSetBackgroundImage (context->doc, context->lastElement,
1.108 vatton 1733: REPEAT, 0, attrValue, FALSE);
1.48 vatton 1734: }
1735: else if (!strcmp (lastMappedAttr->XMLattribute, "bgcolor"))
1.76 vatton 1736: HTMLSetBackgroundColor (context->doc, context->lastElement,
1.108 vatton 1737: 0, attrValue);
1.48 vatton 1738: else if (!strcmp (lastMappedAttr->XMLattribute, "text") ||
1739: !strcmp (lastMappedAttr->XMLattribute, "color"))
1.108 vatton 1740: HTMLSetForegroundColor (context->doc, context->lastElement,
1741: 0, attrValue);
1.48 vatton 1742: }
1743: }
1.30 cvs 1744: }
1745:
1746: /*----------------------------------------------------------------------
1.16 cvs 1747: MapHTMLAttributeValue
1.2 cvs 1748: Search in the Attribute Value Mapping Table the entry for the attribute
1.66 vatton 1749: ThotAtt and its value attVal. Returns the corresponding Thot value.
1.1 cvs 1750: ----------------------------------------------------------------------*/
1.100 gully 1751: void MapHTMLAttributeValue (char *attVal, const AttributeType * attrType, int *value)
1.1 cvs 1752: {
1.66 vatton 1753: MapXMLAttributeValue (XHTML_TYPE, attVal, attrType, value);
1.1 cvs 1754: }
Webmaster