version 1.40, 2009/06/19 08:52:43
|
version 1.41, 2009/08/12 10:32:05
|
Line 299 ThotBool CheckTemplateAttrInMenu (Notify
|
Line 299 ThotBool CheckTemplateAttrInMenu (Notify
|
{ |
{ |
#ifdef TEMPLATES |
#ifdef TEMPLATES |
Document doc = event->document; |
Document doc = event->document; |
Element elem; |
Element elem, parent = event->element; |
Element parent = event->element; |
|
ElementType elType; |
ElementType elType; |
|
SSchema schema; |
AttributeType attrType; |
AttributeType attrType; |
Attribute attr; |
Attribute attr; |
char *attrName; |
char *attrName; |
Line 311 ThotBool CheckTemplateAttrInMenu (Notify
|
Line 311 ThotBool CheckTemplateAttrInMenu (Notify
|
/* Prevent from showing attributes for template instance but not templates. */ |
/* Prevent from showing attributes for template instance but not templates. */ |
if (IsTemplateInstanceDocument(doc)) |
if (IsTemplateInstanceDocument(doc)) |
{ |
{ |
|
schema = TtaGetSSchema ("Template", doc); |
/* Prevent if attribute's element is not a descendant of xt:use */ |
/* Prevent if attribute's element is not a descendant of xt:use */ |
/* Dont prevent if descendant of xt:bag. */ |
/* Dont prevent if descendant of xt:bag. */ |
elem = GetFirstTemplateParentElement(parent); |
elem = GetFirstTemplateParentElement (parent); |
if (!elem) |
if (elem) |
return TRUE; |
{ |
elType = TtaGetElementType(elem); |
elType = TtaGetElementType (elem); |
if (elType.ElTypeNum == Template_EL_bag) |
if (elType.ElTypeNum == Template_EL_bag) |
return FALSE; /* let Thot perform normal operation */ |
return FALSE; /* let Thot perform normal operation */ |
if (elType.ElTypeNum != Template_EL_useSimple) |
if (elType.ElTypeNum != Template_EL_useSimple) |
return TRUE; |
return TRUE; |
if (!TtaIsReadOnly (parent)) |
if (!TtaIsReadOnly (parent)) |
return FALSE; /* let Thot perform normal operation */ |
return FALSE; /* let Thot perform normal operation */ |
|
} |
/* Search for the corresponding xt:attribute element*/ |
/* Search for the corresponding xt:attribute element*/ |
attrName = TtaGetAttributeName(event->attributeType); |
attrName = TtaGetAttributeName (event->attributeType); |
attrType.AttrSSchema = TtaGetSSchema ("Template", doc); |
attrType.AttrSSchema = schema; |
for (elem = TtaGetFirstChild(parent); elem; TtaNextSibling(&elem)) |
for (elem = TtaGetFirstChild (parent); elem; TtaNextSibling (&elem)) |
{ |
{ |
attrType.AttrTypeNum = Template_ATTR_ref_name; |
attrType.AttrTypeNum = Template_ATTR_ref_name; |
elType = TtaGetElementType(elem); |
elType = TtaGetElementType(elem); |
if (elType.ElTypeNum == Template_EL_attribute && |
if (elType.ElTypeNum == Template_EL_attribute && elType.ElSSchema == schema) |
elType.ElSSchema == TtaGetSSchema ("Template", doc)) |
|
{ |
{ |
attr = TtaGetAttribute(elem, attrType); |
attr = TtaGetAttribute(elem, attrType); |
if (attr) |
if (attr) |
Line 362 ThotBool CheckTemplateAttrInMenu (Notify
|
Line 362 ThotBool CheckTemplateAttrInMenu (Notify
|
if (useAt == Template_ATTR_useAt_VAL_prohibited) |
if (useAt == Template_ATTR_useAt_VAL_prohibited) |
return TRUE; |
return TRUE; |
if (useAt == Template_ATTR_useAt_VAL_required) |
if (useAt == Template_ATTR_useAt_VAL_required) |
{ |
/* Force the usage of this attribute.*/ |
/* Force the usage of this attribute.*/ |
event->restr.RestrFlags |= attr_mandatory; |
event->restr.RestrFlags |= attr_mandatory; |
|
} |
|
|
|
/* Get 'fixed' attr value. */ |
/* Get 'fixed' attr value. */ |
attrType.AttrTypeNum = Template_ATTR_fixed; |
attrType.AttrTypeNum = Template_ATTR_fixed; |
Line 518 void DumpTemplateElement (Element el, Do
|
Line 516 void DumpTemplateElement (Element el, Do
|
case Template_EL_useSimple: |
case Template_EL_useSimple: |
case Template_EL_useEl: |
case Template_EL_useEl: |
str = GetAttributeStringValueFromNum(el, Template_ATTR_title, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_title, NULL); |
printf(" label=%s", str); |
printf (" label=%s", str); |
TtaFreeMemory(str); |
TtaFreeMemory(str); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_types, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_types, NULL); |
printf(" types=%s", str); |
printf (" types=%s", str); |
TtaFreeMemory(str); |
TtaFreeMemory(str); |
attType.AttrSSchema = elType.ElSSchema; |
attType.AttrSSchema = elType.ElSSchema; |
attType.AttrTypeNum = Template_ATTR_option; |
attType.AttrTypeNum = Template_ATTR_option; |
att = TtaGetAttribute (el, attType); |
att = TtaGetAttribute (el, attType); |
if (att) |
if (att) |
printf(" option"); |
printf (" option"); |
break; |
break; |
case Template_EL_bag: |
case Template_EL_bag: |
str = GetAttributeStringValueFromNum(el, Template_ATTR_title, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_title, NULL); |
Line 539 void DumpTemplateElement (Element el, Do
|
Line 537 void DumpTemplateElement (Element el, Do
|
break; |
break; |
case Template_EL_attribute: |
case Template_EL_attribute: |
str = GetAttributeStringValueFromNum(el, Template_ATTR_ref_name, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_ref_name, NULL); |
printf(" name=%s", str); |
printf (" name=%s", str); |
TtaFreeMemory(str); |
TtaFreeMemory(str); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_type, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_type, NULL); |
printf(" type=%s", str); |
printf (" type=%s", str); |
TtaFreeMemory(str); |
TtaFreeMemory(str); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_useAt, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_useAt, NULL); |
printf(" use=%s", str); |
printf (" use=%s", str); |
TtaFreeMemory(str); |
TtaFreeMemory(str); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_defaultAt, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_defaultAt, NULL); |
printf(" default=%s", str); |
printf (" default=%s", str); |
TtaFreeMemory(str); |
TtaFreeMemory(str); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_fixed, NULL); |
str = GetAttributeStringValueFromNum(el, Template_ATTR_fixed, NULL); |
printf(" fixed=%s", str); |
printf (" fixed=%s", str); |
TtaFreeMemory(str); |
TtaFreeMemory(str); |
break; |
break; |
} |
} |