version 1.134, 2006/06/30 13:03:14
|
version 1.135, 2006/07/05 12:25:19
|
Line 312 void XhtmlElementComplete (ParserData *c
|
Line 312 void XhtmlElementComplete (ParserData *c
|
elFrames, lastFrame, lastChild, parent, picture, content; |
elFrames, lastFrame, lastChild, parent, picture, content; |
Attribute attr; |
Attribute attr; |
AttributeType attrType; |
AttributeType attrType; |
|
SSchema htmlSchema; |
Language lang; |
Language lang; |
char *text; |
char *text, *ptr; |
char lastChar[2]; |
char lastChar[2]; |
char *name1, *data; |
char *name1, *data; |
int length; |
|
SSchema htmlSchema; |
|
ThotBool isImage, isInline, clean; |
|
char msgBuffer[MaxMsgLength]; |
char msgBuffer[MaxMsgLength]; |
int lineNum; |
int lineNum, typenum, length; |
|
ThotBool isImage, isInline, clean; |
|
|
*error = 0; |
*error = 0; |
doc = context->doc; |
doc = context->doc; |
Line 368 void XhtmlElementComplete (ParserData *c
|
Line 367 void XhtmlElementComplete (ParserData *c
|
elType.ElTypeNum != HTML_EL_XMLPI) |
elType.ElTypeNum != HTML_EL_XMLPI) |
BlockInCharLevelElem (el); |
BlockInCharLevelElem (el); |
|
|
switch (elType.ElTypeNum) |
typenum = elType.ElTypeNum; |
|
switch (typenum) |
{ |
{ |
case HTML_EL_PICTURE_UNIT: |
case HTML_EL_PICTURE_UNIT: |
/* Check the mandatory SRC attribute */ |
/* Check the mandatory SRC attribute */ |
Line 545 void XhtmlElementComplete (ParserData *c
|
Line 545 void XhtmlElementComplete (ParserData *c
|
TtaFreeMemory (data); |
TtaFreeMemory (data); |
break; |
break; |
|
|
|
case HTML_EL_Image_Input: |
case HTML_EL_IMG: |
case HTML_EL_IMG: |
/* Check the mandatory ALT attribute */ |
/* Check the mandatory ALT attribute */ |
CheckMandatoryAttribute (el, doc, HTML_ATTR_ALT); |
CheckMandatoryAttribute (el, doc, HTML_ATTR_ALT); |
Line 601 void XhtmlElementComplete (ParserData *c
|
Line 602 void XhtmlElementComplete (ParserData *c
|
TtaFreeMemory (data); |
TtaFreeMemory (data); |
} |
} |
} |
} |
attrType.AttrTypeNum = HTML_ATTR_Height_; |
if (typenum == HTML_EL_IMG) |
attr = TtaGetAttribute (el, attrType); |
|
if (attr) |
|
/* the img has a height attribute. Applies it to the |
|
picture element */ |
|
{ |
{ |
length = TtaGetTextAttributeLength (attr); |
attrType.AttrTypeNum = HTML_ATTR_Height_; |
if (length > 0) |
attr = TtaGetAttribute (el, attrType); |
|
if (attr) |
|
/* the img has a height attribute. Applies it to the |
|
picture element */ |
{ |
{ |
text = (char *)TtaGetMemory (length + 1); |
length = TtaGetTextAttributeLength (attr); |
TtaGiveTextAttributeValue (attr, text, &length); |
if (length > 0) |
/* create the corresponding attribute IntHeightPercent or */ |
{ |
/* IntHeightPxl */ |
text = (char *)TtaGetMemory (length + 1); |
CreateAttrHeightPercentPxl (text, el, doc, -1); |
TtaGiveTextAttributeValue (attr, text, &length); |
TtaFreeMemory (text); |
/* create the corresponding attribute IntHeightPercent or */ |
|
/* IntHeightPxl */ |
|
CreateAttrHeightPercentPxl (text, el, doc, -1); |
|
TtaFreeMemory (text); |
|
} |
} |
} |
} |
attrType.AttrTypeNum = HTML_ATTR_Width__; |
attrType.AttrTypeNum = HTML_ATTR_Width__; |
attr = TtaGetAttribute (el, attrType); |
attr = TtaGetAttribute (el, attrType); |
if (attr) |
if (attr) |
/* the img has a width attribute. Applies it to the |
/* the img has a width attribute. Applies it to the |
picture element */ |
picture element */ |
|
{ |
|
length = TtaGetTextAttributeLength (attr); |
|
if (length > 0) |
|
{ |
{ |
text = (char *)TtaGetMemory (length + 1); |
length = TtaGetTextAttributeLength (attr); |
TtaGiveTextAttributeValue (attr, text, &length); |
if (length > 0) |
/* create the corresponding attribute IntWidthPercent or */ |
{ |
/* IntWidthPxl */ |
text = (char *)TtaGetMemory (length + 1); |
CreateAttrWidthPercentPxl (text, el, doc, -1); |
TtaGiveTextAttributeValue (attr, text, &length); |
TtaFreeMemory (text); |
/* create the corresponding attribute IntWidthPercent or */ |
|
/* IntWidthPxl */ |
|
CreateAttrWidthPercentPxl (text, el, doc, -1); |
|
TtaFreeMemory (text); |
|
} |
} |
} |
} |
} |
break; |
break; |
|
|
case HTML_EL_Parameter: |
case HTML_EL_Parameter: |
Line 1232 void CreateHTMLAttribute (Element
|
Line 1236 void CreateHTMLAttribute (Element
|
} |
} |
} |
} |
|
|
/*---------------------------------------------------------------------- |
|
HTMLTypeAttrValue |
|
Value val has been read for the HTML attribute TYPE. |
|
Create a child for the current Thot element INPUT accordingly. |
|
----------------------------------------------------------------------*/ |
|
void HTMLTypeAttrValue (char *val, Attribute lastAttribute, |
|
Element lastAttrElement, ParserData *context) |
|
{ |
|
ElementType elType; |
|
Element newChild; |
|
AttributeType attrType; |
|
Attribute attr; |
|
char msgBuffer[MaxMsgLength]; |
|
int value; |
|
int numberOfLinesRead; |
|
|
|
value = MapAttrValue (DummyAttribute, val); |
|
elType = TtaGetElementType (context->lastElement); |
|
if (value <= 0) |
|
{ |
|
if (strlen (val) > MaxMsgLength - 40) |
|
val[MaxMsgLength - 40] = EOS; |
|
sprintf (msgBuffer, "Unknown attribute value \"type = %s\"", val); |
|
HTMLParseError (context->doc, msgBuffer, 0); |
|
attrType.AttrSSchema = elType.ElSSchema; |
|
attrType.AttrTypeNum = pHTMLAttributeMapping[0].ThotAttribute; |
|
sprintf (msgBuffer, "type=%s", val); |
|
CreateHTMLAttribute (context->lastElement, attrType, msgBuffer, TRUE, |
|
context->doc, &lastAttribute, &lastAttrElement); |
|
} |
|
else |
|
{ |
|
if (elType.ElTypeNum != HTML_EL_Input) |
|
{ |
|
if (strlen (val) > MaxMsgLength - 40) |
|
val[MaxMsgLength - 40] = EOS; |
|
sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val); |
|
} |
|
else |
|
{ |
|
elType.ElTypeNum = value; |
|
newChild = TtaNewTree (context->doc, elType, ""); |
|
numberOfLinesRead = 0; |
|
TtaSetElementLineNumber (newChild, numberOfLinesRead); |
|
TtaInsertFirstChild (&newChild, context->lastElement, context->doc); |
|
if (value == HTML_EL_PICTURE_UNIT) |
|
{ |
|
/* add the attribute IsInput to input pictures */ |
|
attrType.AttrSSchema = elType.ElSSchema; |
|
attrType.AttrTypeNum = HTML_ATTR_IsInput; |
|
attr = TtaNewAttribute (attrType); |
|
TtaAttachAttribute (newChild, attr, context->doc); |
|
} |
|
} |
|
} |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
XhtmlTypeAttrValue |
XhtmlTypeAttrValue |
Value val has been read for the HTML attribute TYPE. |
Value val has been read for the HTML attribute TYPE. |
Create a child for the current Thot element INPUT accordingly. |
Create a child for the current Thot element INPUT accordingly. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
void XhtmlTypeAttrValue (char *val, |
static void XhtmlTypeAttrValue (char *val, |
Attribute currentAttribute, |
Attribute currentAttribute, |
Element lastAttrElement, |
Element lastAttrElement, |
ParserData *context) |
ParserData *context, ThotBool isXML) |
{ |
{ |
ElementType elType; |
ElementType elType; |
Element newChild; |
Element newChild; |
AttributeType attrType; |
AttributeType attrType; |
Attribute attr; |
Attribute attr; |
char msgBuffer[MaxMsgLength]; |
char msgBuffer[MaxMsgLength]; |
int value; |
int value, nb; |
ThotBool level; |
ThotBool level; |
|
|
/* Look in the dummy section of the attribute value table */ |
/* Look in the dummy section of the attribute value table */ |
attrType.AttrTypeNum = DummyAttribute; |
attrType.AttrTypeNum = DummyAttribute; |
MapHTMLAttributeValue (val, &attrType, &value); |
MapHTMLAttributeValue (val, &attrType, &value); |
|
elType = TtaGetElementType (context->lastElement); |
if (value <= 0) |
if (value <= 0) |
/* invalid value for the type attribute of an input element */ |
/* invalid value for the type attribute of an input element */ |
{ |
{ |
sprintf (msgBuffer, "Unknown attribute value \"type=%s\"", val); |
sprintf (msgBuffer, "Unknown attribute value \"type=%s\"", val); |
XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0); |
if (isXML) |
|
XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0); |
|
else |
|
HTMLParseError (context->doc, msgBuffer, 0); |
MapHTMLAttribute ("unknown_attr", &attrType, NULL, |
MapHTMLAttribute ("unknown_attr", &attrType, NULL, |
&level, context->doc); |
&level, context->doc); |
sprintf (msgBuffer, "type=%s", val); |
sprintf (msgBuffer, "type=%s", val); |
Line 1325 void XhtmlTypeAttrValue (char *val
|
Line 1277 void XhtmlTypeAttrValue (char *val
|
/* value is the Thot type of the element to be created for this value of |
/* value is the Thot type of the element to be created for this value of |
the TYPE attribute */ |
the TYPE attribute */ |
{ |
{ |
elType = TtaGetElementType (context->lastElement); |
|
if (elType.ElTypeNum != HTML_EL_Input) |
if (elType.ElTypeNum != HTML_EL_Input) |
{ |
{ |
sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val); |
sprintf (msgBuffer, "Duplicate attribute \"type = %s\"", val); |
XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0); |
if (isXML) |
|
XmlParseError (errorParsing, (unsigned char *)msgBuffer, 0); |
|
else |
|
HTMLParseError (context->doc, msgBuffer, 0); |
} |
} |
else |
else |
{ |
{ |
elType.ElTypeNum = value; |
elType.ElTypeNum = value; |
newChild = TtaNewTree (context->doc, elType, ""); |
newChild = TtaNewTree (context->doc, elType, ""); |
XmlSetElemLineNumber (newChild); |
|
|
nb = TtaGetElementLineNumber (context->lastElement); |
|
TtaSetElementLineNumber (newChild, nb); |
TtaInsertFirstChild (&newChild, context->lastElement, context->doc); |
TtaInsertFirstChild (&newChild, context->lastElement, context->doc); |
if (value == HTML_EL_PICTURE_UNIT) |
/* add the attribute type */ |
|
attrType.AttrSSchema = elType.ElSSchema; |
|
attrType.AttrTypeNum = HTML_ATTR_type; |
|
attr = TtaGetAttribute (newChild, attrType); |
|
if (attr == NULL) |
{ |
{ |
/* add the attribute IsInput to input pictures */ |
|
attrType.AttrSSchema = elType.ElSSchema; |
|
attrType.AttrTypeNum = HTML_ATTR_IsInput; |
|
attr = TtaNewAttribute (attrType); |
attr = TtaNewAttribute (attrType); |
TtaAttachAttribute (newChild, attr, context->doc); |
TtaAttachAttribute (newChild, attr, context->doc); |
} |
} |
Line 1376 void CreateAttrWidthPercentPxl (char *bu
|
Line 1333 void CreateAttrWidthPercentPxl (char *bu
|
elType.ElTypeNum == HTML_EL_Data_cell || |
elType.ElTypeNum == HTML_EL_Data_cell || |
elType.ElTypeNum == HTML_EL_Heading_cell || |
elType.ElTypeNum == HTML_EL_Heading_cell || |
elType.ElTypeNum == HTML_EL_Object || |
elType.ElTypeNum == HTML_EL_Object || |
elType.ElTypeNum == HTML_EL_IMG); |
elType.ElTypeNum == HTML_EL_IMG || |
|
elType.ElTypeNum == HTML_EL_Image_Input); |
|
|
if (elType.ElTypeNum == HTML_EL_Object) |
if (elType.ElTypeNum == HTML_EL_Object) |
/* the width attribute is attached to an Object element */ |
/* the width attribute is attached to an Object element */ |
Line 1626 void CreateAttrIntAreaSize (int value, E
|
Line 1584 void CreateAttrIntAreaSize (int value, E
|
|
|
elType = TtaGetElementType (el); |
elType = TtaGetElementType (el); |
attrType.AttrSSchema = elType.ElSSchema; |
attrType.AttrSSchema = elType.ElSSchema; |
attrType.AttrTypeNum = HTML_ATTR_IntAreaSize; |
if (elType.ElTypeNum == HTML_EL_Image_Input) |
attr = TtaGetAttribute (el, attrType); |
{ |
if (!attr) |
attrType.AttrTypeNum = HTML_ATTR_IntWidthPxl; |
|
attr = TtaGetAttribute (el, attrType); |
|
if (!attr) |
|
{ |
|
attr = TtaNewAttribute (attrType); |
|
TtaAttachAttribute (el, attr, doc); |
|
} |
|
/* the presentation rule associated with attribute IntWidthPxl */ |
|
TtaSetAttributeValue (attr, value, el, doc); |
|
} |
|
else |
{ |
{ |
attr = TtaNewAttribute (attrType); |
attrType.AttrTypeNum = HTML_ATTR_IntAreaSize; |
TtaAttachAttribute (el, attr, doc); |
attr = TtaGetAttribute (el, attrType); |
|
if (!attr) |
|
{ |
|
attr = TtaNewAttribute (attrType); |
|
TtaAttachAttribute (el, attr, doc); |
|
} |
|
/* the presentation rule associated with attribute IntAreaSize expresses |
|
the element width in "em". Convert the value into em */ |
|
TtaSetAttributeValue (attr, (int) (value * 0.40), el, doc); |
} |
} |
/* the presentation rule associated with attribute IntAreaSize expresses |
|
the element width in "em". Convert the value into em */ |
|
TtaSetAttributeValue (attr, (int) (value * 0.40), el, doc); |
|
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Line 1923 void EndOfHTMLAttributeValue (char *attr
|
Line 1896 void EndOfHTMLAttributeValue (char *attr
|
} |
} |
break; |
break; |
case SPACE: |
case SPACE: |
if (isXML) |
XhtmlTypeAttrValue (attrValue, currentAttribute, |
XhtmlTypeAttrValue (attrValue, currentAttribute, |
lastAttrElement, context,isXML ); |
lastAttrElement, context); |
|
else |
|
HTMLTypeAttrValue (attrValue, currentAttribute, |
|
lastAttrElement, context); |
|
break; |
break; |
default: |
default: |
break; |
break; |