Annotation of Amaya/amaya/XLinkedit.c, revision 1.10
1.1 cvs 1: /*
2: *
1.10 ! vatton 3: * (c) COPYRIGHT INRIA and W3C, 2000-2004
1.1 cvs 4: * Please first read the full copyright statement in file COPYRIGHT.
5: *
6: */
7:
8: /*
9: * This module contains editing functions for handling XLink hypertext links
10: *
1.7 cvs 11: * Authors: V. Quint
12: * L. Carcone (namespaces)
1.1 cvs 13: *
14: */
15:
16: /* Included headerfiles */
1.9 gully 17: #undef THOT_EXPORT
18: #define THOT_EXPORT extern
1.1 cvs 19: #include "amaya.h"
20: #include "XLink.h"
21:
1.2 cvs 22: #include "HTMLedit_f.h"
23:
1.1 cvs 24: /*----------------------------------------------------------------------
25: SetXLinkTypeSimple attach an attribute xlink:type="simple" to element el
26: ----------------------------------------------------------------------*/
1.6 vatton 27: void SetXLinkTypeSimple (Element el, Document doc, ThotBool withUndo)
1.1 cvs 28: {
29: AttributeType attrType;
30: Attribute attr;
31: SSchema XLinkSchema;
1.9 gully 32: ThotBool new_;
1.1 cvs 33:
1.3 cvs 34: XLinkSchema = TtaGetSSchema ("XLink", doc);
1.1 cvs 35: attrType.AttrSSchema = XLinkSchema;
36: attrType.AttrTypeNum = XLink_ATTR_type;
37: attr = TtaGetAttribute (el, attrType);
38: if (attr == NULL)
39: {
40: attr = TtaNewAttribute (attrType);
41: TtaAttachAttribute (el, attr, doc);
1.9 gully 42: new_ = TRUE;
1.1 cvs 43: }
44: else
45: {
1.9 gully 46: new_ = FALSE;
1.1 cvs 47: if (withUndo)
48: TtaRegisterAttributeReplace (attr, el, doc);
49: }
50: TtaSetAttributeValue (attr, XLink_ATTR_type_VAL_simple, el, doc);
1.9 gully 51: if (new_ && withUndo)
1.1 cvs 52: TtaRegisterAttributeCreate (attr, el, doc);
53: }
54:
55: /*----------------------------------------------------------------------
56: XLinkPasted
1.2 cvs 57: An element from any namespace has been pasted.
1.1 cvs 58: If it has some XLink attributes, update the link.
59: -----------------------------------------------------------------------*/
60: void XLinkPasted (NotifyElement *event)
61: {
1.2 cvs 62: Document originDocument;
1.7 cvs 63: ElementType elType;
1.2 cvs 64: AttributeType attrType;
1.7 cvs 65: Attribute attr = NULL;
1.2 cvs 66: SSchema XLinkSchema;
67:
1.7 cvs 68: XLinkSchema = TtaGetSSchema ("XLink", event->document);
69: if (XLinkSchema)
1.2 cvs 70: {
71: /* is there an href attribute from the XLink namespace? */
72: attrType.AttrSSchema = XLinkSchema;
73: attrType.AttrTypeNum = XLink_ATTR_href_;
74: attr = TtaGetAttribute (event->element, attrType);
75: if (attr)
1.7 cvs 76: {
77: /* the pasted element has an href attribute */
78: /* does the pasted element come from another document? */
79: originDocument = (Document) event->position;
80: if (originDocument >= 0 && originDocument != event->document)
81: {
82: /* Update the value of that attribute */
83: ChangeURI (event->element, attr, originDocument, event->document);
84: }
85: /* Set the XLink namespace declaration */
86: elType = TtaGetElementType (event->element);
87: TtaSetUriSSchema (elType.ElSSchema, XLink_URI);
88: TtaSetANamespaceDeclaration (event->document, event->element, XLink_PREFIX, XLink_URI);
89: }
1.2 cvs 90: }
1.7 cvs 91:
1.1 cvs 92: }
Webmaster