version 1.130, 2001/11/26 12:02:38
|
version 1.131, 2001/12/03 08:27:54
|
Line 713 void SetIntVertStretchAttr (Element el,
|
Line 713 void SetIntVertStretchAttr (Element el,
|
ElementType elType; |
ElementType elType; |
Attribute attr; |
Attribute attr; |
AttributeType attrType; |
AttributeType attrType; |
|
SSchema MathMLSSchema; |
Language lang; |
Language lang; |
char alphabet; |
char alphabet; |
CHAR_T text[2]; |
#define buflen 50 |
|
CHAR_T text[buflen]; |
unsigned char c; |
unsigned char c; |
int len; |
int len, i; |
|
ThotBool inbase, integral; |
|
|
if (el == NULL) |
if (el == NULL) |
return; |
return; |
operator = NULL; |
operator = NULL; |
|
inbase = FALSE; |
|
MathMLSSchema = TtaGetElementType(el).ElSSchema; |
|
|
if (base == 0) |
if (base == 0) |
/* it's a MO */ |
/* it's a MO */ |
{ |
{ |
parent = TtaGetParent (el); |
parent = TtaGetParent (el); |
if (parent != NULL) |
if (parent != NULL) |
{ |
{ |
elType = TtaGetElementType (parent); |
/* don't process the mo if it is within a base. It will be processed |
if (elType.ElTypeNum != MathML_EL_Base && |
when the enclosing construct is processed (see below) */ |
elType.ElTypeNum != MathML_EL_UnderOverBase && |
elType = TtaGetElementType (parent); |
elType.ElTypeNum != MathML_EL_MSUBSUP && |
if (elType.ElSSchema != MathMLSSchema || |
elType.ElTypeNum != MathML_EL_MSUB && |
(elType.ElTypeNum != MathML_EL_Base && |
elType.ElTypeNum != MathML_EL_MSUP && |
elType.ElTypeNum != MathML_EL_UnderOverBase && |
elType.ElTypeNum != MathML_EL_MUNDEROVER && |
elType.ElTypeNum != MathML_EL_MSUBSUP && |
elType.ElTypeNum != MathML_EL_MUNDER && |
elType.ElTypeNum != MathML_EL_MSUB && |
elType.ElTypeNum != MathML_EL_MUNDEROVER) |
elType.ElTypeNum != MathML_EL_MSUP && |
operator = el; |
elType.ElTypeNum != MathML_EL_MUNDEROVER && |
|
elType.ElTypeNum != MathML_EL_MUNDER && |
|
elType.ElTypeNum != MathML_EL_MUNDEROVER)) |
|
operator = el; |
} |
} |
} |
} |
else |
else |
/* it's not a MO */ |
/* it's not a MO */ |
{ |
{ |
/* search the Base or UnderOverBase child */ |
/* search the Base or UnderOverBase child */ |
child = TtaGetFirstChild (el); |
child = TtaGetFirstChild (el); |
if (child != NULL) |
if (child != NULL) |
{ |
{ |
elType = TtaGetElementType (child); |
elType = TtaGetElementType (child); |
if (elType.ElTypeNum == base) |
if (elType.ElTypeNum == base && elType.ElSSchema == MathMLSSchema) |
/* the first child is a Base or UnderOverBase */ |
/* the first child is a Base or UnderOverBase */ |
{ |
{ |
child = TtaGetFirstChild (child); |
child = TtaGetFirstChild (child); |
if (child != NULL) |
if (child != NULL) |
{ |
{ |
elType = TtaGetElementType (child); |
elType = TtaGetElementType (child); |
if (elType.ElTypeNum == MathML_EL_MO) |
if (elType.ElTypeNum == MathML_EL_MO && |
/* its first child is a MO */ |
elType.ElSSchema == MathMLSSchema) |
{ |
/* its first child is a MO */ |
sibling = child; |
{ |
TtaNextSibling (&sibling); |
sibling = child; |
if (sibling == NULL) |
TtaNextSibling (&sibling); |
/* there is no other child */ |
if (sibling == NULL) |
operator = child; |
/* there is no other child */ |
} |
{ |
} |
operator = child; |
} |
if (base == MathML_EL_Base || |
|
base == MathML_EL_UnderOverBase) |
|
{ |
|
parent = el; |
|
inbase = TRUE; |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
} |
if (operator != NULL) |
if (operator) |
{ |
{ |
textEl = TtaGetFirstChild (operator); |
textEl = TtaGetFirstChild (operator); |
if (textEl != NULL) |
if (textEl != NULL) |
{ |
{ |
elType = TtaGetElementType (textEl); |
elType = TtaGetElementType (textEl); |
if (elType.ElTypeNum == MathML_EL_TEXT_UNIT) |
if (elType.ElTypeNum == MathML_EL_TEXT_UNIT) |
{ |
{ |
len = TtaGetVolume (textEl); |
len = TtaGetVolume (textEl); |
if (len == 1) |
if (len >= 1) |
{ |
{ |
len = 2; |
if (len >= buflen) |
TtaGiveBufferContent (textEl, text, len, &lang); |
len = buflen-1; |
alphabet = TtaGetAlphabet (lang); |
len++; |
if (alphabet == 'G') |
TtaGiveBufferContent (textEl, text, len, &lang); |
/* a single Symbol character */ |
len --; |
if (text[0] == 242) |
alphabet = TtaGetAlphabet (lang); |
/* Integral */ |
if (alphabet == 'G') |
|
/* Adobe Symbol character set */ |
{ |
{ |
/* attach a IntVertStretch attribute */ |
integral = TRUE; |
attrType.AttrSSchema = elType.ElSSchema; |
/* check all characters in this TEXT element */ |
attrType.AttrTypeNum = MathML_ATTR_IntVertStretch; |
for (i = 0; i < len; i++) |
attr = TtaNewAttribute (attrType); |
if (text[i] != 242) |
TtaAttachAttribute (el, attr, doc); |
/**** accept also other symbols like double or triple |
TtaSetAttributeValue (attr, |
integral, contour integral, etc. ****/ |
MathML_ATTR_IntVertStretch_VAL_yes_, |
integral = FALSE; |
el, doc); |
if (integral) |
/* replace the TEXT element by a Thot SYMBOL element*/ |
/* the operator contains only integral symbols */ |
elType.ElTypeNum = MathML_EL_SYMBOL_UNIT; |
{ |
symbolEl = TtaNewElement (doc, elType); |
/* attach a IntVertStretch attribute */ |
TtaInsertSibling (symbolEl, textEl, FALSE, doc); |
attrType.AttrSSchema = MathMLSSchema; |
if (selEl != NULL) |
attrType.AttrTypeNum = MathML_ATTR_IntVertStretch; |
if (*selEl == textEl) |
attr = TtaNewAttribute (attrType); |
*selEl = symbolEl; |
TtaAttachAttribute (el, attr, doc); |
TtaDeleteTree (textEl, doc); |
TtaSetAttributeValue (attr, |
c = 'i'; |
MathML_ATTR_IntVertStretch_VAL_yes_, |
TtaSetGraphicsShape (symbolEl, c, doc); |
el, doc); |
|
TtaRegisterAttributeCreate (attr, el, doc); |
|
|
|
/* replace the Integral characters by a Thot SYMBOL |
|
element. If there are several such characters in |
|
the mo (multiple integral), replace them too. */ |
|
do |
|
{ |
|
/* replace the TEXT element by a Thot SYMBOL */ |
|
elType.ElTypeNum = MathML_EL_SYMBOL_UNIT; |
|
elType.ElSSchema = MathMLSSchema; |
|
for (i = 0; i < len; i++) |
|
if (text[i] == 242) |
|
{ |
|
symbolEl = TtaNewElement (doc, elType); |
|
TtaInsertSibling (symbolEl, textEl, TRUE,doc); |
|
if (selEl != NULL) |
|
if (*selEl == textEl) |
|
*selEl = symbolEl; |
|
c = 'i'; |
|
TtaSetGraphicsShape (symbolEl, c, doc); |
|
TtaRegisterElementCreate (symbolEl, doc); |
|
} |
|
TtaRegisterElementDelete (textEl, doc); |
|
TtaDeleteTree (textEl, doc); |
|
/* is there an other text element after the |
|
integral symbol? */ |
|
textEl = symbolEl; TtaNextSibling (&textEl); |
|
if (textEl) |
|
{ |
|
elType = TtaGetElementType (textEl); |
|
if (elType.ElTypeNum != MathML_EL_TEXT_UNIT) |
|
textEl = NULL; |
|
else |
|
/* there is another text element. |
|
Is it a single integral symbol? */ |
|
{ |
|
len = TtaGetVolume (textEl); |
|
if (len < 1) |
|
/* not a single character */ |
|
textEl = NULL; |
|
else |
|
{ |
|
if (len >= buflen) |
|
len = buflen-1; |
|
len++; |
|
TtaGiveBufferContent (textEl, text, |
|
len, &lang); |
|
alphabet = TtaGetAlphabet (lang); |
|
if (alphabet != 'G') |
|
/* not the right alphabet for an |
|
integral*/ |
|
textEl = NULL; |
|
else |
|
if (text[0] != 242) |
|
/* not an integral symbol */ |
|
textEl = NULL; |
|
} |
|
} |
|
} |
|
} |
|
while (textEl); |
|
|
|
if (inbase) |
|
/* it's within a Base or UnderOverBase element */ |
|
{ |
|
sibling = parent; |
|
TtaNextSibling (&sibling); |
|
if (!sibling) |
|
/* the msubsup or munderover has no next sibling. |
|
Add a Construct1 element as the next sibling, |
|
to allow P rules to operate correctly */ |
|
{ |
|
elType.ElTypeNum = MathML_EL_Construct1; |
|
elType.ElSSchema = MathMLSSchema; |
|
sibling = TtaNewElement (doc, elType); |
|
TtaInsertSibling (sibling, parent, FALSE, doc); |
|
TtaRegisterElementCreate (sibling, doc); |
|
} |
|
else |
|
{ |
|
elType = TtaGetElementType (sibling); |
|
if (elType.ElTypeNum == MathML_EL_Construct && |
|
elType.ElSSchema == MathMLSSchema) |
|
{ |
|
TtaRegisterElementDelete (sibling, doc); |
|
TtaRemoveTree (sibling, doc); |
|
ChangeElementType (sibling, |
|
MathML_EL_Construct1); |
|
TtaInsertSibling (sibling, parent, FALSE, |
|
doc); |
|
TtaRegisterElementCreate (sibling, doc); |
|
} |
|
} |
|
/* force the msubsup element to be reformatted and |
|
take into account its new next sibling */ |
|
TtaRemoveTree (parent, doc); |
|
TtaInsertSibling (parent, sibling, TRUE, doc); |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |