Diff for /Amaya/amaya/templates.c between versions 1.23 and 1.24

version 1.23, 2003/02/17 11:00:51 version 1.24, 2004/01/19 13:53:06
Line 1 Line 1
 /*  /*
  *   *
  *  COPYRIGHT INRIA and W3C, 1996-2003   *  COPYRIGHT INRIA and W3C, 1996-2004
  *  Please first read the full copyright statement in file COPYRIGHT.   *  Please first read the full copyright statement in file COPYRIGHT.
  *   *
  */   */
Line 38  void NewTemplate (Document doc, View vie Line 38  void NewTemplate (Document doc, View vie
   
   url = TtaGetEnvString ("TEMPLATE_URL");    url = TtaGetEnvString ("TEMPLATE_URL");
   if (url)    if (url)
     GetAmayaDoc (url, NULL, 0, 0, CE_ABSOLUTE, FALSE, NULL, NULL,      GetAmayaDoc (url, NULL, 0, 0, CE_ABSOLUTE, FALSE, NULL, NULL);
                  TtaGetDefaultCharset ());  
 }  }
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
    OpenTemplateDocument: Process the meta of a template document,     OpenTemplateDocument: Process the meta of a template document,
Line 53  void OpenTemplateDocument (Document doc) Line 52  void OpenTemplateDocument (Document doc)
   Attribute           metaAttr;    Attribute           metaAttr;
   AttributeType       metaAttrType;    AttributeType       metaAttrType;
   ThotBool            found = FALSE;    ThotBool            found = FALSE;
   ThotBool            ok = FALSE;  
   int                 length;    int                 length;
   char              buffer[MAX_LENGTH];    char               *utf8path, *path;
   char             *URLdir;    char               *URLdir, *URLname;
   char             *URLname;  
   
   metaElType.ElSSchema = TtaGetDocumentSSchema (doc);    metaElType.ElSSchema = TtaGetDocumentSSchema (doc);
   metaElType.ElTypeNum = HTML_EL_META;    metaElType.ElTypeNum = HTML_EL_META;
Line 65  void OpenTemplateDocument (Document doc) Line 62  void OpenTemplateDocument (Document doc)
   metaAttrType.AttrTypeNum = HTML_ATTR_meta_name;    metaAttrType.AttrTypeNum = HTML_ATTR_meta_name;
   /* search the meta element */    /* search the meta element */
   metaEl = TtaGetMainRoot (doc);    metaEl = TtaGetMainRoot (doc);
     path = NULL;
   do    do
     {      {
       metaEl = TtaSearchTypedElement (metaElType, SearchForward, metaEl);        metaEl = TtaSearchTypedElement (metaElType, SearchForward, metaEl);
Line 73  void OpenTemplateDocument (Document doc) Line 71  void OpenTemplateDocument (Document doc)
           metaAttr = TtaGetAttribute (metaEl, metaAttrType);             metaAttr = TtaGetAttribute (metaEl, metaAttrType); 
           if (metaAttr != NULL)            if (metaAttr != NULL)
             {              {
               length = MAX_LENGTH - 1;                length = TtaGetTextAttributeLength (metaAttr) + 1;
               TtaGiveTextAttributeValue (metaAttr, buffer, &length);                utf8path = (char *) TtaGetMemory (length);
               found = !strcmp (buffer, META_TEMPLATE_NAME);                TtaGiveTextAttributeValue (metaAttr, utf8path, &length);
                 path = (char *)TtaConvertMbsToByte ((unsigned char *)utf8path,
                                                     TtaGetDefaultCharset ());
                 TtaFreeMemory (utf8path);
                 found = !strcmp (path, META_TEMPLATE_NAME);
             }              }
         }          }
     }      }
   while (metaEl != NULL && !found);    while (metaEl && !found);
   
   if (found)    if (found)
     {      {
       /* get the url of the document */        /* get the url of the document */
Line 87  void OpenTemplateDocument (Document doc) Line 90  void OpenTemplateDocument (Document doc)
       metaAttr = TtaGetAttribute (metaEl, metaAttrType);        metaAttr = TtaGetAttribute (metaEl, metaAttrType);
       if (metaAttr != NULL)        if (metaAttr != NULL)
         {          {
           length = MAX_LENGTH - 1;            length = TtaGetTextAttributeLength (metaAttr) + 1;
           TtaGiveTextAttributeValue (metaAttr, buffer, &length);            utf8path = (char *) TtaGetMemory (length);
             TtaGiveTextAttributeValue (metaAttr, utf8path, &length);
             path = (char *)TtaConvertMbsToByte ((unsigned char *)utf8path,
                                                 TtaGetDefaultCharset ());
             TtaFreeMemory (utf8path);
         }          }
   
       /* Delete the meta element */        /* Delete the meta element */
       TtaDeleteTree (metaEl, doc);          TtaDeleteTree (metaEl, doc);  
       /* try to save to the new url */        if (script_URL == NULL)
 #ifdef WITH_PRELABLE_SAVE_POUR_VOIR                script_URL = TtaStrdup (DocumentURLs[doc]);
       ok = SaveDocumentThroughNet (doc, 1, buffer, FALSE, TRUE, TRUE);        TtaFreeMemory (DocumentURLs[doc]);
 #else        DocumentURLs[doc] = TtaStrdup (path);
       ok = TRUE;        DocumentMeta[doc]->method = CE_TEMPLATE;
 #endif        AddURLInCombobox (DocumentURLs[doc], NULL, TRUE);
       if (ok)        TtaSetTextZone (doc, 1, URL_list);
         {        TtaSetDocumentUnmodified (doc);
           if (script_URL == NULL)  
             script_URL = TtaStrdup (DocumentURLs[doc]);  
           TtaFreeMemory (DocumentURLs[doc]);  
           DocumentURLs[doc] = TtaStrdup (buffer);  
           DocumentMeta[doc]->method = CE_TEMPLATE;  
           AddURLInCombobox (DocumentURLs[doc], NULL, TRUE);  
           TtaSetTextZone (doc, 1, URL_list);  
           TtaSetDocumentUnmodified (doc);  
             
         }  
       else   
         {  
           /* save failed : print warning message */  
            
         }  
           
       /* set the document name and dir */  
               
       URLname = strrchr (buffer, URL_SEP);        /* set the document name and dir */
         URLname = strrchr (path, URL_SEP);
       if (URLname)        if (URLname)
         {          {
           URLname[0] = EOS;            URLname[0] = EOS;
           URLname++;            URLname++;
           URLdir = buffer;            URLdir = path;
           TtaSetDocumentDirectory (doc, URLdir);            TtaSetDocumentDirectory (doc, URLdir);
           TtaSetDocumentName (doc, URLname);            TtaSetDocumentName (doc, URLname);
           /* SetBrowserEditor(doc); */             /* SetBrowserEditor(doc); */ 
Line 131  void OpenTemplateDocument (Document doc) Line 123  void OpenTemplateDocument (Document doc)
       else        else
         {          {
           TtaSetDocumentDirectory (doc, "");            TtaSetDocumentDirectory (doc, "");
           TtaSetDocumentName (doc, buffer);            TtaSetDocumentName (doc, path);
         }          }
       SetWindowTitle (doc, doc, 0);        SetWindowTitle (doc, doc, 0);
     }      }
         TtaFreeMemory (path);
 }  }
       
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------

Removed from v.1.23  
changed lines
  Added in v.1.24


Webmaster