Diff for /Amaya/amaya/templates.c between versions 1.209 and 1.210

version 1.209, 2008/10/02 13:08:24 version 1.210, 2008/10/09 14:59:36
Line 7 Line 7
   
 /*  /*
  * Authors: Francesc Campoy Flores   * Authors: Francesc Campoy Flores
  *          Ă‰milien Kia   *          Emilien Kia
  *   *
  */   */
   
Line 57  ThotBool IsTemplateInstanceDocument(Docu Line 57  ThotBool IsTemplateInstanceDocument(Docu
 #ifdef TEMPLATES  #ifdef TEMPLATES
   XTigerTemplate t = GetXTigerDocTemplate(doc);    XTigerTemplate t = GetXTigerDocTemplate(doc);
   if (t)    if (t)
     return (t->state & templInstance) != 0;      return ((t->state & templInstance) != 0);
   else    else
     return FALSE;      return FALSE;
 #else /* TEMPLATES */  #else /* TEMPLATES */
Line 84  ThotBool IsTemplateDocument (Document do Line 84  ThotBool IsTemplateDocument (Document do
   
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
     GetUsedTypeName returns the name of the current used type or the first
     name of the types attribute
     The returned string must be freed
     ----------------------------------------------------------------------*/
   char *GetUsedTypeName (Element el)
   {
     char        *name = NULL;
   #ifdef TEMPLATES
     char        *ptr;
   
     if (IsTemplateElement (el))
       {
         name = GetAttributeStringValueFromNum (el, Template_ATTR_currentType, NULL);
         if (name == NULL)
           {
             // use the first type
             name = GetAttributeStringValueFromNum (el, Template_ATTR_types, NULL);
             if (name)
               {
                 ptr = strstr (name, " ");
                 if (ptr)
                   *ptr = EOS;
               }
             return name;
           }
       }
   #endif /* TEMPLATES */
     return name;
   }
   
   /*----------------------------------------------------------------------
   Test if a document is an internal template.    Test if a document is an internal template.
   (no instance is opened and it is not edited)    (no instance is opened and it is not edited)
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
Line 1268  void Template_FillFromDocument (Document Line 1299  void Template_FillFromDocument (Document
       printf("plop : %d\n", t->state);        printf("plop : %d\n", t->state);
 #endif  #endif
       SetTemplateDocument (t, doc);        SetTemplateDocument (t, doc);
         Template_PrepareTemplate(t, doc);
       Template_PrepareTemplate(t);  
   
       if (IsTemplateInstanceDocument(doc))        if (IsTemplateInstanceDocument(doc))
         {          {
 #ifdef AMAYA_DEBUG  #ifdef AMAYA_DEBUG
Line 1551  ThotBool TemplateElementWillBeCreated (N Line 1580  ThotBool TemplateElementWillBeCreated (N
               (elType.ElTypeNum != Template_EL_useSimple &&                (elType.ElTypeNum != Template_EL_useSimple &&
                elType.ElTypeNum != Template_EL_useEl))                 elType.ElTypeNum != Template_EL_useEl))
             return TRUE; // don't let Thot do the job              return TRUE; // don't let Thot do the job
           t = GetXTigerDocTemplate(doc);            t = GetXTigerDocTemplate (doc);
           el = NULL;            el = NULL;
           i = 0;            i = 0;
           next = TtaGetFirstChild (ancestor);            next = TtaGetFirstChild (ancestor);
Line 1563  ThotBool TemplateElementWillBeCreated (N Line 1592  ThotBool TemplateElementWillBeCreated (N
             }              }
           if (el)            if (el)
             next = el;              next = el;
           name = GetAttributeStringValueFromNum (next, Template_ATTR_currentType, NULL);            name = GetUsedTypeName (next);
           if (name == NULL)  
             {  
               // use the first type  
               name = GetAttributeStringValueFromNum (next, Template_ATTR_types, NULL);  
               if (name)  
                 {  
                   ptr = strstr (name, " ");  
                   if (ptr)  
                     *ptr = EOS;  
                 }  
             }  
           DoReplicateUseElement (t, doc, view, el, ancestor, name);            DoReplicateUseElement (t, doc, view, el, ancestor, name);
           TtaFreeMemory(name);            TtaFreeMemory(name);
           return TRUE; // don't let Thot do the job            return TRUE; // don't let Thot do the job
Line 1627  ThotBool TemplateElementWillBeCreated (N Line 1645  ThotBool TemplateElementWillBeCreated (N
         return FALSE;          return FALSE;
     }      }
   
   if (elType.ElSSchema == templateSSchema &&    if (!IsTemplateInstanceDocument(doc) &&
          elType.ElSSchema == templateSSchema &&
       (elType.ElTypeNum == Template_EL_TEXT_UNIT ||        (elType.ElTypeNum == Template_EL_TEXT_UNIT ||
        elType.ElTypeNum == Template_EL_component))         elType.ElTypeNum == Template_EL_component))
       return FALSE;        return FALSE;

Removed from v.1.209  
changed lines
  Added in v.1.210


Webmaster