version 1.248, 2009/09/03 16:14:27
|
version 1.249, 2009/09/07 14:01:56
|
Line 748 void UseCreated (NotifyElement *event)
|
Line 748 void UseCreated (NotifyElement *event)
|
} |
} |
// look for the enclosing target element |
// look for the enclosing target element |
parent = GetParentLine (parent, templateSSchema); |
parent = GetParentLine (parent, templateSSchema); |
InstantiateUse (t, el, doc, parent, TRUE); |
InstantiateUse (t, el, doc, parent, TRUE, FALSE); |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
} |
} |
|
|
Line 1275 ThotBool UseSimpleButtonClicked (NotifyE
|
Line 1275 ThotBool UseSimpleButtonClicked (NotifyE
|
ThotBool OptionButtonClicked (NotifyElement *event) |
ThotBool OptionButtonClicked (NotifyElement *event) |
{ |
{ |
#ifdef TEMPLATES |
#ifdef TEMPLATES |
Element el, child, next, parent; |
Element el, child, parent; |
ElementType useType, childType; |
ElementType useType, childType; |
Document doc; |
Document doc; |
XTigerTemplate t; |
XTigerTemplate t; |
Line 1319 ThotBool OptionButtonClicked (NotifyElem
|
Line 1319 ThotBool OptionButtonClicked (NotifyElem
|
|
|
// look for the enclosing target element |
// look for the enclosing target element |
parent = GetParentLine (el, useType.ElSSchema); |
parent = GetParentLine (el, useType.ElSSchema); |
InstantiateUse (t, el, doc, parent, TRUE); |
InstantiateUse (t, el, doc, parent, TRUE, FALSE); |
SetAttributeIntValue (el, Template_ATTR_option, |
SetAttributeIntValue (el, Template_ATTR_option, |
Template_ATTR_option_VAL_option_set, TRUE); |
Template_ATTR_option_VAL_option_set, TRUE); |
} |
} |
else |
else |
/* remove the content of the "use" element */ |
/* remove the content of the "use" element */ |
{ |
{ |
do |
child = Template_FillEmpty (el, doc, TRUE); |
{ |
|
next = child; |
|
TtaNextSibling (&next); |
|
TtaRegisterElementDelete(child, doc); |
|
TtaDeleteTree (child, doc); |
|
child = next; |
|
} |
|
while (next); |
|
child = Template_FillEmpty (el, doc); |
|
if (child) |
|
{ |
|
TtaRegisterElementCreate (child, doc); |
|
TtaSetAccessRight (child, ReadOnly, doc); |
|
} |
|
SetAttributeIntValue (el, Template_ATTR_option, |
SetAttributeIntValue (el, Template_ATTR_option, |
Template_ATTR_option_VAL_option_unset, TRUE); |
Template_ATTR_option_VAL_option_unset, TRUE); |
} |
} |
child = TtaGetFirstChild (el); |
child = TtaGetFirstChild (el); |
TtaSelectElement (doc, child); |
TtaSelectElement (doc, child); |
TtaCloseUndoSequence(doc); |
TtaCloseUndoSequence (doc); |
TtaSetDocumentModified (doc); |
TtaSetDocumentModified (doc); |
return TRUE; /* don't let Thot perform normal operation */ |
return TRUE; /* don't let Thot perform normal operation */ |
#endif /* TEMPLATES */ |
#endif /* TEMPLATES */ |
Line 1383 void Template_FillFromDocument (Document
|
Line 1369 void Template_FillFromDocument (Document
|
Template_FixAccessRight (t, root, doc); |
Template_FixAccessRight (t, root, doc); |
TtaUpdateAccessRightInViews (doc, root); |
TtaUpdateAccessRightInViews (doc, root); |
// Parse template to fill structure and remove extra data |
// Parse template to fill structure and remove extra data |
ParseTemplate (t, root, doc, NULL, FALSE); |
ParseTemplate (t, root, doc, NULL, TRUE); |
} |
} |
#ifdef TEMPLATE_DEBUG |
#ifdef TEMPLATE_DEBUG |
else if (t->state & templLibraryFlag) |
else if (t->state & templLibraryFlag) |
Line 1773 ThotBool TemplateElementWillBeCreated (N
|
Line 1759 ThotBool TemplateElementWillBeCreated (N
|
return FALSE; |
return FALSE; |
} |
} |
|
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
TemplateElementWillBeDeleted |
TemplateElementWillBeDeleted |
Processed when an element will be deleted in a template context. |
Processed when an element will be deleted in a template context. |
Line 1782 ThotBool TemplateElementWillBeDeleted (N
|
Line 1769 ThotBool TemplateElementWillBeDeleted (N
|
#ifdef TEMPLATES |
#ifdef TEMPLATES |
Document doc = event->document; |
Document doc = event->document; |
Element el = event->element; |
Element el = event->element; |
Element xtEl, parent = NULL, sibling, next, child; |
Element xtEl, parent = NULL, sibling; |
ElementType xtType, elType; |
ElementType xtType, elType; |
SSchema templateSSchema; |
SSchema templateSSchema; |
XTigerTemplate t; |
XTigerTemplate t; |
|
|
if (event->info==1) |
if (event->info == 1) |
return FALSE; |
return FALSE; |
|
|
if (!TtaGetDocumentAccessMode(doc)) |
if (!TtaGetDocumentAccessMode(doc)) |
Line 1803 ThotBool TemplateElementWillBeDeleted (N
|
Line 1790 ThotBool TemplateElementWillBeDeleted (N
|
elType = TtaGetElementType (el); |
elType = TtaGetElementType (el); |
xtEl = GetFirstTemplateParentElement (el); |
xtEl = GetFirstTemplateParentElement (el); |
if (elType.ElSSchema == templateSSchema && |
if (elType.ElSSchema == templateSSchema && |
(elType.ElTypeNum == Template_EL_repeat || |
elType.ElTypeNum == Template_EL_repeat) |
elType.ElTypeNum == Template_EL_bag)) |
{ |
|
TtaOpenUndoSequence (doc, el, el, 0, 0); |
|
CleanUpRepeat (el, doc, TRUE); |
|
TtaCloseUndoSequence (doc); |
|
TtaSelectElement (doc, el); |
|
TtaSetDocumentModified (doc); |
|
} |
|
else if (elType.ElSSchema == templateSSchema && |
|
elType.ElTypeNum == Template_EL_bag) |
{ |
{ |
// clean up the content of the bag or repeat |
// clean up the content of the bag or repeat |
sibling = TtaGetFirstChild (el); |
sibling = TtaGetFirstChild (el); |
xtEl = el; |
xtEl = el; |
TtaOpenUndoSequence (doc, el, el, 0, 0); |
TtaOpenUndoSequence (doc, el, el, 0, 0); |
if (elType.ElTypeNum == Template_EL_repeat) |
|
{ |
|
// keep the first item |
|
elType = TtaGetElementType (sibling); |
|
if (elType.ElTypeNum == Template_EL_useSimple) |
|
{ |
|
// replace it by an empty use element |
|
child = TtaGetFirstChild (sibling); |
|
do |
|
{ |
|
next = child; |
|
TtaNextSibling (&next); |
|
TtaRegisterElementDelete(child, doc); |
|
TtaDeleteTree (child, doc); |
|
child = next; |
|
} |
|
while (next); |
|
child = Template_FillEmpty (sibling, doc); |
|
TtaChangeTypeOfElement (sibling, doc, Template_EL_useEl); |
|
TtaRegisterElementTypeChange (sibling, Template_EL_useSimple, doc); |
|
} |
|
TtaNextSibling (&sibling); |
|
} |
|
while (sibling) |
while (sibling) |
{ |
{ |
el = sibling; |
el = sibling; |
Line 1840 ThotBool TemplateElementWillBeDeleted (N
|
Line 1812 ThotBool TemplateElementWillBeDeleted (N
|
TtaRegisterElementDelete (el, doc); |
TtaRegisterElementDelete (el, doc); |
TtaDeleteTree (el, doc); |
TtaDeleteTree (el, doc); |
} |
} |
if (xtType.ElTypeNum == Template_EL_repeat) |
|
{ |
|
// regenerate the minimum of instances |
|
parent = GetParentLine (xtEl, templateSSchema); |
|
InstantiateRepeat (t, xtEl, doc, parent, TRUE); |
|
} |
|
TtaCloseUndoSequence (doc); |
TtaCloseUndoSequence (doc); |
TtaSelectElement (doc, xtEl); |
TtaSelectElement (doc, xtEl); |
|
TtaSetDocumentModified (doc); |
} |
} |
else if (xtEl) |
else if (xtEl) |
{ |
{ |
Line 1903 ThotBool TemplateElementWillBeDeleted (N
|
Line 1870 ThotBool TemplateElementWillBeDeleted (N
|
TtaRegisterElementDelete (el, doc); |
TtaRegisterElementDelete (el, doc); |
TtaDeleteTree (el, doc); |
TtaDeleteTree (el, doc); |
} |
} |
else if (elType.ElTypeNum == Template_EL_useSimple) |
else |
{ |
// keep an empty use element |
// keep an empty use element |
Template_FillEmpty (el, doc, TRUE); |
child = TtaGetFirstChild (el); |
TtaSetDocumentModified (doc); |
do |
|
{ |
|
next = child; |
|
TtaNextSibling (&next); |
|
TtaRegisterElementDelete(child, doc); |
|
TtaDeleteTree (child, doc); |
|
child = next; |
|
} |
|
while (next); |
|
child = Template_FillEmpty (el, doc); |
|
TtaChangeTypeOfElement (el, doc, Template_EL_useEl); |
|
TtaRegisterElementTypeChange (el, Template_EL_useSimple, doc); |
|
} |
|
} |
} |
else if (xtType.ElSSchema == templateSSchema && |
else if (xtType.ElSSchema == templateSSchema && |
xtType.ElTypeNum == Template_EL_bag) |
xtType.ElTypeNum == Template_EL_bag) |
Line 1927 ThotBool TemplateElementWillBeDeleted (N
|
Line 1881 ThotBool TemplateElementWillBeDeleted (N
|
// delete the use within a bag or a repeat |
// delete the use within a bag or a repeat |
TtaRegisterElementDelete (el, doc); |
TtaRegisterElementDelete (el, doc); |
TtaDeleteTree (el, doc); |
TtaDeleteTree (el, doc); |
|
TtaSetDocumentModified (doc); |
} |
} |
TtaCloseUndoSequence (doc); |
TtaCloseUndoSequence (doc); |
TtaSelectElement (doc, xtEl); |
TtaSelectElement (doc, xtEl); |
Line 2988 Element Template_CreateUseFromSelection
|
Line 2943 Element Template_CreateUseFromSelection
|
TtaInsertFirstChild (&comp, parent, doc); |
TtaInsertFirstChild (&comp, parent, doc); |
SetAttributeStringValue (comp, Template_ATTR_name, buffer); |
SetAttributeStringValue (comp, Template_ATTR_name, buffer); |
// generate a content |
// generate a content |
selElem = Template_FillEmpty (comp, doc); |
selElem = Template_FillEmpty (comp, doc, FALSE); |
TtaRegisterElementCreate (comp, doc); |
TtaRegisterElementCreate (comp, doc); |
TtaSelectElement (doc, selElem); |
TtaSelectElement (doc, selElem); |
// register document modification |
// register document modification |