Diff for /Amaya/amaya/templateInstantiate.c between versions 1.70 and 1.71

version 1.70, 2008/04/04 12:43:15 version 1.71, 2008/04/04 14:09:22
Line 6 Line 6
  */   */
   
 #include "templates.h"  #include "templates.h"
   
 #define THOT_EXPORT extern  #define THOT_EXPORT extern
   #include "amaya.h"
 #include "templateDeclarations.h"  #include "templateDeclarations.h"
   
 #include "Elemlist.h"  #include "Elemlist.h"
   #include "AHTURLTools_f.h"
 #include "wxdialogapi_f.h"  #include "wxdialogapi_f.h"
 #include "EDITimage_f.h"  #include "EDITimage_f.h"
 #include "HTMLsave_f.h"  #include "HTMLsave_f.h"
Line 29 Line 29
   
 #ifdef TEMPLATES  #ifdef TEMPLATES
 #define TEMPLATE_SCHEMA_NAME "Template"  #define TEMPLATE_SCHEMA_NAME "Template"
   
 typedef struct _InstantiateCtxt  
 {  
   char         *templatePath;  
   char         *instancePath;  
   char         *schemaName;  
   Document      doc;  
   DocumentType  docType;  
   ThotBool      dontReplace;  
 } InstantiateCtxt;  
 #endif /* TEMPLATES */  #endif /* TEMPLATES */
   
   
Line 300  void CreateTemplate(Document doc, char * Line 290  void CreateTemplate(Document doc, char *
   // Save document    // Save document
   TtaGetEnvBoolean ("GENERATE_MATHPI", &mathPI);    TtaGetEnvBoolean ("GENERATE_MATHPI", &mathPI);
   TtaSetEnvBoolean("GENERATE_MATHPI", TRUE, TRUE);    TtaSetEnvBoolean("GENERATE_MATHPI", TRUE, TRUE);
   SaveDocumentToNewDoc(doc, newdoc, templatePath, NULL);    SaveDocumentToNewDoc(doc, newdoc, templatePath);
   TtaSetEnvBoolean("GENERATE_MATHPI", mathPI, TRUE);    TtaSetEnvBoolean("GENERATE_MATHPI", mathPI, TRUE);
       
   TtaClearUndoHistory (doc);    TtaClearUndoHistory (doc);
Line 345  void CreateTemplate(Document doc, char * Line 335  void CreateTemplate(Document doc, char *
   CreateInstance    CreateInstance
   basedoc is the displayed doc that launchs the creation of instance    basedoc is the displayed doc that launchs the creation of instance
   ----------------------------------------------------------------------*/    ----------------------------------------------------------------------*/
 void CreateInstance(char *templatePath, char *instancePath, int basedoc)  void CreateInstance(char *templatePath, char *instancePath,
                       char *docname, int basedoc)
 {  {
 #ifdef TEMPLATES  #ifdef TEMPLATES
   Document          doc = 0, newdoc = 0;    Document          doc = 0, newdoc = 0;
   ElementType       elType;    ElementType       elType;
   Element           root, title, text;    Element           root, title, text;
   CHARSET           charset;    CHARSET           charset;
   char             *localFile, *s, *charsetname;    char             *s, *charsetname;
   ThotBool          changes = FALSE;    ThotBool          changes = FALSE;
   
   XTigerTemplate t = GetXTigerTemplate(templatePath);    XTigerTemplate t = GetXTigerTemplate(templatePath);
Line 420  void CreateInstance(char *templatePath, Line 411  void CreateInstance(char *templatePath,
       changes = TRUE;        changes = TRUE;
   
       // Save document        // Save document
       SaveDocumentToNewDoc(doc, newdoc, instancePath, &localFile);        SaveDocumentToNewDoc(doc, newdoc, instancePath);
   
       // Revert HTML special changes        // Revert HTML special changes
       if(changes)        if (changes)
         TtaUndoNoRedo (doc);          TtaUndoNoRedo (doc);
               
       TtaFreeMemory(localFile);  
   
       TtaClearUndoHistory (doc);        TtaClearUndoHistory (doc);
       RemoveParsingErrors (doc);        RemoveParsingErrors (doc);
         // now load the document as an instance
       GetAmayaDoc (instancePath, NULL, basedoc, basedoc, CE_INSTANCE,        GetAmayaDoc (instancePath, NULL, basedoc, basedoc, CE_INSTANCE,
                    !DontReplaceOldDoc, NULL, NULL);                     !DontReplaceOldDoc, NULL, NULL);
       TtaSetDocumentModified (newdoc);        TtaSetDocumentModified (newdoc);
Line 438  void CreateInstance(char *templatePath, Line 428  void CreateInstance(char *templatePath,
 #endif /* TEMPLATES */  #endif /* TEMPLATES */
 }  }
   
 /*----------------------------------------------------------------------  
   ----------------------------------------------------------------------*/  
 void InstantiateTemplate_callback (int newdoc, int status,  char *urlName,  
                                    char *outputfile,  
                                    char *proxyName, AHTHeaders *http_headers,  
                                    void * context)  
 {  
 #ifdef TEMPLATES  
   InstantiateCtxt *ctx = (InstantiateCtxt*)context;  
   
   DoInstanceTemplate (ctx->templatePath);  
   CreateInstance (ctx->templatePath, ctx->instancePath, ctx->doc);  
   TtaFreeMemory (ctx->templatePath);  
   TtaFreeMemory (ctx->instancePath);  
   TtaFreeMemory (ctx);  
 #endif /* TEMPLATES */  
 }  
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
   InstantiateAttribute    InstantiateAttribute

Removed from v.1.70  
changed lines
  Added in v.1.71


Webmaster