Diff for /Amaya/amaya/templateInstantiate.c between versions 1.33 and 1.34

version 1.33, 2007/04/03 10:10:57 version 1.34, 2007/04/18 15:18:52
Line 15 Line 15
 #include "EDITimage_f.h"  #include "EDITimage_f.h"
 #include "HTMLactions_f.h"  #include "HTMLactions_f.h"
 #include "HTMLsave_f.h"  #include "HTMLsave_f.h"
   #include "HTMLtable_f.h"
 #include "init_f.h"  #include "init_f.h"
 #include "mydictionary_f.h"  #include "mydictionary_f.h"
 #include "templates_f.h"  #include "templates_f.h"
Line 340  Element Template_GetNewXmlElementInstanc Line 341  Element Template_GetNewXmlElementInstanc
   return newEl;    return newEl;
 }  }
   
   
   /*----------------------------------------------------------------------
     InsertWithNotify applies pre and post functions when inserting the new
     element el after child (if not NULL) or as first child of parent.
     ----------------------------------------------------------------------*/
   Element InsertWithNotify (Element el, Element child, Element parent, Document doc)
   {
     ElementType      elType;
     NotifyElement    event;
     char            *name;
     ThotBool         isRow = FALSE, isCell = FALSE;
   
     elType = TtaGetElementType (el);
     name = TtaGetSSchemaName (elType.ElSSchema);
     isCell = ((!strcmp (name,"HTML") &&
                elType.ElTypeNum == HTML_EL_Data_cell ||
                elType.ElTypeNum == HTML_EL_Heading_cell) ||
               (!strcmp (name,"MathML") && elType.ElTypeNum == MathML_EL_MTD));
     isRow = ((!strcmp (name,"HTML") && elType.ElTypeNum == HTML_EL_Table_row) ||
              (!strcmp (name,"MathML") &&
               (elType.ElTypeNum == MathML_EL_MTR ||
                elType.ElTypeNum == MathML_EL_MLABELEDTR)));
     if (child)
       TtaInsertSibling (el, child, FALSE, doc);
     else
       TtaInsertFirstChild (&el, parent, doc);
   
     if (isCell)
       {
         // a cell is created
         //NewCell (el, doc, FALSE, FALSE, TRUE);
       }
     else if (isRow)
       {
         // a row is created
         event.element = el;
         event.document = doc;
         RowPasted (&event);
       }
     //else
     // TtaNotifySubTree (TteElemNew, doc, el, FALSE);
     return el;
   }
   
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
   Template_InsertUseChildren    Template_InsertUseChildren
   Insert children to a xt:use    Insert children to a xt:use
Line 351  Element Template_GetNewXmlElementInstanc Line 397  Element Template_GetNewXmlElementInstanc
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 Element Template_InsertUseChildren(Document doc, Element el, Declaration dec)  Element Template_InsertUseChildren(Document doc, Element el, Declaration dec)
 {  {
   Element     newEl   = NULL;    Element     newEl = NULL;
 #ifdef TEMPLATES  #ifdef TEMPLATES
   Element     current = NULL;    Element     current = NULL;
   Element     child   = NULL;    Element     child = NULL;
   //char       *attrCurrentTypeValue;    //char       *attrCurrentTypeValue;
   //ElementType elType;    //ElementType elType;
       
Line 364  Element Template_InsertUseChildren(Docum Line 410  Element Template_InsertUseChildren(Docum
     {      {
       case SimpleTypeNat:        case SimpleTypeNat:
         newEl = Template_GetNewSimpleTypeInstance(doc, el, dec);          newEl = Template_GetNewSimpleTypeInstance(doc, el, dec);
         TtaInsertFirstChild (&newEl, el, doc);          newEl = InsertWithNotify (newEl, NULL, el, doc);
         break;          break;
       case XmlElementNat:        case XmlElementNat:
         newEl = Template_GetNewXmlElementInstance(doc, el, dec);          newEl = Template_GetNewXmlElementInstance(doc, el, dec);
         TtaInsertFirstChild (&newEl, el, doc);          newEl = InsertWithNotify (newEl, NULL, el, doc);
         break;          break;
       case ComponentNat:        case ComponentNat:
         newEl = TtaCopyTree(dec->componentType.content, doc, doc, el);          newEl = TtaCopyTree(dec->componentType.content, doc, doc, el);
         ProcessAttr (dec->declaredIn, newEl, doc);          ProcessAttr (dec->declaredIn, newEl, doc);        
           
         /* Copy elements from new use to existing use. */          /* Copy elements from new use to existing use. */
         while((child = TtaGetFirstChild(newEl)))          while ((child = TtaGetFirstChild(newEl)))
         {          {
           TtaRemoveTree (child, doc);            TtaRemoveTree (child, doc);
           if (current)            child = InsertWithNotify (child, current, el, doc);
             TtaInsertSibling (child, current, FALSE, doc);  
           else  
             TtaInsertFirstChild (&child, el, doc);        
           current = child;             current = child; 
         }          }
                   
Line 620  void InstantiateRepeat (XTigerTemplate t Line 662  void InstantiateRepeat (XTigerTemplate t
       TtaInsertSibling (newChild, child, FALSE, doc);        TtaInsertSibling (newChild, child, FALSE, doc);
       SetAttributeStringValueWithUndo (newChild, Template_ATTR_types, types);        SetAttributeStringValueWithUndo (newChild, Template_ATTR_types, types);
       SetAttributeStringValueWithUndo (newChild, Template_ATTR_title, title);        SetAttributeStringValueWithUndo (newChild, Template_ATTR_title, title);
               InstantiateUse (t, newChild, doc, TRUE);
       InstantiateUse(t, newChild, doc, TRUE);  
               
       if (registerUndo)        if (registerUndo)
         TtaRegisterElementCreate(newChild, doc);          TtaRegisterElementCreate (newChild, doc);
       child = newChild;        child = newChild;
       childrenCount++;        childrenCount++;
     }      }
Line 807  void DoInstanceTemplate (char *templaten Line 848  void DoInstanceTemplate (char *templaten
   TtaSetStructureChecking (FALSE, doc);    TtaSetStructureChecking (FALSE, doc);
   elType.ElTypeNum = pi_type;    elType.ElTypeNum = pi_type;
   piElem = TtaNewTree (doc, elType, "");    piElem = TtaNewTree (doc, elType, "");
   TtaInsertSibling(piElem, doctype, FALSE, doc);    TtaInsertSibling (piElem, doctype, FALSE, doc);
   elFound = TtaGetFirstChild (piElem);    elFound = TtaGetFirstChild (piElem);
   text = TtaGetFirstChild (elFound);    text = TtaGetFirstChild (elFound);
   strcpy (buffer, "xtiger template=\"");    strcpy (buffer, "xtiger template=\"");

Removed from v.1.33  
changed lines
  Added in v.1.34


Webmaster