version 1.106, 2007/01/31 11:23:29
|
version 1.107, 2007/01/31 11:58:12
|
Line 290 void NewTemplate (Document doc, View vie
|
Line 290 void NewTemplate (Document doc, View vie
|
|
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
|
PreventReloadingTemplate |
|
Prevent reloading a template. |
|
You must call AllowReloadingTemplate when finish. |
|
Usefull for reload an instance without reloading the template. |
|
----------------------------------------------------------------------*/ |
|
void PreventReloadingTemplate(char* template_url) |
|
{ |
|
#ifdef TEMPLATES |
|
XTigerTemplate t = (XTigerTemplate) Dictionary_Get (Templates_Dic, template_url); |
|
if(t) |
|
t->users++; |
|
#endif /* TEMPLATES */ |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
|
AllowReloadingTemplate |
|
Allow reloading a template. |
|
You must call it after each PreventReloadingTemplate call. |
|
----------------------------------------------------------------------*/ |
|
void AllowReloadingTemplate(char* template_url) |
|
{ |
|
#ifdef TEMPLATES |
|
XTigerTemplate t = (XTigerTemplate) Dictionary_Get (Templates_Dic, template_url); |
|
if(t) |
|
t->users--; |
|
#endif /* TEMPLATES */ |
|
} |
|
|
|
|
|
/*---------------------------------------------------------------------- |
giveItems : Lists type items from string |
giveItems : Lists type items from string |
example : "one two three" is extracted to {one, two, three} |
example : "one two three" is extracted to {one, two, three} |
note : item type are setted to SimpleTypeNat |
note : item type are setted to SimpleTypeNat |
Line 1124 ThotBool TemplateElementWillBeCreated (N
|
Line 1154 ThotBool TemplateElementWillBeCreated (N
|
----------------------------------------------------------------------*/ |
----------------------------------------------------------------------*/ |
ThotBool TemplateElementWillBeDeleted (NotifyElement *event) |
ThotBool TemplateElementWillBeDeleted (NotifyElement *event) |
{ |
{ |
#ifdef AMAYA_DEBUG |
#ifdef TEMPLATES |
printf("TemplateElementWillBeDeleted\n"); |
Document doc = event->document; |
#endif /* AMAYA_DEBUG */ |
Element elem = event->element; |
|
Element xtElem, parent; |
|
ElementType xtType; |
|
char* type; |
|
Declaration dec; |
|
SSchema templateSSchema = TtaGetSSchema ("Template", event->document); |
|
XTigerTemplate t; |
|
|
|
printf("TemplateElementWillBeDeleted : %s\n", TtaGetElementTypeName(TtaGetElementType(elem))); |
|
|
|
if (templateSSchema == NULL) |
|
return FALSE; // let Thot do the job |
|
|
|
|
|
xtElem = GetFirstTemplateParentElement(elem); |
|
if(xtElem) |
|
{ |
|
xtType = TtaGetElementType(xtElem); |
|
if(xtType.ElSSchema==templateSSchema) |
|
{ |
|
t = (XTigerTemplate) Dictionary_Get (Templates_Dic, DocumentMeta[doc]->template_url); |
|
|
|
if(xtType.ElTypeNum==Template_EL_bag) |
|
return FALSE; // xt:bag always allow remove children. |
|
else if(xtType.ElTypeNum==Template_EL_useSimple || xtType.ElTypeNum==Template_EL_useEl) |
|
{ |
|
parent = TtaGetParent(elem); |
|
if(xtElem==parent){ |
|
//TODO replace current xt:use child element by its initial content (reset element) |
|
return TRUE; // Cant remove use direct child. It is mandatory. |
|
} |
|
type = GetAttributeStringValueFromNum(xtElem, Template_ATTR_currentType, NULL); |
|
dec = Template_GetDeclaration(t, type); |
|
TtaFreeMemory(type); |
|
if(dec->nature == XmlElementNat) |
|
return FALSE; // Can remove element only if in xt:use current type is base language element. |
|
else |
|
return TRUE; |
|
} |
|
else if(xtType.ElTypeNum==Template_EL_repeat) |
|
{ |
|
printf("Must remove xt:repeat element and validate xt:repeat content.\n"); |
|
TtaRemoveTree(elem, doc); |
|
TtaDeleteTree(elem, doc); |
|
//InstantiateRepeat(t, xtType, doc); |
|
} |
|
} |
|
} |
|
return TRUE; |
|
#else /* TEMPLATES */ |
return FALSE; |
return FALSE; |
|
#endif /* TEMPLATES */ |
} |
} |
|
|
|
|