version 1.235, 2009/06/24 15:40:40
|
version 1.236, 2009/06/25 13:41:21
|
Line 1100 ThotBool ElementIsOptional (Element el)
|
Line 1100 ThotBool ElementIsOptional (Element el)
|
|
|
elType = TtaGetElementType (el); |
elType = TtaGetElementType (el); |
attType.AttrSSchema = elType.ElSSchema; |
attType.AttrSSchema = elType.ElSSchema; |
attType.AttrTypeNum = Template_ATTR_types; |
attType.AttrTypeNum = Template_ATTR_option; |
att = TtaGetAttribute (el, attType); |
att = TtaGetAttribute (el, attType); |
return (att != NULL); |
return (att != NULL); |
} |
} |
Line 1158 ThotBool UseButtonClicked (NotifyElement
|
Line 1158 ThotBool UseButtonClicked (NotifyElement
|
result = QueryStringFromMenu(doc, listtypes, option); |
result = QueryStringFromMenu(doc, listtypes, option); |
if (result) |
if (result) |
{ |
{ |
decl = Template_GetDeclaration(t, result); |
decl = Template_GetDeclaration (t, result); |
if (decl || !strcmp (result, " ")) |
if (decl || !strcmp (result, " ")) |
{ |
{ |
/* Prepare insertion.*/ |
/* Prepare insertion.*/ |
Line 1181 ThotBool UseButtonClicked (NotifyElement
|
Line 1181 ThotBool UseButtonClicked (NotifyElement
|
newEl = Template_InsertUseChildren(doc, el, decl, parent, TRUE); |
newEl = Template_InsertUseChildren(doc, el, decl, parent, TRUE); |
else |
else |
{ |
{ |
newEl = Template_GetNewSimpleTypeInstance(doc, el, decl); |
newEl = Template_GetNewSimpleTypeInstance(doc); |
newEl = InsertWithNotify (newEl, NULL, el, doc); |
newEl = InsertWithNotify (newEl, NULL, el, doc); |
} |
} |
for (child = TtaGetFirstChild(newEl); child; TtaNextSibling(&child)) |
for (child = TtaGetFirstChild(newEl); child; TtaNextSibling(&child)) |
TtaRegisterElementCreate (child, doc); |
TtaRegisterElementCreate (child, doc); |
|
|
/* xt:currentType attribute.*/ |
/* xt:currentType attribute.*/ |
SetAttributeStringValueWithUndo(el, Template_ATTR_currentType, result); |
SetAttributeStringValueWithUndo (el, Template_ATTR_currentType, result); |
|
|
/* Finish insertion. */ |
/* Finish insertion. */ |
TtaCloseUndoSequence(doc); |
TtaCloseUndoSequence(doc); |
TtaSetDocumentModified (doc); |
TtaSetDocumentModified (doc); |
Line 1257 ThotBool UseSimpleButtonClicked (NotifyE
|
Line 1256 ThotBool UseSimpleButtonClicked (NotifyE
|
ThotBool OptionButtonClicked (NotifyElement *event) |
ThotBool OptionButtonClicked (NotifyElement *event) |
{ |
{ |
#ifdef TEMPLATES |
#ifdef TEMPLATES |
Element useEl, contentEl, next, parent; |
Element el, child, next, parent; |
ElementType useType; |
ElementType useType, childType; |
Document doc; |
Document doc; |
XTigerTemplate t; |
XTigerTemplate t; |
View view; |
View view; |
Line 1273 ThotBool OptionButtonClicked (NotifyElem
|
Line 1272 ThotBool OptionButtonClicked (NotifyElem
|
return FALSE; /* let Thot perform normal operation */ |
return FALSE; /* let Thot perform normal operation */ |
|
|
doc = event->document; |
doc = event->document; |
useEl = event->element; |
el = event->element; |
if (!useEl) |
if (!el) |
return FALSE; /* let Thot perform normal operation */ |
return FALSE; /* let Thot perform normal operation */ |
useType = TtaGetElementType (useEl); |
useType = TtaGetElementType (el); |
if (useType.ElTypeNum != Template_EL_useEl && |
if (useType.ElTypeNum != Template_EL_useEl && |
useType.ElTypeNum != Template_EL_useSimple) |
useType.ElTypeNum != Template_EL_useSimple) |
return FALSE; |
return FALSE; |
|
|
TtaOpenUndoSequence(doc, NULL, NULL, 0, 0); |
TtaOpenUndoSequence(doc, NULL, NULL, 0, 0); |
TtaCancelSelection (doc); |
TtaCancelSelection (doc); |
contentEl = TtaGetFirstChild (useEl); |
child = TtaGetFirstChild (el); |
if (!contentEl) |
childType = TtaGetElementType (child); |
|
if (child == NULL || |
|
(childType.ElSSchema == useType.ElSSchema && |
|
childType.ElTypeNum == Template_EL_TemplateObject)) |
/* the "use" element is empty. Instantiate it */ |
/* the "use" element is empty. Instantiate it */ |
{ |
{ |
|
if (child) |
|
{ |
|
TtaRegisterElementDelete (child, doc); |
|
TtaDeleteTree (child, doc); |
|
} |
t = GetXTigerDocTemplate (doc); |
t = GetXTigerDocTemplate (doc); |
if (!t) |
if (!t) |
return FALSE; // no template ?!?! |
return FALSE; // no template ?!?! |
|
|
// look for the enclosing target element |
// look for the enclosing target element |
parent = GetParentLine (useEl, useType.ElSSchema); |
parent = GetParentLine (el, useType.ElSSchema); |
InstantiateUse (t, useEl, doc, parent, TRUE); |
InstantiateUse (t, el, doc, parent, TRUE); |
|
SetAttributeIntValue (el, Template_ATTR_option, |
|
Template_ATTR_option_VAL_option_set, TRUE); |
} |
} |
else |
else |
/* remove the content of the "use" element */ |
/* remove the content of the "use" element */ |
{ |
{ |
do |
do |
{ |
{ |
next = contentEl; |
next = child; |
TtaNextSibling (&next); |
TtaNextSibling (&next); |
TtaRegisterElementDelete(contentEl, doc); |
TtaRegisterElementDelete(child, doc); |
TtaDeleteTree (contentEl, doc); |
TtaDeleteTree (child, doc); |
contentEl = next; |
child = next; |
} |
} |
while (next); |
while (next); |
if (NeedAMenu (useEl, doc)) |
childType.ElSSchema = useType.ElSSchema; |
{ |
childType.ElTypeNum = Template_EL_TemplateObject; |
TtaChangeTypeOfElement (useEl, doc, Template_EL_useEl); |
child = TtaNewElement (doc, childType); |
TtaRegisterElementTypeChange(useEl, Template_EL_useSimple, doc); |
TtaInsertFirstChild (&child, el, doc); |
} |
TtaRegisterElementCreate (child, doc); |
|
TtaSetAccessRight (child, ReadOnly, doc); |
|
SetAttributeIntValue (el, Template_ATTR_option, |
|
Template_ATTR_option_VAL_option_unset, TRUE); |
} |
} |
TtaSelectElement (doc, event->element); |
child = TtaGetFirstChild (el); |
|
TtaSelectElement (doc, child); |
TtaCloseUndoSequence(doc); |
TtaCloseUndoSequence(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 */ |
return TRUE; |
return TRUE; |
} |
} |
|
|
|
|
|
|
/*---------------------------------------------------------------------- |
/*---------------------------------------------------------------------- |
Template_FillFromDocument |
Template_FillFromDocument |
Fill XTigerTemplate structure with the content of the document. |
Fill XTigerTemplate structure with the content of the document. |