Annotation of Amaya/amaya/XLinkedit.c, revision 1.6
1.1 cvs 1: /*
2: *
1.6 ! vatton 3: * (c) COPYRIGHT MIT and INRIA, 2000-2002
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: *
11: * Author: V. Quint
12: *
13: */
14:
15: /* Included headerfiles */
16: #define THOT_EXPORT
17: #include "amaya.h"
18: #include "XLink.h"
19:
1.2 cvs 20: #include "HTMLedit_f.h"
21:
1.1 cvs 22: /*----------------------------------------------------------------------
23: SetXLinkTypeSimple attach an attribute xlink:type="simple" to element el
24: ----------------------------------------------------------------------*/
1.6 ! vatton 25: void SetXLinkTypeSimple (Element el, Document doc, ThotBool withUndo)
1.1 cvs 26: {
27: AttributeType attrType;
28: Attribute attr;
29: SSchema XLinkSchema;
30: ThotBool new;
31:
1.3 cvs 32: XLinkSchema = TtaGetSSchema ("XLink", doc);
1.1 cvs 33: attrType.AttrSSchema = XLinkSchema;
34: attrType.AttrTypeNum = XLink_ATTR_type;
35: attr = TtaGetAttribute (el, attrType);
36: if (attr == NULL)
37: {
38: attr = TtaNewAttribute (attrType);
39: TtaAttachAttribute (el, attr, doc);
40: new = TRUE;
41: }
42: else
43: {
44: new = FALSE;
45: if (withUndo)
46: TtaRegisterAttributeReplace (attr, el, doc);
47: }
48: TtaSetAttributeValue (attr, XLink_ATTR_type_VAL_simple, el, doc);
49: if (new && withUndo)
50: TtaRegisterAttributeCreate (attr, el, doc);
51: }
52:
53: /*----------------------------------------------------------------------
54: XLinkPasted
1.2 cvs 55: An element from any namespace has been pasted.
1.1 cvs 56: If it has some XLink attributes, update the link.
57: -----------------------------------------------------------------------*/
58: void XLinkPasted (NotifyElement *event)
59: {
1.2 cvs 60: Document originDocument;
61: AttributeType attrType;
62: Attribute attr;
63: SSchema XLinkSchema;
64:
65: /* does the pasted element come from another document? */
66: originDocument = (Document) event->position;
1.4 cvs 67: if (originDocument >= 0 && originDocument != event->document)
1.2 cvs 68: /* this element has changed document. Check its links */
69: {
1.3 cvs 70: XLinkSchema = TtaGetSSchema ("XLink", event->document);
1.2 cvs 71: if (XLinkSchema)
72: {
73: /* is there an href attribute from the XLink namespace? */
74: attrType.AttrSSchema = XLinkSchema;
75: attrType.AttrTypeNum = XLink_ATTR_href_;
76: attr = TtaGetAttribute (event->element, attrType);
77: if (attr)
78: /* the pasted element has an href attribute. Update the value
79: of that attribute */
80: ChangeURI (event->element, attr, originDocument, event->document);
81: }
82: }
1.1 cvs 83: }
Webmaster