version 1.86, 2006/12/08 11:56:10
|
version 1.87, 2006/12/21 08:00:13
|
Line 30
|
Line 30
|
|
|
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
|
|
|
|
|
#include "fetchXMLname_f.h" |
#include "MENUconf.h" |
#include "MENUconf.h" |
|
|
|
#include "containers.h" |
|
#include "Elemlist.h" |
|
|
|
|
/* Paths from which looking for templates.*/ |
/* Paths from which looking for templates.*/ |
static Prop_Templates_Path *TemplateRepositoryPaths; |
static Prop_Templates_Path *TemplateRepositoryPaths; |
|
|
|
|
|
/*---------------------------------------------------------------------- |
|
IsTemplateInstanceDocument: Test if a document is a template instance |
|
doc : Document to test |
|
return : TRUE if the document is a template instance |
|
----------------------------------------------------------------------*/ |
|
ThotBool IsTemplateInstanceDocument(Document doc){ |
|
#ifdef TEMPLATES |
|
return (DocumentMeta[doc]!=NULL) && (DocumentMeta[doc]->template_url!=NULL); |
|
#else /* TEMPLATES */ |
|
return false; |
|
#endif /* TEMPLATES */ |
|
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
AllocTemplateRepositoryListElement: alloc an element for the list of template repositories. |
AllocTemplateRepositoryListElement: alloc an element for the list of template repositories. |
path : path of the new element |
path : path of the new element |
Line 238 void InitTemplates ()
|
Line 258 void InitTemplates ()
|
|
|
|
|
|
|
|
|
|
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
NewTemplate: Create the "new document from template" dialog |
NewTemplate: Create the "new document from template" dialog |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
Line 292 void CreateInstanceOfTemplate (Document
|
Line 315 void CreateInstanceOfTemplate (Document
|
} |
} |
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
|
giveItems : Lists type items from string |
|
example : "one two three" is extracted to {one, two, three} |
|
note : item type are setted to SimpleTypeNat |
|
text : text from which list items |
|
size : size of text in characters |
|
items : address of exctracted item list |
|
nbitems : items number in items list |
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
void giveItems (char *text, int size, struct menuType **items, int *nbitems) |
void giveItems (char *text, int size, struct menuType **items, int *nbitems) |
{ |
{ |
Line 403 void UseCreated (NotifyElement *event)
|
Line 433 void UseCreated (NotifyElement *event)
|
/* this Use element has already some content. It has already been |
/* this Use element has already some content. It has already been |
instanciated */ |
instanciated */ |
return; |
return; |
t = (XTigerTemplate) Get (Templates_Dic, DocumentMeta[doc]->template_url); |
t = (XTigerTemplate) Dictionary_Get (Templates_Dic, DocumentMeta[doc]->template_url); |
if (!t) |
if (!t) |
return; // no template ?!?! |
return; // no template ?!?! |
InstantiateUse (t, el, doc, TRUE); |
InstantiateUse (t, el, doc, TRUE); |
Line 435 ThotBool UseButtonClicked (NotifyElement
|
Line 465 ThotBool UseButtonClicked (NotifyElement
|
return FALSE; /* let Thot perform normal operation */ |
return FALSE; /* let Thot perform normal operation */ |
|
|
doc = event->document; |
doc = event->document; |
t = (XTigerTemplate) Get (Templates_Dic, DocumentMeta[doc]->template_url); |
t = (XTigerTemplate) Dictionary_Get (Templates_Dic, DocumentMeta[doc]->template_url); |
if (!t) |
if (!t) |
return FALSE; /* let Thot perform normal operation */ |
return FALSE; /* let Thot perform normal operation */ |
|
|
Line 579 ThotBool OptionButtonClicked (NotifyElem
|
Line 609 ThotBool OptionButtonClicked (NotifyElem
|
if (!grandChild) |
if (!grandChild) |
/* the "use" element is empty. Instantiate it */ |
/* the "use" element is empty. Instantiate it */ |
{ |
{ |
t = (XTigerTemplate) Get (Templates_Dic, DocumentMeta[doc]->template_url); |
t = (XTigerTemplate) Dictionary_Get (Templates_Dic, DocumentMeta[doc]->template_url); |
if (!t) |
if (!t) |
return FALSE; // no template ?!?! |
return FALSE; // no template ?!?! |
InstantiateUse (t, child, doc, TRUE); |
InstantiateUse (t, child, doc, TRUE); |
Line 623 ThotBool RepeatButtonClicked (NotifyElem
|
Line 653 ThotBool RepeatButtonClicked (NotifyElem
|
if (view != 1) |
if (view != 1) |
return FALSE; /* let Thot perform normal operation */ |
return FALSE; /* let Thot perform normal operation */ |
doc = event->document; |
doc = event->document; |
t = (XTigerTemplate) Get (Templates_Dic, DocumentMeta[doc]->template_url); |
t = (XTigerTemplate) Dictionary_Get (Templates_Dic, DocumentMeta[doc]->template_url); |
if (!t) |
if (!t) |
return FALSE; // no template ?!?! |
return FALSE; // no template ?!?! |
|
|
Line 718 void OpeningInstance (char *fileName, Do
|
Line 748 void OpeningInstance (char *fileName, Do
|
DocumentMeta[doc]->template_url = TtaStrdup (content); |
DocumentMeta[doc]->template_url = TtaStrdup (content); |
if (Templates_Dic == NULL) |
if (Templates_Dic == NULL) |
InitializeTemplateEnvironment (); |
InitializeTemplateEnvironment (); |
t = (XTigerTemplate) Get (Templates_Dic, content); |
t = (XTigerTemplate) Dictionary_Get (Templates_Dic, content); |
if (!t) |
if (!t) |
{ |
{ |
LoadTemplate (0, content); |
LoadTemplate (0, content); |
t = (XTigerTemplate) Get (Templates_Dic, content); |
t = (XTigerTemplate) Dictionary_Get (Templates_Dic, content); |
} |
} |
AddUser (t); |
AddUser (t); |
} |
} |
Line 746 ThotBool ClosingInstance(NotifyDialog* d
|
Line 776 ThotBool ClosingInstance(NotifyDialog* d
|
char *turl = DocumentMeta[dialog->document]->template_url; |
char *turl = DocumentMeta[dialog->document]->template_url; |
if (turl) |
if (turl) |
{ |
{ |
XTigerTemplate t = (XTigerTemplate) Get (Templates_Dic, turl); |
XTigerTemplate t = (XTigerTemplate) Dictionary_Get (Templates_Dic, turl); |
if (t) |
if (t) |
RemoveUser (t); |
RemoveUser (t); |
TtaFreeMemory (turl); |
TtaFreeMemory (turl); |
Line 754 ThotBool ClosingInstance(NotifyDialog* d
|
Line 784 ThotBool ClosingInstance(NotifyDialog* d
|
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
return FALSE; |
return FALSE; |
} |
} |
|
|
|
|
|
/*---------------------------------------------------------------------- |
|
GetFirstTemplateParentElement |
|
Return the first element wich has "Template" as SShema name or null if none. |
|
----------------------------------------------------------------------*/ |
|
ThotBool IsTemplateElement(Element elem) |
|
{ |
|
#ifdef TEMPLATES |
|
return strcmp(TtaGetSSchemaName(TtaGetElementType(elem).ElSSchema) |
|
, TEMPLATE_SSHEMA_NAME)==0; |
|
#else |
|
return FALSE; |
|
#endif /* TEMPLATES */ |
|
} |
|
|
|
|
|
/*---------------------------------------------------------------------- |
|
GetFirstTemplateParentElement |
|
Return the first element wich has "Template" as SShema name or null if none. |
|
----------------------------------------------------------------------*/ |
|
Element GetFirstTemplateParentElement(Element elem) |
|
{ |
|
#ifdef TEMPLATES |
|
elem = TtaGetParent(elem); |
|
while(elem!=NULL && strcmp(TtaGetSSchemaName(TtaGetElementType(elem).ElSSchema) |
|
, TEMPLATE_SSHEMA_NAME)!=0) |
|
{ |
|
elem = TtaGetParent(elem); |
|
} |
|
return elem; |
|
#else |
|
return NULL; |
|
#endif /* TEMPLATES */ |
|
} |