version 1.153, 2007/10/05 15:26:19
|
version 1.154, 2007/10/15 10:46:02
|
Line 623 void UseCreated (NotifyElement *event)
|
Line 623 void UseCreated (NotifyElement *event)
|
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
} |
} |
|
|
/*---------------------------------------------------------------------- |
|
Template_IncrementRepeatOccurNumber |
|
Increment the number of occurs of a xt:repeat |
|
@param el element (xt:repeat) |
|
----------------------------------------------------------------------*/ |
|
void Template_IncrementRepeatOccurNumber(Element el) |
|
{ |
|
#ifdef TEMPLATES |
|
char* current; |
|
char newVal[8]; |
|
int curVal; |
|
|
|
current = GetAttributeStringValueFromNum(el, Template_ATTR_currentOccurs, NULL); |
|
if (current) |
|
{ |
|
curVal = atoi(current); |
|
curVal++; |
|
TtaFreeMemory(current); |
|
sprintf(newVal, "%d", curVal); |
|
SetAttributeStringValue(el, Template_ATTR_currentOccurs, newVal); |
|
} |
|
#endif /* TEMPLATES */ |
|
} |
|
|
|
/*---------------------------------------------------------------------- |
|
Template_DecrementRepeatOccurNumber |
|
Decrement the number of occurs of a xt:repeat |
|
@param el element (xt:repeat) |
|
----------------------------------------------------------------------*/ |
|
void Template_DecrementRepeatOccurNumber(Element el) |
|
{ |
|
#ifdef TEMPLATES |
|
char* current; |
|
char newVal[8]; |
|
int curVal; |
|
|
|
current = GetAttributeStringValueFromNum(el, Template_ATTR_currentOccurs, NULL); |
|
if (current) |
|
{ |
|
curVal = atoi(current); |
|
curVal--; |
|
TtaFreeMemory(current); |
|
sprintf(newVal, "%d", curVal); |
|
SetAttributeStringValue(el, Template_ATTR_currentOccurs, newVal); |
|
} |
|
#endif /* TEMPLATES */ |
|
} |
|
|
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Template_CanInsertRepeatChild |
Template_CanInsertRepeatChild |
Line 681 void Template_DecrementRepeatOccurNumber
|
Line 633 void Template_DecrementRepeatOccurNumber
|
ThotBool Template_CanInsertRepeatChild(Element el) |
ThotBool Template_CanInsertRepeatChild(Element el) |
{ |
{ |
#ifdef TEMPLATES |
#ifdef TEMPLATES |
char* max; |
char *max; |
char* current; |
int maxVal, curVal; |
int maxVal, curVal; |
Element child; |
Element child; |
|
|
|
max = GetAttributeStringValueFromNum(el, Template_ATTR_maxOccurs, NULL); |
max = GetAttributeStringValueFromNum(el, Template_ATTR_maxOccurs, NULL); |
if (max) |
if (max) |
{ |
|
if (!strcmp(max, "*")) |
|
{ |
|
TtaFreeMemory(max); |
|
return TRUE; |
|
} |
|
maxVal = atoi (max); |
|
TtaFreeMemory (max); |
|
|
|
current = GetAttributeStringValueFromNum(el, Template_ATTR_currentOccurs, NULL); |
|
if (current) |
|
{ |
|
curVal = atoi (current); |
|
TtaFreeMemory (current); |
|
} |
|
else |
|
{ |
{ |
|
if (!strcmp(max, "*")) |
|
{ |
|
TtaFreeMemory(max); |
|
return TRUE; |
|
} |
|
maxVal = atoi (max); |
|
TtaFreeMemory (max); |
curVal = 0; |
curVal = 0; |
for (child = TtaGetFirstChild(el); child; TtaNextSibling(&child)) |
for (child = TtaGetFirstChild(el); child; TtaNextSibling(&child)) |
{ |
|
curVal++; |
curVal++; |
} |
return (curVal < maxVal); |
} |
} |
|
|
return curVal<maxVal; |
|
} |
|
else |
else |
return TRUE; |
return TRUE; |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
Line 1496 ThotBool TemplateElementWillBeDeleted (N
|
Line 1434 ThotBool TemplateElementWillBeDeleted (N
|
sibling = TtaGetSuccessor(elem); |
sibling = TtaGetSuccessor(elem); |
TtaRegisterElementDelete(elem, doc); |
TtaRegisterElementDelete(elem, doc); |
TtaDeleteTree(elem, doc); |
TtaDeleteTree(elem, doc); |
Template_DecrementRepeatOccurNumber(xtElem); |
|
InstantiateRepeat(t, xtElem, doc, TRUE); |
InstantiateRepeat(t, xtElem, doc, TRUE); |
leaf = TtaGetFirstLeaf (sibling); |
leaf = TtaGetFirstLeaf (sibling); |
elType = TtaGetElementType (leaf); |
elType = TtaGetElementType (leaf); |