version 1.123, 2001/07/02 08:08:27
|
version 1.124, 2001/07/09 07:10:38
|
Line 308 void MathMLEntityCreatedWithExpat (int
|
Line 308 void MathMLEntityCreatedWithExpat (int
|
int len; |
int len; |
Language lang; |
Language lang; |
#define MAX_ENTITY_LENGTH 80 |
#define MAX_ENTITY_LENGTH 80 |
char buffer[MAX_ENTITY_LENGTH]; |
char buffer[MAX_ENTITY_LENGTH]; |
char bufName[MAX_ENTITY_LENGTH]; |
char bufName[MAX_ENTITY_LENGTH]; |
char msgBuffer[MAX_ENTITY_LENGTH + 50]; |
char msgBuffer[MAX_ENTITY_LENGTH + 50]; |
|
|
if (entityValue <= 255 && entityFound) |
if (entityValue <= 255 && entityFound) |
{ |
{ |
Line 555 static void NextNotComment (Element* el,
|
Line 555 static void NextNotComment (Element* el,
|
CheckMathSubExpressions |
CheckMathSubExpressions |
Children of element el should be of type type1, type2, and type3. |
Children of element el should be of type type1, type2, and type3. |
If they are not, wrap them in elements of these types. |
If they are not, wrap them in elements of these types. |
If element el have too many or not enough children, return FALSE. |
If element el has too many or not enough children, return FALSE. |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
static ThotBool CheckMathSubExpressions (Element el, int type1, int type2, int type3, Document doc) |
static ThotBool CheckMathSubExpressions (Element el, int type1, int type2, int type3, Document doc) |
{ |
{ |
Element child, new, prev; |
Element child, new, prev; |
ElementType elType, childType; |
ElementType elType, childType; |
|
char msgBuffer[200]; |
ThotBool result; |
ThotBool result; |
|
|
result = TRUE; |
result = TRUE; |
Line 572 static ThotBool CheckMathSubExpressions
|
Line 573 static ThotBool CheckMathSubExpressions
|
{ |
{ |
if (child) |
if (child) |
/* no child expected and there is one, error */ |
/* no child expected and there is one, error */ |
result = FALSE; |
{ |
|
sprintf (msgBuffer, "No subexpression allowed in %s", |
|
TtaGetElementTypeName (TtaGetElementType (el))); |
|
XmlParseError (errorParsing, msgBuffer, 0); |
|
result = FALSE; |
|
} |
} |
} |
else |
else |
if (!child) |
if (!child) |
/* a first child is expected and it's missing */ |
/* a first child is expected and it's missing */ |
result = FALSE; |
{ |
|
sprintf (msgBuffer, "Missing subexpression in %s", |
|
TtaGetElementTypeName (TtaGetElementType (el))); |
|
XmlParseError (errorParsing, msgBuffer, 0); |
|
result = FALSE; |
|
} |
else |
else |
{ |
{ |
elType.ElTypeNum = type1; |
elType.ElTypeNum = type1; |
Line 601 static ThotBool CheckMathSubExpressions
|
Line 612 static ThotBool CheckMathSubExpressions
|
{ |
{ |
if (child) |
if (child) |
/* this second child is not expected, error */ |
/* this second child is not expected, error */ |
result = FALSE; |
{ |
|
sprintf (msgBuffer, "Only 1 subexpression allowed in %s", |
|
TtaGetElementTypeName (TtaGetElementType (el))); |
|
XmlParseError (errorParsing, msgBuffer, 0); |
|
result = FALSE; |
|
} |
} |
} |
else |
else |
{ |
{ |
if (!child) |
if (!child) |
/* a second child is expected and it's missing */ |
/* a second child is expected and it's missing */ |
result = FALSE; |
{ |
|
sprintf (msgBuffer, "2 subexpressions required in %s", |
|
TtaGetElementTypeName (TtaGetElementType (el))); |
|
XmlParseError (errorParsing, msgBuffer, 0); |
|
result = FALSE; |
|
} |
else |
else |
{ |
{ |
elType.ElTypeNum = type2; |
elType.ElTypeNum = type2; |
Line 628 static ThotBool CheckMathSubExpressions
|
Line 649 static ThotBool CheckMathSubExpressions
|
{ |
{ |
if (child) |
if (child) |
/* this third child is not expected, error */ |
/* this third child is not expected, error */ |
result = FALSE; |
{ |
|
sprintf (msgBuffer, "Only 2 subexpressions allowed in %s", |
|
TtaGetElementTypeName (TtaGetElementType (el))); |
|
XmlParseError (errorParsing, msgBuffer, 0); |
|
result = FALSE; |
|
} |
} |
} |
else |
else |
{ |
{ |
if (!child) |
if (!child) |
/* a third child is expected and it's missing */ |
/* a third child is expected and it's missing */ |
result = FALSE; |
{ |
|
sprintf (msgBuffer, "3 subexpressions required in %s", |
|
TtaGetElementTypeName (TtaGetElementType (el))); |
|
XmlParseError (errorParsing, msgBuffer, 0); |
|
result = FALSE; |
|
} |
else |
else |
{ |
{ |
elType.ElTypeNum = type3; |
elType.ElTypeNum = type3; |
Line 654 static ThotBool CheckMathSubExpressions
|
Line 685 static ThotBool CheckMathSubExpressions
|
NextNotComment (&child, &prev); |
NextNotComment (&child, &prev); |
if (child) |
if (child) |
/* this fourth child is unexpected */ |
/* this fourth child is unexpected */ |
result = FALSE; |
{ |
|
sprintf (msgBuffer,"Only 3 subexpressions allowed in %s", |
|
TtaGetElementTypeName (TtaGetElementType (el))); |
|
XmlParseError (errorParsing, msgBuffer, 0); |
|
result = FALSE; |
|
} |
} |
} |
} |
} |
} |
} |
Line 1312 void SetFontstyleAttr (Element el, Docum
|
Line 1348 void SetFontstyleAttr (Element el, Docum
|
else |
else |
/* MI contains a single character. Remove attribute IntFontstyle |
/* MI contains a single character. Remove attribute IntFontstyle |
if it exists, except if it's ImaginaryI, ExponentialE or |
if it exists, except if it's ImaginaryI, ExponentialE or |
DifferentialD. */ |
DifferentialD */ |
{ |
{ |
italic = TRUE; |
italic = TRUE; |
textEl = TtaGetFirstChild (el); |
textEl = TtaGetFirstChild (el); |
Line 1328 void SetFontstyleAttr (Element el, Docum
|
Line 1364 void SetFontstyleAttr (Element el, Docum
|
{ |
{ |
value = TtaGetMemory (len+1); |
value = TtaGetMemory (len+1); |
TtaGiveTextAttributeValue (attr, value, &len); |
TtaGiveTextAttributeValue (attr, value, &len); |
if (strcmp (value, "ⅈ") == 0 || |
if (strcmp (&value[1], "ImaginaryI;") == 0 || |
strcmp (value, "ⅇ") == 0 || |
strcmp (&value[1], "ExponentialE;") == 0 || |
strcmp (value, "ⅆ") == 0) |
strcmp (&value[1], "DifferentialD;") == 0) |
italic = FALSE; |
italic = FALSE; |
TtaFreeMemory (value); |
TtaFreeMemory (value); |
} |
} |
Line 1704 void CreateFencedSeparators (Element fen
|
Line 1740 void CreateFencedSeparators (Element fen
|
} |
} |
} |
} |
|
|
|
/*---------------------------------------------------------------------- |
|
CreateOpeningOrClosingFence |
|
Create the OpeningFence or ClosingFence element (depending on parameter |
|
open) for the MFENCED element el which contain the fencedExpression |
|
element. |
|
----------------------------------------------------------------------*/ |
|
static void CreateOpeningOrClosingFence (Element fencedExpression, |
|
Element el, Document doc, |
|
ThotBool open) |
|
{ |
|
ElementType elType; |
|
Element leaf, fence; |
|
AttributeType attrType; |
|
Attribute attr; |
|
int length; |
|
char text[32]; |
|
char c; |
|
|
|
elType = TtaGetElementType (el); |
|
attrType.AttrSSchema = elType.ElSSchema; |
|
if (open) |
|
{ |
|
c = '('; /* default value of attribute 'open' */ |
|
attrType.AttrTypeNum = MathML_ATTR_open; |
|
elType.ElTypeNum = MathML_EL_OpeningFence; |
|
} |
|
else |
|
{ |
|
c = ')'; /* default value of attribute 'close' */ |
|
attrType.AttrTypeNum = MathML_ATTR_close; |
|
elType.ElTypeNum = MathML_EL_ClosingFence; |
|
} |
|
attr = TtaGetAttribute (el, attrType); |
|
if (attr != NULL) |
|
{ |
|
length = 31; |
|
TtaGiveTextAttributeValue (attr, text, &length); |
|
if (length != 1) |
|
/* content of attribute open or close should be a single character */ |
|
c = '?'; |
|
else |
|
{ |
|
c = (char)text[0]; |
|
/* filter characters that would represent strange symbols, such |
|
as root, integrals, arrows, etc. */ |
|
if (c == 'r' || c == 'i' || c == 'c' || c == 'd' || c == 'S' || |
|
c == 'P' || c == 'I' || c == 'U' || c == 'o' || c == 'u' || |
|
c == 'h' || c == 'v' || c == 'R' || c == '^' || c == 'L' || |
|
c == 'V' || c == 'D') |
|
c = '?'; |
|
} |
|
} |
|
fence = TtaNewElement (doc, elType); |
|
TtaInsertSibling (fence, fencedExpression, open, doc); |
|
elType.ElTypeNum = MathML_EL_SYMBOL_UNIT; |
|
leaf = TtaNewElement (doc, elType); |
|
TtaInsertFirstChild (&leaf, fence, doc); |
|
TtaSetGraphicsShape (leaf, c, doc); |
|
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
TransformMFENCED |
TransformMFENCED |
Line 1713 void CreateFencedSeparators (Element fen
|
Line 1808 void CreateFencedSeparators (Element fen
|
static void TransformMFENCED (Element el, Document doc) |
static void TransformMFENCED (Element el, Document doc) |
{ |
{ |
ElementType elType; |
ElementType elType; |
Element child, fencedExpression, leaf, fence, next, prev, |
Element child, fencedExpression, next, prev, firstChild; |
firstChild; |
|
AttributeType attrType; |
|
Attribute attr; |
|
int length; |
|
char text[32]; |
|
char c; |
|
|
|
child = TtaGetFirstChild (el); |
child = TtaGetFirstChild (el); |
if (child != NULL) |
if (child != NULL) |
Line 1799 static void TransformMFENCED (Eleme
|
Line 1888 static void TransformMFENCED (Eleme
|
} |
} |
|
|
/* create the OpeningFence element according to the open attribute */ |
/* create the OpeningFence element according to the open attribute */ |
c = '('; |
CreateOpeningOrClosingFence (fencedExpression, el, doc, TRUE); |
attrType.AttrSSchema = elType.ElSSchema; |
|
attrType.AttrTypeNum = MathML_ATTR_open; |
|
attr = TtaGetAttribute (el, attrType); |
|
if (attr != NULL) |
|
{ |
|
length = 7; |
|
TtaGiveTextAttributeValue (attr, text, &length); |
|
c = (char)text[0]; |
|
} |
|
elType.ElTypeNum = MathML_EL_OpeningFence; |
|
fence = TtaNewElement (doc, elType); |
|
TtaInsertSibling (fence, fencedExpression, TRUE, doc); |
|
elType.ElTypeNum = MathML_EL_SYMBOL_UNIT; |
|
leaf = TtaNewElement (doc, elType); |
|
TtaInsertFirstChild (&leaf, fence, doc); |
|
TtaSetGraphicsShape (leaf, c, doc); |
|
|
|
/* create the ClosingFence element according to close attribute */ |
/* create the ClosingFence element according to close attribute */ |
c = ')'; |
CreateOpeningOrClosingFence (fencedExpression, el, doc, FALSE); |
attrType.AttrTypeNum = MathML_ATTR_close; |
|
attr = TtaGetAttribute (el, attrType); |
|
if (attr != NULL) |
|
{ |
|
length = 7; |
|
TtaGiveTextAttributeValue (attr, text, &length); |
|
c = (char) text[0]; |
|
} |
|
elType.ElTypeNum = MathML_EL_ClosingFence; |
|
fence = TtaNewElement (doc, elType); |
|
TtaInsertSibling (fence, fencedExpression, FALSE, doc); |
|
elType.ElTypeNum = MathML_EL_SYMBOL_UNIT; |
|
leaf = TtaNewElement (doc, elType); |
|
TtaInsertFirstChild (&leaf, fence, doc); |
|
TtaSetGraphicsShape (leaf, c, doc); |
|
} |
} |
} |
} |
|
|