Diff for /Amaya/amaya/MathMLbuilder.c between versions 1.151 and 1.152

version 1.151, 2002/03/28 15:43:13 version 1.152, 2002/03/29 15:35:09
Line 462  static ThotBool CheckMathSubExpressions Line 462  static ThotBool CheckMathSubExpressions
   return result;    return result;
 }  }
   
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    SetSingleIntHorizStretchAttr     SetSingleIntHorizStretchAttr
   
Line 472  static ThotBool CheckMathSubExpressions Line 471  static ThotBool CheckMathSubExpressions
 void SetSingleIntHorizStretchAttr (Element el, Document doc, Element* selEl)  void SetSingleIntHorizStretchAttr (Element el, Document doc, Element* selEl)
 {  {
   Element       child, sibling, textEl, symbolEl;    Element       child, sibling, textEl, symbolEl;
   ElementType   elType;    ElementType   elType, childType, siblingType;
   Attribute     attr;    Attribute     attr;
   AttributeType attrType;    AttributeType attrType;
   Language      lang;    Language      lang;
Line 480  void SetSingleIntHorizStretchAttr (Eleme Line 479  void SetSingleIntHorizStretchAttr (Eleme
   char          script;    char          script;
   unsigned char c;    unsigned char c;
   int           len;    int           len;
     ThotBool      doit;
   
   if (el == NULL)    if (el == NULL)
      return;       return;
Line 487  void SetSingleIntHorizStretchAttr (Eleme Line 487  void SetSingleIntHorizStretchAttr (Eleme
   if (child)    if (child)
      {       {
      elType = TtaGetElementType (child);       elType = TtaGetElementType (child);
      while (elType.ElTypeNum == MathML_EL_MROW && child)       /* skip a possible empty Construct (placeholder) */
         /* the first child is a mrow. Look whether it contains a single       if (elType.ElTypeNum == MathML_EL_Construct)
            child of type mo */         {
            TtaNextSibling (&child);
            if (child)
              elType = TtaGetElementType (child);
          }
        while (child && elType.ElTypeNum == MathML_EL_MROW)
           /* the first child is a mrow. Check whether it has a single child */
         {          {
         child = TtaGetFirstChild (child);          child = TtaGetFirstChild (child);
         if (child)          if (child)
           {            {
               elType = TtaGetElementType (child);
               /* skip a possible empty Construct (placeholder) */
               if (elType.ElTypeNum == MathML_EL_Construct)
                 {
                 TtaNextSibling (&child);
                 if (child)
                   elType = TtaGetElementType (child);
                 }
             sibling = child;              sibling = child;
             TtaNextSibling (&sibling);              TtaNextSibling (&sibling);
             if (sibling == NULL)              if (sibling)
               /* the mrow element has a single child. Get its type */                /* there are other children */
               elType = TtaGetElementType (child);                {
             else                siblingType = TtaGetElementType (sibling);
               child = NULL;                if (siblingType.ElTypeNum == MathML_EL_Construct)
                   /* its a construct, skip it */
                   TtaNextSibling (&sibling);
                 if (sibling)
                   child = NULL;
                 }
           }            }
         }          }
      if (elType.ElTypeNum == MathML_EL_MO && child)       if (child && (elType.ElTypeNum == MathML_EL_MO ||
         /* the first child is a MO */                     elType.ElTypeNum == MathML_EL_MOVER ||
                      elType.ElTypeNum == MathML_EL_MUNDER))
           /* the first child is a MO, a MUNDER or a MOVER */
         {          {
         sibling = child;          sibling = child;
         TtaNextSibling (&sibling);          TtaNextSibling (&sibling);
           /* skip a possible empty Construct (placeholder) */
           if (sibling)
             {
               siblingType = TtaGetElementType (sibling);
               if (siblingType.ElTypeNum == MathML_EL_Construct)
                 TtaNextSibling (&sibling);
             }
         if (sibling == NULL)          if (sibling == NULL)
            /* there is no other child */             /* there is no other child */
            {             {
            textEl = TtaGetFirstChild (child);             c = EOS;
            elType = TtaGetElementType (textEl);             doit = FALSE;
            if (elType.ElTypeNum == MathML_EL_TEXT_UNIT)             attrType.AttrSSchema = elType.ElSSchema;
               /* the MO child contains a TEXT element */             attrType.AttrTypeNum = MathML_ATTR_IntHorizStretch;
               {  
               len = TtaGetElementVolume (textEl);             if (elType.ElTypeNum == MathML_EL_MOVER ||
               if (len == 1)                 elType.ElTypeNum == MathML_EL_MUNDER)
                /* check if the UnderOverBase has a IntHorizStretch attribute */
                {
                  childType.ElTypeNum = MathML_EL_UnderOverBase;
                  textEl = TtaSearchTypedElement (childType, SearchInTree, child);
                  if (textEl)
                    {
                      if (TtaGetAttribute (textEl, attrType))
                        doit = TRUE;
                    }
                }
              else if (elType.ElTypeNum == MathML_EL_MO)
                {
                textEl = TtaGetFirstChild (child);
                childType = TtaGetElementType (textEl);
                if (childType.ElTypeNum == MathML_EL_TEXT_UNIT)
                  /* the MO child contains a TEXT element */
                  {
                  len = TtaGetElementVolume (textEl);
                  if (len == 1)
                  /* the TEXT element contains a single character */                   /* the TEXT element contains a single character */
                  {                   {
                  c = EOS;                     /* get that character */
                  /* get that character */                     len = 2;
                  len = 2;                     TtaGiveBufferContent (textEl, text, len, &lang);
                  TtaGiveBufferContent (textEl, text, len, &lang);                     script = TtaGetScript (lang);
                  script = TtaGetScript (lang);                     if (
                  if (  
 #ifndef _I18N_  #ifndef _I18N_
                      (script == 'L') &&                         (script == 'L') &&
 #endif  #endif
                      (text[0] == '-' || text[0] == '_' ||                         (text[0] == '-' || text[0] == '_' ||
                       text[0] == 175))                          text[0] == 175))
                       /* a horizontal line in the middle of the box */  
                       c = 'h';   
                  else   
 #ifdef _I18N_  
                    if (text[0] == 0x2190)  
                      c = 'L';  /* arrow left */  
                    else if (text[0] == 0x2192)  
                      c = 'R';  /* arrow right */  
                    else if (text[0] == 45)    /* - (minus) */  
                      /* a horizontal line in the middle of the box */                       /* a horizontal line in the middle of the box */
                      c = 'h';                        c = 'h'; 
                    else if (text[0] == 0x0332)    /* UnderBar */                     else 
                      /* a horizontal line */  #ifdef _I18N_
                      c = 'h';                        if (text[0] == 0x2190)
                    else if (text[0] == 65079)                         c = 'L';  /* arrow left */
                      c = 'o';  /* Over brace */                       else if (text[0] == 0x2192)
                    else if (text[0] == 65080)                         c = 'R';  /* arrow right */
                      c = 'u';  /* Under brace */                       else if (text[0] == 45)    /* - (minus) */
                          /* a horizontal line in the middle of the box */
                          c = 'h'; 
                        else if (text[0] == 0x0332)    /* UnderBar */
                          /* a horizontal line */
                          c = 'h'; 
                        else if (text[0] == 65079)
                          c = 'o';  /* Over brace */
                        else if (text[0] == 65080)
                          c = 'u';  /* Under brace */
 #else  #else
                    if (script == 'G')                     if (script == 'G')
                      /* a single Symbol character */                       /* a single Symbol character */
Line 566  void SetSingleIntHorizStretchAttr (Eleme Line 612  void SetSingleIntHorizStretchAttr (Eleme
                          c = 'u';  /* Under brace */                           c = 'u';  /* Under brace */
                      }                       }
 #endif  #endif
                  if (c != EOS)                     if (c != EOS)
                     {                       doit = TRUE;
                     /* attach a IntHorizStretch attribute to the mo */  
                     attrType.AttrSSchema = elType.ElSSchema;  
                     attrType.AttrTypeNum = MathML_ATTR_IntHorizStretch;  
                     attr = TtaNewAttribute (attrType);  
                     TtaAttachAttribute (el, attr, doc);  
                     TtaSetAttributeValue (attr, MathML_ATTR_IntHorizStretch_VAL_yes_, el, doc);  
                     /* replace the TEXT element by a Thot SYMBOL element */  
                     elType.ElTypeNum = MathML_EL_SYMBOL_UNIT;  
                     symbolEl = TtaNewElement (doc, elType);  
                     TtaInsertSibling (symbolEl, textEl, FALSE, doc);  
                     if (selEl != NULL)  
                       if (*selEl == textEl)  
                         *selEl = symbolEl;  
                     TtaDeleteTree (textEl, doc);  
                     if (c != EOS)  
                       TtaSetGraphicsShape (symbolEl, c, doc);  
                     }  
                  }                   }
               }                 }
                }
              if (doit)
                {
                  /* attach a IntHorizStretch attribute to the element
                     (UnderOverBase, Underscript, or Overscript) */
                  attr = TtaNewAttribute (attrType);
                  TtaAttachAttribute (el, attr, doc);
                  TtaSetAttributeValue (attr, MathML_ATTR_IntHorizStretch_VAL_yes_, el, doc);
                  attr = TtaNewAttribute (attrType);
                  TtaAttachAttribute (child, attr, doc);
                  TtaSetAttributeValue (attr, MathML_ATTR_IntHorizStretch_VAL_yes_, child, doc);
                }
              if (c != EOS)
                {
                  /* replace the TEXT element by a Thot SYMBOL element */
                  childType.ElTypeNum = MathML_EL_SYMBOL_UNIT;
                  symbolEl = TtaNewElement (doc, childType);
                  TtaInsertSibling (symbolEl, textEl, FALSE, doc);
                  if (selEl != NULL)
                    if (*selEl == textEl)
                      *selEl = symbolEl;
                  TtaDeleteTree (textEl, doc);
                  if (c != EOS)
                    TtaSetGraphicsShape (symbolEl, c, doc);
                }
            }             }
         }          }
      }       }
Line 595  void SetSingleIntHorizStretchAttr (Eleme Line 649  void SetSingleIntHorizStretchAttr (Eleme
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    SetIntHorizStretchAttr     SetIntHorizStretchAttr
   
    Put a IntHorizStretch attribute on all children of element el which     Put a IntHorizStretch attribute on all children of element el that
    contain only a MO element that is a stretchable symbol.     contain only a MO element that is a stretchable symbol.
  -----------------------------------------------------------------------*/   -----------------------------------------------------------------------*/
 static void SetIntHorizStretchAttr (Element el, Document doc)  static void SetIntHorizStretchAttr (Element el, Document doc)

Removed from v.1.151  
changed lines
  Added in v.1.152


Webmaster