Diff for /Amaya/amaya/MathMLbuilder.c between versions 1.174 and 1.175

version 1.174, 2002/11/28 14:12:07 version 1.175, 2002/12/02 09:16:26
Line 1998  ThotBool      ChildOfMRowOrInferred (Ele Line 1998  ThotBool      ChildOfMRowOrInferred (Ele
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    CheckFenceLargeOp     CheckLargeOp
    If el is a MO element,     If el is a MO element,
     - if it's a large operator (∑ for instance), put a presentation     if it's a large operator (∑ for instance), put a presentation
       rule to enlarge the character.     rule to enlarge the character.
     - if it's a child of a MROW (or equivalent) element and if it contains  
       a single fence character, transform the MO into a MF and the fence  
       character into a Thot stretchable symbol.  
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void      CheckFenceLargeOp (Element el, Document doc)  void      CheckLargeOp (Element el, Document doc)
 {  {
    ElementType         elType, contType;     ElementType         elType, contType;
    Element             content, ancestor;     Element             content, ancestor;
    AttributeType       attrType;     AttributeType       attrType;
    Attribute           attrLargeop, attr, attrStretchy;     Attribute           attrLargeop, attr;
    Language            lang;     Language            lang;
    PresentationValue   pval;     PresentationValue   pval;
    PresentationContext ctxt;     PresentationContext ctxt;
    CHAR_T              text[2];     CHAR_T              text[2];
    char                script;     char                script;
    unsigned char       c;     int                 len, val;
    int                 len, val, oldStructureChecking;  
    ThotBool            largeop;     ThotBool            largeop;
   
    elType = TtaGetElementType (el);     elType = TtaGetElementType (el);
    if (elType.ElTypeNum == MathML_EL_MO ||     if (elType.ElTypeNum == MathML_EL_MO)
        elType.ElTypeNum == MathML_EL_OpeningFence ||       /* the element is a MO */
        elType.ElTypeNum == MathML_EL_ClosingFence ||  
        elType.ElTypeNum == MathML_EL_FencedSeparator)  
      /* the element is a MO or equivalent */  
      {       {
      content = TtaGetFirstChild (el);       content = TtaGetFirstChild (el);
      if (content != NULL)       if (content != NULL)
Line 2041  void      CheckFenceLargeOp (Element el, Line 2034  void      CheckFenceLargeOp (Element el,
            TtaGiveBufferContent (content, text, len+1, &lang);             TtaGiveBufferContent (content, text, len+1, &lang);
            script = TtaGetScript (lang);             script = TtaGetScript (lang);
            largeop = FALSE;             largeop = FALSE;
            /* is there an attribute largeop on this mo element? */             /* is there an attribute largeop on this MO element? */
            attrType.AttrSSchema = elType.ElSSchema;             attrType.AttrSSchema = elType.ElSSchema;
            attrType.AttrTypeNum = MathML_ATTR_largeop;             attrType.AttrTypeNum = MathML_ATTR_largeop;
            attrLargeop = TtaGetAttribute (el, attrType);             attrLargeop = TtaGetAttribute (el, attrType);
Line 2091  void      CheckFenceLargeOp (Element el, Line 2084  void      CheckFenceLargeOp (Element el,
              pval.typed_data.value = 0;               pval.typed_data.value = 0;
              }               }
            TtaSetStylePresentation (PRSize, content, NULL, ctxt, pval);             TtaSetStylePresentation (PRSize, content, NULL, ctxt, pval);
              }
            }
          }
        }
   }
   
   /*----------------------------------------------------------------------
      CheckFence
      If el is a MO element of a fence,
      if it's a child of a MROW (or equivalent) element and if it contains
      a single fence character, transform the MO into a MF and the fence
      character into a Thot stretchable symbol.
     ----------------------------------------------------------------------*/
   void      CheckFence (Element el, Document doc)
   {
      ElementType         elType, contType;
      Element             content;
      AttributeType       attrType;
      Attribute           attr, attrStretchy;
      Language            lang;
      CHAR_T              text[2];
      char                script;
      unsigned char       c;
      int                 len, val, oldStructureChecking;
   
            if (!largeop && ChildOfMRowOrInferred (el))     elType = TtaGetElementType (el);
              /* the MO element is a child of a MROW element */     if (elType.ElTypeNum == MathML_EL_MO ||
          elType.ElTypeNum == MathML_EL_OpeningFence ||
          elType.ElTypeNum == MathML_EL_ClosingFence ||
          elType.ElTypeNum == MathML_EL_FencedSeparator)
        /* the element is a MO or equivalent */
        {
        content = TtaGetFirstChild (el);
        if (content != NULL)
          {
          contType = TtaGetElementType (content);
          if (contType.ElTypeNum == MathML_EL_TEXT_UNIT)
            {
            len = TtaGetElementVolume (content);
            if (len == 1)
              /* the MO or fence element contains a single character */
              {
              TtaGiveBufferContent (content, text, len+1, &lang);
              script = TtaGetScript (lang);
              if (ChildOfMRowOrInferred (el))
                /* the MO or fence element is a child of a MROW element */
              /* Is it a stretchable symbol? */               /* Is it a stretchable symbol? */
               {                {
                 if (IsStretchy (text[0], script))                if (IsStretchy (text[0], script))
                 /* it's a stretchable parenthesis or equivalent */                  /* it's a stretchable parenthesis or equivalent */
                 {                  {
                 /* remove the content of the MO element */                  /* remove the content of the MO element */
Line 2222  void CreateFencedSeparators (Element fen Line 2258  void CreateFencedSeparators (Element fen
            TtaSetTextContent (leaf, sepValue, lang, doc);             TtaSetTextContent (leaf, sepValue, lang, doc);
            SetIntAddSpaceAttr (separator, doc);             SetIntAddSpaceAttr (separator, doc);
            SetIntVertStretchAttr (separator, doc, 0, NULL);             SetIntVertStretchAttr (separator, doc, 0, NULL);
            CheckFenceLargeOp (separator, doc);             CheckFence (separator, doc);
   
            /* is there a following non-space character in separators? */             /* is there a following non-space character in separators? */
            i = sep + 1;             i = sep + 1;
Line 2289  static void  CreateOpeningOrClosingFence Line 2325  static void  CreateOpeningOrClosingFence
   TtaSetTextContent (leaf, text, TtaGetLanguageIdFromScript('L'), doc);    TtaSetTextContent (leaf, text, TtaGetLanguageIdFromScript('L'), doc);
   SetIntAddSpaceAttr (fence, doc);    SetIntAddSpaceAttr (fence, doc);
   SetIntVertStretchAttr (fence, doc, 0, NULL);    SetIntVertStretchAttr (fence, doc, 0, NULL);
   CheckFenceLargeOp (fence, doc);    CheckFence (fence, doc);
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 3792  void HandleFramespacingAttribute (Attrib Line 3828  void HandleFramespacingAttribute (Attrib
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
      ApplyDisplaystyle
      An IntDisplaystyle attribute has been associated with (or removed from)
      element el.
      Handle all large operators in the sub tree.
      Update attribute IntMovelimits for all munder, mover or munderover
      elements in the subtree
     ----------------------------------------------------------------------*/
   static void   ApplyDisplaystyle (Element el, Document doc)
   {
     ElementType  elType;
     Element      child;
   
     elType = TtaGetElementType (el);
     if (!strcmp (TtaGetSSchemaName (elType.ElSSchema), "MathML"))
       {
         if (elType.ElTypeNum == MathML_EL_MO)
           CheckLargeOp (el, doc);
         else if (elType.ElTypeNum == MathML_EL_MUNDER ||
                  elType.ElTypeNum == MathML_EL_MOVER ||
                  elType.ElTypeNum == MathML_EL_MUNDEROVER)
           SetIntMovelimitsAttr (el, doc);
       }
     child = TtaGetFirstChild (el);
     while (child)
       {
         ApplyDisplaystyle (child, doc);
         TtaNextSibling (&child);
       }
   }
   
   /*----------------------------------------------------------------------
    SetDisplaystyleMathElement     SetDisplaystyleMathElement
    Associate a IntDisplaystyle attribute with element el (which is a     Associate a IntDisplaystyle attribute with element el (which is a
    <math> element), and set its value depending on the surrounding context.     <math> element), and set its value depending on the surrounding context.
Line 3865  void   SetDisplaystyleMathElement (Eleme Line 3932  void   SetDisplaystyleMathElement (Eleme
       TtaAttachAttribute (el, attr, doc);        TtaAttachAttribute (el, attr, doc);
     }      }
   TtaSetAttributeValue (attr, display, el, doc);    TtaSetAttributeValue (attr, display, el, doc);
     ApplyDisplaystyle (el, doc);
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 3920  void      MathMLElementComplete (ParserD Line 3988  void      MathMLElementComplete (ParserD
           /* if the MO element is a child of a MROW (or equivalent) and if it            /* if the MO element is a child of a MROW (or equivalent) and if it
              contains a fence character, transform this MO into MF and               contains a fence character, transform this MO into MF and
              transform the fence character into a Thot SYMBOL */               transform the fence character into a Thot SYMBOL */
           CheckFenceLargeOp (el, doc);            CheckFence (el, doc);
             /* if the MO element contains an operator that should be
                large (&sum; for instance), enlarge it */
             CheckLargeOp (el, doc);
           break;            break;
        case MathML_EL_MSPACE:         case MathML_EL_MSPACE:
           break;            break;
Line 4085  void      MathMLElementComplete (ParserD Line 4156  void      MathMLElementComplete (ParserD
        {         {
          parentType = TtaGetElementType (parent);           parentType = TtaGetElementType (parent);
          if (parentType.ElSSchema != elType.ElSSchema)           if (parentType.ElSSchema != elType.ElSSchema)
            /* root of a MathML tree, Create a MathML element if there is no */             /* root of a MathML (sub-)tree, Create a MathML element if it is
                 not present */
            if (elType.ElTypeNum != MathML_EL_MathML)             if (elType.ElTypeNum != MathML_EL_MathML)
              {               {
                elType.ElSSchema = MathMLSSchema;                 elType.ElSSchema = MathMLSSchema;
Line 4363  void MathMLSpacingAttr (Document doc, El Line 4435  void MathMLSpacingAttr (Document doc, El
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    MathMLSetDisplayAttr  
    The MathML attribute display is associated  with element el (which  
    should be a <math> element).  
    Generate the corresponding internal attribute.  
   ----------------------------------------------------------------------*/  
 void MathMLSetDisplayAttr (Element el, Attribute attr, Document doc,  
                            ThotBool delete)  
 {  
   int            val, intVal, attrKind;  
   AttributeType  attrType;  
   Attribute      intAttr;  
   
   if (delete)  
     SetDisplaystyleMathElement (el, doc);  
   else  
     {  
       val = TtaGetAttributeValue (attr);  
       if (val == MathML_ATTR_display_VAL_block)  
         intVal = MathML_ATTR_IntDisplaystyle_VAL_true;  
       else  
         intVal = MathML_ATTR_IntDisplaystyle_VAL_false;  
       TtaGiveAttributeType (attr, &attrType, &attrKind);  
       attrType.AttrTypeNum = MathML_ATTR_IntDisplaystyle;  
       intAttr = TtaGetAttribute (el, attrType);  
       /* create the IntDisplaystyle attribute and set its value */  
       if (!intAttr)  
         {  
           intAttr = TtaNewAttribute (attrType);  
           TtaAttachAttribute (el, intAttr, doc);  
         }  
       TtaSetAttributeValue (intAttr, intVal, el, doc);  
     }  
 }  
   
 /*----------------------------------------------------------------------  
    MathMLSetDisplaystyleAttr     MathMLSetDisplaystyleAttr
    The attribute displaystyle is associated  with element el (which     The attribute displaystyle is associated  with element el (which
    should be a <mstyle> or a <mtable> element).     should be a <mstyle> or a <mtable> element).
    GenerateSet the corresponding internal attribute accordingly.     Generate or set the corresponding internal attribute accordingly.
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void MathMLSetDisplaystyleAttr (Element el, Attribute attr, Document doc,  void MathMLSetDisplaystyleAttr (Element el, Attribute attr, Document doc,
                                 ThotBool delete)                                  ThotBool delete)
Line 4411  void MathMLSetDisplaystyleAttr (Element Line 4448  void MathMLSetDisplaystyleAttr (Element
   AttributeType  attrType;    AttributeType  attrType;
   Attribute      intAttr;    Attribute      intAttr;
   
     intVal = 0;
   /* get the internal attribute */    /* get the internal attribute */
   elType = TtaGetElementType (el);    elType = TtaGetElementType (el);
   attrType.AttrSSchema = elType.ElSSchema;    attrType.AttrSSchema = elType.ElSSchema;
Line 4424  void MathMLSetDisplaystyleAttr (Element Line 4462  void MathMLSetDisplaystyleAttr (Element
         {          {
           if (intAttr)            if (intAttr)
             TtaRemoveAttribute (el, intAttr, doc);              TtaRemoveAttribute (el, intAttr, doc);
           return;  
         }          }
       else if (elType.ElTypeNum == MathML_EL_MTABLE)        else if (elType.ElTypeNum == MathML_EL_MTABLE)
         /* it's a matable element, set the default value (false) */          /* it's a matable element, set the default value (false) */
         intVal = MathML_ATTR_IntDisplaystyle_VAL_false;          intVal = MathML_ATTR_IntDisplaystyle_VAL_false;
       else  
         return;  
     }      }
   else    else
     {      {
Line 4441  void MathMLSetDisplaystyleAttr (Element Line 4476  void MathMLSetDisplaystyleAttr (Element
         intVal = MathML_ATTR_IntDisplaystyle_VAL_false;          intVal = MathML_ATTR_IntDisplaystyle_VAL_false;
     }      }
   /* create the IntDisplaystyle attribute if needed and set its value */    /* create the IntDisplaystyle attribute if needed and set its value */
   if (!intAttr)    if (intVal)
     {      {
       intAttr = TtaNewAttribute (attrType);        if (!intAttr)
       TtaAttachAttribute (el, intAttr, doc);          {
             intAttr = TtaNewAttribute (attrType);
             TtaAttachAttribute (el, intAttr, doc);
           }
         TtaSetAttributeValue (intAttr, intVal, el, doc);
     }      }
   TtaSetAttributeValue (intAttr, intVal, el, doc);    ApplyDisplaystyle (el, doc);
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 4515  void MathMLAttributeComplete (Attribute Line 4554  void MathMLAttributeComplete (Attribute
    */     */
   
    else if (attrType.AttrTypeNum == MathML_ATTR_display)     else if (attrType.AttrTypeNum == MathML_ATTR_display)
      /* it's a display attribute on element <math> */       /* it's a display attribute on element <math>, set the corresponding
      MathMLSetDisplayAttr (el, attr, doc, FALSE);          internal attribute IntDisplaystyle */
        SetDisplaystyleMathElement (el, doc);
   
    else if (attrType.AttrTypeNum == MathML_ATTR_displaystyle)     else if (attrType.AttrTypeNum == MathML_ATTR_displaystyle)
      /* it's a displaystyle attribute */       /* it's a displaystyle attribute */

Removed from v.1.174  
changed lines
  Added in v.1.175


Webmaster