version 1.103, 2007/01/26 13:15:48
|
version 1.104, 2007/01/29 11:17:16
|
Line 461 void Template_IncrementRepeatOccurNumber
|
Line 461 void Template_IncrementRepeatOccurNumber
|
char newVal[8]; |
char newVal[8]; |
int curVal; |
int curVal; |
|
|
current = GetAttributeStringValue(el, Template_ATTR_currentOccurs, NULL); |
current = GetAttributeStringValueFromNum(el, Template_ATTR_currentOccurs, NULL); |
curVal = atoi(current); |
if(current) |
curVal++; |
{ |
TtaFreeMemory(current); |
curVal = atoi(current); |
sprintf(newVal, "%d", curVal); |
curVal++; |
SetAttributeStringValue(el, Template_ATTR_currentOccurs, newVal); |
TtaFreeMemory(current); |
|
sprintf(newVal, "%d", curVal); |
|
SetAttributeStringValue(el, Template_ATTR_currentOccurs, newVal); |
|
} |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
} |
} |
|
|
Line 482 void Template_DecrementRepeatOccurNumber
|
Line 485 void Template_DecrementRepeatOccurNumber
|
char newVal[8]; |
char newVal[8]; |
int curVal; |
int curVal; |
|
|
current = GetAttributeStringValue(el, Template_ATTR_currentOccurs, NULL); |
current = GetAttributeStringValueFromNum(el, Template_ATTR_currentOccurs, NULL); |
curVal = atoi(current); |
if(current) |
curVal--; |
{ |
TtaFreeMemory(current); |
curVal = atoi(current); |
sprintf(newVal, "%d", curVal); |
curVal--; |
SetAttributeStringValue(el, Template_ATTR_currentOccurs, newVal); |
TtaFreeMemory(current); |
|
sprintf(newVal, "%d", curVal); |
|
SetAttributeStringValue(el, Template_ATTR_currentOccurs, newVal); |
|
} |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
} |
} |
|
|
Line 504 ThotBool Template_CanInsertRepeatChild(E
|
Line 510 ThotBool Template_CanInsertRepeatChild(E
|
char* max; |
char* max; |
char* current; |
char* current; |
int maxVal, curVal; |
int maxVal, curVal; |
|
Element child; |
|
|
max = GetAttributeStringValue(el, Template_ATTR_maxOccurs, NULL); |
max = GetAttributeStringValueFromNum(el, Template_ATTR_maxOccurs, NULL); |
if(!strcmp(max, "*")){ |
if(max) |
return TRUE; |
{ |
} |
if(!strcmp(max, "*")){ |
|
TtaFreeMemory(max); |
current = GetAttributeStringValue(el, Template_ATTR_currentOccurs, NULL); |
return TRUE; |
curVal = atoi(current); |
} |
maxVal = atoi(max); |
maxVal = atoi(max); |
|
TtaFreeMemory(max); |
return curVal<maxVal; |
|
|
|
|
current = GetAttributeStringValueFromNum(el, Template_ATTR_currentOccurs, NULL); |
|
if(current) |
|
{ |
|
curVal = atoi(current); |
|
TtaFreeMemory(current); |
|
} |
|
else |
|
{ |
|
curVal = 0; |
|
for(child = TtaGetFirstChild(el); child; TtaNextSibling(&child)) |
|
{ |
|
curVal++; |
|
} |
|
} |
|
|
|
return curVal<maxVal; |
|
} |
|
else |
|
return TRUE; |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
return FALSE; |
return FALSE; |
} |
} |
Line 683 ThotBool RepeatButtonClicked (NotifyElem
|
Line 708 ThotBool RepeatButtonClicked (NotifyElem
|
char* types; |
char* types; |
ThotBool oldStructureChecking; |
ThotBool oldStructureChecking; |
View view; |
View view; |
|
char* listtypes; |
|
char* result; |
|
|
|
|
TtaGetActiveView (&doc, &view); |
TtaGetActiveView (&doc, &view); |
if (view != 1) |
if (view != 1) |
Line 704 ThotBool RepeatButtonClicked (NotifyElem
|
Line 732 ThotBool RepeatButtonClicked (NotifyElem
|
if(Template_CanInsertRepeatChild(repeatEl)) |
if(Template_CanInsertRepeatChild(repeatEl)) |
{ |
{ |
firstEl = TtaGetFirstChild(repeatEl); |
firstEl = TtaGetFirstChild(repeatEl); |
types = GetAttributeStringValue(firstEl, Template_ATTR_types, NULL); |
types = GetAttributeStringValueFromNum(firstEl, Template_ATTR_types, NULL); |
|
if(types) |
char* listtypes = Template_ExpandTypes(t, types); |
|
char* result = QueryStringFromMenu(doc, listtypes); |
|
if(result) |
|
{ |
{ |
decl = Template_GetDeclaration(t, result); |
listtypes = Template_ExpandTypes(t, types); |
if(decl) |
result = QueryStringFromMenu(doc, listtypes); |
|
if(result) |
{ |
{ |
/* Prepare insertion.*/ |
decl = Template_GetDeclaration(t, result); |
oldStructureChecking = TtaGetStructureChecking (doc); |
if(decl) |
TtaSetStructureChecking (FALSE, doc); |
|
TtaOpenUndoSequence(doc, NULL, NULL, 0, 0); |
|
|
|
/* Insert. */ |
|
if(el==repeatEl) |
|
newEl = Template_InsertRepeatChildAfter(doc, repeatEl, decl, NULL); |
|
else |
|
newEl = Template_InsertRepeatChildAfter(doc, repeatEl, decl, el); |
|
|
|
/* Finish insertion.*/ |
|
TtaCloseUndoSequence(doc); |
|
TtaSetStructureChecking (oldStructureChecking, doc); |
|
|
|
firstEl = GetFirstEditableElement(newEl); |
|
if(firstEl) |
|
{ |
|
TtaSelectElement (doc, firstEl); |
|
TtaSetStatusSelectedElement(doc, view, firstEl); |
|
} |
|
else |
|
{ |
{ |
TtaSelectElement (doc, newEl); |
/* Prepare insertion.*/ |
TtaSetStatusSelectedElement(doc, view, newEl); |
oldStructureChecking = TtaGetStructureChecking (doc); |
|
TtaSetStructureChecking (FALSE, doc); |
|
TtaOpenUndoSequence(doc, NULL, NULL, 0, 0); |
|
|
|
/* Insert. */ |
|
if(el==repeatEl) |
|
newEl = Template_InsertRepeatChildAfter(doc, repeatEl, decl, NULL); |
|
else |
|
newEl = Template_InsertRepeatChildAfter(doc, repeatEl, decl, el); |
|
|
|
/* Finish insertion.*/ |
|
TtaCloseUndoSequence(doc); |
|
TtaSetStructureChecking (oldStructureChecking, doc); |
|
|
|
firstEl = GetFirstEditableElement(newEl); |
|
if(firstEl) |
|
{ |
|
TtaSelectElement (doc, firstEl); |
|
TtaSetStatusSelectedElement(doc, view, firstEl); |
|
} |
|
else |
|
{ |
|
TtaSelectElement (doc, newEl); |
|
TtaSetStatusSelectedElement(doc, view, newEl); |
|
} |
} |
} |
} |
} |
} |
} |
|
TtaFreeMemory(types); |
TtaFreeMemory(listtypes); |
TtaFreeMemory(listtypes); |
TtaFreeMemory(result); |
TtaFreeMemory(result); |
} |
} |
Line 772 ThotBool UseButtonClicked (NotifyElement
|
Line 803 ThotBool UseButtonClicked (NotifyElement
|
char* types; |
char* types; |
ThotBool oldStructureChecking; |
ThotBool oldStructureChecking; |
View view; |
View view; |
|
char* listtypes; |
|
char* result; |
|
|
TtaGetActiveView (&doc, &view); |
TtaGetActiveView (&doc, &view); |
if (view != 1) |
if (view != 1) |
Line 791 ThotBool UseButtonClicked (NotifyElement
|
Line 824 ThotBool UseButtonClicked (NotifyElement
|
} |
} |
else |
else |
{ |
{ |
types = GetAttributeStringValue(el, Template_ATTR_types, NULL); |
types = GetAttributeStringValueFromNum(el, Template_ATTR_types, NULL); |
|
if(types) |
char* listtypes = Template_ExpandTypes(t, types); |
|
char* result = QueryStringFromMenu(doc, listtypes); |
|
if(result) |
|
{ |
{ |
decl = Template_GetDeclaration(t, result); |
listtypes = Template_ExpandTypes(t, types); |
if(decl) |
result = QueryStringFromMenu(doc, listtypes); |
|
if(result) |
{ |
{ |
/* Prepare insertion.*/ |
decl = Template_GetDeclaration(t, result); |
oldStructureChecking = TtaGetStructureChecking (doc); |
if(decl) |
TtaSetStructureChecking (FALSE, doc); |
|
TtaOpenUndoSequence(doc, NULL, NULL, 0, 0); |
|
|
|
/* Insert */ |
|
newEl = Template_InsertUseChildren(doc, el, decl); |
|
|
|
for(child = TtaGetFirstChild(newEl); child; TtaNextSibling(&child)) |
|
{ |
|
TtaRegisterElementCreate(child, doc); |
|
} |
|
|
|
TtaChangeTypeOfElement(el, doc, Template_EL_useSimple); |
|
TtaRegisterElementTypeChange(el, Template_EL_useEl, doc); |
|
|
|
/* Finish insertion. */ |
|
TtaCloseUndoSequence(doc); |
|
TtaSetStructureChecking (oldStructureChecking, doc); |
|
|
|
firstEl = GetFirstEditableElement(newEl); |
|
if(firstEl) |
|
{ |
|
TtaSelectElement (doc, firstEl); |
|
TtaSetStatusSelectedElement(doc, view, firstEl); |
|
} |
|
else |
|
{ |
{ |
TtaSelectElement (doc, newEl); |
/* Prepare insertion.*/ |
TtaSetStatusSelectedElement(doc, view, newEl); |
oldStructureChecking = TtaGetStructureChecking (doc); |
|
TtaSetStructureChecking (FALSE, doc); |
|
TtaOpenUndoSequence(doc, NULL, NULL, 0, 0); |
|
|
|
/* Insert */ |
|
newEl = Template_InsertUseChildren(doc, el, decl); |
|
|
|
for(child = TtaGetFirstChild(newEl); child; TtaNextSibling(&child)) |
|
{ |
|
TtaRegisterElementCreate(child, doc); |
|
} |
|
|
|
TtaChangeTypeOfElement(el, doc, Template_EL_useSimple); |
|
TtaRegisterElementTypeChange(el, Template_EL_useEl, doc); |
|
|
|
/* Finish insertion. */ |
|
TtaCloseUndoSequence(doc); |
|
TtaSetStructureChecking (oldStructureChecking, doc); |
|
|
|
firstEl = GetFirstEditableElement(newEl); |
|
if(firstEl) |
|
{ |
|
TtaSelectElement (doc, firstEl); |
|
TtaSetStatusSelectedElement(doc, view, firstEl); |
|
} |
|
else |
|
{ |
|
TtaSelectElement (doc, newEl); |
|
TtaSetStatusSelectedElement(doc, view, newEl); |
|
} |
} |
} |
} |
} |
} |
} |
|
TtaFreeMemory(types); |
TtaFreeMemory(listtypes); |
TtaFreeMemory(listtypes); |
TtaFreeMemory(result); |
TtaFreeMemory(result); |
} |
} |
Line 1002 ThotBool ClosingInstance(NotifyDialog* d
|
Line 1038 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) Dictionary_Get (Templates_Dic, turl); |
XTigerTemplate t = (XTigerTemplate) Dictionary_Get (Templates_Dic, turl); |
if (t) |
if (t) |
RemoveUser (t); |
RemoveUser (t); |
TtaFreeMemory (turl); |
TtaFreeMemory (turl); |
} |
DocumentMeta[dialog->document]->template_url = NULL; |
|
} |
|
|
|
if(DocumentMeta[dialog->document]->template_version) |
|
{ |
|
TtaFreeMemory(DocumentMeta[dialog->document]->template_version); |
|
DocumentMeta[dialog->document]->template_version = NULL; |
|
} |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
return FALSE; |
return FALSE; |
} |
} |
Line 1058 ThotBool TemplateElementWillBeCreated (N
|
Line 1101 ThotBool TemplateElementWillBeCreated (N
|
ElementType elType = event->elementType; |
ElementType elType = event->elementType; |
Element parent = event->element; |
Element parent = event->element; |
ElementType parentType = TtaGetElementType(parent); |
ElementType parentType = TtaGetElementType(parent); |
Element ancestor; |
// Element ancestor; |
ElementType ancestorType; |
// ElementType ancestorType; |
|
|
SSchema templateSSchema = TtaGetSSchema ("Template", event->document); |
SSchema templateSSchema = TtaGetSSchema ("Template", event->document); |
|
|
Line 1089 ThotBool TemplateElementWillBeCreated (N
|
Line 1132 ThotBool TemplateElementWillBeCreated (N
|
// printf(" >> %s:%s\n", TtaGetSSchemaName(ancestorType.ElSSchema), TtaGetElementTypeName(ancestorType)); |
// printf(" >> %s:%s\n", TtaGetSSchemaName(ancestorType.ElSSchema), TtaGetElementTypeName(ancestorType)); |
// if (ancestorType.ElSSchema == templateSSchema && ancestorType.ElTypeNum == Template_EL_bag) |
// if (ancestorType.ElSSchema == templateSSchema && ancestorType.ElTypeNum == Template_EL_bag) |
// { |
// { |
// char* types = GetAttributeStringValue(ancestor, Template_ATTR_types, NULL); |
// char* types = GetAttributeStringValueFromNum(ancestor, Template_ATTR_types, NULL); |
// ThotBool b = Template_CanInsertElementInBag(event->document, elType, types); |
// ThotBool b = Template_CanInsertElementInBag(event->document, elType, types); |
// printf(" Intend to insert xt:bag element : %s\n", b?"TRUE":"FALSE"); |
// printf(" Intend to insert xt:bag element : %s\n", b?"TRUE":"FALSE"); |
// return !b; |
// return !b; |